[Libreoffice-commits] .: Branch 'feature/new-autofilter-popup' - sc/inc sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Fri Nov 4 09:19:03 PDT 2011
sc/inc/lookupcache.hxx | 2
sc/source/core/data/table3.cxx | 15 ++++--
sc/source/core/tool/interpr1.cxx | 51 ++++++++++++-----------
sc/source/filter/excel/excrecds.cxx | 20 ++++-----
sc/source/filter/inc/excrecds.hxx | 2
sc/source/filter/xml/XMLExportDataPilot.cxx | 10 ++--
sc/source/filter/xml/XMLExportDatabaseRanges.cxx | 4 -
sc/source/filter/xml/xmlfilti.cxx | 6 +-
sc/source/ui/dbgui/filtdlg.cxx | 20 ++++-----
sc/source/ui/dbgui/pfiltdlg.cxx | 12 ++---
sc/source/ui/view/gridwin.cxx | 20 ++++-----
11 files changed, 87 insertions(+), 75 deletions(-)
New commits:
commit de9f1649fc5b7b2c8d662f082c1c3c514f55d5fe
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 4 12:18:47 2011 -0400
More on avoiding direct access to pStr, also fixed several memory leaks.
diff --git a/sc/inc/lookupcache.hxx b/sc/inc/lookupcache.hxx
index 01ab425..cdf3b42 100644
--- a/sc/inc/lookupcache.hxx
+++ b/sc/inc/lookupcache.hxx
@@ -110,7 +110,7 @@ public:
DBG_ERRORFILE( "ScLookupCache::QueryCriteria not prepared for this ScQueryOp");
}
if (rEntry.bQueryByString)
- setString( rEntry.pStr);
+ setString(rEntry.GetQueryString());
else
setDouble( rEntry.nVal);
}
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 8f3c985..ec9657f 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1274,12 +1274,13 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
}
if ( !bRealRegExp )
{
+ rtl::OUString aQueryStr = rEntry.GetQueryString();
if ( rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL
|| rEntry.eOp == SC_CONTAINS || rEntry.eOp == SC_DOES_NOT_CONTAIN
|| rEntry.eOp == SC_BEGINS_WITH || rEntry.eOp == SC_ENDS_WITH
|| rEntry.eOp == SC_DOES_NOT_BEGIN_WITH || rEntry.eOp == SC_DOES_NOT_END_WITH )
{
- if ( !rEntry.bQueryByString && rEntry.pStr->Len() == 0 )
+ if (!rEntry.bQueryByString && aQueryStr.isEmpty())
{
// #i18374# When used from functions (match, countif, sumif, vlookup, hlookup, lookup),
// the query value is assigned directly, and the string is empty. In that case,
@@ -1290,7 +1291,7 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
}
else if ( bMatchWholeCell )
{
- bOk = pTransliteration->isEqual( aCellStr, *rEntry.pStr );
+ bOk = pTransliteration->isEqual(aCellStr, aQueryStr);
if ( rEntry.eOp == SC_NOT_EQUAL )
bOk = !bOk;
}
@@ -1300,7 +1301,7 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
aCellStr, ScGlobal::eLnge, 0, aCellStr.Len(),
NULL ) );
String aQuer( pTransliteration->transliterate(
- *rEntry.pStr, ScGlobal::eLnge, 0, rEntry.pStr->Len(),
+ aQueryStr, ScGlobal::eLnge, 0, aQueryStr.getLength(),
NULL ) );
xub_StrLen nIndex = (rEntry.eOp == SC_ENDS_WITH
|| rEntry.eOp == SC_DOES_NOT_END_WITH)? (aCell.Len()-aQuer.Len()):0;
@@ -1337,7 +1338,7 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
else
{ // use collator here because data was probably sorted
sal_Int32 nCompare = pCollator->compareString(
- aCellStr, *rEntry.pStr );
+ aCellStr, aQueryStr);
switch (rEntry.eOp)
{
case SC_LESS :
@@ -1559,7 +1560,7 @@ static void lcl_PrepareQuery( ScDocument* pDoc, ScTable* pTab, ScQueryParam& rPa
{
sal_uInt32 nIndex = 0;
rEntry.bQueryByString = !( pDoc->GetFormatTable()->
- IsNumberFormat( *rEntry.pStr, nIndex, rEntry.nVal ) );
+ IsNumberFormat(rEntry.GetQueryString(), nIndex, rEntry.nVal));
if (rEntry.bQueryByDate)
{
if (!rEntry.bQueryByString && ((nIndex % SV_COUNTRY_LANGUAGE_OFFSET) != 0))
@@ -1903,7 +1904,9 @@ bool ScTable::CreateStarQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2
// Vierte Spalte Wert
if (bValid)
{
- GetString(nCol1 + 3, nRow, *rEntry.pStr);
+ String aStr;
+ GetString(nCol1 + 3, nRow, aStr);
+ rEntry.SetQueryString(aStr);
rEntry.bDoQuery = true;
}
nIndex++;
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 3fc28bb..6c42369 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -721,7 +721,7 @@ double ScInterpreter::CompareFunc( const ScCompare& rComp, ScCompareOptions* pOp
// is/must be identical to *rEntry.pStr, which is essential for
// regex to work through GetSearchTextPtr().
ScQueryEntry& rEntry = pOptions->aQueryEntry;
- OSL_ENSURE( *rComp.pVal[1] == *rEntry.pStr, "ScInterpreter::CompareFunc: broken options");
+ OSL_ENSURE(rEntry.GetQueryString().equals(*rComp.pVal[1]), "ScInterpreter::CompareFunc: broken options");
if (pOptions->bRegEx)
{
xub_StrLen nStart = 0;
@@ -999,7 +999,7 @@ ScMatrixRef ScInterpreter::QueryMat( const ScMatrixRef& pMat, ScCompareOptions&
short nSaveFuncFmtType = nFuncFmtType;
PushMatrix( pMat);
if (rOptions.aQueryEntry.bQueryByString)
- PushString( *rOptions.aQueryEntry.pStr);
+ PushString(rOptions.aQueryEntry.GetQueryString());
else
PushDouble( rOptions.aQueryEntry.nVal);
ScMatrixRef pResultMatrix = CompareMat( &rOptions);
@@ -4321,8 +4321,8 @@ static sal_Int32 lcl_CompareMatrix2Query(
// this should not happen!
return 1;
- const String& rStr1 = rMat.GetString(i);
- const String& rStr2 = *rEntry.pStr;
+ const rtl::OUString rStr1 = rMat.GetString(i);
+ const rtl::OUString rStr2 = rEntry.GetQueryString();
return ScGlobal::GetCollator()->compareString( rStr1, rStr2); // case-insensitive
}
@@ -4465,7 +4465,7 @@ void ScInterpreter::ScMatch()
{
sStr = GetString();
rEntry.bQueryByString = true;
- *rEntry.pStr = sStr;
+ rEntry.SetQueryString(sStr);
}
break;
case svDoubleRef :
@@ -4488,7 +4488,7 @@ void ScInterpreter::ScMatch()
{
GetCellString(sStr, pCell);
rEntry.bQueryByString = true;
- *rEntry.pStr = sStr;
+ rEntry.SetQueryString(sStr);
}
}
break;
@@ -4509,7 +4509,7 @@ void ScInterpreter::ScMatch()
else
{
rEntry.bQueryByString = true;
- *rEntry.pStr = pToken->GetString();
+ rEntry.SetQueryString(pToken->GetString());
}
}
break;
@@ -4520,8 +4520,10 @@ void ScInterpreter::ScMatch()
break;
case svMatrix :
{
+ String aStr;
ScMatValType nType = GetDoubleOrStringFromMatrix(
- rEntry.nVal, *rEntry.pStr);
+ rEntry.nVal, aStr);
+ rEntry.SetQueryString(aStr);
rEntry.bQueryByString = ScMatrix::IsNonValueType( nType);
}
break;
@@ -4541,7 +4543,7 @@ void ScInterpreter::ScMatch()
if ( bIsVBAMode )
rParam.bRegExp = false;
else
- rParam.bRegExp = MayBeRegExp( *rEntry.pStr, pDok );
+ rParam.bRegExp = MayBeRegExp(rEntry.GetQueryString(), pDok);
}
if (pMatSrc) // The source data is matrix array.
@@ -4887,9 +4889,9 @@ void ScInterpreter::ScCountIf()
sal_uInt32 nIndex = 0;
rEntry.bQueryByString =
!(pFormatter->IsNumberFormat(
- *rEntry.pStr, nIndex, rEntry.nVal));
+ rEntry.GetQueryString(), nIndex, rEntry.nVal));
if ( rEntry.bQueryByString )
- rParam.bRegExp = MayBeRegExp( *rEntry.pStr, pDok );
+ rParam.bRegExp = MayBeRegExp(rEntry.GetQueryString(), pDok);
}
rParam.nCol1 = nCol1;
rParam.nCol2 = nCol2;
@@ -5209,9 +5211,9 @@ void ScInterpreter::ScSumIf()
sal_uInt32 nIndex = 0;
rEntry.bQueryByString =
!(pFormatter->IsNumberFormat(
- *rEntry.pStr, nIndex, rEntry.nVal));
+ rEntry.GetQueryString(), nIndex, rEntry.nVal));
if ( rEntry.bQueryByString )
- rParam.bRegExp = MayBeRegExp( *rEntry.pStr, pDok );
+ rParam.bRegExp = MayBeRegExp(rEntry.GetQueryString(), pDok);
}
ScAddress aAdr;
aAdr.SetTab( nTab3 );
@@ -5528,7 +5530,7 @@ void ScInterpreter::ScLookup()
if ( !rEntry.bQueryByString )
bFound = false;
else
- bFound = (ScGlobal::GetCollator()->compareString( aDataStr, *rEntry.pStr) <= 0);
+ bFound = (ScGlobal::GetCollator()->compareString(aDataStr, rEntry.GetQueryString()) <= 0);
}
if (!bFound)
@@ -5773,7 +5775,7 @@ void ScInterpreter::ScLookup()
rEntry.eOp = SC_LESS_EQUAL;
rEntry.nField = nCol1;
if ( rEntry.bQueryByString )
- aParam.bRegExp = MayBeRegExp( *rEntry.pStr, pDok );
+ aParam.bRegExp = MayBeRegExp(rEntry.GetQueryString(), pDok);
ScQueryCellIterator aCellIter(pDok, nTab1, aParam, false);
SCCOL nC;
@@ -5996,7 +5998,7 @@ void ScInterpreter::CalculateLookup(bool HLookup)
if ( !FillEntry(rEntry) )
return;
if ( rEntry.bQueryByString )
- rParam.bRegExp = MayBeRegExp( *rEntry.pStr, pDok );
+ rParam.bRegExp = MayBeRegExp(rEntry.GetQueryString(), pDok);
if (pMat)
{
SCSIZE nMatCount = HLookup ? nC : nR;
@@ -6006,7 +6008,7 @@ void ScInterpreter::CalculateLookup(bool HLookup)
//!!!!!!!
//! TODO: enable regex on matrix strings
//!!!!!!!
- String aParamStr = *rEntry.pStr;
+ rtl::OUString aParamStr = rEntry.GetQueryString();
if ( bSorted )
{
static CollatorWrapper* pCollator = ScGlobal::GetCollator();
@@ -6148,9 +6150,9 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry)
break;
case svString:
{
- const String sStr = GetString();
+ const String& sStr = GetString();
rEntry.bQueryByString = true;
- *rEntry.pStr = sStr;
+ rEntry.SetQueryString(sStr);
}
break;
case svDoubleRef :
@@ -6180,14 +6182,16 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry)
String sStr;
GetCellString(sStr, pCell);
rEntry.bQueryByString = true;
- *rEntry.pStr = sStr;
+ rEntry.SetQueryString(sStr);
}
}
}
break;
case svMatrix :
{
- const ScMatValType nType = GetDoubleOrStringFromMatrix(rEntry.nVal, *rEntry.pStr);
+ String aStr;
+ const ScMatValType nType = GetDoubleOrStringFromMatrix(rEntry.nVal, aStr);
+ rEntry.SetQueryString(aStr);
rEntry.bQueryByString = ScMatrix::IsNonValueType( nType);
}
break;
@@ -6371,10 +6375,11 @@ ScDBQueryParamBase* ScInterpreter::GetDBParams( bool& rMissingField )
if ( rEntry.bDoQuery )
{
sal_uInt32 nIndex = 0;
+ rtl::OUString aQueryStr = rEntry.GetQueryString();
rEntry.bQueryByString = !pFormatter->IsNumberFormat(
- *rEntry.pStr, nIndex, rEntry.nVal );
+ aQueryStr, nIndex, rEntry.nVal );
if ( rEntry.bQueryByString && !pParam->bRegExp )
- pParam->bRegExp = MayBeRegExp( *rEntry.pStr, pDok );
+ pParam->bRegExp = MayBeRegExp(aQueryStr, pDok);
}
else
break; // for
diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx
index 4ec4d53..dfa2fc0 100644
--- a/sc/source/filter/excel/excrecds.cxx
+++ b/sc/source/filter/excel/excrecds.cxx
@@ -677,14 +677,14 @@ sal_Bool XclExpAutofilter::AddCondition( ScQueryConnect eConn, sal_uInt8 nType,
return sal_True;
}
-sal_Bool XclExpAutofilter::AddEntry( const ScQueryEntry& rEntry )
+bool XclExpAutofilter::AddEntry( const ScQueryEntry& rEntry )
{
- sal_Bool bConflict = false;
+ bool bConflict = false;
String sText;
-
- if( rEntry.pStr )
+ rtl::OUString aQueryStr = rEntry.GetQueryString();
+ if (!aQueryStr.isEmpty())
{
- sText.Assign( *rEntry.pStr );
+ sText.Assign(aQueryStr);
switch( rEntry.eOp )
{
case SC_CONTAINS:
@@ -709,19 +709,19 @@ sal_Bool XclExpAutofilter::AddEntry( const ScQueryEntry& rEntry )
}
}
- sal_Bool bLen = sText.Len() > 0;
+ bool bLen = sText.Len() > 0;
// empty/nonempty fields
if( !bLen && (rEntry.nVal == SC_EMPTYFIELDS) )
- bConflict = !AddCondition( rEntry.eConnect, EXC_AFTYPE_EMPTY, EXC_AFOPER_NONE, 0.0, NULL, sal_True );
+ bConflict = !AddCondition( rEntry.eConnect, EXC_AFTYPE_EMPTY, EXC_AFOPER_NONE, 0.0, NULL, true );
else if( !bLen && (rEntry.nVal == SC_NONEMPTYFIELDS) )
- bConflict = !AddCondition( rEntry.eConnect, EXC_AFTYPE_NOTEMPTY, EXC_AFOPER_NONE, 0.0, NULL, sal_True );
+ bConflict = !AddCondition( rEntry.eConnect, EXC_AFTYPE_NOTEMPTY, EXC_AFOPER_NONE, 0.0, NULL, true );
// other conditions
else
{
double fVal = 0.0;
sal_uInt32 nIndex = 0;
- sal_Bool bIsNum = bLen ? GetFormatter().IsNumberFormat( sText, nIndex, fVal ) : sal_True;
+ bool bIsNum = bLen ? GetFormatter().IsNumberFormat( sText, nIndex, fVal ) : true;
String* pText = bIsNum ? NULL : &sText;
// top10 flags
@@ -742,7 +742,7 @@ sal_Bool XclExpAutofilter::AddEntry( const ScQueryEntry& rEntry )
break;
default:;
}
- sal_Bool bNewTop10 = ::get_flag( nNewFlags, EXC_AFFLAG_TOP10 );
+ bool bNewTop10 = ::get_flag( nNewFlags, EXC_AFFLAG_TOP10 );
bConflict = HasTop10() && bNewTop10;
if( !bConflict )
diff --git a/sc/source/filter/inc/excrecds.hxx b/sc/source/filter/inc/excrecds.hxx
index 9689d01..747ca08 100644
--- a/sc/source/filter/inc/excrecds.hxx
+++ b/sc/source/filter/inc/excrecds.hxx
@@ -420,7 +420,7 @@ public:
inline sal_Bool HasCondition() const { return !aCond[ 0 ].IsEmpty(); }
inline sal_Bool HasTop10() const { return ::get_flag( nFlags, EXC_AFFLAG_TOP10 ); }
- sal_Bool AddEntry( const ScQueryEntry& rEntry );
+ bool AddEntry( const ScQueryEntry& rEntry );
virtual void SaveXml( XclExpXmlStream& rStrm );
};
diff --git a/sc/source/filter/xml/XMLExportDataPilot.cxx b/sc/source/filter/xml/XMLExportDataPilot.cxx
index 844b9fc..8a70167 100644
--- a/sc/source/filter/xml/XMLExportDataPilot.cxx
+++ b/sc/source/filter/xml/XMLExportDataPilot.cxx
@@ -134,17 +134,19 @@ void ScXMLExportDataPilot::WriteDPCondition(const ScQueryEntry& aQueryEntry, boo
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, rtl::OUString::valueOf(sal_Int32(aQueryEntry.nField)));
if (bIsCaseSensitive)
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TRUE);
+ rtl::OUString aQueryStr = aQueryEntry.GetQueryString();
if (aQueryEntry.bQueryByString)
{
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE, *aQueryEntry.pStr);
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE, aQueryStr);
}
else
{
rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_NUMBER);
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE, rtl::OUString(*aQueryEntry.pStr));
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE, aQueryStr);
}
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_OPERATOR, getDPOperatorXML(aQueryEntry.eOp, bUseRegularExpressions,
- aQueryEntry.bQueryByString, aQueryEntry.nVal, *aQueryEntry.pStr));
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_OPERATOR,
+ getDPOperatorXML(aQueryEntry.eOp, bUseRegularExpressions,
+ aQueryEntry.bQueryByString, aQueryEntry.nVal, aQueryStr));
SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_FILTER_CONDITION, true, true);
}
diff --git a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
index 9fb61fa..4a757bc 100644
--- a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
+++ b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
@@ -844,7 +844,7 @@ private:
case SC_ENDS_WITH:
return GetXMLToken(XML_ENDS_WITH);
case SC_EQUAL:
- if (!rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING)
+ if (!rEntry.bQueryByString && rEntry.GetQueryString().isEmpty())
{
if (rEntry.nVal == SC_EMPTYFIELDS)
return GetXMLToken(XML_EMPTY);
@@ -884,7 +884,7 @@ private:
if (bCaseSens)
mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TRUE);
if (rEntry.bQueryByString)
- mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE, *rEntry.pStr);
+ mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE, rEntry.GetQueryString());
else
{
mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_NUMBER);
diff --git a/sc/source/filter/xml/xmlfilti.cxx b/sc/source/filter/xml/xmlfilti.cxx
index b7cd8fa..baf9f9c 100644
--- a/sc/source/filter/xml/xmlfilti.cxx
+++ b/sc/source/filter/xml/xmlfilti.cxx
@@ -765,17 +765,17 @@ void ScXMLDPConditionContext::EndElement()
if (IsXMLToken(sDataType, XML_NUMBER))
{
aFilterField.nVal = sConditionValue.toDouble();
- *aFilterField.pStr = sConditionValue;
+ aFilterField.SetQueryString(sConditionValue);
aFilterField.bQueryByString = false;
if (dVal != 0.0)
{
aFilterField.nVal = dVal;
- *aFilterField.pStr = EMPTY_STRING;
+ aFilterField.SetQueryString(rtl::OUString());
}
}
else
{
- aFilterField.pStr = new String(sConditionValue);
+ aFilterField.SetQueryString(sConditionValue);
aFilterField.bQueryByString = true;
aFilterField.nVal = 0;
}
diff --git a/sc/source/ui/dbgui/filtdlg.cxx b/sc/source/ui/dbgui/filtdlg.cxx
index 4f949c4..2b332ff 100644
--- a/sc/source/ui/dbgui/filtdlg.cxx
+++ b/sc/source/ui/dbgui/filtdlg.cxx
@@ -311,18 +311,19 @@ void ScFilterDlg::Init( const SfxItemSet& rArgSet )
{
nCondPos = (sal_uInt16)rEntry.eOp;
nFieldSelPos = GetFieldSelPos( static_cast<SCCOL>(rEntry.nField) );
- if ( rEntry.nVal == SC_EMPTYFIELDS && !rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING )
+ bool bEmptyString = rEntry.GetQueryString().isEmpty();
+ if (rEntry.nVal == SC_EMPTYFIELDS && !rEntry.bQueryByString && bEmptyString)
{
aValStr = aStrEmpty;
aCondLbArr[i]->Disable();
}
- else if ( rEntry.nVal == SC_NONEMPTYFIELDS && !rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING )
+ else if (rEntry.nVal == SC_NONEMPTYFIELDS && !rEntry.bQueryByString && bEmptyString)
{
aValStr = aStrNotEmpty;
aCondLbArr[i]->Disable();
}
else
- aValStr = *rEntry.pStr;
+ aValStr = rEntry.GetQueryString();
}
else if ( i == 0 )
{
@@ -1145,19 +1146,19 @@ IMPL_LINK( ScFilterDlg, ValModifyHdl, ComboBox*, pEd )
{
if ( aStrEmpty.equals(aStrVal) )
{
- rEntry.pStr->Erase();
+ rEntry.SetQueryString(rtl::OUString());
rEntry.nVal = SC_EMPTYFIELDS;
rEntry.bQueryByString = false;
}
else if ( aStrNotEmpty.equals(aStrVal) )
{
- rEntry.pStr->Erase();
+ rEntry.SetQueryString(rtl::OUString());
rEntry.nVal = SC_NONEMPTYFIELDS;
rEntry.bQueryByString = false;
}
else
{
- *rEntry.pStr = aStrVal;
+ rEntry.SetQueryString(aStrVal);
rEntry.nVal = 0;
rEntry.bQueryByString = true;
}
@@ -1217,19 +1218,20 @@ void ScFilterDlg::RefreshEditRow( size_t nOffset )
if(rEntry.bDoQuery)
nFieldSelPos = GetFieldSelPos( static_cast<SCCOL>(rEntry.nField) );
- if ( rEntry.nVal == SC_EMPTYFIELDS && !rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING )
+ rtl::OUString aQueryStr = rEntry.GetQueryString();
+ if ( rEntry.nVal == SC_EMPTYFIELDS && !rEntry.bQueryByString && aQueryStr.isEmpty())
{
aValStr = aStrEmpty;
aCondLbArr[i]->Disable();
}
- else if ( rEntry.nVal == SC_NONEMPTYFIELDS && !rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING )
+ else if ( rEntry.nVal == SC_NONEMPTYFIELDS && !rEntry.bQueryByString && aQueryStr.isEmpty())
{
aValStr = aStrNotEmpty;
aCondLbArr[i]->Disable();
}
else
{
- aValStr = *rEntry.pStr;
+ aValStr = aQueryStr;
aCondLbArr[i]->Enable();
}
aFieldLbArr[i]->Enable();
diff --git a/sc/source/ui/dbgui/pfiltdlg.cxx b/sc/source/ui/dbgui/pfiltdlg.cxx
index 171a2b5..c776021 100644
--- a/sc/source/ui/dbgui/pfiltdlg.cxx
+++ b/sc/source/ui/dbgui/pfiltdlg.cxx
@@ -215,8 +215,8 @@ void ScPivotFilterDlg::Init( const SfxItemSet& rArgSet )
{
const ScQueryEntry& rEntry = theQueryData.GetEntry(i);
- String aValStr = *rEntry.pStr;
- if (!rEntry.bQueryByString && aValStr == EMPTY_STRING)
+ rtl::OUString aValStr = rEntry.GetQueryString();
+ if (!rEntry.bQueryByString && aValStr.isEmpty())
{
if (rEntry.nVal == SC_EMPTYFIELDS)
aValStr = aStrEmpty;
@@ -230,7 +230,7 @@ void ScPivotFilterDlg::Init( const SfxItemSet& rArgSet )
aCondLbArr [i]->SelectEntryPos( nCondPos );
UpdateValueList( static_cast<sal_uInt16>(i+1) );
aValueEdArr[i]->SetText( aValStr );
- if (aValStr == aStrEmpty || aValStr == aStrNotEmpty)
+ if (aValStr.equals(aStrEmpty) || aValStr.equals(aStrNotEmpty))
aCondLbArr[i]->Disable();
}
else
@@ -426,19 +426,19 @@ const ScQueryItem& ScPivotFilterDlg::GetOutputItem()
*/
if ( aStrVal == aStrEmpty )
{
- *rEntry.pStr = EMPTY_STRING;
+ rEntry.SetQueryString(rtl::OUString());
rEntry.nVal = SC_EMPTYFIELDS;
rEntry.bQueryByString = false;
}
else if ( aStrVal == aStrNotEmpty )
{
- *rEntry.pStr = EMPTY_STRING;
+ rEntry.SetQueryString(rtl::OUString());
rEntry.nVal = SC_NONEMPTYFIELDS;
rEntry.bQueryByString = false;
}
else
{
- *rEntry.pStr = aStrVal;
+ rEntry.SetQueryString(aStrVal);
rEntry.nVal = 0;
rEntry.bQueryByString = sal_True;
}
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 14aeaa1..dc7ff54 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -695,7 +695,7 @@ void ScGridWindow::UpdateAutoFilterFromMenu()
ScQueryEntry& rEntry = aParam.GetEntry(0);
rEntry.bDoQuery = true;
rEntry.bQueryByString = true;
- rEntry.pStr = new String(aSelected[0]);
+ rEntry.SetQueryString(aSelected[0]);
pViewData->GetView()->Query(aParam, NULL, true);
pDBData->SetQueryParam(aParam);
@@ -1169,16 +1169,15 @@ void ScGridWindow::LaunchDataSelectMenu( SCCOL nCol, SCROW nRow, bool bDataSelec
bValid = false;
if (rEntry.nField == nCol)
{
+ rtl::OUString aQueryStr = rEntry.GetQueryString();
if (rEntry.eOp == SC_EQUAL)
{
- String* pStr = rEntry.pStr;
- if (pStr)
+ if (!aQueryStr.isEmpty())
{
- nSelPos = pFilterBox->GetEntryPos( *pStr );
+ nSelPos = pFilterBox->GetEntryPos(aQueryStr);
}
}
- else if (rEntry.eOp == SC_TOPVAL && rEntry.pStr &&
- rEntry.pStr->EqualsAscii("10"))
+ else if (rEntry.eOp == SC_TOPVAL && aQueryStr.equalsAscii("10"))
nSelPos = SC_AUTOFILTER_TOP10;
else
nSelPos = SC_AUTOFILTER_CUSTOM;
@@ -1391,11 +1390,12 @@ void ScGridWindow::ExecFilter( sal_uLong nSel,
if ( nSel == SC_AUTOFILTER_TOP10 )
{
rNewEntry.eOp = SC_TOPVAL;
- *rNewEntry.pStr = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("10"));
+ rNewEntry.SetQueryString(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("10")));
}
else if (nSel == SC_AUTOFILTER_EMPTY)
{
- rNewEntry.pStr->Erase();
+ rNewEntry.SetQueryString(rtl::OUString());
rNewEntry.bQueryByString = false;
rNewEntry.eOp = SC_EQUAL;
rNewEntry.nVal = SC_EMPTYFIELDS;
@@ -1403,7 +1403,7 @@ void ScGridWindow::ExecFilter( sal_uLong nSel,
}
else if (nSel == SC_AUTOFILTER_NOTEMPTY)
{
- rNewEntry.pStr->Erase();
+ rNewEntry.SetQueryString(rtl::OUString());
rNewEntry.bQueryByString = false;
rNewEntry.eOp = SC_EQUAL;
rNewEntry.nVal = SC_NONEMPTYFIELDS;
@@ -1411,7 +1411,7 @@ void ScGridWindow::ExecFilter( sal_uLong nSel,
else
{
rNewEntry.eOp = SC_EQUAL;
- *rNewEntry.pStr = aValue;
+ rNewEntry.SetQueryString(aValue);
}
if (nQueryPos > 0)
rNewEntry.eConnect = SC_AND;
More information about the Libreoffice-commits
mailing list