[Libreoffice-commits] .: Branch 'feature/gsoc-calc-perf' - sc/source
Daniel Bankston
dbank at kemper.freedesktop.org
Sat May 26 01:05:03 PDT 2012
sc/source/filter/xml/xmlcelli.cxx | 71 ++++----------------------------------
sc/source/filter/xml/xmlcelli.hxx | 1
2 files changed, 8 insertions(+), 64 deletions(-)
New commits:
commit c827d7b23bdccc1adfb8b44ec04ea2b6503d57f5
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date: Sat May 26 02:54:41 2012 -0500
Remove ScDocFunc calls and unnecessary checks from ODS import for merged cells
It seems only one line was actually needed from ScDocFunc::MergeCells() during
ODS import, which was the call to ScDocument::DoMerge(). Also, IsMerged()
and unmerging is not needed during ODS import.
Change-Id: Ieec5abf8c4c8ce52df16cece77ffe1a1574e6397
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 305a478..25f8f17 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -41,9 +41,7 @@
#include "unonames.hxx"
#include "postit.hxx"
#include "sheetdata.hxx"
-#include "cellmergeoption.hxx"
#include "docsh.hxx"
-#include "docfunc.hxx"
#include "XMLTableShapeImportHelper.hxx"
#include "XMLTextPContext.hxx"
@@ -455,69 +453,16 @@ SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPr
return pContext;
}
-namespace {
-
-static bool ScCellExists( const ScAddress& rScAddress )
-{
- return( rScAddress.Col() <= MAXCOL && rScAddress.Row() <= MAXROW );
-}
-
-void merge( ScDocShell* pDocSh, const ScRange& rScRange, const bool bMerge )
-{
- if( pDocSh )
- {
- ScCellMergeOption aMergeOption(
- rScRange.aStart.Col(), rScRange.aStart.Row(),
- rScRange.aEnd.Col(), rScRange.aEnd.Row(), false
- );
- aMergeOption.maTabs.insert( rScRange.aStart.Tab() );
- if ( bMerge )
- pDocSh->GetDocFunc().MergeCells( aMergeOption, false, true, true );
- else
- pDocSh->GetDocFunc().UnmergeCells( aMergeOption, true, true );
- }
-}
-
-} //anonymous namespace
-
-bool ScXMLTableRowCellContext::IsMerged( ScRange& rScRange, const ScAddress& rScCell ) const
+void ScXMLTableRowCellContext::DoMerge( const ScAddress& rScAddress, const SCCOL nCols, const SCROW nRows )
{
- if( ScCellExists(rScCell) )
+ SCCOL mergeToCol = rScAddress.Col() + nCols;
+ SCROW mergeToRow = rScAddress.Row() + nRows;
+ bool bInBounds = rScAddress.Col() <= MAXCOL && rScAddress.Row() <= MAXROW &&
+ mergeToCol <= MAXCOL && mergeToRow <= MAXROW;
+ if( bInBounds )
{
- ScDocument* pDoc = rXMLImport.GetDocument();
- pDoc->ExtendOverlapped( rScRange );
- pDoc->ExtendMerge( rScRange );
- rScRange.Justify();
- if( rScRange.aStart.Col() == rScCell.Col() && rScRange.aEnd.Col() == rScCell.Col() &&
- rScRange.aStart.Row() == rScCell.Row() && rScRange.aEnd.Row() == rScCell.Row() )
- return false;
- else
- return true;
- }
- return false;
-}
-
-void ScXMLTableRowCellContext::DoMerge( const ScAddress& rScCellPos, const SCCOL nCols, const SCROW nRows )
-{
- if( ScCellExists(rScCellPos) )
- {
- SCTAB nCurrentSheet = GetScImport().GetTables().GetCurrentSheet();
- ScRange aScRange(
- rScCellPos.Col(), rScCellPos.Row(), nCurrentSheet,
- rScCellPos.Col(), rScCellPos.Row(), nCurrentSheet
- );
- ScDocShell* pDocSh = static_cast< ScDocShell* >( rXMLImport.GetDocument()->GetDocumentShell() );
- if( IsMerged(aScRange, rScCellPos) )
- {
- //unmerge
- merge( pDocSh, aScRange, false );
- }
- //merge
- SCCOL newEndCol = aScRange.aStart.Col() + nCols;
- SCROW newEndRow = aScRange.aStart.Row() + nRows;
- aScRange.aEnd.SetCol( newEndCol );
- aScRange.aEnd.SetRow( newEndRow );
- merge( pDocSh, aScRange, true );
+ rXMLImport.GetDocument()->DoMerge( rScAddress.Tab(),
+ rScAddress.Col(), rScAddress.Row(), mergeToCol, mergeToRow );
}
}
diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx
index 9cdcac5..70137f0 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -82,7 +82,6 @@ class ScXMLTableRowCellContext : public SvXMLImportContext
sal_Int16 GetCellType(const rtl::OUString& sOUValue) const;
- bool IsMerged(ScRange& rScRange, const ScAddress& rScCell) const;
void DoMerge(const ScAddress& rScCellPos, const SCCOL nCols, const SCROW nRows);
void SetContentValidation(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet>& xPropSet);
More information about the Libreoffice-commits
mailing list