diff options
author | Daniel Bankston <daniel.e.bankston@gmail.com> | 2012-06-06 17:45:18 -0500 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-06-17 17:04:02 +0200 |
commit | 2b8e1f0dfb2522aeaeb388070f7d4d8f2df9b28d (patch) | |
tree | 1faaadea466879677a035515b33bc9b25e83eb91 /sc | |
parent | 3a703ee4403bf1e23b93097c5053e3eb365696a4 (diff) |
Put EndElement()'s long for-loop into its own method
Moved EndElements()'s long for-loop (where rows and columns are added to the
table) to is own method.
Renamed sub-methods to more appropriately reflect the work being done.
Change-Id: Iab9bdc2deb50577af164c8a210a32557e9708d67
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/xml/xmlcelli.cxx | 166 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcelli.hxx | 8 |
2 files changed, 93 insertions, 81 deletions
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index 0cc970e06e44..745a0c3e0280 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -762,8 +762,8 @@ rtl::OUString getOutputString(ScDocument* pDoc, const ScAddress& aCellPos) } // anon namespace -void ScXMLTableRowCellContext::DoNumberFormatTextWork( const ScAddress& rScCurrentPos, - const SCCOL nCurrentCol, const ::boost::optional< rtl::OUString >& pOUText ) +void ScXMLTableRowCellContext::AddTextCellToDoc( const ScAddress& rScCurrentPos, + const SCCOL nCurrentCol, const ::boost::optional< rtl::OUString >& pOUText ) { bool bDoIncrement = true; if( rXMLImport.GetTables().IsPartOfMatrix(rScCurrentPos.Col(), rScCurrentPos.Row()) ) @@ -808,7 +808,7 @@ void ScXMLTableRowCellContext::DoNumberFormatTextWork( const ScAddress& rScCurre rXMLImport.ProgressBarIncrement(false); } -void ScXMLTableRowCellContext::DoNumberFormatOtherWork( const ScAddress& rScCurrentPos ) +void ScXMLTableRowCellContext::AddNumberCellToDoc( const ScAddress& rScCurrentPos ) { if( rXMLImport.GetTables().IsPartOfMatrix(rScCurrentPos.Col(), rScCurrentPos.Row()) ) { @@ -836,6 +836,90 @@ void ScXMLTableRowCellContext::DoNumberFormatOtherWork( const ScAddress& rScCurr rXMLImport.ProgressBarIncrement(false); } +void ScXMLTableRowCellContext::AddCellsToTable( const ScAddress& rScCellPos, + const ::boost::optional< rtl::OUString >& pOUText, ScAddress& rScCurrentPos ) +{ + ScMyTables& rTables = rXMLImport.GetTables(); + bool bWasEmpty = bIsEmpty; + for (SCCOL i = 0; i < nCellsRepeated; ++i) + { + rScCurrentPos.SetCol( rScCellPos.Col() + i ); + if (i > 0) + rTables.AddColumn(false); + if (!bIsEmpty) + { + for (SCROW j = 0; j < nRepeatedRows; ++j) + { + rScCurrentPos.SetRow( rScCellPos.Row() + j ); + if( (rScCurrentPos.Col() == 0) && (j > 0) ) + { + rTables.AddRow(); + rTables.AddColumn(false); + } + if( scCellExists(rScCurrentPos) ) + { + if( ( !(bIsCovered) || lcl_IsEmptyOrNote(rXMLImport.GetDocument(), rScCurrentPos) ) ) + { + switch (nCellType) + { + case util::NumberFormat::TEXT: + { + AddTextCellToDoc( rScCurrentPos, i, pOUText ); + } + break; + case util::NumberFormat::NUMBER: + case util::NumberFormat::PERCENT: + case util::NumberFormat::CURRENCY: + case util::NumberFormat::TIME: + case util::NumberFormat::DATETIME: + case util::NumberFormat::LOGICAL: + { + AddNumberCellToDoc( rScCurrentPos ); + } + break; + default: + { + OSL_FAIL("no cell type given"); + } + break; + } + } + + SetAnnotation( rScCurrentPos ); + SetDetectiveObj( rScCurrentPos ); + SetCellRangeSource( rScCurrentPos ); + } + else + { + if (!bWasEmpty || mxAnnotationData.get()) + { + if (rScCurrentPos.Row() > MAXROW) + rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_ROW_OVERFLOW); + else + rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_COLUMN_OVERFLOW); + } + } + } + } + else + { + // #i56027# If the child context put formatted text into the cell, + // bIsEmpty is true and ProgressBarIncrement has to be called + // with bEditCell = TRUE. + if (bHasTextImport) + rXMLImport.ProgressBarIncrement(true); + if ((i == 0) && (rScCellPos.Col() == 0)) + { + for (sal_Int32 j = 1; j < nRepeatedRows; ++j) + { + rTables.AddRow(); + rTables.AddColumn(false); + } + } + } + } +} + void ScXMLTableRowCellContext::EndElement() { if (!bHasSubTable) @@ -883,88 +967,14 @@ void ScXMLTableRowCellContext::EndElement() if (!pOUTextContent && !pOUText && !pOUTextValue) bIsEmpty = true; } - bool bWasEmpty = bIsEmpty; ScAddress aScCurrentPos( aScCellPos ); if ((pContentValidationName && !pContentValidationName->isEmpty()) || mxAnnotationData.get() || pDetectiveObjVec || pCellRangeSource) bIsEmpty = false; - for (SCCOL i = 0; i < nCellsRepeated; ++i) - { - aScCurrentPos.SetCol( aScCellPos.Col() + i ); - if (i > 0) - rTables.AddColumn(false); - if (!bIsEmpty) - { - for (SCROW j = 0; j < nRepeatedRows; ++j) - { - aScCurrentPos.SetRow( aScCellPos.Row() + j ); - if( (aScCurrentPos.Col() == 0) && (j > 0) ) - { - rTables.AddRow(); - rTables.AddColumn(false); - } - if( scCellExists(aScCurrentPos) ) - { - if( ( !(bIsCovered) || lcl_IsEmptyOrNote(rXMLImport.GetDocument(), aScCurrentPos) ) ) - { - switch (nCellType) - { - case util::NumberFormat::TEXT: - { - DoNumberFormatTextWork( aScCurrentPos, i, pOUText ); - } - break; - case util::NumberFormat::NUMBER: - case util::NumberFormat::PERCENT: - case util::NumberFormat::CURRENCY: - case util::NumberFormat::TIME: - case util::NumberFormat::DATETIME: - case util::NumberFormat::LOGICAL: - { - DoNumberFormatOtherWork( aScCurrentPos ); - } - break; - default: - { - OSL_FAIL("no cell type given"); - } - break; - } - } + AddCellsToTable( aScCellPos, pOUText, aScCurrentPos ); - SetAnnotation( aScCurrentPos ); - SetDetectiveObj( aScCurrentPos ); - SetCellRangeSource( aScCurrentPos ); - } - else - { - if (!bWasEmpty || mxAnnotationData.get()) - { - if (aScCurrentPos.Row() > MAXROW) - rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_ROW_OVERFLOW); - else - rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_COLUMN_OVERFLOW); - } - } - } - } - else - { - // #i56027# If the child context put formatted text into the cell, - // bIsEmpty is true and ProgressBarIncrement has to be called - // with bEditCell = TRUE. - if (bHasTextImport) - rXMLImport.ProgressBarIncrement(true); - if ((i == 0) && (aScCellPos.Col() == 0)) - for (sal_Int32 j = 1; j < nRepeatedRows; ++j) - { - rTables.AddRow(); - rTables.AddColumn(false); - } - } - } if (nCellsRepeated > 1 || nRepeatedRows > 1) { SetCellProperties(xCellRange, aScCellPos); // set now only the validation for the complete range with the given cell as start cell diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx index 845dacd8e58f..0a0e8c2101f8 100644 --- a/sc/source/filter/xml/xmlcelli.hxx +++ b/sc/source/filter/xml/xmlcelli.hxx @@ -95,9 +95,11 @@ class ScXMLTableRowCellContext : public SvXMLImportContext return (aCellPos.Column <= MAXCOL && aCellPos.Row <= MAXROW); } - void DoNumberFormatTextWork( const ScAddress& rScCurrentPos, const SCCOL nCurrentCol, - const ::boost::optional< rtl::OUString >& pOUText ); - void DoNumberFormatOtherWork( const ScAddress& rScCurrentPos ); + void AddTextCellToDoc ( const ScAddress& rScCurrentPos, const SCCOL nCurrentCol, + const ::boost::optional< rtl::OUString >& pOUText ); + void AddNumberCellToDoc ( const ScAddress& rScCurrentPos ); + void AddCellsToTable ( const ScAddress& rScCellPos, + const ::boost::optional< rtl::OUString >& pOUText, ScAddress& rScCurrentPos ); public: |