From db1d278dcc308c73eb5edebc20481c96e7f479d8 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 7 Apr 2015 22:20:49 +0200 Subject: tdf#89802: xmloff: fix ODF import of frame with empty style name ref draw:fill-gradient-name="" in the graphic properties now causes BaseFrameProperties_Impl::FillBaseProperties() to fail and prevent insertion of the SwXTextFrame. (regression from 6e61ecd09679a66060f932835622821d39e92f01) Change-Id: I9b4f3ddb0f0e1b3a80e86bbdc1af2dade1c8edf7 --- sw/qa/extras/odfimport/data/tdf89802.fodt | 56 +++++++++++++++++++++++++++++ sw/qa/extras/odfimport/odfimport.cxx | 12 +++++++ xmloff/source/draw/XMLShapeStyleContext.cxx | 13 +++++++ 3 files changed, 81 insertions(+) create mode 100644 sw/qa/extras/odfimport/data/tdf89802.fodt diff --git a/sw/qa/extras/odfimport/data/tdf89802.fodt b/sw/qa/extras/odfimport/data/tdf89802.fodt new file mode 100644 index 000000000000..3d8601b5ae91 --- /dev/null +++ b/sw/qa/extras/odfimport/data/tdf89802.fodt @@ -0,0 +1,56 @@ + + + + ms 2015-04-07T22:24:25.3740120802015-04-07T22:25:28.460806924ms PT1M3S1LibreOfficeDev/4.5.0.0.alpha0$Linux_X86_64 LibreOffice_project/52ae345470d8fa657817cf87b3e8e8c1b51bd7da + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + foo + + + + + diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index 7c6e2e257137..a4b467e327a4 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -400,6 +400,18 @@ DECLARE_ODFIMPORT_TEST(testFdo82165, "fdo82165.odt") } catch (lang::IndexOutOfBoundsException const&) { } } +DECLARE_ODFIMPORT_TEST(testTdf89802, "tdf89802.fodt") +{ + // the text frame was dropped during import + uno::Reference const xTextFramesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference const xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + uno::Reference const xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY); + sal_Int32 nValue(0); + xFrame->getPropertyValue("BackColor") >>= nValue; + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x3f004586), nValue); +} + DECLARE_ODFIMPORT_TEST(testFdo37606, "fdo37606.odt") { SwXTextDocument* pTxtDoc = dynamic_cast(mxComponent.get()); diff --git a/xmloff/source/draw/XMLShapeStyleContext.cxx b/xmloff/source/draw/XMLShapeStyleContext.cxx index 720ac4cf4883..fe1b6b9bd1db 100644 --- a/xmloff/source/draw/XMLShapeStyleContext.cxx +++ b/xmloff/source/draw/XMLShapeStyleContext.cxx @@ -238,6 +238,19 @@ void XMLShapeStyleContext::FillPropertySet( const Reference< beans::XPropertySet OUString sStyleName; rState.maValue >>= sStyleName; sStyleName = GetImport().GetStyleDisplayName( aFamilies[i], sStyleName ); + // All of these attributes refer to something with draw:name + // of type styleName = NCName which is non-empty. + // tdf#89802: for Writer frames there would be no exception here but + // it will fail later on attach() and take out the entire frame + if (sStyleName.isEmpty()) + { + Sequence const seq{ sStyleName }; + GetImport().SetError( + XMLERROR_STYLE_PROP_VALUE | XMLERROR_FLAG_WARNING, + seq, "empty style name reference", NULL ); + break; + } + try { -- cgit