sc/source/filter/xml/XMLDetectiveContext.cxx | 2 sc/source/filter/xml/xmlcelli.cxx | 8 sc/source/filter/xml/xmlcoli.cxx | 1 sc/source/filter/xml/xmlsubti.cxx | 265 ++------------------------- sc/source/filter/xml/xmlsubti.hxx | 61 ------ 5 files changed, 40 insertions(+), 297 deletions(-)
New commits: commit 74dd823ebdc6910529f5b916780ace49121c04ea Author: Daniel Bankston <[email protected]> Date: Mon Jun 18 16:04:36 2012 -0500 Use better variable and method names for ScMyTables current cell position Change-Id: Icdefd17751b61e9c27e3ab4468691bba08e245c0 diff --git a/sc/source/filter/xml/XMLDetectiveContext.cxx b/sc/source/filter/xml/XMLDetectiveContext.cxx index e669dae..fbe2143 100644 --- a/sc/source/filter/xml/XMLDetectiveContext.cxx +++ b/sc/source/filter/xml/XMLDetectiveContext.cxx @@ -241,7 +241,7 @@ ScXMLDetectiveOperationContext::ScXMLDetectiveOperationContext( break; } } - aDetectiveOp.aPosition = rImport.GetTables().GetRealScCellPos(); + aDetectiveOp.aPosition = rImport.GetTables().GetCurrentCellPos(); } ScXMLDetectiveOperationContext::~ScXMLDetectiveOperationContext() diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index 56aafc7..841c85c 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -304,7 +304,7 @@ bool cellExists( const ScAddress& rCellPos ) void ScXMLTableRowCellContext::SetCursorOnTextImport(const rtl::OUString& rOUTempText) { - ScAddress aCellPos = rXMLImport.GetTables().GetRealScCellPos(); + ScAddress aCellPos = rXMLImport.GetTables().GetCurrentCellPos(); if (cellExists(aCellPos)) { sal_Int32 nCol = static_cast<sal_Int32>( aCellPos.Col() ); @@ -354,7 +354,7 @@ SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPr bIsEmpty = false; bTextP = true; - ScAddress aCellPos = rXMLImport.GetTables().GetRealScCellPos(); + ScAddress aCellPos = rXMLImport.GetTables().GetCurrentCellPos(); if( ((nCellType == util::NumberFormat::TEXT) || bFormulaTextResult) && !rXMLImport.GetTables().IsPartOfMatrix(aCellPos.Col(), aCellPos.Row()) ) @@ -432,7 +432,7 @@ SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPr if (!pContext && !bTextP) { - ScAddress aCellPos = rXMLImport.GetTables().GetRealScCellPos(); + ScAddress aCellPos = rXMLImport.GetTables().GetCurrentCellPos(); uno::Reference<drawing::XShapes> xShapes (rXMLImport.GetTables().GetCurrentXShapes()); if (xShapes.is()) { @@ -1103,7 +1103,7 @@ void ScXMLTableRowCellContext::EndElement() } } - ScAddress aCellPos = rXMLImport.GetTables().GetRealScCellPos(); + ScAddress aCellPos = rXMLImport.GetTables().GetCurrentCellPos(); if( aCellPos.Col() > 0 && nRepeatedRows > 1 ) aCellPos.SetRow( aCellPos.Row() - (nRepeatedRows - 1) ); if( bIsMerged ) diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx index 820c58e..8db9eb1 100644 --- a/sc/source/filter/xml/xmlsubti.cxx +++ b/sc/source/filter/xml/xmlsubti.cxx @@ -74,7 +74,7 @@ ScXMLTabProtectionData::ScXMLTabProtectionData() : ScMyTables::ScMyTables(ScXMLImport& rTempImport) : rImport(rTempImport), aFixupOLEs(rTempImport), - maCellPos(ScAddress::INITIALIZE_INVALID), + maCurrentCellPos(ScAddress::INITIALIZE_INVALID), nCurrentColStylePos(0), nCurrentDrawPage( -1 ), nCurrentXShapes( -1 ) @@ -116,22 +116,22 @@ void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString& nCurrentColStylePos = 0; sCurrentSheetName = sTableName; //reset cols and rows for new sheet, but increment tab - maCellPos.SetCol(-1); - maCellPos.SetRow(-1); - maCellPos.SetTab(maCellPos.Tab() + 1); + maCurrentCellPos.SetCol(-1); + maCurrentCellPos.SetRow(-1); + maCurrentCellPos.SetTab(maCurrentCellPos.Tab() + 1); maProtectionData = rProtectData; ScDocument *pDoc = ScXMLConverter::GetScDocument(rImport.GetModel()); // The document contains one sheet when created. So for the first // sheet, we only need to set its name. - if (maCellPos.Tab() > 0) + if (maCurrentCellPos.Tab() > 0) pDoc->AppendTabOnLoad(sTableName); else - pDoc->SetTabNameOnLoad(maCellPos.Tab(), sTableName); + pDoc->SetTabNameOnLoad(maCurrentCellPos.Tab(), sTableName); rImport.SetTableStyle(sStyleName); - xCurrentSheet = getCurrentSheet(rImport.GetModel(), maCellPos.Tab()); + xCurrentSheet = getCurrentSheet(rImport.GetModel(), maCurrentCellPos.Tab()); if (xCurrentSheet.is()) { // We need to set the current cell range here regardless of @@ -172,7 +172,7 @@ void ScMyTables::SetTableStyle(const rtl::OUString& sStyleName) pStyle->FillPropertySet(xProperties); ScSheetSaveData* pSheetData = ScModelObj::getImplementation(rImport.GetModel())->GetSheetSaveData(); - pSheetData->AddTableStyle( sStyleName, ScAddress( 0, 0, maCellPos.Tab() ) ); + pSheetData->AddTableStyle( sStyleName, ScAddress( 0, 0, maCurrentCellPos.Tab() ) ); } } } @@ -182,8 +182,8 @@ void ScMyTables::SetTableStyle(const rtl::OUString& sStyleName) void ScMyTables::AddRow() { - maCellPos.SetRow(maCellPos.Row() + 1); - maCellPos.SetCol(-1); //reset columns for new row + maCurrentCellPos.SetRow(maCurrentCellPos.Row() + 1); + maCurrentCellPos.SetCol(-1); //reset columns for new row } void ScMyTables::SetRowStyle(const rtl::OUString& rCellStyleName) @@ -193,11 +193,11 @@ void ScMyTables::SetRowStyle(const rtl::OUString& rCellStyleName) void ScMyTables::AddColumn(bool bIsCovered) { - maCellPos.SetCol( maCellPos.Col() + 1 ); + maCurrentCellPos.SetCol( maCurrentCellPos.Col() + 1 ); //here only need to set column style if this is the first row and //the cell is not covered. - if(maCellPos.Row() == 0 && !bIsCovered) - rImport.GetStylesImportHelper()->InsertCol(maCellPos.Col(), maCellPos.Tab(), rImport.GetDocument()); + if(maCurrentCellPos.Row() == 0 && !bIsCovered) + rImport.GetStylesImportHelper()->InsertCol(maCurrentCellPos.Col(), maCurrentCellPos.Tab(), rImport.GetDocument()); } void ScMyTables::UpdateRowHeights() @@ -274,7 +274,7 @@ void ScMyTables::DeleteTable() pProtect->setPasswordHash(aHash, maProtectionData.meHash1, maProtectionData.meHash2); pProtect->setOption(ScTableProtection::SELECT_LOCKED_CELLS, maProtectionData.mbSelectProtectedCells); pProtect->setOption(ScTableProtection::SELECT_UNLOCKED_CELLS, maProtectionData.mbSelectUnprotectedCells); - rImport.GetDocument()->SetTabProtection(maCellPos.Tab(), pProtect.get()); + rImport.GetDocument()->SetTabProtection(maCurrentCellPos.Tab(), pProtect.get()); } } @@ -286,24 +286,24 @@ void ScMyTables::AddColStyle(const sal_Int32 nRepeat, const rtl::OUString& rCell uno::Reference< drawing::XDrawPage > ScMyTables::GetCurrentXDrawPage() { - if( (maCellPos.Tab() != nCurrentDrawPage) || !xDrawPage.is() ) + if( (maCurrentCellPos.Tab() != nCurrentDrawPage) || !xDrawPage.is() ) { uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier( xCurrentSheet, uno::UNO_QUERY ); if( xDrawPageSupplier.is() ) xDrawPage.set(xDrawPageSupplier->getDrawPage()); - nCurrentDrawPage = sal::static_int_cast<sal_Int16>(maCellPos.Tab()); + nCurrentDrawPage = sal::static_int_cast<sal_Int16>(maCurrentCellPos.Tab()); } return xDrawPage; } uno::Reference< drawing::XShapes > ScMyTables::GetCurrentXShapes() { - if( (maCellPos.Tab() != nCurrentXShapes) || !xShapes.is() ) + if( (maCurrentCellPos.Tab() != nCurrentXShapes) || !xShapes.is() ) { xShapes.set(GetCurrentXDrawPage(), uno::UNO_QUERY); rImport.GetShapeImport()->startPage(xShapes); rImport.GetShapeImport()->pushGroupForSorting ( xShapes ); - nCurrentXShapes = sal::static_int_cast<sal_Int16>(maCellPos.Tab()); + nCurrentXShapes = sal::static_int_cast<sal_Int16>(maCurrentCellPos.Tab()); return xShapes; } else @@ -312,12 +312,12 @@ uno::Reference< drawing::XShapes > ScMyTables::GetCurrentXShapes() bool ScMyTables::HasDrawPage() { - return !((maCellPos.Tab() != nCurrentDrawPage) || !xDrawPage.is()); + return !((maCurrentCellPos.Tab() != nCurrentDrawPage) || !xDrawPage.is()); } bool ScMyTables::HasXShapes() { - return !((maCellPos.Tab() != nCurrentXShapes) || !xShapes.is()); + return !((maCurrentCellPos.Tab() != nCurrentXShapes) || !xShapes.is()); } void ScMyTables::AddOLE(uno::Reference <drawing::XShape>& rShape, @@ -333,8 +333,8 @@ void ScMyTables::AddMatrixRange( OSL_ENSURE(nEndRow >= nStartRow, "wrong row order"); OSL_ENSURE(nEndColumn >= nStartColumn, "wrong column order"); ScRange aScRange( - nStartColumn, nStartRow, maCellPos.Tab(), - nEndColumn, nEndRow, maCellPos.Tab() + nStartColumn, nStartRow, maCurrentCellPos.Tab(), + nEndColumn, nEndRow, maCurrentCellPos.Tab() ); ScMatrixRange aMRange(aScRange, rFormula, rFormulaNmsp, eGrammar); aMatrixRangeList.push_back(aMRange); @@ -350,7 +350,7 @@ bool ScMyTables::IsPartOfMatrix(const SCCOL nColumn, const SCROW nRow) bool bReady(false); while(!bReady && aItr != aEndItr) { - if (maCellPos.Tab() > aItr->aScRange.aStart.Tab()) + if (maCurrentCellPos.Tab() > aItr->aScRange.aStart.Tab()) { OSL_FAIL("should never hapen, because the list should be cleared in DeleteTable"); aItr = aMatrixRangeList.erase(aItr); diff --git a/sc/source/filter/xml/xmlsubti.hxx b/sc/source/filter/xml/xmlsubti.hxx index 7b69d5b..971cb69 100644 --- a/sc/source/filter/xml/xmlsubti.hxx +++ b/sc/source/filter/xml/xmlsubti.hxx @@ -88,7 +88,7 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > xDrawPage; ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShapes > xShapes; rtl::OUString sCurrentSheetName; - ScAddress maCellPos; + ScAddress maCurrentCellPos; ScXMLTabProtectionData maProtectionData; ScMyMatrixRangeList aMatrixRangeList; sal_Int32 nCurrentColStylePos; @@ -112,13 +112,13 @@ public: bool IsOLE(com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape) const { return ScMyOLEFixer::IsOLE(rShape); } void DeleteTable(); - ScAddress GetRealScCellPos() const { return maCellPos; }; + ScAddress GetCurrentCellPos() const { return maCurrentCellPos; }; void AddColStyle(const sal_Int32 nRepeat, const rtl::OUString& rCellStyleName); ScXMLTabProtectionData& GetCurrentProtectionData() { return maProtectionData; } rtl::OUString GetCurrentSheetName() const { return sCurrentSheetName; } - SCTAB GetCurrentSheet() const { return (maCellPos.Tab() >= 0) ? maCellPos.Tab() : 0; } - SCCOL GetCurrentColumn() const { return (maCellPos.Col() >= 0) ? maCellPos.Col() : 0; } - SCROW GetCurrentRow() const { return (maCellPos.Row() >= 0) ? maCellPos.Row() : 0; } + SCTAB GetCurrentSheet() const { return (maCurrentCellPos.Tab() >= 0) ? maCurrentCellPos.Tab() : 0; } + SCCOL GetCurrentColumn() const { return (maCurrentCellPos.Col() >= 0) ? maCurrentCellPos.Col() : 0; } + SCROW GetCurrentRow() const { return (maCurrentCellPos.Row() >= 0) ? maCurrentCellPos.Row() : 0; } ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet > GetCurrentXSheet() const { return xCurrentSheet; } ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > commit 1cf4bcf1564aed21763d86f43427167821253c5a Author: Daniel Bankston <[email protected]> Date: Mon Jun 18 15:50:38 2012 -0500 Simplify table ODS import logic to improve performance - Removed subtable import logic since sc core doesn't support it. - Simplified the overall table import logic. Should have an overall table import performance increase. Change-Id: I79d27470321bf17f7ef16becd7cb6aa840491f80 diff --git a/sc/source/filter/xml/xmlcoli.cxx b/sc/source/filter/xml/xmlcoli.cxx index b4d31b2..e47588e 100644 --- a/sc/source/filter/xml/xmlcoli.cxx +++ b/sc/source/filter/xml/xmlcoli.cxx @@ -169,7 +169,6 @@ void ScXMLTableColContext::EndElement() if ( sCellStyleName.isEmpty() ) sCellStyleName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Default" )); - GetScImport().GetTables().AddColCount(nColCount); GetScImport().GetTables().AddColStyle(nColCount, sCellStyleName); } diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx index 3d88df0..820c58e 100644 --- a/sc/source/filter/xml/xmlsubti.cxx +++ b/sc/source/filter/xml/xmlsubti.cxx @@ -26,8 +26,6 @@ * ************************************************************************/ - -// INCLUDE --------------------------------------------------------------- #include "xmlsubti.hxx" #include "global.hxx" #include "xmlstyli.hxx" @@ -61,88 +59,8 @@ #include <memory> using ::std::auto_ptr; - -//------------------------------------------------------------------ - using namespace com::sun::star; -ScMyTableData::ScMyTableData(SCTAB nSheet, SCCOL nCol, SCROW nRow) - : maTableCellPos(nCol, nRow, nSheet), - nColsPerCol(nDefaultColCount, 1), - nRealCols(nDefaultColCount + 1, 0), - nRowsPerRow(nDefaultRowCount, 1), - nRealRows(nDefaultRowCount + 1, 0), - nChangedCols() -{ - for (sal_Int32 i = 0; i < 3; ++i) - nRealCols[i] = i; - for (sal_Int32 j = 0; j < 3; ++j) - nRealRows[j] = j; - - nSpannedCols = 1; - nColCount = 0; - nSubTableSpanned = 1; -} - -ScMyTableData::~ScMyTableData() -{ -} - -void ScMyTableData::AddRow() -{ - maTableCellPos.SetRow( maTableCellPos.Row() + 1 ); - if (static_cast<sal_uInt32>(maTableCellPos.Row()) >= nRowsPerRow.size()) - { - nRowsPerRow.resize(nRowsPerRow.size() + nDefaultRowCount, 1); - nRealRows.resize(nRowsPerRow.size() + nDefaultRowCount + 1, 0); - } - nRealRows[maTableCellPos.Row() + 1] = nRealRows[maTableCellPos.Row()] + nRowsPerRow[maTableCellPos.Row()]; -} - -void ScMyTableData::AddColumn() -{ - maTableCellPos.SetCol( maTableCellPos.Col() + 1 ); - if (static_cast<sal_uInt32>(maTableCellPos.Col()) >= nColsPerCol.size()) - { - nColsPerCol.resize(nColsPerCol.size() + nDefaultColCount, 1); - nRealCols.resize(nColsPerCol.size() + nDefaultColCount + 1, 0); - } - nRealCols[maTableCellPos.Col() + 1] = nRealCols[maTableCellPos.Col()] + nColsPerCol[maTableCellPos.Col()]; -} - -sal_Int32 ScMyTableData::GetRealCols(const sal_Int32 nIndex, const bool /* bIsNormal */) const -{ - return (nIndex < 0) ? 0 : nRealCols[nIndex]; -} - -sal_Int32 ScMyTableData::GetChangedCols(const sal_Int32 nFromIndex, const sal_Int32 nToIndex) const -{ - ScMysalIntList::const_iterator i(nChangedCols.begin()); - ScMysalIntList::const_iterator endi(nChangedCols.end()); - while ((i != endi) && ((*i < nToIndex) && !(*i >= nFromIndex))) - ++i; - if (i == endi) - return -1; - else - if ((*i >= nFromIndex) && (*i < nToIndex)) - return *i; - else - return -1; -} - -void ScMyTableData::SetChangedCols(const sal_Int32 nValue) -{ - ScMysalIntList::iterator i(nChangedCols.begin()); - ScMysalIntList::iterator endi(nChangedCols.end()); - while ((i != endi) && (*i < nValue)) - { - ++i; - } - if ((i == endi) || (*i != nValue)) - nChangedCols.insert(i, nValue); -} - -/*******************************************************************************************************************************/ ScXMLTabProtectionData::ScXMLTabProtectionData() : meHash1(PASSHASH_SHA1), @@ -156,11 +74,10 @@ ScXMLTabProtectionData::ScXMLTabProtectionData() : ScMyTables::ScMyTables(ScXMLImport& rTempImport) : rImport(rTempImport), aFixupOLEs(rTempImport), + maCellPos(ScAddress::INITIALIZE_INVALID), nCurrentColStylePos(0), nCurrentDrawPage( -1 ), - nCurrentXShapes( -1 ), - nCurrentSheet( -1 ), - pCurrentTab(NULL) + nCurrentXShapes( -1 ) { } @@ -198,22 +115,23 @@ void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString& { nCurrentColStylePos = 0; sCurrentSheetName = sTableName; - maTables.clear(); - pCurrentTab = NULL; - ++nCurrentSheet; + //reset cols and rows for new sheet, but increment tab + maCellPos.SetCol(-1); + maCellPos.SetRow(-1); + maCellPos.SetTab(maCellPos.Tab() + 1); maProtectionData = rProtectData; ScDocument *pDoc = ScXMLConverter::GetScDocument(rImport.GetModel()); // The document contains one sheet when created. So for the first // sheet, we only need to set its name. - if (nCurrentSheet > 0) + if (maCellPos.Tab() > 0) pDoc->AppendTabOnLoad(sTableName); else - pDoc->SetTabNameOnLoad(nCurrentSheet, sTableName); + pDoc->SetTabNameOnLoad(maCellPos.Tab(), sTableName); rImport.SetTableStyle(sStyleName); - xCurrentSheet = getCurrentSheet(rImport.GetModel(), nCurrentSheet); + xCurrentSheet = getCurrentSheet(rImport.GetModel(), maCellPos.Tab()); if (xCurrentSheet.is()) { // We need to set the current cell range here regardless of @@ -222,10 +140,6 @@ void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString& SetTableStyle(sStyleName); } } - - maTables.push_back(new ScMyTableData(nCurrentSheet)); - pCurrentTab = & maTables.back(); - pCurrentTab->SetSpannedCols(1); } void ScMyTables::SetTableStyle(const rtl::OUString& sStyleName) @@ -258,7 +172,7 @@ void ScMyTables::SetTableStyle(const rtl::OUString& sStyleName) pStyle->FillPropertySet(xProperties); ScSheetSaveData* pSheetData = ScModelObj::getImplementation(rImport.GetModel())->GetSheetSaveData(); - pSheetData->AddTableStyle( sStyleName, ScAddress( 0, 0, nCurrentSheet ) ); + pSheetData->AddTableStyle( sStyleName, ScAddress( 0, 0, maCellPos.Tab() ) ); } } } @@ -266,42 +180,10 @@ void ScMyTables::SetTableStyle(const rtl::OUString& sStyleName) } } -void ScMyTables::NewRow() -{ - size_t n = maTables.size(); - if (n <= 1) - return; - - if (pCurrentTab->GetRealRows(pCurrentTab->GetRow()) > - maTables[n-2].GetRowsPerRow(maTables[n-2].GetRow()) - 1) - { - if (GetRealScCellPos().Col() > 0) - rImport.GetStylesImportHelper()->InsertRow(GetRealScCellPos().Row(), nCurrentSheet, rImport.GetDocument()); - - for (size_t i = n - 1; i > 0; --i) - { - sal_Int32 nRow = maTables[i-1].GetRow(); - maTables[i-1].SetRowsPerRow( - nRow, - maTables[i-1].GetRowsPerRow(nRow) + 1); - - maTables[i-1].SetRealRows( - nRow + 1, - maTables[i-1].GetRealRows(nRow) + maTables[i-1].GetRowsPerRow(nRow)); - } - } -} - void ScMyTables::AddRow() { - pCurrentTab->AddRow(); - pCurrentTab->SetFirstColumn(); - sal_Int32 nRow = pCurrentTab->GetRow(); - if (nRow > 0) - NewRow(); - - pCurrentTab->SetRealRows( - nRow + 1, pCurrentTab->GetRealRows(nRow) + pCurrentTab->GetRowsPerRow(nRow)); + maCellPos.SetRow(maCellPos.Row() + 1); + maCellPos.SetCol(-1); //reset columns for new row } void ScMyTables::SetRowStyle(const rtl::OUString& rCellStyleName) @@ -309,69 +191,13 @@ void ScMyTables::SetRowStyle(const rtl::OUString& rCellStyleName) rImport.GetStylesImportHelper()->SetRowStyle(rCellStyleName); } -void ScMyTables::NewColumn(bool bIsCovered) -{ - if (bIsCovered) - return; - - sal_Int32 nColCount = pCurrentTab->GetColCount(); - sal_Int32 nSpannedCols = pCurrentTab->GetSpannedCols(); - if ( (nSpannedCols > nColCount) && - (pCurrentTab->GetRow() == 0) && - (pCurrentTab->GetColumn() == 0) ) - { - if (nColCount > 0) - { - sal_Int32 FirstColsSpanned(nSpannedCols / nColCount); - sal_Int32 LastColSpanned(FirstColsSpanned - + (nSpannedCols % nColCount)); - for (sal_Int32 i = 0; i < nColCount - 1; ++i) - { - pCurrentTab->SetColsPerCol(i, FirstColsSpanned); - pCurrentTab->SetRealCols(i + 1, pCurrentTab->GetRealCols(i) + FirstColsSpanned); - } - pCurrentTab->SetColsPerCol(nColCount - 1, LastColSpanned); - pCurrentTab->SetRealCols( - nColCount, pCurrentTab->GetRealCols(nColCount - 1) + LastColSpanned); - } - } - if (pCurrentTab->GetRealCols(pCurrentTab->GetColumn()) > nSpannedCols - 1) - { - if (pCurrentTab->GetRow() == 0) - { - rImport.GetStylesImportHelper()->InsertCol(GetRealScCellPos().Col(), nCurrentSheet, rImport.GetDocument()); - size_t n = maTables.size(); - for (size_t i = n - 1; i > 0; --i) - { - sal_Int32 nColPos = - maTables[i-1].GetColumn() + maTables[i].GetSpannedCols() - 1; - - maTables[i-1].SetColsPerCol(nColPos, - maTables[i-1].GetColsPerCol(nColPos) + - pCurrentTab->GetColsPerCol(pCurrentTab->GetColumn())); - - maTables[i-1].SetRealCols( - nColPos + 1, - maTables[i-1].GetRealCols(nColPos) + maTables[i-1].GetColsPerCol(nColPos)); - - maTables[i-1].SetChangedCols(nColPos); - } - } - } -} - void ScMyTables::AddColumn(bool bIsCovered) { - pCurrentTab->AddColumn(); - if (pCurrentTab->GetSubTableSpanned() > 1) - pCurrentTab->SetSubTableSpanned(pCurrentTab->GetSubTableSpanned() - 1); - else - { - NewColumn(bIsCovered); - sal_Int32 nCol = pCurrentTab->GetColumn(); - pCurrentTab->SetRealCols( - nCol + 1, pCurrentTab->GetRealCols(nCol) + pCurrentTab->GetColsPerCol(nCol)); - } + maCellPos.SetCol( maCellPos.Col() + 1 ); + //here only need to set column style if this is the first row and + //the cell is not covered. + if(maCellPos.Row() == 0 && !bIsCovered) + rImport.GetStylesImportHelper()->InsertCol(maCellPos.Col(), maCellPos.Tab(), rImport.GetDocument()); } void ScMyTables::UpdateRowHeights() @@ -420,21 +246,8 @@ void ScMyTables::DeleteTable() { ScXMLImport::MutexGuard aGuard(rImport); - nCurrentColStylePos = 0; - if (!maTables.empty()) - { - maTables.pop_back(); - if (!maTables.empty()) - pCurrentTab = &maTables.back(); - else - pCurrentTab = NULL; - } - - if (maTables.empty()) // only set the styles if all subtables are imported and the table is finished - { - rImport.GetStylesImportHelper()->SetStylesToRanges(); - rImport.SetStylesToRangesFinished(); - } + rImport.GetStylesImportHelper()->SetStylesToRanges(); + rImport.SetStylesToRangesFinished(); //#i48793#; has to be set before protection if (!aMatrixRangeList.empty()) @@ -461,56 +274,36 @@ void ScMyTables::DeleteTable() pProtect->setPasswordHash(aHash, maProtectionData.meHash1, maProtectionData.meHash2); pProtect->setOption(ScTableProtection::SELECT_LOCKED_CELLS, maProtectionData.mbSelectProtectedCells); pProtect->setOption(ScTableProtection::SELECT_UNLOCKED_CELLS, maProtectionData.mbSelectUnprotectedCells); - rImport.GetDocument()->SetTabProtection(nCurrentSheet, pProtect.get()); + rImport.GetDocument()->SetTabProtection(maCellPos.Tab(), pProtect.get()); } } -ScAddress ScMyTables::GetRealScCellPos() const -{ - SCROW nRow = 0; - SCCOL nCol = 0; - size_t n = maTables.size(); - for (size_t i = 0; i < n; ++i) - { - const ScMyTableData& rTab = maTables[i]; - nCol += rTab.GetRealCols(rTab.GetColumn()); - nRow += rTab.GetRealRows(rTab.GetRow()); - } - return ScAddress( nCol, nRow, nCurrentSheet ); -} - -void ScMyTables::AddColCount(sal_Int32 nTempColCount) -{ - pCurrentTab->SetColCount(pCurrentTab->GetColCount() + nTempColCount); -} - void ScMyTables::AddColStyle(const sal_Int32 nRepeat, const rtl::OUString& rCellStyleName) { - OSL_ENSURE(maTables.size() == 1, "not possible to use default styles on columns in subtables"); rImport.GetStylesImportHelper()->AddColumnStyle(rCellStyleName, nCurrentColStylePos, nRepeat); nCurrentColStylePos += nRepeat; } uno::Reference< drawing::XDrawPage > ScMyTables::GetCurrentXDrawPage() { - if( (nCurrentSheet != nCurrentDrawPage) || !xDrawPage.is() ) + if( (maCellPos.Tab() != nCurrentDrawPage) || !xDrawPage.is() ) { uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier( xCurrentSheet, uno::UNO_QUERY ); if( xDrawPageSupplier.is() ) xDrawPage.set(xDrawPageSupplier->getDrawPage()); - nCurrentDrawPage = sal::static_int_cast<sal_Int16>(nCurrentSheet); + nCurrentDrawPage = sal::static_int_cast<sal_Int16>(maCellPos.Tab()); } return xDrawPage; } uno::Reference< drawing::XShapes > ScMyTables::GetCurrentXShapes() { - if( (nCurrentSheet != nCurrentXShapes) || !xShapes.is() ) + if( (maCellPos.Tab() != nCurrentXShapes) || !xShapes.is() ) { xShapes.set(GetCurrentXDrawPage(), uno::UNO_QUERY); rImport.GetShapeImport()->startPage(xShapes); rImport.GetShapeImport()->pushGroupForSorting ( xShapes ); - nCurrentXShapes = sal::static_int_cast<sal_Int16>(nCurrentSheet); + nCurrentXShapes = sal::static_int_cast<sal_Int16>(maCellPos.Tab()); return xShapes; } else @@ -519,12 +312,12 @@ uno::Reference< drawing::XShapes > ScMyTables::GetCurrentXShapes() bool ScMyTables::HasDrawPage() { - return !((nCurrentSheet != nCurrentDrawPage) || !xDrawPage.is()); + return !((maCellPos.Tab() != nCurrentDrawPage) || !xDrawPage.is()); } bool ScMyTables::HasXShapes() { - return !((nCurrentSheet != nCurrentXShapes) || !xShapes.is()); + return !((maCellPos.Tab() != nCurrentXShapes) || !xShapes.is()); } void ScMyTables::AddOLE(uno::Reference <drawing::XShape>& rShape, @@ -540,8 +333,8 @@ void ScMyTables::AddMatrixRange( OSL_ENSURE(nEndRow >= nStartRow, "wrong row order"); OSL_ENSURE(nEndColumn >= nStartColumn, "wrong column order"); ScRange aScRange( - nStartColumn, nStartRow, nCurrentSheet, - nEndColumn, nEndRow, nCurrentSheet + nStartColumn, nStartRow, maCellPos.Tab(), + nEndColumn, nEndRow, maCellPos.Tab() ); ScMatrixRange aMRange(aScRange, rFormula, rFormulaNmsp, eGrammar); aMatrixRangeList.push_back(aMRange); @@ -557,7 +350,7 @@ bool ScMyTables::IsPartOfMatrix(const SCCOL nColumn, const SCROW nRow) bool bReady(false); while(!bReady && aItr != aEndItr) { - if (nCurrentSheet > aItr->aScRange.aStart.Tab()) + if (maCellPos.Tab() > aItr->aScRange.aStart.Tab()) { OSL_FAIL("should never hapen, because the list should be cleared in DeleteTable"); aItr = aMatrixRangeList.erase(aItr); diff --git a/sc/source/filter/xml/xmlsubti.hxx b/sc/source/filter/xml/xmlsubti.hxx index 8252f4c..7b69d5b 100644 --- a/sc/source/filter/xml/xmlsubti.hxx +++ b/sc/source/filter/xml/xmlsubti.hxx @@ -47,52 +47,6 @@ class ScXMLImport; -typedef std::vector<sal_Int32> ScMysalIntVec; -typedef std::list<sal_Int32> ScMysalIntList; - -const ScMysalIntVec::size_type nDefaultRowCount = 20; -const ScMysalIntVec::size_type nDefaultColCount = 20; -const ScMysalIntVec::size_type nDefaultTabCount = 10; - -class ScMyTableData -{ -private: - ScAddress maTableCellPos; - ScMysalIntVec nColsPerCol; - ScMysalIntVec nRealCols; - ScMysalIntVec nRowsPerRow; - ScMysalIntVec nRealRows; - sal_Int32 nSpannedCols; - sal_Int32 nColCount; - sal_Int32 nSubTableSpanned; - ScMysalIntList nChangedCols; -public: - ScMyTableData(SCTAB nSheet = -1, SCCOL nCol = -1, SCROW nRow = -1); - ~ScMyTableData(); - SCROW GetRow() const { return maTableCellPos.Row(); } - SCCOL GetColumn() const { return maTableCellPos.Col(); } - void AddRow(); - void AddColumn(); - void SetFirstColumn() { maTableCellPos.SetCol(-1); } - sal_Int32 GetColsPerCol(const sal_Int32 nIndex) const { return nColsPerCol[nIndex]; } - void SetColsPerCol(const sal_Int32 nIndex, sal_Int32 nValue = 1) { nColsPerCol[nIndex] = nValue; } - sal_Int32 GetRealCols(const sal_Int32 nIndex, const bool bIsNormal = true) const; - void SetRealCols(const sal_Int32 nIndex, const sal_Int32 nValue) { nRealCols[nIndex] = nValue; } - sal_Int32 GetRowsPerRow(const sal_Int32 nIndex) const { return nRowsPerRow[nIndex]; } - void SetRowsPerRow(const sal_Int32 nIndex, const sal_Int32 nValue = 1) { nRowsPerRow[nIndex] = nValue; } - sal_Int32 GetRealRows(const sal_Int32 nIndex) const { return nIndex < 0 ? 0 : nRealRows[nIndex]; } - void SetRealRows(const sal_Int32 nIndex, const sal_Int32 nValue) { nRealRows[nIndex] = nValue; } - sal_Int32 GetSpannedCols() const { return nSpannedCols; } - void SetSpannedCols(const sal_Int32 nTempSpannedCols) { nSpannedCols = nTempSpannedCols; } - sal_Int32 GetColCount() const { return nColCount; } - void SetColCount(const sal_Int32 nTempColCount) { nColCount = nTempColCount; } - sal_Int32 GetSubTableSpanned() const { return nSubTableSpanned; } - void SetSubTableSpanned(const sal_Int32 nValue) { nSubTableSpanned = nValue; } - sal_Int32 GetChangedCols(const sal_Int32 nFromIndex, const sal_Int32 nToIndex) const; - void SetChangedCols(const sal_Int32 nValue); -}; - - struct ScMatrixRange { rtl::OUString sFormula; @@ -134,14 +88,12 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > xDrawPage; ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShapes > xShapes; rtl::OUString sCurrentSheetName; - ::boost::ptr_vector<ScMyTableData> maTables; + ScAddress maCellPos; ScXMLTabProtectionData maProtectionData; ScMyMatrixRangeList aMatrixRangeList; sal_Int32 nCurrentColStylePos; sal_Int16 nCurrentDrawPage; sal_Int16 nCurrentXShapes; - SCTAB nCurrentSheet; - ScMyTableData* pCurrentTab; void NewRow(); void NewColumn(bool bIsCovered); @@ -158,16 +110,15 @@ public: void UpdateRowHeights(); void FixupOLEs() { aFixupOLEs.FixupOLEs(); } bool IsOLE(com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape) const - { return ScMyOLEFixer::IsOLE(rShape); } + { return ScMyOLEFixer::IsOLE(rShape); } void DeleteTable(); - ScAddress GetRealScCellPos() const; - void AddColCount(sal_Int32 nTempColCount); + ScAddress GetRealScCellPos() const { return maCellPos; }; void AddColStyle(const sal_Int32 nRepeat, const rtl::OUString& rCellStyleName); ScXMLTabProtectionData& GetCurrentProtectionData() { return maProtectionData; } rtl::OUString GetCurrentSheetName() const { return sCurrentSheetName; } - SCTAB GetCurrentSheet() const { return nCurrentSheet; } - sal_Int32 GetCurrentColumn() const { return maTables.back().GetColCount(); } - sal_Int32 GetCurrentRow() const { return maTables.back().GetRow(); } + SCTAB GetCurrentSheet() const { return (maCellPos.Tab() >= 0) ? maCellPos.Tab() : 0; } + SCCOL GetCurrentColumn() const { return (maCellPos.Col() >= 0) ? maCellPos.Col() : 0; } + SCROW GetCurrentRow() const { return (maCellPos.Row() >= 0) ? maCellPos.Row() : 0; } ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet > GetCurrentXSheet() const { return xCurrentSheet; } ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
