sw/qa/extras/ww8export/ww8export3.cxx |   44 +++++++++++++++++++---------------
 sw/source/filter/ww8/ww8atr.cxx       |   10 ++++++-
 2 files changed, 34 insertions(+), 20 deletions(-)

New commits:
commit e2efa0f42c264ae7e6b90ad83360db425cde7d8c
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Fri Mar 18 10:09:18 2022 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Mar 31 08:24:29 2022 +0200

    sw clearing breaks: add DOC export
    
    Map SwLineBreakClear to sprmCLbcCRJ's LBCOperand.
    
    And most importantly, write the newline character: a clearing break was
    not "downgraded" to a plain line break previously.
    
    (cherry picked from commit 0da10420ed6e69384498de7404287e8c936fef14)
    
    Change-Id: I3bc11a120af09d5c774df992cb17cfc5ee251e1d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132292
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/ww8export/ww8export3.cxx 
b/sw/qa/extras/ww8export/ww8export3.cxx
index 2a558c036e97..a292af9d3da6 100644
--- a/sw/qa/extras/ww8export/ww8export3.cxx
+++ b/sw/qa/extras/ww8export/ww8export3.cxx
@@ -33,6 +33,7 @@
 #include <IDocumentSettingAccess.hxx>
 #include <docsh.hxx>
 #include <unotxdoc.hxx>
+#include <formatlinebreak.hxx>
 
 class Test : public SwModelTestBase
 {
@@ -989,29 +990,34 @@ DECLARE_WW8EXPORT_TEST(testTdf136814, "tdf136814.odt")
 
 CPPUNIT_TEST_FIXTURE(Test, testClearingBreak)
 {
+    auto verify = [this]() {
+        uno::Reference<container::XEnumerationAccess> 
xParagraph(getParagraph(1), uno::UNO_QUERY);
+        uno::Reference<container::XEnumeration> xPortions = 
xParagraph->createEnumeration();
+        xPortions->nextElement();
+        xPortions->nextElement();
+        // Without the accompanying fix in place, this test would have failed 
with:
+        // An uncaught exception of type 
com.sun.star.container.NoSuchElementException
+        // i.e. the first para was just a fly + text portion, the clearing 
break was lost.
+        uno::Reference<beans::XPropertySet> xPortion(xPortions->nextElement(), 
uno::UNO_QUERY);
+        OUString aPortionType;
+        xPortion->getPropertyValue("TextPortionType") >>= aPortionType;
+        CPPUNIT_ASSERT_EQUAL(OUString("LineBreak"), aPortionType);
+        uno::Reference<text::XTextContent> xLineBreak;
+        xPortion->getPropertyValue("LineBreak") >>= xLineBreak;
+        sal_Int16 eClear{};
+        uno::Reference<beans::XPropertySet> xLineBreakProps(xLineBreak, 
uno::UNO_QUERY);
+        xLineBreakProps->getPropertyValue("Clear") >>= eClear;
+        CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(SwLineBreakClear::ALL), 
eClear);
+    };
+
     // Given a document with a clearing break:
     // When loading that file:
     load(mpTestDocumentPath, "clearing-break.doc");
-
     // Then make sure that the clear property of the break is not ignored:
-    uno::Reference<container::XEnumerationAccess> xParagraph(getParagraph(1), 
uno::UNO_QUERY);
-    uno::Reference<container::XEnumeration> xPortions = 
xParagraph->createEnumeration();
-    xPortions->nextElement();
-    xPortions->nextElement();
-    // Without the accompanying fix in place, this test would have failed with:
-    // An uncaught exception of type 
com.sun.star.container.NoSuchElementException
-    // i.e. the first para was just a fly + text portion, the clearing break 
was lost.
-    uno::Reference<beans::XPropertySet> xPortion(xPortions->nextElement(), 
uno::UNO_QUERY);
-    OUString aPortionType;
-    xPortion->getPropertyValue("TextPortionType") >>= aPortionType;
-    CPPUNIT_ASSERT_EQUAL(OUString("LineBreak"), aPortionType);
-    uno::Reference<text::XTextContent> xLineBreak;
-    xPortion->getPropertyValue("LineBreak") >>= xLineBreak;
-    sal_Int16 eClear{};
-    uno::Reference<beans::XPropertySet> xLineBreakProps(xLineBreak, 
uno::UNO_QUERY);
-    xLineBreakProps->getPropertyValue("Clear") >>= eClear;
-    // SwLineBreakClear::ALL
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(3), eClear);
+    verify();
+    reload(mpFilter, "clearing-break.doc");
+    // Make sure that that the clear property of the break is not ignored 
during export:
+    verify();
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index de00c649ba16..a7fccf6d6733 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -4190,7 +4190,15 @@ void WW8AttributeOutput::SectionRtlGutter(const 
SfxBoolItem& rRtlGutter)
     m_rWW8Export.pO->push_back(1);
 }
 
-void WW8AttributeOutput::TextLineBreak(const SwFormatLineBreak& 
/*rLineBreak*/) {}
+void WW8AttributeOutput::TextLineBreak(const SwFormatLineBreak& rLineBreak)
+{
+    // Write the linebreak itself.
+    m_rWW8Export.WriteChar(0x0b);
+
+    // sprmCLbcCRJ
+    m_rWW8Export.InsUInt16(NS_sprm::CLbcCRJ::val);
+    m_rWW8Export.pO->push_back(rLineBreak.GetEnumValue());
+}
 
 void WW8AttributeOutput::FormatULSpace( const SvxULSpaceItem& rUL )
 {

Reply via email to