Kaydet (Commit) 32e8b39c authored tarafından Michael Stahl's avatar Michael Stahl Kaydeden (comit) Andras Timar

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 b8499fc3)

Change-Id: I00a8132583c45d1953c207932cc7f02f3065ae77
(cherry picked from commit 555c988f)
Reviewed-on: https://gerrit.libreoffice.org/10895Reviewed-by: 's avatarDavid Tardon <dtardon@redhat.com>
Tested-by: 's avatarDavid Tardon <dtardon@redhat.com>
üst cc28a7cb
......@@ -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());
......
......@@ -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 =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment