summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-03-20 10:39:08 +0100
committerNoel Power <noel.power@suse.com>2013-03-20 15:06:26 +0000
commit473cd59a71706ada01f8be68c7dfd008ca9bb716 (patch)
treec34538f9d9585f5df9e144b08ae69085723d6ca7 /sw
parent0bebb6b7ee44db2554a74a77ffaffb304a7d9b3b (diff)
fdo#60769 implement odf export of multi-paragraph comment ranges
(cherry picked from commits 287c254d5ebf9b58ca63a8c271e523adf0d34b82 and 1fba17854b2be4fdbe436f44da3ae57a1f75a27c) Conflicts: sw/qa/extras/odfexport/odfexport.cxx Change-Id: Ifb850438586eb6589fde79d10ed9eef727368f42 Reviewed-on: https://gerrit.libreoffice.org/2873 Reviewed-by: Noel Power <noel.power@suse.com> Tested-by: Noel Power <noel.power@suse.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/odfexport/data/fdo60769.odtbin0 -> 9482 bytes
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx28
-rw-r--r--sw/source/core/unocore/unoportenum.cxx12
3 files changed, 40 insertions, 0 deletions
diff --git a/sw/qa/extras/odfexport/data/fdo60769.odt b/sw/qa/extras/odfexport/data/fdo60769.odt
new file mode 100644
index 000000000000..b3c39376b82c
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/fdo60769.odt
Binary files differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index 7d93b3b89efa..1252fe97b3c8 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -33,6 +33,7 @@ class Test : public SwModelTestBase
public:
void testFdo38244();
void testFirstHeaderFooter();
+ void testFdo60769();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -49,6 +50,7 @@ void Test::run()
MethodEntry<Test> aMethods[] = {
{"fdo38244.odt", &Test::testFdo38244},
{"first-header-footer.odt", &Test::testFirstHeaderFooter},
+ {"fdo60769.odt", &Test::testFdo60769},
};
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
{
@@ -116,6 +118,32 @@ void Test::testFirstHeaderFooter()
CPPUNIT_ASSERT_EQUAL(OUString("Left footer2"), parseDump("/root/page[6]/footer/txt/text()"));
}
+void Test::testFdo60769()
+{
+ // Test multi-paragraph comment range feature.
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
+ uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
+ while (xRunEnum->hasMoreElements())
+ {
+ uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
+ OUString aType = getProperty<OUString>(xPropertySet, "TextPortionType");
+ // First paragraph: no field end, no anchor
+ CPPUNIT_ASSERT(aType == "Text" || aType == "TextFieldStart");
+ }
+
+ xRunEnumAccess.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+ while (xRunEnum->hasMoreElements())
+ {
+ uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
+ OUString aType = getProperty<OUString>(xPropertySet, "TextPortionType");
+ // Second paragraph: no field start
+ CPPUNIT_ASSERT(aType == "Text" || aType == "TextFieldEnd" || aType == "TextFieldEnd");
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index d05b8f5b0d6a..2829d3f6b058 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -754,6 +754,18 @@ lcl_ExportHints(
Reference<XTextField> xField =
SwXTextField::CreateSwXTextField(*pDoc, pAttr->GetFld());
pPortion->SetTextField(xField);
+
+ // If this is a postit field and it has a fieldmark
+ // associated, set the fieldmark as a bookmark.
+ const SwField* pField = pAttr->GetFld().GetFld();
+ if (pField->Which() == RES_POSTITFLD)
+ {
+ const SwPostItField* pPostItField = dynamic_cast<const SwPostItField*>(pField);
+ IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
+ IDocumentMarkAccess::const_iterator_t it = pMarkAccess->findMark(pPostItField->GetName());
+ if (it != pMarkAccess->getMarksEnd())
+ pPortion->SetBookmark(SwXFieldmark::CreateXFieldmark(*pDoc, *it->get()));
+ }
}
break;
case RES_TXTATR_FLYCNT :