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

New commits:
commit 0da10420ed6e69384498de7404287e8c936fef14
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Fri Mar 18 10:09:18 2022 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri Mar 18 10:53:45 2022 +0100

    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.
    
    Change-Id: I3bc11a120af09d5c774df992cb17cfc5ee251e1d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131732
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/qa/extras/ww8export/ww8export3.cxx 
b/sw/qa/extras/ww8export/ww8export3.cxx
index e0eb32ee9f1b..261d74938e70 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
 {
@@ -997,29 +998,34 @@ DECLARE_WW8EXPORT_TEST(testTdf79186_noLayoutInCell, 
"tdf79186_noLayoutInCell.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 0cf65abc4553..409b00f196d2 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -4183,7 +4183,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