[Libreoffice-commits] .: Branch 'libreoffice-4-0' - 2 commits - svx/inc svx/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Dec 18 23:05:14 PST 2012


 svx/inc/svx/svdoashp.hxx       |    5 ++++-
 svx/inc/svx/svdobj.hxx         |   21 +++++++++++++++++++--
 svx/source/svdraw/svdoashp.cxx |   36 +++++++++++++++++++++++++-----------
 3 files changed, 48 insertions(+), 14 deletions(-)

New commits:
commit 75118d2f9ebdf96250d3a4c78b695085c3527e4e
Author: David Tardon <dtardon at redhat.com>
Date:   Tue Dec 18 15:24:28 2012 +0100

    fdo#56267, fdo#56980 propagate shape change to subclasses
    
    It turns out (as witnessed by fdo#56267) that my fix for fdo#56980 only
    cured the symptom, not the cause. The real problem is caused by the
    following sequence of events during ODF import:
    
    1) an SvxCustomShape object is created (XShape iface)
    2) an SdrObjCustomShape object is created for the SvxCustomShape, but it
       is not associated with it (yet)
    3) another SvxCustomShape object is created internally by the
       SdrObjCustomShape and they are associated
    4) an EnhancedCustomShapeEngine is created for this SvxCustomShape by
       SdrObjCustomShape
    5) the SvxCustomShape from point 1 is set to the SdrObjCustomShape
    
    At some point (I did not follow this explicitly) the SvxCustomShape
    cached by the EnhancedCustomShapeEngine loses its (weak) reference to
    the SdrObjCustomShape. This leaves it gutted and all subsequent calls to
    render() return an empty XShape.
    
    The solution is simple: let SdrObjCustomShape know that the associated
    UNO shape has changed, so it can drop the custom shape engine.
    
    Change-Id: I267838ea4857dfcd646f40c811f3ae572237a1e6
    (cherry picked from commit 7fec8dfcaca4efc92516f9af51a3157f1a11ccd7)
    
    Signed-off-by: David Tardon <dtardon at redhat.com>

diff --git a/svx/inc/svx/svdoashp.hxx b/svx/inc/svx/svdoashp.hxx
index 987132f..aae1f51 100644
--- a/svx/inc/svx/svdoashp.hxx
+++ b/svx/inc/svx/svdoashp.hxx
@@ -83,6 +83,7 @@ private:
 
 protected:
     virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact();
+    virtual void impl_setUnoShape(const com::sun::star::uno::Reference<com::sun::star::uno::XInterface>& rxUnoShape);
 
 public:
     virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties();
diff --git a/svx/inc/svx/svdobj.hxx b/svx/inc/svx/svdobj.hxx
index 656a218..8241ed4 100644
--- a/svx/inc/svx/svdobj.hxx
+++ b/svx/inc/svx/svdobj.hxx
@@ -989,7 +989,14 @@ public:
 
     static SdrObject* getSdrObjectFromXShape( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xInt );
 
-    // setting the UNO representation is allowed for the UNO representation itself only!
+    /** Sets a new UNO representation of the shape
+      *
+      * This is only a public interface function. The actual work is
+      * done by impl_setUnoShape().
+      *
+      * Calling this function is only allowed for the UNO representation
+      * itself!
+      */
     void setUnoShape(
             const com::sun::star::uno::Reference<
                 com::sun::star::uno::XInterface>& _rxUnoShape);
@@ -1045,7 +1052,17 @@ public:
     void SetBLIPSizeRectangle( const Rectangle& aRect );
 
 protected:
-    void    impl_setUnoShape( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxUnoShape );
+    /** Sets a new UNO shape
+      *
+      * The default implementation of this function sets the new UNO
+      * shape. Derived classes should override the function to handle
+      * any other actions that are needed when the shape is being
+      * changed.
+      *
+      * The implementation _must_ call the same method of its parent
+      * class (preferably as the first step)!
+      */
+    virtual void    impl_setUnoShape( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxUnoShape );
 
     /**
      Helper function for reimplementing Clone().
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 61b9002..68ca861 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -3211,9 +3211,17 @@ bool SdrObjCustomShape::doConstructOrthogonal(const ::rtl::OUString& rName)
 void SdrObjCustomShape::InvalidateRenderGeometry()
 {
     mXRenderedCustomShape = 0L;
-    mxCustomShapeEngine = 0L;
     SdrObject::Free( mpLastShadowGeometry );
     mpLastShadowGeometry = 0L;
 }
 
+void SdrObjCustomShape::impl_setUnoShape(const uno::Reference<uno::XInterface>& rxUnoShape)
+{
+    SdrTextObj::impl_setUnoShape(rxUnoShape);
+
+    // The shape engine is created with _current_ shape. This means we
+    // _must_ reset it when the shape changes.
+    mxCustomShapeEngine.set(0);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 756159812e267b6d1a81dac9d960b9c9eedbb668
Author: David Tardon <dtardon at redhat.com>
Date:   Tue Dec 18 08:00:17 2012 +0100

    Revert "fdo#58399 - revert attempts to untangle and accelerate this mess."
    
    This reverts commit bb3f2900a867fdcb6df916fff58199b4ce94dd05.
    (cherry picked from commit c3fed9f4ea354427c205bd407fcfa3d04093ba50)
    
    Signed-off-by: David Tardon <dtardon at redhat.com>

diff --git a/svx/inc/svx/svdoashp.hxx b/svx/inc/svx/svdoashp.hxx
index 847ebf1..987132f 100644
--- a/svx/inc/svx/svdoashp.hxx
+++ b/svx/inc/svx/svdoashp.hxx
@@ -92,10 +92,12 @@ public:
 
     com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mXRenderedCustomShape;
 
+    mutable com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeEngine > mxCustomShapeEngine;
+
     // #i37011# render geometry shadow
     SdrObject*                                          mpLastShadowGeometry;
 
-    static com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeEngine > GetCustomShapeEngine( const SdrObjCustomShape* pCustomShape );
+    com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeEngine > GetCustomShapeEngine() const;
 
 //  SVX_DLLPRIVATE com::sun::star::uno::Sequence< com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeHandle > >
 //      SdrObjCustomShape::GetInteraction( const SdrObjCustomShape* pCustomShape ) const;
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index abce04a..61b9002 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -87,7 +87,6 @@ using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::beans;
 using namespace ::com::sun::star::drawing;
 
-
 static void lcl_ShapeSegmentFromBinary( EnhancedCustomShapeSegment& rSegInfo, sal_uInt16 nSDat )
 {
     switch( nSDat >> 8 )
@@ -390,16 +389,18 @@ SdrObject* ImpCreateShadowObjectClone(const SdrObject& rOriginal, const SfxItemS
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
-Reference< XCustomShapeEngine > SdrObjCustomShape::GetCustomShapeEngine( const SdrObjCustomShape* pCustomShape )
+Reference< XCustomShapeEngine > SdrObjCustomShape::GetCustomShapeEngine() const
 {
-    Reference< XCustomShapeEngine > xCustomShapeEngine;
-    String aEngine(((SdrCustomShapeEngineItem&)pCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_ENGINE )).GetValue());
+    if (mxCustomShapeEngine.is())
+        return mxCustomShapeEngine;
+
+    String aEngine(((SdrCustomShapeEngineItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_ENGINE )).GetValue());
     if ( !aEngine.Len() )
         aEngine = String( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.drawing.EnhancedCustomShapeEngine" ) );
 
     Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
 
-    Reference< XShape > aXShape = GetXShapeForSdrObject( (SdrObjCustomShape*)pCustomShape );
+    Reference< XShape > aXShape = GetXShapeForSdrObject(const_cast<SdrObjCustomShape*>(this));
     if ( aXShape.is() )
     {
         if ( aEngine.Len() && xFactory.is() )
@@ -411,16 +412,18 @@ Reference< XCustomShapeEngine > SdrObjCustomShape::GetCustomShapeEngine( const S
             aArgument[ 0 ] <<= aPropValues;
             Reference< XInterface > xInterface( xFactory->createInstanceWithArguments( aEngine, aArgument ) );
             if ( xInterface.is() )
-                xCustomShapeEngine = Reference< XCustomShapeEngine >( xInterface, UNO_QUERY );
+                mxCustomShapeEngine = Reference< XCustomShapeEngine >( xInterface, UNO_QUERY );
         }
     }
-    return xCustomShapeEngine;
+
+    return mxCustomShapeEngine;
 }
+
 const SdrObject* SdrObjCustomShape::GetSdrObjectFromCustomShape() const
 {
     if ( !mXRenderedCustomShape.is() )
     {
-        Reference< XCustomShapeEngine > xCustomShapeEngine( GetCustomShapeEngine( this ) );
+        Reference< XCustomShapeEngine > xCustomShapeEngine( GetCustomShapeEngine() );
         if ( xCustomShapeEngine.is() )
             ((SdrObjCustomShape*)this)->mXRenderedCustomShape = xCustomShapeEngine->render();
     }
@@ -547,10 +550,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() );
     if ( xCustomShapeEngine.is() )
     {
         awt::Rectangle aR( xCustomShapeEngine->getTextBounds() );
@@ -565,7 +570,7 @@ sal_Bool SdrObjCustomShape::GetTextBounds( Rectangle& rTextBound ) const
 basegfx::B2DPolyPolygon SdrObjCustomShape::GetLineGeometry( const SdrObjCustomShape* pCustomShape, const sal_Bool bBezierAllowed )
 {
     basegfx::B2DPolyPolygon aRetval;
-    Reference< XCustomShapeEngine > xCustomShapeEngine( GetCustomShapeEngine( pCustomShape ) );
+    Reference< XCustomShapeEngine > xCustomShapeEngine( pCustomShape->GetCustomShapeEngine() );
     if ( xCustomShapeEngine.is() )
     {
         com::sun::star::drawing::PolyPolygonBezierCoords aBezierCoords = xCustomShapeEngine->getLineGeometry();
@@ -589,7 +594,7 @@ std::vector< SdrCustomShapeInteraction > SdrObjCustomShape::GetInteractionHandle
     std::vector< SdrCustomShapeInteraction > xRet;
     try
     {
-        Reference< XCustomShapeEngine > xCustomShapeEngine( GetCustomShapeEngine( pCustomShape ) );
+        Reference< XCustomShapeEngine > xCustomShapeEngine( pCustomShape->GetCustomShapeEngine() );
         if ( xCustomShapeEngine.is() )
         {
             int i;
@@ -3206,6 +3211,7 @@ bool SdrObjCustomShape::doConstructOrthogonal(const ::rtl::OUString& rName)
 void SdrObjCustomShape::InvalidateRenderGeometry()
 {
     mXRenderedCustomShape = 0L;
+    mxCustomShapeEngine = 0L;
     SdrObject::Free( mpLastShadowGeometry );
     mpLastShadowGeometry = 0L;
 }


More information about the Libreoffice-commits mailing list