diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-03-31 13:59:38 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-03-31 14:56:49 +0200 |
commit | fac65bb9d831a854298d6cba09ad6159d15b8323 (patch) | |
tree | 1a12ad1710bd28f9c0eac25ed52ef114f5a87d4b /xmloff/qa/unit | |
parent | b802ab694a8a7357d4657f3e11b571144fa7c7bf (diff) |
tdf#140343 sw page rtl gutter margin: add ODF import
See <https://issues.oasis-open.org/browse/OFFICE-4105>, the proposal is
to not map this to a new attribute of the <style:page-layout-properties>
XML element, rather only write writing mode on export and infer
RtlGutter from that writing mode in import.
This is similar to how FillBitmapOffsetX and FillBitmapOffsetY are two
UNO properties, but there is a single draw:tile-repeat-offset attribute
for them.
This has the benefit of simpler ODF markup, at the cost of more
complicated xmloff code.
Change-Id: I189a7ec62d4e5624e20252b7259a36133594fe40
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113405
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'xmloff/qa/unit')
-rw-r--r-- | xmloff/qa/unit/data/rtl-gutter.fodt | 16 | ||||
-rw-r--r-- | xmloff/qa/unit/style.cxx | 24 |
2 files changed, 40 insertions, 0 deletions
diff --git a/xmloff/qa/unit/data/rtl-gutter.fodt b/xmloff/qa/unit/data/rtl-gutter.fodt new file mode 100644 index 000000000000..ad08d4f33d1a --- /dev/null +++ b/xmloff/qa/unit/data/rtl-gutter.fodt @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<office:document xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:automatic-styles> + <style:page-layout style:name="pm1"> + <style:page-layout-properties fo:page-width="21.0cm" fo:page-height="29.7cm" fo:margin-top="2.54cm" fo:margin-bottom="2.54cm" fo:margin-left="2.54cm" fo:margin-right="2.54cm" style:writing-mode="rl-tb" loext:margin-gutter="2.54cm"/> + </style:page-layout> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-layout-name="pm1"/> + </office:master-styles> + <office:body> + <office:text> + <text:p>hello</text:p> + </office:text> + </office:body> +</office:document> diff --git a/xmloff/qa/unit/style.cxx b/xmloff/qa/unit/style.cxx index c3c120de0e7f..c6dd4ecd8bc2 100644 --- a/xmloff/qa/unit/style.cxx +++ b/xmloff/qa/unit/style.cxx @@ -19,6 +19,8 @@ #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/packages/zip/ZipFileAccess.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <comphelper/propertysequence.hxx> #include <unotools/tempfile.hxx> @@ -132,6 +134,28 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testFontSorting) xmlXPathFreeObject(pXPath); } +CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testRtlGutter) +{ + // Given a document with a gutter margin and an RTL writing mode: + // When loading that document from ODF: + load(u"rtl-gutter.fodt"); + + // Then make sure the page style's RtlGutter property is true. + uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(getComponent(), + uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xStyleFamilies + = xStyleFamiliesSupplier->getStyleFamilies(); + uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("PageStyles"), + uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xStandard(xStyleFamily->getByName("Standard"), + uno::UNO_QUERY); + bool bRtlGutter{}; + xStandard->getPropertyValue("RtlGutter") >>= bRtlGutter; + // Without the accompanying fix in place, this test would have failed as + // <style:page-layout-properties>'s style:writing-mode="..." did not affect RtlGutter. + CPPUNIT_ASSERT(bRtlGutter); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |