diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-08-09 22:18:42 +0200 |
---|---|---|
committer | Lionel Elie Mamane <lionel@mamane.lu> | 2012-08-10 10:00:23 +0200 |
commit | 40157f6fa8950505a7ffd22e0b11696ccbd512ae (patch) | |
tree | 711b6c7ddb60e1648dc6d04d89b1648f487c87e1 | |
parent | dc29a85982a4b54657be3f448dd8d37d2144a020 (diff) |
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
Signed-off-by: Lionel Elie Mamane <lionel@mamane.lu>
-rw-r--r-- | reportdesign/inc/UndoEnv.hxx | 2 | ||||
-rw-r--r-- | reportdesign/source/core/api/Section.cxx | 87 | ||||
-rw-r--r-- | reportdesign/source/core/inc/Section.hxx | 34 |
3 files changed, 82 insertions, 41 deletions
diff --git a/reportdesign/inc/UndoEnv.hxx b/reportdesign/inc/UndoEnv.hxx index e48cd253a4ce..7d7ab35cacdc 100644 --- a/reportdesign/inc/UndoEnv.hxx +++ b/reportdesign/inc/UndoEnv.hxx @@ -32,6 +32,8 @@ #include <com/sun/star/beans/PropertyChangeEvent.hpp> #include <com/sun/star/container/XContainerListener.hpp> #include <com/sun/star/report/XReportDefinition.hpp> + +#include <cppuhelper/compbase3.hxx> #include <memory> #include <svl/lstner.hxx> diff --git a/reportdesign/source/core/api/Section.cxx b/reportdesign/source/core/api/Section.cxx index dd054afbf8e4..8142bef0a10c 100644 --- a/reportdesign/source/core/api/Section.cxx +++ b/reportdesign/source/core/api/Section.cxx @@ -143,8 +143,6 @@ OSection::OSection(const uno::Reference< report::XReportDefinition >& _xParent OSection::~OSection() { DBG_DTOR( rpt_OSection,NULL); - if ( m_xProxy.is() ) - m_xProxy->setDelegator( NULL ); } //-------------------------------------------------------------------------- //IMPLEMENT_FORWARD_XINTERFACE2(OSection,SectionBase,SectionPropertySet) @@ -159,7 +157,7 @@ uno::Any SAL_CALL OSection::queryInterface( const uno::Type& _rType ) throw (uno if ( !aReturn.hasValue() && OReportControlModel::isInterfaceForbidden(_rType) ) return aReturn; - return aReturn.hasValue() ? aReturn : (m_xProxy.is() ? m_xProxy->queryAggregation(_rType) : aReturn); + return aReturn; } // ----------------------------------------------------------------------------- @@ -206,33 +204,18 @@ void OSection::init() { uno::Reference< report::XReportDefinition> xReport = getReportDefinition(); ::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 ) { -// DO NOT TOUCH THIS BLOCKS, WE HAVE A COMPILER PROBLEM UNDER SOLARIS X86 - osl_incrementInterlockedCount( &m_refCount ); - { - uno::Reference<report::XSection> xTemp = this; - { - { - m_xProxy.set(pModel->createNewPage(xTemp)->getUnoPage(),uno::UNO_QUERY); - } - { - ::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 ); + uno::Reference<report::XSection> const xSection(this); + m_xDrawPage.set(pModel->createNewPage(xSection)->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); + // 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); } } // ----------------------------------------------------------------------------- @@ -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) { ::osl::MutexGuard aGuard(m_aMutex); - return m_xDrawPage->getByIndex(Index); + return m_xDrawPage.is() ? m_xDrawPage->getByIndex(Index) : uno::Any(); } // ----------------------------------------------------------------------------- // XEnumerationAccess uno::Reference< container::XEnumeration > SAL_CALL OSection::createEnumeration( ) throw (uno::RuntimeException) { ::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) @@ -633,7 +616,45 @@ void SAL_CALL OSection::remove( const uno::Reference< drawing::XShape >& 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 //------------------------------------------------------------------ @@ -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 ) ) return reinterpret_cast<sal_Int64>(this); - uno::Reference< lang::XUnoTunnel> xTunnel; - ::comphelper::query_aggregation(m_xProxy,xTunnel); - return xTunnel->getSomething(rId); + return (m_xDrawPage_Tunnel.is()) ? m_xDrawPage_Tunnel->getSomething(rId) : 0; } // ----------------------------------------------------------------------------- diff --git a/reportdesign/source/core/inc/Section.hxx b/reportdesign/source/core/inc/Section.hxx index c424b908a4e4..757ebaaedb2d 100644 --- a/reportdesign/source/core/inc/Section.hxx +++ b/reportdesign/source/core/inc/Section.hxx @@ -29,14 +29,16 @@ #define REPORTDESIGN_API_SECTION_HXX #include <com/sun/star/report/XSection.hpp> -#include <cppuhelper/compbase3.hxx> +#include <cppuhelper/compbase6.hxx> #include <comphelper/broadcasthelper.hxx> #include <comphelper/uno3.hxx> #include <comphelper/types.hxx> #include <cppuhelper/propertysetmixin.hxx> #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/uno/XAggregation.hpp> +#include <com/sun/star/form/XFormsSupplier2.hpp> #include <comphelper/stl_types.hxx> #include <comphelper/implementationreference.hxx> #include <com/sun/star/lang/XUnoTunnel.hpp> @@ -44,9 +46,16 @@ namespace reportdesign { - typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::report::XSection - , ::com::sun::star::lang::XServiceInfo - , ::com::sun::star::lang::XUnoTunnel> SectionBase; + typedef ::cppu::WeakComponentImplHelper6 + < ::com::sun::star::report::XSection + , ::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; class OSection : public comphelper::OMutexAndBroadcastHelper, @@ -55,8 +64,10 @@ namespace reportdesign { ::cppu::OInterfaceContainerHelper m_aContainerListeners; ::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::uno::XAggregation > m_xProxy; + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > m_xDrawPage; + ::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::XReportDefinition > m_xReportDefinition; ::rtl::OUString m_sName; @@ -177,6 +188,15 @@ namespace reportdesign // 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 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 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); |