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

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Fri Feb 7 16:58:01 UTC 2020


 sw/qa/core/data/ooxml/pass/tdf108272.docx                |binary
 writerfilter/source/dmapper/DomainMapperTableManager.cxx |   10 +++++-----
 writerfilter/source/dmapper/DomainMapperTableManager.hxx |    6 +++---
 writerfilter/source/dmapper/DomainMapper_Impl.cxx        |   11 ++++++++++-
 4 files changed, 18 insertions(+), 9 deletions(-)

New commits:
commit bd704b167a07054335601aa86c636d7db84e982a
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Mon Feb 3 13:54:57 2020 +0100
Commit:     Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Fri Feb 7 17:57:07 2020 +0100

    tdf#108272 DOCX table-only header: fix SAX parser error
    
    Floating tables in table-only headers are imported
    as non-floating ones after a SAX parser error. Now
    we import them as non-floating ones from the beginning
    to avoid of the parser error.
    
    Change-Id: I0a816a7af642f402a25ed53d9766b1e8b82db789
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87874
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit 213d6390a2cc59d174173f4359c161625a9c4bdc)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88097
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>

diff --git a/sw/qa/core/data/ooxml/pass/tdf108272.docx b/sw/qa/core/data/ooxml/pass/tdf108272.docx
new file mode 100644
index 000000000000..8ee707c5ba8f
Binary files /dev/null and b/sw/qa/core/data/ooxml/pass/tdf108272.docx differ
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index f4d025739915..5315e947ceae 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -51,7 +51,7 @@ DomainMapperTableManager::DomainMapperTableManager() :
     m_nGridAfter(0),
     m_nHeaderRepeat(0),
     m_nTableWidth(0),
-    m_bIsInShape(false),
+    m_bIsUnfloatTable(false),
     m_aTmpPosition(),
     m_aTmpTableProperties(),
     m_bPushCurrentWidth(false),
@@ -339,8 +339,8 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
             case NS_ooxml::LN_CT_TblPrBase_tblpPr:
                 {
                     writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
-                    // Ignore <w:tblpPr> in shape text, those tables should be always non-floating ones.
-                    if (!m_bIsInShape && pProperties.get())
+                    // Ignore <w:tblpPr> in shape text or in table-only header, those tables should be always non-floating ones.
+                    if (!m_bIsUnfloatTable && pProperties.get())
                     {
                         TablePositionHandlerPtr pHandler = m_aTmpPosition.back();
                         if ( !pHandler )
@@ -430,9 +430,9 @@ TablePositionHandler* DomainMapperTableManager::getCurrentTableRealPosition()
         return nullptr;
 }
 
-void DomainMapperTableManager::setIsInShape(bool bIsInShape)
+void DomainMapperTableManager::setIsUnfloatTable(bool bIsUnfloatTable)
 {
-    m_bIsInShape = bIsInShape;
+    m_bIsUnfloatTable = bIsUnfloatTable;
 }
 
 void DomainMapperTableManager::startLevel( )
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.hxx b/writerfilter/source/dmapper/DomainMapperTableManager.hxx
index 219986870ef3..d58d5e29095e 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.hxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.hxx
@@ -46,8 +46,8 @@ class DomainMapperTableManager : public TableManager
     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
-    /// Are we in a shape (text append stack is not empty) or in the body document?
-    bool m_bIsInShape;
+    /// Unfloat tables in a shape/table-only header (text append stack is not empty)
+    bool m_bIsUnfloatTable;
     OUString m_sTableStyleName;
     /// Grab-bag of table look attributes for preserving.
     comphelper::SequenceAsHashMap m_aTableLook;
@@ -131,7 +131,7 @@ public:
 
     using TableManager::isInCell;
 
-    void setIsInShape(bool bIsInShape);
+    void setIsUnfloatTable(bool bIsUnfloatTable);
 
 };
 
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index fe6283616c1e..58aa43b82712 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1843,6 +1843,11 @@ void DomainMapper_Impl::appendTextPortion( const OUString& rString, const Proper
 
     if (m_aTextAppendStack.empty())
         return;
+
+    // not a table-only header, don't avoid of floating tables
+    if (m_eInHeaderFooterImport == HeaderFooterImportState::header && !IsInShape() && hasTableManager() && !getTableManager().isInCell())
+        getTableManager().setIsUnfloatTable(false);
+
     // Before placing call to processDeferredCharacterProperties(), TopContextType should be CONTEXT_CHARACTER
     // processDeferredCharacterProperties() invokes only if character inserted
     if( pPropertyMap == m_pTopContext && !deferredCharacterProperties.empty() && (GetTopContextType() == CONTEXT_CHARACTER) )
@@ -2190,6 +2195,10 @@ void DomainMapper_Impl::PushPageHeaderFooter(bool bHeader, SectionPropertyMap::P
     m_eInHeaderFooterImport
         = bHeader ? HeaderFooterImportState::header : HeaderFooterImportState::footer;
 
+    // ignore <w:tblpPr> in table-only header, that table is imported as non-floating one
+    if (bHeader && hasTableManager())
+        getTableManager().setIsUnfloatTable(true);
+
     //get the section context
     PropertyMapPtr pContext = DomainMapper_Impl::GetTopContextOfType(CONTEXT_SECTION);
     //ask for the header/footer name of the given type
@@ -2743,7 +2752,7 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape
                         uno::makeAny( true ) );
         }
         m_bParaChanged = true;
-        getTableManager().setIsInShape(true);
+        getTableManager().setIsUnfloatTable(true);
     }
     catch ( const uno::Exception& )
     {


More information about the Libreoffice-commits mailing list