[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - 2 commits - include/svx reportdesign/inc reportdesign/source svx/source wizards/com

David Tardon dtardon at redhat.com
Fri May 24 07:23:42 PDT 2013


 include/svx/svdobj.hxx                                         |   10 ++++
 reportdesign/inc/RptObject.hxx                                 |    6 ++
 reportdesign/source/core/sdr/RptObject.cxx                     |   24 ++++++++++
 svx/source/svdraw/svdobj.cxx                                   |   19 +++++++
 svx/source/unodraw/unopage.cxx                                 |   14 +++++
 wizards/com/sun/star/wizards/web/LogTaskListener.py            |    2 
 wizards/com/sun/star/wizards/web/export/ImpressHTMLExporter.py |    6 +-
 7 files changed, 74 insertions(+), 7 deletions(-)

New commits:
commit 1a4893d7620e06c09a19e97887355b46aee4c2c6
Author: David Tardon <dtardon at redhat.com>
Date:   Fri May 24 09:54:20 2013 +0200

    fix syntax errors in python wizards
    
    Change-Id: Ia237a0095c2cc783f52224bdde5d525baafacc52
    (cherry picked from commit cdad97557a729ecbbe0236f7998647c5249a005f)
    
    Signed-off-by: David Tardon <dtardon at redhat.com>

diff --git a/wizards/com/sun/star/wizards/web/LogTaskListener.py b/wizards/com/sun/star/wizards/web/LogTaskListener.py
index 13b7e59..a1fba5f 100644
--- a/wizards/com/sun/star/wizards/web/LogTaskListener.py
+++ b/wizards/com/sun/star/wizards/web/LogTaskListener.py
@@ -35,7 +35,7 @@ class LogTaskListener(TaskListener, ErrorHandler):
         out.println("TASK " + te.getTask().getTaskName() + " FINISHED: " + te.getTask().getSuccessfull() + "/" + te.getTask().getMax() + "Succeeded.")
 
     #@see com.sun.star.wizards.web.status.TaskListener#taskStatusChanged(com.sun.star.wizards.web.status.TaskEvent)
-    def taskStatusChanged(te)
+    def taskStatusChanged(te):
         out.println("TASK " + te.getTask().getTaskName() + " status : " + te.getTask().getSuccessfull() + "(+" + te.getTask().getFailed() + ")/" + te.getTask().getMax())
 
     #@see com.sun.star.wizards.web.status.TaskListener#subtaskNameChanged(com.sun.star.wizards.web.status.TaskEvent)
diff --git a/wizards/com/sun/star/wizards/web/export/ImpressHTMLExporter.py b/wizards/com/sun/star/wizards/web/export/ImpressHTMLExporter.py
index c60a6dd..0b620c1 100644
--- a/wizards/com/sun/star/wizards/web/export/ImpressHTMLExporter.py
+++ b/wizards/com/sun/star/wizards/web/export/ImpressHTMLExporter.py
@@ -60,11 +60,11 @@ class ImpressHTMLExporter(ConfiguredExporter):
         size = session.cp_Design.cp_OptimizeDisplaySize
         if (size ==  0):
             return self.SMALL_IMAGE
-        elif (size ==  1)
+        elif (size ==  1):
             return self.MEDIUM_IMAGE
-        elif (size ==  2)
+        elif (size ==  2):
             return self.LARGE_IMAGE
         return self.MEDIUM_IMAGE
 
-    def getSession(doc)
+    def getSession(doc):
         return doc.getSettings().cp_DefaultSession
commit ec2f66b51fe5a3874cbbbb21d4f386552cb05d9c
Author: David Tardon <dtardon at redhat.com>
Date:   Thu May 16 15:27:08 2013 +0200

    fdo#64279 do not crash opening report for editing
    
    There are two problems:
    
    1) The classes derived from SdrObject cache their SvxShape, but do not
       implement impl_setUnoShape().
    
    2) There is a lifetime issue in association of a SdrObject and its
       SvxShape. SvxDrawPage::CreateSdrObject not only creates a new SdrObject
       for a shape, but also inserts it into the page. At this point, the shape
       has not been attached to the object yet. That means that the object
       creates another shape at one point during the InsertObject call,
       which is then destroyed again. But reportdesign shapes own their
       objects, which means that destuction of the shape causes destruction
       of the object too...
    
       My first idea was to disable the insertion in
       SvxDrawPage::CreateSdrObject, but it has been there since the dawn of
       time, so I did not gather the courage to do that. Instead, I put in a
       hack to allow to skip the insertion.
    
    Change-Id: I888a54067be1934578434d8b476a13a7ff8d02b3
    (cherry picked from commit 02d03eb4ad6e64744659c5fe04282b25b66c28d8)
    
    Signed-off-by: David Tardon <dtardon at redhat.com>

diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index d3047b8..081fe76 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -1055,6 +1055,11 @@ public:
     Rectangle GetBLIPSizeRectangle() const;
     void SetBLIPSizeRectangle( const Rectangle& aRect );
 
+    /// @see mbDoNotInsertIntoPageAutomatically
+    void SetDoNotInsertIntoPageAutomatically(bool bSet);
+    /// @see mbDoNotInsertIntoPageAutomatically
+    bool IsDoNotInsertIntoPageAutomatically() const;
+
 protected:
     /** Sets a new UNO shape
       *
@@ -1082,6 +1087,11 @@ private:
     SvxShape*   mpSvxShape;
     ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface >
                 maWeakUnoShape;
+    /** HACK: Do not automatically insert newly created object into a page.
+      *
+      * The user needs to do it manually later.
+      */
+    bool mbDoNotInsertIntoPageAutomatically;
 };
 
 //************************************************************
diff --git a/reportdesign/inc/RptObject.hxx b/reportdesign/inc/RptObject.hxx
index ac22e47..9de4b13 100644
--- a/reportdesign/inc/RptObject.hxx
+++ b/reportdesign/inc/RptObject.hxx
@@ -169,6 +169,9 @@ public:
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoShape();
     virtual sal_uInt16 GetObjIdentifier() const;
     virtual sal_uInt32 GetObjInventor() const;
+
+private:
+    virtual void impl_setUnoShape( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxUnoShape );
 };
 
 //============================================================================
@@ -182,6 +185,8 @@ class REPORTDESIGN_DLLPUBLIC OOle2Obj: public SdrOle2Obj , public OObjectBase
     sal_uInt16 m_nType;
     bool    m_bOnlyOnce;
     void impl_createDataProvider_nothrow( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>& _xModel);
+    virtual void impl_setUnoShape( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxUnoShape );
+
 public:
     static OOle2Obj* Create( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent,sal_uInt16 _nType )
     {
@@ -271,6 +276,7 @@ public:
     OUnoObject& operator=(const OUnoObject& rObj);
 
 private:
+    virtual void impl_setUnoShape( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxUnoShape );
     void    impl_setReportComponent_nothrow();
     void    impl_initializeModel_nothrow();
 };
diff --git a/reportdesign/source/core/sdr/RptObject.cxx b/reportdesign/source/core/sdr/RptObject.cxx
index 280f3de..ad81cdc 100644
--- a/reportdesign/source/core/sdr/RptObject.cxx
+++ b/reportdesign/source/core/sdr/RptObject.cxx
@@ -166,6 +166,9 @@ SdrObject* OObjectBase::createObject(const uno::Reference< report::XReportCompon
             break;
     }
 
+    if ( pNewObj )
+        pNewObj->SetDoNotInsertIntoPageAutomatically( true );
+
     ensureSdrObjectOwnership( _xComponent );
 
     return pNewObj;
@@ -609,6 +612,13 @@ uno::Reference< uno::XInterface > OCustomShape::getUnoShape()
     return xShape;
 }
 
+void OCustomShape::impl_setUnoShape( const uno::Reference< uno::XInterface >& rxUnoShape )
+{
+    SdrObjCustomShape::impl_setUnoShape( rxUnoShape );
+    releaseUnoShape();
+    m_xReportComponent.clear();
+}
+
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
 TYPEINIT1(OUnoObject, SdrUnoObj);
@@ -932,6 +942,12 @@ uno::Reference< uno::XInterface > OUnoObject::getUnoShape()
     return OObjectBase::getUnoShapeOf( *this );
 }
 
+void OUnoObject::impl_setUnoShape( const uno::Reference< uno::XInterface >& rxUnoShape )
+{
+    SdrUnoObj::impl_setUnoShape( rxUnoShape );
+    releaseUnoShape();
+}
+
 OUnoObject& OUnoObject::operator=(const OUnoObject& rObj)
 {
     if( this == &rObj )
@@ -1135,6 +1151,14 @@ uno::Reference< uno::XInterface > OOle2Obj::getUnoShape()
     }
     return xShape;
 }
+
+void OOle2Obj::impl_setUnoShape( const uno::Reference< uno::XInterface >& rxUnoShape )
+{
+    SdrOle2Obj::impl_setUnoShape( rxUnoShape );
+    releaseUnoShape();
+    m_xReportComponent.clear();
+}
+
 // -----------------------------------------------------------------------------
 uno::Reference< chart2::data::XDatabaseDataProvider > lcl_getDataProvider(const uno::Reference < embed::XEmbeddedObject >& _xObj)
 {
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index 7052004..0577860 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -423,6 +423,7 @@ SdrObject::SdrObject()
     ,mnLayerID(0)
     ,mpSvxShape( NULL )
     ,maWeakUnoShape()
+    ,mbDoNotInsertIntoPageAutomatically(false)
 {
     DBG_CTOR(SdrObject,NULL);
     bVirtObj         =false;
@@ -497,6 +498,8 @@ SdrObject::~SdrObject()
         delete mpViewContact;
         mpViewContact = 0L;
     }
+
+    mnLayerID = static_cast<SdrLayerID>(0xdead);
 }
 
 void SdrObject::Free( SdrObject*& _rpObject )
@@ -585,7 +588,11 @@ void SdrObject::SetPage(SdrPage* pNewPage)
     // assume they create compatible UNO shape objects so we shouldn't have
     // to invalidate.
     if (pOldPage != pPage && !(pOldPage && pPage && pOldModel == pModel))
-        setUnoShape(NULL);
+    {
+        SvxShape* const pShape(getSvxShape());
+        if (pShape && !pShape->HasSdrObjectOwnership())
+            setUnoShape(NULL);
+    }
 }
 
 SdrPage* SdrObject::GetPage() const
@@ -3223,6 +3230,16 @@ void SdrObject::SetContextWritingMode( const sal_Int16 /*_nContextWritingMode*/
     // this base class does not support different writing modes, so ignore the call
 }
 
+void SdrObject::SetDoNotInsertIntoPageAutomatically(const bool bSet)
+{
+    mbDoNotInsertIntoPageAutomatically = bSet;
+}
+
+bool SdrObject::IsDoNotInsertIntoPageAutomatically() const
+{
+    return mbDoNotInsertIntoPageAutomatically;
+}
+
 
 SdrObjFactory::SdrObjFactory(sal_uInt32 nInvent, sal_uInt16 nIdent, SdrPage* pNewPage, SdrModel* pNewModel)
 {
diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx
index df6e8ba..4cd9800 100644
--- a/svx/source/unodraw/unopage.cxx
+++ b/svx/source/unodraw/unopage.cxx
@@ -242,6 +242,12 @@ void SAL_CALL SvxDrawPage::add( const uno::Reference< drawing::XShape >& xShape
     pShape->Create( pObj, this );
     OSL_ENSURE( pShape->GetSdrObject() == pObj, "SvxDrawPage::add: shape does not know about its newly created SdrObject!" );
 
+    if ( !pObj->IsInserted() )
+    {
+        pObj->SetModel(mpModel);
+        mpPage->InsertObject( pObj );
+    }
+
     mpModel->SetChanged();
 }
 
@@ -835,8 +841,12 @@ Reference< drawing::XShape >  SvxDrawPage::_CreateShape( SdrObject *pObj ) const
 SdrObject *SvxDrawPage::CreateSdrObject( const Reference< drawing::XShape > & xShape ) throw()
 {
     SdrObject* pObj = _CreateSdrObject( xShape );
-    if( pObj && !pObj->IsInserted() )
-        mpPage->InsertObject( pObj );
+    if( pObj)
+    {
+        pObj->SetModel(mpModel);
+        if ( !pObj->IsInserted() && !pObj->IsDoNotInsertIntoPageAutomatically() )
+            mpPage->InsertObject( pObj );
+    }
 
     return pObj;
 }


More information about the Libreoffice-commits mailing list