summaryrefslogtreecommitdiff
path: root/xmloff/source/draw/ximpshap.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'xmloff/source/draw/ximpshap.cxx')
-rw-r--r--xmloff/source/draw/ximpshap.cxx67
1 files changed, 67 insertions, 0 deletions
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index 3e51b1287a3d..80e2df91c122 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -917,6 +917,73 @@ sal_Bool SdXMLShapeContext::isPresentationShape() const
return sal_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());
+ UniReference< 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 = uno::Reference< container::XIdentifierContainer >::query( xSupplier->getGluePoints() );
+
+ 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);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
TYPEINIT1( SdXMLRectShapeContext, SdXMLShapeContext );
SdXMLRectShapeContext::SdXMLRectShapeContext(