diff options
author | Serge Krot <Serge.Krot@cib.de> | 2018-08-28 14:32:14 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2018-08-30 00:21:23 +0200 |
commit | 3559daee24ea1224d3d40e6a86b10cf37e18443f (patch) | |
tree | f4ecb418071b7c4c464335003e947f3bdc598a2d | |
parent | a1dd8098e6e2a7d5ba4b9c1a2d094db11d3d6b27 (diff) |
tdf#101856 Handle properties of nested bookmarks
Change-Id: I1a92d2001e58751c5bbe41f6480f4c46dcc8c9e7
Reviewed-on: https://gerrit.libreoffice.org/59766
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r-- | include/xmloff/txtimp.hxx | 6 | ||||
-rw-r--r-- | sw/qa/extras/odfexport/data/tdf101856_overlapped.odt | bin | 0 -> 9233 bytes | |||
-rw-r--r-- | sw/qa/extras/odfexport/odfexport.cxx | 24 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextMarkImportContext.cxx | 10 | ||||
-rw-r--r-- | xmloff/source/text/txtimp.cxx | 19 |
5 files changed, 41 insertions, 18 deletions
diff --git a/include/xmloff/txtimp.hxx b/include/xmloff/txtimp.hxx index c8e060f15d9c..2caeff3ea689 100644 --- a/include/xmloff/txtimp.hxx +++ b/include/xmloff/txtimp.hxx @@ -712,9 +712,9 @@ public: void AddCrossRefHeadingMapping(OUString const& rFrom, OUString const& rTo); void MapCrossRefHeadingFieldsHorribly(); - void setBookmarkAttributes(bool hidden, OUString const& condition); - bool getBookmarkHidden(); - const OUString& getBookmarkCondition(); + void setBookmarkAttributes(OUString const& bookmark, bool hidden, OUString const& condition); + bool getBookmarkHidden(OUString const& bookmark) const; + const OUString& getBookmarkCondition(OUString const& bookmark) const; }; diff --git a/sw/qa/extras/odfexport/data/tdf101856_overlapped.odt b/sw/qa/extras/odfexport/data/tdf101856_overlapped.odt Binary files differnew file mode 100644 index 000000000000..c05df538da52 --- /dev/null +++ b/sw/qa/extras/odfexport/data/tdf101856_overlapped.odt diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index ef48e648661b..ab993fb28439 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -1997,6 +1997,30 @@ DECLARE_ODFEXPORT_TEST(testSpellOutNumberingTypes, "spellout-numberingtypes.odt" } // MAILMERGE Add conditional to expand / collapse bookmarks +DECLARE_ODFEXPORT_TEST(tdf101856_overlapped, "tdf101856_overlapped.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>(2), xBookmarksByIdx->getCount()); + CPPUNIT_ASSERT(xBookmarksByName->hasByName("BookmarkNonHidden")); + CPPUNIT_ASSERT(xBookmarksByName->hasByName("BookmarkHidden")); + + // <text:bookmark-start text:name="BookmarkNonHidden"/> + uno::Reference<beans::XPropertySet> xBookmark1(xBookmarksByName->getByName("BookmarkNonHidden"), 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"/> + 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)); +} + +// MAILMERGE Add conditional to expand / collapse bookmarks DECLARE_ODFEXPORT_TEST(tdf101856, "tdf101856.odt") { // get bookmark interface diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx index 6641bec775a8..ea00d0aae2cd 100644 --- a/xmloff/source/text/XMLTextMarkImportContext.cxx +++ b/xmloff/source/text/XMLTextMarkImportContext.cxx @@ -174,9 +174,9 @@ void XMLTextMarkImportContext::StartElement( if (IsXMLToken(GetLocalName(), XML_BOOKMARK_START)) { - OUString sHidden = xAttrList->getValueByName("loext:hidden"); - OUString sCondition = xAttrList->getValueByName("loext:condition"); - m_rHelper.setBookmarkAttributes(sHidden == "true", sCondition); + const OUString sHidden = xAttrList->getValueByName("loext:hidden"); + const OUString sCondition = xAttrList->getValueByName("loext:condition"); + m_rHelper.setBookmarkAttributes(m_sBookmarkName, sHidden == "true", sCondition); } } @@ -357,8 +357,8 @@ void XMLTextMarkImportContext::EndElement() const Reference<XPropertySet> xPropertySet(xContent, UNO_QUERY); if (xPropertySet.is()) { - xPropertySet->setPropertyValue("BookmarkHidden", uno::Any(m_rHelper.getBookmarkHidden())); - xPropertySet->setPropertyValue("BookmarkCondition", uno::Any(m_rHelper.getBookmarkCondition())); + xPropertySet->setPropertyValue("BookmarkHidden", uno::Any(m_rHelper.getBookmarkHidden(m_sBookmarkName))); + xPropertySet->setPropertyValue("BookmarkCondition", uno::Any(m_rHelper.getBookmarkCondition(m_sBookmarkName))); } } diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index eadf77c4d3a3..e193a8c6f670 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -548,8 +548,8 @@ struct XMLTextImportHelper::Impl // Used for frame deduplication, the name of the last frame imported directly before the current one OUString msLastImportedFrameName; - bool m_bBookmarkHidden; - OUString m_sBookmarkCondition; + std::map< OUString, bool > m_bBookmarkHidden; + std::map< OUString, OUString > m_sBookmarkCondition; uno::Reference<text::XText> m_xText; uno::Reference<text::XTextCursor> m_xCursor; @@ -596,7 +596,6 @@ struct XMLTextImportHelper::Impl bool const bProgress, bool const bBlockMode, bool const bOrganizerMode) : m_xTextListsHelper( new XMLTextListsHelper() ) - , m_bBookmarkHidden( false ) // XML import: reconstrution of assignment of paragraph style to outline levels (#i69629#) , m_xServiceFactory( rModel, UNO_QUERY ) , m_rSvXMLImport( rImport ) @@ -2952,20 +2951,20 @@ void XMLTextImportHelper::MapCrossRefHeadingFieldsHorribly() } } -void XMLTextImportHelper::setBookmarkAttributes(bool hidden, OUString const& condition) +void XMLTextImportHelper::setBookmarkAttributes(OUString const& bookmark, bool hidden, OUString const& condition) { - m_xImpl->m_bBookmarkHidden = hidden; - m_xImpl->m_sBookmarkCondition = condition; + m_xImpl->m_bBookmarkHidden[bookmark] = hidden; + m_xImpl->m_sBookmarkCondition[bookmark] = condition; } -bool XMLTextImportHelper::getBookmarkHidden() +bool XMLTextImportHelper::getBookmarkHidden(OUString const& bookmark) const { - return m_xImpl->m_bBookmarkHidden; + return m_xImpl->m_bBookmarkHidden[bookmark]; } -const OUString& XMLTextImportHelper::getBookmarkCondition() +const OUString& XMLTextImportHelper::getBookmarkCondition(OUString const& bookmark) const { - return m_xImpl->m_sBookmarkCondition; + return m_xImpl->m_sBookmarkCondition[bookmark]; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |