summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/xmloff/unointerfacetouniqueidentifiermapper.hxx17
-rw-r--r--include/xmloff/xmlmultiimagehelper.hxx6
-rw-r--r--xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx41
-rw-r--r--xmloff/source/core/xmlmultiimagehelper.cxx6
-rw-r--r--xmloff/source/draw/ximpshap.cxx37
5 files changed, 98 insertions, 9 deletions
diff --git a/include/xmloff/unointerfacetouniqueidentifiermapper.hxx b/include/xmloff/unointerfacetouniqueidentifiermapper.hxx
index e538cbe176e0..591929612301 100644
--- a/include/xmloff/unointerfacetouniqueidentifiermapper.hxx
+++ b/include/xmloff/unointerfacetouniqueidentifiermapper.hxx
@@ -24,6 +24,7 @@
#include "xmloff/dllapi.h"
#include "sal/types.h"
+#include <deque>
#include <map>
#include <rtl/ustring.hxx>
#include <com/sun/star/uno/XInterface.hpp>
@@ -35,6 +36,8 @@ typedef ::std::map< OUString, const ::com::sun::star::uno::Reference< ::com::sun
class XMLOFF_DLLPUBLIC UnoInterfaceToUniqueIdentifierMapper
{
+ typedef std::deque< rtl::OUString > Reserved_t;
+
public:
UnoInterfaceToUniqueIdentifierMapper();
@@ -50,6 +53,17 @@ public:
*/
bool registerReference( const OUString& rIdentifier, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rInterface );
+ /** reserves an identifier for later registration.
+
+ @returns
+ false, if the identifier already exists
+ */
+ bool reserveIdentifier( const rtl::OUString& rIdentifier );
+
+ /** registers the given uno object with reserved identifier.
+ */
+ bool registerReservedReference( const rtl::OUString& rIdentifier, const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& rInterface );
+
/** @returns
the identifier for the given uno object. If this uno object is not already
registered, an empty string is returned
@@ -65,9 +79,12 @@ public:
private:
bool findReference( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rInterface, IdMap_t::const_iterator& rIter ) const;
bool findIdentifier( const OUString& rIdentifier, IdMap_t::const_iterator& rIter ) const;
+ bool findReserved( const OUString& rIdentifier ) const;
+ bool findReserved( const OUString& rIdentifier, Reserved_t::const_iterator& rIter ) const;
IdMap_t maEntries;
sal_Int32 mnNextId;
+ Reserved_t maReserved;
};
}
diff --git a/include/xmloff/xmlmultiimagehelper.hxx b/include/xmloff/xmlmultiimagehelper.hxx
index cb0a290b1bbd..bbe9ce121477 100644
--- a/include/xmloff/xmlmultiimagehelper.hxx
+++ b/include/xmloff/xmlmultiimagehelper.hxx
@@ -41,8 +41,10 @@ public:
virtual ~multiImageImportHelper();
/// solve multiple imported images. The most valuable one is choosen,
- /// see imlementation for evtl. changing weights and/or adding filetypes
- void solveMultipleImages();
+ /// see imlementation for evtl. changing weights and/or adding filetypes.
+ ///
+ /// @returns import context of the selected image
+ const SvXMLImportContext* solveMultipleImages();
/// add a content to the remembered image import contexts
void addContent(const SvXMLImportContext& rSvXMLImportContext);
diff --git a/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx b/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx
index 87e54d711e21..4b2b9db6f141 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>
@@ -71,7 +72,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;
}
@@ -173,6 +174,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: */
diff --git a/xmloff/source/core/xmlmultiimagehelper.cxx b/xmloff/source/core/xmlmultiimagehelper.cxx
index b1ad7bb1ae19..e33c4438ee1e 100644
--- a/xmloff/source/core/xmlmultiimagehelper.cxx
+++ b/xmloff/source/core/xmlmultiimagehelper.cxx
@@ -89,8 +89,9 @@ multiImageImportHelper::~multiImageImportHelper()
}
}
-void multiImageImportHelper::solveMultipleImages()
+const SvXMLImportContext* multiImageImportHelper::solveMultipleImages()
{
+ const SvXMLImportContext* pContext(0);
if(maImplContextVector.size() > 1)
{
// multiple child contexts were imported, decide which is the most valuable one
@@ -118,6 +119,7 @@ void multiImageImportHelper::solveMultipleImages()
// Take out the most valuable one
const std::vector< SvXMLImportContextRef* >::iterator aRemove(maImplContextVector.begin() + nIndexOfPreferred);
+ pContext = **aRemove;
delete *aRemove;
maImplContextVector.erase(aRemove);
@@ -127,6 +129,8 @@ void multiImageImportHelper::solveMultipleImages()
removeGraphicFromImportContext(**maImplContextVector[a]);
}
}
+
+ return pContext;
}
void multiImageImportHelper::addContent(const SvXMLImportContext& rSvXMLImportContext)
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 );