summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-02-22 17:08:39 +0100
committerMiklos Vajna <vmiklos@suse.cz>2013-02-22 17:48:58 +0100
commit0208ead70a9412ccd554fcef3e9308f8ca17037b (patch)
tree6f324f0afd493c4790d80671ffd903805c0bbddb
parent5dff2d0822bb299c134a05a64747ce1bb42ad7cd (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
-rwxr-xr-xsw/qa/extras/ooxmlimport/data/tblr-height.docxbin0 -> 10466 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx13
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableManager.cxx10
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableManager.hxx7
-rw-r--r--writerfilter/source/dmapper/TablePropertiesHandler.cxx8
5 files changed, 37 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/tblr-height.docx b/sw/qa/extras/ooxmlimport/data/tblr-height.docx
new file mode 100755
index 000000000000..6a16c81dd5e0
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/tblr-height.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index eec5e708cfa7..f6eb0ef311bf 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -51,6 +51,7 @@
#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/table/TableBorder2.hpp>
+#include <com/sun/star/text/SizeType.hpp>
#include <vcl/svapp.hxx>
@@ -115,6 +116,7 @@ public:
void testN793998();
void testGroupshapeLine();
void testN779642();
+ void testTbLrHeight();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -182,6 +184,7 @@ void Test::run()
{"n793998.docx", &Test::testN793998},
{"groupshape-line.docx", &Test::testGroupshapeLine},
{"n779642.docx", &Test::testN779642},
+ {"tblr-height.docx", &Test::testTbLrHeight},
};
header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1183,6 +1186,16 @@ void Test::testN779642()
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong vertical orientation relation", nValue, text::RelOrientation::PAGE_PRINT_AREA);
}
+void Test::testTbLrHeight()
+{
+ uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
+ uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
+ // btLr text direction was imported as MIN, it should be FIX to avoid incorrectly large height in case of too much content.
+ CPPUNIT_ASSERT_EQUAL(text::SizeType::FIX, getProperty<sal_Int16>(xTableRows->getByIndex(0), "SizeType"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
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);
}