1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Section.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "Section.hxx"
31 #include <comphelper/enumhelper.hxx>
32 #include <connectivity/dbtools.hxx>
33 #include <com/sun/star/report/XReportComponent.hpp>
34 #include <com/sun/star/report/ForceNewPage.hpp>
35 #include <com/sun/star/beans/PropertyAttribute.hpp>
36 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 #ifndef REPORTDESIGN_SHARED_CORESTRINGS_HRC
38 #include "corestrings.hrc"
40 #include "core_resource.hxx"
41 #ifndef REPORTDESIGN_CORE_RESOURCE_HRC_
42 #include "core_resource.hrc"
44 #include <tools/debug.hxx>
46 #include "RptModel.hxx"
47 #include "RptPage.hxx"
48 #include "ReportDefinition.hxx"
50 #include <svx/unoshape.hxx>
51 #include "RptObject.hxx"
52 #include "ReportDrawPage.hxx"
53 #include <comphelper/property.hxx>
54 // =============================================================================
55 namespace reportdesign
57 // =============================================================================
58 using namespace com::sun::star
;
59 using namespace comphelper
;
60 DBG_NAME( rpt_OSection
)
61 // -----------------------------------------------------------------------------
62 uno::Sequence
< ::rtl::OUString
> lcl_getGroupAbsent()
64 ::rtl::OUString pProps
[] = {
69 return uno::Sequence
< ::rtl::OUString
>(pProps
,sizeof(pProps
)/sizeof(pProps
[0]));
72 // -----------------------------------------------------------------------------
73 OSection::OSection( const uno::Reference
< report::XGroup
>& _xParent
74 ,const uno::Reference
< uno::XComponentContext
>& context
75 ,bool /*_bPageSection*/)
76 :SectionBase(m_aMutex
)
77 ,SectionPropertySet(context
,static_cast< Implements
>(IMPLEMENTS_PROPERTY_SET
),lcl_getGroupAbsent())
78 ,m_aContainerListeners(m_aMutex
)
82 ,m_nBackgroundColor(COL_TRANSPARENT
)
83 ,m_nForceNewPage(report::ForceNewPage::NONE
)
84 ,m_nNewRowOrCol(report::ForceNewPage::NONE
)
85 ,m_bKeepTogether(sal_False
)
86 ,m_bCanGrow(sal_False
)
87 ,m_bCanShrink(sal_False
)
88 ,m_bRepeatSection(sal_False
)
90 ,m_bBacktransparent(sal_True
)
91 ,m_bInRemoveNotify(false)
92 ,m_bInInsertNotify(false)
94 DBG_CTOR( rpt_OSection
,NULL
);
97 // -----------------------------------------------------------------------------
98 uno::Sequence
< ::rtl::OUString
> lcl_getAbsent(bool _bPageSection
)
102 ::rtl::OUString pProps
[] = {
103 PROPERTY_FORCENEWPAGE
104 ,PROPERTY_NEWROWORCOL
105 ,PROPERTY_KEEPTOGETHER
108 ,PROPERTY_REPEATSECTION
110 return uno::Sequence
< ::rtl::OUString
>(pProps
,sizeof(pProps
)/sizeof(pProps
[0]));
113 ::rtl::OUString pProps
[] = {
116 ,PROPERTY_REPEATSECTION
119 return uno::Sequence
< ::rtl::OUString
>(pProps
,sizeof(pProps
)/sizeof(pProps
[0]));
121 // -----------------------------------------------------------------------------
122 OSection::OSection(const uno::Reference
< report::XReportDefinition
>& _xParent
123 ,const uno::Reference
< uno::XComponentContext
>& context
125 :SectionBase(m_aMutex
)
126 ,SectionPropertySet(context
,SectionPropertySet::IMPLEMENTS_PROPERTY_SET
,lcl_getAbsent(_bPageSection
))
127 ,m_aContainerListeners(m_aMutex
)
129 ,m_xReportDefinition(_xParent
)
131 ,m_nBackgroundColor(COL_TRANSPARENT
)
132 ,m_nForceNewPage(report::ForceNewPage::NONE
)
133 ,m_nNewRowOrCol(report::ForceNewPage::NONE
)
134 ,m_bKeepTogether(sal_False
)
135 ,m_bCanGrow(sal_False
)
136 ,m_bCanShrink(sal_False
)
137 ,m_bRepeatSection(sal_False
)
138 ,m_bVisible(sal_True
)
139 ,m_bBacktransparent(sal_True
)
140 ,m_bInRemoveNotify(false)
141 ,m_bInInsertNotify(false)
143 DBG_CTOR( rpt_OSection
,NULL
);
145 //.getSdrModel()->createNewPage(m_xSection);
147 //--------------------------------------------------------------------------
148 // TODO: VirtualFunctionFinder: This is virtual function!
150 OSection::~OSection()
152 DBG_DTOR( rpt_OSection
,NULL
);
154 m_xProxy
->setDelegator( NULL
);
156 //--------------------------------------------------------------------------
157 //IMPLEMENT_FORWARD_XINTERFACE2(OSection,SectionBase,SectionPropertySet)
158 IMPLEMENT_FORWARD_REFCOUNT( OSection
, SectionBase
)
159 // --------------------------------------------------------------------------------
160 uno::Any SAL_CALL
OSection::queryInterface( const uno::Type
& _rType
) throw (uno::RuntimeException
)
162 uno::Any aReturn
= SectionBase::queryInterface(_rType
);
163 if ( !aReturn
.hasValue() )
164 aReturn
= SectionPropertySet::queryInterface(_rType
);
166 if ( !aReturn
.hasValue() && OReportControlModel::isInterfaceForbidden(_rType
) )
169 return aReturn
.hasValue() ? aReturn
: (m_xProxy
.is() ? m_xProxy
->queryAggregation(_rType
) : aReturn
);
172 // -----------------------------------------------------------------------------
173 void SAL_CALL
OSection::dispose() throw(uno::RuntimeException
)
175 OSL_ENSURE(!rBHelper
.bDisposed
,"Already disposed!");
176 SectionPropertySet::dispose();
177 cppu::WeakComponentImplHelperBase::dispose();
180 // -----------------------------------------------------------------------------
181 // TODO: VirtualFunctionFinder: This is virtual function!
183 void SAL_CALL
OSection::disposing()
185 lang::EventObject
aDisposeEvent( static_cast< ::cppu::OWeakObject
* >( this ) );
186 m_aContainerListeners
.disposeAndClear( aDisposeEvent
);
188 //m_xDrawPage.clear();
190 /*uno::Reference< report::XReportDefinition> xReport = getReportDefinition();
191 ::boost::shared_ptr<rptui::OReportModel> pModel = OReportDefinition::getSdrModel(xReport);
192 osl_incrementInterlockedCount( &m_refCount );
193 while( m_xDrawPage.is() && m_xDrawPage->hasElements() )
197 uno::Reference< drawing::XShape> xShape(m_xDrawPage->getByIndex(0),uno::UNO_QUERY);
198 m_xDrawPage->remove(xShape);
199 ::comphelper::disposeComponent(xShape);
201 catch(const uno::Exception&)
206 uno::Reference< report::XSection> xSection = this;
207 pModel->DeletePage(pModel->getPage(xSection)->GetPageNum());
209 osl_decrementInterlockedCount( &m_refCount );*/
211 //--------------------------------------------------------------------------
212 ::rtl::OUString SAL_CALL
OSection::getImplementationName( ) throw(uno::RuntimeException
)
214 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.Section"));
216 //------------------------------------------------------------------------------
217 uno::Sequence
< ::rtl::OUString
> OSection::getSupportedServiceNames_Static(void) throw( uno::RuntimeException
)
219 uno::Sequence
< ::rtl::OUString
> aSupported(1);
220 aSupported
.getArray()[0] = SERVICE_SECTION
;
223 //-------------------------------------------------------------------------
224 uno::Sequence
< ::rtl::OUString
> SAL_CALL
OSection::getSupportedServiceNames() throw(uno::RuntimeException
)
226 return getSupportedServiceNames_Static();
228 // -----------------------------------------------------------------------------
229 sal_Bool SAL_CALL
OSection::supportsService( const ::rtl::OUString
& _rServiceName
) throw(uno::RuntimeException
)
231 return ::comphelper::existsValue(_rServiceName
,getSupportedServiceNames_Static());
233 // -----------------------------------------------------------------------------
234 void OSection::init()
236 uno::Reference
< report::XReportDefinition
> xReport
= getReportDefinition();
237 ::boost::shared_ptr
<rptui::OReportModel
> pModel
= OReportDefinition::getSdrModel(xReport
);
238 OSL_ENSURE(pModel
,"No odel set at the report definition!");
241 // DO NOT TOUCH THIS BLOCKS, WE HAVE A COMPILER PROBLEM UNDER SOLARIS X86
242 osl_incrementInterlockedCount( &m_refCount
);
244 uno::Reference
<report::XSection
> xTemp
= this;
247 m_xProxy
.set(pModel
->createNewPage(xTemp
)->getUnoPage(),uno::UNO_QUERY
);
250 ::comphelper::query_aggregation(m_xProxy
,m_xDrawPage
);
253 // set ourself as delegator
257 m_xProxy
->setDelegator( xTemp
);
263 // DO NOT TOUCH THIS BLOCKS, WE HAVE A COMPILER PROBLEM UNDER SOLARIS X86
264 osl_decrementInterlockedCount( &m_refCount
);
267 // -----------------------------------------------------------------------------
269 // -----------------------------------------------------------------------------
270 ::sal_Bool SAL_CALL
OSection::getVisible() throw (uno::RuntimeException
)
272 ::osl::MutexGuard
aGuard(m_aMutex
);
275 // -----------------------------------------------------------------------------
276 void SAL_CALL
OSection::setVisible( ::sal_Bool _visible
) throw (uno::RuntimeException
)
278 set(PROPERTY_VISIBLE
,_visible
,m_bVisible
);
280 // -----------------------------------------------------------------------------
281 ::rtl::OUString SAL_CALL
OSection::getName() throw (uno::RuntimeException
)
283 ::osl::MutexGuard
aGuard(m_aMutex
);
286 // -----------------------------------------------------------------------------
287 void SAL_CALL
OSection::setName( const ::rtl::OUString
& _name
) throw (uno::RuntimeException
)
289 set(PROPERTY_NAME
,_name
,m_sName
);
291 // -----------------------------------------------------------------------------
292 ::sal_uInt32 SAL_CALL
OSection::getHeight() throw (uno::RuntimeException
)
294 ::osl::MutexGuard
aGuard(m_aMutex
);
297 // -----------------------------------------------------------------------------
298 void SAL_CALL
OSection::setHeight( ::sal_uInt32 _height
) throw (uno::RuntimeException
)
300 set(PROPERTY_HEIGHT
,_height
,m_nHeight
);
302 // -----------------------------------------------------------------------------
303 ::sal_Int32 SAL_CALL
OSection::getBackColor() throw (uno::RuntimeException
)
305 ::osl::MutexGuard
aGuard(m_aMutex
);
306 return m_bBacktransparent
? COL_TRANSPARENT
: m_nBackgroundColor
;
308 // -----------------------------------------------------------------------------
309 void SAL_CALL
OSection::setBackColor( ::sal_Int32 _backgroundcolor
) throw (uno::RuntimeException
)
311 sal_Bool bTransparent
= _backgroundcolor
== static_cast<sal_Int32
>(COL_TRANSPARENT
);
312 setBackTransparent(bTransparent
);
314 set(PROPERTY_BACKCOLOR
,_backgroundcolor
,m_nBackgroundColor
);
316 // -----------------------------------------------------------------------------
317 ::sal_Bool SAL_CALL
OSection::getBackTransparent() throw (uno::RuntimeException
)
319 ::osl::MutexGuard
aGuard(m_aMutex
);
320 return m_bBacktransparent
;
322 // -----------------------------------------------------------------------------
323 void SAL_CALL
OSection::setBackTransparent( ::sal_Bool _backtransparent
) throw (uno::RuntimeException
)
325 set(PROPERTY_BACKTRANSPARENT
,_backtransparent
,m_bBacktransparent
);
326 if ( _backtransparent
)
327 set(PROPERTY_BACKCOLOR
,static_cast<sal_Int32
>(COL_TRANSPARENT
),m_nBackgroundColor
);
329 // -----------------------------------------------------------------------------
330 ::rtl::OUString SAL_CALL
OSection::getConditionalPrintExpression() throw (uno::RuntimeException
)
332 ::osl::MutexGuard
aGuard(m_aMutex
);
333 return m_sConditionalPrintExpression
;
335 // -----------------------------------------------------------------------------
336 void SAL_CALL
OSection::setConditionalPrintExpression( const ::rtl::OUString
& _conditionalprintexpression
) throw (uno::RuntimeException
)
338 set(PROPERTY_CONDITIONALPRINTEXPRESSION
,_conditionalprintexpression
,m_sConditionalPrintExpression
);
340 // -----------------------------------------------------------------------------
341 void OSection::checkNotPageHeaderFooter()
343 ::osl::MutexGuard
aGuard(m_aMutex
);
344 uno::Reference
< report::XReportDefinition
> xRet
= m_xReportDefinition
;
347 if ( xRet
->getPageHeaderOn() && xRet
->getPageHeader() == *this )
348 throw beans::UnknownPropertyException();
349 if ( xRet
->getPageFooterOn() && xRet
->getPageFooter() == *this )
350 throw beans::UnknownPropertyException();
353 // -----------------------------------------------------------------------------
354 ::sal_Int16 SAL_CALL
OSection::getForceNewPage() throw (beans::UnknownPropertyException
, uno::RuntimeException
)
356 ::osl::MutexGuard
aGuard(m_aMutex
);
358 checkNotPageHeaderFooter();
359 return m_nForceNewPage
;
361 // -----------------------------------------------------------------------------
362 void SAL_CALL
OSection::setForceNewPage( ::sal_Int16 _forcenewpage
) throw (lang::IllegalArgumentException
, beans::UnknownPropertyException
, uno::RuntimeException
)
364 if ( _forcenewpage
< report::ForceNewPage::NONE
|| _forcenewpage
> report::ForceNewPage::BEFORE_AFTER_SECTION
)
365 throwIllegallArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com::sun::star::report::ForceNewPage"))
369 checkNotPageHeaderFooter();
370 set(PROPERTY_FORCENEWPAGE
,_forcenewpage
,m_nForceNewPage
);
372 // -----------------------------------------------------------------------------
373 ::sal_Int16 SAL_CALL
OSection::getNewRowOrCol() throw (beans::UnknownPropertyException
, uno::RuntimeException
)
375 ::osl::MutexGuard
aGuard(m_aMutex
);
376 checkNotPageHeaderFooter();
377 return m_nNewRowOrCol
;
379 // -----------------------------------------------------------------------------
380 void SAL_CALL
OSection::setNewRowOrCol( ::sal_Int16 _newroworcol
) throw (lang::IllegalArgumentException
, beans::UnknownPropertyException
, uno::RuntimeException
)
382 if ( _newroworcol
< report::ForceNewPage::NONE
|| _newroworcol
> report::ForceNewPage::BEFORE_AFTER_SECTION
)
383 throwIllegallArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com::sun::star::report::ForceNewPage"))
387 checkNotPageHeaderFooter();
389 set(PROPERTY_NEWROWORCOL
,_newroworcol
,m_nNewRowOrCol
);
391 // -----------------------------------------------------------------------------
392 ::sal_Bool SAL_CALL
OSection::getKeepTogether() throw (beans::UnknownPropertyException
, uno::RuntimeException
)
394 ::osl::MutexGuard
aGuard(m_aMutex
);
395 checkNotPageHeaderFooter();
396 return m_bKeepTogether
;
398 // -----------------------------------------------------------------------------
399 void SAL_CALL
OSection::setKeepTogether( ::sal_Bool _keeptogether
) throw (lang::IllegalArgumentException
, beans::UnknownPropertyException
, uno::RuntimeException
)
402 ::osl::MutexGuard
aGuard(m_aMutex
);
403 checkNotPageHeaderFooter();
406 set(PROPERTY_KEEPTOGETHER
,_keeptogether
,m_bKeepTogether
);
408 // -----------------------------------------------------------------------------
409 ::sal_Bool SAL_CALL
OSection::getCanGrow() throw (beans::UnknownPropertyException
, uno::RuntimeException
)
411 throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment
413 // -----------------------------------------------------------------------------
414 void SAL_CALL
OSection::setCanGrow( ::sal_Bool
/*_cangrow*/ ) throw (lang::IllegalArgumentException
, beans::UnknownPropertyException
, uno::RuntimeException
)
416 throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment
418 // -----------------------------------------------------------------------------
419 ::sal_Bool SAL_CALL
OSection::getCanShrink() throw (beans::UnknownPropertyException
, uno::RuntimeException
)
421 throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment
423 // -----------------------------------------------------------------------------
424 void SAL_CALL
OSection::setCanShrink( ::sal_Bool
/*_canshrink*/ ) throw (lang::IllegalArgumentException
, beans::UnknownPropertyException
, uno::RuntimeException
)
426 throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment
428 // -----------------------------------------------------------------------------
429 ::sal_Bool SAL_CALL
OSection::getRepeatSection() throw (beans::UnknownPropertyException
, uno::RuntimeException
)
431 ::osl::MutexGuard
aGuard(m_aMutex
);
432 uno::Reference
< report::XGroup
> xGroup
= m_xGroup
;
434 throw beans::UnknownPropertyException();
435 return m_bRepeatSection
;
437 // -----------------------------------------------------------------------------
438 void SAL_CALL
OSection::setRepeatSection( ::sal_Bool _repeatsection
) throw (lang::IllegalArgumentException
, beans::UnknownPropertyException
, uno::RuntimeException
)
441 ::osl::MutexGuard
aGuard(m_aMutex
);
442 uno::Reference
< report::XGroup
> xGroup
= m_xGroup
;
444 throw beans::UnknownPropertyException();
446 set(PROPERTY_REPEATSECTION
,_repeatsection
,m_bRepeatSection
);
448 // -----------------------------------------------------------------------------
449 uno::Reference
< report::XGroup
> SAL_CALL
OSection::getGroup() throw (uno::RuntimeException
)
451 ::osl::MutexGuard
aGuard(m_aMutex
);
454 // -----------------------------------------------------------------------------
455 uno::Reference
< report::XReportDefinition
> SAL_CALL
OSection::getReportDefinition() throw (uno::RuntimeException
)
457 ::osl::MutexGuard
aGuard(m_aMutex
);
458 uno::Reference
< report::XReportDefinition
> xRet
= m_xReportDefinition
;
459 uno::Reference
< report::XGroup
> xGroup
= m_xGroup
;
460 if ( !xRet
.is() && xGroup
.is() )
462 uno::Reference
< report::XGroups
> xGroups(xGroup
->getParent(),uno::UNO_QUERY
);
464 xRet
= xGroups
->getReportDefinition();
469 // -----------------------------------------------------------------------------
470 const ::std::vector
< ::rtl::OUString
>& lcl_getControlModelMap()
472 static ::std::vector
< ::rtl::OUString
> s_sControlModels
;
473 if ( s_sControlModels
.empty() )
475 s_sControlModels
.push_back( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FixedText")) );
476 s_sControlModels
.push_back( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FixedLine")) );
477 s_sControlModels
.push_back( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageControl")) );
478 s_sControlModels
.push_back( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FormattedField")) );
479 s_sControlModels
.push_back( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Shape")) );
480 } // if ( s_sMap.empty() )
481 return s_sControlModels
;
484 // -----------------------------------------------------------------------------
485 uno::Reference
< report::XReportComponent
> SAL_CALL
OSection::createReportComponent( const ::rtl::OUString
& _sReportComponentSpecifier
) throw (uno::Exception
, lang::IllegalArgumentException
,uno::RuntimeException
)
487 ::osl::ResettableMutexGuard
aGuard(m_aMutex
);
488 const ::std::vector
< ::rtl::OUString
>& aRet
= lcl_getControlModelMap();
489 ::std::vector
< ::rtl::OUString
>::const_iterator aFind
= ::std::find(aRet
.begin(),aRet
.end(),_sReportComponentSpecifier
);
490 if ( aFind
== aRet
.end() )
491 throw lang::IllegalArgumentException();
493 uno::Reference
< report::XReportComponent
> xRet
;
494 uno::Reference
< lang::XMultiServiceFactory
> xFac(getReportDefinition(),uno::UNO_QUERY_THROW
);
495 switch( aFind
- aRet
.begin() )
498 xRet
.set(xFac
->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText"))),uno::UNO_QUERY
);
501 xRet
.set(xFac
->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedLineModel"))),uno::UNO_QUERY
);
504 xRet
.set(xFac
->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.DatabaseImageControl"))),uno::UNO_QUERY
);
507 xRet
.set(xFac
->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FormattedField"))),uno::UNO_QUERY
);
510 xRet
.set(xFac
->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ControlShape"))),uno::UNO_QUERY
);
513 //xRet = new OShape(m_xContext);
515 } // switch( aRet.begin() - aFind )
518 // -----------------------------------------------------------------------------
519 uno::Sequence
< ::rtl::OUString
> SAL_CALL
OSection::getAvailableReportComponentNames( ) throw (uno::RuntimeException
)
521 ::osl::MutexGuard
aGuard(m_aMutex
);
523 const ::std::vector
< ::rtl::OUString
>& aRet
= lcl_getControlModelMap();
524 const ::rtl::OUString
* pRet
= aRet
.empty() ? 0 : &aRet
[0];
525 return uno::Sequence
< ::rtl::OUString
>(pRet
, aRet
.size());
527 // -----------------------------------------------------------------------------
529 uno::Reference
< uno::XInterface
> SAL_CALL
OSection::getParent( ) throw (uno::RuntimeException
)
531 uno::Reference
< uno::XInterface
> xRet
;
533 ::osl::MutexGuard
aGuard(m_aMutex
);
534 xRet
= m_xReportDefinition
;
540 // -----------------------------------------------------------------------------
541 void SAL_CALL
OSection::setParent( const uno::Reference
< uno::XInterface
>& /*Parent*/ ) throw (lang::NoSupportException
, uno::RuntimeException
)
543 throw lang::NoSupportException();
545 // -----------------------------------------------------------------------------
547 void SAL_CALL
OSection::addContainerListener( const uno::Reference
< container::XContainerListener
>& xListener
) throw (uno::RuntimeException
)
549 m_aContainerListeners
.addInterface(xListener
);
551 // -----------------------------------------------------------------------------
552 void SAL_CALL
OSection::removeContainerListener( const uno::Reference
< container::XContainerListener
>& xListener
) throw (uno::RuntimeException
)
554 m_aContainerListeners
.removeInterface(xListener
);
556 // -----------------------------------------------------------------------------
558 uno::Type SAL_CALL
OSection::getElementType( ) throw (uno::RuntimeException
)
560 return ::getCppuType(static_cast< uno::Reference
<report::XReportComponent
>*>(NULL
));
562 // -----------------------------------------------------------------------------
563 ::sal_Bool SAL_CALL
OSection::hasElements( ) throw (uno::RuntimeException
)
565 ::osl::MutexGuard
aGuard(m_aMutex
);
566 return m_xDrawPage
.is() ? m_xDrawPage
->hasElements() : sal_False
;
568 // -----------------------------------------------------------------------------
570 ::sal_Int32 SAL_CALL
OSection::getCount( ) throw (uno::RuntimeException
)
572 ::osl::MutexGuard
aGuard(m_aMutex
);
573 return m_xDrawPage
.is() ? m_xDrawPage
->getCount() : 0;
575 // -----------------------------------------------------------------------------
576 uno::Any SAL_CALL
OSection::getByIndex( ::sal_Int32 Index
) throw (lang::IndexOutOfBoundsException
, lang::WrappedTargetException
, uno::RuntimeException
)
578 ::osl::MutexGuard
aGuard(m_aMutex
);
579 return m_xDrawPage
->getByIndex(Index
);
581 // -----------------------------------------------------------------------------
582 // XEnumerationAccess
583 uno::Reference
< container::XEnumeration
> SAL_CALL
OSection::createEnumeration( ) throw (uno::RuntimeException
)
585 ::osl::MutexGuard
aGuard(m_aMutex
);
586 return new ::comphelper::OEnumerationByIndex(static_cast<XIndexAccess
*>(this));
588 // -----------------------------------------------------------------------------
589 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
OSection::getPropertySetInfo( ) throw(uno::RuntimeException
)
591 return SectionPropertySet::getPropertySetInfo();
593 // -------------------------------------------------------------------------
594 void SAL_CALL
OSection::setPropertyValue( const ::rtl::OUString
& aPropertyName
, const uno::Any
& aValue
) throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
596 SectionPropertySet::setPropertyValue( aPropertyName
, aValue
);
598 // -----------------------------------------------------------------------------
599 uno::Any SAL_CALL
OSection::getPropertyValue( const ::rtl::OUString
& PropertyName
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
601 return SectionPropertySet::getPropertyValue( PropertyName
);
603 // -----------------------------------------------------------------------------
604 void SAL_CALL
OSection::addPropertyChangeListener( const ::rtl::OUString
& aPropertyName
, const uno::Reference
< beans::XPropertyChangeListener
>& xListener
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
606 SectionPropertySet::addPropertyChangeListener( aPropertyName
, xListener
);
608 // -----------------------------------------------------------------------------
609 void SAL_CALL
OSection::removePropertyChangeListener( const ::rtl::OUString
& aPropertyName
, const uno::Reference
< beans::XPropertyChangeListener
>& aListener
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
611 SectionPropertySet::removePropertyChangeListener( aPropertyName
, aListener
);
613 // -----------------------------------------------------------------------------
614 void SAL_CALL
OSection::addVetoableChangeListener( const ::rtl::OUString
& PropertyName
, const uno::Reference
< beans::XVetoableChangeListener
>& aListener
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
616 SectionPropertySet::addVetoableChangeListener( PropertyName
, aListener
);
618 // -----------------------------------------------------------------------------
619 void SAL_CALL
OSection::removeVetoableChangeListener( const ::rtl::OUString
& PropertyName
, const uno::Reference
< beans::XVetoableChangeListener
>& aListener
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
621 SectionPropertySet::removeVetoableChangeListener( PropertyName
, aListener
);
623 // -----------------------------------------------------------------------------
624 void OSection::lcl_copySection(const uno::Reference
< report::XSection
>& _xSource
,uno::Reference
< report::XSection
>& _xDest
)
628 ::comphelper::copyProperties(_xSource
.get(),_xDest
.get());
629 sal_Int32 nCount
= _xSource
->getCount();
630 for(sal_Int32 i
= 0;i
!= nCount
;++i
)
632 uno::Reference
<util::XCloneable
> xClone(_xSource
->getByIndex(i
),uno::UNO_QUERY
);
633 OSL_ENSURE(xClone
.is(),"No XCloneable interface found!");
636 uno::Reference
< drawing::XShape
> xShape(xClone
->createClone(),uno::UNO_QUERY
);
642 // -----------------------------------------------------------------------------
643 void SAL_CALL
OSection::add( const uno::Reference
< drawing::XShape
>& xShape
) throw (uno::RuntimeException
)
646 ::osl::MutexGuard
aGuard(m_aMutex
);
647 m_bInInsertNotify
= true;
648 OSL_ENSURE(m_xDrawPage
.is(),"No DrawPage!");
649 m_xDrawPage
->add(xShape
);
650 m_bInInsertNotify
= false;
652 notifyElementAdded(xShape
);
654 // -----------------------------------------------------------------------------
655 void SAL_CALL
OSection::remove( const uno::Reference
< drawing::XShape
>& xShape
) throw (uno::RuntimeException
)
658 ::osl::MutexGuard
aGuard(m_aMutex
);
659 m_bInRemoveNotify
= true;
660 OSL_ENSURE(m_xDrawPage
.is(),"No DrawPage!");
661 m_xDrawPage
->remove(xShape
);
662 m_bInRemoveNotify
= false;
664 notifyElementRemoved(xShape
);
666 // -----------------------------------------------------------------------------
667 // -----------------------------------------------------------------------------
668 // com::sun::star::lang::XUnoTunnel
669 //------------------------------------------------------------------
670 sal_Int64
OSection::getSomething( const uno::Sequence
< sal_Int8
> & rId
) throw (uno::RuntimeException
)
672 if (rId
.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId
.getConstArray(), 16 ) )
673 return reinterpret_cast<sal_Int64
>(this);
674 uno::Reference
< lang::XUnoTunnel
> xTunnel
;
675 ::comphelper::query_aggregation(m_xProxy
,xTunnel
);
676 return xTunnel
->getSomething(rId
);
679 // -----------------------------------------------------------------------------
680 OSection
* OSection::getImplementation( const uno::Reference
< uno::XInterface
>& _rxComponent
)
682 OSection
* pContent( NULL
);
684 uno::Reference
< lang::XUnoTunnel
> xUnoTunnel( _rxComponent
, uno::UNO_QUERY
);
685 if ( xUnoTunnel
.is() )
686 pContent
= reinterpret_cast< OSection
* >( xUnoTunnel
->getSomething( getUnoTunnelImplementationId() ) );
690 //------------------------------------------------------------------------
691 uno::Sequence
< sal_Int8
> OSection::getUnoTunnelImplementationId()
693 static ::cppu::OImplementationId
* pId
= 0;
696 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
699 static ::cppu::OImplementationId aId
;
703 return pId
->getImplementationId();
705 // -----------------------------------------------------------------------------
706 void OSection::notifyElementAdded(const uno::Reference
< drawing::XShape
>& xShape
)
708 if ( !m_bInInsertNotify
)
710 container::ContainerEvent
aEvent(static_cast<container::XContainer
*>(this), uno::Any(), uno::makeAny(xShape
), uno::Any());
711 m_aContainerListeners
.notifyEach(&container::XContainerListener::elementInserted
,aEvent
);
714 // -----------------------------------------------------------------------------
715 void OSection::notifyElementRemoved(const uno::Reference
< drawing::XShape
>& xShape
)
717 if ( !m_bInRemoveNotify
)
719 // notify our container listeners
720 container::ContainerEvent
aEvent(static_cast<container::XContainer
*>(this), uno::Any(), uno::makeAny(xShape
), uno::Any());
721 m_aContainerListeners
.notifyEach(&container::XContainerListener::elementRemoved
,aEvent
);
724 // =============================================================================
725 } // namespace reportdesign
726 // =============================================================================