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

Mike Kaganski mike.kaganski at collabora.com
Wed Dec 9 05:12:13 PST 2015


 sw/qa/extras/ooxmlimport/data/tdf95755.docx              |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx                 |   15 ++++++++
 writerfilter/source/dmapper/DomainMapperTableManager.cxx |   26 ++++++---------
 3 files changed, 27 insertions(+), 14 deletions(-)

New commits:
commit 769dc61fcaea382518f014c24dffb702b7a50fc6
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Thu Nov 19 20:48:14 2015 +1000

    tdf#95755: Don't discard table properties in endOfRowAction()
    
    In the beginning of endOfRowAction(), the current value of
    m_aTmpTableProperties.back( ) is stored in a temporary variable.
    Then, the width of table may be put into m_aTmpTableProperties.back( ).
    In the end, this temp variable is assigned to TableManager::mState.mTableProps
    and the m_aTmpTableProperties.back( ) is reset.
    
    In the middle, the m_aTmpTableProperties.back( ) may be replaced in
    endLevel()/startLevel() sequence (if new table is started). In that case,
    the width calculations go to a different object than stored in temp var.
    Consequently, that value will be discarded and replaced with initial
    stored in temp var. Fixed that by directly operating with temp var
    instead of m_aTmpTableProperties.back( ).
    
    Also, the value of m_nCell was not kept over endLevel()/startLevel() sequence
    and that prevented from calculating width. Fixed that.
    
    Also, removed leftovers from commit cbd0fbc287051f918e4adb32b3e9b58dfbf8059d.
    
    Change-Id: If85dbb715e7c60f60043f9d60d6a3c3d02277add
    Reviewed-on: https://gerrit.libreoffice.org/20052
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/ooxmlimport/data/tdf95755.docx b/sw/qa/extras/ooxmlimport/data/tdf95755.docx
new file mode 100644
index 0000000..194c431
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf95755.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index e19d1ba..f5cc1f6 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -2933,6 +2933,21 @@ DECLARE_OOXMLIMPORT_TEST(testTdf78902, "tdf78902.docx")
     CPPUNIT_ASSERT_EQUAL(2, getPages());
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf95755, "tdf95755.docx")
+{
+    /*
+    * The problem was that the width of a second table with single cell was discarded
+    * and resulted in too wide table
+    */
+    uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xTableProperties(xTables->getByIndex(0), uno::UNO_QUERY);
+    uno::Any aValue = xTableProperties->getPropertyValue("Width");
+    sal_Int32 nWidth;
+    aValue >>= nWidth;
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(10659), nWidth);
+}
+
 DECLARE_OOXMLIMPORT_TEST(testTdf95775, "tdf95775.docx")
 {
     // This must not fail in layout
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index 6419939..61988b6 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -177,9 +177,8 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
                             (See 17.18.87 of the ISO/IEC 29500-1:2011.)
                             */
                             bool bFixed = true;
-                            sal_Int32 nRowFixedWidth = 0;
                             IntVectorPtr pCellWidths = getCurrentCellWidths();
-                            // Step 1. Check whether all cells have fixed widths in the given row of table.
+                            // Check whether all cells have fixed widths in the given row of table.
                             for (std::vector<sal_Int32>::const_iterator aValIter = pCellWidths->begin(); aValIter != pCellWidths->end(); ++aValIter)
                             {
                                 if (*aValIter == -1)
@@ -187,14 +186,11 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
                                     bFixed = false;
                                     break;
                                 }
-                                // Sum the width of cells to find the total width of given row
-                                nRowFixedWidth += (*aValIter);
                             }
 
-                            // Check whether the total width of given row is compared with the maximum value of rows (m_nMaxFixedWidth).
                             if (!bFixed)
                             {
-                                // Set the width type of table with 'Auto' and set the width value to 100(%)
+                                // Set the width type of table with 'Auto' and set the width value to 0 (as per grid values)
                                 pPropMap->setValue( TablePropertyMap::TABLE_WIDTH_TYPE, text::SizeType::VARIABLE );
                                 pPropMap->setValue( TablePropertyMap::TABLE_WIDTH, 0 );
                             }
@@ -523,7 +519,7 @@ void DomainMapperTableManager::endOfRowAction()
     // into two tables if those are different. We surely don't want to do anything
     // if we don't have any row yet.
     TablePositionHandlerPtr pTmpPosition = m_aTmpPosition.back();
-    TablePropertyMapPtr pTmpTableProperties = m_aTmpTableProperties.back( );
+    TablePropertyMapPtr pTablePropMap = m_aTmpTableProperties.back( );
     TablePositionHandlerPtr pCurrentPosition = m_aTablePositions.back();
     bool bSamePosition = ( pTmpPosition == pCurrentPosition ) ||
                          ( pTmpPosition && pCurrentPosition && *pTmpPosition == *pCurrentPosition );
@@ -533,6 +529,7 @@ void DomainMapperTableManager::endOfRowAction()
         IntVectorPtr pTmpTableGrid = m_aTableGrid.back();
         IntVectorPtr pTmpGridSpans = m_aGridSpans.back();
         IntVectorPtr pTmpCellWidths = m_aCellWidths.back();
+        sal_uInt32 nTmpCell = m_nCell.back();
 
         // endLevel and startLevel are taking care of the non finished row
         // to carry it over to the next table
@@ -544,9 +541,11 @@ void DomainMapperTableManager::endOfRowAction()
         m_aTableGrid.pop_back();
         m_aGridSpans.pop_back();
         m_aCellWidths.pop_back();
+        m_nCell.pop_back();
         m_aTableGrid.push_back(pTmpTableGrid);
         m_aGridSpans.push_back(pTmpGridSpans);
         m_aCellWidths.push_back(pTmpCellWidths);
+        m_nCell.push_back(nTmpCell);
     }
 
     // Push the tmp position now that we compared it
@@ -633,21 +632,20 @@ void DomainMapperTableManager::endOfRowAction()
          * If table width property set earlier is smaller than the current table width,
          * then replace the TABLE_WIDTH property, set earlier.
          */
-        TablePropertyMapPtr propMap = m_aTmpTableProperties.back();
         sal_Int32 nTableWidth(0);
         sal_Int32 nTableWidthType(text::SizeType::VARIABLE);
-        propMap->getValue( TablePropertyMap::TABLE_WIDTH, nTableWidth );
-        propMap->getValue( TablePropertyMap::TABLE_WIDTH_TYPE, nTableWidthType );
+        pTablePropMap->getValue(TablePropertyMap::TABLE_WIDTH, nTableWidth);
+        pTablePropMap->getValue(TablePropertyMap::TABLE_WIDTH_TYPE, nTableWidthType);
         if ((nTableWidthType == text::SizeType::FIX) && (nTableWidth < m_nTableWidth))
         {
-            propMap->setValue( TablePropertyMap::TABLE_WIDTH, m_nTableWidth );
+            pTablePropMap->setValue(TablePropertyMap::TABLE_WIDTH, m_nTableWidth);
         }
         if (nTableWidthType == text::SizeType::VARIABLE )
         {
             if(nTableWidth > 100 || nTableWidth <= 0)
             {
-                propMap->setValue( TablePropertyMap::TABLE_WIDTH, m_nTableWidth);
-                propMap->setValue( TablePropertyMap::TABLE_WIDTH_TYPE, text::SizeType::FIX);
+                pTablePropMap->setValue(TablePropertyMap::TABLE_WIDTH, m_nTableWidth);
+                pTablePropMap->setValue(TablePropertyMap::TABLE_WIDTH_TYPE, text::SizeType::FIX);
             }
         }
         uno::Sequence< text::TableColumnSeparator > aSeparators( m_nCell.back( ) - 1 );
@@ -734,7 +732,7 @@ void DomainMapperTableManager::endOfRowAction()
     }
 
     // Now that potentially opened table is closed, save the table properties
-    TableManager::insertTableProps( pTmpTableProperties );
+    TableManager::insertTableProps(pTablePropMap);
 
     m_aTmpTableProperties.pop_back();
     TablePropertyMapPtr pEmptyTableProps( new TablePropertyMap() );


More information about the Libreoffice-commits mailing list