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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Jan 29 19:34:04 PST 2013


 sc/inc/attrib.hxx                |    1 -
 sc/inc/dpobject.hxx              |    4 ++--
 sc/source/core/data/documen8.cxx |    9 +++++++--
 sc/source/core/data/dpobject.cxx |   37 ++++++++++++++++++++++++++-----------
 4 files changed, 35 insertions(+), 16 deletions(-)

New commits:
commit ef6761fd95b52fc5f444dd076478300fa448ee0d
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jan 29 22:29:09 2013 -0500

    Slightly better way to skip pivot table ranges during spell check.
    
    Change-Id: I43e45cbd11f532f35ca9f0063236850ebc2e518e

diff --git a/sc/inc/attrib.hxx b/sc/inc/attrib.hxx
index 08979c2..562505d 100644
--- a/sc/inc/attrib.hxx
+++ b/sc/inc/attrib.hxx
@@ -94,7 +94,6 @@ public:
     bool    IsOverlapped() const        { return ( GetValue() & ( SC_MF_HOR | SC_MF_VER ) ) != 0; }
 
     bool    HasAutoFilter() const       { return ( GetValue() & SC_MF_AUTO ) != 0; }
-    bool    HasDPTable() const          { return ( GetValue() & SC_MF_DP_TABLE ) != 0; }
 
     bool    IsScenario() const          { return ( GetValue() & SC_MF_SCENARIO ) != 0; }
 
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index b0971ac..2c09436 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -64,6 +64,7 @@ class ScSheetSourceDesc;
 struct ScPivotField;
 class ScDPTableData;
 class ScDPDimensionSaveData;
+class ScRangeList;
 
 struct ScDPServiceDesc
 {
@@ -389,12 +390,11 @@ public:
     void FreeTable(ScDPObject* pDPObj);
     SC_DLLPUBLIC bool InsertNewTable(ScDPObject* pDPObj);
 
-    bool HasDPTable(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
-
     SheetCaches& GetSheetCaches();
     NameCaches& GetNameCaches();
     DBCaches& GetDBCaches();
 
+    ScRangeList GetAllTableRanges( SCTAB nTab ) const;
     bool IntersectsTableByColumns( SCCOL nCol1, SCCOL nCol2, SCROW nRow, SCTAB nTab ) const;
     bool IntersectsTableByRows( SCCOL nCol, SCROW nRow1, SCROW nRow2, SCTAB nTab ) const;
     bool HasTable( const ScRange& rRange ) const;
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index d36453b..134fdf3 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -668,6 +668,11 @@ bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe
             return false;
         }
     }
+
+    ScRangeList aPivotRanges;
+    if (pDPCollection)
+        aPivotRanges = pDPCollection->GetAllTableRanges(nTab);
+
     ScHorizontalCellIterator aIter( this, nTab,
                                     rSpellRange.aStart.Col(), nRow,
                                     rSpellRange.aEnd.Col(), rSpellRange.aEnd.Row() );
@@ -678,8 +683,8 @@ bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe
 
     for (; pCell; pCell = aIter.GetNext(nCol, nRow))
     {
-        if (pDPCollection && pDPCollection->HasDPTable(nCol, nRow, nTab))
-            // Don't spell check within datapilot table.
+        if (!aPivotRanges.empty() && aPivotRanges.In(ScAddress(nCol, nRow, nTab)))
+            // Don't spell check within pivot tables.
             continue;
 
         CellType eType = pCell->GetCellType();
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 6823ed5..e75e1d5 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -641,6 +641,27 @@ public:
     }
 };
 
+class AccumulateOutputRanges : std::unary_function<ScDPObject, void>
+{
+    ScRangeList maRanges;
+    SCTAB mnTab;
+public:
+    AccumulateOutputRanges(SCTAB nTab) : mnTab(nTab) {}
+    AccumulateOutputRanges(const AccumulateOutputRanges& r) : maRanges(r.maRanges), mnTab(r.mnTab) {}
+
+    void operator() (const ScDPObject& rObj)
+    {
+        const ScRange& rRange = rObj.GetOutRange();
+        if (mnTab != rRange.aStart.Tab())
+            // Not on this sheet.
+            return;
+
+        maRanges.Join(rRange);
+    }
+
+    ScRangeList getRanges() const { return maRanges; }
+};
+
 }
 
 ScDPTableData* ScDPObject::GetTableData()
@@ -3452,17 +3473,6 @@ bool ScDPCollection::InsertNewTable(ScDPObject* pDPObj)
     return true;
 }
 
-bool ScDPCollection::HasDPTable(SCCOL nCol, SCROW nRow, SCTAB nTab) const
-{
-    const ScMergeFlagAttr* pMergeAttr = static_cast<const ScMergeFlagAttr*>(
-            mpDoc->GetAttr(nCol, nRow, nTab, ATTR_MERGE_FLAG));
-
-    if (!pMergeAttr)
-        return false;
-
-    return pMergeAttr->HasDPTable();
-}
-
 ScDPCollection::SheetCaches& ScDPCollection::GetSheetCaches()
 {
     return maSheetCaches;
@@ -3478,6 +3488,11 @@ ScDPCollection::DBCaches& ScDPCollection::GetDBCaches()
     return maDBCaches;
 }
 
+ScRangeList ScDPCollection::GetAllTableRanges( SCTAB nTab ) const
+{
+    return std::for_each(maTables.begin(), maTables.end(), AccumulateOutputRanges(nTab)).getRanges();
+}
+
 bool ScDPCollection::IntersectsTableByColumns( SCCOL nCol1, SCCOL nCol2, SCROW nRow, SCTAB nTab ) const
 {
     return std::find_if(


More information about the Libreoffice-commits mailing list