[Libreoffice-commits] .: 2 commits - sc/inc sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Wed Nov 16 13:07:38 PST 2011


 sc/inc/dociter.hxx              |    6 ++
 sc/source/core/data/dociter.cxx |   83 ++++++++++++++++++++--------------------
 sc/source/ui/app/uiitems.cxx    |   36 ++++++++++++-----
 sc/source/ui/inc/filtdlg.hxx    |    1 
 sc/source/ui/inc/uiitems.hxx    |   12 +++--
 5 files changed, 80 insertions(+), 58 deletions(-)

New commits:
commit 4db12f8a9325d2fd82cba5d1e22ad59ffc4c1365
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Wed Nov 16 16:07:08 2011 -0500

    More on reducing header dependency.

diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index c06b993..48682b7 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -40,6 +40,7 @@
 #include <set>
 #include <vector>
 #include <boost/shared_ptr.hpp>
+#include <boost/scoped_ptr.hpp>
 
 class ScDocument;
 class ScBaseCell;
@@ -48,6 +49,9 @@ class ScAttrArray;
 class ScAttrIterator;
 class ScRange;
 class ScFlatBoolRowSegments;
+struct ScQueryParam;
+struct ScDBQueryParamInternal;
+struct ScDBQueryParamMatrix;
 
 class ScDocumentIterator                // walk through all non-empty cells
 {
@@ -265,7 +269,7 @@ class ScQueryCellIterator           // walk through all non-empty cells in an ar
     };
 
 private:
-    ScQueryParam    aParam;
+    boost::scoped_ptr<ScQueryParam> mpParam;
     ScDocument*     pDoc;
     const ScAttrArray*  pAttrArray;
     sal_uLong           nNumFormat;
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index f31610e..9cee166 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -46,6 +46,7 @@
 #include "cellform.hxx"
 #include "segmenttree.hxx"
 #include "progress.hxx"
+#include "queryparam.hxx"
 #include "queryentry.hxx"
 #include "globstr.hrc"
 #include "tools/fract.hxx"
@@ -1085,7 +1086,7 @@ ScBaseCell* ScCellIterator::GetNext()
 
 ScQueryCellIterator::ScQueryCellIterator(ScDocument* pDocument, SCTAB nTable,
              const ScQueryParam& rParam, sal_Bool bMod ) :
-    aParam (rParam),
+    mpParam(new ScQueryParam(rParam)),
     pDoc( pDocument ),
     nTab( nTable),
     nStopOnMismatch( nStopOnMismatchDisabled ),
@@ -1093,16 +1094,16 @@ ScQueryCellIterator::ScQueryCellIterator(ScDocument* pDocument, SCTAB nTable,
     bAdvanceQuery( false ),
     bIgnoreMismatchOnLeadingStrings( false )
 {
-    nCol = aParam.nCol1;
-    nRow = aParam.nRow1;
+    nCol = mpParam->nCol1;
+    nRow = mpParam->nRow1;
     nColRow = 0;                    // wird bei GetFirst initialisiert
     SCSIZE i;
     if (bMod)                               // sonst schon eingetragen
     {
-        SCSIZE nCount = aParam.GetEntryCount();
-        for (i = 0; (i < nCount) && (aParam.GetEntry(i).bDoQuery); ++i)
+        SCSIZE nCount = mpParam->GetEntryCount();
+        for (i = 0; (i < nCount) && (mpParam->GetEntry(i).bDoQuery); ++i)
         {
-            ScQueryEntry& rEntry = aParam.GetEntry(i);
+            ScQueryEntry& rEntry = mpParam->GetEntry(i);
             ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
             sal_uInt32 nIndex = 0;
             bool bNumber = pDoc->GetFormatTable()->IsNumberFormat(
@@ -1120,26 +1121,26 @@ ScBaseCell* ScQueryCellIterator::GetThis()
     if (nTab >= pDoc->GetTableCount())
         OSL_FAIL("try to access index out of bounds, FIX IT");
     ScColumn* pCol = &(pDoc->maTabs[nTab])->aCol[nCol];
-    const ScQueryEntry& rEntry = aParam.GetEntry(0);
+    const ScQueryEntry& rEntry = mpParam->GetEntry(0);
     const ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
 
     SCCOLROW nFirstQueryField = rEntry.nField;
     bool bAllStringIgnore = bIgnoreMismatchOnLeadingStrings &&
         rItem.meType != ScQueryEntry::ByString;
     bool bFirstStringIgnore = bIgnoreMismatchOnLeadingStrings &&
-        !aParam.bHasHeader && rItem.meType == ScQueryEntry::ByString &&
-        ((aParam.bByRow && nRow == aParam.nRow1) ||
-         (!aParam.bByRow && nCol == aParam.nCol1));
+        !mpParam->bHasHeader && rItem.meType == ScQueryEntry::ByString &&
+        ((mpParam->bByRow && nRow == mpParam->nRow1) ||
+         (!mpParam->bByRow && nCol == mpParam->nCol1));
     for ( ;; )
     {
-        if ( nRow > aParam.nRow2 )
+        if ( nRow > mpParam->nRow2 )
         {
-            nRow = aParam.nRow1;
-            if (aParam.bHasHeader && aParam.bByRow)
+            nRow = mpParam->nRow1;
+            if (mpParam->bHasHeader && mpParam->bByRow)
                 nRow++;
             do
             {
-                if ( ++nCol > aParam.nCol2 )
+                if ( ++nCol > mpParam->nCol2 )
                     return NULL;                // Ende und Aus
                 if ( bAdvanceQuery )
                 {
@@ -1150,15 +1151,15 @@ ScBaseCell* ScQueryCellIterator::GetThis()
             } while ( pCol->nCount == 0 );
             pCol->Search( nRow, nColRow );
             bFirstStringIgnore = bIgnoreMismatchOnLeadingStrings &&
-                !aParam.bHasHeader && rItem.meType == ScQueryEntry::ByString &&
-                aParam.bByRow;
+                !mpParam->bHasHeader && rItem.meType == ScQueryEntry::ByString &&
+                mpParam->bByRow;
         }
 
         while ( nColRow < pCol->nCount && pCol->pItems[nColRow].nRow < nRow )
             nColRow++;
 
         if ( nColRow < pCol->nCount &&
-                (nRow = pCol->pItems[nColRow].nRow) <= aParam.nRow2 )
+                (nRow = pCol->pItems[nColRow].nRow) <= mpParam->nRow2 )
         {
             ScBaseCell* pCell = pCol->pItems[nColRow].pCell;
             if ( pCell->GetCellType() == CELLTYPE_NOTE )
@@ -1168,7 +1169,7 @@ ScBaseCell* ScQueryCellIterator::GetThis()
             else
             {
                 bool bTestEqualCondition;
-                if ( (pDoc->maTabs[nTab])->ValidQuery( nRow, aParam,
+                if ( (pDoc->maTabs[nTab])->ValidQuery( nRow, *mpParam,
                         (nCol == static_cast<SCCOL>(nFirstQueryField) ? pCell : NULL),
                         (nTestEqualCondition ? &bTestEqualCondition : NULL) ) )
                 {
@@ -1211,7 +1212,7 @@ ScBaseCell* ScQueryCellIterator::GetThis()
             }
         }
         else
-            nRow = aParam.nRow2 + 1; // Naechste Spalte
+            nRow = mpParam->nRow2 + 1; // Naechste Spalte
         bFirstStringIgnore = false;
     }
 }
@@ -1220,9 +1221,9 @@ ScBaseCell* ScQueryCellIterator::GetFirst()
 {
     if (nTab >= pDoc->GetTableCount())
         OSL_FAIL("try to access index out of bounds, FIX IT");
-    nCol = aParam.nCol1;
-    nRow = aParam.nRow1;
-    if (aParam.bHasHeader)
+    nCol = mpParam->nCol1;
+    nRow = mpParam->nRow1;
+    if (mpParam->bHasHeader)
         nRow++;
     ScColumn* pCol = &(pDoc->maTabs[nTab])->aCol[nCol];
     pCol->Search( nRow, nColRow );
@@ -1241,10 +1242,10 @@ ScBaseCell* ScQueryCellIterator::GetNext()
 
 void ScQueryCellIterator::AdvanceQueryParamEntryField()
 {
-    SCSIZE nEntries = aParam.GetEntryCount();
+    SCSIZE nEntries = mpParam->GetEntryCount();
     for ( SCSIZE j = 0; j < nEntries; j++  )
     {
-        ScQueryEntry& rEntry = aParam.GetEntry( j );
+        ScQueryEntry& rEntry = mpParam->GetEntry( j );
         if ( rEntry.bDoQuery )
         {
             if ( rEntry.nField < MAXCOL )
@@ -1269,9 +1270,9 @@ sal_Bool ScQueryCellIterator::FindEqualOrSortedLastInRange( SCCOL& nFoundCol,
     SetStopOnMismatch( sal_True );      // assume sorted keys
     SetTestEqualCondition( sal_True );
     bIgnoreMismatchOnLeadingStrings = bIgnoreMismatchOnLeadingStringsP;
-    bool bRegExp = aParam.bRegExp && aParam.GetEntry(0).GetQueryItem().meType == ScQueryEntry::ByString;
-    bool bBinary = !bRegExp && aParam.bByRow && (aParam.GetEntry(0).eOp ==
-            SC_LESS_EQUAL || aParam.GetEntry(0).eOp == SC_GREATER_EQUAL);
+    bool bRegExp = mpParam->bRegExp && mpParam->GetEntry(0).GetQueryItem().meType == ScQueryEntry::ByString;
+    bool bBinary = !bRegExp && mpParam->bByRow && (mpParam->GetEntry(0).eOp ==
+            SC_LESS_EQUAL || mpParam->GetEntry(0).eOp == SC_GREATER_EQUAL);
     if (bBinary ? (BinarySearch() ? GetThis() : 0) : GetFirst())
     {
         // First equal entry or last smaller than (greater than) entry.
@@ -1297,10 +1298,10 @@ sal_Bool ScQueryCellIterator::FindEqualOrSortedLastInRange( SCCOL& nFoundCol,
     if ( IsEqualConditionFulfilled() )
     {
         // Position on last equal entry.
-        SCSIZE nEntries = aParam.GetEntryCount();
+        SCSIZE nEntries = mpParam->GetEntryCount();
         for ( SCSIZE j = 0; j < nEntries; j++  )
         {
-            ScQueryEntry& rEntry = aParam.GetEntry( j );
+            ScQueryEntry& rEntry = mpParam->GetEntry( j );
             if ( rEntry.bDoQuery )
             {
                 switch ( rEntry.eOp )
@@ -1333,15 +1334,15 @@ sal_Bool ScQueryCellIterator::FindEqualOrSortedLastInRange( SCCOL& nFoundCol,
         nColRow = nColRowSave;
         return sal_True;
     }
-    if ( (bSearchForEqualAfterMismatch || aParam.bRegExp) &&
+    if ( (bSearchForEqualAfterMismatch || mpParam->bRegExp) &&
             StoppedOnMismatch() )
     {
         // Assume found entry to be the last value less than respectively
         // greater than the query. But keep on searching for an equal match.
-        SCSIZE nEntries = aParam.GetEntryCount();
+        SCSIZE nEntries = mpParam->GetEntryCount();
         for ( SCSIZE j = 0; j < nEntries; j++  )
         {
-            ScQueryEntry& rEntry = aParam.GetEntry( j );
+            ScQueryEntry& rEntry = mpParam->GetEntry( j );
             if ( rEntry.bDoQuery )
             {
                 switch ( rEntry.eOp )
@@ -1387,26 +1388,26 @@ ScBaseCell* ScQueryCellIterator::BinarySearch()
 {
     if (nTab >= pDoc->GetTableCount())
         OSL_FAIL("try to access index out of bounds, FIX IT");
-    nCol = aParam.nCol1;
+    nCol = mpParam->nCol1;
     ScColumn* pCol = &(pDoc->maTabs[nTab])->aCol[nCol];
     if (!pCol->nCount)
         return 0;
 
     ScBaseCell* pCell;
     SCSIZE nHi, nLo;
-    CollatorWrapper* pCollator = (aParam.bCaseSens ? ScGlobal::GetCaseCollator() :
+    CollatorWrapper* pCollator = (mpParam->bCaseSens ? ScGlobal::GetCaseCollator() :
         ScGlobal::GetCollator());
     SvNumberFormatter& rFormatter = *(pDoc->GetFormatTable());
-    const ScQueryEntry& rEntry = aParam.GetEntry(0);
+    const ScQueryEntry& rEntry = mpParam->GetEntry(0);
     const ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
     bool bLessEqual = rEntry.eOp == SC_LESS_EQUAL;
     bool bByString = rItem.meType == ScQueryEntry::ByString;
     bool bAllStringIgnore = bIgnoreMismatchOnLeadingStrings && !bByString;
     bool bFirstStringIgnore = bIgnoreMismatchOnLeadingStrings &&
-        !aParam.bHasHeader && bByString;
+        !mpParam->bHasHeader && bByString;
 
-    nRow = aParam.nRow1;
-    if (aParam.bHasHeader)
+    nRow = mpParam->nRow1;
+    if (mpParam->bHasHeader)
         nRow++;
     const ColEntry* pItems = pCol->pItems;
     if (pCol->Search( nRow, nLo ) && bFirstStringIgnore &&
@@ -1422,7 +1423,7 @@ ScBaseCell* ScQueryCellIterator::BinarySearch()
                 (rEntry.eOp == SC_EQUAL && nTmp != 0))
             ++nLo;
     }
-    if (!pCol->Search( aParam.nRow2, nHi ) && nHi>0)
+    if (!pCol->Search( mpParam->nRow2, nHi ) && nHi>0)
         --nHi;
     while (bAllStringIgnore && nLo <= nHi && nLo < pCol->nCount &&
             pItems[nLo].pCell->HasStringData())
@@ -1638,7 +1639,7 @@ ScBaseCell* ScQueryCellIterator::BinarySearch()
         // --nLo with nLastInRange == nLo-1. Both conditions combined yield:
         nLo = nLastInRange;
     }
-    if (nLo < pCol->nCount && pCol->pItems[nLo].nRow <= aParam.nRow2)
+    if (nLo < pCol->nCount && pCol->pItems[nLo].nRow <= mpParam->nRow2)
     {
         nRow = pItems[nLo].nRow;
         pCell = pItems[nLo].pCell;
@@ -1646,7 +1647,7 @@ ScBaseCell* ScQueryCellIterator::BinarySearch()
     }
     else
     {
-        nRow = aParam.nRow2 + 1;
+        nRow = mpParam->nRow2 + 1;
         pCell = 0;
         nColRow = pCol->nCount - 1;
     }
commit 892a9ff6181cd08797359e1299e67009ba4749b8
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Wed Nov 16 15:57:53 2011 -0500

    More on reducing header dependency.

diff --git a/sc/source/ui/app/uiitems.cxx b/sc/source/ui/app/uiitems.cxx
index 78e4e67..1e2df4c 100644
--- a/sc/source/ui/app/uiitems.cxx
+++ b/sc/source/ui/app/uiitems.cxx
@@ -30,12 +30,13 @@
 #include "precompiled_sc.hxx"
 
 
-
-#include <editeng/editobj.hxx>
+#include "uiitems.hxx"
 
 #include "userlist.hxx"
-#include "uiitems.hxx"
 #include "dpsave.hxx"
+#include "queryparam.hxx"
+
+#include <editeng/editobj.hxx>
 
 // STATIC DATA -----------------------------------------------------------
 
@@ -237,10 +238,14 @@ ScQueryItem::ScQueryItem( sal_uInt16                nWhichP,
                           ScViewData*           ptrViewData,
                           const ScQueryParam*   pQueryData ) :
         SfxPoolItem ( nWhichP ),
+        mpQueryData(NULL),
         pViewData   ( ptrViewData ),
         bIsAdvanced ( false )
 {
-    if ( pQueryData ) theQueryData = *pQueryData;
+    if (pQueryData)
+        mpQueryData.reset(new ScQueryParam(*pQueryData));
+    else
+        mpQueryData.reset(new ScQueryParam);
 }
 
 //------------------------------------------------------------------------
@@ -248,20 +253,24 @@ ScQueryItem::ScQueryItem( sal_uInt16                nWhichP,
 ScQueryItem::ScQueryItem( sal_uInt16                nWhichP,
                           const ScQueryParam*   pQueryData ) :
         SfxPoolItem ( nWhichP ),
+        mpQueryData(NULL),
         pViewData   ( NULL ),
         bIsAdvanced ( false )
 {
-    if ( pQueryData ) theQueryData = *pQueryData;
+    if (pQueryData)
+        mpQueryData.reset(new ScQueryParam(*pQueryData));
+    else
+        mpQueryData.reset(new ScQueryParam);
 }
 
 //------------------------------------------------------------------------
 
 ScQueryItem::ScQueryItem( const ScQueryItem& rItem ) :
         SfxPoolItem ( rItem ),
+        mpQueryData(new ScQueryParam(*rItem.mpQueryData)),
         pViewData   ( rItem.pViewData ),
-        theQueryData( rItem.theQueryData ),
-        bIsAdvanced ( rItem.bIsAdvanced ),
-        aAdvSource  ( rItem.aAdvSource )
+        aAdvSource  ( rItem.aAdvSource ),
+        bIsAdvanced ( rItem.bIsAdvanced )
 {
 }
 
@@ -276,13 +285,18 @@ void ScQueryItem::SetAdvancedQuerySource(const ScRange* pSource)
     if (pSource)
     {
         aAdvSource = *pSource;
-        bIsAdvanced = sal_True;
+        bIsAdvanced = true;
     }
     else
         bIsAdvanced = false;
 }
 
-sal_Bool ScQueryItem::GetAdvancedQuerySource(ScRange& rSource) const
+const ScQueryParam& ScQueryItem::GetQueryData() const
+{
+    return *mpQueryData;
+}
+
+bool ScQueryItem::GetAdvancedQuerySource(ScRange& rSource) const
 {
     rSource = aAdvSource;
     return bIsAdvanced;
@@ -306,7 +320,7 @@ int ScQueryItem::operator==( const SfxPoolItem& rItem ) const
     return (   (pViewData    == rQueryItem.pViewData)
             && (bIsAdvanced  == rQueryItem.bIsAdvanced)
             && (aAdvSource   == rQueryItem.aAdvSource)
-            && (theQueryData == rQueryItem.theQueryData) );
+            && (*mpQueryData == *rQueryItem.mpQueryData) );
 }
 
 //------------------------------------------------------------------------
diff --git a/sc/source/ui/inc/filtdlg.hxx b/sc/source/ui/inc/filtdlg.hxx
index 693c2d7..865fc1b 100644
--- a/sc/source/ui/inc/filtdlg.hxx
+++ b/sc/source/ui/inc/filtdlg.hxx
@@ -36,6 +36,7 @@
 #include "global.hxx" // -> ScQueryParam
 #include "address.hxx"
 #include "anyrefdg.hxx"
+#include "queryparam.hxx"
 
 #include <deque>
 #include <vector>
diff --git a/sc/source/ui/inc/uiitems.hxx b/sc/source/ui/inc/uiitems.hxx
index 7f71a15..2e8258a 100644
--- a/sc/source/ui/inc/uiitems.hxx
+++ b/sc/source/ui/inc/uiitems.hxx
@@ -32,15 +32,17 @@
 #include "scdllapi.h"
 #include "conditio.hxx"
 #include "sortparam.hxx"
-#include "queryparam.hxx"
 #include "subtotalparam.hxx"
 #include "paramisc.hxx"
 #include <svl/poolitem.hxx>
 
+#include <boost/scoped_ptr.hpp>
+
 class ScEditEngineDefaulter;
 class EditTextObject;
 class ScViewData;
 class ScDPSaveData;
+struct ScQueryParam;
 
 // ---------------------------------------------------------------------------
 
@@ -192,16 +194,16 @@ public:
     virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;
 
     ScViewData*         GetViewData () const { return pViewData; }
-    const ScQueryParam& GetQueryData() const { return theQueryData; }
+    const ScQueryParam& GetQueryData() const;
 
-    sal_Bool        GetAdvancedQuerySource(ScRange& rSource) const;
+    bool        GetAdvancedQuerySource(ScRange& rSource) const;
     void        SetAdvancedQuerySource(const ScRange* pSource);
 
 private:
+    boost::scoped_ptr<ScQueryParam> mpQueryData;
     ScViewData*     pViewData;
-    ScQueryParam    theQueryData;
-    sal_Bool            bIsAdvanced;
     ScRange         aAdvSource;
+    bool            bIsAdvanced;
 };
 
 //----------------------------------------------------------------------------


More information about the Libreoffice-commits mailing list