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

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 9 10:08:12 UTC 2020


 sw/qa/extras/ooxmlexport/data/tdf133455.docx             |binary
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx                |   17 ++++++
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx |   39 +--------------
 writerfilter/source/dmapper/TableManager.cxx             |   16 ++++++
 writerfilter/source/dmapper/TableManager.hxx             |   33 ++++++++++++
 writerfilter/source/dmapper/TablePropertiesHandler.cxx   |    4 -
 writerfilter/source/dmapper/TablePropertiesHandler.hxx   |   11 ++++
 7 files changed, 81 insertions(+), 39 deletions(-)

New commits:
commit c043b589c4b185dc4f78e52ef16e2600c121decb
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Thu Jun 4 13:32:53 2020 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Tue Jun 9 12:07:41 2020 +0200

    tdf#133455 DOCX import: fix table border regression
    
    caused by commit 8ffc1299ebf83450e67cf2a89304859e2558cd27
    (tdf#95033 DOCX import: apply tblPrEx table border).
    
    Change-Id: Ief4da3bce3282b5dab1ce4dabb4e075efcc1abaf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95504
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit 3593dd550882783b5f776262e928fc058c4dbd9d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95550
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf133455.docx b/sw/qa/extras/ooxmlexport/data/tdf133455.docx
new file mode 100644
index 000000000000..e852976995e6
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf133455.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index 74e98cfb49da..c2aaec5c64a9 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -726,6 +726,23 @@ DECLARE_OOXMLEXPORT_TEST(testTdf95033, "tdf95033.docx")
     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[9]/w:tc[2]/w:tcPr/w:tcBorders/w:bottom[@w:val = 'nil']", 0);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf133455, "tdf133455.docx")
+{
+    xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
+    if (!pXmlDocument)
+        return;
+
+    //Not disabled table cell borders
+    assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:top[@w:val = 'nil']", 0);
+    assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:start[@w:val = 'nil']", 0);
+    assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:end[@w:val = 'nil']", 0);
+    assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:tcBorders/w:start[@w:val = 'nil']", 0);
+    assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:tcBorders/w:end[@w:val = 'nil']", 0);
+    assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[11]/w:tc[1]/w:tcPr/w:tcBorders/w:start[@w:val = 'nil']", 0);
+    assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[11]/w:tc[1]/w:tcPr/w:tcBorders/w:end[@w:val = 'nil']", 0);
+    assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[11]/w:tc[1]/w:tcPr/w:tcBorders/w:bottom[@w:val = 'nil']", 0);
+}
+
 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf128646, "tdf128646.docx")
 {
     // The problem was that not hidden shapes anchored to empty hidden paragraphs were imported as hidden.
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index dd5a14b732eb..c32b33af10c4 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -762,11 +762,6 @@ CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(Tabl
         pCellProperties[nRow].realloc( aRowOfCellsIterator->size() );
         beans::PropertyValues* pSingleCellProperties = pCellProperties[nRow].getArray();
 
-        static const PropertyIds pBorders[] =
-        {
-            PROP_TOP_BORDER, PROP_LEFT_BORDER, PROP_BOTTOM_BORDER, PROP_RIGHT_BORDER
-        };
-
         while( aCellIterator != aCellIteratorEnd )
         {
             PropertyMapPtr pAllCellProps( new PropertyMap );
@@ -823,33 +818,15 @@ CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(Tabl
                     PropertyMapPtr pStyleProps = rInfo.pTableStyle->GetProperties( nCnfStyleMask );
 
                     // Check if we need to clean up some empty border definitions to match what Word does.
-                    // Apply also possible tblPrEx borders on cells
+                    static const PropertyIds pBorders[] =
+                    {
+                        PROP_TOP_BORDER, PROP_LEFT_BORDER, PROP_BOTTOM_BORDER, PROP_RIGHT_BORDER
+                    };
                     for (const PropertyIds& rBorder : pBorders)
                     {
                         std::optional<PropertyMap::Property> oStyleCellBorder = pStyleProps->getProperty(rBorder);
                         std::optional<PropertyMap::Property> oRowCellBorder;
-                        // we can have table border exception in row properties
-                        if (*aRowIter && (*aRowIter)->isSet(rBorder))
-                            oRowCellBorder = (*aRowIter)->getProperty(rBorder);
                         std::optional<PropertyMap::Property> oDirectCellBorder = (*aCellIterator)->getProperty(rBorder);
-                        if (oRowCellBorder && oDirectCellBorder)
-                        {
-                            table::BorderLine2 aRowCellBorder = oRowCellBorder->second.get<table::BorderLine2>();
-                            table::BorderLine2 aDirectCellBorder = oDirectCellBorder->second.get<table::BorderLine2>();
-                            if (aRowCellBorder.LineStyle != table::BorderLineStyle::NONE && aDirectCellBorder.LineStyle == table::BorderLineStyle::NONE)
-                                oDirectCellBorder = std::optional<PropertyMap::Property>();
-                        }
-                        if (oRowCellBorder && !oDirectCellBorder)
-                        {
-                            table::BorderLine2 aRowCellBorder = oRowCellBorder->second.get<table::BorderLine2>();
-                            if ( (rBorder == PROP_LEFT_BORDER && nCnfStyleMask&CNF_FIRST_COLUMN)
-                                    || (rBorder == PROP_RIGHT_BORDER && bIsEndCol)
-                                    || (rBorder != PROP_LEFT_BORDER && rBorder != PROP_RIGHT_BORDER) )
-                            {
-                                (*aCellIterator)->Insert(rBorder, uno::makeAny(aRowCellBorder));
-                                oDirectCellBorder = (*aCellIterator)->getProperty(rBorder);
-                            }
-                        }
                         if (oStyleCellBorder && oDirectCellBorder)
                         {
                             // We have a cell border from the table style and as direct formatting as well.
@@ -972,14 +949,6 @@ CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(Tabl
             ++nCell;
             ++aCellIterator;
         }
-
-        // remove tblPrEx table border properties stored in row properties temporarily
-        for (const PropertyIds& rBorder : pBorders)
-        {
-            if (*aRowIter && (*aRowIter)->isSet(rBorder))
-                (*aRowIter)->Erase(rBorder);
-        }
-
         ++nRow;
         ++aRowOfCellsIterator;
         ++aRowIter;
diff --git a/writerfilter/source/dmapper/TableManager.cxx b/writerfilter/source/dmapper/TableManager.cxx
index 7ce34d988996..50e948b00eba 100644
--- a/writerfilter/source/dmapper/TableManager.cxx
+++ b/writerfilter/source/dmapper/TableManager.cxx
@@ -101,6 +101,22 @@ void TableManager::cellProps(const TablePropertyMapPtr& pProps)
 #endif
 }
 
+void TableManager::tableExceptionProps(const TablePropertyMapPtr& pProps)
+{
+#ifdef DBG_UTIL
+    TagLogger::getInstance().startElement("tablemanager.tableExceptionProps");
+#endif
+
+    if (getTableExceptionProps())
+        getTableExceptionProps()->InsertProps(pProps.get());
+    else
+        mState.setTableExceptionProps(pProps);
+
+#ifdef DBG_UTIL
+    TagLogger::getInstance().endElement();
+#endif
+}
+
 void TableManager::utext(const sal_uInt8* data, std::size_t len)
 {
     // optimization: cell/row end characters are the last characters in a run
diff --git a/writerfilter/source/dmapper/TableManager.hxx b/writerfilter/source/dmapper/TableManager.hxx
index d5814df6d8e7..5e18becab606 100644
--- a/writerfilter/source/dmapper/TableManager.hxx
+++ b/writerfilter/source/dmapper/TableManager.hxx
@@ -57,6 +57,11 @@ class TableManager : public virtual SvRefBase
          */
         TablePropertyMapPtr mpRowProps;
 
+        /**
+         table exception properties of the current row
+         */
+        TablePropertyMapPtr mpTableExceptionProps;
+
         /**
          properties of the current table
          */
@@ -109,7 +114,7 @@ class TableManager : public virtual SvRefBase
 
         void resetCellProps()
         {
-            mpCellProps.clear();
+            mpCellProps = getTableExceptionProps();
         }
 
         void setCellProps(TablePropertyMapPtr pProps)
@@ -124,6 +129,10 @@ class TableManager : public virtual SvRefBase
 
         void resetRowProps()
         {
+            // reset also table exception and
+            // its copy set by the previous resetCellProps()
+            mpTableExceptionProps.clear();
+            resetCellProps();
             mpRowProps.clear();
         }
 
@@ -137,6 +146,16 @@ class TableManager : public virtual SvRefBase
             return mpRowProps;
         }
 
+        void setTableExceptionProps(TablePropertyMapPtr pProps)
+        {
+            mpTableExceptionProps = pProps;
+        }
+
+        const TablePropertyMapPtr& getTableExceptionProps() const
+        {
+            return mpTableExceptionProps;
+        }
+
         void resetTableProps()
         {
             if (mTableProps.size() > 0)
@@ -209,6 +228,11 @@ public:
         return mState.getRowProps();
     }
 
+    TablePropertyMapPtr const & getTableExceptionProps() const
+    {
+        return mState.getTableExceptionProps();
+    }
+
 protected:
     void setInCell(bool bInCell)
     {
@@ -454,6 +478,13 @@ public:
      */
     virtual void insertRowProps(const TablePropertyMapPtr& pProps);
 
+    /**
+       Handle table exception properties of the current row.
+
+       @param pProps   the properties
+     */
+    virtual void tableExceptionProps(const TablePropertyMapPtr& pProps);
+
     /**
        Handle properties of the current table.
 
diff --git a/writerfilter/source/dmapper/TablePropertiesHandler.cxx b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
index abce3a1e6b14..8b5563669d26 100644
--- a/writerfilter/source/dmapper/TablePropertiesHandler.cxx
+++ b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
@@ -224,9 +224,7 @@ namespace writerfilter::dmapper {
 #ifdef DBG_UTIL
                     pTablePropMap->dumpXml();
 #endif
-                    // store row-level table border exceptions in row properties temporarily
-                    // and apply them on cells later
-                    insertRowProps( pTablePropMap );
+                    tableExceptionProps( pTablePropMap );
                 }
             }
             break;
diff --git a/writerfilter/source/dmapper/TablePropertiesHandler.hxx b/writerfilter/source/dmapper/TablePropertiesHandler.hxx
index 16c28da8c9d1..d35ad7f114f0 100644
--- a/writerfilter/source/dmapper/TablePropertiesHandler.hxx
+++ b/writerfilter/source/dmapper/TablePropertiesHandler.hxx
@@ -74,6 +74,17 @@ private:
             m_pCurrentProperties->InsertProps(pProps.get());
     };
 
+    void tableExceptionProps( TablePropertyMapPtr pProps )
+    {
+        if ( m_pTableManager )
+        {
+            m_pTableManager->tableExceptionProps( pProps );
+            cellProps( pProps );
+        }
+        else
+            m_pCurrentProperties->InsertProps(pProps.get());
+    };
+
     void insertTableProps( TablePropertyMapPtr pProps )
     {
         if ( m_pTableManager )


More information about the Libreoffice-commits mailing list