From 909562ae8a614cdd50131028ece20e0ee08d16aa Mon Sep 17 00:00:00 2001 From: "Henning Brinkmann[hbrinkm]" Date: Tue, 5 Jan 2010 16:59:52 +0100 Subject: writerfilter07: TableManager: use a stack for the current table state --- writerfilter/inc/resourcemodel/TableManager.hxx | 148 +++++++++++++++++------- 1 file changed, 105 insertions(+), 43 deletions(-) (limited to 'writerfilter/inc') diff --git a/writerfilter/inc/resourcemodel/TableManager.hxx b/writerfilter/inc/resourcemodel/TableManager.hxx index 23e3f7a24994..7f38b075624c 100644 --- a/writerfilter/inc/resourcemodel/TableManager.hxx +++ b/writerfilter/inc/resourcemodel/TableManager.hxx @@ -116,6 +116,90 @@ template */ class TableManager { + struct TableManagerState + { + /** + properties at the current point in document + */ + PropertiesPointer mpProps; + + /** + properties of the current cell + */ + PropertiesPointer mpCellProps; + + /** + properties of the current row + */ + PropertiesPointer mpRowProps; + + /** + properties of the current table + */ + PropertiesPointer mpTableProps; + + }; + + /** + handle for the current position in document + */ + T mCurHandle; + + ::std::stack mStateStack; + TableManagerState mState; + +protected: + PropertiesPointer getProps() + { + return mState.mpProps; + } + + void setProps(PropertiesPointer pProps) + { + mState.mpProps = pProps; + } + + PropertiesPointer getCellProps() + { + return mState.mpCellProps; + } + + void setCellProps(PropertiesPointer pProps) + { + mState.mpCellProps = pProps; + } + + PropertiesPointer getRowProps() + { + return mState.mpRowProps; + } + + void setRowProps(PropertiesPointer pProps) + { + mState.mpRowProps = pProps; + } + + PropertiesPointer getTableProps() + { + return mState.mpTableProps; + } + + void setTableProps(PropertiesPointer pProps) + { + mState.mpTableProps = pProps; + } + + T getHandle() + { + return mCurHandle; + } + + void setHandle(const T & rHandle) + { + mCurHandle = rHandle; + } + +private: typedef boost::shared_ptr T_p; /** @@ -143,31 +227,6 @@ class TableManager */ sal_uInt32 mnTableDepth; - /** - properties at the current point in document - */ - PropertiesPointer mpProps; - - /** - properties of the current cell - */ - PropertiesPointer mpCellProps; - - /** - properties of the current row - */ - PropertiesPointer mpRowProps; - - /** - properties of the current table - */ - PropertiesPointer mpTableProps; - - /** - handle for the current position in document - */ - T mCurHandle; - /** stack of table data @@ -392,7 +451,7 @@ void TableManager::setHandler template void TableManager::handle(const T & rHandle) { - mCurHandle = rHandle; + setHandle(rHandle); } template @@ -402,6 +461,7 @@ void TableManager::startLevel() (new TableData(mTableDataStack.size())); mTableDataStack.push(pTableData); + mStateStack.push(mState); } template @@ -411,6 +471,8 @@ void TableManager::endLevel() resolveCurrentTable(); mTableDataStack.pop(); + mState = mStateStack.top(); + mStateStack.pop(); } template @@ -449,22 +511,22 @@ void TableManager::endParagraphGroup() if (mbRowEnd) { endOfRowAction(); - pTableData->endRow(mpRowProps); - mpRowProps.reset(); + pTableData->endRow(getRowProps()); + getRowProps().reset(); } else if (mbInCell) { if (! pTableData->isCellOpen()) - pTableData->addCell(mCurHandle, mpCellProps); + pTableData->addCell(getHandle(), getCellProps()); if (mbCellEnd) { endOfCellAction(); - pTableData->endCell(mCurHandle); + pTableData->endCell(getHandle()); } } - mpCellProps.reset(); + getCellProps().reset(); } } @@ -499,7 +561,7 @@ bool TableManager::sprm(Sprm & rSprm) template void TableManager::props(PropertiesPointer pProps) { - mpProps = pProps; + setProps(pProps); } template @@ -541,10 +603,10 @@ void TableManager::utext(const sal_uInt8 * data, size_t le template void TableManager::cellProps(PropertiesPointer pProps) { - if(mpCellProps.get()) - mpCellProps->insert( pProps ); + if(getCellProps().get()) + getCellProps()->insert( pProps ); else - mpCellProps = pProps; + setCellProps(pProps); } template @@ -557,19 +619,19 @@ void TableManager::cellPropsByCell template void TableManager::insertRowProps(PropertiesPointer pProps) { - if( mpRowProps.get() ) - mpRowProps->insert( pProps ); + if( getRowProps().get() ) + getRowProps()->insert( pProps ); else - mpRowProps = pProps; + setRowProps(pProps); } template void TableManager::insertTableProps(PropertiesPointer pProps) { - if( mpTableProps.get() ) - mpTableProps->insert( pProps ); + if( getTableProps().get() ) + getTableProps()->insert( pProps ); else - mpTableProps = pProps; + setTableProps(pProps); } template @@ -582,7 +644,7 @@ void TableManager::resolveCurrentTable() unsigned int nRows = pTableData->getRowCount(); - mpTableDataHandler->startTable(nRows, pTableData->getDepth(), mpTableProps); + mpTableDataHandler->startTable(nRows, pTableData->getDepth(), getTableProps()); for (unsigned int nRow = 0; nRow < nRows; ++nRow) { @@ -606,7 +668,7 @@ void TableManager::resolveCurrentTable() mpTableDataHandler->endTable(); } - mpTableProps.reset(); + getTableProps().reset(); clearData(); } -- cgit v1.2.3