summaryrefslogtreecommitdiff
path: root/writerfilter/source
diff options
context:
space:
mode:
Diffstat (limited to 'writerfilter/source')
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableManager.cxx61
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableManager.hxx4
-rw-r--r--writerfilter/source/dmapper/TablePositionHandler.cxx10
-rw-r--r--writerfilter/source/dmapper/TablePositionHandler.hxx2
-rw-r--r--writerfilter/source/ooxml/OOXMLParserState.cxx3
5 files changed, 74 insertions, 6 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index 59ce1eac2d84..6362969ecdb7 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -50,6 +50,8 @@ DomainMapperTableManager::DomainMapperTableManager(bool bOOXML) :
m_nHeaderRepeat(0),
m_nTableWidth(0),
m_bOOXML( bOOXML ),
+ m_aTmpPosition(),
+ m_aTmpTableProperties(),
m_bPushCurrentWidth(false),
m_nLayoutType(0),
m_nMaxFixedWidth(0),
@@ -386,14 +388,14 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
if (pProperties.get())
{
- TablePositionHandlerPtr pHandler = m_aTablePositions.back();
+ TablePositionHandlerPtr pHandler = m_aTmpPosition.back();
if ( !pHandler )
{
- m_aTablePositions.pop_back();
+ m_aTmpPosition.pop_back();
pHandler.reset( new TablePositionHandler );
- m_aTablePositions.push_back( pHandler );
+ m_aTmpPosition.push_back( pHandler );
}
- pProperties->resolve(*pHandler);
+ pProperties->resolve(*m_aTmpPosition.back());
}
}
break;
@@ -457,6 +459,11 @@ void DomainMapperTableManager::startLevel( )
m_aGridSpans.push_back( pNewSpans );
m_aCellWidths.push_back( pNewCellWidths );
m_aTablePositions.push_back( pNewPositionHandler );
+
+ TablePositionHandlerPtr pTmpPosition;
+ TablePropertyMapPtr pTmpProperties( new TablePropertyMap( ) );
+ m_aTmpPosition.push_back( pTmpPosition );
+ m_aTmpTableProperties.push_back( pTmpProperties );
m_nCell.push_back( 0 );
m_nTableWidth = 0;
m_nLayoutType = 0;
@@ -475,6 +482,8 @@ void DomainMapperTableManager::endLevel( )
m_nTableWidth = 0;
m_nLayoutType = 0;
+ m_aTmpPosition.pop_back( );
+ m_aTmpTableProperties.pop_back( );
DomainMapperTableManager_Base_t::endLevel( );
#ifdef DEBUG_DOMAINMAPPER
@@ -511,6 +520,42 @@ void DomainMapperTableManager::endOfRowAction()
dmapper_logger->startElement("endOfRowAction");
#endif
+ // Compare the table position with the previous ones. We may need to split
+ // into two tables if those are different. We surely don't want to do anything
+ // if we don't have any row yet.
+ TablePositionHandlerPtr pTmpPosition = m_aTmpPosition.back();
+ TablePropertyMapPtr pTmpTableProperties = m_aTmpTableProperties.back( );
+ TablePositionHandlerPtr pCurrentPosition = m_aTablePositions.back();
+ bool bSamePosition = ( pTmpPosition == pCurrentPosition ) ||
+ ( pTmpPosition && pCurrentPosition && *pTmpPosition == *pCurrentPosition );
+ if ( !bSamePosition && m_nRow > 0 )
+ {
+ // Save the grid infos to have them survive the end/start level
+ IntVectorPtr pTmpTableGrid = m_aTableGrid.back();
+ IntVectorPtr pTmpGridSpans = m_aGridSpans.back();
+ IntVectorPtr pTmpCellWidths = m_aCellWidths.back();
+
+ // endLevel and startLevel are taking care of the non finished row
+ // to carry it over to the next table
+ setKeepUnfinishedRow( true );
+ endLevel();
+ setKeepUnfinishedRow( false );
+ startLevel();
+
+ m_aTableGrid.pop_back();
+ m_aGridSpans.pop_back();
+ m_aCellWidths.pop_back();
+ m_aTableGrid.push_back(pTmpTableGrid);
+ m_aGridSpans.push_back(pTmpGridSpans);
+ m_aCellWidths.push_back(pTmpCellWidths);
+ }
+
+ // Push the tmp position now that we compared it
+ m_aTablePositions.pop_back();
+ m_aTablePositions.push_back( pTmpPosition );
+ m_aTmpPosition.back().reset( );
+
+
IntVectorPtr pTableGrid = getCurrentGrid( );
IntVectorPtr pCellWidths = getCurrentCellWidths( );
if(!m_nTableWidth && pTableGrid->size())
@@ -645,9 +690,17 @@ void DomainMapperTableManager::endOfRowAction()
insertRowProps(pPropMap);
}
+ // Now that potentially opened table is closed, save the table properties
+ DomainMapperTableManager_Base_t::insertTableProps( pTmpTableProperties );
+
+ m_aTmpTableProperties.pop_back();
+ TablePropertyMapPtr pEmptyTableProps( new TablePropertyMap() );
+ m_aTmpTableProperties.push_back( pEmptyTableProps );
+
++m_nRow;
m_nCell.back( ) = 0;
m_nCellBorderIndex = 0;
+ getCurrentGrid()->clear();
pCurrentSpans->clear();
pCellWidths->clear();
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.hxx b/writerfilter/source/dmapper/DomainMapperTableManager.hxx
index c3ac115ded3f..fc4f7aa201eb 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.hxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.hxx
@@ -46,6 +46,8 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t
bool m_bOOXML;
OUString m_sTableStyleName;
std::vector< TablePositionHandlerPtr > m_aTablePositions;
+ std::vector< TablePositionHandlerPtr > m_aTmpPosition; ///< Temporarily stores the position to compare it later
+ std::vector< TablePropertyMapPtr > m_aTmpTableProperties; ///< Temporarily stores the table properties until end of row
PropertyMapPtr m_pTableStyleTextProperies;
::std::vector< IntVectorPtr > m_aTableGrid;
@@ -119,7 +121,7 @@ public:
if ( m_pStyleProps.get( ) )
m_pStyleProps->InsertProps(pProps);
else
- DomainMapperTableManager_Base_t::insertTableProps( pProps );
+ m_aTmpTableProperties.back()->InsertProps(pProps);
};
void SetLayoutType(sal_uInt32 nLayoutType)
diff --git a/writerfilter/source/dmapper/TablePositionHandler.cxx b/writerfilter/source/dmapper/TablePositionHandler.cxx
index 8ae6ac20e6a4..7ed8bde1d230 100644
--- a/writerfilter/source/dmapper/TablePositionHandler.cxx
+++ b/writerfilter/source/dmapper/TablePositionHandler.cxx
@@ -164,6 +164,16 @@ uno::Sequence<beans::PropertyValue> TablePositionHandler::getTablePosition() con
return aFrameProperties;
}
+bool TablePositionHandler::operator== (const TablePositionHandler& rHandler) const
+{
+ return m_aVertAnchor == rHandler.m_aVertAnchor &&
+ m_aYSpec == rHandler.m_aYSpec &&
+ m_aHorzAnchor == rHandler.m_aHorzAnchor &&
+ m_aXSpec == rHandler.m_aXSpec &&
+ m_nY == rHandler.m_nY &&
+ m_nX == rHandler.m_nX;
+}
+
} // namespace dmapper
} // namespace writerfilter
diff --git a/writerfilter/source/dmapper/TablePositionHandler.hxx b/writerfilter/source/dmapper/TablePositionHandler.hxx
index dc096e687d26..b6ddd5006d21 100644
--- a/writerfilter/source/dmapper/TablePositionHandler.hxx
+++ b/writerfilter/source/dmapper/TablePositionHandler.hxx
@@ -43,6 +43,8 @@ namespace writerfilter {
properties before actually using them.
*/
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> getTablePosition() const;
+
+ bool operator== (const TablePositionHandler& rHandler) const;
};
typedef boost::shared_ptr<TablePositionHandler> TablePositionHandlerPtr;
diff --git a/writerfilter/source/ooxml/OOXMLParserState.cxx b/writerfilter/source/ooxml/OOXMLParserState.cxx
index 723aef804b35..36be1d1e6059 100644
--- a/writerfilter/source/ooxml/OOXMLParserState.cxx
+++ b/writerfilter/source/ooxml/OOXMLParserState.cxx
@@ -232,7 +232,8 @@ void OOXMLParserState::resolveTableProperties(Stream & rStream)
if (rTableProps.get() != NULL)
{
rStream.props(rTableProps);
- rTableProps.reset(new OOXMLPropertySetImpl());
+ // Don't clean the table props to send them again for each row
+ // This mimics the behaviour from RTF tokenizer.
}
}
}