[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Mar 13 05:55:17 PDT 2014


 sw/qa/extras/ooxmlimport/data/bnc865381.docx             |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx                 |   12 ++++++++++++
 writerfilter/source/dmapper/DomainMapperTableManager.cxx |   15 +++++++++++----
 writerfilter/source/dmapper/DomainMapperTableManager.hxx |    7 +++++++
 writerfilter/source/dmapper/TablePropertiesHandler.cxx   |   12 ++++++++----
 5 files changed, 38 insertions(+), 8 deletions(-)

New commits:
commit e6e828a72b97bb639e160d52bbe2a095d03b892b
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Mar 12 11:42:34 2014 +0100

    bnc#865381 DOCX import: table cell btLr text direction fixes
    
    (cherry picked from commit 48b5b7641d0df960558082e8948da8598f801264)
    (cherry picked from commit 970160f78ef6cc7abacfa252daa8451e1f0117bb)
    
    Change-Id: I527955671e1100f05da717bffe002131baaf0291
    Reviewed-on: https://gerrit.libreoffice.org/8553
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/qa/extras/ooxmlimport/data/bnc865381.docx b/sw/qa/extras/ooxmlimport/data/bnc865381.docx
new file mode 100755
index 0000000..bb125cc
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/bnc865381.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 1a2ee5f..ab7404f 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1059,6 +1059,18 @@ DECLARE_OOXMLIMPORT_TEST(testTbLrHeight, "tblr-height.docx")
     CPPUNIT_ASSERT_EQUAL(text::SizeType::FIX, getProperty<sal_Int16>(xTableRows->getByIndex(0), "SizeType"));
 }
 
+DECLARE_OOXMLIMPORT_TEST(testBnc865381, "bnc865381.docx")
+{
+    uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
+    uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
+    uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
+    // Second row has a vertically merged cell, make sure size type is not FIX in that case (otherwise B2 is not readable).
+    CPPUNIT_ASSERT(text::SizeType::FIX != getProperty<sal_Int16>(xTableRows->getByIndex(1), "SizeType"));
+    // Explicit size of 41 mm100 was set, so the vertical text in A2 was not readable.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTableRows->getByIndex(1), "Height"));
+}
+
 DECLARE_OOXMLIMPORT_TEST(testFdo53985, "fdo53985.docx")
 {
     // Unhandled excetion prevented import of the rest of the document.
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index cc7d119..764a065 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -55,6 +55,7 @@ DomainMapperTableManager::DomainMapperTableManager(bool bOOXML) :
     m_aTmpTableProperties(),
     m_bPushCurrentWidth(false),
     m_bRowSizeTypeInserted(false),
+    m_bHasBtlrCell(false),
     m_bTableSizeTypeInserted(false),
     m_nLayoutType(0),
     m_nMaxFixedWidth(0),
@@ -340,10 +341,15 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
                         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, uno::makeAny(text::SizeType::FIX));
-                        m_bRowSizeTypeInserted = true;
-                        insertRowProps(pRowPropMap);
+                        if (!getCellProps() || getCellProps()->find(PROP_VERTICAL_MERGE) == getCellProps()->end())
+                        {
+                            // Though in case there will be a vertical merge, don't do this, it hides text that is supposed to be visible.
+                            TablePropertyMapPtr pRowPropMap( new TablePropertyMap );
+                            pRowPropMap->Insert(PROP_SIZE_TYPE, uno::makeAny(text::SizeType::FIX));
+                            m_bRowSizeTypeInserted = true;
+                            insertRowProps(pRowPropMap);
+                        }
+                        m_bHasBtlrCell = true;
                         }
                         break;
                     case 4: // lrTbV
@@ -727,6 +733,7 @@ void DomainMapperTableManager::endOfRowAction()
 
     m_nGridBefore = m_nGridAfter = 0;
     m_bRowSizeTypeInserted = false;
+    m_bHasBtlrCell = false;
     m_bTableSizeTypeInserted = false;
 
 #ifdef DEBUG_DOMAINMAPPER
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.hxx b/writerfilter/source/dmapper/DomainMapperTableManager.hxx
index f36ac5d2..e9e9779 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.hxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.hxx
@@ -58,6 +58,8 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t
     ::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;
+    /// At least one cell in the current row has the btLr text direction.
+    bool m_bHasBtlrCell;
     /// Remember if table width was already set, when we lack a w:tblW, it should be set manually at the end.
     bool m_bTableSizeTypeInserted;
     /// Table layout algorithm, IOW if we should consider fixed column width or not.
@@ -130,6 +132,11 @@ public:
         return m_bRowSizeTypeInserted;
     }
 
+    bool HasBtlrCell() const
+    {
+        return m_bHasBtlrCell;
+    }
+
     bool IsTableSizeTypeInserted() const
     {
         return m_bTableSizeTypeInserted;
diff --git a/writerfilter/source/dmapper/TablePropertiesHandler.cxx b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
index 7a6eab6..0595a85 100644
--- a/writerfilter/source/dmapper/TablePropertiesHandler.cxx
+++ b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
@@ -95,12 +95,16 @@ namespace dmapper {
                     pProperties->resolve(*pMeasureHandler);
                     TablePropertyMapPtr pPropMap( new TablePropertyMap );
 
-                    // 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, uno::makeAny( pMeasureHandler->GetRowHeightSizeType() ), false);
+                    // In case any of the cells has the btLr cell direction, then an explicit minimal size will just hide the whole row, don't do that.
+                    if (pMeasureHandler->GetRowHeightSizeType() != text::SizeType::MIN || !pManager->HasBtlrCell())
+                    {
+                        // In case a cell already wanted fixed size, we should not overwrite it here.
+                        if (!pManager || !pManager->IsRowSizeTypeInserted())
+                            pPropMap->Insert( PROP_SIZE_TYPE, uno::makeAny( pMeasureHandler->GetRowHeightSizeType() ), false);
 
-                    pPropMap->Insert( PROP_HEIGHT, uno::makeAny(pMeasureHandler->getMeasureValue() ));
+                        pPropMap->Insert( PROP_HEIGHT, uno::makeAny(pMeasureHandler->getMeasureValue() ));
+                    }
                     insertRowProps(pPropMap);
                 }
             }


More information about the Libreoffice-commits mailing list