xref: /AOO41X/main/reportdesign/source/core/api/Section.cxx (revision 9e0e41911c53968aad5ad356e2b2126da667034f)
1*9e0e4191SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9e0e4191SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9e0e4191SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9e0e4191SAndrew Rist  * distributed with this work for additional information
6*9e0e4191SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9e0e4191SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9e0e4191SAndrew Rist  * "License"); you may not use this file except in compliance
9*9e0e4191SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*9e0e4191SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*9e0e4191SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9e0e4191SAndrew Rist  * software distributed under the License is distributed on an
15*9e0e4191SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9e0e4191SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9e0e4191SAndrew Rist  * specific language governing permissions and limitations
18*9e0e4191SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*9e0e4191SAndrew Rist  *************************************************************/
21*9e0e4191SAndrew Rist 
22*9e0e4191SAndrew Rist 
23cdf0e10cSrcweir #include "Section.hxx"
24cdf0e10cSrcweir #include <comphelper/enumhelper.hxx>
25cdf0e10cSrcweir #include <connectivity/dbtools.hxx>
26cdf0e10cSrcweir #include <com/sun/star/report/XReportComponent.hpp>
27cdf0e10cSrcweir #include <com/sun/star/report/ForceNewPage.hpp>
28cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
29cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30cdf0e10cSrcweir #ifndef REPORTDESIGN_SHARED_CORESTRINGS_HRC
31cdf0e10cSrcweir #include "corestrings.hrc"
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #include "core_resource.hxx"
34cdf0e10cSrcweir #ifndef REPORTDESIGN_CORE_RESOURCE_HRC_
35cdf0e10cSrcweir #include "core_resource.hrc"
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir #include <tools/debug.hxx>
38cdf0e10cSrcweir #include "Tools.hxx"
39cdf0e10cSrcweir #include "RptModel.hxx"
40cdf0e10cSrcweir #include "RptPage.hxx"
41cdf0e10cSrcweir #include "ReportDefinition.hxx"
42cdf0e10cSrcweir #include "Shape.hxx"
43cdf0e10cSrcweir #include <svx/unoshape.hxx>
44cdf0e10cSrcweir #include "RptObject.hxx"
45cdf0e10cSrcweir #include "ReportDrawPage.hxx"
46cdf0e10cSrcweir #include <comphelper/property.hxx>
47cdf0e10cSrcweir // =============================================================================
48cdf0e10cSrcweir namespace reportdesign
49cdf0e10cSrcweir {
50cdf0e10cSrcweir // =============================================================================
51cdf0e10cSrcweir 	using namespace com::sun::star;
52cdf0e10cSrcweir 	using namespace comphelper;
DBG_NAME(rpt_OSection)53cdf0e10cSrcweir DBG_NAME( rpt_OSection )
54cdf0e10cSrcweir // -----------------------------------------------------------------------------
55cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> lcl_getGroupAbsent()
56cdf0e10cSrcweir {
57cdf0e10cSrcweir     ::rtl::OUString pProps[] = {
58cdf0e10cSrcweir                 PROPERTY_CANGROW
59cdf0e10cSrcweir                 ,PROPERTY_CANSHRINK
60cdf0e10cSrcweir 	    };
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 	return uno::Sequence< ::rtl::OUString >(pProps,sizeof(pProps)/sizeof(pProps[0]));
63cdf0e10cSrcweir }
64cdf0e10cSrcweir 
65cdf0e10cSrcweir // -----------------------------------------------------------------------------
OSection(const uno::Reference<report::XGroup> & _xParent,const uno::Reference<uno::XComponentContext> & context,bool)66cdf0e10cSrcweir OSection::OSection( const uno::Reference< report::XGroup >& _xParent
67cdf0e10cSrcweir 				   ,const uno::Reference< uno::XComponentContext >& context
68cdf0e10cSrcweir                    ,bool /*_bPageSection*/)
69cdf0e10cSrcweir :SectionBase(m_aMutex)
70cdf0e10cSrcweir ,SectionPropertySet(context,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),lcl_getGroupAbsent())
71cdf0e10cSrcweir ,m_aContainerListeners(m_aMutex)
72cdf0e10cSrcweir ,m_xContext(context)
73cdf0e10cSrcweir ,m_xGroup(_xParent)
74cdf0e10cSrcweir ,m_nHeight(3000)
75cdf0e10cSrcweir ,m_nBackgroundColor(COL_TRANSPARENT)
76cdf0e10cSrcweir ,m_nForceNewPage(report::ForceNewPage::NONE)
77cdf0e10cSrcweir ,m_nNewRowOrCol(report::ForceNewPage::NONE)
78cdf0e10cSrcweir ,m_bKeepTogether(sal_False)
79cdf0e10cSrcweir ,m_bCanGrow(sal_False)
80cdf0e10cSrcweir ,m_bCanShrink(sal_False)
81cdf0e10cSrcweir ,m_bRepeatSection(sal_False)
82cdf0e10cSrcweir ,m_bVisible(sal_True)
83cdf0e10cSrcweir ,m_bBacktransparent(sal_True)
84cdf0e10cSrcweir ,m_bInRemoveNotify(false)
85cdf0e10cSrcweir ,m_bInInsertNotify(false)
86cdf0e10cSrcweir {
87cdf0e10cSrcweir 	DBG_CTOR( rpt_OSection,NULL);
88cdf0e10cSrcweir     init();
89cdf0e10cSrcweir }
90cdf0e10cSrcweir // -----------------------------------------------------------------------------
lcl_getAbsent(bool _bPageSection)91cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> lcl_getAbsent(bool _bPageSection)
92cdf0e10cSrcweir {
93cdf0e10cSrcweir     if ( _bPageSection )
94cdf0e10cSrcweir     {
95cdf0e10cSrcweir         ::rtl::OUString pProps[] = {
96cdf0e10cSrcweir 			    PROPERTY_FORCENEWPAGE
97cdf0e10cSrcweir 			    ,PROPERTY_NEWROWORCOL
98cdf0e10cSrcweir 			    ,PROPERTY_KEEPTOGETHER
99cdf0e10cSrcweir                 ,PROPERTY_CANGROW
100cdf0e10cSrcweir                 ,PROPERTY_CANSHRINK
101cdf0e10cSrcweir                 ,PROPERTY_REPEATSECTION
102cdf0e10cSrcweir 	    };
103cdf0e10cSrcweir         return uno::Sequence< ::rtl::OUString >(pProps,sizeof(pProps)/sizeof(pProps[0]));
104cdf0e10cSrcweir     }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     ::rtl::OUString pProps[] = {
107cdf0e10cSrcweir                 PROPERTY_CANGROW
108cdf0e10cSrcweir                 ,PROPERTY_CANSHRINK
109cdf0e10cSrcweir                 ,PROPERTY_REPEATSECTION
110cdf0e10cSrcweir 	    };
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 	return uno::Sequence< ::rtl::OUString >(pProps,sizeof(pProps)/sizeof(pProps[0]));
113cdf0e10cSrcweir }
114cdf0e10cSrcweir // -----------------------------------------------------------------------------
OSection(const uno::Reference<report::XReportDefinition> & _xParent,const uno::Reference<uno::XComponentContext> & context,bool _bPageSection)115cdf0e10cSrcweir OSection::OSection(const uno::Reference< report::XReportDefinition >& _xParent
116cdf0e10cSrcweir 				   ,const uno::Reference< uno::XComponentContext >& context
117cdf0e10cSrcweir                    ,bool _bPageSection)
118cdf0e10cSrcweir :SectionBase(m_aMutex)
119cdf0e10cSrcweir ,SectionPropertySet(context,SectionPropertySet::IMPLEMENTS_PROPERTY_SET,lcl_getAbsent(_bPageSection))
120cdf0e10cSrcweir ,m_aContainerListeners(m_aMutex)
121cdf0e10cSrcweir ,m_xContext(context)
122cdf0e10cSrcweir ,m_xReportDefinition(_xParent)
123cdf0e10cSrcweir ,m_nHeight(3000)
124cdf0e10cSrcweir ,m_nBackgroundColor(COL_TRANSPARENT)
125cdf0e10cSrcweir ,m_nForceNewPage(report::ForceNewPage::NONE)
126cdf0e10cSrcweir ,m_nNewRowOrCol(report::ForceNewPage::NONE)
127cdf0e10cSrcweir ,m_bKeepTogether(sal_False)
128cdf0e10cSrcweir ,m_bCanGrow(sal_False)
129cdf0e10cSrcweir ,m_bCanShrink(sal_False)
130cdf0e10cSrcweir ,m_bRepeatSection(sal_False)
131cdf0e10cSrcweir ,m_bVisible(sal_True)
132cdf0e10cSrcweir ,m_bBacktransparent(sal_True)
133cdf0e10cSrcweir ,m_bInRemoveNotify(false)
134cdf0e10cSrcweir ,m_bInInsertNotify(false)
135cdf0e10cSrcweir {
136cdf0e10cSrcweir 	DBG_CTOR( rpt_OSection,NULL);
137cdf0e10cSrcweir     init();
138cdf0e10cSrcweir     //.getSdrModel()->createNewPage(m_xSection);
139cdf0e10cSrcweir }
140cdf0e10cSrcweir //--------------------------------------------------------------------------
141cdf0e10cSrcweir // TODO: VirtualFunctionFinder: This is virtual function!
142cdf0e10cSrcweir //
~OSection()143cdf0e10cSrcweir OSection::~OSection()
144cdf0e10cSrcweir {
145cdf0e10cSrcweir     DBG_DTOR( rpt_OSection,NULL);
146cdf0e10cSrcweir     if ( m_xProxy.is() )
147cdf0e10cSrcweir         m_xProxy->setDelegator( NULL );
148cdf0e10cSrcweir }
149cdf0e10cSrcweir //--------------------------------------------------------------------------
150cdf0e10cSrcweir //IMPLEMENT_FORWARD_XINTERFACE2(OSection,SectionBase,SectionPropertySet)
IMPLEMENT_FORWARD_REFCOUNT(OSection,SectionBase)151cdf0e10cSrcweir IMPLEMENT_FORWARD_REFCOUNT( OSection, SectionBase )
152cdf0e10cSrcweir // --------------------------------------------------------------------------------
153cdf0e10cSrcweir uno::Any SAL_CALL OSection::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException)
154cdf0e10cSrcweir {
155cdf0e10cSrcweir 	uno::Any aReturn = SectionBase::queryInterface(_rType);
156cdf0e10cSrcweir     if ( !aReturn.hasValue() )
157cdf0e10cSrcweir         aReturn = SectionPropertySet::queryInterface(_rType);
158cdf0e10cSrcweir 
159cdf0e10cSrcweir     if ( !aReturn.hasValue() && OReportControlModel::isInterfaceForbidden(_rType) )
160cdf0e10cSrcweir         return aReturn;
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	return aReturn.hasValue() ? aReturn : (m_xProxy.is() ? m_xProxy->queryAggregation(_rType) : aReturn);
163cdf0e10cSrcweir }
164cdf0e10cSrcweir 
165cdf0e10cSrcweir // -----------------------------------------------------------------------------
dispose()166cdf0e10cSrcweir void SAL_CALL OSection::dispose() throw(uno::RuntimeException)
167cdf0e10cSrcweir {
168cdf0e10cSrcweir     OSL_ENSURE(!rBHelper.bDisposed,"Already disposed!");
169cdf0e10cSrcweir 	SectionPropertySet::dispose();
170cdf0e10cSrcweir 	cppu::WeakComponentImplHelperBase::dispose();
171cdf0e10cSrcweir 
172cdf0e10cSrcweir }
173cdf0e10cSrcweir // -----------------------------------------------------------------------------
174cdf0e10cSrcweir // TODO: VirtualFunctionFinder: This is virtual function!
175cdf0e10cSrcweir //
disposing()176cdf0e10cSrcweir void SAL_CALL OSection::disposing()
177cdf0e10cSrcweir {
178cdf0e10cSrcweir     lang::EventObject aDisposeEvent( static_cast< ::cppu::OWeakObject* >( this ) );
179cdf0e10cSrcweir     m_aContainerListeners.disposeAndClear( aDisposeEvent );
180cdf0e10cSrcweir     m_xContext.clear();
181cdf0e10cSrcweir     //m_xDrawPage.clear();
182cdf0e10cSrcweir 
183cdf0e10cSrcweir     /*uno::Reference< report::XReportDefinition> xReport = getReportDefinition();
184cdf0e10cSrcweir     ::boost::shared_ptr<rptui::OReportModel> pModel = OReportDefinition::getSdrModel(xReport);
185cdf0e10cSrcweir     osl_incrementInterlockedCount( &m_refCount );
186cdf0e10cSrcweir     while( m_xDrawPage.is() && m_xDrawPage->hasElements() )
187cdf0e10cSrcweir     {
188cdf0e10cSrcweir         try
189cdf0e10cSrcweir         {
190cdf0e10cSrcweir             uno::Reference< drawing::XShape> xShape(m_xDrawPage->getByIndex(0),uno::UNO_QUERY);
191cdf0e10cSrcweir             m_xDrawPage->remove(xShape);
192cdf0e10cSrcweir             ::comphelper::disposeComponent(xShape);
193cdf0e10cSrcweir         }
194cdf0e10cSrcweir         catch(const uno::Exception&)
195cdf0e10cSrcweir         {}
196cdf0e10cSrcweir     }
197cdf0e10cSrcweir     if ( pModel )
198cdf0e10cSrcweir     {
199cdf0e10cSrcweir         uno::Reference< report::XSection> xSection = this;
200cdf0e10cSrcweir         pModel->DeletePage(pModel->getPage(xSection)->GetPageNum());
201cdf0e10cSrcweir     }
202cdf0e10cSrcweir     osl_decrementInterlockedCount( &m_refCount );*/
203cdf0e10cSrcweir }
204cdf0e10cSrcweir //--------------------------------------------------------------------------
getImplementationName()205cdf0e10cSrcweir ::rtl::OUString SAL_CALL OSection::getImplementationName(  ) throw(uno::RuntimeException)
206cdf0e10cSrcweir {
207cdf0e10cSrcweir     return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.Section"));
208cdf0e10cSrcweir }
209cdf0e10cSrcweir //------------------------------------------------------------------------------
getSupportedServiceNames_Static(void)210cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> OSection::getSupportedServiceNames_Static(void) throw( uno::RuntimeException )
211cdf0e10cSrcweir {
212cdf0e10cSrcweir 	uno::Sequence< ::rtl::OUString> aSupported(1);
213cdf0e10cSrcweir 	aSupported.getArray()[0] = SERVICE_SECTION;
214cdf0e10cSrcweir 	return aSupported;
215cdf0e10cSrcweir }
216cdf0e10cSrcweir //-------------------------------------------------------------------------
getSupportedServiceNames()217cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> SAL_CALL OSection::getSupportedServiceNames() throw(uno::RuntimeException)
218cdf0e10cSrcweir {
219cdf0e10cSrcweir 	return getSupportedServiceNames_Static();
220cdf0e10cSrcweir }
221cdf0e10cSrcweir // -----------------------------------------------------------------------------
supportsService(const::rtl::OUString & _rServiceName)222cdf0e10cSrcweir sal_Bool SAL_CALL OSection::supportsService( const ::rtl::OUString& _rServiceName ) throw(uno::RuntimeException)
223cdf0e10cSrcweir {
224cdf0e10cSrcweir 	return ::comphelper::existsValue(_rServiceName,getSupportedServiceNames_Static());
225cdf0e10cSrcweir }
226cdf0e10cSrcweir // -----------------------------------------------------------------------------
init()227cdf0e10cSrcweir void OSection::init()
228cdf0e10cSrcweir {
229cdf0e10cSrcweir     uno::Reference< report::XReportDefinition> xReport = getReportDefinition();
230cdf0e10cSrcweir     ::boost::shared_ptr<rptui::OReportModel> pModel = OReportDefinition::getSdrModel(xReport);
231cdf0e10cSrcweir     OSL_ENSURE(pModel,"No odel set at the report definition!");
232cdf0e10cSrcweir     if ( pModel )
233cdf0e10cSrcweir     {
234cdf0e10cSrcweir // DO NOT TOUCH THIS BLOCKS, WE HAVE A COMPILER PROBLEM UNDER SOLARIS X86
235cdf0e10cSrcweir         osl_incrementInterlockedCount( &m_refCount );
236cdf0e10cSrcweir         {
237cdf0e10cSrcweir 			uno::Reference<report::XSection> xTemp = this;
238cdf0e10cSrcweir 			{
239cdf0e10cSrcweir 				{
240cdf0e10cSrcweir             		m_xProxy.set(pModel->createNewPage(xTemp)->getUnoPage(),uno::UNO_QUERY);
241cdf0e10cSrcweir 				}
242cdf0e10cSrcweir 				{
243cdf0e10cSrcweir 		            ::comphelper::query_aggregation(m_xProxy,m_xDrawPage);
244cdf0e10cSrcweir 				}
245cdf0e10cSrcweir 
246cdf0e10cSrcweir         	    // set ourself as delegator
247cdf0e10cSrcweir 				{
248cdf0e10cSrcweir     		        if ( m_xProxy.is() )
249cdf0e10cSrcweir 					{
250cdf0e10cSrcweir                 		m_xProxy->setDelegator( xTemp );
251cdf0e10cSrcweir 					}
252cdf0e10cSrcweir 				}
253cdf0e10cSrcweir 			}
254cdf0e10cSrcweir 			xTemp.clear();
255cdf0e10cSrcweir         }
256cdf0e10cSrcweir // DO NOT TOUCH THIS BLOCKS, WE HAVE A COMPILER PROBLEM UNDER SOLARIS X86
257cdf0e10cSrcweir         osl_decrementInterlockedCount( &m_refCount );
258cdf0e10cSrcweir     }
259cdf0e10cSrcweir }
260cdf0e10cSrcweir // -----------------------------------------------------------------------------
261cdf0e10cSrcweir // XSection
262cdf0e10cSrcweir // -----------------------------------------------------------------------------
getVisible()263cdf0e10cSrcweir ::sal_Bool SAL_CALL OSection::getVisible() throw (uno::RuntimeException)
264cdf0e10cSrcweir {
265cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
266cdf0e10cSrcweir 	return m_bVisible;
267cdf0e10cSrcweir }
268cdf0e10cSrcweir // -----------------------------------------------------------------------------
setVisible(::sal_Bool _visible)269cdf0e10cSrcweir void SAL_CALL OSection::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeException)
270cdf0e10cSrcweir {
271cdf0e10cSrcweir 	set(PROPERTY_VISIBLE,_visible,m_bVisible);
272cdf0e10cSrcweir }
273cdf0e10cSrcweir // -----------------------------------------------------------------------------
getName()274cdf0e10cSrcweir ::rtl::OUString SAL_CALL OSection::getName() throw (uno::RuntimeException)
275cdf0e10cSrcweir {
276cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
277cdf0e10cSrcweir 	return m_sName;
278cdf0e10cSrcweir }
279cdf0e10cSrcweir // -----------------------------------------------------------------------------
setName(const::rtl::OUString & _name)280cdf0e10cSrcweir void SAL_CALL OSection::setName( const ::rtl::OUString& _name ) throw (uno::RuntimeException)
281cdf0e10cSrcweir {
282cdf0e10cSrcweir 	set(PROPERTY_NAME,_name,m_sName);
283cdf0e10cSrcweir }
284cdf0e10cSrcweir // -----------------------------------------------------------------------------
getHeight()285cdf0e10cSrcweir ::sal_uInt32 SAL_CALL OSection::getHeight() throw (uno::RuntimeException)
286cdf0e10cSrcweir {
287cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
288cdf0e10cSrcweir 	return m_nHeight;
289cdf0e10cSrcweir }
290cdf0e10cSrcweir // -----------------------------------------------------------------------------
setHeight(::sal_uInt32 _height)291cdf0e10cSrcweir void SAL_CALL OSection::setHeight( ::sal_uInt32 _height ) throw (uno::RuntimeException)
292cdf0e10cSrcweir {
293cdf0e10cSrcweir 	set(PROPERTY_HEIGHT,_height,m_nHeight);
294cdf0e10cSrcweir }
295cdf0e10cSrcweir // -----------------------------------------------------------------------------
getBackColor()296cdf0e10cSrcweir ::sal_Int32 SAL_CALL OSection::getBackColor() throw (uno::RuntimeException)
297cdf0e10cSrcweir {
298cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
299cdf0e10cSrcweir     return m_bBacktransparent ? COL_TRANSPARENT : m_nBackgroundColor;
300cdf0e10cSrcweir }
301cdf0e10cSrcweir // -----------------------------------------------------------------------------
setBackColor(::sal_Int32 _backgroundcolor)302cdf0e10cSrcweir void SAL_CALL OSection::setBackColor( ::sal_Int32 _backgroundcolor ) throw (uno::RuntimeException)
303cdf0e10cSrcweir {
304cdf0e10cSrcweir     sal_Bool bTransparent = _backgroundcolor == static_cast<sal_Int32>(COL_TRANSPARENT);
305cdf0e10cSrcweir     setBackTransparent(bTransparent);
306cdf0e10cSrcweir     if ( !bTransparent )
307cdf0e10cSrcweir 	    set(PROPERTY_BACKCOLOR,_backgroundcolor,m_nBackgroundColor);
308cdf0e10cSrcweir }
309cdf0e10cSrcweir // -----------------------------------------------------------------------------
getBackTransparent()310cdf0e10cSrcweir ::sal_Bool SAL_CALL OSection::getBackTransparent() throw (uno::RuntimeException)
311cdf0e10cSrcweir {
312cdf0e10cSrcweir     ::osl::MutexGuard aGuard(m_aMutex);
313cdf0e10cSrcweir     return m_bBacktransparent;
314cdf0e10cSrcweir }
315cdf0e10cSrcweir // -----------------------------------------------------------------------------
setBackTransparent(::sal_Bool _backtransparent)316cdf0e10cSrcweir void SAL_CALL OSection::setBackTransparent( ::sal_Bool _backtransparent ) throw (uno::RuntimeException)
317cdf0e10cSrcweir {
318cdf0e10cSrcweir     set(PROPERTY_BACKTRANSPARENT,_backtransparent,m_bBacktransparent);
319cdf0e10cSrcweir     if ( _backtransparent )
320cdf0e10cSrcweir         set(PROPERTY_BACKCOLOR,static_cast<sal_Int32>(COL_TRANSPARENT),m_nBackgroundColor);
321cdf0e10cSrcweir }
322cdf0e10cSrcweir // -----------------------------------------------------------------------------
getConditionalPrintExpression()323cdf0e10cSrcweir ::rtl::OUString SAL_CALL OSection::getConditionalPrintExpression() throw (uno::RuntimeException)
324cdf0e10cSrcweir {
325cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
326cdf0e10cSrcweir 	return m_sConditionalPrintExpression;
327cdf0e10cSrcweir }
328cdf0e10cSrcweir // -----------------------------------------------------------------------------
setConditionalPrintExpression(const::rtl::OUString & _conditionalprintexpression)329cdf0e10cSrcweir void SAL_CALL OSection::setConditionalPrintExpression( const ::rtl::OUString& _conditionalprintexpression ) throw (uno::RuntimeException)
330cdf0e10cSrcweir {
331cdf0e10cSrcweir 	set(PROPERTY_CONDITIONALPRINTEXPRESSION,_conditionalprintexpression,m_sConditionalPrintExpression);
332cdf0e10cSrcweir }
333cdf0e10cSrcweir // -----------------------------------------------------------------------------
checkNotPageHeaderFooter()334cdf0e10cSrcweir void OSection::checkNotPageHeaderFooter()
335cdf0e10cSrcweir {
336cdf0e10cSrcweir     ::osl::MutexGuard aGuard(m_aMutex);
337cdf0e10cSrcweir     uno::Reference< report::XReportDefinition > xRet = m_xReportDefinition;
338cdf0e10cSrcweir     if ( xRet.is() )
339cdf0e10cSrcweir     {
340cdf0e10cSrcweir         if ( xRet->getPageHeaderOn() && xRet->getPageHeader() == *this )
341cdf0e10cSrcweir             throw beans::UnknownPropertyException();
342cdf0e10cSrcweir         if ( xRet->getPageFooterOn() && xRet->getPageFooter() == *this )
343cdf0e10cSrcweir             throw beans::UnknownPropertyException();
344cdf0e10cSrcweir     }
345cdf0e10cSrcweir }
346cdf0e10cSrcweir // -----------------------------------------------------------------------------
getForceNewPage()347cdf0e10cSrcweir ::sal_Int16 SAL_CALL OSection::getForceNewPage() throw (beans::UnknownPropertyException, uno::RuntimeException)
348cdf0e10cSrcweir {
349cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
350cdf0e10cSrcweir 
351cdf0e10cSrcweir     checkNotPageHeaderFooter();
352cdf0e10cSrcweir 	return m_nForceNewPage;
353cdf0e10cSrcweir }
354cdf0e10cSrcweir // -----------------------------------------------------------------------------
setForceNewPage(::sal_Int16 _forcenewpage)355cdf0e10cSrcweir void SAL_CALL OSection::setForceNewPage( ::sal_Int16 _forcenewpage ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException)
356cdf0e10cSrcweir {
357cdf0e10cSrcweir 	if ( _forcenewpage < report::ForceNewPage::NONE || _forcenewpage > report::ForceNewPage::BEFORE_AFTER_SECTION )
358cdf0e10cSrcweir 		throwIllegallArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com::sun::star::report::ForceNewPage"))
359cdf0e10cSrcweir                         ,*this
360cdf0e10cSrcweir                         ,1
361cdf0e10cSrcweir                         ,m_xContext);
362cdf0e10cSrcweir     checkNotPageHeaderFooter();
363cdf0e10cSrcweir 	set(PROPERTY_FORCENEWPAGE,_forcenewpage,m_nForceNewPage);
364cdf0e10cSrcweir }
365cdf0e10cSrcweir // -----------------------------------------------------------------------------
getNewRowOrCol()366cdf0e10cSrcweir ::sal_Int16 SAL_CALL OSection::getNewRowOrCol() throw (beans::UnknownPropertyException, uno::RuntimeException)
367cdf0e10cSrcweir {
368cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
369cdf0e10cSrcweir     checkNotPageHeaderFooter();
370cdf0e10cSrcweir 	return m_nNewRowOrCol;
371cdf0e10cSrcweir }
372cdf0e10cSrcweir // -----------------------------------------------------------------------------
setNewRowOrCol(::sal_Int16 _newroworcol)373cdf0e10cSrcweir void SAL_CALL OSection::setNewRowOrCol( ::sal_Int16 _newroworcol ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException)
374cdf0e10cSrcweir {
375cdf0e10cSrcweir 	if ( _newroworcol < report::ForceNewPage::NONE || _newroworcol > report::ForceNewPage::BEFORE_AFTER_SECTION )
376cdf0e10cSrcweir 		throwIllegallArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com::sun::star::report::ForceNewPage"))
377cdf0e10cSrcweir                         ,*this
378cdf0e10cSrcweir                         ,1
379cdf0e10cSrcweir                         ,m_xContext);
380cdf0e10cSrcweir     checkNotPageHeaderFooter();
381cdf0e10cSrcweir 
382cdf0e10cSrcweir 	set(PROPERTY_NEWROWORCOL,_newroworcol,m_nNewRowOrCol);
383cdf0e10cSrcweir }
384cdf0e10cSrcweir // -----------------------------------------------------------------------------
getKeepTogether()385cdf0e10cSrcweir ::sal_Bool SAL_CALL OSection::getKeepTogether() throw (beans::UnknownPropertyException, uno::RuntimeException)
386cdf0e10cSrcweir {
387cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
388cdf0e10cSrcweir     checkNotPageHeaderFooter();
389cdf0e10cSrcweir 	return m_bKeepTogether;
390cdf0e10cSrcweir }
391cdf0e10cSrcweir // -----------------------------------------------------------------------------
setKeepTogether(::sal_Bool _keeptogether)392cdf0e10cSrcweir void SAL_CALL OSection::setKeepTogether( ::sal_Bool _keeptogether ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException)
393cdf0e10cSrcweir {
394cdf0e10cSrcweir     {
395cdf0e10cSrcweir         ::osl::MutexGuard aGuard(m_aMutex);
396cdf0e10cSrcweir         checkNotPageHeaderFooter();
397cdf0e10cSrcweir     }
398cdf0e10cSrcweir 
399cdf0e10cSrcweir 	set(PROPERTY_KEEPTOGETHER,_keeptogether,m_bKeepTogether);
400cdf0e10cSrcweir }
401cdf0e10cSrcweir // -----------------------------------------------------------------------------
getCanGrow()402cdf0e10cSrcweir ::sal_Bool SAL_CALL OSection::getCanGrow() throw (beans::UnknownPropertyException, uno::RuntimeException)
403cdf0e10cSrcweir {
404cdf0e10cSrcweir     throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment
405cdf0e10cSrcweir }
406cdf0e10cSrcweir // -----------------------------------------------------------------------------
setCanGrow(::sal_Bool)407cdf0e10cSrcweir void SAL_CALL OSection::setCanGrow( ::sal_Bool /*_cangrow*/ ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException)
408cdf0e10cSrcweir {
409cdf0e10cSrcweir     throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment
410cdf0e10cSrcweir }
411cdf0e10cSrcweir // -----------------------------------------------------------------------------
getCanShrink()412cdf0e10cSrcweir ::sal_Bool SAL_CALL OSection::getCanShrink() throw (beans::UnknownPropertyException, uno::RuntimeException)
413cdf0e10cSrcweir {
414cdf0e10cSrcweir     throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment
415cdf0e10cSrcweir }
416cdf0e10cSrcweir // -----------------------------------------------------------------------------
setCanShrink(::sal_Bool)417cdf0e10cSrcweir void SAL_CALL OSection::setCanShrink( ::sal_Bool /*_canshrink*/ ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException)
418cdf0e10cSrcweir {
419cdf0e10cSrcweir     throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment
420cdf0e10cSrcweir }
421cdf0e10cSrcweir // -----------------------------------------------------------------------------
getRepeatSection()422cdf0e10cSrcweir ::sal_Bool SAL_CALL OSection::getRepeatSection() throw (beans::UnknownPropertyException, uno::RuntimeException)
423cdf0e10cSrcweir {
424cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
425cdf0e10cSrcweir     uno::Reference< report::XGroup > xGroup = m_xGroup;
426cdf0e10cSrcweir     if ( !xGroup.is() )
427cdf0e10cSrcweir         throw beans::UnknownPropertyException();
428cdf0e10cSrcweir 	return m_bRepeatSection;
429cdf0e10cSrcweir }
430cdf0e10cSrcweir // -----------------------------------------------------------------------------
setRepeatSection(::sal_Bool _repeatsection)431cdf0e10cSrcweir void SAL_CALL OSection::setRepeatSection( ::sal_Bool _repeatsection ) throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException)
432cdf0e10cSrcweir {
433cdf0e10cSrcweir     {
434cdf0e10cSrcweir         ::osl::MutexGuard aGuard(m_aMutex);
435cdf0e10cSrcweir         uno::Reference< report::XGroup > xGroup = m_xGroup;
436cdf0e10cSrcweir         if ( !xGroup.is() )
437cdf0e10cSrcweir             throw beans::UnknownPropertyException();
438cdf0e10cSrcweir     }
439cdf0e10cSrcweir 	set(PROPERTY_REPEATSECTION,_repeatsection,m_bRepeatSection);
440cdf0e10cSrcweir }
441cdf0e10cSrcweir // -----------------------------------------------------------------------------
getGroup()442cdf0e10cSrcweir uno::Reference< report::XGroup > SAL_CALL OSection::getGroup() throw (uno::RuntimeException)
443cdf0e10cSrcweir {
444cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
445cdf0e10cSrcweir 	return m_xGroup;
446cdf0e10cSrcweir }
447cdf0e10cSrcweir // -----------------------------------------------------------------------------
getReportDefinition()448cdf0e10cSrcweir uno::Reference< report::XReportDefinition > SAL_CALL OSection::getReportDefinition() throw (uno::RuntimeException)
449cdf0e10cSrcweir {
450cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
451cdf0e10cSrcweir 	uno::Reference< report::XReportDefinition > xRet = m_xReportDefinition;
452cdf0e10cSrcweir 	uno::Reference< report::XGroup > xGroup = m_xGroup;
453cdf0e10cSrcweir 	if ( !xRet.is() && xGroup.is() )
454cdf0e10cSrcweir 	{
455cdf0e10cSrcweir 		uno::Reference< report::XGroups> xGroups(xGroup->getGroups());
456cdf0e10cSrcweir 		if ( xGroups.is() )
457cdf0e10cSrcweir 			xRet = xGroups->getReportDefinition();
458cdf0e10cSrcweir 	}
459cdf0e10cSrcweir 
460cdf0e10cSrcweir 	return xRet;
461cdf0e10cSrcweir }
462cdf0e10cSrcweir // -----------------------------------------------------------------------------
lcl_getControlModelMap()463cdf0e10cSrcweir const ::std::vector< ::rtl::OUString >& lcl_getControlModelMap()
464cdf0e10cSrcweir {
465cdf0e10cSrcweir 	static ::std::vector< ::rtl::OUString > s_sControlModels;
466cdf0e10cSrcweir 	if ( s_sControlModels.empty() )
467cdf0e10cSrcweir 	{
468cdf0e10cSrcweir 		s_sControlModels.push_back( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FixedText")) );
469cdf0e10cSrcweir         s_sControlModels.push_back( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FixedLine")) );
470cdf0e10cSrcweir 		s_sControlModels.push_back( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageControl")) );
471cdf0e10cSrcweir 		s_sControlModels.push_back( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FormattedField")) );
472cdf0e10cSrcweir         s_sControlModels.push_back( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Shape")) );
473cdf0e10cSrcweir 	} // if ( s_sMap.empty() )
474cdf0e10cSrcweir 	return s_sControlModels;
475cdf0e10cSrcweir 
476cdf0e10cSrcweir }
477cdf0e10cSrcweir // -----------------------------------------------------------------------------
createReportComponent(const::rtl::OUString & _sReportComponentSpecifier)478cdf0e10cSrcweir uno::Reference< report::XReportComponent > SAL_CALL OSection::createReportComponent( const ::rtl::OUString& _sReportComponentSpecifier ) throw (uno::Exception, lang::IllegalArgumentException,uno::RuntimeException)
479cdf0e10cSrcweir {
480cdf0e10cSrcweir 	::osl::ResettableMutexGuard aGuard(m_aMutex);
481cdf0e10cSrcweir 	const ::std::vector< ::rtl::OUString >& aRet = lcl_getControlModelMap();
482cdf0e10cSrcweir 	::std::vector< ::rtl::OUString >::const_iterator aFind = ::std::find(aRet.begin(),aRet.end(),_sReportComponentSpecifier);
483cdf0e10cSrcweir 	if ( aFind == aRet.end() )
484cdf0e10cSrcweir 		throw lang::IllegalArgumentException();
485cdf0e10cSrcweir 
486cdf0e10cSrcweir 	uno::Reference< report::XReportComponent > xRet;
487cdf0e10cSrcweir     uno::Reference< lang::XMultiServiceFactory> xFac(getReportDefinition(),uno::UNO_QUERY_THROW);
488cdf0e10cSrcweir 	switch( aFind - aRet.begin()  )
489cdf0e10cSrcweir 	{
490cdf0e10cSrcweir 		case 0:
491cdf0e10cSrcweir             xRet.set(xFac->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText"))),uno::UNO_QUERY);
492cdf0e10cSrcweir 			break;
493cdf0e10cSrcweir         case 1:
494cdf0e10cSrcweir             xRet.set(xFac->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedLineModel"))),uno::UNO_QUERY);
495cdf0e10cSrcweir 			break;
496cdf0e10cSrcweir 		case 2:
497cdf0e10cSrcweir             xRet.set(xFac->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.DatabaseImageControl"))),uno::UNO_QUERY);
498cdf0e10cSrcweir 			break;
499cdf0e10cSrcweir 		case 3:
500cdf0e10cSrcweir 			xRet.set(xFac->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FormattedField"))),uno::UNO_QUERY);
501cdf0e10cSrcweir 			break;
502cdf0e10cSrcweir         case 4:
503cdf0e10cSrcweir 			xRet.set(xFac->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ControlShape"))),uno::UNO_QUERY);
504cdf0e10cSrcweir 			break;
505cdf0e10cSrcweir         default:
506cdf0e10cSrcweir 			//xRet = new OShape(m_xContext);
507cdf0e10cSrcweir 			break;
508cdf0e10cSrcweir 	} // switch( aRet.begin() - aFind  )
509cdf0e10cSrcweir 	return xRet;
510cdf0e10cSrcweir }
511cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAvailableReportComponentNames()512cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL OSection::getAvailableReportComponentNames(  ) throw (uno::RuntimeException)
513cdf0e10cSrcweir {
514cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
515cdf0e10cSrcweir 
516cdf0e10cSrcweir 	const ::std::vector< ::rtl::OUString >& aRet = lcl_getControlModelMap();
517cdf0e10cSrcweir 	const ::rtl::OUString* pRet = aRet.empty() ? 0 : &aRet[0];
518cdf0e10cSrcweir 	return uno::Sequence< ::rtl::OUString >(pRet, aRet.size());
519cdf0e10cSrcweir }
520cdf0e10cSrcweir // -----------------------------------------------------------------------------
521cdf0e10cSrcweir // XChild
getParent()522cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL OSection::getParent(  ) throw (uno::RuntimeException)
523cdf0e10cSrcweir {
524cdf0e10cSrcweir 	uno::Reference< uno::XInterface > xRet;
525cdf0e10cSrcweir 	{
526cdf0e10cSrcweir 		::osl::MutexGuard aGuard(m_aMutex);
527cdf0e10cSrcweir 		xRet = m_xReportDefinition;
528cdf0e10cSrcweir 		if ( !xRet.is() )
529cdf0e10cSrcweir 			xRet = m_xGroup;
530cdf0e10cSrcweir 	}
531cdf0e10cSrcweir 	return  xRet;
532cdf0e10cSrcweir }
533cdf0e10cSrcweir // -----------------------------------------------------------------------------
setParent(const uno::Reference<uno::XInterface> &)534cdf0e10cSrcweir void SAL_CALL OSection::setParent( const uno::Reference< uno::XInterface >& /*Parent*/ ) throw (lang::NoSupportException, uno::RuntimeException)
535cdf0e10cSrcweir {
536cdf0e10cSrcweir 	throw lang::NoSupportException();
537cdf0e10cSrcweir }
538cdf0e10cSrcweir // -----------------------------------------------------------------------------
539cdf0e10cSrcweir // XContainer
addContainerListener(const uno::Reference<container::XContainerListener> & xListener)540cdf0e10cSrcweir void SAL_CALL OSection::addContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException)
541cdf0e10cSrcweir {
542cdf0e10cSrcweir 	m_aContainerListeners.addInterface(xListener);
543cdf0e10cSrcweir }
544cdf0e10cSrcweir // -----------------------------------------------------------------------------
removeContainerListener(const uno::Reference<container::XContainerListener> & xListener)545cdf0e10cSrcweir void SAL_CALL OSection::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException)
546cdf0e10cSrcweir {
547cdf0e10cSrcweir 	m_aContainerListeners.removeInterface(xListener);
548cdf0e10cSrcweir }
549cdf0e10cSrcweir // -----------------------------------------------------------------------------
550cdf0e10cSrcweir // XElementAccess
getElementType()551cdf0e10cSrcweir uno::Type SAL_CALL OSection::getElementType(  ) throw (uno::RuntimeException)
552cdf0e10cSrcweir {
553cdf0e10cSrcweir 	return ::getCppuType(static_cast< uno::Reference<report::XReportComponent>*>(NULL));
554cdf0e10cSrcweir }
555cdf0e10cSrcweir // -----------------------------------------------------------------------------
hasElements()556cdf0e10cSrcweir ::sal_Bool SAL_CALL OSection::hasElements(  ) throw (uno::RuntimeException)
557cdf0e10cSrcweir {
558cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
559cdf0e10cSrcweir     return m_xDrawPage.is() ? m_xDrawPage->hasElements() : sal_False;
560cdf0e10cSrcweir }
561cdf0e10cSrcweir // -----------------------------------------------------------------------------
562cdf0e10cSrcweir // XIndexAccess
getCount()563cdf0e10cSrcweir ::sal_Int32 SAL_CALL OSection::getCount(  ) throw (uno::RuntimeException)
564cdf0e10cSrcweir {
565cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
566cdf0e10cSrcweir     return m_xDrawPage.is() ? m_xDrawPage->getCount() : 0;
567cdf0e10cSrcweir }
568cdf0e10cSrcweir // -----------------------------------------------------------------------------
getByIndex(::sal_Int32 Index)569cdf0e10cSrcweir uno::Any SAL_CALL OSection::getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
570cdf0e10cSrcweir {
571cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
572cdf0e10cSrcweir     return m_xDrawPage->getByIndex(Index);
573cdf0e10cSrcweir }
574cdf0e10cSrcweir // -----------------------------------------------------------------------------
575cdf0e10cSrcweir // XEnumerationAccess
createEnumeration()576cdf0e10cSrcweir uno::Reference< container::XEnumeration > SAL_CALL OSection::createEnumeration(  ) throw (uno::RuntimeException)
577cdf0e10cSrcweir {
578cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
579cdf0e10cSrcweir 	return new ::comphelper::OEnumerationByIndex(static_cast<XIndexAccess*>(this));
580cdf0e10cSrcweir }
581cdf0e10cSrcweir // -----------------------------------------------------------------------------
getPropertySetInfo()582cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SAL_CALL OSection::getPropertySetInfo(  ) throw(uno::RuntimeException)
583cdf0e10cSrcweir {
584cdf0e10cSrcweir 	return SectionPropertySet::getPropertySetInfo();
585cdf0e10cSrcweir }
586cdf0e10cSrcweir // -------------------------------------------------------------------------
setPropertyValue(const::rtl::OUString & aPropertyName,const uno::Any & aValue)587cdf0e10cSrcweir void SAL_CALL OSection::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
588cdf0e10cSrcweir {
589cdf0e10cSrcweir 	SectionPropertySet::setPropertyValue( aPropertyName, aValue );
590cdf0e10cSrcweir }
591cdf0e10cSrcweir // -----------------------------------------------------------------------------
getPropertyValue(const::rtl::OUString & PropertyName)592cdf0e10cSrcweir uno::Any SAL_CALL OSection::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
593cdf0e10cSrcweir {
594cdf0e10cSrcweir 	return SectionPropertySet::getPropertyValue( PropertyName);
595cdf0e10cSrcweir }
596cdf0e10cSrcweir // -----------------------------------------------------------------------------
addPropertyChangeListener(const::rtl::OUString & aPropertyName,const uno::Reference<beans::XPropertyChangeListener> & xListener)597cdf0e10cSrcweir void SAL_CALL OSection::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
598cdf0e10cSrcweir {
599cdf0e10cSrcweir 	SectionPropertySet::addPropertyChangeListener( aPropertyName, xListener );
600cdf0e10cSrcweir }
601cdf0e10cSrcweir // -----------------------------------------------------------------------------
removePropertyChangeListener(const::rtl::OUString & aPropertyName,const uno::Reference<beans::XPropertyChangeListener> & aListener)602cdf0e10cSrcweir void SAL_CALL OSection::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
603cdf0e10cSrcweir {
604cdf0e10cSrcweir 	SectionPropertySet::removePropertyChangeListener( aPropertyName, aListener );
605cdf0e10cSrcweir }
606cdf0e10cSrcweir // -----------------------------------------------------------------------------
addVetoableChangeListener(const::rtl::OUString & PropertyName,const uno::Reference<beans::XVetoableChangeListener> & aListener)607cdf0e10cSrcweir void SAL_CALL OSection::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
608cdf0e10cSrcweir {
609cdf0e10cSrcweir 	SectionPropertySet::addVetoableChangeListener( PropertyName, aListener );
610cdf0e10cSrcweir }
611cdf0e10cSrcweir // -----------------------------------------------------------------------------
removeVetoableChangeListener(const::rtl::OUString & PropertyName,const uno::Reference<beans::XVetoableChangeListener> & aListener)612cdf0e10cSrcweir void SAL_CALL OSection::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
613cdf0e10cSrcweir {
614cdf0e10cSrcweir 	SectionPropertySet::removeVetoableChangeListener( PropertyName, aListener );
615cdf0e10cSrcweir }
616cdf0e10cSrcweir // -----------------------------------------------------------------------------
lcl_copySection(const uno::Reference<report::XSection> & _xSource,uno::Reference<report::XSection> & _xDest)617cdf0e10cSrcweir void OSection::lcl_copySection(const uno::Reference< report::XSection>& _xSource,uno::Reference< report::XSection>& _xDest)
618cdf0e10cSrcweir {
619cdf0e10cSrcweir 	if ( _xSource.is() )
620cdf0e10cSrcweir 	{
621cdf0e10cSrcweir 		::comphelper::copyProperties(_xSource.get(),_xDest.get());
622cdf0e10cSrcweir 		sal_Int32 nCount = _xSource->getCount();
623cdf0e10cSrcweir 		for(sal_Int32 i = 0;i != nCount;++i)
624cdf0e10cSrcweir 		{
625cdf0e10cSrcweir 			uno::Reference<util::XCloneable> xClone(_xSource->getByIndex(i),uno::UNO_QUERY);
626cdf0e10cSrcweir 			OSL_ENSURE(xClone.is(),"No XCloneable interface found!");
627cdf0e10cSrcweir 			if ( xClone.is() )
628cdf0e10cSrcweir             {
629cdf0e10cSrcweir                 uno::Reference< drawing::XShape> xShape(xClone->createClone(),uno::UNO_QUERY);
630cdf0e10cSrcweir                 _xDest->add(xShape);
631cdf0e10cSrcweir             }
632cdf0e10cSrcweir 		}
633cdf0e10cSrcweir 	}
634cdf0e10cSrcweir }
635cdf0e10cSrcweir // -----------------------------------------------------------------------------
add(const uno::Reference<drawing::XShape> & xShape)636cdf0e10cSrcweir void SAL_CALL OSection::add( const uno::Reference< drawing::XShape >& xShape ) throw (uno::RuntimeException)
637cdf0e10cSrcweir {
638cdf0e10cSrcweir     {
639cdf0e10cSrcweir         ::osl::MutexGuard aGuard(m_aMutex);
640cdf0e10cSrcweir         m_bInInsertNotify = true;
641cdf0e10cSrcweir         OSL_ENSURE(m_xDrawPage.is(),"No DrawPage!");
642cdf0e10cSrcweir         m_xDrawPage->add(xShape);
643cdf0e10cSrcweir         m_bInInsertNotify = false;
644cdf0e10cSrcweir     }
645cdf0e10cSrcweir     notifyElementAdded(xShape);
646cdf0e10cSrcweir }
647cdf0e10cSrcweir // -----------------------------------------------------------------------------
remove(const uno::Reference<drawing::XShape> & xShape)648cdf0e10cSrcweir void SAL_CALL OSection::remove( const uno::Reference< drawing::XShape >& xShape ) throw (uno::RuntimeException)
649cdf0e10cSrcweir {
650cdf0e10cSrcweir     {
651cdf0e10cSrcweir         ::osl::MutexGuard aGuard(m_aMutex);
652cdf0e10cSrcweir         m_bInRemoveNotify = true;
653cdf0e10cSrcweir         OSL_ENSURE(m_xDrawPage.is(),"No DrawPage!");
654cdf0e10cSrcweir         m_xDrawPage->remove(xShape);
655cdf0e10cSrcweir         m_bInRemoveNotify = false;
656cdf0e10cSrcweir     }
657cdf0e10cSrcweir     notifyElementRemoved(xShape);
658cdf0e10cSrcweir }
659cdf0e10cSrcweir // -----------------------------------------------------------------------------
660cdf0e10cSrcweir // -----------------------------------------------------------------------------
661cdf0e10cSrcweir // com::sun::star::lang::XUnoTunnel
662cdf0e10cSrcweir //------------------------------------------------------------------
getSomething(const uno::Sequence<sal_Int8> & rId)663cdf0e10cSrcweir sal_Int64 OSection::getSomething( const uno::Sequence< sal_Int8 > & rId ) throw (uno::RuntimeException)
664cdf0e10cSrcweir {
665cdf0e10cSrcweir 	if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(),  rId.getConstArray(), 16 ) )
666cdf0e10cSrcweir 		return reinterpret_cast<sal_Int64>(this);
667cdf0e10cSrcweir     uno::Reference< lang::XUnoTunnel> xTunnel;
668cdf0e10cSrcweir     ::comphelper::query_aggregation(m_xProxy,xTunnel);
669cdf0e10cSrcweir 	return xTunnel->getSomething(rId);
670cdf0e10cSrcweir }
671cdf0e10cSrcweir 
672cdf0e10cSrcweir // -----------------------------------------------------------------------------
getImplementation(const uno::Reference<uno::XInterface> & _rxComponent)673cdf0e10cSrcweir OSection* OSection::getImplementation( const uno::Reference< uno::XInterface >& _rxComponent )
674cdf0e10cSrcweir {
675cdf0e10cSrcweir 	OSection* pContent( NULL );
676cdf0e10cSrcweir 
677cdf0e10cSrcweir     uno::Reference< lang::XUnoTunnel > xUnoTunnel( _rxComponent, uno::UNO_QUERY );
678cdf0e10cSrcweir 	if ( xUnoTunnel.is() )
679cdf0e10cSrcweir 		pContent = reinterpret_cast< OSection* >( xUnoTunnel->getSomething( getUnoTunnelImplementationId() ) );
680cdf0e10cSrcweir 
681cdf0e10cSrcweir     return pContent;
682cdf0e10cSrcweir }
683cdf0e10cSrcweir //------------------------------------------------------------------------
getUnoTunnelImplementationId()684cdf0e10cSrcweir uno::Sequence< sal_Int8 > OSection::getUnoTunnelImplementationId()
685cdf0e10cSrcweir {
686cdf0e10cSrcweir 	static ::cppu::OImplementationId * pId = 0;
687cdf0e10cSrcweir 	if (! pId)
688cdf0e10cSrcweir 	{
689cdf0e10cSrcweir 		::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
690cdf0e10cSrcweir 		if (! pId)
691cdf0e10cSrcweir 		{
692cdf0e10cSrcweir 			static ::cppu::OImplementationId aId;
693cdf0e10cSrcweir 			pId = &aId;
694cdf0e10cSrcweir 		}
695cdf0e10cSrcweir 	}
696cdf0e10cSrcweir 	return pId->getImplementationId();
697cdf0e10cSrcweir }
698cdf0e10cSrcweir // -----------------------------------------------------------------------------
notifyElementAdded(const uno::Reference<drawing::XShape> & xShape)699cdf0e10cSrcweir void OSection::notifyElementAdded(const uno::Reference< drawing::XShape >& xShape )
700cdf0e10cSrcweir {
701cdf0e10cSrcweir     if ( !m_bInInsertNotify )
702cdf0e10cSrcweir     {
703cdf0e10cSrcweir         container::ContainerEvent aEvent(static_cast<container::XContainer*>(this), uno::Any(), uno::makeAny(xShape), uno::Any());
704cdf0e10cSrcweir 	    m_aContainerListeners.notifyEach(&container::XContainerListener::elementInserted,aEvent);
705cdf0e10cSrcweir     }
706cdf0e10cSrcweir }
707cdf0e10cSrcweir // -----------------------------------------------------------------------------
notifyElementRemoved(const uno::Reference<drawing::XShape> & xShape)708cdf0e10cSrcweir void OSection::notifyElementRemoved(const uno::Reference< drawing::XShape >& xShape)
709cdf0e10cSrcweir {
710cdf0e10cSrcweir     if ( !m_bInRemoveNotify )
711cdf0e10cSrcweir     {
712cdf0e10cSrcweir         // notify our container listeners
713cdf0e10cSrcweir         container::ContainerEvent aEvent(static_cast<container::XContainer*>(this), uno::Any(), uno::makeAny(xShape), uno::Any());
714cdf0e10cSrcweir 	    m_aContainerListeners.notifyEach(&container::XContainerListener::elementRemoved,aEvent);
715cdf0e10cSrcweir     }
716cdf0e10cSrcweir }
717cdf0e10cSrcweir // =============================================================================
718cdf0e10cSrcweir } // namespace reportdesign
719cdf0e10cSrcweir // =============================================================================
720