[Libreoffice-commits] .: reportdesign/source svx/inc svx/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Sep 4 11:50:54 PDT 2012


 reportdesign/source/core/api/Section.cxx |   14 ++++++++++++--
 svx/inc/svx/svdpage.hxx                  |   11 +++++++----
 svx/source/svdraw/svdpage.cxx            |    5 ++++-
 3 files changed, 23 insertions(+), 7 deletions(-)

New commits:
commit 1146b889325fd01f24c6aacf557d3940dd147936
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Sep 4 20:38:17 2012 +0200

    fdo#53872: reportdesign: fix section drawpage crash:
    
    In order to wrap the SdrPage's UNO object completely, set its mxUnoPage
    member to the OSection wrapper instance in OSection::init; only OSection
    should have access to it.
    Also initialize m_xDrawPage_Tunnel (thanks Lionel for the hint).
    (regression from 05218c101df486302bf4cfe8be23ad840daa3f73)
    
    Change-Id: I048ddafc31e946853e56e6a403ddc9487cfbcf0e

diff --git a/reportdesign/source/core/api/Section.cxx b/reportdesign/source/core/api/Section.cxx
index 0bde01b..71aeef5 100644
--- a/reportdesign/source/core/api/Section.cxx
+++ b/reportdesign/source/core/api/Section.cxx
@@ -165,6 +165,12 @@ void SAL_CALL OSection::dispose() throw(uno::RuntimeException)
 {
     OSL_ENSURE(!rBHelper.bDisposed,"Already disposed!");
     SectionPropertySet::dispose();
+    uno::Reference<lang::XComponent> const xPageComponent(m_xDrawPage,
+            uno::UNO_QUERY);
+    if (xPageComponent.is())
+    {
+        xPageComponent->dispose();
+    }
     cppu::WeakComponentImplHelperBase::dispose();
 
 }
@@ -208,11 +214,15 @@ void OSection::init()
     if ( pModel )
     {
         uno::Reference<report::XSection> const xSection(this);
-        m_xDrawPage.set(pModel->createNewPage(xSection)->getUnoPage(),
-                uno::UNO_QUERY_THROW);
+        SdrPage & rSdrPage(*pModel->createNewPage(xSection));
+        m_xDrawPage.set(rSdrPage.getUnoPage(), uno::UNO_QUERY_THROW);
         m_xDrawPage_ShapeGrouper.set(m_xDrawPage, uno::UNO_QUERY_THROW);
         // apparently we may also get OReportDrawPage which doesn't support this
         m_xDrawPage_FormSupplier.set(m_xDrawPage, uno::UNO_QUERY);
+        m_xDrawPage_Tunnel.set(m_xDrawPage, uno::UNO_QUERY_THROW);
+        // fdo#53872: now also exchange the XDrawPage in the SdrPage so that
+        // rSdrPage.getUnoPage returns this
+        rSdrPage.SetUnoPage(this);
         // createNewPage _should_ have stored away 2 uno::References to this,
         // so our ref count cannot be 1 here, so this isn't destroyed here
         assert(m_refCount > 1);
diff --git a/svx/inc/svx/svdpage.hxx b/svx/inc/svx/svdpage.hxx
index 5ab0f5a..cc1761d 100644
--- a/svx/inc/svx/svdpage.hxx
+++ b/svx/inc/svx/svdpage.hxx
@@ -42,12 +42,14 @@
 #include <svx/sdrmasterpagedescriptor.hxx>
 #include "svx/svxdllapi.h"
 #include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/drawing/XDrawPage.hpp>
 #include <svx/svdobj.hxx>
 #include <boost/scoped_ptr.hpp>
 
 //////////////////////////////////////////////////////////////////////////////
 // predefines
 
+namespace reportdesign { class OSection; }
 namespace sdr { namespace contact { class ViewContact; }}
 class SdrPage;
 class SdrModel;
@@ -444,8 +446,8 @@ public:
     friend class SvxUnoDrawPagesAccess;
 
 // this class uses its own UNO wrapper
-// and thus has to set mxUnoPage
-friend class ChXChartDocument;
+// and thus has to set mxUnoPage (it also relies on mxUnoPage not being WeakRef)
+friend class reportdesign::OSection;
 
     sal_Int32 nWdt;     // Seitengroesse
     sal_Int32 nHgt;     // Seitengroesse
@@ -454,12 +456,11 @@ friend class ChXChartDocument;
     sal_Int32 nBordRgt; // Seitenrand rechts
     sal_Int32 nBordLwr; // Seitenrand unten
 
-    ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxUnoPage;
-
 protected:
     SdrLayerAdmin*      pLayerAdmin;
 private:
     SdrPageProperties*  mpSdrPageProperties;
+    ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxUnoPage;
 
 public:
     SdrPageProperties& getSdrPageProperties() { return *mpSdrPageProperties; }
@@ -482,6 +483,8 @@ protected:
     // #i93597#
     unsigned            mbPageBorderOnlyLeftRight : 1;
 
+    void SetUnoPage(::com::sun::star::uno::Reference<
+                        ::com::sun::star::drawing::XDrawPage> const&);
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createUnoPage();
 
 public:
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index fffb8ed..05434c4 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -1785,10 +1785,13 @@ void SdrPage::SetInserted( bool bIns )
     }
 }
 
+void SdrPage::SetUnoPage(uno::Reference<drawing::XDrawPage> const& xNewPage)
+{
+    mxUnoPage = xNewPage;
+}
 
 uno::Reference< uno::XInterface > SdrPage::getUnoPage()
 {
-    // try weak reference first
     if( !mxUnoPage.is() )
     {
         // create one


More information about the Libreoffice-commits mailing list