summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerge Krot <Serge.Krot@cib.de>2018-02-08 13:19:01 +0100
committerMichael Stahl <Michael.Stahl@cib.de>2018-07-06 10:22:53 +0200
commit8c2545153572b32ecba202e52aade84b188dac73 (patch)
tree141db7410901a4a0c58330d72efc5df9091330f7
parenttdf#101856 Backport parsing of bookmark properties (diff)
downloadcore-8c2545153572b32ecba202e52aade84b188dac73.tar.gz
core-8c2545153572b32ecba202e52aade84b188dac73.zip
tdf#101856 odt: write/read new bookmark attributes: unit test
Change-Id: I094f91c2af2d171067e3c37a8d52276835d36e9c (cherry picked from commit 61150f1c37744457e7a1a1c1e684612b6adf0298) Reviewed-on: https://gerrit.libreoffice.org/49424 Tested-by: Jenkins Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
-rw-r--r--schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng14
-rwxr-xr-xsw/qa/extras/odfexport/data/tdf101856.odtbin0 -> 9406 bytes
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx46
3 files changed, 60 insertions, 0 deletions
diff --git a/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng b/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
index f6561295af84..adae650eafc9 100644
--- a/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
+++ b/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
@@ -2299,6 +2299,20 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
</rng:optional>
</rng:define>
+ <!-- TODO no proposal -->
+ <rng:define name="text-bookmark-start-attlist" combine="interleave">
+ <rng:optional>
+ <rng:attribute name="loext:hidden">
+ <rng:ref name="boolean"/>
+ </rng:attribute>
+ <rng:optional>
+ <rng:attribute name="loext:condition">
+ <rng:ref name="string"/>
+ </rng:attribute>
+ </rng:optional>
+ </rng:optional>
+ </rng:define>
+
<!-- just a test-case for user-defined attributes, move along, nothing to see here... -->
<rng:define name="style-table-cell-properties-attlist" combine="interleave">
<rng:optional>
diff --git a/sw/qa/extras/odfexport/data/tdf101856.odt b/sw/qa/extras/odfexport/data/tdf101856.odt
new file mode 100755
index 000000000000..bddd1502281c
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/tdf101856.odt
Binary files differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index 48ac63b27271..ef48e648661b 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -1996,6 +1996,52 @@ DECLARE_ODFEXPORT_TEST(testSpellOutNumberingTypes, "spellout-numberingtypes.odt"
}
}
+// MAILMERGE Add conditional to expand / collapse bookmarks
+DECLARE_ODFEXPORT_TEST(tdf101856, "tdf101856.odt")
+{
+ // get bookmark interface
+ uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
+
+ // check: we have 2 bookmarks
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(5), xBookmarksByIdx->getCount());
+ CPPUNIT_ASSERT(xBookmarksByName->hasByName("BookmarkVisible"));
+ CPPUNIT_ASSERT(xBookmarksByName->hasByName("BookmarkHidden"));
+ CPPUNIT_ASSERT(xBookmarksByName->hasByName("BookmarkVisibleWithCondition"));
+ CPPUNIT_ASSERT(xBookmarksByName->hasByName("BookmarkNotHiddenWithCondition"));
+ CPPUNIT_ASSERT(xBookmarksByName->hasByName("BookmarkHiddenWithCondition"));
+
+ // <text:bookmark-start text:name="BookmarkVisible"/>
+ uno::Reference<beans::XPropertySet> xBookmark1(xBookmarksByName->getByName("BookmarkVisible"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xBookmark1, UNO_NAME_BOOKMARK_CONDITION));
+ CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xBookmark1, UNO_NAME_BOOKMARK_HIDDEN));
+
+ // <text:bookmark-start text:name="BookmarkHidden" loext:condition="" loext:hidden="true"/>
+ uno::Reference<beans::XPropertySet> xBookmark2(xBookmarksByName->getByName("BookmarkHidden"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xBookmark2, UNO_NAME_BOOKMARK_CONDITION));
+ CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xBookmark2, UNO_NAME_BOOKMARK_HIDDEN));
+
+ // <text:bookmark-start text:name="BookmarkVisibleWithCondition" loext:condition="0==1" loext:hidden="true"/>
+ uno::Reference<beans::XPropertySet> xBookmark3(xBookmarksByName->getByName("BookmarkVisibleWithCondition"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("0==1"), getProperty<OUString>(xBookmark3, UNO_NAME_BOOKMARK_CONDITION));
+ CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xBookmark3, UNO_NAME_BOOKMARK_HIDDEN));
+
+ // <text:bookmark-start text:name="BookmarkNotHiddenWithCondition" loext:condition="1==1" loext:hidden="false"/>
+ //
+ // The following test doesn't work, while during output in the case of loext:hidden="false".
+ // no additional parameters are written. Implementation should be reviewed.
+ //
+// uno::Reference<beans::XPropertySet> xBookmark4(xBookmarksByName->getByName("BookmarkNotHiddenWithCondition"), uno::UNO_QUERY);
+// CPPUNIT_ASSERT_EQUAL(OUString("1==1"), getProperty<OUString>(xBookmark4, UNO_NAME_BOOKMARK_CONDITION));
+// CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xBookmark4, UNO_NAME_BOOKMARK_HIDDEN));
+
+ // <text:bookmark-start text:name="BookmarkHiddenWithCondition" loext:condition="1==1" loext:hidden="true"/>
+ uno::Reference<beans::XPropertySet> xBookmark5(xBookmarksByName->getByName("BookmarkHiddenWithCondition"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("1==1"), getProperty<OUString>(xBookmark5, UNO_NAME_BOOKMARK_CONDITION));
+ CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xBookmark5, UNO_NAME_BOOKMARK_HIDDEN));
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();