From 344e4a25eac6505678f4ce8a6c1c8cef83c68276 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 7 Mar 2013 17:42:26 +0100 Subject: fdo#61343 fix DOCX import of OLE object after groupshape Change-Id: I88d5e49cc3fb915d25c1b2576cdda1fffc9e2f23 --- sw/qa/extras/ooxmlimport/data/fdo61343.docx | Bin 0 -> 114220 bytes sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 11 +++++++++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 15 ++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100755 sw/qa/extras/ooxmlimport/data/fdo61343.docx diff --git a/sw/qa/extras/ooxmlimport/data/fdo61343.docx b/sw/qa/extras/ooxmlimport/data/fdo61343.docx new file mode 100755 index 000000000000..9ab99739b7c2 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/fdo61343.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 8365013aff62..0332a0c41ca5 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -119,6 +119,7 @@ public: void testTbLrHeight(); void testFdo53985(); void testFdo59638(); + void testFdo61343(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -189,6 +190,7 @@ void Test::run() {"tblr-height.docx", &Test::testTbLrHeight}, {"fdo53985.docx", &Test::testFdo53985}, {"fdo59638.docx", &Test::testFdo59638}, + {"fdo61343.docx", &Test::testFdo61343}, }; header(); for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) @@ -1232,6 +1234,15 @@ void Test::testFdo59638() CPPUNIT_FAIL("no BulletChar property"); } +void Test::testFdo61343() +{ + // The problem was that there were a groupshape in the doc, followed by an + // OLE object, and this lead to a crash. + uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 383681d66f5d..50daf773a851 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1626,6 +1626,19 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape uno::Reference xTextAppend = m_aTextAppendStack.top().xTextAppend; try { + uno::Reference< lang::XServiceInfo > xSInfo( xShape, uno::UNO_QUERY_THROW ); + if (xSInfo->supportsService("com.sun.star.drawing.GroupShape")) + { + // A GroupShape doesn't implement text::XTextRange, but appending + // an empty reference to the stacks still makes sense, because this + // way bToRemove can be set, and we won't end up with duplicated + // shapes for OLE objects. + m_aTextAppendStack.push(TextAppendContext(uno::Reference(xShape, uno::UNO_QUERY), uno::Reference())); + uno::Reference xTxtContent(xShape, uno::UNO_QUERY); + m_aAnchoredStack.push(xTxtContent); + } + else + { uno::Reference< text::XTextRange > xShapeText( xShape, uno::UNO_QUERY_THROW); // Add the shape to the text append stack m_aTextAppendStack.push( TextAppendContext(uno::Reference< text::XTextAppend >( xShape, uno::UNO_QUERY_THROW ), @@ -1641,7 +1654,6 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape #ifdef DEBUG_DOMAINMAPPER dmapper_logger->unoPropertySet(xProps); #endif - uno::Reference< lang::XServiceInfo > xSInfo( xShape, uno::UNO_QUERY_THROW ); bool bIsGraphic = xSInfo->supportsService( "com.sun.star.drawing.GraphicObjectShape" ); // If there are position properties, the shape should not be inserted "as character". @@ -1669,6 +1681,7 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape { xProps->setPropertyValue( rPropNameSupplier.GetName( PROP_ANCHOR_TYPE ), bIsGraphic ? uno::makeAny( text::TextContentAnchorType_AS_CHARACTER ) : uno::makeAny( text::TextContentAnchorType_AT_PARAGRAPH ) ); } + } appendTableManager( ); appendTableHandler( ); -- cgit v1.2.3