From 3272c1eb5563f3bda2caa24f32b1018372622109 Mon Sep 17 00:00:00 2001 From: Thorsten Behrens Date: Mon, 1 Oct 2018 03:21:59 +0200 Subject: related tdf#100074: prepare group shapes text input via writerfilter Put various preps into place, that enable us to read txbxContent from group shape children via the writerfilter parser, which gets us much more features Also: - store shapecontexthandler on wrapper class in writerfilter - move adding children shapes to ctor, not dtor - remove RuntimeException in Writer's XShapes::add(), aligns this with Draw/Impress API semantics, and helps here when trying to add the same shape a 2nd time (which we then simply ignore) - make oox's Shape notion of 'inside group' less ad-hoc - make SwTextBoxHelper::getTextRectangle() cope with more than CustomShape - so passing in a group shape will also yield some sensible bounding box - have SwTextBoxHelper handle group content, too - derive WpsContext from ShapeContext, so we can later substitute it for that inside WpgContext - keep WpgContext::onCreateContext() _for the moment_ with the old delegation to ShapeContext (needs to use WpsContext to enable writerfilter text input) Change-Id: I2b0f0583e21137f3321a8dc13823058b14d19773 Reviewed-on: https://gerrit.libreoffice.org/65914 Tested-by: Jenkins Reviewed-by: Thorsten Behrens --- sd/qa/unit/data/xml/n819614_0.xml | 16 ++++++++-------- sd/qa/unit/export-tests-ooxml1.cxx | 10 +++++----- sd/qa/unit/export-tests-ooxml2.cxx | 8 ++++---- sd/qa/unit/import-tests.cxx | 6 +++--- 4 files changed, 20 insertions(+), 20 deletions(-) (limited to 'sd') diff --git a/sd/qa/unit/data/xml/n819614_0.xml b/sd/qa/unit/data/xml/n819614_0.xml index e51b520d3130..8238da646086 100644 --- a/sd/qa/unit/data/xml/n819614_0.xml +++ b/sd/qa/unit/data/xml/n819614_0.xml @@ -14,6 +14,14 @@ + + + + + + + + @@ -6824,12 +6832,4 @@ - - - - - - - - diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx index 1a3a818f929d..109c5a3f2261 100644 --- a/sd/qa/unit/export-tests-ooxml1.cxx +++ b/sd/qa/unit/export-tests-ooxml1.cxx @@ -221,7 +221,7 @@ void SdOOXMLExportTest1::testBnc870233_2() // First smart art has blue font color (direct formatting) { - const SdrObjGroup *pObjGroup = dynamic_cast(pPage->GetObj(0)); + const SdrObjGroup *pObjGroup = dynamic_cast(pPage->GetObj(1)); CPPUNIT_ASSERT(pObjGroup); const SdrTextObj *pObj = dynamic_cast(pObjGroup->GetSubList()->GetObj(0)); checkFontAttributes(pObj, Color(0x0000ff)); @@ -229,7 +229,7 @@ void SdOOXMLExportTest1::testBnc870233_2() // Second smart art has "dk2" font color (style) { - const SdrObjGroup *pObjGroup = dynamic_cast(pPage->GetObj(2)); // FIXME should be 1, smartart import creates an additional empty group for some reason + const SdrObjGroup *pObjGroup = dynamic_cast(pPage->GetObj(3)); // FIXME should be 1, smartart import creates an additional empty group for some reason CPPUNIT_ASSERT(pObjGroup); const SdrTextObj *pObj = dynamic_cast(pObjGroup->GetSubList()->GetObj(0)); checkFontAttributes( pObj, Color(0x1F497D) ); @@ -237,7 +237,7 @@ void SdOOXMLExportTest1::testBnc870233_2() // Third smart art has white font color (style) { - const SdrObjGroup *pObjGroup = dynamic_cast(pPage->GetObj(4)); // FIXME should be 2, smartart import creates an additional empty group for some reason + const SdrObjGroup *pObjGroup = dynamic_cast(pPage->GetObj(5)); // FIXME should be 2, smartart import creates an additional empty group for some reason CPPUNIT_ASSERT(pObjGroup); const SdrTextObj *pObj = dynamic_cast(pObjGroup->GetSubList()->GetObj(0)); checkFontAttributes(pObj, Color(0xffffff)); @@ -365,7 +365,7 @@ void SdOOXMLExportTest1::testBnc880763() // Check z-order of the two shapes, use background color to identify them // First object in the background has blue background color - const SdrObjGroup *pObjGroup = dynamic_cast(pPage->GetObj(0)); + const SdrObjGroup *pObjGroup = dynamic_cast(pPage->GetObj(1)); CPPUNIT_ASSERT(pObjGroup); const SdrObject *pObj = pObjGroup->GetSubList()->GetObj(0); CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr); @@ -387,7 +387,7 @@ void SdOOXMLExportTest1::testBnc862510_5() const SdrPage *pPage = GetPage( 1, xDocShRef ); // Same as testBnc870237, but here we check the horizontal spacing - const SdrObjGroup *pObjGroup = dynamic_cast(pPage->GetObj(0)); + const SdrObjGroup *pObjGroup = dynamic_cast(pPage->GetObj(1)); CPPUNIT_ASSERT(pObjGroup); const SdrObject* pObj = pObjGroup->GetSubList()->GetObj(1); CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr); diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index a472b0ef20fa..503b913b1ce0 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -1410,10 +1410,10 @@ void SdOOXMLExportTest2::testGroupsPosition() xDocShRef->DoClose(); xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml"); - assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:spPr/a:xfrm/a:off", "x", "6796800"); - assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:spPr/a:xfrm/a:off", "y", "4273920"); - assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[1]/p:spPr/a:xfrm/a:off", "x", "4040640"); - assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[1]/p:spPr/a:xfrm/a:off", "y", "4273920"); + assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[2]/p:sp[1]/p:spPr/a:xfrm/a:off", "x", "4040640"); + assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[2]/p:sp[1]/p:spPr/a:xfrm/a:off", "y", "4273920"); + assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[2]/p:sp[3]/p:spPr/a:xfrm/a:off", "x", "6796800"); + assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[2]/p:sp[3]/p:spPr/a:xfrm/a:off", "y", "4273920"); } void SdOOXMLExportTest2::testGroupsRotatedPosition() diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index e8827df1b946..0234733fe697 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -435,7 +435,7 @@ void SdImportTest::testN862510_2() const SdrPage *pPage = GetPage( 1, xDocShRef ); { - SdrObjGroup *pGrpObj = dynamic_cast( pPage->GetObj( 0 ) ); + SdrObjGroup *pGrpObj = dynamic_cast( pPage->GetObj( 1 ) ); CPPUNIT_ASSERT( pGrpObj ); SdrObjCustomShape *pObj = dynamic_cast( pGrpObj->GetSubList()->GetObj( 0 ) ); CPPUNIT_ASSERT( pObj ); @@ -815,7 +815,7 @@ void SdImportTest::testBnc870237() const SdrPage *pPage = GetPage( 1, xDocShRef ); // Simulate a:ext inside dsp:txXfrm with changing the lower distance - const SdrObjGroup* pObj = dynamic_cast( pPage->GetObj( 0 ) ); + const SdrObjGroup* pObj = dynamic_cast( pPage->GetObj( 1 ) ); CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr); CPPUNIT_ASSERT_EQUAL( sal_Int32(0), pObj->GetMergedItem(SDRATTR_TEXT_UPPERDIST).GetValue()); CPPUNIT_ASSERT_EQUAL( sal_Int32(9919), pObj->GetMergedItem(SDRATTR_TEXT_LOWERDIST).GetValue()); @@ -1262,7 +1262,7 @@ void SdImportTest::testTdf93830() uno::Reference< drawing::XDrawPage > xPage( getPage( 0, xDocShRef ) ); // Get the first text box from group shape - uno::Reference< container::XIndexAccess > xShape( xPage->getByIndex(0), uno::UNO_QUERY ); + uno::Reference< container::XIndexAccess > xShape( xPage->getByIndex(1), uno::UNO_QUERY ); uno::Reference< beans::XPropertySet > xPropSet( xShape->getByIndex(2), uno::UNO_QUERY ); CPPUNIT_ASSERT_MESSAGE( "no textbox shape", xPropSet.is() ); -- cgit