Kaydet (Commit) ef6761fd authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Slightly better way to skip pivot table ranges during spell check.

Change-Id: I43e45cbd11f532f35ca9f0063236850ebc2e518e
üst 5e29af06
......@@ -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; }
......
......@@ -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;
......
......@@ -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();
......
......@@ -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(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment