diff options
author | Henning Brinkmann[hbrinkm] <hbrinkm@openoffice.org> | 2009-12-15 13:53:59 +0100 |
---|---|---|
committer | Henning Brinkmann[hbrinkm] <hbrinkm@openoffice.org> | 2009-12-15 13:53:59 +0100 |
commit | 1814b0dfc3869a85b513af107ff6172cb749f87e (patch) | |
tree | a3f59be34f685ffc8173681f4fb441ff9afb924b /writerfilter/inc | |
parent | writerfilter07: obey TableManager protocol again, some debugging output (diff) | |
download | core-1814b0dfc3869a85b513af107ff6172cb749f87e.tar.gz core-1814b0dfc3869a85b513af107ff6172cb749f87e.zip |
writerfilter07: restored TableManager
Diffstat (limited to 'writerfilter/inc')
-rw-r--r-- | writerfilter/inc/resourcemodel/TableManager.hxx | 115 |
1 files changed, 42 insertions, 73 deletions
diff --git a/writerfilter/inc/resourcemodel/TableManager.hxx b/writerfilter/inc/resourcemodel/TableManager.hxx index cc267273fdf0..23e3f7a24994 100644 --- a/writerfilter/inc/resourcemodel/TableManager.hxx +++ b/writerfilter/inc/resourcemodel/TableManager.hxx @@ -103,11 +103,6 @@ public: @param rT end handle of cell */ virtual void endCell(const T & rT) = 0; - - virtual T* getTable( ) - { - return NULL; - }; }; template <typename T, typename PropertiesPointer> @@ -156,16 +151,16 @@ class TableManager /** properties of the current cell */ - vector< PropertiesPointer > mpCellProps; + PropertiesPointer mpCellProps; /** properties of the current row */ - vector< PropertiesPointer > mpRowProps; + PropertiesPointer mpRowProps; /** - properties of the current table: don't use them directly. - */ + properties of the current table + */ PropertiesPointer mpTableProps; /** @@ -173,7 +168,6 @@ class TableManager */ T mCurHandle; - T* mpInnerTable; /** stack of table data @@ -237,6 +231,7 @@ protected: */ virtual void clearData(); + public: TableManager(); virtual ~TableManager(){} @@ -356,7 +351,7 @@ public: template <typename T, typename PropertiesPointer> TableManager<T, PropertiesPointer>::TableManager() : mbRowEnd(false), mbInCell(false), mbCellEnd(false), mnTableDepthNew(0), - mnTableDepth(0), mpInnerTable( NULL ) + mnTableDepth(0) { } @@ -403,30 +398,19 @@ void TableManager<T, PropertiesPointer>::handle(const T & rHandle) template <typename T, typename PropertiesPointer> void TableManager<T, PropertiesPointer>::startLevel() { -#if DEBUG - std::clog << "TableManager::startLevel()" << std::endl; -#endif typename TableData<T, PropertiesPointer>::Pointer_t pTableData (new TableData<T, PropertiesPointer>(mTableDataStack.size())); mTableDataStack.push(pTableData); - - PropertiesPointer pEmptyProps; - cellProps( pEmptyProps ); } template <typename T, typename PropertiesPointer> void TableManager<T, PropertiesPointer>::endLevel() { -#if DEBUG - std::clog << "TableManager::endLevel()" << std::endl; -#endif if (mpTableDataHandler.get() != NULL) resolveCurrentTable(); - mTableDataStack.pop(); - if ( mpCellProps.size( ) > 0 ) - mpCellProps.pop_back( ); + mTableDataStack.pop(); } template <typename T, typename PropertiesPointer> @@ -442,6 +426,12 @@ template <typename T, typename PropertiesPointer> void TableManager<T, PropertiesPointer>::endParagraphGroup() { sal_Int32 nTableDepthDifference = mnTableDepthNew - mnTableDepth; + while (nTableDepthDifference > 0) + { + startLevel(); + + --nTableDepthDifference; + } while (nTableDepthDifference < 0) { endLevel(); @@ -451,38 +441,31 @@ void TableManager<T, PropertiesPointer>::endParagraphGroup() mnTableDepth = mnTableDepthNew; - typename TableData<T, PropertiesPointer>::Pointer_t pTableData = + if (mnTableDepth > 0) + { + typename TableData<T, PropertiesPointer>::Pointer_t pTableData = mTableDataStack.top(); - if (mbRowEnd) - { - endOfRowAction(); - pTableData->endRow( mpRowProps.back( ) ); - mpRowProps.back( ).reset(); - } - else if ( mbInCell ) - { - if (! pTableData->isCellOpen()) + if (mbRowEnd) { - if ( mpInnerTable ) - { - pTableData->addCell( *mpInnerTable, mpCellProps.back( ) ); - mpInnerTable = NULL; - } - else - { - pTableData->addCell( mCurHandle, mpCellProps.back( ) ); - } + endOfRowAction(); + pTableData->endRow(mpRowProps); + mpRowProps.reset(); } - if (mbCellEnd) + else if (mbInCell) { - endOfCellAction(); - pTableData->endCell(mCurHandle); + if (! pTableData->isCellOpen()) + pTableData->addCell(mCurHandle, mpCellProps); + + if (mbCellEnd) + { + endOfCellAction(); + pTableData->endCell(mCurHandle); + } } + mpCellProps.reset(); } - if ( mpCellProps.size( ) > 0 ) - mpCellProps.back().reset( ); } template <typename T, typename PropertiesPointer> @@ -558,15 +541,10 @@ void TableManager<T, PropertiesPointer>::utext(const sal_uInt8 * data, size_t le template <typename T, typename PropertiesPointer> void TableManager<T, PropertiesPointer>::cellProps(PropertiesPointer pProps) { - if ( mpCellProps.size( ) == mTableDataStack.size( ) ) - { - if ( mpCellProps.back( ).get( ) ) - mpCellProps.back()->insert( pProps ); - else - mpCellProps.back( ) = pProps; - } + if(mpCellProps.get()) + mpCellProps->insert( pProps ); else - mpCellProps.push_back( pProps ); + mpCellProps = pProps; } template <typename T, typename PropertiesPointer> @@ -579,24 +557,19 @@ void TableManager<T, PropertiesPointer>::cellPropsByCell template <typename T, typename PropertiesPointer> void TableManager<T, PropertiesPointer>::insertRowProps(PropertiesPointer pProps) { - if ( mpRowProps.size( ) == ( mTableDataStack.size( ) - 1 ) ) - { - if( mpRowProps.back( ).get( ) ) - mpRowProps.back( )->insert( pProps ); - else - mpRowProps.back( ) = pProps; - } + if( mpRowProps.get() ) + mpRowProps->insert( pProps ); else - mpRowProps.push_back( pProps ); + mpRowProps = pProps; } template <typename T, typename PropertiesPointer> void TableManager<T, PropertiesPointer>::insertTableProps(PropertiesPointer pProps) { - typename TableData<T, PropertiesPointer>::Pointer_t - pTableData = mTableDataStack.top(); - - pTableData->insertTableProperties( pProps ); + if( mpTableProps.get() ) + mpTableProps->insert( pProps ); + else + mpTableProps = pProps; } template <typename T, typename PropertiesPointer> @@ -609,7 +582,7 @@ void TableManager<T, PropertiesPointer>::resolveCurrentTable() unsigned int nRows = pTableData->getRowCount(); - mpTableDataHandler->startTable(nRows, pTableData->getDepth(), pTableData->getTableProperties( ) ); + mpTableDataHandler->startTable(nRows, pTableData->getDepth(), mpTableProps); for (unsigned int nRow = 0; nRow < nRows; ++nRow) { @@ -632,12 +605,8 @@ void TableManager<T, PropertiesPointer>::resolveCurrentTable() } mpTableDataHandler->endTable(); - - // The inner table has to be stored only if there is something in the stack - // The 0 depth is the dummy table for the whole stream - if ( pTableData->getDepth( ) > 1 ) - mpInnerTable = mpTableDataHandler->getTable( ); } + mpTableProps.reset(); clearData(); } |