From 473cd59a71706ada01f8be68c7dfd008ca9bb716 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 20 Mar 2013 10:39:08 +0100 Subject: 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 Tested-by: Noel Power --- sw/qa/extras/odfexport/data/fdo60769.odt | Bin 0 -> 9482 bytes sw/qa/extras/odfexport/odfexport.cxx | 28 ++++++++++++++++++++++++++++ sw/source/core/unocore/unoportenum.cxx | 12 ++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 sw/qa/extras/odfexport/data/fdo60769.odt (limited to 'sw') 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 Binary files /dev/null and b/sw/qa/extras/odfexport/data/fdo60769.odt 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 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 xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); + uno::Reference xParaEnum = xParaEnumAccess->createEnumeration(); + uno::Reference xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY); + uno::Reference xRunEnum = xRunEnumAccess->createEnumeration(); + while (xRunEnum->hasMoreElements()) + { + uno::Reference xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY); + OUString aType = getProperty(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 xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY); + OUString aType = getProperty(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 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(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 : -- cgit