Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2873

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/73/2873/1

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
---
A sw/qa/extras/odfexport/data/fdo60769.odt
M sw/qa/extras/odfexport/odfexport.cxx
M sw/source/core/unocore/unoportenum.cxx
M xmloff/source/text/txtparae.cxx
4 files changed, 52 insertions(+), 8 deletions(-)



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
--- /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 7d93b3b..1252fe9 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -33,6 +33,7 @@
 public:
     void testFdo38244();
     void testFirstHeaderFooter();
+    void testFdo60769();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -49,6 +50,7 @@
     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 @@
     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 d05b8f5..2829d3f 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -754,6 +754,18 @@
                         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   :
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index 96cb842..36f7f0c 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -2198,7 +2198,6 @@
     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. */
@@ -2222,11 +2221,17 @@
             }
             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;
@@ -2291,10 +2296,9 @@
             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;
                 }
 
@@ -2358,7 +2362,8 @@
             }
             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();
@@ -2378,7 +2383,6 @@
                 }
                 else
                 {
-                    Reference< ::com::sun::star::text::XFormField > 
xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
                     if (xFormField.is())
                     {
                         OUString sName;

-- 
To view, visit https://gerrit.libreoffice.org/2873
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifb850438586eb6589fde79d10ed9eef727368f42
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Miklos Vajna <vmiklos@suse.cz>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.