summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2012-10-23 10:40:47 +0100
committerMichael Meeks <michael.meeks@suse.com>2012-10-23 13:49:55 +0100
commit1d16f59023b1b19d01ca69b8c9735be6d3baf5d9 (patch)
treea68521eb62faa92a0fee2c423bace8fa2d795049 /svx
parent0a6da5e194e22a7b337896bf81e1996fb60b9f88 (diff)
add cache to avoid excessive repeated UNO peer creation for customshapes
Change-Id: I30366e1a4d0648fc617c0cc20f61d3d54dd66d48
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svdoashp.cxx25
1 files changed, 24 insertions, 1 deletions
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 4236d4bab00d..7020d6b9efa5 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -97,6 +97,12 @@ using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::drawing;
+// A simple one item cache really helps here ...
+namespace {
+ static const SdrObjCustomShape *g_pLastCacheShape;
+ static Reference< XCustomShapeEngine > g_xLastCacheShape;
+}
+
static void lcl_ShapeSegmentFromBinary( EnhancedCustomShapeSegment& rSegInfo, sal_uInt16 nSDat )
{
switch( nSDat >> 8 )
@@ -402,6 +408,11 @@ SdrObject* ImpCreateShadowObjectClone(const SdrObject& rOriginal, const SfxItemS
Reference< XCustomShapeEngine > SdrObjCustomShape::GetCustomShapeEngine( const SdrObjCustomShape* pCustomShape )
{
Reference< XCustomShapeEngine > xCustomShapeEngine;
+
+ // We get dozens of back-to-back calls for the same shape
+ if( pCustomShape == g_pLastCacheShape )
+ return xCustomShapeEngine;
+
String aEngine(((SdrCustomShapeEngineItem&)pCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_ENGINE )).GetValue());
if ( !aEngine.Len() )
aEngine = String( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.drawing.EnhancedCustomShapeEngine" ) );
@@ -423,8 +434,13 @@ Reference< XCustomShapeEngine > SdrObjCustomShape::GetCustomShapeEngine( const S
xCustomShapeEngine = Reference< XCustomShapeEngine >( xInterface, UNO_QUERY );
}
}
+
+ g_pLastCacheShape = pCustomShape;
+ g_xLastCacheShape = xCustomShapeEngine;
+
return xCustomShapeEngine;
}
+
const SdrObject* SdrObjCustomShape::GetSdrObjectFromCustomShape() const
{
if ( !mXRenderedCustomShape.is() )
@@ -556,10 +572,12 @@ double SdrObjCustomShape::GetExtraTextRotation( const bool bPreRotation ) const
*pAny >>= fExtraTextRotateAngle;
return fExtraTextRotateAngle;
}
+
sal_Bool SdrObjCustomShape::GetTextBounds( Rectangle& rTextBound ) const
{
sal_Bool bRet = sal_False;
- Reference< XCustomShapeEngine > xCustomShapeEngine( GetCustomShapeEngine( this ) ); // a candidate for being cached
+
+ Reference< XCustomShapeEngine > xCustomShapeEngine( GetCustomShapeEngine( this ) );
if ( xCustomShapeEngine.is() )
{
awt::Rectangle aR( xCustomShapeEngine->getTextBounds() );
@@ -847,6 +865,11 @@ SdrObjCustomShape::SdrObjCustomShape() :
SdrObjCustomShape::~SdrObjCustomShape()
{
+ if (this == g_pLastCacheShape)
+ {
+ g_pLastCacheShape = NULL;
+ g_xLastCacheShape.clear();
+ }
// delete buffered display geometry
InvalidateRenderGeometry();
}