Kaydet (Commit) 8ec79131 authored tarafından Michael Stahl's avatar Michael Stahl

fdo#53154: fix report design wizard crash:

As described by Stephan in the bug report, the XAggregation usage in
OSection of SvxFmDrawPage is broken; replace it by explicit forwarding
of the XDrawPage, XShapeGrouper, XFormsSupplier2 methods; it seems
to fix the crash here.  Also get rid of horrid refcount manipulation
etc. while at it.

Change-Id: Ib08830d2092bd2026db5b57c1c2e165b946889b3
üst bbc1742d
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include <com/sun/star/beans/PropertyChangeEvent.hpp> #include <com/sun/star/beans/PropertyChangeEvent.hpp>
#include <com/sun/star/container/XContainerListener.hpp> #include <com/sun/star/container/XContainerListener.hpp>
#include <com/sun/star/report/XReportDefinition.hpp> #include <com/sun/star/report/XReportDefinition.hpp>
#include <cppuhelper/compbase3.hxx>
#include <memory> #include <memory>
#include <svl/lstner.hxx> #include <svl/lstner.hxx>
......
...@@ -143,8 +143,6 @@ OSection::OSection(const uno::Reference< report::XReportDefinition >& _xParent ...@@ -143,8 +143,6 @@ OSection::OSection(const uno::Reference< report::XReportDefinition >& _xParent
OSection::~OSection() OSection::~OSection()
{ {
DBG_DTOR( rpt_OSection,NULL); DBG_DTOR( rpt_OSection,NULL);
if ( m_xProxy.is() )
m_xProxy->setDelegator( NULL );
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
//IMPLEMENT_FORWARD_XINTERFACE2(OSection,SectionBase,SectionPropertySet) //IMPLEMENT_FORWARD_XINTERFACE2(OSection,SectionBase,SectionPropertySet)
...@@ -159,7 +157,7 @@ uno::Any SAL_CALL OSection::queryInterface( const uno::Type& _rType ) throw (uno ...@@ -159,7 +157,7 @@ uno::Any SAL_CALL OSection::queryInterface( const uno::Type& _rType ) throw (uno
if ( !aReturn.hasValue() && OReportControlModel::isInterfaceForbidden(_rType) ) if ( !aReturn.hasValue() && OReportControlModel::isInterfaceForbidden(_rType) )
return aReturn; return aReturn;
return aReturn.hasValue() ? aReturn : (m_xProxy.is() ? m_xProxy->queryAggregation(_rType) : aReturn); return aReturn;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -206,33 +204,18 @@ void OSection::init() ...@@ -206,33 +204,18 @@ void OSection::init()
{ {
uno::Reference< report::XReportDefinition> xReport = getReportDefinition(); uno::Reference< report::XReportDefinition> xReport = getReportDefinition();
::boost::shared_ptr<rptui::OReportModel> pModel = OReportDefinition::getSdrModel(xReport); ::boost::shared_ptr<rptui::OReportModel> pModel = OReportDefinition::getSdrModel(xReport);
OSL_ENSURE(pModel,"No odel set at the report definition!"); assert(pModel); //"No model set at the report definition!"
if ( pModel ) if ( pModel )
{ {
// DO NOT TOUCH THIS BLOCKS, WE HAVE A COMPILER PROBLEM UNDER SOLARIS X86 uno::Reference<report::XSection> const xSection(this);
osl_incrementInterlockedCount( &m_refCount ); m_xDrawPage.set(pModel->createNewPage(xSection)->getUnoPage(),
{ uno::UNO_QUERY_THROW);
uno::Reference<report::XSection> xTemp = this; 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_xProxy.set(pModel->createNewPage(xTemp)->getUnoPage(),uno::UNO_QUERY); // 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);
::comphelper::query_aggregation(m_xProxy,m_xDrawPage);
}
// set ourself as delegator
{
if ( m_xProxy.is() )
{
m_xProxy->setDelegator( xTemp );
}
}
}
xTemp.clear();
}
// DO NOT TOUCH THIS BLOCKS, WE HAVE A COMPILER PROBLEM UNDER SOLARIS X86
osl_decrementInterlockedCount( &m_refCount );
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -546,14 +529,14 @@ uno::Type SAL_CALL OSection::getElementType( ) throw (uno::RuntimeException) ...@@ -546,14 +529,14 @@ uno::Type SAL_CALL OSection::getElementType( ) throw (uno::RuntimeException)
uno::Any SAL_CALL OSection::getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) uno::Any SAL_CALL OSection::getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
{ {
::osl::MutexGuard aGuard(m_aMutex); ::osl::MutexGuard aGuard(m_aMutex);
return m_xDrawPage->getByIndex(Index); return m_xDrawPage.is() ? m_xDrawPage->getByIndex(Index) : uno::Any();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// XEnumerationAccess // XEnumerationAccess
uno::Reference< container::XEnumeration > SAL_CALL OSection::createEnumeration( ) throw (uno::RuntimeException) uno::Reference< container::XEnumeration > SAL_CALL OSection::createEnumeration( ) throw (uno::RuntimeException)
{ {
::osl::MutexGuard aGuard(m_aMutex); ::osl::MutexGuard aGuard(m_aMutex);
return new ::comphelper::OEnumerationByIndex(static_cast<XIndexAccess*>(this)); return new ::comphelper::OEnumerationByIndex(static_cast<XSection*>(this));
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
uno::Reference< beans::XPropertySetInfo > SAL_CALL OSection::getPropertySetInfo( ) throw(uno::RuntimeException) uno::Reference< beans::XPropertySetInfo > SAL_CALL OSection::getPropertySetInfo( ) throw(uno::RuntimeException)
...@@ -633,7 +616,45 @@ void SAL_CALL OSection::remove( const uno::Reference< drawing::XShape >& xShape ...@@ -633,7 +616,45 @@ void SAL_CALL OSection::remove( const uno::Reference< drawing::XShape >& xShape
} }
notifyElementRemoved(xShape); notifyElementRemoved(xShape);
} }
// -----------------------------------------------------------------------------
// XShapeGrouper
uno::Reference< drawing::XShapeGroup > SAL_CALL
OSection::group(uno::Reference< drawing::XShapes > const& xShapes)
throw (uno::RuntimeException)
{
// no lock because m_xDrawPage_ShapeGrouper is const
return (m_xDrawPage_ShapeGrouper.is())
? m_xDrawPage_ShapeGrouper->group(xShapes)
: 0;
}
void SAL_CALL
OSection::ungroup(uno::Reference<drawing::XShapeGroup> const& xGroup)
throw (uno::RuntimeException)
{
// no lock because m_xDrawPage_ShapeGrouper is const
if (m_xDrawPage_ShapeGrouper.is()) {
m_xDrawPage_ShapeGrouper->ungroup(xGroup);
}
}
// XFormsSupplier
uno::Reference<container::XNameContainer> SAL_CALL OSection::getForms()
throw (uno::RuntimeException)
{
// no lock because m_xDrawPage_FormSupplier is const
return (m_xDrawPage_FormSupplier.is())
? m_xDrawPage_FormSupplier->getForms()
: 0;
}
// XFormsSupplier2
sal_Bool SAL_CALL OSection::hasForms() throw (uno::RuntimeException)
{
// no lock because m_xDrawPage_FormSupplier is const
return (m_xDrawPage_FormSupplier.is())
? m_xDrawPage_FormSupplier->hasForms()
: 0;
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// com::sun::star::lang::XUnoTunnel // com::sun::star::lang::XUnoTunnel
//------------------------------------------------------------------ //------------------------------------------------------------------
...@@ -641,9 +662,7 @@ sal_Int64 OSection::getSomething( const uno::Sequence< sal_Int8 > & rId ) throw ...@@ -641,9 +662,7 @@ sal_Int64 OSection::getSomething( const uno::Sequence< sal_Int8 > & rId ) throw
{ {
if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
return reinterpret_cast<sal_Int64>(this); return reinterpret_cast<sal_Int64>(this);
uno::Reference< lang::XUnoTunnel> xTunnel; return (m_xDrawPage_Tunnel.is()) ? m_xDrawPage_Tunnel->getSomething(rId) : 0;
::comphelper::query_aggregation(m_xProxy,xTunnel);
return xTunnel->getSomething(rId);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -20,14 +20,16 @@ ...@@ -20,14 +20,16 @@
#define REPORTDESIGN_API_SECTION_HXX #define REPORTDESIGN_API_SECTION_HXX
#include <com/sun/star/report/XSection.hpp> #include <com/sun/star/report/XSection.hpp>
#include <cppuhelper/compbase3.hxx> #include <cppuhelper/compbase6.hxx>
#include <comphelper/broadcasthelper.hxx> #include <comphelper/broadcasthelper.hxx>
#include <comphelper/uno3.hxx> #include <comphelper/uno3.hxx>
#include <comphelper/types.hxx> #include <comphelper/types.hxx>
#include <cppuhelper/propertysetmixin.hxx> #include <cppuhelper/propertysetmixin.hxx>
#include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/drawing/XDrawPage.hpp>
#include <com/sun/star/drawing/XShapeGrouper.hpp>
#include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/drawing/XShapes.hpp>
#include <com/sun/star/uno/XAggregation.hpp> #include <com/sun/star/form/XFormsSupplier2.hpp>
#include <comphelper/stl_types.hxx> #include <comphelper/stl_types.hxx>
#include <comphelper/implementationreference.hxx> #include <comphelper/implementationreference.hxx>
#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp>
...@@ -35,9 +37,16 @@ ...@@ -35,9 +37,16 @@
namespace reportdesign namespace reportdesign
{ {
typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::report::XSection typedef ::cppu::WeakComponentImplHelper6
, ::com::sun::star::lang::XServiceInfo < ::com::sun::star::report::XSection
, ::com::sun::star::lang::XUnoTunnel> SectionBase; , ::com::sun::star::lang::XServiceInfo
, ::com::sun::star::lang::XUnoTunnel
// SvxDrawPage forward
, ::com::sun::star::drawing::XDrawPage
, ::com::sun::star::drawing::XShapeGrouper
// SvxFmDrawPage forward
, ::com::sun::star::form::XFormsSupplier2
> SectionBase;
typedef ::cppu::PropertySetMixin<com::sun::star::report::XSection> SectionPropertySet; typedef ::cppu::PropertySetMixin<com::sun::star::report::XSection> SectionPropertySet;
class OSection : public comphelper::OMutexAndBroadcastHelper, class OSection : public comphelper::OMutexAndBroadcastHelper,
...@@ -46,8 +55,10 @@ namespace reportdesign ...@@ -46,8 +55,10 @@ namespace reportdesign
{ {
::cppu::OInterfaceContainerHelper m_aContainerListeners; ::cppu::OInterfaceContainerHelper m_aContainerListeners;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xDrawPage; ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > m_xDrawPage;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > m_xProxy; ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapeGrouper > m_xDrawPage_ShapeGrouper;
::com::sun::star::uno::Reference< ::com::sun::star::form::XFormsSupplier2 > m_xDrawPage_FormSupplier;
::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > m_xDrawPage_Tunnel;
::com::sun::star::uno::WeakReference< ::com::sun::star::report::XGroup > m_xGroup; ::com::sun::star::uno::WeakReference< ::com::sun::star::report::XGroup > m_xGroup;
::com::sun::star::uno::WeakReference< ::com::sun::star::report::XReportDefinition > m_xReportDefinition; ::com::sun::star::uno::WeakReference< ::com::sun::star::report::XReportDefinition > m_xReportDefinition;
::rtl::OUString m_sName; ::rtl::OUString m_sName;
...@@ -168,6 +179,15 @@ namespace reportdesign ...@@ -168,6 +179,15 @@ namespace reportdesign
// XShapes // XShapes
virtual void SAL_CALL add( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL add( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw (::com::sun::star::uno::RuntimeException);
// XShapeGrouper
virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapeGroup > SAL_CALL group( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xShapes ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL ungroup( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapeGroup >& aGroup ) throw (::com::sun::star::uno::RuntimeException);
// XFormsSupplier
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > SAL_CALL getForms() throw (::com::sun::star::uno::RuntimeException);
// XFormsSupplier2
virtual sal_Bool SAL_CALL hasForms() throw (::com::sun::star::uno::RuntimeException);
// XIndexAccess // XIndexAccess
virtual ::sal_Int32 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment