summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-05-29 15:03:23 +0200
committerJan Holesovsky <kendy@collabora.com>2021-01-07 16:32:57 +0100
commit08f306622ea33da65338583864e812114cbe8d7c (patch)
tree794fc15fda9d0045c226148bed3d0d4d63cde126 /sw
parent5461539a952b16c8ac8107a7dac0f4615e6ae74c (diff)
sw: ODF export: test new ODF 1.3 features exported to different versions
Change-Id: I57f598c39e1ffe77e351507cf661b52caa6bd4b0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95141 Tested-by: Michael Stahl <michael.stahl@cib.de> Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/globalfilter/data/text13e.odtbin0 -> 9718 bytes
-rw-r--r--sw/qa/extras/globalfilter/globalfilter.cxx159
2 files changed, 159 insertions, 0 deletions
diff --git a/sw/qa/extras/globalfilter/data/text13e.odt b/sw/qa/extras/globalfilter/data/text13e.odt
new file mode 100644
index 000000000000..bb16e0467e1a
--- /dev/null
+++ b/sw/qa/extras/globalfilter/data/text13e.odt
Binary files differ
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx
index fe9b58e16413..eba58e55716d 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -12,6 +12,9 @@
#include <com/sun/star/awt/XBitmap.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/graphic/GraphicType.hpp>
+#include <com/sun/star/text/XText.hpp>
+#include <com/sun/star/text/XDocumentIndex.hpp>
+#include <o3tl/safeint.hxx>
#include <officecfg/Office/Common.hxx>
#include <sfx2/linkmgr.hxx>
#include <comphelper/propertysequence.hxx>
@@ -50,6 +53,8 @@ public:
void testSkipImages();
#endif
void testNestedFieldmark();
+ void verifyText13(char const*);
+ void testODF13();
void testRedlineFlags();
void testBulletAsImage();
void testTextFormField();
@@ -72,6 +77,7 @@ public:
CPPUNIT_TEST(testSkipImages);
#endif
CPPUNIT_TEST(testNestedFieldmark);
+ CPPUNIT_TEST(testODF13);
CPPUNIT_TEST(testRedlineFlags);
CPPUNIT_TEST(testBulletAsImage);
CPPUNIT_TEST(testTextFormField);
@@ -1032,6 +1038,159 @@ void Test::testNestedFieldmark()
}
}
+auto Test::verifyText13(char const*const pTestName) -> void
+{
+ // OFFICE-3789 style:header-first/style:footer-first
+ uno::Reference<beans::XPropertySet> xPageStyle;
+ getStyles("PageStyles")->getByName("Standard") >>= xPageStyle;
+ uno::Reference<text::XText> xHF(getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderTextFirst"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(pTestName, OUString("Header first"), xHF->getString());
+ uno::Reference<text::XText> xFF(getProperty<uno::Reference<text::XText>>(xPageStyle, "FooterTextFirst"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(pTestName, OUString("Footer first"), xFF->getString());
+ // OFFICE-3767 text:contextual-spacing
+ uno::Reference<text::XTextRange> xPara(getParagraph(1));
+ CPPUNIT_ASSERT_MESSAGE(pTestName, getProperty<bool>(xPara, "ParaContextMargin"));
+ // OFFICE-3776 meta:creator-initials
+ uno::Reference<text::XTextRange> xRun(getRun(xPara, 1));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(pTestName, OUString("Annotation"), getProperty<OUString>(xRun, "TextPortionType"));
+ uno::Reference<beans::XPropertySet> xComment(getProperty<uno::Reference<beans::XPropertySet>>(xRun, "TextField"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(pTestName, OUString("dj"), getProperty<OUString>(xComment, "Initials"));
+ // OFFICE-3941 text:index-entry-link-start/text:index-entry-link-end
+ uno::Reference<text::XDocumentIndexesSupplier> xDIS(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xIndexes(xDIS->getDocumentIndexes());
+ uno::Reference<text::XDocumentIndex> xIndex(xIndexes->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<container::XIndexReplace> xLevels(getProperty<uno::Reference<container::XIndexReplace>>(xIndex, "LevelFormat"));
+ uno::Sequence<beans::PropertyValues> format;
+ xLevels->getByIndex(1) >>= format; // 1-based?
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(pTestName, OUString("TokenType"), format[0][0].Name);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(pTestName, OUString("TokenHyperlinkStart"), format[0][0].Value.get<OUString>());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(pTestName, OUString("TokenType"), format[4][0].Name);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(pTestName, OUString("TokenHyperlinkEnd"), format[4][0].Value.get<OUString>());
+}
+
+// test ODF 1.3 new text document features
+void Test::testODF13()
+{
+ // import
+ mxComponent = loadFromDesktop(m_directories.getURLFromSrc(
+ "/sw/qa/extras/globalfilter/data/text13e.odt"),
+ "com.sun.star.text.TextDocument");
+
+ // check model
+ verifyText13("import");
+
+ Resetter _([]() {
+ std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch);
+ return pBatch->commit();
+ });
+
+ {
+ // export ODF 1.3
+ std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Save::ODF::DefaultVersion::set(10, pBatch);
+ pBatch->commit();
+
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= OUString("writer8");
+
+ utl::TempFile aTempFile;
+ uno::Reference<frame::XStorable> const xStorable(mxComponent, uno::UNO_QUERY);
+ xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+
+ // check XML
+ xmlDocPtr pContentXml = parseExportInternal(aTempFile.GetURL(), "content.xml");
+ assertXPath(pContentXml, "/office:document-content/office:automatic-styles/style:style/style:paragraph-properties[@style:contextual-spacing='true']");
+ assertXPath(pContentXml, "/office:document-content/office:body/office:text/text:p/office:annotation/meta:creator-initials");
+ assertXPath(pContentXml, "/office:document-content/office:body/office:text/text:p/office:annotation/loext:sender-initials", 0);
+ assertXPath(pContentXml, "/office:document-content/office:body/office:text/text:illustration-index/text:illustration-index-source/text:illustration-index-entry-template/text:index-entry-link-start");
+ assertXPath(pContentXml, "/office:document-content/office:body/office:text/text:illustration-index/text:illustration-index-source/text:illustration-index-entry-template/loext:index-entry-link-start", 0);
+ assertXPath(pContentXml, "/office:document-content/office:body/office:text/text:illustration-index/text:illustration-index-source/text:illustration-index-entry-template/text:index-entry-link-end");
+ assertXPath(pContentXml, "/office:document-content/office:body/office:text/text:illustration-index/text:illustration-index-source/text:illustration-index-entry-template/loext:index-entry-link-end", 0);
+ xmlDocPtr pStylesXml = parseExportInternal(aTempFile.GetURL(), "styles.xml");
+ assertXPath(pStylesXml, "/office:document-styles/office:master-styles/style:master-page/style:header-first");
+ assertXPath(pStylesXml, "/office:document-styles/office:master-styles/style:master-page/loext:header-first", 0);
+ assertXPath(pStylesXml, "/office:document-styles/office:master-styles/style:master-page/style:footer-first");
+ assertXPath(pStylesXml, "/office:document-styles/office:master-styles/style:master-page/loext:footer-first", 0);
+
+ // reload
+ mxComponent->dispose();
+ mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument");
+
+ // check model
+ verifyText13("1.3 reload");
+ }
+ {
+ // export ODF 1.2 extended
+ std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Save::ODF::DefaultVersion::set(9, pBatch);
+ pBatch->commit();
+
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= OUString("writer8");
+
+ utl::TempFile aTempFile;
+ uno::Reference<frame::XStorable> const xStorable(mxComponent, uno::UNO_QUERY);
+ xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+
+ // check XML
+ xmlDocPtr pContentXml = parseExportInternal(aTempFile.GetURL(), "content.xml");
+ assertXPath(pContentXml, "/office:document-content/office:automatic-styles/style:style/style:paragraph-properties[@loext:contextual-spacing='true']");
+ assertXPath(pContentXml, "/office:document-content/office:body/office:text/text:p/office:annotation/loext:sender-initials");
+ assertXPath(pContentXml, "/office:document-content/office:body/office:text/text:p/office:annotation/meta:creator-initials", 0);
+ assertXPath(pContentXml, "/office:document-content/office:body/office:text/text:illustration-index/text:illustration-index-source/text:illustration-index-entry-template/loext:index-entry-link-start");
+ assertXPath(pContentXml, "/office:document-content/office:body/office:text/text:illustration-index/text:illustration-index-source/text:illustration-index-entry-template/text:index-entry-link-start", 0);
+ assertXPath(pContentXml, "/office:document-content/office:body/office:text/text:illustration-index/text:illustration-index-source/text:illustration-index-entry-template/loext:index-entry-link-end");
+ assertXPath(pContentXml, "/office:document-content/office:body/office:text/text:illustration-index/text:illustration-index-source/text:illustration-index-entry-template/text:index-entry-link-end", 0);
+ xmlDocPtr pStylesXml = parseExportInternal(aTempFile.GetURL(), "styles.xml");
+ assertXPath(pStylesXml, "/office:document-styles/office:master-styles/style:master-page/loext:header-first");
+ assertXPath(pStylesXml, "/office:document-styles/office:master-styles/style:master-page/style:header-first", 0);
+ assertXPath(pStylesXml, "/office:document-styles/office:master-styles/style:master-page/loext:footer-first");
+ assertXPath(pStylesXml, "/office:document-styles/office:master-styles/style:master-page/style:footer-first", 0);
+
+ // reload
+ mxComponent->dispose();
+ mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument");
+
+ // check model
+ verifyText13("1.2 Extended reload");
+ }
+ {
+ // export ODF 1.2
+ std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Save::ODF::DefaultVersion::set(4, pBatch);
+ pBatch->commit();
+
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= OUString("writer8");
+
+ utl::TempFile aTempFile;
+ uno::Reference<frame::XStorable> const xStorable(mxComponent, uno::UNO_QUERY);
+ xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+
+ // check XML
+ xmlDocPtr pContentXml = parseExportInternal(aTempFile.GetURL(), "content.xml");
+ assertXPathNoAttribute(pContentXml, "/office:document-content/office:automatic-styles/style:style/style:paragraph-properties", "contextual-spacing");
+ assertXPath(pContentXml, "/office:document-content/office:body/office:text/text:p/office:annotation/meta:creator-initials", 0);
+ assertXPath(pContentXml, "/office:document-content/office:body/office:text/text:p/office:annotation/loext:sender-initials", 0);
+ assertXPath(pContentXml, "/office:document-content/office:body/office:text/text:illustration-index/text:illustration-index-source/text:illustration-index-entry-template/text:index-entry-link-start", 0);
+ assertXPath(pContentXml, "/office:document-content/office:body/office:text/text:illustration-index/text:illustration-index-source/text:illustration-index-entry-template/loext:index-entry-link-start", 0);
+ assertXPath(pContentXml, "/office:document-content/office:body/office:text/text:illustration-index/text:illustration-index-source/text:illustration-index-entry-template/text:index-entry-link-end", 0);
+ assertXPath(pContentXml, "/office:document-content/office:body/office:text/text:illustration-index/text:illustration-index-source/text:illustration-index-entry-template/loext:index-entry-link-end", 0);
+ xmlDocPtr pStylesXml = parseExportInternal(aTempFile.GetURL(), "styles.xml");
+ assertXPath(pStylesXml, "/office:document-styles/office:master-styles/style:master-page/style:header-first", 0);
+ assertXPath(pStylesXml, "/office:document-styles/office:master-styles/style:master-page/loext:header-first", 0);
+ assertXPath(pStylesXml, "/office:document-styles/office:master-styles/style:master-page/style:footer-first", 0);
+ assertXPath(pStylesXml, "/office:document-styles/office:master-styles/style:master-page/loext:footer-first", 0);
+
+ // don't reload - no point
+ }
+}
+
void Test::testRedlineFlags()
{
const OUString aFilterNames[] = {