diff options
author | David Tardon <dtardon@redhat.com> | 2013-05-03 06:15:30 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2013-05-03 10:29:47 +0200 |
commit | 30b248dfe5bfb8a0649e36f22c943b3feb2f1385 (patch) | |
tree | 25a4f5798b08c3d9c93b43924a0779f17cb17131 /xmloff/source/draw | |
parent | 9918757003ae043ad53a9c3fcea2733696f6eb5c (diff) |
fdo#60075 open drawings with connector attached to SVG
This problem arises when there is a connector attached to draw:frame
element with multiple draw:image elements in it. The import code expects
that they are different representations of the same image (I have not
found if this is specified in ODF), so it only selects the most
"suitable" for import. To do that, it imports them all and then removes
all but the selected one. The image import context,
SdXMLGraphicObjectShapeContext, shares the parent frame's attributes,
which means that all the images in a frame have got the same ID. in
SdXMLGraphicObjectShapeContext::AddShape, the created css::draw::XShape
is registered with its ID... That means that anything that refers to the
frame's ID, like a draw:connector, will always get the _first_ image in
the frame.
Solution is to extend comphelper::UnoInterfaceToUniqueIdentifierMapper
to allow reserving an identifier and setting an interface for it later.
That way, SdXMLFrameShapeContext can reserve its own ID before it starts
importing the first draw:image, and then set the selected XShape at the
end.
Change-Id: I2e11cfd38e1e3534df2b3c01d85da0d755a266c3
Diffstat (limited to 'xmloff/source/draw')
-rw-r--r-- | xmloff/source/draw/ximpshap.cxx | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx index 9074b5959647..81c91a18fdf2 100644 --- a/xmloff/source/draw/ximpshap.cxx +++ b/xmloff/source/draw/ximpshap.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <cassert> + #include <tools/debug.hxx> #include <com/sun/star/document/XEventsSupplier.hpp> #include <com/sun/star/container/XNameReplace.hpp> @@ -3453,6 +3455,9 @@ SvXMLImportContext *SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPref if(getSupportsMultipleContents() && dynamic_cast< SdXMLGraphicObjectShapeContext* >(pContext)) { + if ( !maShapeId.isEmpty() ) + GetImport().getInterfaceToIdentifierMapper().reserveIdentifier( maShapeId ); + addContent(*mxImplContext); } } @@ -3526,8 +3531,15 @@ void SdXMLFrameShapeContext::StartElement(const uno::Reference< xml::sax::XAttri void SdXMLFrameShapeContext::EndElement() { - /// solve if multiple image child contexts were imported - solveMultipleImages(); + // solve if multiple image child contexts were imported + const SvXMLImportContext* const pSelectedContext(solveMultipleImages()); + const SdXMLGraphicObjectShapeContext* pShapeContext( dynamic_cast<const SdXMLGraphicObjectShapeContext*>( pSelectedContext ) ); + if ( pShapeContext ) + { + assert( mxImplContext.Is() ); + const uno::Reference< uno::XInterface > xShape( pShapeContext->getShape() ); + GetImport().getInterfaceToIdentifierMapper().registerReservedReference( maShapeId, xShape ); + } if( !mxImplContext.Is() ) { @@ -3588,10 +3600,25 @@ void SdXMLFrameShapeContext::EndElement() SdXMLShapeContext::EndElement(); } -void SdXMLFrameShapeContext::processAttribute( sal_uInt16, - const OUString&, const OUString& ) +void SdXMLFrameShapeContext::processAttribute( sal_uInt16 nPrefix, + const OUString& rLocalName, const OUString& rValue ) { - // ignore + bool bId( false ); + + switch ( nPrefix ) + { + case XML_NAMESPACE_DRAW : + case XML_NAMESPACE_DRAW_EXT : + bId = IsXMLToken( rLocalName, XML_ID ); + break; + case XML_NAMESPACE_NONE : + case XML_NAMESPACE_XML : + bId = IsXMLToken( rLocalName, XML_ID ); + break; + } + + if ( bId ) + SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); } TYPEINIT1( SdXMLCustomShapeContext, SdXMLShapeContext ); |