diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-03-21 10:20:34 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-03-21 11:23:32 +0100 |
commit | 3afe4f66f7266ede9922ce0682db38c9369349b7 (patch) | |
tree | e29c66fb0abe74b2d3ff709dcc494891f79f669b /sw | |
parent | a13faccd7e8c6503e96e9342a8615b4542b0601f (diff) |
sw clearing breaks: add RTF filter
Map between SwLineBreakClear and \lbr<N>.
Change-Id: Ibed94ad74157a08787212a34176590a1dc4d5547
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131886
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/rtfexport/data/clearing-break.rtf | 22 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport4.cxx | 33 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.cxx | 10 |
3 files changed, 64 insertions, 1 deletions
diff --git a/sw/qa/extras/rtfexport/data/clearing-break.rtf b/sw/qa/extras/rtfexport/data/clearing-break.rtf new file mode 100644 index 000000000000..aa99b1677c22 --- /dev/null +++ b/sw/qa/extras/rtfexport/data/clearing-break.rtf @@ -0,0 +1,22 @@ +{\rtf1 +\pard\plain +{\shp +{\*\shpinst\shpleft0\shptop0\shpright1024\shpbottom1024\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr2\shpwrk0\shpfblwtxt0\shpz0 +{\sp +{\sn shapeType} +{\sv 75} +} +{\sp +{\sn pib} +{\sv +{\pict\picscalex100\picscaley100\piccropl0\piccropr0\piccropt0\piccropb0 +\picw1806\pich1806\picwgoal1024\pichgoal1024\pngblip\bliptag26676260 47494638396110001000d5ff00000000ffffffc0c0c0555f00ffffaafcfcfcf6f6f6eaeaeae6e6e6e4e4e4e3e3e3c2c2c2c1c1c1bcbcbcb5b5b5b3b3b3b0b0b0adadada5a5a5a2a2a2a1a1a19f9f9f9494948a8a8a8888888686867b7b7b6c6c6c5c5c5c4e4e4e4b4b4b4747474646463d3d3d3c3c3c2e2e2e2525251b1b1b18181810101009090906060603030300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000021f90401000002002c0000000010001000000684408170482c0a06c8a4728924389f506833b281302a8e6b164b18103024c52111504cca67332102e0042e9a40d9319f8300a343c1200f54e47f7e2a00001e0b0a7d0d728a010d838400261a7c0d94947784252700127e9d159f6c8411140019080ea7a9a85f842122281612b1b3b25d6b1f29291d0fbbbdbc5d5e51c34e4cc64a46c94341003b} +} +} +} +} +foo +\lbr3\line +bar +\par +} diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx b/sw/qa/extras/rtfexport/rtfexport4.cxx index 26426654d54a..058972ef09e0 100644 --- a/sw/qa/extras/rtfexport/rtfexport4.cxx +++ b/sw/qa/extras/rtfexport/rtfexport4.cxx @@ -23,6 +23,7 @@ #include <pam.hxx> #include <fmtanchr.hxx> #include <frameformats.hxx> +#include <formatlinebreak.hxx> using namespace css; @@ -429,6 +430,38 @@ CPPUNIT_TEST_FIXTURE(Test, testGutterTop) CPPUNIT_ASSERT(bGutterAtTop); } +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.rtf"); + // Then make sure that the clear property of the break is not ignored: + verify(); + reload(mpFilter, "clearing-break.rtf"); + // Make sure that that the clear property of the break is not ignored during export: + verify(); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 26542763837e..f22ec5a48c02 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -4395,6 +4395,14 @@ void RtfAttributeOutput::SectionRtlGutter(const SfxBoolItem& rRtlGutter) m_rExport.Strm().WriteCharPtr(LO_STRING_SVTOOLS_RTF_RTLGUTTER); } -void RtfAttributeOutput::TextLineBreak(const SwFormatLineBreak& /*rLineBreak*/) {} +void RtfAttributeOutput::TextLineBreak(const SwFormatLineBreak& rLineBreak) +{ + // Text wrapping break of type: + m_aStyles.append(LO_STRING_SVTOOLS_RTF_LBR); + m_aStyles.append(static_cast<sal_Int32>(rLineBreak.GetEnumValue())); + + // Write the linebreak itself. + RunText("\x0b"); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |