1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include "Section.hxx"
20 #include <comphelper/enumhelper.hxx>
21 #include <connectivity/dbtools.hxx>
22 #include <com/sun/star/report/XReportComponent.hpp>
23 #include <com/sun/star/report/ForceNewPage.hpp>
24 #include <com/sun/star/beans/PropertyAttribute.hpp>
25 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 #include "corestrings.hrc"
27 #include "core_resource.hxx"
28 #include "core_resource.hrc"
29 #include <tools/debug.hxx>
31 #include "RptModel.hxx"
32 #include "RptPage.hxx"
33 #include "ReportDefinition.hxx"
35 #include <svx/unoshape.hxx>
36 #include "RptObject.hxx"
37 #include "ReportDrawPage.hxx"
38 #include <comphelper/property.hxx>
39 // =============================================================================
40 namespace reportdesign
42 // =============================================================================
43 using namespace com::sun::star
;
44 using namespace comphelper
;
45 DBG_NAME( rpt_OSection
)
47 // -----------------------------------------------------------------------------
48 uno::Sequence
< OUString
> lcl_getGroupAbsent()
51 OUString(PROPERTY_CANGROW
)
52 ,OUString(PROPERTY_CANSHRINK
)
55 return uno::Sequence
< OUString
>(pProps
,sizeof(pProps
)/sizeof(pProps
[0]));
58 // -----------------------------------------------------------------------------
59 uno::Sequence
< OUString
> lcl_getAbsent(bool _bPageSection
)
64 OUString(PROPERTY_FORCENEWPAGE
)
65 ,OUString(PROPERTY_NEWROWORCOL
)
66 ,OUString(PROPERTY_KEEPTOGETHER
)
67 ,OUString(PROPERTY_CANGROW
)
68 ,OUString(PROPERTY_CANSHRINK
)
69 ,OUString(PROPERTY_REPEATSECTION
)
71 return uno::Sequence
< OUString
>(pProps
,sizeof(pProps
)/sizeof(pProps
[0]));
75 OUString(PROPERTY_CANGROW
)
76 ,OUString(PROPERTY_CANSHRINK
)
77 ,OUString(PROPERTY_REPEATSECTION
)
80 return uno::Sequence
< OUString
>(pProps
,sizeof(pProps
)/sizeof(pProps
[0]));
83 uno::Reference
<report::XSection
> OSection::createOSection(
84 const uno::Reference
< report::XReportDefinition
>& xParentDef
,
85 const uno::Reference
< uno::XComponentContext
>& context
,
86 bool const bPageSection
)
88 OSection
*const pNew
=
89 new OSection(xParentDef
, 0, context
, lcl_getAbsent(bPageSection
));
94 uno::Reference
<report::XSection
> OSection::createOSection(
95 const uno::Reference
< report::XGroup
>& xParentGroup
,
96 const uno::Reference
< uno::XComponentContext
>& context
,
99 OSection
*const pNew
=
100 new OSection(0, xParentGroup
, context
, lcl_getGroupAbsent());
105 // -----------------------------------------------------------------------------
106 OSection::OSection(const uno::Reference
< report::XReportDefinition
>& xParentDef
107 ,const uno::Reference
< report::XGroup
>& xParentGroup
108 ,const uno::Reference
< uno::XComponentContext
>& context
109 ,uno::Sequence
< OUString
> const& rStrings
)
110 :SectionBase(m_aMutex
)
111 ,SectionPropertySet(context
,SectionPropertySet::IMPLEMENTS_PROPERTY_SET
,rStrings
)
112 ,m_aContainerListeners(m_aMutex
)
114 ,m_xGroup(xParentGroup
)
115 ,m_xReportDefinition(xParentDef
)
117 ,m_nBackgroundColor(COL_TRANSPARENT
)
118 ,m_nForceNewPage(report::ForceNewPage::NONE
)
119 ,m_nNewRowOrCol(report::ForceNewPage::NONE
)
120 ,m_bKeepTogether(sal_False
)
121 ,m_bCanGrow(sal_False
)
122 ,m_bCanShrink(sal_False
)
123 ,m_bRepeatSection(sal_False
)
124 ,m_bVisible(sal_True
)
125 ,m_bBacktransparent(sal_True
)
126 ,m_bInRemoveNotify(false)
127 ,m_bInInsertNotify(false)
129 DBG_CTOR( rpt_OSection
,NULL
);
131 //--------------------------------------------------------------------------
132 // TODO: VirtualFunctionFinder: This is virtual function!
134 OSection::~OSection()
136 DBG_DTOR( rpt_OSection
,NULL
);
138 //--------------------------------------------------------------------------
139 //IMPLEMENT_FORWARD_XINTERFACE2(OSection,SectionBase,SectionPropertySet)
140 IMPLEMENT_FORWARD_REFCOUNT( OSection
, SectionBase
)
141 // --------------------------------------------------------------------------------
142 uno::Any SAL_CALL
OSection::queryInterface( const uno::Type
& _rType
) throw (uno::RuntimeException
)
144 uno::Any aReturn
= SectionBase::queryInterface(_rType
);
145 if ( !aReturn
.hasValue() )
146 aReturn
= SectionPropertySet::queryInterface(_rType
);
148 if ( !aReturn
.hasValue() && OReportControlModel::isInterfaceForbidden(_rType
) )
154 // -----------------------------------------------------------------------------
155 void SAL_CALL
OSection::dispose() throw(uno::RuntimeException
)
157 OSL_ENSURE(!rBHelper
.bDisposed
,"Already disposed!");
158 SectionPropertySet::dispose();
159 uno::Reference
<lang::XComponent
> const xPageComponent(m_xDrawPage
,
161 if (xPageComponent
.is())
163 xPageComponent
->dispose();
165 cppu::WeakComponentImplHelperBase::dispose();
168 // -----------------------------------------------------------------------------
169 // TODO: VirtualFunctionFinder: This is virtual function!
171 void SAL_CALL
OSection::disposing()
173 lang::EventObject
aDisposeEvent( static_cast< ::cppu::OWeakObject
* >( this ) );
174 m_aContainerListeners
.disposeAndClear( aDisposeEvent
);
177 //--------------------------------------------------------------------------
178 OUString SAL_CALL
OSection::getImplementationName( ) throw(uno::RuntimeException
)
180 return OUString("com.sun.star.comp.report.Section");
182 //------------------------------------------------------------------------------
183 uno::Sequence
< OUString
> OSection::getSupportedServiceNames_Static(void) throw( uno::RuntimeException
)
185 uno::Sequence
< OUString
> aSupported(1);
186 aSupported
.getArray()[0] = SERVICE_SECTION
;
189 //-------------------------------------------------------------------------
190 uno::Sequence
< OUString
> SAL_CALL
OSection::getSupportedServiceNames() throw(uno::RuntimeException
)
192 return getSupportedServiceNames_Static();
194 // -----------------------------------------------------------------------------
195 sal_Bool SAL_CALL
OSection::supportsService( const OUString
& _rServiceName
) throw(uno::RuntimeException
)
197 return ::comphelper::existsValue(_rServiceName
,getSupportedServiceNames_Static());
199 // -----------------------------------------------------------------------------
200 void OSection::init()
202 uno::Reference
< report::XReportDefinition
> xReport
= getReportDefinition();
203 ::boost::shared_ptr
<rptui::OReportModel
> pModel
= OReportDefinition::getSdrModel(xReport
);
204 assert(pModel
); //"No model set at the report definition!"
207 uno::Reference
<report::XSection
> const xSection(this);
208 SdrPage
& rSdrPage(*pModel
->createNewPage(xSection
));
209 m_xDrawPage
.set(rSdrPage
.getUnoPage(), uno::UNO_QUERY_THROW
);
210 m_xDrawPage_ShapeGrouper
.set(m_xDrawPage
, uno::UNO_QUERY_THROW
);
211 // apparently we may also get OReportDrawPage which doesn't support this
212 m_xDrawPage_FormSupplier
.set(m_xDrawPage
, uno::UNO_QUERY
);
213 m_xDrawPage_Tunnel
.set(m_xDrawPage
, uno::UNO_QUERY_THROW
);
214 // fdo#53872: now also exchange the XDrawPage in the SdrPage so that
215 // rSdrPage.getUnoPage returns this
216 rSdrPage
.SetUnoPage(this);
217 // createNewPage _should_ have stored away 2 uno::References to this,
218 // so our ref count cannot be 1 here, so this isn't destroyed here
219 assert(m_refCount
> 1);
222 // -----------------------------------------------------------------------------
224 // -----------------------------------------------------------------------------
225 ::sal_Bool SAL_CALL
OSection::getVisible() throw (uno::RuntimeException
)
227 ::osl::MutexGuard
aGuard(m_aMutex
);
230 // -----------------------------------------------------------------------------
231 void SAL_CALL
OSection::setVisible( ::sal_Bool _visible
) throw (uno::RuntimeException
)
233 set(PROPERTY_VISIBLE
,_visible
,m_bVisible
);
235 // -----------------------------------------------------------------------------
236 OUString SAL_CALL
OSection::getName() throw (uno::RuntimeException
)
238 ::osl::MutexGuard
aGuard(m_aMutex
);
241 // -----------------------------------------------------------------------------
242 void SAL_CALL
OSection::setName( const OUString
& _name
) throw (uno::RuntimeException
)
244 set(PROPERTY_NAME
,_name
,m_sName
);
246 // -----------------------------------------------------------------------------
247 ::sal_uInt32 SAL_CALL
OSection::getHeight() throw (uno::RuntimeException
)
249 ::osl::MutexGuard
aGuard(m_aMutex
);
252 // -----------------------------------------------------------------------------
253 void SAL_CALL
OSection::setHeight( ::sal_uInt32 _height
) throw (uno::RuntimeException
)
255 set(PROPERTY_HEIGHT
,_height
,m_nHeight
);
257 // -----------------------------------------------------------------------------
258 ::sal_Int32 SAL_CALL
OSection::getBackColor() throw (uno::RuntimeException
)
260 ::osl::MutexGuard
aGuard(m_aMutex
);
261 return m_bBacktransparent
? COL_TRANSPARENT
: m_nBackgroundColor
;
263 // -----------------------------------------------------------------------------
264 void SAL_CALL
OSection::setBackColor( ::sal_Int32 _backgroundcolor
) throw (uno::RuntimeException
)
266 sal_Bool bTransparent
= _backgroundcolor
== static_cast<sal_Int32
>(COL_TRANSPARENT
);
267 setBackTransparent(bTransparent
);
269 set(PROPERTY_BACKCOLOR
,_backgroundcolor
,m_nBackgroundColor
);
271 // -----------------------------------------------------------------------------
272 ::sal_Bool SAL_CALL
OSection::getBackTransparent() throw (uno::RuntimeException
)
274 ::osl::MutexGuard
aGuard(m_aMutex
);
275 return m_bBacktransparent
;
277 // -----------------------------------------------------------------------------
278 void SAL_CALL
OSection::setBackTransparent( ::sal_Bool _backtransparent
) throw (uno::RuntimeException
)
280 set(PROPERTY_BACKTRANSPARENT
,_backtransparent
,m_bBacktransparent
);
281 if ( _backtransparent
)
282 set(PROPERTY_BACKCOLOR
,static_cast<sal_Int32
>(COL_TRANSPARENT
),m_nBackgroundColor
);
284 // -----------------------------------------------------------------------------
285 OUString SAL_CALL
OSection::getConditionalPrintExpression() throw (uno::RuntimeException
)
287 ::osl::MutexGuard
aGuard(m_aMutex
);
288 return m_sConditionalPrintExpression
;
290 // -----------------------------------------------------------------------------
291 void SAL_CALL
OSection::setConditionalPrintExpression( const OUString
& _conditionalprintexpression
) throw (uno::RuntimeException
)
293 set(PROPERTY_CONDITIONALPRINTEXPRESSION
,_conditionalprintexpression
,m_sConditionalPrintExpression
);
295 // -----------------------------------------------------------------------------
296 void OSection::checkNotPageHeaderFooter()
298 ::osl::MutexGuard
aGuard(m_aMutex
);
299 uno::Reference
< report::XReportDefinition
> xRet
= m_xReportDefinition
;
302 if ( xRet
->getPageHeaderOn() && xRet
->getPageHeader() == *this )
303 throw beans::UnknownPropertyException();
304 if ( xRet
->getPageFooterOn() && xRet
->getPageFooter() == *this )
305 throw beans::UnknownPropertyException();
308 // -----------------------------------------------------------------------------
309 ::sal_Int16 SAL_CALL
OSection::getForceNewPage() throw (beans::UnknownPropertyException
, uno::RuntimeException
)
311 ::osl::MutexGuard
aGuard(m_aMutex
);
313 checkNotPageHeaderFooter();
314 return m_nForceNewPage
;
316 // -----------------------------------------------------------------------------
317 void SAL_CALL
OSection::setForceNewPage( ::sal_Int16 _forcenewpage
) throw (lang::IllegalArgumentException
, beans::UnknownPropertyException
, uno::RuntimeException
)
319 if ( _forcenewpage
< report::ForceNewPage::NONE
|| _forcenewpage
> report::ForceNewPage::BEFORE_AFTER_SECTION
)
320 throwIllegallArgumentException(OUString("com::sun::star::report::ForceNewPage")
324 checkNotPageHeaderFooter();
325 set(PROPERTY_FORCENEWPAGE
,_forcenewpage
,m_nForceNewPage
);
327 // -----------------------------------------------------------------------------
328 ::sal_Int16 SAL_CALL
OSection::getNewRowOrCol() throw (beans::UnknownPropertyException
, uno::RuntimeException
)
330 ::osl::MutexGuard
aGuard(m_aMutex
);
331 checkNotPageHeaderFooter();
332 return m_nNewRowOrCol
;
334 // -----------------------------------------------------------------------------
335 void SAL_CALL
OSection::setNewRowOrCol( ::sal_Int16 _newroworcol
) throw (lang::IllegalArgumentException
, beans::UnknownPropertyException
, uno::RuntimeException
)
337 if ( _newroworcol
< report::ForceNewPage::NONE
|| _newroworcol
> report::ForceNewPage::BEFORE_AFTER_SECTION
)
338 throwIllegallArgumentException(OUString("com::sun::star::report::ForceNewPage")
342 checkNotPageHeaderFooter();
344 set(PROPERTY_NEWROWORCOL
,_newroworcol
,m_nNewRowOrCol
);
346 // -----------------------------------------------------------------------------
347 ::sal_Bool SAL_CALL
OSection::getKeepTogether() throw (beans::UnknownPropertyException
, uno::RuntimeException
)
349 ::osl::MutexGuard
aGuard(m_aMutex
);
350 checkNotPageHeaderFooter();
351 return m_bKeepTogether
;
353 // -----------------------------------------------------------------------------
354 void SAL_CALL
OSection::setKeepTogether( ::sal_Bool _keeptogether
) throw (lang::IllegalArgumentException
, beans::UnknownPropertyException
, uno::RuntimeException
)
357 ::osl::MutexGuard
aGuard(m_aMutex
);
358 checkNotPageHeaderFooter();
361 set(PROPERTY_KEEPTOGETHER
,_keeptogether
,m_bKeepTogether
);
363 // -----------------------------------------------------------------------------
364 ::sal_Bool SAL_CALL
OSection::getCanGrow() throw (beans::UnknownPropertyException
, uno::RuntimeException
)
366 throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment
368 // -----------------------------------------------------------------------------
369 void SAL_CALL
OSection::setCanGrow( ::sal_Bool
/*_cangrow*/ ) throw (lang::IllegalArgumentException
, beans::UnknownPropertyException
, uno::RuntimeException
)
371 throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment
373 // -----------------------------------------------------------------------------
374 ::sal_Bool SAL_CALL
OSection::getCanShrink() throw (beans::UnknownPropertyException
, uno::RuntimeException
)
376 throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment
378 // -----------------------------------------------------------------------------
379 void SAL_CALL
OSection::setCanShrink( ::sal_Bool
/*_canshrink*/ ) throw (lang::IllegalArgumentException
, beans::UnknownPropertyException
, uno::RuntimeException
)
381 throw beans::UnknownPropertyException(); ///TODO: unsupported at the moment
383 // -----------------------------------------------------------------------------
384 ::sal_Bool SAL_CALL
OSection::getRepeatSection() throw (beans::UnknownPropertyException
, uno::RuntimeException
)
386 ::osl::MutexGuard
aGuard(m_aMutex
);
387 uno::Reference
< report::XGroup
> xGroup
= m_xGroup
;
389 throw beans::UnknownPropertyException();
390 return m_bRepeatSection
;
392 // -----------------------------------------------------------------------------
393 void SAL_CALL
OSection::setRepeatSection( ::sal_Bool _repeatsection
) throw (lang::IllegalArgumentException
, beans::UnknownPropertyException
, uno::RuntimeException
)
396 ::osl::MutexGuard
aGuard(m_aMutex
);
397 uno::Reference
< report::XGroup
> xGroup
= m_xGroup
;
399 throw beans::UnknownPropertyException();
401 set(PROPERTY_REPEATSECTION
,_repeatsection
,m_bRepeatSection
);
403 // -----------------------------------------------------------------------------
404 uno::Reference
< report::XGroup
> SAL_CALL
OSection::getGroup() throw (uno::RuntimeException
)
406 ::osl::MutexGuard
aGuard(m_aMutex
);
409 // -----------------------------------------------------------------------------
410 uno::Reference
< report::XReportDefinition
> SAL_CALL
OSection::getReportDefinition() throw (uno::RuntimeException
)
412 ::osl::MutexGuard
aGuard(m_aMutex
);
413 uno::Reference
< report::XReportDefinition
> xRet
= m_xReportDefinition
;
414 uno::Reference
< report::XGroup
> xGroup
= m_xGroup
;
415 if ( !xRet
.is() && xGroup
.is() )
417 uno::Reference
< report::XGroups
> xGroups(xGroup
->getGroups());
419 xRet
= xGroups
->getReportDefinition();
424 // -----------------------------------------------------------------------------
425 const ::std::vector
< OUString
>& lcl_getControlModelMap()
427 static ::std::vector
< OUString
> s_sControlModels
;
428 if ( s_sControlModels
.empty() )
430 s_sControlModels
.push_back( OUString("FixedText") );
431 s_sControlModels
.push_back( OUString("FixedLine") );
432 s_sControlModels
.push_back( OUString("ImageControl") );
433 s_sControlModels
.push_back( OUString("FormattedField") );
434 s_sControlModels
.push_back( OUString("Shape") );
436 return s_sControlModels
;
439 // -----------------------------------------------------------------------------
440 uno::Reference
< report::XReportComponent
> SAL_CALL
OSection::createReportComponent( const OUString
& _sReportComponentSpecifier
) throw (uno::Exception
, lang::IllegalArgumentException
,uno::RuntimeException
)
442 ::osl::ResettableMutexGuard
aGuard(m_aMutex
);
443 const ::std::vector
< OUString
>& aRet
= lcl_getControlModelMap();
444 ::std::vector
< OUString
>::const_iterator aFind
= ::std::find(aRet
.begin(),aRet
.end(),_sReportComponentSpecifier
);
445 if ( aFind
== aRet
.end() )
446 throw lang::IllegalArgumentException();
448 uno::Reference
< report::XReportComponent
> xRet
;
449 uno::Reference
< lang::XMultiServiceFactory
> xFac(getReportDefinition(),uno::UNO_QUERY_THROW
);
450 switch( aFind
- aRet
.begin() )
453 xRet
.set(xFac
->createInstance(OUString("com.sun.star.form.component.FixedText")),uno::UNO_QUERY
);
456 xRet
.set(xFac
->createInstance(OUString("com.sun.star.awt.UnoControlFixedLineModel")),uno::UNO_QUERY
);
459 xRet
.set(xFac
->createInstance(OUString("com.sun.star.form.component.DatabaseImageControl")),uno::UNO_QUERY
);
462 xRet
.set(xFac
->createInstance(OUString("com.sun.star.form.component.FormattedField")),uno::UNO_QUERY
);
465 xRet
.set(xFac
->createInstance(OUString("com.sun.star.drawing.ControlShape")),uno::UNO_QUERY
);
472 // -----------------------------------------------------------------------------
473 uno::Sequence
< OUString
> SAL_CALL
OSection::getAvailableReportComponentNames( ) throw (uno::RuntimeException
)
475 ::osl::MutexGuard
aGuard(m_aMutex
);
477 const ::std::vector
< OUString
>& aRet
= lcl_getControlModelMap();
478 const OUString
* pRet
= aRet
.empty() ? 0 : &aRet
[0];
479 return uno::Sequence
< OUString
>(pRet
, aRet
.size());
481 // -----------------------------------------------------------------------------
483 uno::Reference
< uno::XInterface
> SAL_CALL
OSection::getParent( ) throw (uno::RuntimeException
)
485 uno::Reference
< uno::XInterface
> xRet
;
487 ::osl::MutexGuard
aGuard(m_aMutex
);
488 xRet
= m_xReportDefinition
;
494 // -----------------------------------------------------------------------------
495 void SAL_CALL
OSection::setParent( const uno::Reference
< uno::XInterface
>& /*Parent*/ ) throw (lang::NoSupportException
, uno::RuntimeException
)
497 throw lang::NoSupportException();
499 // -----------------------------------------------------------------------------
501 void SAL_CALL
OSection::addContainerListener( const uno::Reference
< container::XContainerListener
>& xListener
) throw (uno::RuntimeException
)
503 m_aContainerListeners
.addInterface(xListener
);
505 // -----------------------------------------------------------------------------
506 void SAL_CALL
OSection::removeContainerListener( const uno::Reference
< container::XContainerListener
>& xListener
) throw (uno::RuntimeException
)
508 m_aContainerListeners
.removeInterface(xListener
);
510 // -----------------------------------------------------------------------------
512 uno::Type SAL_CALL
OSection::getElementType( ) throw (uno::RuntimeException
)
514 return ::getCppuType(static_cast< uno::Reference
<report::XReportComponent
>*>(NULL
));
516 // -----------------------------------------------------------------------------
517 ::sal_Bool SAL_CALL
OSection::hasElements( ) throw (uno::RuntimeException
)
519 ::osl::MutexGuard
aGuard(m_aMutex
);
520 return m_xDrawPage
.is() ? m_xDrawPage
->hasElements() : sal_False
;
522 // -----------------------------------------------------------------------------
524 ::sal_Int32 SAL_CALL
OSection::getCount( ) throw (uno::RuntimeException
)
526 ::osl::MutexGuard
aGuard(m_aMutex
);
527 return m_xDrawPage
.is() ? m_xDrawPage
->getCount() : 0;
529 // -----------------------------------------------------------------------------
530 uno::Any SAL_CALL
OSection::getByIndex( ::sal_Int32 Index
) throw (lang::IndexOutOfBoundsException
, lang::WrappedTargetException
, uno::RuntimeException
)
532 ::osl::MutexGuard
aGuard(m_aMutex
);
533 return m_xDrawPage
.is() ? m_xDrawPage
->getByIndex(Index
) : uno::Any();
535 // -----------------------------------------------------------------------------
536 // XEnumerationAccess
537 uno::Reference
< container::XEnumeration
> SAL_CALL
OSection::createEnumeration( ) throw (uno::RuntimeException
)
539 ::osl::MutexGuard
aGuard(m_aMutex
);
540 return new ::comphelper::OEnumerationByIndex(static_cast<XSection
*>(this));
542 // -----------------------------------------------------------------------------
543 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
OSection::getPropertySetInfo( ) throw(uno::RuntimeException
)
545 return SectionPropertySet::getPropertySetInfo();
547 // -------------------------------------------------------------------------
548 void SAL_CALL
OSection::setPropertyValue( const OUString
& aPropertyName
, const uno::Any
& aValue
) throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
550 SectionPropertySet::setPropertyValue( aPropertyName
, aValue
);
552 // -----------------------------------------------------------------------------
553 uno::Any SAL_CALL
OSection::getPropertyValue( const OUString
& PropertyName
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
555 return SectionPropertySet::getPropertyValue( PropertyName
);
557 // -----------------------------------------------------------------------------
558 void SAL_CALL
OSection::addPropertyChangeListener( const OUString
& aPropertyName
, const uno::Reference
< beans::XPropertyChangeListener
>& xListener
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
560 SectionPropertySet::addPropertyChangeListener( aPropertyName
, xListener
);
562 // -----------------------------------------------------------------------------
563 void SAL_CALL
OSection::removePropertyChangeListener( const OUString
& aPropertyName
, const uno::Reference
< beans::XPropertyChangeListener
>& aListener
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
565 SectionPropertySet::removePropertyChangeListener( aPropertyName
, aListener
);
567 // -----------------------------------------------------------------------------
568 void SAL_CALL
OSection::addVetoableChangeListener( const OUString
& PropertyName
, const uno::Reference
< beans::XVetoableChangeListener
>& aListener
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
570 SectionPropertySet::addVetoableChangeListener( PropertyName
, aListener
);
572 // -----------------------------------------------------------------------------
573 void SAL_CALL
OSection::removeVetoableChangeListener( const OUString
& PropertyName
, const uno::Reference
< beans::XVetoableChangeListener
>& aListener
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
575 SectionPropertySet::removeVetoableChangeListener( PropertyName
, aListener
);
577 // -----------------------------------------------------------------------------
578 void OSection::lcl_copySection(const uno::Reference
< report::XSection
>& _xSource
,uno::Reference
< report::XSection
>& _xDest
)
582 ::comphelper::copyProperties(_xSource
.get(),_xDest
.get());
583 sal_Int32 nCount
= _xSource
->getCount();
584 for(sal_Int32 i
= 0;i
!= nCount
;++i
)
586 uno::Reference
<util::XCloneable
> xClone(_xSource
->getByIndex(i
),uno::UNO_QUERY
);
587 OSL_ENSURE(xClone
.is(),"No XCloneable interface found!");
590 uno::Reference
< drawing::XShape
> xShape(xClone
->createClone(),uno::UNO_QUERY
);
596 // -----------------------------------------------------------------------------
597 void SAL_CALL
OSection::add( const uno::Reference
< drawing::XShape
>& xShape
) throw (uno::RuntimeException
)
600 ::osl::MutexGuard
aGuard(m_aMutex
);
601 m_bInInsertNotify
= true;
602 OSL_ENSURE(m_xDrawPage
.is(),"No DrawPage!");
603 m_xDrawPage
->add(xShape
);
604 m_bInInsertNotify
= false;
606 notifyElementAdded(xShape
);
608 // -----------------------------------------------------------------------------
609 void SAL_CALL
OSection::remove( const uno::Reference
< drawing::XShape
>& xShape
) throw (uno::RuntimeException
)
612 ::osl::MutexGuard
aGuard(m_aMutex
);
613 m_bInRemoveNotify
= true;
614 OSL_ENSURE(m_xDrawPage
.is(),"No DrawPage!");
615 m_xDrawPage
->remove(xShape
);
616 m_bInRemoveNotify
= false;
618 notifyElementRemoved(xShape
);
622 uno::Reference
< drawing::XShapeGroup
> SAL_CALL
623 OSection::group(uno::Reference
< drawing::XShapes
> const& xShapes
)
624 throw (uno::RuntimeException
)
626 // no lock because m_xDrawPage_ShapeGrouper is const
627 return (m_xDrawPage_ShapeGrouper
.is())
628 ? m_xDrawPage_ShapeGrouper
->group(xShapes
)
632 OSection::ungroup(uno::Reference
<drawing::XShapeGroup
> const& xGroup
)
633 throw (uno::RuntimeException
)
635 // no lock because m_xDrawPage_ShapeGrouper is const
636 if (m_xDrawPage_ShapeGrouper
.is()) {
637 m_xDrawPage_ShapeGrouper
->ungroup(xGroup
);
642 uno::Reference
<container::XNameContainer
> SAL_CALL
OSection::getForms()
643 throw (uno::RuntimeException
)
645 // no lock because m_xDrawPage_FormSupplier is const
646 return (m_xDrawPage_FormSupplier
.is())
647 ? m_xDrawPage_FormSupplier
->getForms()
651 sal_Bool SAL_CALL
OSection::hasForms() throw (uno::RuntimeException
)
653 // no lock because m_xDrawPage_FormSupplier is const
654 return (m_xDrawPage_FormSupplier
.is())
655 ? m_xDrawPage_FormSupplier
->hasForms()
659 // -----------------------------------------------------------------------------
660 // com::sun::star::lang::XUnoTunnel
661 //------------------------------------------------------------------
662 sal_Int64
OSection::getSomething( const uno::Sequence
< sal_Int8
> & rId
) throw (uno::RuntimeException
)
664 if (rId
.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId
.getConstArray(), 16 ) )
665 return reinterpret_cast<sal_Int64
>(this);
666 return (m_xDrawPage_Tunnel
.is()) ? m_xDrawPage_Tunnel
->getSomething(rId
) : 0;
669 // -----------------------------------------------------------------------------
670 OSection
* OSection::getImplementation( const uno::Reference
< uno::XInterface
>& _rxComponent
)
672 OSection
* pContent( NULL
);
674 uno::Reference
< lang::XUnoTunnel
> xUnoTunnel( _rxComponent
, uno::UNO_QUERY
);
675 if ( xUnoTunnel
.is() )
676 pContent
= reinterpret_cast< OSection
* >( xUnoTunnel
->getSomething( getUnoTunnelImplementationId() ) );
680 //------------------------------------------------------------------------
681 uno::Sequence
< sal_Int8
> OSection::getUnoTunnelImplementationId()
683 static ::cppu::OImplementationId
* pId
= 0;
686 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
689 static ::cppu::OImplementationId aId
;
693 return pId
->getImplementationId();
695 // -----------------------------------------------------------------------------
696 void OSection::notifyElementAdded(const uno::Reference
< drawing::XShape
>& xShape
)
698 if ( !m_bInInsertNotify
)
700 container::ContainerEvent
aEvent(static_cast<container::XContainer
*>(this), uno::Any(), uno::makeAny(xShape
), uno::Any());
701 m_aContainerListeners
.notifyEach(&container::XContainerListener::elementInserted
,aEvent
);
704 // -----------------------------------------------------------------------------
705 void OSection::notifyElementRemoved(const uno::Reference
< drawing::XShape
>& xShape
)
707 if ( !m_bInRemoveNotify
)
709 // notify our container listeners
710 container::ContainerEvent
aEvent(static_cast<container::XContainer
*>(this), uno::Any(), uno::makeAny(xShape
), uno::Any());
711 m_aContainerListeners
.notifyEach(&container::XContainerListener::elementRemoved
,aEvent
);
714 // =============================================================================
715 } // namespace reportdesign
716 // =============================================================================
718 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */