summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-03-31 09:54:25 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-03-31 11:02:28 +0200
commit3db477fd0e6cfc4ff77b3c911ca4ab14fd980932 (patch)
tree88fb7cf427016cfd3ec47e750ec234dad73541ec
parentc088d26578d1be352efa49bd164a8217627648de (diff)
tdf#140343 sw page rtl gutter margin: add DOCX filter
Map to <w:rtlGutter> inside <w:sectPr>. Change-Id: Iaa1d9da8c1585ec31c7cbe539f49643eb972c327 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113398 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
-rw-r--r--sw/qa/extras/ooxmlexport/data/rtl-gutter.docxbin0 -> 8843 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport16.cxx18
-rw-r--r--sw/source/filter/ww8/attributeoutputbase.hxx3
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx10
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx2
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx3
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx7
-rw-r--r--writerfilter/source/dmapper/PropertyIds.cxx3
-rw-r--r--writerfilter/source/dmapper/PropertyIds.hxx1
9 files changed, 47 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/rtl-gutter.docx b/sw/qa/extras/ooxmlexport/data/rtl-gutter.docx
new file mode 100644
index 000000000000..d6b28e5cbce2
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/rtl-gutter.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index bda5911c1b16..afd0b94e5d0b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -197,6 +197,24 @@ CPPUNIT_TEST_FIXTURE(Test, testEffectExtentLineWidth)
verify();
}
+CPPUNIT_TEST_FIXTURE(Test, testRtlGutter)
+{
+ // Given a document with RTL gutter:
+ load(mpTestDocumentPath, "rtl-gutter.docx");
+ uno::Reference<beans::XPropertySet> xStandard(getStyles("PageStyles")->getByName("Standard"),
+ uno::UNO_QUERY);
+ CPPUNIT_ASSERT(getProperty<bool>(xStandard, "RtlGutter"));
+
+ // When saving back to DOCX:
+ reload(mpFilter, "rtl-gutter.docx");
+
+ // Then make sure the section's gutter is still RTL:
+ xmlDocUniquePtr pXmlDoc = parseExport();
+ // Without the accompanying fix in place, this test would have failed as the XML element was
+ // missing.
+ assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:rtlGutter", 1);
+}
+
DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf140572_docDefault_superscript, "tdf140572_docDefault_superscript.docx")
{
// A round-trip was crashing.
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx
index cea47b8e3c60..d85d58237d60 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -640,6 +640,9 @@ protected:
ww8::GridColsPtr GetGridCols( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner );
ww8::WidthsPtr GetColumnWidths( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner );
+ /// RES_RTL_GUTTER
+ virtual void SectionRtlGutter(const SfxBoolItem& /*rRtlGutter*/) {}
+
public:
AttributeOutputBase(const OUString& sBaseURL)
: m_sBaseURL(sBaseURL)
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index cd67d87495bd..b64be1d084b3 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -6715,6 +6715,16 @@ void DocxAttributeOutput::SectionFormProtection( bool bProtected )
m_pSerializer->singleElementNS(XML_w, XML_formProt, FSNS(XML_w, XML_val), "false");
}
+void DocxAttributeOutput::SectionRtlGutter(const SfxBoolItem& rRtlGutter)
+{
+ if (!rRtlGutter.GetValue())
+ {
+ return;
+ }
+
+ m_pSerializer->singleElementNS(XML_w, XML_rtlGutter);
+}
+
void DocxAttributeOutput::SectionLineNumbering( sal_uLong nRestartNo, const SwLineNumberInfo& rLnNumInfo )
{
rtl::Reference<FastAttributeList> pAttr = FastSerializerHelper::createAttrList();
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 7a2826e81ea9..62ace93d55f0 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -681,6 +681,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
DocxExport &m_rExport;
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 985df4df45a2..2103490e9cc7 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -5503,6 +5503,9 @@ void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt )
case RES_CHRATR_GRABBAG:
CharGrabBag(static_cast<const SfxGrabBagItem&>(rHt));
break;
+ case RES_RTL_GUTTER:
+ SectionRtlGutter(static_cast<const SfxBoolItem&>(rHt));
+ break;
default:
SAL_INFO("sw.ww8", "Unhandled SfxPoolItem with id " << rHt.Which() );
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 42b8bd3a09a8..a70c5e81d5af 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1599,6 +1599,13 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext )
pSectionContext->Insert(PROP_WRITING_MODE, uno::makeAny(writingMode));
}
break;
+ case NS_ooxml::LN_EG_SectPrContents_rtlGutter:
+ if (pSectionContext != nullptr)
+ {
+ bool bRtlGutter = nIntValue != 0;
+ pSectionContext->Insert(PROP_RTL_GUTTER, uno::makeAny(bRtlGutter));
+ }
+ break;
case NS_ooxml::LN_EG_RPrBase_highlight:
{
// MS Word completely ignores character highlighting in character styles.
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index 5450c0c0dfc6..0100313bdf45 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -360,6 +360,9 @@ OUString getPropertyName( PropertyIds eId )
case PROP_GUTTER_MARGIN:
sName = "GutterMargin";
break;
+ case PROP_RTL_GUTTER:
+ sName = "RtlGutter";
+ break;
}
assert(sName.getLength()>0);
return sName;
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx
index 67e804d231cb..a6afe0c5313f 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -359,6 +359,7 @@ enum PropertyIds
,PROP_CELL_FORMULA
,PROP_CELL_FORMULA_CONVERTED
,PROP_GUTTER_MARGIN
+ ,PROP_RTL_GUTTER
};
//Returns the UNO string equivalent to eId.