sw/qa/extras/ooxmlexport/data/tdf144362.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx   |   26 ++++++++++++++++++++++++++
 sw/source/core/doc/docbm.cxx                |    2 +-
 sw/source/filter/ww8/wrtw8sty.cxx           |    8 +++-----
 sw/source/filter/ww8/wrtww8.hxx             |    2 +-
 sw/source/filter/ww8/ww8atr.cxx             |   25 +++++++++++++++++++++++++
 6 files changed, 56 insertions(+), 7 deletions(-)

New commits:
commit bc5c5ded52f272d5900b2b313121435a488326d7
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Wed May 10 10:49:56 2023 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Thu May 18 02:02:09 2023 +0200

    tdf#154956 sw: delete bookmarks at end: fix crashtesting
    
    This fixes LO 7.6 commit 21b1dd42e9a817ae9b68e9e13ea57ce2491940c6
    
    wget https://bugs.documentfoundation.org/attachment.cgi?id=124859 \
        -O ~/tdf99692-1.odt
    ./instdir/program/soffice --headless --convert-to odt ~/tdf99692-1.odt
    
    sw/source/core/crsr/pam.cxx:268: void SwPosition::SetContent(sal_Int32):
    Assertion `nNode.GetNode().GetContentNode()
        && "only valid to call this if we point to an SwContentNode"' failed.
    
    Change-Id: Ic8280bf56f1e7f339fdff3e9591470bc74aa0d5b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151639
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151892
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 00102a5e8458..cde421f74188 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -2050,7 +2050,7 @@ void DelBookmarks(
         if( lcl_Greater( *pREnd, rStt, oStartContentIdx ) && lcl_Lower( 
*pREnd, rEnd, oEndContentIdx ))
         {
             pREnd->Assign( rStt );
-            if( oStartContentIdx )
+            if (oStartContentIdx && rStt.IsContentNode())
                 pREnd->SetContent( *oStartContentIdx );
             else
             {
commit 7a35d80cc3058c37253f39706ccdd6ee5d608d5b
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Sat May 13 22:17:07 2023 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Thu May 18 02:01:57 2023 +0200

    tdf#144362 doc/x export: different columns mean new section
    
    The situation causing this may have become more likely in 7.4.0.
    I think that tdf#149313 might have caused a regression in the
    unit test that I found that exhibited the problem,
    so I am adding another one.
    
    make CppunitTest_sw_ooxmlexport9 
CPPUNIT_TEST_NAME=testTdf97648_relativeWidth
    make CppunitTest_sw_ooxmlexport9 CPPUNIT_TEST_NAME=testTdf144362
    
    Change-Id: I8e668ac7bfb01a8704634a3e16243be7298bd1ee
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151731
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151891
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf144362.odt 
b/sw/qa/extras/ooxmlexport/data/tdf144362.odt
new file mode 100644
index 000000000000..9c161dbdeb7f
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf144362.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 436d3d547d62..956ae7119a97 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -529,6 +529,32 @@ DECLARE_OOXMLEXPORT_TEST(testTdf97648_relativeWidth, 
"tdf97648_relativeWidth.doc
         CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::RIGHT, 
getProperty<sal_Int16>(getShape(3), "HoriOrient"));
         CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::LEFT, 
getProperty<sal_Int16>(getShape(4), "HoriOrient"));
     }
+
+    uno::Reference<text::XTextSectionsSupplier> 
xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> 
xSections(xTextSectionsSupplier->getTextSections(),
+                                                      uno::UNO_QUERY);
+
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xSections->getCount());
+
+    uno::Reference<beans::XPropertySet> xTextSection(xSections->getByIndex(2), 
uno::UNO_QUERY);
+    uno::Reference<text::XTextColumns> xTextColumns
+        = getProperty<uno::Reference<text::XTextColumns>>(xTextSection, 
"TextColumns");
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf144362, "tdf144362.odt")
+{
+    uno::Reference<text::XTextSectionsSupplier> 
xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> 
xSections(xTextSectionsSupplier->getTextSections(),
+                                                      uno::UNO_QUERY);
+
+    // This is difference OK: tdf#107837 extra section added on export to 
preserve balanced columns.
+    CPPUNIT_ASSERT_GREATEREQUAL(sal_Int32(2), xSections->getCount());
+
+    uno::Reference<beans::XPropertySet> xTextSection(xSections->getByIndex(1), 
uno::UNO_QUERY);
+    uno::Reference<text::XTextColumns> xTextColumns
+        = getProperty<uno::Reference<text::XTextColumns>>(xTextSection, 
"TextColumns");
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
 }
 
 
DECLARE_OOXMLEXPORT_TEST(testTdf104061_tableSectionColumns,"tdf104061_tableSectionColumns.docx")
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx 
b/sw/source/filter/ww8/wrtw8sty.cxx
index 96ff0c783a91..ab72b5f1cc15 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -1117,10 +1117,10 @@ sal_uInt16 MSWordSections::CurrentNumberOfColumns( 
const SwDoc &rDoc ) const
     if ( m_aSects.empty() )
         return 1;
 
-    return NumberOfColumns( rDoc, m_aSects.back() );
+    return GetFormatCol(rDoc, m_aSects.back()).GetNumCols();
 }
 
-sal_uInt16 MSWordSections::NumberOfColumns( const SwDoc &rDoc, const 
WW8_SepInfo& rInfo )
+const SwFormatCol& MSWordSections::GetFormatCol(const SwDoc &rDoc, const 
WW8_SepInfo& rInfo)
 {
     const SwPageDesc* pPd = rInfo.pPageDesc;
     if ( !pPd )
@@ -1134,9 +1134,7 @@ sal_uInt16 MSWordSections::NumberOfColumns( const SwDoc 
&rDoc, const WW8_SepInfo
     if ( rInfo.pSectionFormat && 
reinterpret_cast<SwSectionFormat*>(sal_IntPtr(-1)) != rInfo.pSectionFormat )
         aSet.Put( rInfo.pSectionFormat->GetFormatAttr( RES_COL ) );
 
-    const SwFormatCol& rCol = aSet.Get( RES_COL );
-    const SwColumns& rColumns = rCol.GetColumns();
-    return rColumns.size();
+    return aSet.Get(RES_COL);
 }
 
 const WW8_SepInfo* MSWordSections::CurrentSectionInfo()
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index cf5d0bfa104b..16ffa22fab64 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -223,7 +223,7 @@ public:
     sal_uInt16 CurrentNumberOfColumns( const SwDoc &rDoc ) const;
 
     /// Number of columns of the provided WW8_SepInfo.
-    static sal_uInt16 NumberOfColumns( const SwDoc &rDoc, const WW8_SepInfo& 
rInfo );
+    static const SwFormatCol& GetFormatCol(const SwDoc &rDoc, const 
WW8_SepInfo& rInfo);
 
     bool DocumentIsProtected() const { return mbDocumentIsProtected; }
 
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index d4307b71d209..fd8214942525 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -595,6 +595,31 @@ void MSWordExportBase::OutputSectionBreaks( const 
SfxItemSet *pSet, const SwNode
                         bNewPageDesc |= SetCurrentPageDescFromNode( rNd );
                     }
                 }
+
+                // If the columns are different in LO's adjacent sections, 
create a new MS section
+                if (!bNewPageDesc && pBreak->GetBreak() == SvxBreak::PageBefore
+                    && Sections().CurrentSectionInfo())
+                {
+                    const SwSectionFormat* pSectionFormat = 
MSWordExportBase::GetSectionFormat(rNd);
+                    if (pSectionFormat)
+                    {
+                        const SwFormatCol& rNewSect = 
pSectionFormat->GetFormatAttr(RES_COL);
+                        const SwFormatCol& rPrevSect
+                            = MSWordSections::GetFormatCol(m_rDoc,
+                                                           
*Sections().CurrentSectionInfo());
+                        if (rNewSect.GetNumCols() != rPrevSect.GetNumCols()
+                            || !rNewSect.IsOrtho() || !rPrevSect.IsOrtho()
+                            || rNewSect.GetLineStyle() != 
rPrevSect.GetLineStyle()
+                            || rNewSect.GetLineWidth() != 
rPrevSect.GetLineWidth()
+                            || rNewSect.GetLineColor() != 
rPrevSect.GetLineColor()
+                            || rNewSect.GetLineHeight() != 
rPrevSect.GetLineHeight()
+                            || rNewSect.GetLineAdj() != rPrevSect.GetLineAdj())
+                        {
+                            bNewPageDesc = true;
+                        }
+                    }
+                }
+
                 if ( !bNewPageDesc )
                     AttrOutput().OutputItem( *pBreak );
             }

Reply via email to