[Libreoffice-commits] core.git: sw/qa writerfilter/source

Miklos Vajna vmiklos at suse.cz
Fri Feb 22 08:49:12 PST 2013


 sw/qa/extras/ooxmlimport/data/tblr-height.docx           |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx                 |   13 +++++++++++++
 writerfilter/source/dmapper/DomainMapperTableManager.cxx |   10 ++++++++++
 writerfilter/source/dmapper/DomainMapperTableManager.hxx |    7 +++++++
 writerfilter/source/dmapper/TablePropertiesHandler.cxx   |    8 +++++++-
 5 files changed, 37 insertions(+), 1 deletion(-)

New commits:
commit 0208ead70a9412ccd554fcef3e9308f8ca17037b
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Feb 22 17:08:39 2013 +0100

    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

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 0000000..6a16c81
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tblr-height.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index eec5e70..f6eb0ef 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 d3ddf82..1f9853b 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 d3164ea..6ae6b1c 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 b1d560c..a1621f1 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);
                 }


More information about the Libreoffice-commits mailing list