diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-01-29 22:29:09 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-01-29 22:35:30 -0500 |
commit | ef6761fd95b52fc5f444dd076478300fa448ee0d (patch) | |
tree | 30308355a68856853e6f782cae7395c0e094cb8d | |
parent | 5e29af062de877476f5382e8d7368c3de4409b47 (diff) |
Slightly better way to skip pivot table ranges during spell check.
Change-Id: I43e45cbd11f532f35ca9f0063236850ebc2e518e
-rw-r--r-- | sc/inc/attrib.hxx | 1 | ||||
-rw-r--r-- | sc/inc/dpobject.hxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/documen8.cxx | 9 | ||||
-rw-r--r-- | sc/source/core/data/dpobject.cxx | 37 |
4 files changed, 35 insertions, 16 deletions
diff --git a/sc/inc/attrib.hxx b/sc/inc/attrib.hxx index 08979c25bd21..562505de141a 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 b0971ac8bce2..2c09436f377a 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 d36453b208bf..134fdf31d9c0 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 6823ed5c2b45..e75e1d51de44 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( |