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