summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorDaniel Bankston <daniel.e.bankston@gmail.com>2012-05-25 17:22:21 -0500
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-06-01 19:40:08 +0200
commit66ff25666ddb390e5c4bddaaa7d706991297a975 (patch)
treed5e23ffe4cd0519afefcb7af411c5be926c769a1 /sc
parent2b47dd55a3ee886806277b5636517d3d97417bad (diff)
Remove unnecessary code in ODS import for matrix and merge
MyScTables matrix methods and ScXMLTableRowCellContext merge methods used getCellRangePosition() (that was adopted from ScCellRangeObj) which contains logic that is no longer necessary since since the UNO calls have been converted to direct Sc calls. Change-Id: Ibfa335860d142effb120d3e4f28a36d3d3c58666
Diffstat (limited to 'sc')
-rw-r--r--sc/source/filter/xml/xmlcelli.cxx68
-rw-r--r--sc/source/filter/xml/xmlcelli.hxx4
-rw-r--r--sc/source/filter/xml/xmlsubti.cxx32
3 files changed, 24 insertions, 80 deletions
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index a75cd7fc3715..1261c046e66f 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -460,29 +460,6 @@ static bool ScCellExists( const ScAddress& rScAddress )
return( rScAddress.Col() <= MAXCOL && rScAddress.Row() <= MAXROW );
}
-ScRange getCellRangeByPosition( const ScRange& rScRange, const SCCOL nLeft, const SCROW nTop, const SCCOL nRight, const SCROW nBottom )
-{
- if( nLeft >= 0 && nTop >= 0 && nRight >= 0 && nBottom >= 0 )
- {
- SCCOL nStartX = rScRange.aStart.Col() + nLeft;
- SCROW nStartY = rScRange.aStart.Row() + nTop;
- SCCOL nEndX = rScRange.aStart.Col() + nRight;
- SCROW nEndY = rScRange.aStart.Row() + nBottom;
-
- if( nStartX <= nEndX && nEndX <= rScRange.aEnd.Col() &&
- nStartY <= nEndY && nEndY <= rScRange.aEnd.Row() )
- {
- return ScRange( nStartX, nStartY, rScRange.aStart.Tab(), nEndX, nEndY, rScRange.aEnd.Tab() );
- }
- }
- return ScRange( ScAddress::INITIALIZE_INVALID );
-}
-
-ScRange getCellRangeByPosition( const ScRange& rScRange, const ScAddress& rScCell )
-{
- return getCellRangeByPosition( rScRange, rScCell.Col(), rScCell.Row(), rScCell.Col(), rScCell.Row() );
-}
-
void merge( ScDocShell* pDocSh, const ScRange& rScRange, const bool bMerge )
{
if( pDocSh )
@@ -501,18 +478,16 @@ void merge( ScDocShell* pDocSh, const ScRange& rScRange, const bool bMerge )
} //anonymous namespace
-bool ScXMLTableRowCellContext::IsMerged( const ScRange& rScRange, const ScAddress& rScCell, ScRange& rScCellRange ) const
+bool ScXMLTableRowCellContext::IsMerged( ScRange& rScRange, const ScAddress& rScCell ) const
{
if( ScCellExists(rScCell) )
{
ScDocument* pDoc = rXMLImport.GetDocument();
- rScCellRange = getCellRangeByPosition( rScRange, rScCell );
- if( !rScRange.IsValid() ) return false;
- pDoc->ExtendOverlapped( rScCellRange );
- pDoc->ExtendMerge( rScCellRange );
- rScCellRange.Justify();
- if( rScCellRange.aStart.Col() == rScCell.Col() && rScCellRange.aEnd.Col() == rScCell.Col() &&
- rScCellRange.aStart.Row() == rScCell.Row() && rScCellRange.aEnd.Row() == rScCell.Row() )
+ 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;
@@ -520,32 +495,27 @@ bool ScXMLTableRowCellContext::IsMerged( const ScRange& rScRange, const ScAddres
return false;
}
-void ScXMLTableRowCellContext::DoMerge( const ScAddress& rScCellPos, const sal_Int32 nCols, const sal_Int32 nRows )
+void ScXMLTableRowCellContext::DoMerge( const ScAddress& rScCellPos, const SCCOL nCols, const SCROW nRows )
{
if( ScCellExists(rScCellPos) )
{
- ScRange aScCellRange;
SCTAB nCurrentSheet = GetScImport().GetTables().GetCurrentSheet();
- ScRange aScRange( 0, 0, nCurrentSheet, MAXCOL, MAXROW, nCurrentSheet ); //the whole sheet
+ ScRange aScRange(
+ rScCellPos.Col(), rScCellPos.Row(), nCurrentSheet,
+ rScCellPos.Col(), rScCellPos.Row(), nCurrentSheet
+ );
ScDocShell* pDocSh = static_cast< ScDocShell* >( rXMLImport.GetDocument()->GetDocumentShell() );
- if( IsMerged(aScRange, rScCellPos, aScCellRange) )
+ if( IsMerged(aScRange, rScCellPos) )
{
//unmerge
- ScRange aScMergeRange(
- getCellRangeByPosition( aScRange, aScCellRange.aStart.Col(), aScCellRange.aStart.Row(),
- aScCellRange.aEnd.Col(), aScCellRange.aEnd.Row() )
- );
- if( aScMergeRange.IsValid() )
- merge( pDocSh, aScMergeRange, false );
+ merge( pDocSh, aScRange, false );
}
-
//merge
- ScRange aScMergeRange(
- getCellRangeByPosition( aScRange, aScCellRange.aStart.Col(), aScCellRange.aStart.Row(),
- aScCellRange.aEnd.Col() + nCols, aScCellRange.aEnd.Row() + nRows )
- );
- if( aScMergeRange.IsValid() )
- merge( pDocSh, aScMergeRange, true );
+ SCCOL newEndCol = aScRange.aStart.Col() + nCols;
+ SCROW newEndRow = aScRange.aStart.Row() + nRows;
+ aScRange.aEnd.SetCol( newEndCol );
+ aScRange.aEnd.SetRow( newEndRow );
+ merge( pDocSh, aScRange, true );
}
}
@@ -826,7 +796,7 @@ void ScXMLTableRowCellContext::EndElement()
if (xCellRange.is())
{
if (bIsMerged)
- DoMerge(aScCellPos, nMergedCols - 1, nMergedRows - 1);
+ DoMerge(aScCellPos, static_cast<SCCOL>(nMergedCols - 1), static_cast<SCROW>(nMergedRows - 1));
if ( !pOUFormula )
{
::boost::optional< rtl::OUString > pOUText;
diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx
index 4f8b4f9d4303..9cdcac5920bd 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -82,8 +82,8 @@ class ScXMLTableRowCellContext : public SvXMLImportContext
sal_Int16 GetCellType(const rtl::OUString& sOUValue) const;
- bool IsMerged(const ScRange& rScRange, const ScAddress& rScCell, ScRange& rScCellAddress) const;
- void DoMerge(const ScAddress& rScCellPos, const sal_Int32 nCols, const sal_Int32 nRows);
+ 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);
void SetCellProperties(const com::sun::star::uno::Reference<com::sun::star::table::XCellRange>& xCellRange,
diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx
index 9342961b7153..b830a6f3550d 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -804,44 +804,18 @@ bool ScMyTables::IsPartOfMatrix(const SCCOL nColumn, const SCROW nRow)
return bResult;
}
-namespace {
-
-ScRange getCellRangeByPosition( const ScRange& rScRange, const SCCOL nLeft, const SCROW nTop, const SCCOL nRight, const SCROW nBottom )
-{
- if( nLeft >= 0 && nTop >= 0 && nRight >= 0 && nBottom >= 0 )
- {
- SCCOL nStartX = rScRange.aStart.Col() + nLeft;
- SCROW nStartY = rScRange.aStart.Row() + nTop;
- SCCOL nEndX = rScRange.aStart.Col() + nRight;
- SCROW nEndY = rScRange.aStart.Row() + nBottom;
-
- if( nStartX <= nEndX && nEndX <= rScRange.aEnd.Col() &&
- nStartY <= nEndY && nEndY <= rScRange.aEnd.Row() )
- {
- return ScRange( nStartX, nStartY, rScRange.aStart.Tab(), nEndX, nEndY, rScRange.aEnd.Tab() );
- }
- }
- return ScRange( ScAddress::INITIALIZE_INVALID );
-}
-
-} //anonymous namespace
-
void ScMyTables::SetMatrix(const ScRange& rScRange, const rtl::OUString& rFormula,
const rtl::OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar)
{
- ScRange aWholeSheetRange( 0, 0, nCurrentSheet, MAXCOL, MAXROW, nCurrentSheet ); //the whole sheet
- ScRange aMatrixRange(
- getCellRangeByPosition( aWholeSheetRange, rScRange.aStart.Col(), rScRange.aStart.Row(), rScRange.aEnd.Col(), rScRange.aEnd.Row() )
- );
ScDocShell* pDocSh = static_cast< ScDocShell* >( rImport.GetDocument()->GetDocumentShell() );
if ( !rFormula.isEmpty() )
- pDocSh->GetDocFunc().EnterMatrix( aMatrixRange, NULL, NULL, rFormula, sal_True, sal_True, rFormulaNmsp, eGrammar );
+ pDocSh->GetDocFunc().EnterMatrix( rScRange, NULL, NULL, rFormula, sal_True, sal_True, rFormulaNmsp, eGrammar );
else
{
// empty string -> erase array formula
ScMarkData aMark;
- aMark.SetMarkArea( aMatrixRange );
- aMark.SelectTable( aMatrixRange.aStart.Tab(), sal_True );
+ aMark.SetMarkArea( rScRange );
+ aMark.SelectTable( rScRange.aStart.Tab(), sal_True );
pDocSh->GetDocFunc().DeleteContents( aMark, IDF_CONTENTS, sal_True, sal_True );
}
}