diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-08-09 23:52:35 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-08-10 00:09:50 +0200 |
commit | 0abceaaf623cb358b45c106b9f2af87a931ff9a6 (patch) | |
tree | 3b2b4428f64cd60631d18c509d13df5c84d0f824 /reportdesign | |
parent | fdo#53154: fix report design wizard crash: (diff) | |
download | core-0abceaaf623cb358b45c106b9f2af87a931ff9a6.tar.gz core-0abceaaf623cb358b45c106b9f2af87a931ff9a6.zip |
refactor reportdesign::OSection construction
Indended to solve a problem that turned out to be imaginary.
Change-Id: I185887f6e45869102ac600717a0bb7564ebdb7e5
Diffstat (limited to 'reportdesign')
-rw-r--r-- | reportdesign/source/core/api/ReportDefinition.cxx | 6 | ||||
-rw-r--r-- | reportdesign/source/core/api/Section.cxx | 60 | ||||
-rw-r--r-- | reportdesign/source/core/inc/Section.hxx | 12 | ||||
-rw-r--r-- | reportdesign/source/core/inc/Tools.hxx | 2 |
4 files changed, 44 insertions, 36 deletions
diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx index 1e8433ba1329..e67d75c18caa 100644 --- a/reportdesign/source/core/api/ReportDefinition.cxx +++ b/reportdesign/source/core/api/ReportDefinition.cxx @@ -661,7 +661,7 @@ OReportDefinition::OReportDefinition(uno::Reference< uno::XComponentContext > co { init(); m_pImpl->m_xGroups = new OGroups(this,m_aProps->m_xContext); - m_pImpl->m_xDetail = new OSection(this,m_aProps->m_xContext); + m_pImpl->m_xDetail = OSection::createOSection(this,m_aProps->m_xContext); m_pImpl->m_xDetail->setName(RPT_RESSTRING(RID_STR_DETAIL,m_aProps->m_xContext->getServiceManager())); } osl_decrementInterlockedCount( &m_refCount ); @@ -682,7 +682,7 @@ OReportDefinition::OReportDefinition(uno::Reference< uno::XComponentContext > co m_aProps->setShape(_xShape,this,m_refCount); init(); m_pImpl->m_xGroups = new OGroups(this,m_aProps->m_xContext); - m_pImpl->m_xDetail = new OSection(this,m_aProps->m_xContext); + m_pImpl->m_xDetail = OSection::createOSection(this,m_aProps->m_xContext); m_pImpl->m_xDetail->setName(RPT_RESSTRING(RID_STR_DETAIL,m_aProps->m_xContext->getServiceManager())); } osl_decrementInterlockedCount( &m_refCount ); @@ -703,7 +703,7 @@ OReportDefinition::OReportDefinition(const OReportDefinition& _rCopy) OGroups* pGroups = new OGroups(this,m_aProps->m_xContext); m_pImpl->m_xGroups = pGroups; pGroups->copyGroups(_rCopy.m_pImpl->m_xGroups); - m_pImpl->m_xDetail = new OSection(this,m_aProps->m_xContext); + m_pImpl->m_xDetail = OSection::createOSection(this,m_aProps->m_xContext); OSection::lcl_copySection(_rCopy.m_pImpl->m_xDetail,m_pImpl->m_xDetail); setPageHeaderOn(_rCopy.m_pImpl->m_xPageHeader.is()); diff --git a/reportdesign/source/core/api/Section.cxx b/reportdesign/source/core/api/Section.cxx index 8142bef0a10c..0bde01b827cf 100644 --- a/reportdesign/source/core/api/Section.cxx +++ b/reportdesign/source/core/api/Section.cxx @@ -52,6 +52,7 @@ namespace reportdesign using namespace com::sun::star; using namespace comphelper; DBG_NAME( rpt_OSection ) + // ----------------------------------------------------------------------------- uno::Sequence< ::rtl::OUString> lcl_getGroupAbsent() { @@ -64,31 +65,6 @@ uno::Sequence< ::rtl::OUString> lcl_getGroupAbsent() } // ----------------------------------------------------------------------------- -OSection::OSection( const uno::Reference< report::XGroup >& _xParent - ,const uno::Reference< uno::XComponentContext >& context - ,bool /*_bPageSection*/) -:SectionBase(m_aMutex) -,SectionPropertySet(context,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),lcl_getGroupAbsent()) -,m_aContainerListeners(m_aMutex) -,m_xContext(context) -,m_xGroup(_xParent) -,m_nHeight(3000) -,m_nBackgroundColor(COL_TRANSPARENT) -,m_nForceNewPage(report::ForceNewPage::NONE) -,m_nNewRowOrCol(report::ForceNewPage::NONE) -,m_bKeepTogether(sal_False) -,m_bCanGrow(sal_False) -,m_bCanShrink(sal_False) -,m_bRepeatSection(sal_False) -,m_bVisible(sal_True) -,m_bBacktransparent(sal_True) -,m_bInRemoveNotify(false) -,m_bInInsertNotify(false) -{ - DBG_CTOR( rpt_OSection,NULL); - init(); -} -// ----------------------------------------------------------------------------- uno::Sequence< ::rtl::OUString> lcl_getAbsent(bool _bPageSection) { if ( _bPageSection ) @@ -112,15 +88,40 @@ uno::Sequence< ::rtl::OUString> lcl_getAbsent(bool _bPageSection) return uno::Sequence< ::rtl::OUString >(pProps,sizeof(pProps)/sizeof(pProps[0])); } + +uno::Reference<report::XSection> OSection::createOSection( + const uno::Reference< report::XReportDefinition >& xParentDef, + const uno::Reference< uno::XComponentContext >& context, + bool const bPageSection) +{ + OSection *const pNew = + new OSection(xParentDef, 0, context, lcl_getAbsent(bPageSection)); + pNew->init(); + return pNew; +} + +uno::Reference<report::XSection> OSection::createOSection( + const uno::Reference< report::XGroup >& xParentGroup, + const uno::Reference< uno::XComponentContext >& context, + bool const) +{ + OSection *const pNew = + new OSection(0, xParentGroup, context, lcl_getGroupAbsent()); + pNew->init(); + return pNew; +} + // ----------------------------------------------------------------------------- -OSection::OSection(const uno::Reference< report::XReportDefinition >& _xParent +OSection::OSection(const uno::Reference< report::XReportDefinition >& xParentDef + ,const uno::Reference< report::XGroup >& xParentGroup ,const uno::Reference< uno::XComponentContext >& context - ,bool _bPageSection) + ,uno::Sequence< ::rtl::OUString> const& rStrings) :SectionBase(m_aMutex) -,SectionPropertySet(context,SectionPropertySet::IMPLEMENTS_PROPERTY_SET,lcl_getAbsent(_bPageSection)) +,SectionPropertySet(context,SectionPropertySet::IMPLEMENTS_PROPERTY_SET,rStrings) ,m_aContainerListeners(m_aMutex) ,m_xContext(context) -,m_xReportDefinition(_xParent) +,m_xGroup(xParentGroup) +,m_xReportDefinition(xParentDef) ,m_nHeight(3000) ,m_nBackgroundColor(COL_TRANSPARENT) ,m_nForceNewPage(report::ForceNewPage::NONE) @@ -135,7 +136,6 @@ OSection::OSection(const uno::Reference< report::XReportDefinition >& _xParent ,m_bInInsertNotify(false) { DBG_CTOR( rpt_OSection,NULL); - init(); } //-------------------------------------------------------------------------- // TODO: VirtualFunctionFinder: This is virtual function! diff --git a/reportdesign/source/core/inc/Section.hxx b/reportdesign/source/core/inc/Section.hxx index 23deea51c915..c117126d1d27 100644 --- a/reportdesign/source/core/inc/Section.hxx +++ b/reportdesign/source/core/inc/Section.hxx @@ -115,9 +115,17 @@ namespace reportdesign public: typedef ::comphelper::ImplementationReference< OSection ,::com::sun::star::report::XSection,::com::sun::star::uno::XWeak > TSection; - OSection(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xParent + private: + OSection(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& xParentDef + ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& xParentGroup + ,const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& context, + ::com::sun::star::uno::Sequence< ::rtl::OUString> const&); + public: + static ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> + createOSection(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xParent ,const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& context,bool _bPageSection=false); - OSection(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xParent + static ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> + createOSection(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xParent ,const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& context,bool _bPageSection=false); DECLARE_XINTERFACE( ) diff --git a/reportdesign/source/core/inc/Tools.hxx b/reportdesign/source/core/inc/Tools.hxx index 1be4ad8a243b..f9a00b6bbd3f 100644 --- a/reportdesign/source/core/inc/Tools.hxx +++ b/reportdesign/source/core/inc/Tools.hxx @@ -47,7 +47,7 @@ namespace reportdesign template <class T> void lcl_createSectionIfNeeded(sal_Bool _bOn,const T& _xParent,::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection/*in/out*/,bool _bPageSection = false) { if ( _bOn && !_xSection.is() ) - _xSection = new OSection(_xParent,_xParent->getContext(),_bPageSection); + _xSection = OSection::createOSection(_xParent,_xParent->getContext(),_bPageSection); else if ( !_bOn ) ::comphelper::disposeComponent(_xSection); } |