[Libreoffice-commits] core.git: Branch 'private/kohei/excel-2003-xml-orcus-filter' - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Sat Dec 9 14:57:26 UTC 2017
sc/inc/table.hxx | 2 ++
sc/source/core/data/documen3.cxx | 14 +++++---------
sc/source/core/data/documentimport.cxx | 12 +-----------
sc/source/core/data/table2.cxx | 15 +++++++++++++++
4 files changed, 23 insertions(+), 20 deletions(-)
New commits:
commit 34fdf1a9c490819ed3db5d4cf512f8509344f4a6
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Sat Dec 9 09:47:10 2017 -0500
Remove almost duplicate code blocks.
Change-Id: Ib75d0caa41876908091bed374d3afd802928acf7
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index e9f47167dab0..0f6c10621b9b 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -669,6 +669,8 @@ public:
bool ExtendMerge( SCCOL nStartCol, SCROW nStartRow,
SCCOL& rEndCol, SCROW& rEndRow,
bool bRefresh );
+ void SetMergedCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
+
const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, sal_uInt16 nWhich ) const;
const ScPatternAttr* GetPattern( SCCOL nCol, SCROW nRow ) const;
const ScPatternAttr* GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const;
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 62c98d964c37..092044704c21 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -2020,15 +2020,11 @@ void ScDocument::DoEmptyBlock( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
void ScDocument::DoMerge( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
SCCOL nEndCol, SCROW nEndRow, bool bDeleteCaptions )
{
- ScMergeAttr aAttr( nEndCol-nStartCol+1, nEndRow-nStartRow+1 );
- ApplyAttr( nStartCol, nStartRow, nTab, aAttr );
-
- if ( nEndCol > nStartCol )
- ApplyFlagsTab( nStartCol+1, nStartRow, nEndCol, nStartRow, nTab, ScMF::Hor );
- if ( nEndRow > nStartRow )
- ApplyFlagsTab( nStartCol, nStartRow+1, nStartCol, nEndRow, nTab, ScMF::Ver );
- if ( nEndCol > nStartCol && nEndRow > nStartRow )
- ApplyFlagsTab( nStartCol+1, nStartRow+1, nEndCol, nEndRow, nTab, ScMF::Hor | ScMF::Ver );
+ ScTable* pTab = FetchTable(nTab);
+ if (!pTab)
+ return;
+
+ pTab->SetMergedCells(nStartCol, nStartRow, nEndCol, nEndRow);
// Remove all covered notes (removed captions are collected by drawing undo if active)
InsertDeleteFlags nDelFlag = InsertDeleteFlags::NOTE | (bDeleteCaptions ? InsertDeleteFlags::NONE : InsertDeleteFlags::NOCAPTIONS);
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index ddfcf8b10a94..183f3e1650af 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -518,17 +518,7 @@ void ScDocumentImport::setMergedCells(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCO
if (!pTab)
return;
- ScMergeAttr aAttr(nCol2-nCol1+1, nRow2-nRow1+1);
- pTab->ApplyAttr(nCol1, nRow1, aAttr);
-
- if (nCol1 < nCol2)
- pTab->ApplyFlags(nCol1+1, nRow1, nCol2, nRow2, ScMF::Hor);
-
- if (nRow1 < nRow2)
- pTab->ApplyFlags(nCol1, nRow1+1, nCol1, nRow2, ScMF::Ver);
-
- if (nCol1 < nCol2 && nRow1 < nRow2)
- pTab->ApplyFlags(nCol1+1, nRow1+1, nCol2, nRow2, ScMF::Hor | ScMF::Ver);
+ pTab->SetMergedCells(nCol1, nRow1, nCol2, nRow2);
}
namespace {
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 626f58747571..1aa2d8384d1a 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1999,6 +1999,21 @@ bool ScTable::ExtendMerge( SCCOL nStartCol, SCROW nStartRow,
return bFound;
}
+void ScTable::SetMergedCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
+{
+ ScMergeAttr aAttr(nCol2-nCol1+1, nRow2-nRow1+1);
+ ApplyAttr(nCol1, nRow1, aAttr);
+
+ if (nCol1 < nCol2)
+ ApplyFlags(nCol1+1, nRow1, nCol2, nRow2, ScMF::Hor);
+
+ if (nRow1 < nRow2)
+ ApplyFlags(nCol1, nRow1+1, nCol1, nRow2, ScMF::Ver);
+
+ if (nCol1 < nCol2 && nRow1 < nRow2)
+ ApplyFlags(nCol1+1, nRow1+1, nCol2, nRow2, ScMF::Hor | ScMF::Ver);
+}
+
bool ScTable::IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bIgnoreNotes ) const
{
if (!(ValidCol(nCol1) && ValidCol(nCol2)))
More information about the Libreoffice-commits
mailing list