[Libreoffice-commits] .: Branch 'feature/new-autofilter-popup' - 2 commits - sc/inc sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Thu Nov 3 19:57:43 PDT 2011


 sc/inc/global.hxx                           |   40 ---------
 sc/inc/lookupcache.hxx                      |    1 
 sc/inc/queryparam.hxx                       |   48 ++++++++++-
 sc/source/core/data/dptablecache.cxx        |    2 
 sc/source/core/data/global2.cxx             |  106 -------------------------
 sc/source/core/data/table3.cxx              |    2 
 sc/source/core/tool/queryparam.cxx          |  116 +++++++++++++++++++++++++++-
 sc/source/filter/inc/excrecds.hxx           |    1 
 sc/source/filter/xml/XMLExportDataPilot.hxx |    1 
 sc/source/ui/dbgui/pfiltdlg.cxx             |    2 
 sc/source/ui/inc/filtdlg.hxx                |    2 
 11 files changed, 163 insertions(+), 158 deletions(-)

New commits:
commit 175ff3d1f932063febbe46be739a69bca75f93e9
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 197f15f..b8e3184 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -720,46 +720,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
+++ b/sc/source/filter/xml/XMLExportDataPilot.hxx
@@ -43,6 +43,7 @@ class ScDPSaveGroupDimension;
 class ScDPSaveNumGroupDimension;
 struct ScDPNumGroupInfo;
 struct ScQueryParam;
+struct ScQueryEntry;
 
 class ScXMLExportDataPilot
 {
commit fa3c6191b22d25721c72ce840dbbbdd4327b6628
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Thu Nov 3 22:45:31 2011 -0400

    const correct ness etc & mutable only for lazy-initializing accessor.

diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index ead69ba..197f15f 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -745,15 +745,15 @@ struct ScQueryEntry
     ScQueryConnect  eConnect;
     String*         pStr;
     double          nVal;
-    utl::SearchParam*   pSearchParam;       // if RegExp, not saved
-    utl::TextSearch*    pSearchText;        // if RegExp, not saved
+    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 );
+    utl::TextSearch* GetSearchTextPtr( bool bCaseSens ) const;
 
     void            Clear();
     ScQueryEntry&   operator=( const ScQueryEntry& r );
diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx
index 9154224..a083f74 100644
--- a/sc/inc/queryparam.hxx
+++ b/sc/inc/queryparam.hxx
@@ -51,7 +51,8 @@ struct ScQueryParamBase
     virtual bool IsValidFieldIndex() const;
 
     SC_DLLPUBLIC SCSIZE GetEntryCount() const;
-    SC_DLLPUBLIC ScQueryEntry& GetEntry(SCSIZE n) const;
+    SC_DLLPUBLIC const ScQueryEntry& GetEntry(SCSIZE n) const;
+    SC_DLLPUBLIC ScQueryEntry& GetEntry(SCSIZE n);
     void Resize(SCSIZE nNew);
     SC_DLLPUBLIC void DeleteQuery( SCSIZE nPos );
     void FillInExcelSyntax(String& aCellStr, SCSIZE nIndex);
@@ -60,7 +61,7 @@ protected:
     ScQueryParamBase();
     ScQueryParamBase(const ScQueryParamBase& r);
 
-    mutable std::vector<ScQueryEntry>  maEntries;
+    std::vector<ScQueryEntry> maEntries;
 };
 
 // ============================================================================
@@ -92,8 +93,8 @@ struct SC_DLLPUBLIC ScQueryParam : public ScQueryParamBase, public ScQueryParamT
     ScQueryParam( const ScDBQueryParamInternal& r );
     virtual ~ScQueryParam();
 
-    ScQueryParam&   operator=   ( const ScQueryParam& r );
-    sal_Bool            operator==  ( const ScQueryParam& rOther ) const;
+    ScQueryParam&   operator=  ( const ScQueryParam& r );
+    bool            operator== ( const ScQueryParam& rOther ) const;
     void            Clear();
     void            ClearDestParams();
     void            MoveToDest();
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index b39c898..463ceb6 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -599,7 +599,7 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam, bool *pSpeci
 
     while ((i < nEntryCount) && rParam.GetEntry(i).bDoQuery)
     {
-        ScQueryEntry& rEntry = rParam.GetEntry(i);
+        const ScQueryEntry& rEntry = rParam.GetEntry(i);
         // we can only handle one single direct query
         // #i115431# nField in QueryParam is the sheet column, not the field within the source range
         SCCOL nQueryCol = (SCCOL)rEntry.nField;
diff --git a/sc/source/core/data/global2.cxx b/sc/source/core/data/global2.cxx
index 486bfda..91c4ff6 100644
--- a/sc/source/core/data/global2.cxx
+++ b/sc/source/core/data/global2.cxx
@@ -216,7 +216,7 @@ bool ScQueryEntry::operator==( const ScQueryEntry& r ) const
     //! pSearchParam und pSearchText nicht vergleichen
 }
 
-utl::TextSearch* ScQueryEntry::GetSearchTextPtr( bool bCaseSens )
+utl::TextSearch* ScQueryEntry::GetSearchTextPtr( bool bCaseSens ) const
 {
     if ( !pSearchParam )
     {
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 047a7f6..8f3c985 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1091,7 +1091,7 @@ bool ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
 
     while ( (i < nEntryCount) && rParam.GetEntry(i).bDoQuery )
     {
-        ScQueryEntry& rEntry = rParam.GetEntry(i);
+        const ScQueryEntry& rEntry = rParam.GetEntry(i);
         // we can only handle one single direct query
         if ( !pCell || i > 0 )
             pCell = GetCell( static_cast<SCCOL>(rEntry.nField), nRow );
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index 61a763c..f75c677 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -69,7 +69,12 @@ SCSIZE ScQueryParamBase::GetEntryCount() const
     return maEntries.size();
 }
 
-ScQueryEntry& ScQueryParamBase::GetEntry(SCSIZE n) const
+const ScQueryEntry& ScQueryParamBase::GetEntry(SCSIZE n) const
+{
+    return maEntries[n];
+}
+
+ScQueryEntry& ScQueryParamBase::GetEntry(SCSIZE n)
 {
     return maEntries[n];
 }
@@ -265,9 +270,9 @@ ScQueryParam& ScQueryParam::operator=( const ScQueryParam& r )
 
 //------------------------------------------------------------------------
 
-sal_Bool ScQueryParam::operator==( const ScQueryParam& rOther ) const
+bool ScQueryParam::operator==( const ScQueryParam& rOther ) const
 {
-    sal_Bool bEqual = false;
+    bool bEqual = false;
 
     // Anzahl der Queries gleich?
     SCSIZE nUsed      = 0;
@@ -297,7 +302,7 @@ sal_Bool ScQueryParam::operator==( const ScQueryParam& rOther ) const
         && (nDestCol    == rOther.nDestCol)
         && (nDestRow    == rOther.nDestRow) )
     {
-        bEqual = sal_True;
+        bEqual = true;
         for ( SCSIZE i=0; i<nUsed && bEqual; i++ )
             bEqual = maEntries[i] == rOther.maEntries[i];
     }
diff --git a/sc/source/ui/dbgui/pfiltdlg.cxx b/sc/source/ui/dbgui/pfiltdlg.cxx
index cac65a1..171a2b5 100644
--- a/sc/source/ui/dbgui/pfiltdlg.cxx
+++ b/sc/source/ui/dbgui/pfiltdlg.cxx
@@ -213,7 +213,7 @@ void ScPivotFilterDlg::Init( const SfxItemSet& rArgSet )
     {
         if ( theQueryData.GetEntry(i).bDoQuery )
         {
-            ScQueryEntry& rEntry = theQueryData.GetEntry(i);
+            const ScQueryEntry& rEntry = theQueryData.GetEntry(i);
 
             String  aValStr      = *rEntry.pStr;
             if (!rEntry.bQueryByString && aValStr == EMPTY_STRING)
diff --git a/sc/source/ui/inc/filtdlg.hxx b/sc/source/ui/inc/filtdlg.hxx
index b0842e9..99f9b00 100644
--- a/sc/source/ui/inc/filtdlg.hxx
+++ b/sc/source/ui/inc/filtdlg.hxx
@@ -125,7 +125,7 @@ private:
     ScFilterOptionsMgr* pOptionsMgr;
 
     const sal_uInt16        nWhichQuery;
-    const ScQueryParam  theQueryData;
+    ScQueryParam        theQueryData;
     ScQueryItem*        pOutItem;
     ScViewData*         pViewData;
     ScDocument*         pDoc;


More information about the Libreoffice-commits mailing list