[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-6-4' - writerfilter/source

Justin Luth (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 31 06:36:18 UTC 2020


 writerfilter/source/dmapper/DomainMapperTableManager.cxx |   26 ++++-----------
 writerfilter/source/dmapper/DomainMapperTableManager.hxx |    2 -
 writerfilter/source/dmapper/TableData.hxx                |   11 +++++-
 writerfilter/source/dmapper/TableManager.cxx             |   11 ++++++
 writerfilter/source/dmapper/TableManager.hxx             |    2 +
 5 files changed, 30 insertions(+), 22 deletions(-)

New commits:
commit c9503a8a7d52db642d9913efd0c03b72fd0876f4
Author:     Justin Luth <justin.luth at collabora.com>
AuthorDate: Mon Jun 29 12:33:07 2020 +0300
Commit:     Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Fri Jul 31 08:35:46 2020 +0200

    tdf#129452 writerfilter: preserve gridBefore longer than currentRow
    
    It is a fairly common thing for table operations to need to
    compare items in the same column (like merged cells for example).
    In order to determine column information, each row's gridBefore
    (and merged cells) need to be known.
    
    So save that information in the row data - and don't just throw
    it away after the current row has been analyzed.  Good grief.
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97432
    Tested-by: Jenkins
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: Justin Luth <justin_luth at sil.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit 2ad32b39af2e00ef253a2ef99e033feef416808f)
    
    Change-Id: Ie305477f0e3468a4a923095d76f520d97fe99ffe
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99831
    Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>

diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index 910020366888..ee897eb502d6 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -47,7 +47,6 @@ DomainMapperTableManager::DomainMapperTableManager() :
     m_nRow(0),
     m_nCell(),
     m_nGridSpan(1),
-    m_aGridBefore(),
     m_nGridAfter(0),
     m_nHeaderRepeat(0),
     m_nTableWidth(0),
@@ -356,7 +355,7 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
                 }
                 break;
             case NS_ooxml::LN_CT_TrPrBase_gridBefore:
-                m_aGridBefore.back( ) = nIntValue;
+                setCurrentGridBefore( nIntValue );
                 break;
             case NS_ooxml::LN_CT_TrPrBase_gridAfter:
                 m_nGridAfter = nIntValue;
@@ -396,11 +395,6 @@ DomainMapperTableManager::IntVectorPtr const & DomainMapperTableManager::getCurr
     return m_aTableGrid.back( );
 }
 
-sal_uInt32 DomainMapperTableManager::getCurrentGridBefore( )
-{
-    return m_aGridBefore.back( );
-}
-
 bool DomainMapperTableManager::hasCurrentSpans() const
 {
     return !m_aGridSpans.empty();
@@ -474,7 +468,6 @@ void DomainMapperTableManager::startLevel( )
     m_aTmpPosition.push_back( pTmpPosition );
     m_aTmpTableProperties.push_back( pTmpProperties );
     m_nCell.push_back( 0 );
-    m_aGridBefore.push_back( 0 );
     m_nTableWidth = 0;
     m_nLayoutType = 0;
     TableParagraphVectorPtr pNewParagraphs( new vector<TableParagraph> );
@@ -508,7 +501,6 @@ void DomainMapperTableManager::endLevel( )
         m_aCellWidths.back()->push_back(*oCurrentWidth);
 
     m_nCell.pop_back( );
-    m_aGridBefore.pop_back( );
     m_nTableWidth = 0;
     m_nLayoutType = 0;
 
@@ -565,7 +557,6 @@ void DomainMapperTableManager::endOfRowAction()
         IntVectorPtr pTmpGridSpans = m_aGridSpans.back();
         IntVectorPtr pTmpCellWidths = m_aCellWidths.back();
         sal_uInt32 nTmpCell = m_nCell.back();
-        sal_uInt32 nTmpGridBefore = m_aGridBefore.back();
         TableParagraphVectorPtr pTableParagraphs = getCurrentParagraphs();
 
         // endLevel and startLevel are taking care of the non finished row
@@ -579,12 +570,10 @@ void DomainMapperTableManager::endOfRowAction()
         m_aGridSpans.pop_back();
         m_aCellWidths.pop_back();
         m_nCell.pop_back();
-        m_aGridBefore.pop_back();
         m_aTableGrid.push_back(pTmpTableGrid);
         m_aGridSpans.push_back(pTmpGridSpans);
         m_aCellWidths.push_back(pTmpCellWidths);
         m_nCell.push_back(nTmpCell);
-        m_aGridBefore.push_back(nTmpGridBefore);
         m_aParagraphsToEndTable.pop( );
         m_aParagraphsToEndTable.push( pTableParagraphs );
     }
@@ -631,15 +620,15 @@ void DomainMapperTableManager::endOfRowAction()
 
     IntVectorPtr pCurrentSpans = getCurrentSpans( );
 
-    if( m_aGridBefore.back() > 0 )
+    if ( getCurrentGridBefore() )
     {
         //fill missing gridBefore elements with '1'
-        pCurrentSpans->insert( pCurrentSpans->begin( ), m_aGridBefore.back(), 1 );
+        pCurrentSpans->insert( pCurrentSpans->begin(), getCurrentGridBefore(), 1 );
     }
-    if( pCurrentSpans->size() < m_aGridBefore.back() + m_nCell.back( ))
+    if ( pCurrentSpans->size() < getCurrentGridBefore() + m_nCell.back() )
     {
         //fill missing elements with '1'
-        pCurrentSpans->insert( pCurrentSpans->end( ), m_aGridBefore.back() + m_nCell.back( ) - pCurrentSpans->size(), 1 );
+        pCurrentSpans->insert( pCurrentSpans->end(), getCurrentGridBefore() + m_nCell.back() - pCurrentSpans->size(), 1 );
     }
 
 #ifdef DBG_UTIL
@@ -697,12 +686,12 @@ void DomainMapperTableManager::endOfRowAction()
                 }
             }
         }
-        uno::Sequence< text::TableColumnSeparator > aSeparators( m_aGridBefore.back() + m_nCell.back( ) - 1 );
+        uno::Sequence< text::TableColumnSeparator > aSeparators( getCurrentGridBefore() + m_nCell.back() - 1 );
         text::TableColumnSeparator* pSeparators = aSeparators.getArray();
         double nLastRelPos = 0.0;
         sal_uInt32 nBorderGridIndex = 0;
 
-        size_t nWidthsBound = m_aGridBefore.back() + m_nCell.back() - 1;
+        size_t nWidthsBound = getCurrentGridBefore() + m_nCell.back() - 1;
         if (nWidthsBound)
         {
             if (nFullWidthRelative == 0)
@@ -823,7 +812,6 @@ void DomainMapperTableManager::endOfRowAction()
 
     ++m_nRow;
     m_nCell.back( ) = 0;
-    m_aGridBefore.back( ) = 0;
     getCurrentGrid()->clear();
     pCurrentSpans->clear();
     pCellWidths->clear();
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.hxx b/writerfilter/source/dmapper/DomainMapperTableManager.hxx
index a3a8487b22d9..85e55e2a0da5 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.hxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.hxx
@@ -42,7 +42,6 @@ class DomainMapperTableManager : public TableManager
     sal_uInt32      m_nRow;
     ::std::vector< sal_uInt32 > m_nCell;
     sal_uInt32      m_nGridSpan;
-    ::std::vector< sal_uInt32 > m_aGridBefore; ///< number of grid columns in the parent table's table grid which must be skipped before the contents of this table row are added to the parent table
     sal_uInt32      m_nGridAfter; ///< number of grid columns in the parent table's table grid which shall be left after the last cell in the table row
     sal_Int32       m_nHeaderRepeat; //counter of repeated headers - if == -1 then the repeating stops
     sal_Int32       m_nTableWidth; //might be set directly or has to be calculated from the column positions
@@ -95,7 +94,6 @@ public:
     bool hasCurrentSpans() const;
     IntVectorPtr const & getCurrentSpans( );
     IntVectorPtr const & getCurrentCellWidths( );
-    sal_uInt32 getCurrentGridBefore( );
     TableParagraphVectorPtr getCurrentParagraphs( );
 
     /// Turn the attributes collected so far in m_aTableLook into a property and clear the container.
diff --git a/writerfilter/source/dmapper/TableData.hxx b/writerfilter/source/dmapper/TableData.hxx
index 6326dbe33704..8b64148c3536 100644
--- a/writerfilter/source/dmapper/TableData.hxx
+++ b/writerfilter/source/dmapper/TableData.hxx
@@ -115,13 +115,19 @@ class RowData final : public virtual SvRefBase
     */
     mutable TablePropertyMapPtr mpProperties;
 
+    sal_uInt32 m_nGridBefore; ///< number of grid columns in the parent table's table grid which must be skipped before the contents of this table row are added to the parent table
+
 public:
     typedef tools::SvRef<RowData> Pointer_t;
 
-    RowData() {}
+    RowData()
+        : m_nGridBefore(0)
+    {
+    }
 
     RowData(const RowData& rRowData)
     : SvRefBase(), mCells(rRowData.mCells), mpProperties(rRowData.mpProperties)
+        , m_nGridBefore(rRowData.m_nGridBefore)
     {
     }
 
@@ -226,6 +232,9 @@ public:
     {
         return mpProperties;
     }
+
+    sal_uInt32 getGridBefore() { return m_nGridBefore; }
+    void setGridBefore(sal_uInt32 nSkipGrids) { m_nGridBefore = nSkipGrids; }
 };
 
 /**
diff --git a/writerfilter/source/dmapper/TableManager.cxx b/writerfilter/source/dmapper/TableManager.cxx
index 854ab1719153..cd3aef3285d0 100644
--- a/writerfilter/source/dmapper/TableManager.cxx
+++ b/writerfilter/source/dmapper/TableManager.cxx
@@ -49,6 +49,16 @@ void TableManager::openCell(const css::uno::Reference<css::text::XTextRange>& rH
 
 bool TableManager::isIgnore() const { return isRowEnd(); }
 
+sal_uInt32 TableManager::getCurrentGridBefore()
+{
+    return mTableDataStack.top()->getCurrentRow()->getGridBefore();
+}
+
+void TableManager::setCurrentGridBefore(sal_uInt32 nSkipGrids)
+{
+    mTableDataStack.top()->getCurrentRow()->setGridBefore(nSkipGrids);
+}
+
 void TableManager::endOfRowAction() {}
 
 void TableManager::endOfCellAction() {}
@@ -364,6 +374,7 @@ void TableManager::startLevel()
                                  mpUnfinishedRow->getCellProperties(i));
             pTableData2->endCell(mpUnfinishedRow->getCellEnd(i));
         }
+        pTableData2->getCurrentRow()->setGridBefore(mpUnfinishedRow->getGridBefore());
         mpUnfinishedRow.clear();
     }
 
diff --git a/writerfilter/source/dmapper/TableManager.hxx b/writerfilter/source/dmapper/TableManager.hxx
index 47947ee724ee..fe2bf58f8ea8 100644
--- a/writerfilter/source/dmapper/TableManager.hxx
+++ b/writerfilter/source/dmapper/TableManager.hxx
@@ -467,6 +467,8 @@ public:
      */
     bool isIgnore() const;
 
+    sal_uInt32 getCurrentGridBefore();
+    void setCurrentGridBefore( sal_uInt32 nSkipGrids );
 
     void setTableStartsAtCellStart(bool bTableStartsAtCellStart);
     void setCellLastParaAfterAutospacing(bool bIsAfterAutospacing);


More information about the Libreoffice-commits mailing list