diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-01-15 11:57:50 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-01-15 16:05:47 +0100 |
commit | f3b5356bdc51b03f9910ed544b8c17d6f919bc12 (patch) | |
tree | b21b6ae5d1db87e14160e47dbd2d2f46cf686384 /xmloff/qa | |
parent | 79bfb54665b1a8dc2b932318eb6915d300772cff (diff) |
tdf#136861 ODT export: fix writing resolved state for non-ranged comments
It was probably not intentional to write the resolved state only in case
the annotation has a name.
Change-Id: Ia3a6b2320e2288528c43c832211ebfcde492881e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109354
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'xmloff/qa')
-rw-r--r-- | xmloff/qa/unit/text.cxx | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx index c8e867401ccd..30646655bf3a 100644 --- a/xmloff/qa/unit/text.cxx +++ b/xmloff/qa/unit/text.cxx @@ -10,7 +10,13 @@ #include <test/bootstrapfixture.hxx> #include <unotest/macros_test.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/frame/Desktop.hpp> +#include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/text/XTextDocument.hpp> + +#include <comphelper/propertysequence.hxx> +#include <unotools/tempfile.hxx> using namespace ::com::sun::star; @@ -52,6 +58,48 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMailMergeInEditeng) CPPUNIT_ASSERT(getComponent().is()); } +CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testCommentResolved) +{ + getComponent() = loadFromDesktop("private:factory/swriter"); + uno::Sequence<beans::PropertyValue> aCommentProps = comphelper::InitPropertySequence({ + { "Text", uno::makeAny(OUString("comment")) }, + }); + dispatchCommand(getComponent(), ".uno:InsertAnnotation", aCommentProps); + uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), + uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + uno::Reference<container::XEnumerationAccess> xPara(xParaEnum->nextElement(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xPortionEnum = xPara->createEnumeration(); + uno::Reference<beans::XPropertySet> xPortion(xPortionEnum->nextElement(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xField(xPortion->getPropertyValue("TextField"), + uno::UNO_QUERY); + xField->setPropertyValue("Resolved", uno::makeAny(true)); + + uno::Reference<frame::XStorable> xStorable(getComponent(), uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aStoreProps = comphelper::InitPropertySequence({ + { "FilterName", uno::makeAny(OUString("writer8")) }, + }); + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(); + xStorable->storeToURL(aTempFile.GetURL(), aStoreProps); + getComponent()->dispose(); + + getComponent() = loadFromDesktop(aTempFile.GetURL()); + xTextDocument.set(getComponent(), uno::UNO_QUERY); + xParaEnumAccess.set(xTextDocument->getText(), uno::UNO_QUERY); + xParaEnum = xParaEnumAccess->createEnumeration(); + xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); + xPortionEnum = xPara->createEnumeration(); + xPortion.set(xPortionEnum->nextElement(), uno::UNO_QUERY); + xField.set(xPortion->getPropertyValue("TextField"), uno::UNO_QUERY); + bool bResolved = false; + xField->getPropertyValue("Resolved") >>= bResolved; + // Without the accompanying fix in place, this test would have failed, as the resolved state was + // not saved for non-range comments. + CPPUNIT_ASSERT(bResolved); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |