[PATCH libreoffice-4-0] fdo#53985 DOCX import: don't try to set empty PageDescName

Miklos Vajna (via Code Review) gerrit at gerrit.libreoffice.org
Thu Feb 28 01:06:21 PST 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2460

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/60/2460/1

fdo#53985 DOCX import: don't try to set empty PageDescName

Regression from 50cb1667020494906afaacb68d4163d1eda527cf.

(cherry picked from commit 8281578b89c3df3fe3452a594f6b21483683638a)

Conflicts:
	sw/qa/extras/ooxmlimport/ooxmlimport.cxx

Change-Id: Ie04d5ad37555ed4cfeb34ccb8dc021675fbd25ea
---
A sw/qa/extras/ooxmlimport/data/fdo53985.docx
M sw/qa/extras/ooxmlimport/ooxmlimport.cxx
M writerfilter/source/dmapper/PropertyMap.cxx
3 files changed, 25 insertions(+), 1 deletion(-)



diff --git a/sw/qa/extras/ooxmlimport/data/fdo53985.docx b/sw/qa/extras/ooxmlimport/data/fdo53985.docx
new file mode 100644
index 0000000..0c8b32f
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/fdo53985.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 69dc0cb..2c32f13 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -111,6 +111,7 @@
     void testN780645();
     void testFineTableDash();
     void testN779642();
+    void testFdo53985();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -174,6 +175,7 @@
         {"n780645.docx", &Test::testN780645},
         {"tableborder-finedash.docx", &Test::testFineTableDash},
         {"n779642.docx", &Test::testN779642},
+        {"fdo53985.docx", &Test::testFdo53985},
     };
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
     {
@@ -1085,6 +1087,15 @@
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong vertical orientation relation", nValue, text::RelOrientation::PAGE_PRINT_AREA);
 }
 
+void Test::testFdo53985()
+{
+    // Unhandled excetion prevented import of the rest of the document.
+
+    uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xTables->getCount()); // Only 4 tables were imported.
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index c2fe9ef..8f19057 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -840,7 +840,20 @@
             ApplyColumnProperties( xSection );
         uno::Reference<beans::XPropertySet> xRangeProperties(lcl_GetRangeProperties(m_bIsFirstSection, rDM_Impl, m_xStartingRange));
         if (xRangeProperties.is())
-            xRangeProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_PAGE_DESC_NAME), uno::makeAny(m_bTitlePage ? m_sFirstPageStyleName : m_sFollowPageStyleName));
+        {
+            OUString aName = m_bTitlePage ? m_sFirstPageStyleName : m_sFollowPageStyleName;
+            if (!aName.isEmpty())
+            {
+                try
+                {
+                    xRangeProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_PAGE_DESC_NAME), uno::makeAny(aName));
+                }
+                catch( const uno::Exception& )
+                {
+                    SAL_WARN("writerfilter", "failed to set PageDescName!");
+                }
+            }
+        }
     }
     // If the section is of type "New column" (0x01), then simply insert a column break.
     // But only if there actually are columns on the page, otherwise a column break

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

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



More information about the LibreOffice mailing list