summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2012-10-22 13:26:47 +0100
committerMichael Meeks <michael.meeks@suse.com>2012-10-22 13:29:35 +0100
commitcfacb2d111b5319f5e5c494e1cf6426277e88b59 (patch)
tree3c456459664461ba738d217513bdc0e5ae6b85bc /xmloff
parentd8feea6c28540797b4959e66bdc9f38209f7c512 (diff)
accelerate shape import & export by more sensible XInterface handling.
Instead of converting both XInterfaces (again) to a root XInterface inside the Reference == operator - we ensure that we have done this on insertion, and do a fast pointer compare; saves ~40% of load time on some docs, and more on save. Change-Id: Ic3c97dd731ffb3854ebc135f416f6032d87b9d15
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx27
-rw-r--r--xmloff/source/draw/ximpshap.cxx2
2 files changed, 23 insertions, 6 deletions
diff --git a/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx b/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx
index 4e9a71549690..4b1d1336b8c0 100644
--- a/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx
+++ b/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx
@@ -20,6 +20,7 @@
#include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
+using namespace ::com::sun::star;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::XInterface;
using ::rtl::OUString;
@@ -37,8 +38,12 @@ UnoInterfaceToUniqueIdentifierMapper::UnoInterfaceToUniqueIdentifierMapper()
*/
const OUString& UnoInterfaceToUniqueIdentifierMapper::registerReference( const Reference< XInterface >& rInterface )
{
+ // Be certain that the references we store in our table are to the
+ // leading / primary XInterface - cf. findReference
+ uno::Reference< uno::XInterface > xRef( rInterface, uno::UNO_QUERY );
+
IdMap_t::const_iterator aIter;
- if( findReference( rInterface, aIter ) )
+ if( findReference( xRef, aIter ) )
{
return (*aIter).first;
}
@@ -46,7 +51,7 @@ const OUString& UnoInterfaceToUniqueIdentifierMapper::registerReference( const R
{
OUString aId( "id" );
aId += OUString::valueOf( mnNextId++ );
- return (*maEntries.insert( IdMap_t::value_type( aId, rInterface ) ).first).first;
+ return (*maEntries.insert( IdMap_t::value_type( aId, xRef ) ).first).first;
}
}
@@ -58,7 +63,12 @@ const OUString& UnoInterfaceToUniqueIdentifierMapper::registerReference( const R
bool UnoInterfaceToUniqueIdentifierMapper::registerReference( const OUString& rIdentifier, const Reference< XInterface >& rInterface )
{
IdMap_t::const_iterator aIter;
- if( findReference( rInterface, aIter ) )
+
+ // Be certain that the references we store in our table are to the
+ // leading / primary XInterface - cf. findReference
+ uno::Reference< uno::XInterface > xRef( rInterface, uno::UNO_QUERY );
+
+ if( findReference( xRef, aIter ) )
{
return rIdentifier != (*aIter).first;
}
@@ -68,7 +78,7 @@ bool UnoInterfaceToUniqueIdentifierMapper::registerReference( const OUString& rI
}
else
{
- maEntries.insert( IdMap_t::value_type( rIdentifier, rInterface ) );
+ maEntries.insert( IdMap_t::value_type( rIdentifier, xRef ) );
// see if this is a reference like something we would generate in the future
const sal_Unicode *p = rIdentifier.getStr();
@@ -138,11 +148,18 @@ const Reference< XInterface >& UnoInterfaceToUniqueIdentifierMapper::getReferenc
bool UnoInterfaceToUniqueIdentifierMapper::findReference( const Reference< XInterface >& rInterface, IdMap_t::const_iterator& rIter ) const
{
+ uno::Reference< uno::XInterface > xRef( rInterface, uno::UNO_QUERY );
+
rIter = maEntries.begin();
+
const IdMap_t::const_iterator aEnd( maEntries.end() );
while( rIter != aEnd )
{
- if( (*rIter).second == rInterface )
+ // The Reference == operator, does a repeated queryInterface on
+ // this to ensure we got the right XInterface base-class. However,
+ // we can be sure that this has been done already by the time we
+ // get to here.
+ if( (*rIter).second.get() == xRef.get() )
return true;
rIter++;
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index a7434c088033..989892d75051 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -470,7 +470,7 @@ void SdXMLShapeContext::AddShape(uno::Reference< drawing::XShape >& xShape)
if( !maShapeId.isEmpty() )
{
- uno::Reference< uno::XInterface > xRef( xShape, uno::UNO_QUERY );
+ uno::Reference< uno::XInterface > xRef( static_cast<uno::XInterface *>(xShape.get()) );
GetImport().getInterfaceToIdentifierMapper().registerReference( maShapeId, xRef );
}