[Libreoffice-commits] .: 22 commits - sc/inc sc/source svl/inc svl/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Fri Nov 4 19:41:29 PDT 2011
sc/inc/global.hxx | 41 ----
sc/inc/lookupcache.hxx | 3
sc/inc/queryparam.hxx | 57 ++++++
sc/inc/table.hxx | 6
sc/source/core/data/dociter.cxx | 18 --
sc/source/core/data/dpshttab.cxx | 6
sc/source/core/data/dptablecache.cxx | 20 +-
sc/source/core/data/global2.cxx | 106 ------------
sc/source/core/data/table2.cxx | 6
sc/source/core/data/table3.cxx | 175 +++++++++++++------
sc/source/core/tool/dbdata.cxx | 9 -
sc/source/core/tool/doubleref.cxx | 4
sc/source/core/tool/interpr1.cxx | 55 +++---
sc/source/core/tool/queryparam.cxx | 203 ++++++++++++++++++++---
sc/source/filter/excel/excimp8.cxx | 74 ++++----
sc/source/filter/excel/excrecds.cxx | 20 +-
sc/source/filter/inc/excimp8.hxx | 2
sc/source/filter/inc/excrecds.hxx | 3
sc/source/filter/xml/XMLExportDataPilot.cxx | 10 -
sc/source/filter/xml/XMLExportDataPilot.hxx | 1
sc/source/filter/xml/XMLExportDatabaseRanges.cxx | 4
sc/source/filter/xml/xmldrani.cxx | 2
sc/source/filter/xml/xmlfilti.cxx | 6
sc/source/ui/cctrl/checklistmenu.cxx | 192 ++++++++++++---------
sc/source/ui/dbgui/filtdlg.cxx | 138 +++++++++------
sc/source/ui/dbgui/pfiltdlg.cxx | 14 -
sc/source/ui/dbgui/sfiltdlg.cxx | 10 -
sc/source/ui/inc/checklistmenu.hxx | 14 +
sc/source/ui/inc/filtdlg.hxx | 11 -
sc/source/ui/inc/gridwin.hxx | 10 -
sc/source/ui/unoobj/cellsuno.cxx | 6
sc/source/ui/unoobj/datauno.cxx | 50 ++---
sc/source/ui/vba/vbarange.cxx | 5
sc/source/ui/view/gridwin.cxx | 155 +++++++++++++++--
sc/source/ui/view/gridwin2.cxx | 26 ++
sc/source/ui/view/gridwin4.cxx | 6
sc/source/ui/view/tabview.cxx | 9 -
svl/inc/svl/zforlist.hxx | 5
svl/source/numbers/zforlist.cxx | 9 +
39 files changed, 920 insertions(+), 571 deletions(-)
New commits:
commit 5f059974b7778904c4bffa169e07e1d0aee90951
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 4 22:36:32 2011 -0400
Temporarily disabling the new autofilter popup due to a set-back.
Ugh! I need to refactor the query validation code first before working
on the new popup. I will
1) temporarily disable the new autofilter popup,
2) merge my changes so far to master, and
3) work on refactoring the query validation code without changing the
current functionality, then come back to working on the new popup.
Darn...
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 00827d9..4271df2 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -42,6 +42,8 @@
#include <memory>
#include <boost/scoped_ptr.hpp>
+#define USE_NEW_AUTOFILTER 0
+
// ---------------------------------------------------------------------------
struct ScTableInfo;
@@ -341,8 +343,10 @@ public:
void LaunchDataSelectMenu( SCCOL nCol, SCROW nRow, bool bDataSelect );
void DoScenarioMenue( const ScRange& rScenRange );
-
+#if USE_NEW_AUTOFILTER
void LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow);
+ void UpdateAutoFilterFromMenu();
+#endif
void LaunchPageFieldMenu( SCCOL nCol, SCROW nRow );
void LaunchDPFieldMenu( SCCOL nCol, SCROW nRow );
@@ -379,7 +383,6 @@ public:
void CheckNeedsRepaint();
- void UpdateAutoFilterFromMenu();
void UpdateDPFromFieldPopupMenu();
void UpdateVisibleRange();
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index dc7ff54..8293b6f 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -585,6 +585,7 @@ void ScGridWindow::ExecPageFieldSelect( SCCOL nCol, SCROW nRow, sal_Bool bHasSel
}
}
+#if USE_NEW_AUTOFILTER
namespace {
class PopupAction : public ScMenuFloatingWindow::Action
@@ -700,6 +701,7 @@ void ScGridWindow::UpdateAutoFilterFromMenu()
pViewData->GetView()->Query(aParam, NULL, true);
pDBData->SetQueryParam(aParam);
}
+#endif
void ScGridWindow::LaunchPageFieldMenu( SCCOL nCol, SCROW nRow )
{
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index 2688e04..a3ecaae 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -165,7 +165,11 @@ bool ScGridWindow::DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent&
HideCursor();
mpFilterButton->draw();
ShowCursor();
+#if USE_NEW_AUTOFILTER
LaunchAutoFilterMenu(nCol, nRow);
+#else
+ LaunchDataSelectMenu(nCol, nRow, false);
+#endif
return true;
}
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 6e6863a..6804c36 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2403,10 +2403,14 @@ void ScTabView::StartDataSelect()
aViewData.GetDocument()->GetAttr(
nCol, nRow, aViewData.GetTabNo(), ATTR_MERGE_FLAG));
+#if USE_NEW_AUTOFILTER
if (pAttr->HasAutoFilter())
pWin->LaunchAutoFilterMenu(nCol, nRow);
else
pWin->LaunchDataSelectMenu(nCol, nRow, true);
+#else
+ pWin->LaunchDataSelectMenu(nCol, nRow, !pAttr->HasAutoFilter());
+#endif
}
void ScTabView::EnableRefInput(bool bFlag)
commit a1675f6d7691d57df1c80537e1be257172aa9d49
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 4 21:25:49 2011 -0400
Hide the query strings member, and add relevant methods for it.
diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx
index f3d755c..6b87397 100644
--- a/sc/inc/queryparam.hxx
+++ b/sc/inc/queryparam.hxx
@@ -52,9 +52,8 @@ namespace utl {
struct ScQueryEntry
{
-private:
- String* pStr;
-public:
+ typedef std::vector<rtl::OUString> QueryStringsType;
+
bool bDoQuery;
bool bQueryByString;
bool bQueryByDate;
@@ -74,11 +73,15 @@ public:
bool IsQueryStringEmpty() const;
bool MatchByString(const rtl::OUString& rStr, bool bCaseSens) const;
+ void SwapQueryStrings(QueryStringsType& rStrings);
+ void SortQueryStrings(bool bCaseSens);
SC_DLLPUBLIC void SetQueryString(const rtl::OUString& rStr);
SC_DLLPUBLIC rtl::OUString GetQueryString() const;
void Clear();
ScQueryEntry& operator=( const ScQueryEntry& r );
bool operator==( const ScQueryEntry& r ) const;
+private:
+ QueryStringsType maQueryStrings;
};
struct ScQueryParamBase
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 7cae817..31ad25a 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1614,6 +1614,8 @@ static void lcl_PrepareQuery( ScDocument* pDoc, ScTable* pTab, ScQueryParam& rPa
ScQueryEntry& rEntry = rParam.GetEntry(i);
if ( rEntry.bDoQuery )
{
+ rEntry.SortQueryStrings(rParam.bCaseSens);
+
if ( rEntry.bQueryByString )
{
sal_uInt32 nIndex = 0;
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index ca7d3a2..29fdb8b 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -34,6 +34,7 @@
#include "queryparam.hxx"
#include <unotools/textsearch.hxx>
#include <unotools/transliterationwrapper.hxx>
+#include <unotools/collatorwrapper.hxx>
using ::std::vector;
@@ -44,7 +45,6 @@ const SCSIZE MAXQUERY = 8;
}
ScQueryEntry::ScQueryEntry() :
- pStr(new String),
bDoQuery(false),
bQueryByString(false),
bQueryByDate(false),
@@ -58,7 +58,6 @@ ScQueryEntry::ScQueryEntry() :
}
ScQueryEntry::ScQueryEntry(const ScQueryEntry& r) :
- pStr(new String(*r.pStr)),
bDoQuery(r.bDoQuery),
bQueryByString(r.bQueryByString),
bQueryByDate(r.bQueryByDate),
@@ -67,13 +66,13 @@ ScQueryEntry::ScQueryEntry(const ScQueryEntry& r) :
eConnect(r.eConnect),
nVal(r.nVal),
pSearchParam(NULL),
- pSearchText(NULL)
+ pSearchText(NULL),
+ maQueryStrings(r.maQueryStrings)
{
}
ScQueryEntry::~ScQueryEntry()
{
- delete pStr;
delete pSearchParam;
delete pSearchText;
}
@@ -87,7 +86,7 @@ ScQueryEntry& ScQueryEntry::operator=( const ScQueryEntry& r )
eConnect = r.eConnect;
nField = r.nField;
nVal = r.nVal;
- *pStr = *r.pStr;
+ maQueryStrings = r.maQueryStrings;
delete pSearchParam;
delete pSearchText;
@@ -99,24 +98,62 @@ ScQueryEntry& ScQueryEntry::operator=( const ScQueryEntry& r )
bool ScQueryEntry::IsQueryStringEmpty() const
{
- return pStr->Len() == 0;
+ return maQueryStrings.empty();
+}
+
+namespace {
+
+class CompareString : std::binary_function<rtl::OUString, rtl::OUString, bool>
+{
+ CollatorWrapper* mpCollator;
+public:
+ CompareString(bool bCaseSens) :
+ mpCollator(
+ bCaseSens ? ScGlobal::GetCaseCollator() : ScGlobal::GetCollator())
+ {}
+
+ bool operator() (const rtl::OUString& rL, const rtl::OUString& rR) const
+ {
+ return mpCollator->compareString(rL, rR) < 0;
+ }
+};
+
}
bool ScQueryEntry::MatchByString(const rtl::OUString& rStr, bool bCaseSens) const
{
- utl::TransliterationWrapper* pTransliteration = bCaseSens ?
- ScGlobal::GetCaseTransliteration() : ScGlobal::GetpTransliteration();
- return pTransliteration->isEqual(rStr, *pStr);
+ QueryStringsType::const_iterator itr =
+ std::lower_bound(
+ maQueryStrings.begin(), maQueryStrings.end(), rStr, CompareString(bCaseSens));
+
+ if (itr == maQueryStrings.end())
+ return false;
+
+ utl::TransliterationWrapper* pTransliteration =
+ bCaseSens ? ScGlobal::GetCaseTransliteration() : ScGlobal::GetpTransliteration();
+ return pTransliteration->isEqual(rStr, *itr);
+}
+
+void ScQueryEntry::SwapQueryStrings(QueryStringsType& rStrings)
+{
+ maQueryStrings.swap(rStrings);
+}
+
+void ScQueryEntry::SortQueryStrings(bool bCaseSens)
+{
+ std::sort(maQueryStrings.begin(), maQueryStrings.end(), CompareString(bCaseSens));
}
void ScQueryEntry::SetQueryString(const rtl::OUString& rStr)
{
- *pStr = String(rStr);
+ maQueryStrings.clear();
+ if (!rStr.isEmpty())
+ maQueryStrings.push_back(rStr);
}
rtl::OUString ScQueryEntry::GetQueryString() const
{
- return *pStr;
+ return maQueryStrings.empty() ? rtl::OUString() : maQueryStrings[0];
}
void ScQueryEntry::Clear()
@@ -128,7 +165,7 @@ void ScQueryEntry::Clear()
eConnect = SC_AND;
nField = 0;
nVal = 0.0;
- pStr->Erase();
+ maQueryStrings.clear();
delete pSearchParam;
delete pSearchText;
@@ -145,7 +182,7 @@ bool ScQueryEntry::operator==( const ScQueryEntry& r ) const
&& eConnect == r.eConnect
&& nField == r.nField
&& nVal == r.nVal
- && *pStr == *r.pStr;
+ && maQueryStrings == r.maQueryStrings;
//! pSearchParam und pSearchText nicht vergleichen
}
@@ -153,8 +190,11 @@ utl::TextSearch* ScQueryEntry::GetSearchTextPtr( bool bCaseSens ) const
{
if ( !pSearchParam )
{
- pSearchParam = new utl::SearchParam( *pStr, utl::SearchParam::SRCH_REGEXP,
- bCaseSens, false, false );
+ rtl::OUString aStr;
+ if (!maQueryStrings.empty())
+ aStr = maQueryStrings[0];
+ pSearchParam = new utl::SearchParam(
+ aStr, utl::SearchParam::SRCH_REGEXP, bCaseSens, false, false);
pSearchText = new utl::TextSearch( *pSearchParam, *ScGlobal::pCharClass );
}
return pSearchText;
commit 369d2726c7a43f53cafac21520fd0b307f478254
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 4 16:13:17 2011 -0400
Do the simple string equality matching in ScQueryEntry instead.
diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx
index 79330ae..f3d755c 100644
--- a/sc/inc/queryparam.hxx
+++ b/sc/inc/queryparam.hxx
@@ -72,7 +72,8 @@ public:
// creates pSearchParam and pSearchText if necessary, always RegExp!
utl::TextSearch* GetSearchTextPtr( bool bCaseSens ) const;
- bool MatchByString(const rtl::OUString& rStr) const;
+ bool IsQueryStringEmpty() const;
+ bool MatchByString(const rtl::OUString& rStr, bool bCaseSens) const;
SC_DLLPUBLIC void SetQueryString(const rtl::OUString& rStr);
SC_DLLPUBLIC rtl::OUString GetQueryString() const;
void Clear();
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 4f0b540..7cae817 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1077,7 +1077,7 @@ bool isQueryByValue(const ScTable& rTable, const ScQueryEntry& rEntry, SCROW nRo
return rTable.HasValueData(static_cast<SCCOL>(rEntry.nField), nRow);
}
-bool isTextMatchOnlyOp(const ScQueryEntry& rEntry)
+bool isPartialTextMatchOp(const ScQueryEntry& rEntry)
{
switch (rEntry.eOp)
{
@@ -1097,7 +1097,7 @@ bool isTextMatchOnlyOp(const ScQueryEntry& rEntry)
bool isTextMatchOp(const ScQueryEntry& rEntry)
{
- if (isTextMatchOnlyOp(rEntry))
+ if (isPartialTextMatchOp(rEntry))
return true;
switch (rEntry.eOp)
@@ -1266,7 +1266,8 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
else if (isQueryByString(*this, rEntry, nRow, pCell))
{
String aCellStr;
- if (isTextMatchOnlyOp(rEntry))
+ if (isPartialTextMatchOp(rEntry))
+ // may have to do partial textural comparison.
bMatchWholeCell = false;
if ( pCell )
@@ -1338,11 +1339,10 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
}
if ( !bRealRegExp )
{
- // Simple string matching.
- rtl::OUString aQueryStr = rEntry.GetQueryString();
+ // Simple string matching i.e. no regexp match.
if (isTextMatchOp(rEntry))
{
- if (!rEntry.bQueryByString && aQueryStr.isEmpty())
+ if (!rEntry.bQueryByString && rEntry.IsQueryStringEmpty())
{
// #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,
@@ -1353,12 +1353,13 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
}
else if ( bMatchWholeCell )
{
- bOk = pTransliteration->isEqual(aCellStr, aQueryStr);
+ bOk = rEntry.MatchByString(aCellStr, rParam.bCaseSens);
if ( rEntry.eOp == SC_NOT_EQUAL )
bOk = !bOk;
}
else
{
+ rtl::OUString aQueryStr = rEntry.GetQueryString();
String aCell( pTransliteration->transliterate(
aCellStr, ScGlobal::eLnge, 0, aCellStr.Len(),
NULL ) );
@@ -1400,7 +1401,7 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
else
{ // use collator here because data was probably sorted
sal_Int32 nCompare = pCollator->compareString(
- aCellStr, aQueryStr);
+ aCellStr, rEntry.GetQueryString());
switch (rEntry.eOp)
{
case SC_LESS :
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index bfb31d2..ca7d3a2 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -33,6 +33,7 @@
#include "queryparam.hxx"
#include <unotools/textsearch.hxx>
+#include <unotools/transliterationwrapper.hxx>
using ::std::vector;
@@ -96,9 +97,16 @@ ScQueryEntry& ScQueryEntry::operator=( const ScQueryEntry& r )
return *this;
}
-bool ScQueryEntry::MatchByString(const rtl::OUString& rStr) const
+bool ScQueryEntry::IsQueryStringEmpty() const
{
- return rStr.equals(*pStr);
+ return pStr->Len() == 0;
+}
+
+bool ScQueryEntry::MatchByString(const rtl::OUString& rStr, bool bCaseSens) const
+{
+ utl::TransliterationWrapper* pTransliteration = bCaseSens ?
+ ScGlobal::GetCaseTransliteration() : ScGlobal::GetpTransliteration();
+ return pTransliteration->isEqual(rStr, *pStr);
}
void ScQueryEntry::SetQueryString(const rtl::OUString& rStr)
commit da798ecf7b6471df71e8169dbc637cc903469e7d
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 4 15:34:28 2011 -0400
A little cleanup.
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 2490bf7..4f0b540 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1077,12 +1077,11 @@ bool isQueryByValue(const ScTable& rTable, const ScQueryEntry& rEntry, SCROW nRo
return rTable.HasValueData(static_cast<SCCOL>(rEntry.nField), nRow);
}
-bool isQueryByString(const ScTable& rTable, const ScQueryEntry& rEntry, SCROW nRow, const ScBaseCell* pCell)
+bool isTextMatchOnlyOp(const ScQueryEntry& rEntry)
{
switch (rEntry.eOp)
{
- case SC_EQUAL:
- case SC_NOT_EQUAL:
+ // these operators can only be used with textural comparisons.
case SC_CONTAINS:
case SC_DOES_NOT_CONTAIN:
case SC_BEGINS_WITH:
@@ -1093,26 +1092,19 @@ bool isQueryByString(const ScTable& rTable, const ScQueryEntry& rEntry, SCROW nR
default:
;
}
-
- if (!rEntry.bQueryByString)
- return false;
-
- if (pCell)
- return pCell->HasStringData();
-
- return rTable.HasStringData(static_cast<SCCOL>(rEntry.nField), nRow);
+ return false;
}
-bool isPartialStringMatch(const ScQueryEntry& rEntry)
+bool isTextMatchOp(const ScQueryEntry& rEntry)
{
+ if (isTextMatchOnlyOp(rEntry))
+ return true;
+
switch (rEntry.eOp)
{
- case SC_CONTAINS:
- case SC_DOES_NOT_CONTAIN:
- case SC_BEGINS_WITH:
- case SC_ENDS_WITH:
- case SC_DOES_NOT_BEGIN_WITH:
- case SC_DOES_NOT_END_WITH:
+ // these operators can be used for either textural or value comparison.
+ case SC_EQUAL:
+ case SC_NOT_EQUAL:
return true;
default:
;
@@ -1120,27 +1112,26 @@ bool isPartialStringMatch(const ScQueryEntry& rEntry)
return false;
}
+bool isQueryByString(const ScTable& rTable, const ScQueryEntry& rEntry, SCROW nRow, const ScBaseCell* pCell)
+{
+ if (isTextMatchOp(rEntry))
+ return true;
+
+ if (!rEntry.bQueryByString)
+ return false;
+
+ if (pCell)
+ return pCell->HasStringData();
+
+ return rTable.HasStringData(static_cast<SCCOL>(rEntry.nField), nRow);
+}
+
bool isRealRegExp(const ScQueryParam& rParam, const ScQueryEntry& rEntry)
{
if (!rParam.bRegExp)
return false;
- switch (rEntry.eOp)
- {
- case SC_EQUAL:
- case SC_NOT_EQUAL:
- case SC_CONTAINS:
- case SC_DOES_NOT_CONTAIN:
- case SC_BEGINS_WITH:
- case SC_ENDS_WITH:
- case SC_DOES_NOT_BEGIN_WITH:
- case SC_DOES_NOT_END_WITH:
- return true;
- default:
- ;
- }
-
- return false;
+ return isTextMatchOp(rEntry);
}
bool isTestRegExp(const ScQueryParam& rParam, const ScQueryEntry& rEntry, bool* pbTestEqualCondition)
@@ -1275,7 +1266,7 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
else if (isQueryByString(*this, rEntry, nRow, pCell))
{
String aCellStr;
- if (isPartialStringMatch(rEntry))
+ if (isTextMatchOnlyOp(rEntry))
bMatchWholeCell = false;
if ( pCell )
@@ -1347,11 +1338,9 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
}
if ( !bRealRegExp )
{
+ // Simple string matching.
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 (isTextMatchOp(rEntry))
{
if (!rEntry.bQueryByString && aQueryStr.isEmpty())
{
commit 11adb301c801e93e0c9d166776f0714c58e830d9
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 4 14:57:30 2011 -0400
More on extracting complex evaluations...
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 33208e0..2490bf7 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1120,6 +1120,40 @@ bool isPartialStringMatch(const ScQueryEntry& rEntry)
return false;
}
+bool isRealRegExp(const ScQueryParam& rParam, const ScQueryEntry& rEntry)
+{
+ if (!rParam.bRegExp)
+ return false;
+
+ switch (rEntry.eOp)
+ {
+ case SC_EQUAL:
+ case SC_NOT_EQUAL:
+ case SC_CONTAINS:
+ case SC_DOES_NOT_CONTAIN:
+ case SC_BEGINS_WITH:
+ case SC_ENDS_WITH:
+ case SC_DOES_NOT_BEGIN_WITH:
+ case SC_DOES_NOT_END_WITH:
+ return true;
+ default:
+ ;
+ }
+
+ return false;
+}
+
+bool isTestRegExp(const ScQueryParam& rParam, const ScQueryEntry& rEntry, bool* pbTestEqualCondition)
+{
+ if (!pbTestEqualCondition)
+ return false;
+
+ if (!rParam.bRegExp)
+ return false;
+
+ return (rEntry.eOp == SC_LESS_EQUAL || rEntry.eOp == SC_GREATER_EQUAL);
+}
+
}
bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
@@ -1255,14 +1289,9 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
else
GetInputString( static_cast<SCCOL>(rEntry.nField), nRow, aCellStr );
- bool bRealRegExp = (rParam.bRegExp && ((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)));
- bool bTestRegExp = (pbTestEqualCondition && rParam.bRegExp
- && ((rEntry.eOp == SC_LESS_EQUAL)
- || (rEntry.eOp == SC_GREATER_EQUAL)));
+ bool bRealRegExp = isRealRegExp(rParam, rEntry);
+ bool bTestRegExp = isTestRegExp(rParam, rEntry, pbTestEqualCondition);
+
if ( bRealRegExp || bTestRegExp )
{
xub_StrLen nStart = 0;
commit 15386b88d6ab1d5cc59278d489185fd4376762f2
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 4 14:47:12 2011 -0400
Another complex if condition extracted.
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 99f3d21..33208e0 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1103,6 +1103,23 @@ bool isQueryByString(const ScTable& rTable, const ScQueryEntry& rEntry, SCROW nR
return rTable.HasStringData(static_cast<SCCOL>(rEntry.nField), nRow);
}
+bool isPartialStringMatch(const ScQueryEntry& rEntry)
+{
+ switch (rEntry.eOp)
+ {
+ case SC_CONTAINS:
+ case SC_DOES_NOT_CONTAIN:
+ case SC_BEGINS_WITH:
+ case SC_ENDS_WITH:
+ case SC_DOES_NOT_BEGIN_WITH:
+ case SC_DOES_NOT_END_WITH:
+ return true;
+ default:
+ ;
+ }
+ return false;
+}
+
}
bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
@@ -1224,10 +1241,9 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
else if (isQueryByString(*this, rEntry, nRow, pCell))
{
String aCellStr;
- if( 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 (isPartialStringMatch(rEntry))
bMatchWholeCell = false;
+
if ( pCell )
{
if (pCell->GetCellType() != CELLTYPE_NOTE)
commit 13bc18e4bdcb52b0146f9b6bad3bf7f1d18d8ee8
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 4 14:43:28 2011 -0400
Using for loop here is better than while loop.
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index e4c7597..99f3d21 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1119,14 +1119,13 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
std::vector<bool> aTestEqual(nEntryCount, false);
long nPos = -1;
- SCSIZE i = 0;
bool bMatchWholeCell = pDocument->GetDocOptions().IsMatchWholeCell();
CollatorWrapper* pCollator = (rParam.bCaseSens ? ScGlobal::GetCaseCollator() :
ScGlobal::GetCollator());
::utl::TransliterationWrapper* pTransliteration = (rParam.bCaseSens ?
ScGlobal::GetCaseTransliteration() : ScGlobal::GetpTransliteration());
- while ( (i < nEntryCount) && rParam.GetEntry(i).bDoQuery )
+ for (size_t i = 0; i < nEntryCount && rParam.GetEntry(i).bDoQuery; ++i)
{
const ScQueryEntry& rEntry = rParam.GetEntry(i);
// we can only handle one single direct query
@@ -1432,7 +1431,6 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
aTestEqual[nPos] = bTestEqual;
}
}
- i++;
}
for ( long j=1; j <= nPos; j++ )
commit 80697a92c0d5ffd093e6dca873c56fe13db19398
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 4 14:35:39 2011 -0400
Extracted complex if conditions into own methods. Much more readable.
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 0a7cbff..1001ede 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -435,9 +435,9 @@ public:
void LimitChartArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow );
- bool HasData( SCCOL nCol, SCROW nRow );
- bool HasStringData( SCCOL nCol, SCROW nRow );
- bool HasValueData( SCCOL nCol, SCROW nRow );
+ bool HasData( SCCOL nCol, SCROW nRow ) const;
+ bool HasStringData( SCCOL nCol, SCROW nRow ) const;
+ bool HasValueData( SCCOL nCol, SCROW nRow ) const;
bool HasStringCells( SCCOL nStartCol, SCROW nStartRow,
SCCOL nEndCol, SCROW nEndRow ) const;
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index d16d990..7a49a13 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1184,7 +1184,7 @@ void ScTable::GetLastDataPos(SCCOL& rCol, SCROW& rRow) const
}
-bool ScTable::HasData( SCCOL nCol, SCROW nRow )
+bool ScTable::HasData( SCCOL nCol, SCROW nRow ) const
{
if (ValidColRow(nCol,nRow))
return aCol[nCol].HasDataAt( nRow );
@@ -1193,7 +1193,7 @@ bool ScTable::HasData( SCCOL nCol, SCROW nRow )
}
-bool ScTable::HasStringData( SCCOL nCol, SCROW nRow )
+bool ScTable::HasStringData( SCCOL nCol, SCROW nRow ) const
{
if (ValidColRow(nCol,nRow))
return aCol[nCol].HasStringData( nRow );
@@ -1202,7 +1202,7 @@ bool ScTable::HasStringData( SCCOL nCol, SCROW nRow )
}
-bool ScTable::HasValueData( SCCOL nCol, SCROW nRow )
+bool ScTable::HasValueData( SCCOL nCol, SCROW nRow ) const
{
if (ValidColRow(nCol,nRow))
return aCol[nCol].HasValueData( nRow );
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 6153474..e4c7597 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1064,6 +1064,46 @@ bool ScTable::DoSubTotals( ScSubTotalParam& rParam )
return bSpaceLeft;
}
+namespace {
+
+bool isQueryByValue(const ScTable& rTable, const ScQueryEntry& rEntry, SCROW nRow, const ScBaseCell* pCell)
+{
+ if (rEntry.bQueryByString)
+ return false;
+
+ if (pCell)
+ return pCell->HasValueData();
+
+ return rTable.HasValueData(static_cast<SCCOL>(rEntry.nField), nRow);
+}
+
+bool isQueryByString(const ScTable& rTable, const ScQueryEntry& rEntry, SCROW nRow, const ScBaseCell* pCell)
+{
+ switch (rEntry.eOp)
+ {
+ case SC_EQUAL:
+ case SC_NOT_EQUAL:
+ case SC_CONTAINS:
+ case SC_DOES_NOT_CONTAIN:
+ case SC_BEGINS_WITH:
+ case SC_ENDS_WITH:
+ case SC_DOES_NOT_BEGIN_WITH:
+ case SC_DOES_NOT_END_WITH:
+ return true;
+ default:
+ ;
+ }
+
+ if (!rEntry.bQueryByString)
+ return false;
+
+ if (pCell)
+ return pCell->HasStringData();
+
+ return rTable.HasStringData(static_cast<SCCOL>(rEntry.nField), nRow);
+}
+
+}
bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
bool* pSpecial /* =NULL */ , ScBaseCell* pCell /* =NULL */ ,
@@ -1103,9 +1143,8 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
else // if (rEntry.nVal == SC_NONEMPTYFIELDS)
bOk = aCol[rEntry.nField].HasDataAt( nRow );
}
- else if ( !rEntry.bQueryByString && (pCell ? pCell->HasValueData() :
- HasValueData( static_cast<SCCOL>(rEntry.nField), nRow)))
- { // by Value
+ else if (isQueryByValue(*this, rEntry, nRow, pCell))
+ {
double nCellVal;
if ( pCell )
{
@@ -1183,15 +1222,8 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
}
}
}
- else 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) ||
- (rEntry.bQueryByString && (pCell ? pCell->HasStringData() :
- HasStringData(
- static_cast<SCCOL>(rEntry.nField),
- nRow))))
- { // by String
+ else if (isQueryByString(*this, rEntry, nRow, pCell))
+ {
String aCellStr;
if( rEntry.eOp == SC_CONTAINS || rEntry.eOp == SC_DOES_NOT_CONTAIN
|| rEntry.eOp == SC_BEGINS_WITH || rEntry.eOp == SC_ENDS_WITH
commit e6ae91a8248fceee4248aadaf9f8aadec3fcc2bc
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 4 14:10:30 2011 -0400
Prefer STL over heap array.
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index ec9657f..6153474 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1074,12 +1074,9 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
//---------------------------------------------------------------
- const SCSIZE nFixedBools = 32;
- bool aBool[nFixedBools];
- bool aTest[nFixedBools];
SCSIZE nEntryCount = rParam.GetEntryCount();
- bool* pPasst = ( nEntryCount <= nFixedBools ? &aBool[0] : new bool[nEntryCount] );
- bool* pTest = ( nEntryCount <= nFixedBools ? &aTest[0] : new bool[nEntryCount] );
+ std::vector<bool> aPassed(nEntryCount, false);
+ std::vector<bool> aTestEqual(nEntryCount, false);
long nPos = -1;
SCSIZE i = 0;
@@ -1386,21 +1383,21 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
if (nPos == -1)
{
nPos++;
- pPasst[nPos] = bOk;
- pTest[nPos] = bTestEqual;
+ aPassed[nPos] = bOk;
+ aTestEqual[nPos] = bTestEqual;
}
else
{
if (rEntry.eConnect == SC_AND)
{
- pPasst[nPos] = pPasst[nPos] && bOk;
- pTest[nPos] = pTest[nPos] && bTestEqual;
+ aPassed[nPos] = aPassed[nPos] && bOk;
+ aTestEqual[nPos] = aTestEqual[nPos] && bTestEqual;
}
else
{
nPos++;
- pPasst[nPos] = bOk;
- pTest[nPos] = bTestEqual;
+ aPassed[nPos] = bOk;
+ aTestEqual[nPos] = bTestEqual;
}
}
i++;
@@ -1408,17 +1405,13 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
for ( long j=1; j <= nPos; j++ )
{
- pPasst[0] = pPasst[0] || pPasst[j];
- pTest[0] = pTest[0] || pTest[j];
+ aPassed[0] = aPassed[0] || aPassed[j];
+ aTestEqual[0] = aTestEqual[0] || aTestEqual[j];
}
- bool bRet = pPasst[0];
- if ( pPasst != &aBool[0] )
- delete [] pPasst;
+ bool bRet = aPassed[0];
if ( pbTestEqualCondition )
- *pbTestEqualCondition = pTest[0];
- if ( pTest != &aTest[0] )
- delete [] pTest;
+ *pbTestEqualCondition = aTestEqual[0];
return bRet;
}
commit 22f971d6d2070d66f0713ad5f1044b8741f12c43
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 4 12:30:41 2011 -0400
Set pStr private and discovered several more direct access to this member.
diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx
index dd09aa3..79330ae 100644
--- a/sc/inc/queryparam.hxx
+++ b/sc/inc/queryparam.hxx
@@ -52,13 +52,15 @@ namespace utl {
struct ScQueryEntry
{
+private:
+ String* pStr;
+public:
bool bDoQuery;
bool bQueryByString;
bool bQueryByDate;
SCCOLROW nField;
ScQueryOp eOp;
ScQueryConnect eConnect;
- String* pStr;
double nVal;
mutable utl::SearchParam* pSearchParam; // if RegExp, not saved
mutable utl::TextSearch* pSearchText; // if RegExp, not saved
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 6c42369..d8c2f5d 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -4317,10 +4317,6 @@ static sal_Int32 lcl_CompareMatrix2Query(
if (!rEntry.bQueryByString)
return 1; // string always greater than numeric
- if (!rEntry.pStr)
- // this should not happen!
- return 1;
-
const rtl::OUString rStr1 = rMat.GetString(i);
const rtl::OUString rStr2 = rEntry.GetQueryString();
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index ffa9b94..bfb31d2 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -43,13 +43,13 @@ const SCSIZE MAXQUERY = 8;
}
ScQueryEntry::ScQueryEntry() :
+ pStr(new String),
bDoQuery(false),
bQueryByString(false),
bQueryByDate(false),
nField(0),
eOp(SC_EQUAL),
eConnect(SC_AND),
- pStr(new String),
nVal(0.0),
pSearchParam(NULL),
pSearchText(NULL)
@@ -57,13 +57,13 @@ ScQueryEntry::ScQueryEntry() :
}
ScQueryEntry::ScQueryEntry(const ScQueryEntry& r) :
+ pStr(new String(*r.pStr)),
bDoQuery(r.bDoQuery),
bQueryByString(r.bQueryByString),
bQueryByDate(r.bQueryByDate),
nField(r.nField),
eOp(r.eOp),
eConnect(r.eConnect),
- pStr(new String(*r.pStr)),
nVal(r.nVal),
pSearchParam(NULL),
pSearchText(NULL)
@@ -237,17 +237,17 @@ void ScQueryParamBase::FillInExcelSyntax(String& aCellStr, SCSIZE nIndex)
{
if (aCellStr.GetChar(1) == '>')
{
- *rEntry.pStr = aCellStr.Copy(2);
+ rEntry.SetQueryString(aCellStr.Copy(2));
rEntry.eOp = SC_NOT_EQUAL;
}
else if (aCellStr.GetChar(1) == '=')
{
- *rEntry.pStr = aCellStr.Copy(2);
+ rEntry.SetQueryString(aCellStr.Copy(2));
rEntry.eOp = SC_LESS_EQUAL;
}
else
{
- *rEntry.pStr = aCellStr.Copy(1);
+ rEntry.SetQueryString(aCellStr.Copy(1));
rEntry.eOp = SC_LESS;
}
}
@@ -255,21 +255,21 @@ void ScQueryParamBase::FillInExcelSyntax(String& aCellStr, SCSIZE nIndex)
{
if (aCellStr.GetChar(1) == '=')
{
- *rEntry.pStr = aCellStr.Copy(2);
+ rEntry.SetQueryString(aCellStr.Copy(2));
rEntry.eOp = SC_GREATER_EQUAL;
}
else
{
- *rEntry.pStr = aCellStr.Copy(1);
+ rEntry.SetQueryString(aCellStr.Copy(1));
rEntry.eOp = SC_GREATER;
}
}
else
{
if (aCellStr.GetChar(0) == '=')
- *rEntry.pStr = aCellStr.Copy(1);
+ rEntry.SetQueryString(aCellStr.Copy(1));
else
- *rEntry.pStr = aCellStr;
+ rEntry.SetQueryString(aCellStr);
rEntry.eOp = SC_EQUAL;
}
}
commit a917af4fe40faf5a7538b0bf852796949192787d
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 4b56c64..71110f8 100644
--- a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
+++ b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
@@ -405,7 +405,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);
@@ -445,7 +445,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;
commit 9dd9e4baccc4009be524f6ab3070e7458138d82d
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 4 01:03:27 2011 -0400
Remove direct access to the query string (pStr).
I'm about half-way through.
diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx
index 105a801..dd09aa3 100644
--- a/sc/inc/queryparam.hxx
+++ b/sc/inc/queryparam.hxx
@@ -70,6 +70,9 @@ struct ScQueryEntry
// creates pSearchParam and pSearchText if necessary, always RegExp!
utl::TextSearch* GetSearchTextPtr( bool bCaseSens ) const;
+ bool MatchByString(const rtl::OUString& rStr) const;
+ SC_DLLPUBLIC void SetQueryString(const rtl::OUString& rStr);
+ SC_DLLPUBLIC rtl::OUString GetQueryString() const;
void Clear();
ScQueryEntry& operator=( const ScQueryEntry& r );
bool operator==( const ScQueryEntry& r ) const;
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 632abf8..aba2ac5 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -532,7 +532,7 @@ ScDBQueryDataIterator::DataAccessInternal::DataAccessInternal(const ScDBQueryDat
ScQueryEntry& rEntry = mpParam->GetEntry(i);
sal_uInt32 nIndex = 0;
rEntry.bQueryByString =
- !(mpDoc->GetFormatTable()->IsNumberFormat(*rEntry.pStr, nIndex, rEntry.nVal));
+ !(mpDoc->GetFormatTable()->IsNumberFormat(rEntry.GetQueryString(), nIndex, rEntry.nVal));
}
nNumFormat = 0; // werden bei GetNumberFormat initialisiert
pAttrArray = 0;
@@ -814,14 +814,11 @@ bool ScDBQueryDataIterator::DataAccessMatrix::isValidQuery(SCROW nRow, const ScM
// By string
do
{
- if (!rEntry.pStr)
- break;
-
// Equality check first.
OUString aMatStr = rMat.GetString(nField, nRow);
lcl_toUpper(aMatStr);
- OUString aQueryStr = *rEntry.pStr;
+ OUString aQueryStr = rEntry.GetQueryString();
lcl_toUpper(aQueryStr);
bool bDone = false;
switch (rEntry.eOp)
@@ -1108,8 +1105,8 @@ ScQueryCellIterator::ScQueryCellIterator(ScDocument* pDocument, SCTAB nTable,
ScQueryEntry& rEntry = aParam.GetEntry(i);
sal_uInt32 nIndex = 0;
rEntry.bQueryByString =
- !(pDoc->GetFormatTable()->IsNumberFormat(*rEntry.pStr,
- nIndex, rEntry.nVal));
+ !(pDoc->GetFormatTable()->IsNumberFormat(
+ rEntry.GetQueryString(), nIndex, rEntry.nVal));
}
}
nNumFormat = 0; // werden bei GetNumberFormat initialisiert
@@ -1415,7 +1412,7 @@ ScBaseCell* ScQueryCellIterator::BinarySearch()
sal_uLong nFormat = pCol->GetNumberFormat( pItems[nLo].nRow);
ScCellFormat::GetInputString( pItems[nLo].pCell, nFormat, aCellStr,
rFormatter);
- sal_Int32 nTmp = pCollator->compareString( aCellStr, *rEntry.pStr);
+ sal_Int32 nTmp = pCollator->compareString(aCellStr, rEntry.GetQueryString());
if ((rEntry.eOp == SC_LESS_EQUAL && nTmp > 0) ||
(rEntry.eOp == SC_GREATER_EQUAL && nTmp < 0) ||
(rEntry.eOp == SC_EQUAL && nTmp != 0))
@@ -1547,7 +1544,7 @@ ScBaseCell* ScQueryCellIterator::BinarySearch()
sal_uLong nFormat = pCol->GetNumberFormat( pItems[i].nRow);
ScCellFormat::GetInputString( pItems[i].pCell, nFormat, aCellStr,
rFormatter);
- nRes = pCollator->compareString( aCellStr, *rEntry.pStr);
+ nRes = pCollator->compareString( aCellStr, rEntry.GetQueryString());
if (nRes < 0 && bLessEqual)
{
sal_Int32 nTmp = pCollator->compareString( aLastInRangeString,
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index b65bb47..ebac350 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -78,7 +78,7 @@ ScSheetDPData::ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc, con
pSpecial[j] = false;
if (!rEntry.bQueryByString)
{
- if (*rEntry.pStr == EMPTY_STRING &&
+ if (rEntry.GetQueryString().isEmpty() &&
((rEntry.nVal == SC_EMPTYFIELDS) || (rEntry.nVal == SC_NONEMPTYFIELDS)))
pSpecial[j] = true;
}
@@ -86,8 +86,8 @@ ScSheetDPData::ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc, con
{
sal_uInt32 nIndex = 0;
rEntry.bQueryByString =
- !(pD->GetFormatTable()->
- IsNumberFormat(*rEntry.pStr, nIndex, rEntry.nVal));
+ !(pD->GetFormatTable()->IsNumberFormat(
+ rEntry.GetQueryString(), nIndex, rEntry.nVal));
}
}
}
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index 463ceb6..8f9852d 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -681,9 +681,9 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam, bool *pSpeci
{
if (bMatchWholeCell)
{
- bOk = pTransliteration->isEqual( aCellStr, *rEntry.pStr );
- String aStr = *rEntry.pStr;
- sal_Bool bHasStar = false;
+ String aStr = rEntry.GetQueryString();
+ bOk = pTransliteration->isEqual(aCellStr, aStr);
+ bool bHasStar = false;
xub_StrLen nIndex;
if (( nIndex = aStr.Search('*') ) != STRING_NOTFOUND)
bHasStar = sal_True;
@@ -706,12 +706,10 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam, bool *pSpeci
else
{
::com::sun::star::uno::Sequence< sal_Int32 > xOff;
- String aCell( pTransliteration->transliterate(
- aCellStr, ScGlobal::eLnge, 0, aCellStr.Len(),
- &xOff ) );
- String aQuer( pTransliteration->transliterate(
- *rEntry.pStr, ScGlobal::eLnge, 0, rEntry.pStr->Len(),
- &xOff ) );
+ String aCell = pTransliteration->transliterate(
+ aCellStr, ScGlobal::eLnge, 0, aCellStr.Len(), &xOff);
+ String aQuer = pTransliteration->transliterate(
+ rEntry.GetQueryString(), ScGlobal::eLnge, 0, rEntry.GetQueryString().getLength(), &xOff);
bOk = (aCell.Search( aQuer ) != STRING_NOTFOUND);
}
if (rEntry.eOp == SC_NOT_EQUAL)
@@ -720,7 +718,7 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam, bool *pSpeci
else
{ // use collator here because data was probably sorted
sal_Int32 nCompare = pCollator->compareString(
- aCellStr, *rEntry.pStr );
+ aCellStr, rEntry.GetQueryString());
switch (rEntry.eOp)
{
case SC_LESS :
diff --git a/sc/source/core/tool/doubleref.cxx b/sc/source/core/tool/doubleref.cxx
index 5724c79..417e28e 100644
--- a/sc/source/core/tool/doubleref.cxx
+++ b/sc/source/core/tool/doubleref.cxx
@@ -141,8 +141,8 @@ bool lcl_createStarQuery(ScQueryParamBase* pParam, const ScDBRangeBase* pDBRef,
if (bValid)
{
// Finally, the right-hand-side value in the 4th column.
- *rEntry.pStr = pQueryRef->getString(3, nRow);
- rEntry.bDoQuery = sal_True;
+ rEntry.SetQueryString(pQueryRef->getString(3, nRow));
+ rEntry.bDoQuery = true;
}
nIndex++;
nRow++;
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index 7895926..ffa9b94 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -96,6 +96,21 @@ ScQueryEntry& ScQueryEntry::operator=( const ScQueryEntry& r )
return *this;
}
+bool ScQueryEntry::MatchByString(const rtl::OUString& rStr) const
+{
+ return rStr.equals(*pStr);
+}
+
+void ScQueryEntry::SetQueryString(const rtl::OUString& rStr)
+{
+ *pStr = String(rStr);
+}
+
+rtl::OUString ScQueryEntry::GetQueryString() const
+{
+ return *pStr;
+}
+
void ScQueryEntry::Clear()
{
bDoQuery = false;
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index a00aa16..94e74ef 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -499,11 +499,11 @@ XclImpAutoFilterData::XclImpAutoFilterData( RootData* pRoot, const ScRange& rRan
}
-void XclImpAutoFilterData::CreateFromDouble( String& rStr, double fVal )
+void XclImpAutoFilterData::CreateFromDouble( rtl::OUString& rStr, double fVal )
{
- rStr += String( ::rtl::math::doubleToUString( fVal,
+ rStr += ::rtl::math::doubleToUString(fVal,
rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
- ScGlobal::pLocaleData->getNumDecimalSep().GetChar(0), sal_True));
+ ScGlobal::pLocaleData->getNumDecimalSep().GetChar(0), true);
}
void XclImpAutoFilterData::SetCellAttribs()
@@ -540,34 +540,34 @@ void XclImpAutoFilterData::InsertQueryParam()
static void ExcelQueryToOooQuery( ScQueryEntry& rEntry )
{
- if( ( rEntry.eOp != SC_EQUAL && rEntry.eOp != SC_NOT_EQUAL ) || rEntry.pStr == NULL )
+ if (rEntry.eOp != SC_EQUAL && rEntry.eOp != SC_NOT_EQUAL)
return;
- else
+
+ String aStr = rEntry.GetQueryString();
+ xub_StrLen nLen = aStr.Len();
+ sal_Unicode nStart = aStr.GetChar( 0 );
+ sal_Unicode nEnd = aStr.GetChar( nLen-1 );
+ if( nLen >2 && nStart == '*' && nEnd == '*' )
{
- xub_StrLen nLen = rEntry.pStr->Len();
- sal_Unicode nStart = rEntry.pStr->GetChar( 0 );
- sal_Unicode nEnd = rEntry.pStr->GetChar( nLen-1 );
- if( nLen >2 && nStart == '*' && nEnd == '*' )
- {
- rEntry.pStr->Erase( nLen-1, 1 );
- rEntry.pStr->Erase( 0, 1 );
- rEntry.eOp = ( rEntry.eOp == SC_EQUAL ) ? SC_CONTAINS : SC_DOES_NOT_CONTAIN;
- }
- else if( nLen > 1 && nStart == '*' && nEnd != '*' )
- {
- rEntry.pStr->Erase( 0, 1 );
- rEntry.eOp = ( rEntry.eOp == SC_EQUAL ) ? SC_ENDS_WITH : SC_DOES_NOT_END_WITH;
- }
- else if( nLen > 1 && nStart != '*' && nEnd == '*' )
- {
- rEntry.pStr->Erase( nLen-1, 1 );
- rEntry.eOp = ( rEntry.eOp == SC_EQUAL ) ? SC_BEGINS_WITH : SC_DOES_NOT_BEGIN_WITH;
- }
- else if( nLen == 2 && nStart == '*' && nEnd == '*' )
- {
- rEntry.pStr->Erase( 0, 1 );
- }
+ aStr.Erase( nLen-1, 1 );
+ aStr.Erase( 0, 1 );
+ rEntry.eOp = ( rEntry.eOp == SC_EQUAL ) ? SC_CONTAINS : SC_DOES_NOT_CONTAIN;
+ }
+ else if( nLen > 1 && nStart == '*' && nEnd != '*' )
+ {
+ aStr.Erase( 0, 1 );
+ rEntry.eOp = ( rEntry.eOp == SC_EQUAL ) ? SC_ENDS_WITH : SC_DOES_NOT_END_WITH;
+ }
+ else if( nLen > 1 && nStart != '*' && nEnd == '*' )
+ {
+ aStr.Erase( nLen-1, 1 );
+ rEntry.eOp = ( rEntry.eOp == SC_EQUAL ) ? SC_BEGINS_WITH : SC_DOES_NOT_BEGIN_WITH;
+ }
+ else if( nLen == 2 && nStart == '*' && nEnd == '*' )
+ {
+ aStr.Erase( 0, 1 );
}
+ rEntry.SetQueryString(aStr);
}
void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm )
@@ -593,7 +593,7 @@ void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm )
aEntry.eOp = bTopOfTop10 ?
(bPercent ? SC_TOPPERC : SC_TOPVAL) : (bPercent ? SC_BOTPERC : SC_BOTVAL);
aEntry.eConnect = SC_AND;
- aEntry.pStr->Assign( String::CreateFromInt32( (sal_Int32) nCntOfTop10 ) );
+ aEntry.SetQueryString(rtl::OUString::valueOf(static_cast<sal_Int32>(nCntOfTop10)));
rStrm.Ignore( 20 );
nFirstEmpty++;
@@ -642,27 +642,33 @@ void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm )
aEntry.eOp = SC_EQUAL;
}
+ rtl::OUString aStr;
+
switch( nType )
{
case EXC_AFTYPE_RK:
rStrm >> nRK;
rStrm.Ignore( 4 );
- CreateFromDouble( *aEntry.pStr, XclTools::GetDoubleFromRK( nRK ) );
+ aStr = aEntry.GetQueryString();
+ CreateFromDouble(aStr, XclTools::GetDoubleFromRK(nRK));
+ aEntry.SetQueryString(aStr);
break;
case EXC_AFTYPE_DOUBLE:
rStrm >> fVal;
- CreateFromDouble( *aEntry.pStr, fVal );
+ aStr = aEntry.GetQueryString();
+ CreateFromDouble(aStr, fVal);
+ aEntry.SetQueryString(aStr);
break;
case EXC_AFTYPE_STRING:
rStrm.Ignore( 4 );
rStrm >> nStrLen[ nE ];
rStrm.Ignore( 3 );
- aEntry.pStr->Erase();
+ aEntry.SetQueryString(rtl::OUString());
break;
case EXC_AFTYPE_BOOLERR:
rStrm >> nBoolErr >> nVal;
rStrm.Ignore( 6 );
- aEntry.pStr->Assign( String::CreateFromInt32( (sal_Int32) nVal ) );
+ aEntry.SetQueryString(rtl::OUString::valueOf(static_cast<sal_Int32>(nVal)));
bIgnore = (sal_Bool) nBoolErr;
break;
case EXC_AFTYPE_EMPTY:
@@ -704,7 +710,7 @@ void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm )
for( nE = 0; nE < 2; nE++ )
if( nStrLen[ nE ] && pQueryEntries[ nE ] )
{
- pQueryEntries[ nE ]->pStr->Assign ( rStrm.ReadUniString( nStrLen[ nE ] ) );
+ pQueryEntries[nE]->SetQueryString(rStrm.ReadUniString(nStrLen[nE]));
ExcelQueryToOooQuery( *pQueryEntries[ nE ] );
}
diff --git a/sc/source/filter/inc/excimp8.hxx b/sc/source/filter/inc/excimp8.hxx
index eb441f3..6a9b36f 100644
--- a/sc/source/filter/inc/excimp8.hxx
+++ b/sc/source/filter/inc/excimp8.hxx
@@ -107,7 +107,7 @@ private:
sal_Bool bAutoOrAdvanced;
ScRange aCriteriaRange;
- void CreateFromDouble( String& rStr, double fVal );
+ void CreateFromDouble( rtl::OUString& rStr, double fVal );
void SetCellAttribs();
void InsertQueryParam();
void AmendAFName(const sal_Bool bUseUnNamed);
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index aa45cc0..e6e1d32 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -5677,8 +5677,12 @@ void SAL_CALL ScCellRangeObj::filter( const uno::Reference<sheet::XSheetFilterDe
rEntry.nField += nFieldStart;
// Im Dialog wird immer der String angezeigt -> muss zum Wert passen
if ( !rEntry.bQueryByString )
+ {
+ rtl::OUString aStr;
pDocSh->GetDocument()->GetFormatTable()->
- GetInputLineString( rEntry.nVal, 0, *rEntry.pStr );
+ GetInputLineString(rEntry.nVal, 0, aStr);
+ rEntry.SetQueryString(aStr);
+ }
}
}
diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx
index 62db49e..9a6e4a0 100644
--- a/sc/source/ui/unoobj/datauno.cxx
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -1072,19 +1072,19 @@ void ScFilterDescriptorBase::fillQueryParam(
for (i=0; i<nCount; i++)
{
ScQueryEntry& rEntry = rParam.GetEntry(i);
- if (!rEntry.pStr)
- rEntry.pStr = new String; // sollte nicht sein (soll immer initialisiert sein)
rEntry.bDoQuery = sal_True;
rEntry.eConnect = (pAry[i].Connection == sheet::FilterConnection_AND) ? SC_AND : SC_OR;
rEntry.nField = pAry[i].Field;
rEntry.bQueryByString = !pAry[i].IsNumeric;
- *rEntry.pStr = String( pAry[i].StringValue );
rEntry.nVal = pAry[i].NumericValue;
+ rEntry.SetQueryString(pAry[i].StringValue);
if (!rEntry.bQueryByString && pDoc)
{
- pDoc->GetFormatTable()->GetInputLineString(rEntry.nVal, 0, *rEntry.pStr);
+ rtl::OUString aStr;
+ pDoc->GetFormatTable()->GetInputLineString(rEntry.nVal, 0, aStr);
+ rEntry.SetQueryString(aStr);
}
switch (pAry[i].Operator) // FilterOperator
@@ -1110,7 +1110,7 @@ void ScFilterDescriptorBase::fillQueryParam(
rEntry.eOp = SC_EQUAL;
rEntry.nVal = SC_EMPTYFIELDS;
rEntry.bQueryByString = false;
- *rEntry.pStr = EMPTY_STRING;
+ rEntry.SetQueryString(rtl::OUString());
}
break;
case sheet::FilterOperator2::NOT_EMPTY:
@@ -1118,7 +1118,7 @@ void ScFilterDescriptorBase::fillQueryParam(
rEntry.eOp = SC_EQUAL;
rEntry.nVal = SC_NONEMPTYFIELDS;
rEntry.bQueryByString = false;
- *rEntry.pStr = EMPTY_STRING;
+ rEntry.SetQueryString(rtl::OUString());
}
break;
default:
@@ -1180,9 +1180,7 @@ uno::Sequence<sheet::TableFilterField> SAL_CALL ScFilterDescriptorBase::getFilte
{
const ScQueryEntry& rEntry = aParam.GetEntry(i);
- rtl::OUString aStringValue;
- if (rEntry.pStr)
- aStringValue = *rEntry.pStr;
+ rtl::OUString aStringValue = rEntry.GetQueryString();
aField.Connection = (rEntry.eConnect == SC_AND) ? sheet::FilterConnection_AND :
sheet::FilterConnection_OR;
@@ -1196,7 +1194,7 @@ uno::Sequence<sheet::TableFilterField> SAL_CALL ScFilterDescriptorBase::getFilte
case SC_EQUAL:
{
aField.Operator = sheet::FilterOperator_EQUAL;
- if (!rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING)
+ if (!rEntry.bQueryByString && rEntry.GetQueryString().isEmpty())
{
if (rEntry.nVal == SC_EMPTYFIELDS)
{
@@ -1249,9 +1247,7 @@ throw(uno::RuntimeException)
{
const ScQueryEntry& rEntry = aParam.GetEntry(i);
- rtl::OUString aStringValue;
- if (rEntry.pStr)
- aStringValue = *rEntry.pStr;
+ rtl::OUString aStringValue = rEntry.GetQueryString();
aField.Connection = (rEntry.eConnect == SC_AND) ? sheet::FilterConnection_AND : sheet::FilterConnection_OR;
aField.Field = rEntry.nField;
@@ -1264,7 +1260,7 @@ throw(uno::RuntimeException)
case SC_EQUAL:
{
aField.Operator = sheet::FilterOperator2::EQUAL;
- if (!rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING)
+ if (!rEntry.bQueryByString && rEntry.GetQueryString().isEmpty())
{
if (rEntry.nVal == SC_EMPTYFIELDS)
{
@@ -1319,19 +1315,19 @@ void SAL_CALL ScFilterDescriptorBase::setFilterFields(
for (i=0; i<nCount; i++)
{
ScQueryEntry& rEntry = aParam.GetEntry(i);
- if (!rEntry.pStr)
- rEntry.pStr = new String; // sollte nicht sein (soll immer initialisiert sein)
- rEntry.bDoQuery = sal_True;
+ rEntry.bDoQuery = true;
rEntry.eConnect = (pAry[i].Connection == sheet::FilterConnection_AND) ? SC_AND : SC_OR;
rEntry.nField = pAry[i].Field;
rEntry.bQueryByString = !pAry[i].IsNumeric;
- *rEntry.pStr = String( pAry[i].StringValue );
rEntry.nVal = pAry[i].NumericValue;
+ rEntry.SetQueryString(pAry[i].StringValue);
if (!rEntry.bQueryByString && pDocSh)
{
- pDocSh->GetDocument()->GetFormatTable()->GetInputLineString(rEntry.nVal, 0, *rEntry.pStr);
+ rtl::OUString aStr;
+ pDocSh->GetDocument()->GetFormatTable()->GetInputLineString(rEntry.nVal, 0, aStr);
+ rEntry.SetQueryString(aStr);
}
switch (pAry[i].Operator) // FilterOperator
@@ -1351,7 +1347,7 @@ void SAL_CALL ScFilterDescriptorBase::setFilterFields(
rEntry.eOp = SC_EQUAL;
rEntry.nVal = SC_EMPTYFIELDS;
rEntry.bQueryByString = false;
- *rEntry.pStr = EMPTY_STRING;
+ rEntry.SetQueryString(rtl::OUString());
}
break;
case sheet::FilterOperator_NOT_EMPTY:
@@ -1359,7 +1355,7 @@ void SAL_CALL ScFilterDescriptorBase::setFilterFields(
rEntry.eOp = SC_EQUAL;
rEntry.nVal = SC_NONEMPTYFIELDS;
rEntry.bQueryByString = false;
- *rEntry.pStr = EMPTY_STRING;
+ rEntry.SetQueryString(rtl::OUString());
}
break;
default:
commit 5ec42cf012ac22c44fc9864726f7cc5671b72274
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Thu Nov 3 23:22:46 2011 -0400
Support rtl::OUString reference here as well.
diff --git a/svl/inc/svl/zforlist.hxx b/svl/inc/svl/zforlist.hxx
index 67a1678..afcb326 100644
--- a/svl/inc/svl/zforlist.hxx
+++ b/svl/inc/svl/zforlist.hxx
@@ -502,7 +502,10 @@ public:
/** Format a number according to the standard default format matching
the given format index */
void GetInputLineString( const double& fOutNumber,
- sal_uInt32 nFIndex, String& sOutString );
+ sal_uInt32 nFIndex, String& sOutString );
+
+ void GetInputLineString( const double& fOutNumber,
+ sal_uInt32 nFIndex, rtl::OUString& rOutString );
/** Format a number according to a format code string to be scanned.
@return
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index aaa5064..786e80a 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -1512,6 +1512,15 @@ void SvNumberFormatter::GetInputLineString(const double& fOutNumber,
ChangeStandardPrec(nOldPrec);
}
+void SvNumberFormatter::GetInputLineString(const double& fOutNumber,
+ sal_uInt32 nFIndex,
+ rtl::OUString& rOutString)
+{
+ String aTmp;
+ GetInputLineString(fOutNumber, nFIndex, aTmp);
+ rOutString = aTmp;
+}
+
void SvNumberFormatter::GetOutputString(const double& fOutNumber,
sal_uInt32 nFIndex,
String& sOutString,
commit 6d1c73b744e50f3cfc84c30378d2f6c74a6e528e
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Thu Nov 3 23:13:19 2011 -0400
Calling delete on NULL pointer is safe.
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index 44d6201..7895926 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -73,11 +73,8 @@ ScQueryEntry::ScQueryEntry(const ScQueryEntry& r) :
ScQueryEntry::~ScQueryEntry()
{
delete pStr;
- if ( pSearchParam )
- {
- delete pSearchParam;
- delete pSearchText;
- }
+ delete pSearchParam;
+ delete pSearchText;
}
ScQueryEntry& ScQueryEntry::operator=( const ScQueryEntry& r )
@@ -90,11 +87,9 @@ ScQueryEntry& ScQueryEntry::operator=( const ScQueryEntry& r )
nField = r.nField;
nVal = r.nVal;
*pStr = *r.pStr;
- if ( pSearchParam )
- {
- delete pSearchParam;
- delete pSearchText;
- }
+
+ delete pSearchParam;
+ delete pSearchText;
pSearchParam = NULL;
pSearchText = NULL;
@@ -111,11 +106,9 @@ void ScQueryEntry::Clear()
nField = 0;
nVal = 0.0;
pStr->Erase();
- if ( pSearchParam )
- {
- delete pSearchParam;
- delete pSearchText;
- }
+
+ delete pSearchParam;
+ delete pSearchText;
pSearchParam = NULL;
pSearchText = NULL;
}
commit d6edecd37c4fe71cdb7aea313ac1c7478c7920e4
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Thu Nov 3 22:57:31 2011 -0400
Moved ScQueryEntry out of global.?xx to queryparam.?xx.
This is more appropriate.
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index cc8c0fd..78360b6 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -741,46 +741,6 @@ enum ScSubTotalFunc
SUBTOTAL_FUNC_VARP = 11
};
-/*
- * dialog returns the special field values "empty"/"not empty"
- * as constants SC_EMPTYFIELDS and SC_NONEMPTYFIELDS respectively in nVal in
- * conjuctions with the flag bQueryByString = FALSE.
- */
-
-#define SC_EMPTYFIELDS ((double)0x0042)
-#define SC_NONEMPTYFIELDS ((double)0x0043)
-
-namespace utl
-{
- class SearchParam;
- class TextSearch;
-}
-
-struct ScQueryEntry
-{
- bool bDoQuery;
- bool bQueryByString;
- bool bQueryByDate;
- SCCOLROW nField;
- ScQueryOp eOp;
- ScQueryConnect eConnect;
- String* pStr;
- double nVal;
- mutable utl::SearchParam* pSearchParam; // if RegExp, not saved
- mutable utl::TextSearch* pSearchText; // if RegExp, not saved
-
- ScQueryEntry();
- ScQueryEntry(const ScQueryEntry& r);
- ~ScQueryEntry();
-
- // creates pSearchParam and pSearchText if necessary, always RegExp!
- utl::TextSearch* GetSearchTextPtr( bool bCaseSens ) const;
-
- void Clear();
- ScQueryEntry& operator=( const ScQueryEntry& r );
- bool operator==( const ScQueryEntry& r ) const;
-};
-
class ScArea;
struct ScConsolidateParam
diff --git a/sc/inc/lookupcache.hxx b/sc/inc/lookupcache.hxx
index 9901ba5..01ab425 100644
--- a/sc/inc/lookupcache.hxx
+++ b/sc/inc/lookupcache.hxx
@@ -31,6 +31,7 @@
#include "address.hxx"
#include "global.hxx"
+#include "queryparam.hxx"
#include "formula/token.hxx"
#include <svl/listener.hxx>
#include <tools/string.hxx>
diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx
index a083f74..105a801 100644
--- a/sc/inc/queryparam.hxx
+++ b/sc/inc/queryparam.hxx
@@ -34,8 +34,47 @@
#include <vector>
+/*
+ * dialog returns the special field values "empty"/"not empty"
+ * as constants SC_EMPTYFIELDS and SC_NONEMPTYFIELDS respectively in nVal in
+ * conjuctions with the flag bQueryByString = FALSE.
+ */
+
+#define SC_EMPTYFIELDS ((double)0x0042)
+#define SC_NONEMPTYFIELDS ((double)0x0043)
+
struct ScDBQueryParamInternal;
+namespace utl {
+ class SearchParam;
+ class TextSearch;
+}
+
+struct ScQueryEntry
+{
+ bool bDoQuery;
+ bool bQueryByString;
+ bool bQueryByDate;
+ SCCOLROW nField;
+ ScQueryOp eOp;
+ ScQueryConnect eConnect;
+ String* pStr;
+ double nVal;
+ mutable utl::SearchParam* pSearchParam; // if RegExp, not saved
+ mutable utl::TextSearch* pSearchText; // if RegExp, not saved
+
+ ScQueryEntry();
+ ScQueryEntry(const ScQueryEntry& r);
+ ~ScQueryEntry();
+
+ // creates pSearchParam and pSearchText if necessary, always RegExp!
+ utl::TextSearch* GetSearchTextPtr( bool bCaseSens ) const;
+
+ void Clear();
+ ScQueryEntry& operator=( const ScQueryEntry& r );
+ bool operator==( const ScQueryEntry& r ) const;
+};
+
struct ScQueryParamBase
{
bool bHasHeader;
diff --git a/sc/source/core/data/global2.cxx b/sc/source/core/data/global2.cxx
index 91c4ff6..28219fd 100644
--- a/sc/source/core/data/global2.cxx
+++ b/sc/source/core/data/global2.cxx
@@ -33,7 +33,6 @@
#include <sfx2/docfile.hxx>
#include <sfx2/objsh.hxx>
-#include <unotools/textsearch.hxx>
#include <unotools/pathoptions.hxx>
#include <unotools/useroptions.hxx>
#include <tools/urlobj.hxx>
@@ -123,111 +122,6 @@ bool ScImportParam::operator==( const ScImportParam& rOther ) const
}
//------------------------------------------------------------------------
-// struct ScQueryParam:
-
-ScQueryEntry::ScQueryEntry() :
- bDoQuery(false),
- bQueryByString(false),
- bQueryByDate(false),
- nField(0),
- eOp(SC_EQUAL),
- eConnect(SC_AND),
- pStr(new String),
- nVal(0.0),
- pSearchParam(NULL),
- pSearchText(NULL)
-{
-}
-
-ScQueryEntry::ScQueryEntry(const ScQueryEntry& r) :
- bDoQuery(r.bDoQuery),
- bQueryByString(r.bQueryByString),
- bQueryByDate(r.bQueryByDate),
- nField(r.nField),
- eOp(r.eOp),
- eConnect(r.eConnect),
- pStr(new String(*r.pStr)),
- nVal(r.nVal),
- pSearchParam(NULL),
- pSearchText(NULL)
-{
-}
-
-ScQueryEntry::~ScQueryEntry()
-{
- delete pStr;
- if ( pSearchParam )
- {
- delete pSearchParam;
- delete pSearchText;
- }
-}
-
-ScQueryEntry& ScQueryEntry::operator=( const ScQueryEntry& r )
-{
- bDoQuery = r.bDoQuery;
- bQueryByString = r.bQueryByString;
- bQueryByDate = r.bQueryByDate;
- eOp = r.eOp;
- eConnect = r.eConnect;
- nField = r.nField;
- nVal = r.nVal;
- *pStr = *r.pStr;
- if ( pSearchParam )
- {
- delete pSearchParam;
- delete pSearchText;
- }
- pSearchParam = NULL;
- pSearchText = NULL;
-
- return *this;
-}
-
-void ScQueryEntry::Clear()
-{
- bDoQuery = false;
- bQueryByString = false;
- bQueryByDate = false;
- eOp = SC_EQUAL;
- eConnect = SC_AND;
- nField = 0;
- nVal = 0.0;
- pStr->Erase();
- if ( pSearchParam )
- {
- delete pSearchParam;
- delete pSearchText;
- }
- pSearchParam = NULL;
- pSearchText = NULL;
-}
-
-bool ScQueryEntry::operator==( const ScQueryEntry& r ) const
-{
- return bDoQuery == r.bDoQuery
- && bQueryByString == r.bQueryByString
- && bQueryByDate == r.bQueryByDate
- && eOp == r.eOp
- && eConnect == r.eConnect
- && nField == r.nField
- && nVal == r.nVal
- && *pStr == *r.pStr;
- //! pSearchParam und pSearchText nicht vergleichen
-}
-
-utl::TextSearch* ScQueryEntry::GetSearchTextPtr( bool bCaseSens ) const
-{
- if ( !pSearchParam )
- {
- pSearchParam = new utl::SearchParam( *pStr, utl::SearchParam::SRCH_REGEXP,
- bCaseSens, false, false );
- pSearchText = new utl::TextSearch( *pSearchParam, *ScGlobal::pCharClass );
- }
- return pSearchText;
-}
-
-//------------------------------------------------------------------------
// struct ScConsolidateParam:
ScConsolidateParam::ScConsolidateParam() :
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index f75c677..44d6201 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -32,6 +32,7 @@
// INCLUDE ---------------------------------------------------------------
#include "queryparam.hxx"
+#include <unotools/textsearch.hxx>
using ::std::vector;
@@ -41,6 +42,108 @@ const SCSIZE MAXQUERY = 8;
}
+ScQueryEntry::ScQueryEntry() :
+ bDoQuery(false),
+ bQueryByString(false),
+ bQueryByDate(false),
+ nField(0),
+ eOp(SC_EQUAL),
+ eConnect(SC_AND),
+ pStr(new String),
+ nVal(0.0),
+ pSearchParam(NULL),
+ pSearchText(NULL)
+{
+}
+
+ScQueryEntry::ScQueryEntry(const ScQueryEntry& r) :
+ bDoQuery(r.bDoQuery),
+ bQueryByString(r.bQueryByString),
+ bQueryByDate(r.bQueryByDate),
+ nField(r.nField),
+ eOp(r.eOp),
+ eConnect(r.eConnect),
+ pStr(new String(*r.pStr)),
+ nVal(r.nVal),
+ pSearchParam(NULL),
+ pSearchText(NULL)
+{
+}
+
+ScQueryEntry::~ScQueryEntry()
+{
+ delete pStr;
+ if ( pSearchParam )
+ {
+ delete pSearchParam;
+ delete pSearchText;
+ }
+}
+
+ScQueryEntry& ScQueryEntry::operator=( const ScQueryEntry& r )
+{
+ bDoQuery = r.bDoQuery;
+ bQueryByString = r.bQueryByString;
+ bQueryByDate = r.bQueryByDate;
+ eOp = r.eOp;
+ eConnect = r.eConnect;
+ nField = r.nField;
+ nVal = r.nVal;
+ *pStr = *r.pStr;
+ if ( pSearchParam )
+ {
+ delete pSearchParam;
+ delete pSearchText;
+ }
+ pSearchParam = NULL;
+ pSearchText = NULL;
+
+ return *this;
+}
+
+void ScQueryEntry::Clear()
+{
+ bDoQuery = false;
+ bQueryByString = false;
+ bQueryByDate = false;
+ eOp = SC_EQUAL;
+ eConnect = SC_AND;
+ nField = 0;
+ nVal = 0.0;
+ pStr->Erase();
+ if ( pSearchParam )
+ {
+ delete pSearchParam;
+ delete pSearchText;
+ }
+ pSearchParam = NULL;
+ pSearchText = NULL;
+}
+
+bool ScQueryEntry::operator==( const ScQueryEntry& r ) const
+{
+ return bDoQuery == r.bDoQuery
+ && bQueryByString == r.bQueryByString
+ && bQueryByDate == r.bQueryByDate
+ && eOp == r.eOp
+ && eConnect == r.eConnect
+ && nField == r.nField
+ && nVal == r.nVal
+ && *pStr == *r.pStr;
+ //! pSearchParam und pSearchText nicht vergleichen
+}
+
+utl::TextSearch* ScQueryEntry::GetSearchTextPtr( bool bCaseSens ) const
+{
+ if ( !pSearchParam )
+ {
+ pSearchParam = new utl::SearchParam( *pStr, utl::SearchParam::SRCH_REGEXP,
+ bCaseSens, false, false );
+ pSearchText = new utl::TextSearch( *pSearchParam, *ScGlobal::pCharClass );
+ }
+ return pSearchText;
+}
+
// ============================================================================
ScQueryParamBase::ScQueryParamBase() :
diff --git a/sc/source/filter/inc/excrecds.hxx b/sc/source/filter/inc/excrecds.hxx
index 7da65c7..9689d01 100644
--- a/sc/source/filter/inc/excrecds.hxx
+++ b/sc/source/filter/inc/excrecds.hxx
@@ -62,6 +62,7 @@ class SfxItemSet;
class EditTextObject;
class ScPageHFItem;
class ScProgress;
+struct ScQueryEntry;
class ExcTable;
diff --git a/sc/source/filter/xml/XMLExportDataPilot.hxx b/sc/source/filter/xml/XMLExportDataPilot.hxx
index 7fa4eee..5ea7bf8 100644
--- a/sc/source/filter/xml/XMLExportDataPilot.hxx
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list