diff options
author | David Tardon <dtardon@redhat.com> | 2013-05-03 06:15:30 +0200 |
---|---|---|
committer | Thorsten Behrens <tbehrens@suse.com> | 2013-05-15 11:23:00 +0200 |
commit | 7f8ef6795e57713c802d74b4532f9c0addd9b479 (patch) | |
tree | 34f059d8f4d5460ad9775ab54bad84980964da5f /xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx | |
parent | 5ce2944df838fca58808c34dd035a7318dfc1b90 (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/core/unointerfacetouniqueidentifiermapper.cxx')
-rw-r--r-- | xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx b/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx index 4b1d1336b8c0..b76b8a849e25 100644 --- a/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx +++ b/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <algorithm> #include <xmloff/unointerfacetouniqueidentifiermapper.hxx> @@ -72,7 +73,7 @@ bool UnoInterfaceToUniqueIdentifierMapper::registerReference( const OUString& rI { return rIdentifier != (*aIter).first; } - else if( findIdentifier( rIdentifier, aIter ) ) + else if( findIdentifier( rIdentifier, aIter ) || findReserved( rIdentifier ) ) { return false; } @@ -174,6 +175,44 @@ bool UnoInterfaceToUniqueIdentifierMapper::findIdentifier( const OUString& rIden return rIter != maEntries.end(); } +bool UnoInterfaceToUniqueIdentifierMapper::reserveIdentifier( const rtl::OUString& rIdentifier ) +{ + if ( findReserved( rIdentifier ) ) + return false; + + maReserved.push_back( rIdentifier ); + return true; +} + +bool UnoInterfaceToUniqueIdentifierMapper::registerReservedReference( + const rtl::OUString& rIdentifier, + const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& rInterface ) +{ + Reserved_t::const_iterator aIt; + if ( !findReserved( rIdentifier, aIt ) ) + return false; + + Reserved_t::iterator aRemoveIt( maReserved.begin() + ( aIt - maReserved.begin() ) ); + maReserved.erase( aRemoveIt ); + registerReference( rIdentifier, rInterface ); + + return true; +} + +bool UnoInterfaceToUniqueIdentifierMapper::findReserved( const OUString& rIdentifier ) const +{ + Reserved_t::const_iterator aDummy; + return findReserved( rIdentifier, aDummy ); +} + +bool UnoInterfaceToUniqueIdentifierMapper::findReserved( + const OUString& rIdentifier, + Reserved_t::const_iterator& rIter ) const +{ + rIter = std::find( maReserved.begin(), maReserved.end(), rIdentifier ); + return rIter != maReserved.end(); +} + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |