diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2013-03-20 10:43:57 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-03-20 11:35:24 +0100 |
commit | 19802872052aaed9d3deff02b882b2043239a406 (patch) | |
tree | e0f323e8a99c53e99fc62dcc1eec520cb4de34eb | |
parent | c426df5086785807972c1a8d2788567f2842a395 (diff) |
fdo#60769 implement odf export of multi-paragraph comment ranges
Change-Id: Ifb850438586eb6589fde79d10ed9eef727368f42
-rw-r--r-- | sw/qa/extras/odfexport/data/fdo60769.odt | bin | 0 -> 9482 bytes | |||
-rw-r--r-- | sw/qa/extras/odfexport/odfexport.cxx | 28 | ||||
-rw-r--r-- | xmloff/source/text/txtparae.cxx | 20 |
3 files changed, 40 insertions, 8 deletions
diff --git a/sw/qa/extras/odfexport/data/fdo60769.odt b/sw/qa/extras/odfexport/data/fdo60769.odt Binary files differnew file mode 100644 index 000000000000..b3c39376b82c --- /dev/null +++ b/sw/qa/extras/odfexport/data/fdo60769.odt diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index 4ed23f1a401f..e121c2f2f378 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -35,6 +35,7 @@ public: void testFdo38244(); void testFirstHeaderFooter(); void testTextframeGradient(); + void testFdo60769(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -52,6 +53,7 @@ void Test::run() {"fdo38244.odt", &Test::testFdo38244}, {"first-header-footer.odt", &Test::testFirstHeaderFooter}, {"textframe-gradient.odt", &Test::testTextframeGradient}, + {"fdo60769.odt", &Test::testFdo60769}, }; header(); for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) @@ -133,6 +135,32 @@ void Test::testTextframeGradient() CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style); } +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/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index 44f7e4d4c115..cf8dcc8fbc7e 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -2194,7 +2194,6 @@ void XMLTextParagraphExport::exportTextRangeEnumeration( static const OUString sMeta("InContentMetadata"); static const OUString sFieldMarkName("__FieldMark_"); bool bPrevCharIsSpace = bPrvChrIsSpc; - bool bAnnotationStarted = false; /* This is used for exporting to strict OpenDocument 1.2, in which case traditional * bookmarks are used instead of fieldmarks. */ @@ -2218,11 +2217,17 @@ void XMLTextParagraphExport::exportTextRangeEnumeration( } else if( sType.equals(sTextField)) { - if (bAnnotationStarted) + Reference< ::com::sun::star::text::XFormField > xFormField; + try { - bAnnotationStarted = false; + xFormField.set(xPropSet->getPropertyValue(sBookmark), UNO_QUERY); } - else + catch( const uno::Exception& ) + { + SAL_WARN("xmloff", "unexpected bookmark exception"); + } + + if (!xFormField.is() || xFormField->getFieldType() != ODF_COMMENTRANGE) { exportTextField( xTxtRange, bAutoStyles, bIsProgress ); bPrevCharIsSpace = false; @@ -2287,10 +2292,9 @@ void XMLTextParagraphExport::exportTextRangeEnumeration( else if (sType.equals(sTextFieldStart)) { Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY); - if (xFormField->getFieldType() == ODF_COMMENTRANGE) + if (xFormField.is() && xFormField->getFieldType() == ODF_COMMENTRANGE) { exportTextField( xTxtRange, bAutoStyles, bIsProgress ); - bAnnotationStarted = true; continue; } @@ -2354,7 +2358,8 @@ void XMLTextParagraphExport::exportTextRangeEnumeration( } else if (sType.equals(sTextFieldEnd)) { - if (bAnnotationStarted) + Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY); + if (xFormField.is() && xFormField->getFieldType() == ODF_COMMENTRANGE) { Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY); const OUString& rName = xBookmark->getName(); @@ -2374,7 +2379,6 @@ void XMLTextParagraphExport::exportTextRangeEnumeration( } else { - Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY); if (xFormField.is()) { OUString sName; |