diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2013-02-22 17:08:39 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-02-22 17:48:58 +0100 |
commit | 0208ead70a9412ccd554fcef3e9308f8ca17037b (patch) | |
tree | 6f324f0afd493c4790d80671ffd903805c0bbddb /writerfilter/source | |
parent | 5dff2d0822bb299c134a05a64747ce1bb42ad7cd (diff) |
DOCX import: improve btLr table cell support
The problem was that in case the contents didn't fit into a single line,
multiple lines were created, which is not what btLr wants. Set the size
type to fixed in this case.
Change-Id: Ibab1313f95dc16dd0366d21a00109a6f38fa3526
Diffstat (limited to 'writerfilter/source')
3 files changed, 24 insertions, 1 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx index d3ddf82f9fe8..1f9853b7afef 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx @@ -52,6 +52,7 @@ DomainMapperTableManager::DomainMapperTableManager(bool bOOXML) : m_nTableWidth(0), m_bOOXML( bOOXML ), m_bPushCurrentWidth(false), + m_bRowSizeTypeInserted(false), m_pTablePropsHandler( new TablePropertiesHandler( bOOXML ) ) { m_pTablePropsHandler->SetTableManager( this ); @@ -261,10 +262,18 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm) SAL_INFO( "writerfilter", "Have inserted textDirection " << nIntValue ); break; case 3: // btLr + { // We have to fake this text direction pPropMap->Insert( PROP_FRM_DIRECTION, false, uno::makeAny( text::WritingMode2::LR_TB )); pPropMap->Insert( PROP_CHAR_ROTATION, false, uno::makeAny( sal_Int16( 900 ) )); SAL_INFO( "writerfilter", "Have inserted textDirection " << nIntValue ); + + // We're faking a text direction, so don't allow multiple lines. + TablePropertyMapPtr pRowPropMap( new TablePropertyMap ); + pRowPropMap->Insert(PROP_SIZE_TYPE, false, uno::makeAny(text::SizeType::FIX)); + m_bRowSizeTypeInserted = true; + insertRowProps(pRowPropMap); + } break; case 4: // lrTbV pPropMap->Insert( PROP_FRM_DIRECTION, false, uno::makeAny( text::WritingMode2::LR_TB )); @@ -583,6 +592,7 @@ void DomainMapperTableManager::endOfRowAction() pCellWidths->clear(); m_nGridBefore = m_nGridAfter = 0; + m_bRowSizeTypeInserted = false; #ifdef DEBUG_DOMAINMAPPER dmapper_logger->endElement(); diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.hxx b/writerfilter/source/dmapper/DomainMapperTableManager.hxx index d3164eaf3ee3..6ae6b1caad07 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.hxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.hxx @@ -54,6 +54,8 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t bool m_bPushCurrentWidth; /// Individual table cell width values, used only in case the number of cells doesn't match the table grid. ::std::vector< IntVectorPtr > m_aCellWidths; + /// Remember if a cell already set this, then it should not be set at a row level. + bool m_bRowSizeTypeInserted; TablePropertiesHandler *m_pTablePropsHandler; PropertyMapPtr m_pStyleProps; @@ -119,6 +121,11 @@ public: DomainMapperTableManager_Base_t::insertTableProps( pProps ); }; + bool IsRowSizeTypeInserted() const + { + return m_bRowSizeTypeInserted; + } + }; }} diff --git a/writerfilter/source/dmapper/TablePropertiesHandler.cxx b/writerfilter/source/dmapper/TablePropertiesHandler.cxx index b1d560cd592a..a1621f18c11c 100644 --- a/writerfilter/source/dmapper/TablePropertiesHandler.cxx +++ b/writerfilter/source/dmapper/TablePropertiesHandler.cxx @@ -24,6 +24,7 @@ #include "MeasureHandler.hxx" #include "TablePropertiesHandler.hxx" #include "TDefTableHandler.hxx" +#include "DomainMapperTableManager.hxx" #include <ooxml/resourceids.hxx> #include <doctok/sprmids.hxx> @@ -92,7 +93,12 @@ namespace dmapper { MeasureHandlerPtr pMeasureHandler( new MeasureHandler ); pProperties->resolve(*pMeasureHandler); TablePropertyMapPtr pPropMap( new TablePropertyMap ); - pPropMap->Insert( PROP_SIZE_TYPE, false, uno::makeAny( pMeasureHandler->GetRowHeightSizeType() )); + + // In case a cell already wanted fixed size, we should not overwrite it here. + DomainMapperTableManager* pManager = dynamic_cast<DomainMapperTableManager*>(m_pTableManager); + if (!pManager || !pManager->IsRowSizeTypeInserted()) + pPropMap->Insert( PROP_SIZE_TYPE, false, uno::makeAny( pMeasureHandler->GetRowHeightSizeType() ), false); + pPropMap->Insert( PROP_HEIGHT, false, uno::makeAny(pMeasureHandler->getMeasureValue() )); insertRowProps(pPropMap); } |