summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorDaniel Bankston <daniel.e.bankston@gmail.com>2012-05-26 02:54:41 -0500
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-06-01 19:40:09 +0200
commit57f7595fef2d5626eb26680a4f102ac548743541 (patch)
treef9f8b15ef4857e90d674ffafd2886568bf555849 /sc
parent369089180d724720b6c296d8a79db54a0d35e8c2 (diff)
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
Diffstat (limited to 'sc')
-rw-r--r--sc/source/filter/xml/xmlcelli.cxx71
-rw-r--r--sc/source/filter/xml/xmlcelli.hxx1
2 files changed, 8 insertions, 64 deletions
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 1261c046e66f..63057747b606 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"
@@ -453,69 +451,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 9cdcac5920bd..70137f0ac625 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);