include/xmloff/xmlictxt.hxx | 5 -- sd/qa/unit/data/odg/ooo124143-1.odg |binary sd/qa/unit/import-tests.cxx | 49 ++++++++++++++++++++ sd/qa/unit/sdmodeltestbase.hxx | 4 + sw/qa/extras/odfexport/data/tdf103567.odt |binary sw/qa/extras/odfexport/odfexport.cxx | 36 ++++++++++++++ xmloff/source/core/xmlictxt.cxx | 4 - xmloff/source/core/xmlmultiimagehelper.cxx | 7 -- xmloff/source/draw/ximpshap.cxx | 70 ----------------------------- xmloff/source/draw/ximpshap.hxx | 3 - xmloff/source/text/XMLTextFrameContext.cxx | 29 ++++++++++++ 11 files changed, 118 insertions(+), 89 deletions(-)
New commits: commit 6b198399090ae5a963ad5075f396716252ccdea1 Author: Michael Stahl <mst...@redhat.com> Date: Thu Feb 9 11:48:11 2017 +0100 xmloff: remove onDemandRescueUsefulDataFromTemporary This workaround, which is both complex and quite incomplete, should no longer be necessary because the fixes for tdf#103567 should also fix i#124143, see unit test in previous commit. Change-Id: I038f238d5e3cf5cadfc666196380b7b351543982 diff --git a/include/xmloff/xmlictxt.hxx b/include/xmloff/xmlictxt.hxx index d68f6dd..554ecbe 100644 --- a/include/xmloff/xmlictxt.hxx +++ b/include/xmloff/xmlictxt.hxx @@ -113,11 +113,6 @@ public: virtual void SAL_CALL characters(const OUString & aChars) override; - // #i124143# allow to copy evtl. useful data from another temporary import context, e.g. used to - // support multiple images and to rescue evtl. GluePoints imported with one of the - // to be deprecated contents - virtual void onDemandRescueUsefulDataFromTemporary( const SvXMLImportContext& rCandidate ); - void AddFirstRef(); void AddNextRef(); void ReleaseRef(); diff --git a/xmloff/source/core/xmlictxt.cxx b/xmloff/source/core/xmlictxt.cxx index 509e7d9..6302508 100644 --- a/xmloff/source/core/xmlictxt.cxx +++ b/xmloff/source/core/xmlictxt.cxx @@ -160,10 +160,6 @@ void SAL_CALL SvXMLImportContext::characters(const OUString &rChars) mrImport.Characters( rChars ); } -void SvXMLImportContext::onDemandRescueUsefulDataFromTemporary( const SvXMLImportContext& ) -{ -} - void SvXMLImportContext::AddFirstRef() { acquire(); diff --git a/xmloff/source/core/xmlmultiimagehelper.cxx b/xmloff/source/core/xmlmultiimagehelper.cxx index 723cc5d..3b58451 100644 --- a/xmloff/source/core/xmlmultiimagehelper.cxx +++ b/xmloff/source/core/xmlmultiimagehelper.cxx @@ -120,13 +120,6 @@ SvXMLImportContextRef MultiImageImportHelper::solveMultipleImages() { SvXMLImportContext& rCandidate = *maImplContextVector[a].get(); - if(pContext.is()) - { - // #i124143# evtl. copy imported GluePoints before deprecating - // this graphic and context - pContext->onDemandRescueUsefulDataFromTemporary(rCandidate); - } - removeGraphicFromImportContext(rCandidate); } // re-insert it so that solveMultipleImages is idempotent diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx index c49c55a..4892806 100644 --- a/xmloff/source/draw/ximpshap.cxx +++ b/xmloff/source/draw/ximpshap.cxx @@ -931,74 +931,6 @@ bool SdXMLShapeContext::isPresentationShape() const return false; } -void SdXMLShapeContext::onDemandRescueUsefulDataFromTemporary( const SvXMLImportContext& rCandidate ) -{ - const SdXMLShapeContext* pCandidate = dynamic_cast< const SdXMLShapeContext* >(&rCandidate); - - if(!mxGluePoints.is() && pCandidate) - { - // try to rescue GluePoints from rCandidate to local if we not yet have GluePoints by copying them - uno::Reference< drawing::XGluePointsSupplier > xSourceSupplier( pCandidate->getShape(), uno::UNO_QUERY ); - if( !xSourceSupplier.is() ) - return; - - uno::Reference< container::XIdentifierAccess > xSourceGluePoints( xSourceSupplier->getGluePoints(), uno::UNO_QUERY ); - if( !xSourceGluePoints.is() ) - return; - - uno::Sequence< sal_Int32 > aSourceIdSequence( xSourceGluePoints->getIdentifiers() ); - const sal_Int32 nSourceCount(aSourceIdSequence.getLength()); - rtl::Reference< XMLShapeImportHelper > xSourceShapeImportHelper(const_cast< SdXMLShapeContext* >(pCandidate)->GetImport().GetShapeImport()); - - if(nSourceCount) - { - // rCandidate has GluePoints; prepare the GluePoint container for the local shape - uno::Reference< drawing::XGluePointsSupplier > xSupplier( mxShape, uno::UNO_QUERY ); - if( !xSupplier.is() ) - return; - - mxGluePoints.set( xSupplier->getGluePoints(), UNO_QUERY ); - - if( !mxGluePoints.is() ) - return; - - drawing::GluePoint2 aSourceGluePoint; - - for( sal_Int32 nSourceIndex(0); nSourceIndex < nSourceCount; nSourceIndex++ ) - { - const sal_Int32 nSourceIdentifier = aSourceIdSequence[nSourceIndex]; - - // loop over GluePoints which are UserDefined (avoid the auto mapped ones) - if((xSourceGluePoints->getByIdentifier( nSourceIdentifier ) >>= aSourceGluePoint) - && aSourceGluePoint.IsUserDefined) - { - // get original mappingID back, this is the draw:id imported with a draw:glue-point - const sal_Int32 nDestinnationId = xSourceShapeImportHelper->findGluePointMapping( - pCandidate->getShape(), - nSourceIdentifier ); - - if(-1 != nSourceIdentifier) - { - // if we got that we are able to add a copy of that GluePoint to the local - // context and xShape since we have all information that the source shape - // and context had at import time - try - { - const sal_Int32 nInternalId = mxGluePoints->insert( uno::makeAny( aSourceGluePoint ) ); - GetImport().GetShapeImport()->addGluePointMapping( mxShape, nDestinnationId, nInternalId ); - } - catch (const uno::Exception& e) - { - SAL_WARN("xmloff", "exception during setting of glue points: " << e.Message); - } - } - } - } - } - } -} - - SdXMLRectShapeContext::SdXMLRectShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx, diff --git a/xmloff/source/draw/ximpshap.hxx b/xmloff/source/draw/ximpshap.hxx index fab0c53..dc8e219 100644 --- a/xmloff/source/draw/ximpshap.hxx +++ b/xmloff/source/draw/ximpshap.hxx @@ -119,9 +119,6 @@ public: // this is called from the parent group for each unparsed attribute in the attribute list virtual void processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ); - // allow to copy evtl. useful data from another temporary import context, e.g. used to - // support multiple images - virtual void onDemandRescueUsefulDataFromTemporary( const SvXMLImportContext& rCandidate ) override; }; // draw:rect context commit dbc31190532be3d3f0d8fb313b9d7247c2eb6135 Author: Michael Stahl <mst...@redhat.com> Date: Thu Feb 9 13:08:13 2017 +0100 i#124243 sd: add unit test for ODF import of glue points on SVG shape Change-Id: Ib6434063f4dfebb5f3e180c7136b411dbf0d94d0 diff --git a/sd/qa/unit/data/odg/ooo124143-1.odg b/sd/qa/unit/data/odg/ooo124143-1.odg new file mode 100644 index 0000000..8e341cb Binary files /dev/null and b/sd/qa/unit/data/odg/ooo124143-1.odg differ diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 2f5faa8..3ef78f2 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -48,6 +48,9 @@ #include <com/sun/star/drawing/XDrawPage.hpp> #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <com/sun/star/drawing/XMasterPagesSupplier.hpp> +#include <com/sun/star/drawing/XGluePointsSupplier.hpp> +#include <com/sun/star/drawing/GluePoint2.hpp> +#include <com/sun/star/container/XIdentifierAccess.hpp> #include <com/sun/star/animations/XAnimationNodeSupplier.hpp> #include <com/sun/star/animations/XAnimationNode.hpp> #include <com/sun/star/animations/XAnimate.hpp> @@ -132,6 +135,7 @@ public: void testTdf99030(); void testTdf49561(); void testTdf103473(); + void testAoo124143(); void testTdf103567(); void testTdf103792(); void testTdf103876(); @@ -196,6 +200,7 @@ public: CPPUNIT_TEST(testTdf99030); CPPUNIT_TEST(testTdf49561); CPPUNIT_TEST(testTdf103473); + CPPUNIT_TEST(testAoo124143); CPPUNIT_TEST(testTdf103567); CPPUNIT_TEST(testTdf103792); CPPUNIT_TEST(testTdf103876); @@ -1531,6 +1536,50 @@ void SdImportTest::testTdf103473() xDocShRef->DoClose(); } +void SdImportTest::testAoo124143() +{ + sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odg/ooo124143-1.odg"), ODG); + + uno::Reference<beans::XPropertySet> const xImage(getShapeFromPage(0, 0, xDocShRef)); + uno::Reference<drawing::XGluePointsSupplier> const xGPS(xImage, uno::UNO_QUERY); + uno::Reference<container::XIdentifierAccess> const xGluePoints(xGPS->getGluePoints(), uno::UNO_QUERY); + + uno::Sequence<sal_Int32> const ids(xGluePoints->getIdentifiers()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), ids.getLength()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), ids[0]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), ids[1]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), ids[2]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), ids[3]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), ids[4]); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), ids[5]); + + // interesting ones are custom 4, 5 + drawing::GluePoint2 glue4; + xGluePoints->getByIdentifier(4) >>= glue4; + CPPUNIT_ASSERT_EQUAL( 2470, glue4.Position.X); + CPPUNIT_ASSERT_EQUAL(-1810, glue4.Position.Y); + + drawing::GluePoint2 glue5; + xGluePoints->getByIdentifier(5) >>= glue5; + CPPUNIT_ASSERT_EQUAL(-2975, glue5.Position.X); + CPPUNIT_ASSERT_EQUAL(-2165, glue5.Position.Y); + + // now check connectors + uno::Reference<beans::XPropertySet> const xEllipse(getShapeFromPage(1, 0, xDocShRef)); + uno::Reference<beans::XPropertySet> const xConn1(getShapeFromPage(2, 0, xDocShRef)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xConn1->getPropertyValue("StartGluePointIndex").get<sal_Int32>()); + CPPUNIT_ASSERT_EQUAL(xEllipse, xConn1->getPropertyValue("StartShape").get<uno::Reference<beans::XPropertySet>>()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xConn1->getPropertyValue("EndGluePointIndex").get<sal_Int32>()); + CPPUNIT_ASSERT_EQUAL(xImage, xConn1->getPropertyValue("EndShape").get<uno::Reference<beans::XPropertySet>>()); + uno::Reference<beans::XPropertySet> const xConn2(getShapeFromPage(3, 0, xDocShRef)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xConn2->getPropertyValue("StartGluePointIndex").get<sal_Int32>()); + CPPUNIT_ASSERT_EQUAL(xEllipse, xConn2->getPropertyValue("StartShape").get<uno::Reference<beans::XPropertySet>>()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xConn2->getPropertyValue("EndGluePointIndex").get<sal_Int32>()); + CPPUNIT_ASSERT_EQUAL(xImage, xConn2->getPropertyValue("EndShape").get<uno::Reference<beans::XPropertySet>>()); + + xDocShRef->DoClose(); +} + void SdImportTest::testTdf103567() { sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/tdf103567.odp"), ODP); diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx index 8060618..1932268 100644 --- a/sd/qa/unit/sdmodeltestbase.hxx +++ b/sd/qa/unit/sdmodeltestbase.hxx @@ -76,6 +76,7 @@ FileFormat aFileFormats[] = { "fodg", "OpenDocument Drawing Flat XML", "Flat XML ODF Drawing", "", FODG_FORMAT_TYPE }, { "fodp", "OpenDocument Presentation Flat XML", "Flat XML ODF Presentation", "", FODP_FORMAT_TYPE }, { "sxi", "StarOffice XML (Impress)", "OpenOffice.org 1.0 Presentation", "", SXI_FORMAT_TYPE }, + { "odg", "draw8", "draw8", "", ODP_FORMAT_TYPE }, { nullptr, nullptr, nullptr, nullptr, SfxFilterFlags::NONE } }; @@ -87,6 +88,7 @@ FileFormat aFileFormats[] = #define FODG 5 #define FODP 6 #define SXI 7 +#define ODG 8 /// Base class for filter tests loading or roundtriping a document, and asserting the document model. class SdModelTestBase : public test::BootstrapFixture, public unotest::MacrosTest @@ -204,7 +206,7 @@ protected: pTempFile = pNewTempFile.get(); } save(pShell, pFormat, *pTempFile); - if(nExportType == ODP) + if (nExportType == ODP || nExportType == ODG) { // BootstrapFixture::validate(pTempFile->GetFileName(), test::ODF); } commit ae00898f12b9087e1d9b59d9a7820d64b5501775 Author: Michael Stahl <mst...@redhat.com> Date: Thu Feb 9 11:12:26 2017 +0100 tdf#103567 xmloff: ODF import: fix more lossage on Writer frames There's another context that reads draw:frame, and it has the same problem as the one used for Impress shapes. This causes SVG images in Writer to lose contour polygons and image maps. Fix this the same way as the other context. (likely regression from 44cfc7cb6533d827fd2d6e586d92c61d7d7f7a70) Change-Id: I16cf55e68829b4e1b0841f2015d0729be0ce3725 diff --git a/sw/qa/extras/odfexport/data/tdf103567.odt b/sw/qa/extras/odfexport/data/tdf103567.odt new file mode 100644 index 0000000..cbd29bd Binary files /dev/null and b/sw/qa/extras/odfexport/data/tdf103567.odt differ diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index f53ec92..e27b2da 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -17,6 +17,7 @@ #include <com/sun/star/awt/Gradient.hpp> #include <com/sun/star/container/XIndexReplace.hpp> #include <com/sun/star/drawing/FillStyle.hpp> +#include <com/sun/star/drawing/PointSequenceSequence.hpp> #include <com/sun/star/table/ShadowFormat.hpp> #include <com/sun/star/table/XCellRange.hpp> #include <com/sun/star/text/RelOrientation.hpp> @@ -109,6 +110,41 @@ DECLARE_ODFEXPORT_TEST(testMathObjectFlatExport, "2_MathType3.docx") CPPUNIT_ASSERT_EQUAL(OUString(" size 12{2+2=4} {}"), formula2); } +DECLARE_ODFEXPORT_TEST(testTdf103567, "tdf103567.odt") +{ + uno::Reference<drawing::XShape> const xShape(getShape(1)); + + // contour wrap polygon + css::drawing::PointSequenceSequence const pointss( + getProperty<css::drawing::PointSequenceSequence>(xShape, "ContourPolyPolygon")); + CPPUNIT_ASSERT_EQUAL(1, pointss.getLength()); + // for some reason this property exists with 199 points if it wasn't + // imported, that would be a fail + CPPUNIT_ASSERT_EQUAL(5, pointss[0].getLength()); + CPPUNIT_ASSERT_EQUAL( 0, pointss[0][0].X); + CPPUNIT_ASSERT_EQUAL(2672, pointss[0][0].Y); + CPPUNIT_ASSERT_EQUAL( 0, pointss[0][1].X); + CPPUNIT_ASSERT_EQUAL(1111, pointss[0][1].Y); + CPPUNIT_ASSERT_EQUAL(2672, pointss[0][2].X); + CPPUNIT_ASSERT_EQUAL(1111, pointss[0][2].Y); + CPPUNIT_ASSERT_EQUAL(2672, pointss[0][3].X); + CPPUNIT_ASSERT_EQUAL(2672, pointss[0][3].Y); + CPPUNIT_ASSERT_EQUAL( 0, pointss[0][4].X); + CPPUNIT_ASSERT_EQUAL(2672, pointss[0][4].Y); + + // image map, one rectangle + uno::Reference<container::XIndexContainer> const xImageMap( + getProperty<uno::Reference<container::XIndexContainer>>(xShape, "ImageMap")); + + uno::Reference<beans::XPropertySet> const xEntry(xImageMap->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/"), getProperty<OUString>(xEntry, "URL")); + awt::Rectangle const rect(getProperty<awt::Rectangle>(xEntry, "Boundary")); + CPPUNIT_ASSERT_EQUAL( 726, rect.X); + CPPUNIT_ASSERT_EQUAL(1718, rect.Y); + CPPUNIT_ASSERT_EQUAL(1347, rect.Width); + CPPUNIT_ASSERT_EQUAL( 408, rect.Height); +} + DECLARE_ODFEXPORT_TEST(testFramebackgrounds, "framebackgrounds.odt") { //Counting the Number of Frames and checking with the expected count diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx index 4d7a03d..20ee384 100644 --- a/xmloff/source/text/XMLTextFrameContext.cxx +++ b/xmloff/source/text/XMLTextFrameContext.cxx @@ -1503,6 +1503,10 @@ SvXMLImportContext *XMLTextFrameContext::CreateChildContext( { if( IsXMLToken( rLocalName, XML_TITLE ) ) { + if (getSupportsMultipleContents()) + { // tdf#103567 ensure props are set on surviving shape + m_xImplContext = solveMultipleImages(); + } pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(), p_nPrefix, rLocalName, @@ -1510,6 +1514,10 @@ SvXMLImportContext *XMLTextFrameContext::CreateChildContext( } else if ( IsXMLToken( rLocalName, XML_DESC ) ) { + if (getSupportsMultipleContents()) + { // tdf#103567 ensure props are set on surviving shape + m_xImplContext = solveMultipleImages(); + } pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(), p_nPrefix, rLocalName, @@ -1522,24 +1530,40 @@ SvXMLImportContext *XMLTextFrameContext::CreateChildContext( Reference < XPropertySet > xPropSet; if( IsXMLToken( rLocalName, XML_CONTOUR_POLYGON ) ) { + if (getSupportsMultipleContents()) + { // tdf#103567 ensure props are set on surviving shape + m_xImplContext = solveMultipleImages(); + } if( CreateIfNotThere( xPropSet ) ) pContext = new XMLTextFrameContourContext_Impl( GetImport(), p_nPrefix, rLocalName, xAttrList, xPropSet, false ); } else if( IsXMLToken( rLocalName, XML_CONTOUR_PATH ) ) { + if (getSupportsMultipleContents()) + { // tdf#103567 ensure props are set on surviving shape + m_xImplContext = solveMultipleImages(); + } if( CreateIfNotThere( xPropSet ) ) pContext = new XMLTextFrameContourContext_Impl( GetImport(), p_nPrefix, rLocalName, xAttrList, xPropSet, true ); } else if( IsXMLToken( rLocalName, XML_IMAGE_MAP ) ) { + if (getSupportsMultipleContents()) + { // tdf#103567 ensure props are set on surviving shape + m_xImplContext = solveMultipleImages(); + } if( CreateIfNotThere( xPropSet ) ) pContext = new XMLImageMapContext( GetImport(), p_nPrefix, rLocalName, xPropSet ); } } else if( (XML_NAMESPACE_OFFICE == p_nPrefix) && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) ) { + if (getSupportsMultipleContents()) + { // tdf#103567 ensure props are set on surviving shape + m_xImplContext = solveMultipleImages(); + } // do we still have the frame object? Reference < XPropertySet > xPropSet; if( CreateIfNotThere( xPropSet ) ) @@ -1558,6 +1582,11 @@ SvXMLImportContext *XMLTextFrameContext::CreateChildContext( else if( p_nPrefix == XML_NAMESPACE_SVG && // #i68101# (IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) ) { + if (getSupportsMultipleContents()) + { // tdf#103567 ensure props are set on surviving shape + // note: no more draw:image can be added once we get here + m_xImplContext = solveMultipleImages(); + } pContext = m_xImplContext->CreateChildContext( p_nPrefix, rLocalName, xAttrList ); } else commit 3ce68a2a7cc0fe9fe83dccd0019cd32d6518c16e Author: Michael Stahl <mst...@redhat.com> Date: Wed Feb 8 22:28:09 2017 +0100 xmloff: fix this CreateChildContext to be properly ignorant Change-Id: I0b5cc271768ba29d039abb05408ccbd686c18544 diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx index 9abdacf..c49c55a 100644 --- a/xmloff/source/draw/ximpshap.cxx +++ b/xmloff/source/draw/ximpshap.cxx @@ -3505,7 +3505,7 @@ SvXMLImportContext *SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPref if( pPluginContext && pPluginContext->getMimeType() == "model/vnd.gltf+json" ) { mxImplContext = nullptr; - return this; + return new SvXMLImportContext(GetImport(), nPrefix, rLocalName); } } #endif _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits