summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-03-31 15:04:25 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-03-31 18:43:21 +0200
commit8b7ff52ac87795881a4d86395885778f1da3d18b (patch)
tree8e0e132e24bad4d90d708274618d6d8b570dd084
parent8da9f85abc508140b90e4f5be587aa05d4f1e5f4 (diff)
tdf#140343 sw page rtl gutter margin: add DOC filter
The import's tokenizer was there since commit 3e13e053749e1bf19179bf83bdf0a18a9488b5e8 (#i2408# Import and export set/ask references fields as set/input, change references to bookmarks to show variable as appropiate, 2002-02-04), but it tried to read 2 bytes, not 1 byte, so it was broken. This did not cause problems in practice till commit b897cc4dfc7111eb8dfd5d8aa8c970f21ab035d6 (consistently track amount of buffers remaining, 2017-04-10) started to check for not reading past the end of the buffer. The export was missing, since we previously tried to handle this at import time, so the doc model didn't have the info anymore. Change-Id: I0d15a16893de96104812b0cba4566c53f92673ae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113415 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
-rw-r--r--sw/qa/extras/ww8export/data/rtl-gutter.docbin0 -> 22528 bytes
-rw-r--r--sw/qa/extras/ww8export/ww8export3.cxx17
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx12
-rw-r--r--sw/source/filter/ww8/ww8attributeoutput.hxx2
-rw-r--r--sw/source/filter/ww8/ww8par.hxx1
-rw-r--r--sw/source/filter/ww8/ww8par6.cxx9
6 files changed, 38 insertions, 3 deletions
diff --git a/sw/qa/extras/ww8export/data/rtl-gutter.doc b/sw/qa/extras/ww8export/data/rtl-gutter.doc
new file mode 100644
index 000000000000..37cbf8707ce6
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/rtl-gutter.doc
Binary files differ
diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx
index b2afbce478de..6364762be9b0 100644
--- a/sw/qa/extras/ww8export/ww8export3.cxx
+++ b/sw/qa/extras/ww8export/ww8export3.cxx
@@ -708,6 +708,23 @@ DECLARE_WW8EXPORT_TEST(testPresetDash, "tdf127166_prstDash_Word97.doc")
}
}
+CPPUNIT_TEST_FIXTURE(Test, testRtlGutter)
+{
+ auto verify = [this]() {
+ uno::Reference<beans::XPropertySet> xStandard(
+ getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(getProperty<bool>(xStandard, "RtlGutter"));
+ };
+
+ // Given a document with RTL gutter, when loading it:
+ load(mpTestDocumentPath, "rtl-gutter.doc");
+ // Then make sure the section's gutter is still RTL:
+ // Without the accompanying fix in place, this test would have failed as the SPRM was missing.
+ verify();
+ reload(mpFilter, "rtl-gutter.doc");
+ verify();
+}
+
DECLARE_WW8EXPORT_TEST(testTdf120394, "tdf120394.doc")
{
CPPUNIT_ASSERT_EQUAL(1, getPages());
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 2103490e9cc7..4e0451e6072e 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -4105,6 +4105,18 @@ void WW8AttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLR )
}
}
+void WW8AttributeOutput::SectionRtlGutter(const SfxBoolItem& rRtlGutter)
+{
+ if (!rRtlGutter.GetValue())
+ {
+ return;
+ }
+
+ // sprmSFRTLGutter
+ m_rWW8Export.InsUInt16(NS_sprm::SFRTLGutter::val);
+ m_rWW8Export.pO->push_back(1);
+}
+
void WW8AttributeOutput::FormatULSpace( const SvxULSpaceItem& rUL )
{
// Flys are still missing ( see RTF )
diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx
index 7bd1dd1d1e00..f9ea183d1e6b 100644
--- a/sw/source/filter/ww8/ww8attributeoutput.hxx
+++ b/sw/source/filter/ww8/ww8attributeoutput.hxx
@@ -434,6 +434,8 @@ protected:
virtual void WriteBookmarkInActParagraph( const OUString& rName, sal_Int32 nFirstRunPos, sal_Int32 nLastRunPos ) override;
+ void SectionRtlGutter( const SfxBoolItem& rRtlGutter) override;
+
/// Reference to the export, where to get the data from
WW8Export &m_rWW8Export;
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index fcfac3503ad1..ec3702a68a39 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -799,6 +799,7 @@ public:
sal_uInt32 nPgLeft;
sal_uInt32 nPgRight;
sal_uInt32 nPgGutter;
+ bool m_bRtlGutter = false;
css::drawing::TextVerticalAdjust mnVerticalAdjustment;
sal_uInt8 mnBorders;
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 453f7f5aa7d3..4753ca2c1114 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -486,8 +486,7 @@ void wwSectionManager::SetLeftRight(wwSection &rSection)
*/
if (rSection.maSep.fRTLGutter)
{
- nWWRi += nWWGu;
- nWWGu = 0;
+ rSection.m_bRtlGutter = true;
}
// Left / Right
@@ -530,6 +529,9 @@ void wwSectionManager::SetPage(SwPageDesc &rInPageDesc, SwFrameFormat &rFormat,
aLR.SetGutterMargin(rSection.nPgGutter);
rFormat.SetFormatAttr(aLR);
+ SfxBoolItem aRtlGutter(RES_RTL_GUTTER, rSection.m_bRtlGutter);
+ rFormat.SetFormatAttr(aRtlGutter);
+
if (!bIgnoreCols)
SetCols(rFormat, rSection, rSection.GetTextAreaWidth());
}
@@ -1096,7 +1098,8 @@ void wwSectionManager::CreateSep(const tools::Long nTextPos)
aNewSection.maSep.dzaGutter = ReadUSprm( pSep, pIds[5], 0);
- aNewSection.maSep.fRTLGutter = static_cast< sal_uInt8 >(eVer >= ww::eWW8 ? ReadUSprm( pSep, NS_sprm::SFRTLGutter::val, 0 ) : 0);
+ aNewSection.maSep.fRTLGutter = static_cast<sal_uInt8>(
+ eVer >= ww::eWW8 ? ReadBSprm(pSep, NS_sprm::SFRTLGutter::val, 0) : 0);
// Page Number Restarts - sprmSFPgnRestart
aNewSection.maSep.fPgnRestart = ReadBSprm(pSep, pIds[6], 0);