[Libreoffice-commits] core.git: 2 commits - sw/qa sw/source xmloff/source
Miklos Vajna
vmiklos at suse.cz
Wed Mar 20 03:35:44 PDT 2013
sw/qa/extras/odfexport/data/fdo60769.odt |binary
sw/qa/extras/odfexport/odfexport.cxx | 28 ++++++++++++++++++++++++++++
sw/source/core/unocore/unoportenum.cxx | 12 ++++++++++++
xmloff/source/text/txtparae.cxx | 20 ++++++++++++--------
4 files changed, 52 insertions(+), 8 deletions(-)
New commits:
commit 19802872052aaed9d3deff02b882b2043239a406
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Wed Mar 20 10:43:57 2013 +0100
fdo#60769 implement odf export of multi-paragraph comment ranges
Change-Id: Ifb850438586eb6589fde79d10ed9eef727368f42
diff --git a/sw/qa/extras/odfexport/data/fdo60769.odt b/sw/qa/extras/odfexport/data/fdo60769.odt
new file mode 100644
index 0000000..b3c3937
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 4ed23f1..e121c2f 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 44f7e4d..cf8dcc8 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;
commit c426df5086785807972c1a8d2788567f2842a395
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Wed Mar 20 10:39:08 2013 +0100
sw: export fieldmark of postit fields if possible
This way the UNO export filters won't have to remind if the postit field
had an associated fieldmark or not, but can just query the fieldmark
type and ignore e.g. comment fieldmarks.
Change-Id: I791b07fd371f57ec35d8309e666058237dadf190
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index 9fcc536..78be123 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -756,6 +756,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 :
More information about the Libreoffice-commits
mailing list