[Libreoffice-commits] .: 3 commits - sc/inc sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Jan 29 14:41:33 PST 2013
sc/inc/document.hxx | 2
sc/inc/dpobject.hxx | 4
sc/inc/globstr.hrc | 4
sc/source/core/data/documen3.cxx | 10
sc/source/core/data/dpobject.cxx | 98 ++++++++
sc/source/ui/docshell/docfunc.cxx | 458 ++++++++++++++++++++++++++------------
sc/source/ui/inc/docfunc.hxx | 10
sc/source/ui/src/globstr.src | 5
8 files changed, 451 insertions(+), 140 deletions(-)
New commits:
commit 8a5b9413bd098b4643a0ca73eaa4834e962e5647
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Jan 29 17:39:45 2013 -0500
bnc#484599: Prevent pivot table from getting sheared when cells are shifted.
Change-Id: Ic6766105bb221aa4ebc700cbf99b4f6f5b3abf8b
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index b857cb7..8e12ba3 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -483,7 +483,9 @@ public:
SC_DLLPUBLIC const ScRangeData* GetRangeAtBlock( const ScRange& rBlock, rtl::OUString* pName=NULL ) const;
+ bool HasPivotTable() const;
SC_DLLPUBLIC ScDPCollection* GetDPCollection();
+ SC_DLLPUBLIC const ScDPCollection* GetDPCollection() const;
ScDPObject* GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
ScDPObject* GetDPAtBlock( const ScRange& rBlock ) const;
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index fc8d066..b0971ac 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -395,6 +395,10 @@ public:
NameCaches& GetNameCaches();
DBCaches& GetDBCaches();
+ 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;
+
private:
/** Only to be called from ScDPCache::RemoveReference(). */
void RemoveCache(const ScDPCache* pCache);
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index bf0451cc..7709579 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -634,6 +634,8 @@
#define STR_QUERY_FORMULA_RECALC_ONLOAD_XLS 507
#define STR_ALWAYS_PERFORM_SELECTED 508
-#define STR_COUNT 509
+#define STR_NO_INSERT_DELETE_OVER_PIVOT_TABLE 509
+
+#define STR_COUNT 510
#endif
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 1fb4c5b..60e5a4e 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -302,6 +302,11 @@ ScDBData* ScDocument::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nC
return NULL;
}
+bool ScDocument::HasPivotTable() const
+{
+ return pDPCollection && pDPCollection->GetCount();
+}
+
ScDPCollection* ScDocument::GetDPCollection()
{
if (!pDPCollection)
@@ -309,6 +314,11 @@ ScDPCollection* ScDocument::GetDPCollection()
return pDPCollection;
}
+const ScDPCollection* ScDocument::GetDPCollection() const
+{
+ return pDPCollection;
+}
+
ScDPObject* ScDocument::GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const
{
if (!pDPCollection)
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index c829268..6823ed5 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -561,6 +561,86 @@ public:
}
};
+class FindIntersectingTable : std::unary_function<ScDPObject, bool>
+{
+ ScRange maRange;
+public:
+ FindIntersectingTable(const ScRange& rRange) : maRange(rRange) {}
+
+ bool operator() (const ScDPObject& rObj) const
+ {
+ return maRange.Intersects(rObj.GetOutRange());
+ }
+};
+
+class FindIntersetingTableByColumns : std::unary_function<ScDPObject, bool>
+{
+ SCCOL mnCol1;
+ SCCOL mnCol2;
+ SCROW mnRow;
+ SCTAB mnTab;
+public:
+ FindIntersetingTableByColumns(SCCOL nCol1, SCCOL nCol2, SCROW nRow, SCTAB nTab) :
+ mnCol1(nCol1), mnCol2(nCol2), mnRow(nRow), mnTab(nTab) {}
+
+ bool operator() (const ScDPObject& rObj) const
+ {
+ const ScRange& rRange = rObj.GetOutRange();
+ if (mnTab != rRange.aStart.Tab())
+ // Not on this sheet.
+ return false;
+
+ if (rRange.aEnd.Row() < mnRow)
+ // This table is above the row. It's safe.
+ return false;
+
+ if (mnCol1 <= rRange.aStart.Col() && rRange.aEnd.Col() <= mnCol2)
+ // This table is fully enclosed in this column range.
+ return false;
+
+ if (rRange.aEnd.Col() < mnCol1 || mnCol2 < rRange.aStart.Col())
+ // This table is entirely outside this column range.
+ return false;
+
+ // This table must be intersected by this column range.
+ return true;
+ }
+};
+
+class FindIntersectingTableByRows : std::unary_function<ScDPObject, bool>
+{
+ SCCOL mnCol;
+ SCROW mnRow1;
+ SCROW mnRow2;
+ SCTAB mnTab;
+public:
+ FindIntersectingTableByRows(SCCOL nCol, SCROW nRow1, SCROW nRow2, SCTAB nTab) :
+ mnCol(nCol), mnRow1(nRow1), mnRow2(nRow2), mnTab(nTab) {}
+
+ bool operator() (const ScDPObject& rObj) const
+ {
+ const ScRange& rRange = rObj.GetOutRange();
+ if (mnTab != rRange.aStart.Tab())
+ // Not on this sheet.
+ return false;
+
+ if (rRange.aEnd.Col() < mnCol)
+ // This table is to the left of the column. It's safe.
+ return false;
+
+ if (mnRow1 <= rRange.aStart.Row() && rRange.aEnd.Row() <= mnRow2)
+ // This table is fully enclosed in this row range.
+ return false;
+
+ if (rRange.aEnd.Row() < mnRow1 || mnRow2 < rRange.aStart.Row())
+ // This table is entirely outside this row range.
+ return false;
+
+ // This table must be intersected by this row range.
+ return true;
+ }
+};
+
}
ScDPTableData* ScDPObject::GetTableData()
@@ -3398,6 +3478,24 @@ ScDPCollection::DBCaches& ScDPCollection::GetDBCaches()
return maDBCaches;
}
+bool ScDPCollection::IntersectsTableByColumns( SCCOL nCol1, SCCOL nCol2, SCROW nRow, SCTAB nTab ) const
+{
+ return std::find_if(
+ maTables.begin(), maTables.end(), FindIntersetingTableByColumns(nCol1, nCol2, nRow, nTab)) != maTables.end();
+}
+
+bool ScDPCollection::IntersectsTableByRows( SCCOL nCol, SCROW nRow1, SCROW nRow2, SCTAB nTab ) const
+{
+ return std::find_if(
+ maTables.begin(), maTables.end(), FindIntersectingTableByRows(nCol, nRow1, nRow2, nTab)) != maTables.end();
+}
+
+bool ScDPCollection::HasTable( const ScRange& rRange ) const
+{
+ return std::find_if(
+ maTables.begin(), maTables.end(), FindIntersectingTable(rRange)) != maTables.end();
+}
+
void ScDPCollection::RemoveCache(const ScDPCache* pCache)
{
if (maSheetCaches.remove(pCache))
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index b8f17c5..770180d4 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -79,6 +79,7 @@
#include "externalrefmgr.hxx"
#include "undorangename.hxx"
#include "progress.hxx"
+#include "dpobject.hxx"
#include <memory>
#include <basic/basmgr.hxx>
@@ -1346,7 +1347,182 @@ sal_Bool ScDocFunc::ApplyStyle( const ScMarkData& rMark, const String& rStyleNam
return sal_True;
}
-//------------------------------------------------------------------------
+namespace {
+
+/**
+ * Check if this insertion attempt would end up cutting one or more pivot
+ * tables in half, which is not desirable.
+ *
+ * @return true if this insertion can be done safely without shearing any
+ * existing pivot tables, false otherwise.
+ */
+bool canInsertCellsByPivot(const ScRange& rRange, const ScMarkData& rMarkData, InsCellCmd eCmd, const ScDocument* pDoc)
+{
+ if (!pDoc->HasPivotTable())
+ // This document has no pivot tables.
+ return true;
+
+ const ScDPCollection* pDPs = pDoc->GetDPCollection();
+ ScMarkData::const_iterator itBeg = rMarkData.begin(), itEnd = rMarkData.end();
+
+ ScRange aRange(rRange); // local copy
+ switch (eCmd)
+ {
+ case INS_INSROWS:
+ {
+ aRange.aStart.SetCol(0);
+ aRange.aEnd.SetCol(MAXCOL);
+ // Continue below.
+ }
+ case INS_CELLSDOWN:
+ {
+ for (ScMarkData::const_iterator it = itBeg; it != itEnd; ++it)
+ {
+ if (pDPs->IntersectsTableByColumns(aRange.aStart.Col(), aRange.aEnd.Col(), aRange.aStart.Row(), *it))
+ // This column range cuts through at least one pivot table. Not good.
+ return false;
+ }
+
+ // Start row must be either at the top or above any pivot tables.
+ if (aRange.aStart.Row() < 0)
+ // I don't know how to handle this case.
+ return false;
+
+ if (aRange.aStart.Row() == 0)
+ // First row is always allowed.
+ return true;
+
+ ScRange aTest(aRange);
+ aTest.aStart.IncRow(-1); // Test one row up.
+ aTest.aEnd.SetRow(aTest.aStart.Row());
+ for (ScMarkData::const_iterator it = itBeg; it != itEnd; ++it)
+ {
+ aTest.aStart.SetTab(*it);
+ aTest.aEnd.SetTab(*it);
+ if (pDPs->HasTable(aTest))
+ return false;
+ }
+ }
+ break;
+ case INS_INSCOLS:
+ {
+ aRange.aStart.SetRow(0);
+ aRange.aEnd.SetRow(MAXROW);
+ // Continue below.
+ }
+ case INS_CELLSRIGHT:
+ {
+ for (ScMarkData::const_iterator it = itBeg; it != itEnd; ++it)
+ {
+ if (pDPs->IntersectsTableByRows(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Row(), *it))
+ // This column range cuts through at least one pivot table. Not good.
+ return false;
+ }
+
+ // Start row must be either at the top or above any pivot tables.
+ if (aRange.aStart.Col() < 0)
+ // I don't know how to handle this case.
+ return false;
+
+ if (aRange.aStart.Col() == 0)
+ // First row is always allowed.
+ return true;
+
+ ScRange aTest(aRange);
+ aTest.aStart.IncCol(-1); // Test one column to the left.
+ aTest.aEnd.SetCol(aTest.aStart.Col());
+ for (ScMarkData::const_iterator it = itBeg; it != itEnd; ++it)
+ {
+ aTest.aStart.SetTab(*it);
+ aTest.aEnd.SetTab(*it);
+ if (pDPs->HasTable(aTest))
+ return false;
+ }
+ }
+ break;
+ default:
+ ;
+ }
+ return true;
+}
+
+/**
+ * Check if this deletion attempt would end up cutting one or more pivot
+ * tables in half, which is not desirable.
+ *
+ * @return true if this deletion can be done safely without shearing any
+ * existing pivot tables, false otherwise.
+ */
+bool canDeleteCellsByPivot(const ScRange& rRange, const ScMarkData& rMarkData, DelCellCmd eCmd, const ScDocument* pDoc)
+{
+ if (!pDoc->HasPivotTable())
+ // This document has no pivot tables.
+ return true;
+
+ const ScDPCollection* pDPs = pDoc->GetDPCollection();
+ ScMarkData::const_iterator itBeg = rMarkData.begin(), itEnd = rMarkData.end();
+
+ ScRange aRange(rRange); // local copy
+
+ switch (eCmd)
+ {
+ case DEL_DELROWS:
+ {
+ aRange.aStart.SetCol(0);
+ aRange.aEnd.SetCol(MAXCOL);
+ // Continue below.
+ }
+ case DEL_CELLSUP:
+ {
+ for (ScMarkData::const_iterator it = itBeg; it != itEnd; ++it)
+ {
+ if (pDPs->IntersectsTableByColumns(aRange.aStart.Col(), aRange.aEnd.Col(), aRange.aStart.Row(), *it))
+ // This column range cuts through at least one pivot table. Not good.
+ return false;
+ }
+
+ ScRange aTest(aRange);
+ for (ScMarkData::const_iterator it = itBeg; it != itEnd; ++it)
+ {
+ aTest.aStart.SetTab(*it);
+ aTest.aEnd.SetTab(*it);
+ if (pDPs->HasTable(aTest))
+ return false;
+ }
+ }
+ break;
+ case DEL_DELCOLS:
+ {
+ aRange.aStart.SetRow(0);
+ aRange.aEnd.SetRow(MAXROW);
+ // Continue below.
+ }
+ case DEL_CELLSLEFT:
+ {
+ for (ScMarkData::const_iterator it = itBeg; it != itEnd; ++it)
+ {
+ if (pDPs->IntersectsTableByRows(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Row(), *it))
+ // This column range cuts through at least one pivot table. Not good.
+ return false;
+ }
+
+ ScRange aTest(aRange);
+ for (ScMarkData::const_iterator it = itBeg; it != itEnd; ++it)
+ {
+ aTest.aStart.SetTab(*it);
+ aTest.aEnd.SetTab(*it);
+ if (pDPs->HasTable(aTest))
+ return false;
+ }
+ }
+ break;
+ default:
+ ;
+ }
+ return true;
+}
+
+}
bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark, InsCellCmd eCmd,
bool bRecord, bool bApi, bool bPartOfPaste )
@@ -1463,6 +1639,14 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark,
return false;
}
+ // Check if this insertion is allowed with respect to pivot table.
+ if (!canInsertCellsByPivot(rRange, aMark, eCmd, pDoc))
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_NO_INSERT_DELETE_OVER_PIVOT_TABLE);
+ return false;
+ }
+
WaitObject aWait( rDocShell.GetActiveDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference
ScDocument* pRefUndoDoc = NULL;
@@ -1880,6 +2064,12 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
return false;
}
+ if (!canDeleteCellsByPivot(rRange, aMark, eCmd, pDoc))
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_NO_INSERT_DELETE_OVER_PIVOT_TABLE);
+ return false;
+ }
// Test zusammengefasste
SCCOL nMergeTestEndCol = (eCmd==DEL_CELLSLEFT) ? MAXCOL : nUndoEndCol;
diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src
index 6d53c05..7305950 100644
--- a/sc/source/ui/src/globstr.src
+++ b/sc/source/ui/src/globstr.src
@@ -2017,5 +2017,10 @@ Resource RID_GLOBSTR
{
Text [ en-US ] = "Always perform this without prompt in the future.";
};
+
+ String STR_NO_INSERT_DELETE_OVER_PIVOT_TABLE
+ {
+ Text [ en-US ] = "You cannot insert or delete cells when the affected range intersects with pivot table.";
+ };
};
commit 0941a1b0ad99be73f1b051aae79a7a433fefeadf
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Jan 29 11:41:13 2013 -0500
Let's stick with FooCol, FooRow naming as opposed to FooX, FooY.
The latter always confuses me, which likely would lead to bugs caused
by brain shortcircuiting.
Change-Id: Ide7545d8d28e89265cad0d4457ab29cecc1869d3
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index a6a7661..b8f17c5 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -1368,10 +1368,10 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark,
ScDocument* pDoc = rDocShell.GetDocument();
SCTAB nTabCount = pDoc->GetTableCount();
- SCCOL nPaintStartX = nStartCol;
- SCROW nPaintStartY = nStartRow;
- SCCOL nPaintEndX = nEndCol;
- SCROW nPaintEndY = nEndRow;
+ SCCOL nPaintStartCol = nStartCol;
+ SCROW nPaintStartRow = nStartRow;
+ SCCOL nPaintEndCol = nEndCol;
+ SCROW nPaintEndRow = nEndRow;
sal_uInt16 nPaintFlags = PAINT_GRID;
bool bSuccess;
SCTAB i;
@@ -1419,10 +1419,10 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark,
// zugehoerige Szenarien auch anpassen
// Test zusammengefasste
- SCCOL nMergeTestStartX = nStartCol;
- SCROW nMergeTestStartY = nStartRow;
- SCCOL nMergeTestEndX = nEndCol;
- SCROW nMergeTestEndY = nEndRow;
+ SCCOL nMergeTestStartCol = nStartCol;
+ SCROW nMergeTestStartRow = nStartRow;
+ SCCOL nMergeTestEndCol = nEndCol;
+ SCROW nMergeTestEndRow = nEndRow;
ScRange aExtendMergeRange( rRange );
@@ -1430,32 +1430,32 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark,
{
pDoc->ExtendMerge( aExtendMergeRange );
pDoc->ExtendOverlapped( aExtendMergeRange );
- nMergeTestEndX = aExtendMergeRange.aEnd.Col();
- nMergeTestEndY = aExtendMergeRange.aEnd.Row();
- nPaintEndX = nMergeTestEndX;
- nPaintEndY = nMergeTestEndY;
+ nMergeTestEndCol = aExtendMergeRange.aEnd.Col();
+ nMergeTestEndRow = aExtendMergeRange.aEnd.Row();
+ nPaintEndCol = nMergeTestEndCol;
+ nPaintEndRow = nMergeTestEndRow;
}
if ( eCmd == INS_INSROWS )
{
- nMergeTestStartX = 0;
- nMergeTestEndX = MAXCOL;
+ nMergeTestStartCol = 0;
+ nMergeTestEndCol = MAXCOL;
}
if ( eCmd == INS_INSCOLS )
{
- nMergeTestStartY = 0;
- nMergeTestEndY = MAXROW;
+ nMergeTestStartRow = 0;
+ nMergeTestEndRow = MAXROW;
}
if ( eCmd == INS_CELLSDOWN )
- nMergeTestEndY = MAXROW;
+ nMergeTestEndRow = MAXROW;
if ( eCmd == INS_CELLSRIGHT )
- nMergeTestEndX = MAXCOL;
+ nMergeTestEndCol = MAXCOL;
bool bNeedRefresh = false;
- SCCOL nEditTestEndX = (eCmd==INS_INSCOLS) ? MAXCOL : nMergeTestEndX;
- SCROW nEditTestEndY = (eCmd==INS_INSROWS) ? MAXROW : nMergeTestEndY;
- ScEditableTester aTester( pDoc, nMergeTestStartX, nMergeTestStartY, nEditTestEndX, nEditTestEndY, aMark );
+ SCCOL nEditTestEndCol = (eCmd==INS_INSCOLS) ? MAXCOL : nMergeTestEndCol;
+ SCROW nEditTestEndRow = (eCmd==INS_INSROWS) ? MAXROW : nMergeTestEndRow;
+ ScEditableTester aTester( pDoc, nMergeTestStartCol, nMergeTestStartRow, nEditTestEndCol, nEditTestEndRow, aMark );
if (!aTester.IsEditable())
{
if (!bApi)
@@ -1493,21 +1493,21 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark,
pDoc->InitializeNoteCaptions(*itr);
i = *itr;
- if( pDoc->HasAttrib( nMergeTestStartX, nMergeTestStartY, i, nMergeTestEndX, nMergeTestEndY, i, HASATTR_MERGED | HASATTR_OVERLAPPED ) )
+ if( pDoc->HasAttrib( nMergeTestStartCol, nMergeTestStartRow, i, nMergeTestEndCol, nMergeTestEndRow, i, HASATTR_MERGED | HASATTR_OVERLAPPED ) )
{
if (eCmd==INS_CELLSRIGHT)
bNeedRefresh = true;
- SCCOL nMergeStartX = nMergeTestStartX;
- SCROW nMergeStartY = nMergeTestStartY;
- SCCOL nMergeEndX = nMergeTestEndX;
- SCROW nMergeEndY = nMergeTestEndY;
+ SCCOL nMergeStartCol = nMergeTestStartCol;
+ SCROW nMergeStartRow = nMergeTestStartRow;
+ SCCOL nMergeEndCol = nMergeTestEndCol;
+ SCROW nMergeEndRow = nMergeTestEndRow;
- pDoc->ExtendMerge( nMergeStartX, nMergeStartY, nMergeEndX, nMergeEndY, i );
- pDoc->ExtendOverlapped( nMergeStartX, nMergeStartY, nMergeEndX, nMergeEndY, i );
+ pDoc->ExtendMerge( nMergeStartCol, nMergeStartRow, nMergeEndCol, nMergeEndRow, i );
+ pDoc->ExtendOverlapped( nMergeStartCol, nMergeStartRow, nMergeEndCol, nMergeEndRow, i );
- if(( eCmd == INS_CELLSDOWN && ( nMergeStartX != nMergeTestStartX || nMergeEndX != nMergeTestEndX )) ||
- (eCmd == INS_CELLSRIGHT && ( nMergeStartY != nMergeTestStartY || nMergeEndY != nMergeTestEndY )) )
+ if(( eCmd == INS_CELLSDOWN && ( nMergeStartCol != nMergeTestStartCol || nMergeEndCol != nMergeTestEndCol )) ||
+ (eCmd == INS_CELLSRIGHT && ( nMergeStartRow != nMergeTestStartRow || nMergeEndRow != nMergeTestEndRow )) )
{
if (!bApi)
rDocShell.ErrorMessage(STR_MSSG_INSERTCELLS_0);
@@ -1519,8 +1519,8 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark,
SCROW nTestRow1 = -1;
SCROW nTestRow2 = -1;
- ScDocAttrIterator aTestIter( pDoc, i, nMergeTestStartX, nMergeTestStartY, nMergeTestEndX, nMergeTestEndY );
- ScRange aExtendRange( nMergeTestStartX, nMergeTestStartY, i, nMergeTestEndX, nMergeTestEndY, i );
+ ScDocAttrIterator aTestIter( pDoc, i, nMergeTestStartCol, nMergeTestStartRow, nMergeTestEndCol, nMergeTestEndRow );
+ ScRange aExtendRange( nMergeTestStartCol, nMergeTestStartRow, i, nMergeTestEndCol, nMergeTestEndRow, i );
const ScPatternAttr* pPattern = NULL;
const ScMergeAttr* pMergeFlag = NULL;
const ScMergeFlagAttr* pMergeFlagAttr = NULL;
@@ -1570,7 +1570,7 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark,
nEndRow = aExtendMergeRange.aEnd.Row();
if( eCmd == INS_CELLSDOWN )
- nEndCol = nMergeTestEndX;
+ nEndCol = nMergeTestEndCol;
else
{
nStartCol = 0;
@@ -1584,7 +1584,7 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark,
nEndCol = aExtendMergeRange.aEnd.Col();
if( eCmd == INS_CELLSRIGHT )
{
- nEndRow = nMergeTestEndY;
+ nEndRow = nMergeTestEndRow;
}
else
{
@@ -1619,24 +1619,24 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark,
{
case INS_CELLSDOWN:
bSuccess = pDoc->InsertRow( nStartCol, 0, nEndCol, MAXTAB, nStartRow, static_cast<SCSIZE>(nEndRow-nStartRow+1), pRefUndoDoc, &aFullMark );
- nPaintEndY = MAXROW;
+ nPaintEndRow = MAXROW;
break;
case INS_INSROWS:
bSuccess = pDoc->InsertRow( 0, 0, MAXCOL, MAXTAB, nStartRow, static_cast<SCSIZE>(nEndRow-nStartRow+1), pRefUndoDoc, &aFullMark );
- nPaintStartX = 0;
- nPaintEndX = MAXCOL;
- nPaintEndY = MAXROW;
+ nPaintStartCol = 0;
+ nPaintEndCol = MAXCOL;
+ nPaintEndRow = MAXROW;
nPaintFlags |= PAINT_LEFT;
break;
case INS_CELLSRIGHT:
bSuccess = pDoc->InsertCol( nStartRow, 0, nEndRow, MAXTAB, nStartCol, static_cast<SCSIZE>(nEndCol-nStartCol+1), pRefUndoDoc, &aFullMark );
- nPaintEndX = MAXCOL;
+ nPaintEndCol = MAXCOL;
break;
case INS_INSCOLS:
bSuccess = pDoc->InsertCol( 0, 0, MAXROW, MAXTAB, nStartCol, static_cast<SCSIZE>(nEndCol-nStartCol+1), pRefUndoDoc, &aFullMark );
- nPaintStartY = 0;
- nPaintEndY = MAXROW;
- nPaintEndX = MAXCOL;
+ nPaintStartRow = 0;
+ nPaintEndRow = MAXROW;
+ nPaintEndCol = MAXCOL;
nPaintFlags |= PAINT_TOP;
break;
default:
@@ -1717,15 +1717,15 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark,
pDoc->SetDrawPageSize(i);
if (bNeedRefresh)
- pDoc->ExtendMerge( nMergeTestStartX, nMergeTestStartY, nMergeTestEndX, nMergeTestEndY, i, true );
+ pDoc->ExtendMerge( nMergeTestStartCol, nMergeTestStartRow, nMergeTestEndCol, nMergeTestEndRow, i, true );
else
- pDoc->RefreshAutoFilter( nMergeTestStartX, nMergeTestStartY, nMergeTestEndX, nMergeTestEndY, i );
+ pDoc->RefreshAutoFilter( nMergeTestStartCol, nMergeTestStartRow, nMergeTestEndCol, nMergeTestEndRow, i );
if ( eCmd == INS_INSROWS || eCmd == INS_INSCOLS )
pDoc->UpdatePageBreaks( i );
sal_uInt16 nExtFlags = 0;
- rDocShell.UpdatePaintExt( nExtFlags, nPaintStartX, nPaintStartY, i, nPaintEndX, nPaintEndY, i );
+ rDocShell.UpdatePaintExt( nExtFlags, nPaintStartCol, nPaintStartRow, i, nPaintEndCol, nPaintEndRow, i );
SCTAB nScenarioCount = 0;
@@ -1733,15 +1733,15 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark,
nScenarioCount ++;
bool bAdjusted = ( eCmd == INS_INSROWS ) ? AdjustRowHeight(ScRange(0, nStartRow, i, MAXCOL, nEndRow, i+nScenarioCount )) :
- AdjustRowHeight(ScRange(0, nPaintStartY, i, MAXCOL, nPaintEndY, i+nScenarioCount ));
+ AdjustRowHeight(ScRange(0, nPaintStartRow, i, MAXCOL, nPaintEndRow, i+nScenarioCount ));
if (bAdjusted)
{
// paint only what is not done by AdjustRowHeight
if (nPaintFlags & PAINT_TOP)
- rDocShell.PostPaint( nPaintStartX, nPaintStartY, i, nPaintEndX, nPaintEndY, i+nScenarioCount, PAINT_TOP );
+ rDocShell.PostPaint( nPaintStartCol, nPaintStartRow, i, nPaintEndCol, nPaintEndRow, i+nScenarioCount, PAINT_TOP );
}
else
- rDocShell.PostPaint( nPaintStartX, nPaintStartY, i, nPaintEndX, nPaintEndY, i+nScenarioCount, nPaintFlags, nExtFlags );
+ rDocShell.PostPaint( nPaintStartCol, nPaintStartRow, i, nPaintEndCol, nPaintEndRow, i+nScenarioCount, nPaintFlags, nExtFlags );
}
}
else
@@ -1800,10 +1800,10 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
ScDocument* pDoc = rDocShell.GetDocument();
SCTAB nTabCount = pDoc->GetTableCount();
- SCCOL nPaintStartX = nStartCol;
- SCROW nPaintStartY = nStartRow;
- SCCOL nPaintEndX = nEndCol;
- SCROW nPaintEndY = nEndRow;
+ SCCOL nPaintStartCol = nStartCol;
+ SCROW nPaintStartRow = nStartRow;
+ SCCOL nPaintEndCol = nEndCol;
+ SCROW nPaintEndRow = nEndRow;
sal_uInt16 nPaintFlags = PAINT_GRID;
if (bRecord && !pDoc->IsUndoEnabled())
@@ -1837,10 +1837,10 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
SCTAB nSelCount = aMark.GetSelectCount();
- SCCOL nUndoStartX = nStartCol;
- SCROW nUndoStartY = nStartRow;
- SCCOL nUndoEndX = nEndCol;
- SCROW nUndoEndY = nEndRow;
+ SCCOL nUndoStartCol = nStartCol;
+ SCROW nUndoStartRow = nStartRow;
+ SCCOL nUndoEndCol = nEndCol;
+ SCROW nUndoEndRow = nEndRow;
ScRange aExtendMergeRange( rRange );
@@ -1848,31 +1848,31 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
{
pDoc->ExtendMerge( aExtendMergeRange );
pDoc->ExtendOverlapped( aExtendMergeRange );
- nUndoEndX = aExtendMergeRange.aEnd.Col();
- nUndoEndY = aExtendMergeRange.aEnd.Row();
- nPaintEndX = nUndoEndX;
- nPaintEndY = nUndoEndY;
+ nUndoEndCol = aExtendMergeRange.aEnd.Col();
+ nUndoEndRow = aExtendMergeRange.aEnd.Row();
+ nPaintEndCol = nUndoEndCol;
+ nPaintEndRow = nUndoEndRow;
}
if (eCmd==DEL_DELROWS)
{
- nUndoStartX = 0;
- nUndoEndX = MAXCOL;
+ nUndoStartCol = 0;
+ nUndoEndCol = MAXCOL;
}
if (eCmd==DEL_DELCOLS)
{
- nUndoStartY = 0;
- nUndoEndY = MAXROW;
+ nUndoStartRow = 0;
+ nUndoEndRow = MAXROW;
}
// Test Zellschutz
- SCCOL nEditTestEndX = nUndoEndX;
+ SCCOL nEditTestEndX = nUndoEndCol;
if ( eCmd==DEL_DELCOLS || eCmd==DEL_CELLSLEFT )
nEditTestEndX = MAXCOL;
- SCROW nEditTestEndY = nUndoEndY;
+ SCROW nEditTestEndY = nUndoEndRow;
if ( eCmd==DEL_DELROWS || eCmd==DEL_CELLSUP )
nEditTestEndY = MAXROW;
- ScEditableTester aTester( pDoc, nUndoStartX, nUndoStartY, nEditTestEndX, nEditTestEndY, aMark );
+ ScEditableTester aTester( pDoc, nUndoStartCol, nUndoStartRow, nEditTestEndX, nEditTestEndY, aMark );
if (!aTester.IsEditable())
{
if (!bApi)
@@ -1882,10 +1882,10 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
// Test zusammengefasste
- SCCOL nMergeTestEndX = (eCmd==DEL_CELLSLEFT) ? MAXCOL : nUndoEndX;
- SCROW nMergeTestEndY = (eCmd==DEL_CELLSUP) ? MAXROW : nUndoEndY;
- SCCOL nExtendStartCol = nUndoStartX;
- SCROW nExtendStartRow = nUndoStartY;
+ SCCOL nMergeTestEndCol = (eCmd==DEL_CELLSLEFT) ? MAXCOL : nUndoEndCol;
+ SCROW nMergeTestEndRow = (eCmd==DEL_CELLSUP) ? MAXROW : nUndoEndRow;
+ SCCOL nExtendStartCol = nUndoStartCol;
+ SCROW nExtendStartRow = nUndoStartRow;
bool bNeedRefresh = false;
//Issue 8302 want to be able to insert into the middle of merged cells
@@ -1902,17 +1902,17 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
pDoc->InitializeNoteCaptions(*itr);
SCTAB i = *itr;
- if ( pDoc->HasAttrib( nUndoStartX, nUndoStartY, i, nMergeTestEndX, nMergeTestEndY, i, HASATTR_MERGED | HASATTR_OVERLAPPED ))
+ if ( pDoc->HasAttrib( nUndoStartCol, nUndoStartRow, i, nMergeTestEndCol, nMergeTestEndRow, i, HASATTR_MERGED | HASATTR_OVERLAPPED ))
{
- SCCOL nMergeStartX = nUndoStartX;
- SCROW nMergeStartY = nUndoStartY;
- SCCOL nMergeEndX = nMergeTestEndX;
- SCROW nMergeEndY = nMergeTestEndY;
-
- pDoc->ExtendMerge( nMergeStartX, nMergeStartY, nMergeEndX, nMergeEndY, i );
- pDoc->ExtendOverlapped( nMergeStartX, nMergeStartY, nMergeEndX, nMergeEndY, i );
- if( ( eCmd == DEL_CELLSUP && ( nMergeStartX != nUndoStartX || nMergeEndX != nMergeTestEndX))||
- ( eCmd == DEL_CELLSLEFT && ( nMergeStartY != nUndoStartY || nMergeEndY != nMergeTestEndY)))
+ SCCOL nMergeStartCol = nUndoStartCol;
+ SCROW nMergeStartRow = nUndoStartRow;
+ SCCOL nMergeEndCol = nMergeTestEndCol;
+ SCROW nMergeEndRow = nMergeTestEndRow;
+
+ pDoc->ExtendMerge( nMergeStartCol, nMergeStartRow, nMergeEndCol, nMergeEndRow, i );
+ pDoc->ExtendOverlapped( nMergeStartCol, nMergeStartRow, nMergeEndCol, nMergeEndRow, i );
+ if( ( eCmd == DEL_CELLSUP && ( nMergeStartCol != nUndoStartCol || nMergeEndCol != nMergeTestEndCol))||
+ ( eCmd == DEL_CELLSLEFT && ( nMergeStartRow != nUndoStartRow || nMergeEndRow != nMergeTestEndRow)))
{
if (!bApi)
rDocShell.ErrorMessage(STR_MSSG_DELETECELLS_0);
@@ -1920,14 +1920,14 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
return false;
}
- nExtendStartCol = nMergeStartX;
- nExtendStartRow = nMergeStartY;
+ nExtendStartCol = nMergeStartCol;
+ nExtendStartRow = nMergeStartRow;
SCCOL nTestCol = -1;
SCROW nTestRow1 = -1;
SCROW nTestRow2 = -1;
- ScDocAttrIterator aTestIter( pDoc, i, nUndoStartX, nUndoStartY, nMergeTestEndX, nMergeTestEndY );
- ScRange aExtendRange( nUndoStartX, nUndoStartY, i, nMergeTestEndX, nMergeTestEndY, i );
+ ScDocAttrIterator aTestIter( pDoc, i, nUndoStartCol, nUndoStartRow, nMergeTestEndCol, nMergeTestEndRow );
+ ScRange aExtendRange( nUndoStartCol, nUndoStartRow, i, nMergeTestEndCol, nMergeTestEndRow, i );
const ScPatternAttr* pPattern = NULL;
const ScMergeAttr* pMergeFlag = NULL;
const ScMergeFlagAttr* pMergeFlagAttr = NULL;
@@ -2051,7 +2051,7 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
for( SCTAB j = *itr+1; j<nTabCount && pDoc->IsScenario(j); j++ )
nScenarioCount ++;
- pDoc->CopyToDocument( nUndoStartX, nUndoStartY, *itr, nUndoEndX, nUndoEndY, *itr+nScenarioCount,
+ pDoc->CopyToDocument( nUndoStartCol, nUndoStartRow, *itr, nUndoEndCol, nUndoEndRow, *itr+nScenarioCount,
IDF_ALL | IDF_NOCAPTIONS, false, pUndoDoc );
}
@@ -2075,24 +2075,24 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
{
case DEL_CELLSUP:
pDoc->DeleteRow( nStartCol, 0, nEndCol, MAXTAB, nStartRow, static_cast<SCSIZE>(nEndRow-nStartRow+1), pRefUndoDoc, NULL, &aFullMark );
- nPaintEndY = MAXROW;
+ nPaintEndRow = MAXROW;
break;
case DEL_DELROWS:
pDoc->DeleteRow( 0, 0, MAXCOL, MAXTAB, nStartRow, static_cast<SCSIZE>(nEndRow-nStartRow+1), pRefUndoDoc, &bUndoOutline, &aFullMark );
- nPaintStartX = 0;
- nPaintEndX = MAXCOL;
- nPaintEndY = MAXROW;
+ nPaintStartCol = 0;
+ nPaintEndCol = MAXCOL;
+ nPaintEndRow = MAXROW;
nPaintFlags |= PAINT_LEFT;
break;
case DEL_CELLSLEFT:
pDoc->DeleteCol( nStartRow, 0, nEndRow, MAXTAB, nStartCol, static_cast<SCSIZE>(nEndCol-nStartCol+1), pRefUndoDoc, NULL, &aFullMark );
- nPaintEndX = MAXCOL;
+ nPaintEndCol = MAXCOL;
break;
case DEL_DELCOLS:
pDoc->DeleteCol( 0, 0, MAXROW, MAXTAB, nStartCol, static_cast<SCSIZE>(nEndCol-nStartCol+1), pRefUndoDoc, &bUndoOutline, &aFullMark );
- nPaintStartY = 0;
- nPaintEndY = MAXROW;
- nPaintEndX = MAXCOL;
+ nPaintStartRow = 0;
+ nPaintEndRow = MAXROW;
+ nPaintEndCol = MAXCOL;
nPaintFlags |= PAINT_TOP;
break;
default:
@@ -2106,7 +2106,7 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
{
itr = aFullMark.begin(), itrEnd = aFullMark.end();
for (; itr != itrEnd && *itr < nTabCount; ++itr)
- pRefUndoDoc->DeleteAreaTab(nUndoStartX,nUndoStartY,nUndoEndX,nUndoEndY, *itr, IDF_ALL);
+ pRefUndoDoc->DeleteAreaTab(nUndoStartCol,nUndoStartRow,nUndoEndCol,nUndoEndRow, *itr, IDF_ALL);
// alle Tabellen anlegen, damit Formeln kopiert werden koennen:
pUndoDoc->AddUndoTab( 0, nTabCount-1, false, false );
@@ -2200,13 +2200,13 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
// not only for whole columns/rows
if ( eCmd==DEL_DELCOLS || eCmd==DEL_CELLSLEFT )
- nMergeTestEndX = MAXCOL;
+ nMergeTestEndCol = MAXCOL;
if ( eCmd==DEL_DELROWS || eCmd==DEL_CELLSUP )
- nMergeTestEndY = MAXROW;
+ nMergeTestEndRow = MAXROW;
ScPatternAttr aPattern( pDoc->GetPool() );
aPattern.GetItemSet().Put( ScMergeFlagAttr() );
- pDoc->ApplyPatternArea( nExtendStartCol, nExtendStartRow, nMergeTestEndX, nMergeTestEndY, aMark, aPattern );
+ pDoc->ApplyPatternArea( nExtendStartCol, nExtendStartRow, nMergeTestEndCol, nMergeTestEndRow, aMark, aPattern );
itr = aMark.begin(), itrEnd = aMark.end();
for (; itr != itrEnd && *itr < nTabCount; ++itr)
@@ -2216,7 +2216,7 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
for( SCTAB j = *itr+1; j<nTabCount && pDoc->IsScenario(j); j++ )
nScenarioCount ++;
- ScRange aMergedRange( nExtendStartCol, nExtendStartRow, *itr, nMergeTestEndX, nMergeTestEndY, *itr+nScenarioCount );
+ ScRange aMergedRange( nExtendStartCol, nExtendStartRow, *itr, nMergeTestEndCol, nMergeTestEndRow, *itr+nScenarioCount );
pDoc->ExtendMerge( aMergedRange, true );
}
}
@@ -2229,7 +2229,7 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
if ( eCmd == DEL_DELCOLS || eCmd == DEL_DELROWS )
pDoc->UpdatePageBreaks( *itr );
- rDocShell.UpdatePaintExt( nExtFlags, nPaintStartX, nPaintStartY, *itr, nPaintEndX, nPaintEndY, *itr );
+ rDocShell.UpdatePaintExt( nExtFlags, nPaintStartCol, nPaintStartRow, *itr, nPaintEndCol, nPaintEndRow, *itr );
SCTAB nScenarioCount = 0;
@@ -2237,15 +2237,15 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
nScenarioCount ++;
// ganze Zeilen loeschen: nichts anpassen
- if ( eCmd == DEL_DELROWS || !AdjustRowHeight(ScRange( 0, nPaintStartY, *itr, MAXCOL, nPaintEndY, *itr+nScenarioCount )) )
- rDocShell.PostPaint( nPaintStartX, nPaintStartY, *itr, nPaintEndX, nPaintEndY, *itr+nScenarioCount, nPaintFlags, nExtFlags );
+ if ( eCmd == DEL_DELROWS || !AdjustRowHeight(ScRange( 0, nPaintStartRow, *itr, MAXCOL, nPaintEndRow, *itr+nScenarioCount )) )
+ rDocShell.PostPaint( nPaintStartCol, nPaintStartRow, *itr, nPaintEndCol, nPaintEndRow, *itr+nScenarioCount, nPaintFlags, nExtFlags );
else
{
// paint only what is not done by AdjustRowHeight
if (nExtFlags & SC_PF_LINES)
- lcl_PaintAbove( rDocShell, ScRange( nPaintStartX, nPaintStartY, *itr, nPaintEndX, nPaintEndY, *itr+nScenarioCount) );
+ lcl_PaintAbove( rDocShell, ScRange( nPaintStartCol, nPaintStartRow, *itr, nPaintEndCol, nPaintEndRow, *itr+nScenarioCount) );
if (nPaintFlags & PAINT_TOP)
- rDocShell.PostPaint( nPaintStartX, nPaintStartY, *itr, nPaintEndX, nPaintEndY, *itr+nScenarioCount, PAINT_TOP );
+ rDocShell.PostPaint( nPaintStartCol, nPaintStartRow, *itr, nPaintEndCol, nPaintEndRow, *itr+nScenarioCount, PAINT_TOP );
}
}
aModificator.SetDocumentModified();
commit 95b55e75e546b016b7d8dbde9f4ac7f72636d32c
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Jan 29 10:59:31 2013 -0500
Boolean cleanup in InsertCells and DeleteCells.
Change-Id: I11d8ba422b280a9a06dbc9bb13c2ccaae7435afb
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index bbd6c96..a6a7661 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -1348,8 +1348,8 @@ sal_Bool ScDocFunc::ApplyStyle( const ScMarkData& rMark, const String& rStyleNam
//------------------------------------------------------------------------
-sal_Bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark, InsCellCmd eCmd,
- sal_Bool bRecord, sal_Bool bApi, sal_Bool bPartOfPaste )
+bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark, InsCellCmd eCmd,
+ bool bRecord, bool bApi, bool bPartOfPaste )
{
ScDocShellModificator aModificator( rDocShell );
@@ -1373,7 +1373,7 @@ sal_Bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMa
SCCOL nPaintEndX = nEndCol;
SCROW nPaintEndY = nEndRow;
sal_uInt16 nPaintFlags = PAINT_GRID;
- sal_Bool bSuccess;
+ bool bSuccess;
SCTAB i;
ScTabViewShell* pViewSh = rDocShell.GetBestViewShell(); //preserve current cursor position
@@ -1401,7 +1401,7 @@ sal_Bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMa
nCount++;
if( nCount == nEndTab+1 )
{
- aMark.SelectTable( i, sal_True );
+ aMark.SelectTable( i, true );
break;
}
}
@@ -1451,7 +1451,7 @@ sal_Bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMa
if ( eCmd == INS_CELLSRIGHT )
nMergeTestEndX = MAXCOL;
- sal_Bool bNeedRefresh = false;
+ bool bNeedRefresh = false;
SCCOL nEditTestEndX = (eCmd==INS_INSCOLS) ? MAXCOL : nMergeTestEndX;
SCROW nEditTestEndY = (eCmd==INS_INSROWS) ? MAXROW : nMergeTestEndY;
@@ -1481,7 +1481,7 @@ sal_Bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMa
// #i8302 : we unmerge overwhelming ranges, before insertion all the actions are put in the same ListAction
// the patch comes from mloiseleur and maoyg
- sal_Bool bInsertMerge = false;
+ bool bInsertMerge = false;
std::vector<ScRange> qIncreaseRange;
String aUndo = ScGlobal::GetRscString( STR_UNDO_INSERTCELLS );
if (bRecord)
@@ -1496,7 +1496,7 @@ sal_Bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMa
if( pDoc->HasAttrib( nMergeTestStartX, nMergeTestStartY, i, nMergeTestEndX, nMergeTestEndY, i, HASATTR_MERGED | HASATTR_OVERLAPPED ) )
{
if (eCmd==INS_CELLSRIGHT)
- bNeedRefresh = sal_True;
+ bNeedRefresh = true;
SCCOL nMergeStartX = nMergeTestStartX;
SCROW nMergeStartY = nMergeTestStartY;
@@ -1533,7 +1533,7 @@ sal_Bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMa
{
ScRange aRange( nTestCol, nTestRow1, i );
pDoc->ExtendOverlapped(aRange);
- pDoc->ExtendMerge(aRange, sal_True);
+ pDoc->ExtendMerge(aRange, true);
if( nTestRow1 < nTestRow2 && nNewFlags == SC_MF_HOR )
{
@@ -1541,12 +1541,12 @@ sal_Bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMa
{
ScRange aTestRange( nTestCol, nTestRow, i );
pDoc->ExtendOverlapped( aTestRange );
- pDoc->ExtendMerge( aTestRange, sal_True);
+ pDoc->ExtendMerge( aTestRange, true);
ScRange aMergeRange( aTestRange.aStart.Col(),aTestRange.aStart.Row(), i );
if( !aExtendRange.In( aMergeRange ) )
{
qIncreaseRange.push_back( aTestRange );
- bInsertMerge = sal_True;
+ bInsertMerge = true;
}
}
}
@@ -1557,7 +1557,7 @@ sal_Bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMa
{
qIncreaseRange.push_back( aRange );
}
- bInsertMerge = sal_True;
+ bInsertMerge = true;
}
}
}
@@ -1600,7 +1600,7 @@ sal_Bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMa
ScRange aRange( *iIter );
if( pDoc->HasAttrib( aRange, HASATTR_OVERLAPPED | HASATTR_MERGED ) )
{
- UnmergeCells( aRange, sal_True );
+ UnmergeCells( aRange, true );
}
}
}
@@ -1717,7 +1717,7 @@ sal_Bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMa
pDoc->SetDrawPageSize(i);
if (bNeedRefresh)
- pDoc->ExtendMerge( nMergeTestStartX, nMergeTestStartY, nMergeTestEndX, nMergeTestEndY, i, sal_True );
+ pDoc->ExtendMerge( nMergeTestStartX, nMergeTestStartY, nMergeTestEndX, nMergeTestEndY, i, true );
else
pDoc->RefreshAutoFilter( nMergeTestStartX, nMergeTestStartY, nMergeTestEndX, nMergeTestEndY, i );
@@ -1732,7 +1732,7 @@ sal_Bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMa
for( SCTAB j = i+1; j<nTabCount && pDoc->IsScenario(j); j++ )
nScenarioCount ++;
- sal_Bool bAdjusted = ( eCmd == INS_INSROWS ) ? AdjustRowHeight(ScRange(0, nStartRow, i, MAXCOL, nEndRow, i+nScenarioCount )) :
+ bool bAdjusted = ( eCmd == INS_INSROWS ) ? AdjustRowHeight(ScRange(0, nStartRow, i, MAXCOL, nEndRow, i+nScenarioCount )) :
AdjustRowHeight(ScRange(0, nPaintStartY, i, MAXCOL, nPaintEndY, i+nScenarioCount ));
if (bAdjusted)
{
@@ -1780,8 +1780,8 @@ sal_Bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMa
return bSuccess;
}
-sal_Bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark, DelCellCmd eCmd,
- sal_Bool bRecord, sal_Bool bApi )
+bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark, DelCellCmd eCmd,
+ bool bRecord, bool bApi )
{
ScDocShellModificator aModificator( rDocShell );
@@ -1822,7 +1822,7 @@ sal_Bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMa
nCount++;
if( nCount == nEndTab+1 )
{
- aMark.SelectTable( i, sal_True );
+ aMark.SelectTable(i, true);
break;
}
}
@@ -1833,7 +1833,7 @@ sal_Bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMa
ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
for (; itr != itrEnd && *itr < nTabCount; ++itr)
for( SCTAB j = *itr+1; j<nTabCount && pDoc->IsScenario(j); j++ )
- aFullMark.SelectTable( j, sal_True );
+ aFullMark.SelectTable( j, true );
SCTAB nSelCount = aMark.GetSelectCount();
@@ -1886,12 +1886,12 @@ sal_Bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMa
SCROW nMergeTestEndY = (eCmd==DEL_CELLSUP) ? MAXROW : nUndoEndY;
SCCOL nExtendStartCol = nUndoStartX;
SCROW nExtendStartRow = nUndoStartY;
- sal_Bool bNeedRefresh = false;
+ bool bNeedRefresh = false;
//Issue 8302 want to be able to insert into the middle of merged cells
//the patch comes from maoyg
::std::vector<ScRange> qDecreaseRange;
- sal_Bool bDeletingMerge = false;
+ bool bDeletingMerge = false;
String aUndo = ScGlobal::GetRscString( STR_UNDO_DELETECELLS );
if (bRecord)
rDocShell.GetUndoManager()->EnterListAction( aUndo, aUndo );
@@ -1940,7 +1940,7 @@ sal_Bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMa
{
ScRange aRange( nTestCol, nTestRow1, i );
pDoc->ExtendOverlapped( aRange );
- pDoc->ExtendMerge( aRange, sal_True );
+ pDoc->ExtendMerge( aRange, true );
if( nTestRow1 < nTestRow2 && nNewFlags == SC_MF_HOR )
{
@@ -1948,12 +1948,12 @@ sal_Bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMa
{
ScRange aTestRange( nTestCol, nTestRow, i );
pDoc->ExtendOverlapped( aTestRange );
- pDoc->ExtendMerge( aTestRange, sal_True );
+ pDoc->ExtendMerge( aTestRange, true );
ScRange aMergeRange( aTestRange.aStart.Col(),aTestRange.aStart.Row(), i );
if( !aExtendRange.In( aMergeRange ) )
{
qDecreaseRange.push_back( aTestRange );
- bDeletingMerge = sal_True;
+ bDeletingMerge = true;
}
}
}
@@ -1964,7 +1964,7 @@ sal_Bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMa
{
qDecreaseRange.push_back( aRange );
}
- bDeletingMerge = sal_True;
+ bDeletingMerge = true;
}
}
}
@@ -1976,7 +1976,7 @@ sal_Bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMa
{
nStartRow = aExtendMergeRange.aStart.Row();
nEndRow = aExtendMergeRange.aEnd.Row();
- bNeedRefresh = sal_True;
+ bNeedRefresh = true;
if( eCmd == DEL_CELLSUP )
{
@@ -1996,7 +1996,7 @@ sal_Bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMa
if( eCmd == DEL_CELLSLEFT )
{
nEndRow = aExtendMergeRange.aEnd.Row();
- bNeedRefresh = sal_True;
+ bNeedRefresh = true;
}
else
{
@@ -2012,7 +2012,7 @@ sal_Bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMa
ScRange aRange( *iIter );
if( pDoc->HasAttrib( aRange, HASATTR_OVERLAPPED | HASATTR_MERGED ) )
{
- UnmergeCells( aRange, sal_True );
+ UnmergeCells( aRange, true );
}
}
}
@@ -2111,7 +2111,7 @@ sal_Bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMa
// alle Tabellen anlegen, damit Formeln kopiert werden koennen:
pUndoDoc->AddUndoTab( 0, nTabCount-1, false, false );
- // kopieren mit bColRowFlags=sal_False (#54194#)
+ // kopieren mit bColRowFlags=false (#54194#)
pRefUndoDoc->CopyToDocument(0,0,0,MAXCOL,MAXROW,MAXTAB,IDF_FORMULA,false,pUndoDoc,NULL,false);
delete pRefUndoDoc;
@@ -2217,7 +2217,7 @@ sal_Bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMa
nScenarioCount ++;
ScRange aMergedRange( nExtendStartCol, nExtendStartRow, *itr, nMergeTestEndX, nMergeTestEndY, *itr+nScenarioCount );
- pDoc->ExtendMerge( aMergedRange, sal_True );
+ pDoc->ExtendMerge( aMergedRange, true );
}
}
@@ -2252,7 +2252,7 @@ sal_Bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMa
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
- return sal_True;
+ return true;
}
sal_Bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos,
diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx
index 7399f7d..6dcdf8a 100644
--- a/sc/source/ui/inc/docfunc.hxx
+++ b/sc/source/ui/inc/docfunc.hxx
@@ -112,11 +112,11 @@ public:
virtual sal_Bool ApplyStyle( const ScMarkData& rMark, const String& rStyleName,
sal_Bool bRecord, sal_Bool bApi );
- virtual sal_Bool InsertCells( const ScRange& rRange,const ScMarkData* pTabMark,
- InsCellCmd eCmd, sal_Bool bRecord, sal_Bool bApi,
- sal_Bool bPartOfPaste = false );
- virtual sal_Bool DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
- DelCellCmd eCmd, sal_Bool bRecord, sal_Bool bApi );
+ virtual bool InsertCells( const ScRange& rRange,const ScMarkData* pTabMark,
+ InsCellCmd eCmd, bool bRecord, bool bApi, bool bPartOfPaste = false );
+
+ virtual bool DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
+ DelCellCmd eCmd, bool bRecord, bool bApi );
virtual sal_Bool MoveBlock( const ScRange& rSource, const ScAddress& rDestPos,
sal_Bool bCut, sal_Bool bRecord, sal_Bool bPaint, sal_Bool bApi );
More information about the Libreoffice-commits
mailing list