diff options
5 files changed, 38 insertions, 18 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx index bca93f9f5971..a430fc2c0e34 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx @@ -48,7 +48,7 @@ using namespace ::com::sun::star; using namespace ::std; -DomainMapperTableManager::DomainMapperTableManager(bool bOOXML) : +DomainMapperTableManager::DomainMapperTableManager(bool bOOXML, bool bImplicitMerges) : m_nRow(0), m_nCell(0), m_nGridSpan(1), @@ -56,6 +56,7 @@ DomainMapperTableManager::DomainMapperTableManager(bool bOOXML) : m_nHeaderRepeat(0), m_nTableWidth(0), m_bOOXML( bOOXML ), + m_bImplicitMerges(bImplicitMerges), m_pTablePropsHandler( new TablePropertiesHandler( bOOXML ) ) { m_pTablePropsHandler->SetTableManager( this ); @@ -437,12 +438,12 @@ void DomainMapperTableManager::endOfRowAction() for( ; aGridSpanIter != pCurrentSpans->end(); ++aGridSpanIter) nGrids += *aGridSpanIter; + //determine table width + double nFullWidth = m_nTableWidth; + //the positions have to be distibuted in a range of 10000 + const double nFullWidthRelative = 10000.; if( pTableGrid->size() == nGrids ) { - //determine table width - double nFullWidth = m_nTableWidth; - //the positions have to be distibuted in a range of 10000 - const double nFullWidthRelative = 10000.; uno::Sequence< text::TableColumnSeparator > aSeparators( m_nCell - 1 ); text::TableColumnSeparator* pSeparators = aSeparators.getArray(); sal_Int16 nLastRelPos = 0; @@ -476,6 +477,33 @@ void DomainMapperTableManager::endOfRowAction() #endif insertRowProps(pPropMap); } + else if (m_bImplicitMerges) + { + // More grid than cells definitions? Then take the last ones. + // This feature is used by the RTF implicit horizontal cell merges. + uno::Sequence< text::TableColumnSeparator > aSeparators(m_nCell - 1); + text::TableColumnSeparator* pSeparators = aSeparators.getArray(); + + sal_Int16 nSum = 0; + sal_uInt32 nPos = 0; + // Ignoring the i=0 case means we assume that the width of the last cell matches the table width + for (int i = m_nCell; i > 1; i--) + { + nSum += (*pTableGrid.get())[pTableGrid->size() - i]; // Size of the current cell + pSeparators[nPos].Position = nSum * nFullWidthRelative / nFullWidth; // Relative position + pSeparators[nPos].IsVisible = sal_True; + nPos++; + } + + TablePropertyMapPtr pPropMap( new TablePropertyMap ); + pPropMap->Insert( PROP_TABLE_COLUMN_SEPARATORS, false, uno::makeAny( aSeparators ) ); +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->startElement("rowProperties"); + pPropMap->dumpXml( dmapper_logger ); + dmapper_logger->endElement(); +#endif + insertRowProps(pPropMap); + } ++m_nRow; m_nCell = 0; diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.hxx b/writerfilter/source/dmapper/DomainMapperTableManager.hxx index 6b20f026b725..67aeb74e05fb 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.hxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.hxx @@ -50,6 +50,7 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t sal_Int32 m_nHeaderRepeat; //counter of repeated headers - if == -1 then the repeating stops sal_Int32 m_nTableWidth; //might be set directly or has to be calculated from the column positions bool m_bOOXML; + bool m_bImplicitMerges; ::rtl::OUString m_sTableStyleName; PropertyMapPtr m_pTableStyleTextProperies; @@ -63,7 +64,7 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t public: - DomainMapperTableManager(bool bOOXML); + DomainMapperTableManager(bool bOOXML, bool bImplicitMerges); virtual ~DomainMapperTableManager(); // use this method to avoid adding the properties for the table diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index d7d05462f7b1..c4899cb0c20e 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -546,7 +546,7 @@ public: void appendTableManager( ) { boost::shared_ptr< DomainMapperTableManager > pMngr( - new DomainMapperTableManager( m_eDocumentType == DOCUMENT_OOXML || m_eDocumentType == DOCUMENT_RTF ) ); + new DomainMapperTableManager( m_eDocumentType == DOCUMENT_OOXML || m_eDocumentType == DOCUMENT_RTF, m_eDocumentType == DOCUMENT_RTF ) ); m_aTableManagers.push( pMngr ); } diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index de1195bf9282..06fc047b45a5 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -260,7 +260,6 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x m_aFontIndexes(), m_aColorTable(), m_bFirstRun(true), - m_bFirstRow(true), m_bNeedPap(true), m_bNeedCr(false), m_bNeedPar(true), @@ -452,8 +451,6 @@ void RTFDocumentImpl::parBreak() // If we are not in a table, then the next table row will be the first one. RTFValue::Pointer_t pValue = m_aStates.top().aParagraphSprms.find(NS_sprm::LN_PFInTable); - if (!pValue.get()) - m_bFirstRow = true; // start new one Mapper().startParagraphGroup(); @@ -1362,7 +1359,6 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) case RTF_ROW: case RTF_NESTROW: { - m_bFirstRow = false; if (m_aStates.top().nCells) { // Make a backup before we start popping elements @@ -2281,11 +2277,8 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) { int nCellX = nParam - m_aStates.top().nCellX; m_aStates.top().nCellX = nParam; - if (m_bFirstRow) - { - RTFValue::Pointer_t pXValue(new RTFValue(nCellX)); - m_aStates.top().aTableRowSprms->push_back(make_pair(NS_ooxml::LN_CT_TblGridBase_gridCol, pXValue)); - } + RTFValue::Pointer_t pXValue(new RTFValue(nCellX)); + m_aStates.top().aTableRowSprms->push_back(make_pair(NS_ooxml::LN_CT_TblGridBase_gridCol, pXValue)); m_aStates.top().nCells++; // Push cell properties. diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index 80136771dd86..5e6fc683a899 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -370,8 +370,6 @@ namespace writerfilter { /// Color index <-> RGB color value map std::vector<sal_uInt32> m_aColorTable; bool m_bFirstRun; - /// If this is the first row in a table - there we send cell widths. - bool m_bFirstRow; /// If paragraph properties should be emitted on next run. bool m_bNeedPap; /// If we need to emit a CR at the end of substream. |