[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - sw/qa xmloff/source

Michael Stahl mstahl at redhat.com
Thu Aug 14 01:22:06 PDT 2014


 sw/qa/extras/odfimport/data/fdo82165.odt          |binary
 sw/qa/extras/odfimport/odfimport.cxx              |   10 ++++++++++
 xmloff/source/text/XMLTextHeaderFooterContext.cxx |   13 +++++++++++--
 3 files changed, 21 insertions(+), 2 deletions(-)

New commits:
commit 9c4c37e3745a3998f29d8aa15d2023cb3d07424b
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Aug 12 17:47:20 2014 +0200

    fdo#82165: ODF import: clear all shapes when removing header content
    
    Shapes anchored to the first or last paragraph survive setString("")
    so need to be deleted with some ruse.
    
    (regression from b8499fc3dcf474050f026b8d5cd1d9037bbe42b7)
    
    Change-Id: I00a8132583c45d1953c207932cc7f02f3065ae77
    (cherry picked from commit 555c988f3b896e16afc7bdd1bd98e48229599637)
    Reviewed-on: https://gerrit.libreoffice.org/10895
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/sw/qa/extras/odfimport/data/fdo82165.odt b/sw/qa/extras/odfimport/data/fdo82165.odt
new file mode 100644
index 0000000..65a4084
Binary files /dev/null and b/sw/qa/extras/odfimport/data/fdo82165.odt differ
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index 879513b..e7fa8fb 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -344,6 +344,16 @@ DECLARE_ODFIMPORT_TEST(testFdo68839, "fdo68839.odt")
             getProperty<OUString>(xFrame2, "ChainNextName"));
 }
 
+DECLARE_ODFIMPORT_TEST(testFdo82165, "fdo82165.odt")
+{
+    // there was a duplicate shape in the left header
+    lcl_CheckShape(getShape(1), "Picture 9");
+    try {
+        uno::Reference<drawing::XShape> xShape = getShape(2);
+        CPPUNIT_FAIL("IndexOutOfBoundsException expected");
+    } catch (lang::IndexOutOfBoundsException const&) { }
+}
+
 DECLARE_ODFIMPORT_TEST(testFdo37606, "fdo37606.odt")
 {
     SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
diff --git a/xmloff/source/text/XMLTextHeaderFooterContext.cxx b/xmloff/source/text/XMLTextHeaderFooterContext.cxx
index 2a711b0..27cbc9c 100644
--- a/xmloff/source/text/XMLTextHeaderFooterContext.cxx
+++ b/xmloff/source/text/XMLTextHeaderFooterContext.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <com/sun/star/text/XText.hpp>
+#include <com/sun/star/text/XParagraphAppend.hpp>
 #include <com/sun/star/text/XRelativeTextContentRemove.hpp>
 #include <xmloff/nmspmap.hxx>
 #include <xmloff/xmlnmspe.hxx>
@@ -158,8 +159,16 @@ SvXMLImportContext *XMLTextHeaderFooterContext::CreateChildContext(
 
             if( bRemoveContent )
             {
-                OUString aText;
-                xText->setString( aText );
+                xText->setString(OUString());
+                // fdo#82165 shapes anchored at the beginning or end survive
+                // setString("") - kill them the hard way: SwDoc::DelFullPara()
+                uno::Reference<text::XParagraphAppend> const xAppend(
+                        xText, uno::UNO_QUERY_THROW);
+                uno::Reference<lang::XComponent> const xPara(
+                    xAppend->finishParagraph(
+                        uno::Sequence<beans::PropertyValue>()),
+                    uno::UNO_QUERY_THROW);
+                xPara->dispose();
             }
 
             UniReference < XMLTextImportHelper > xTxtImport =


More information about the Libreoffice-commits mailing list