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 "Group.hxx"
29 : : #include "Section.hxx"
30 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
31 : : #include <com/sun/star/report/GroupOn.hpp>
32 : : #include <com/sun/star/report/KeepTogether.hpp>
33 : : #include "corestrings.hrc"
34 : : #include "core_resource.hrc"
35 : : #include "core_resource.hxx"
36 : : #include "Tools.hxx"
37 : : #include <tools/debug.hxx>
38 : : #include <comphelper/property.hxx>
39 : : #include "Functions.hxx"
40 : :
41 : : // =============================================================================
42 : : namespace reportdesign
43 : : {
44 : : // =============================================================================
45 : : using namespace com::sun::star;
46 : : using namespace comphelper;
47 : : DBG_NAME( rpt_OGroup )
48 : : // -----------------------------------------------------------------------------
49 : 0 : OGroup::OGroup(const uno::Reference< report::XGroups >& _xParent
50 : : ,const uno::Reference< uno::XComponentContext >& _xContext)
51 : : :GroupBase(m_aMutex)
52 : : ,GroupPropertySet(_xContext,static_cast< GroupPropertySet::Implements >(IMPLEMENTS_PROPERTY_SET),uno::Sequence< ::rtl::OUString >())
53 : : ,m_xContext(_xContext)
54 [ # # ][ # # ]: 0 : ,m_xParent(_xParent)
[ # # ][ # # ]
55 : : {
56 : : DBG_CTOR( rpt_OGroup,NULL);
57 [ # # ]: 0 : osl_incrementInterlockedCount(&m_refCount);
58 : : {
59 [ # # ][ # # ]: 0 : m_xFunctions = new OFunctions(this,m_xContext);
[ # # ][ # # ]
60 : : }
61 [ # # ]: 0 : osl_decrementInterlockedCount( &m_refCount );
62 : 0 : }
63 : : //--------------------------------------------------------------------------
64 : : // TODO: VirtualFunctionFinder: This is virtual function!
65 : : //
66 [ # # ][ # # ]: 0 : OGroup::~OGroup()
[ # # ]
67 : : {
68 : : DBG_DTOR( rpt_OGroup,NULL);
69 [ # # ]: 0 : }
70 : : //--------------------------------------------------------------------------
71 : 0 : void OGroup::copyGroup(const uno::Reference< report::XGroup >& _xSource)
72 : : {
73 [ # # ][ # # ]: 0 : ::comphelper::copyProperties(_xSource.get(),static_cast<GroupPropertySet*>(this));
[ # # ][ # # ]
74 : :
75 [ # # ]: 0 : if ( _xSource->getHeaderOn() )
76 : : {
77 : 0 : setHeaderOn(sal_True);
78 [ # # ]: 0 : OSection::lcl_copySection(_xSource->getHeader(),m_xHeader);
79 : : }
80 : :
81 [ # # ]: 0 : if ( _xSource->getFooterOn() )
82 : : {
83 : 0 : setFooterOn(sal_True);
84 [ # # ]: 0 : OSection::lcl_copySection(_xSource->getFooter(),m_xFooter);
85 : : }
86 : 0 : }
87 : : //--------------------------------------------------------------------------
88 [ # # ][ # # ]: 0 : IMPLEMENT_FORWARD_XINTERFACE2(OGroup,GroupBase,GroupPropertySet)
89 : : //--------------------------------------------------------------------------
90 : 0 : ::rtl::OUString SAL_CALL OGroup::getImplementationName( ) throw(uno::RuntimeException)
91 : : {
92 : 0 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.Group"));
93 : : }
94 : : //------------------------------------------------------------------------------
95 : 0 : uno::Sequence< ::rtl::OUString> OGroup::getSupportedServiceNames_Static(void) throw( uno::RuntimeException )
96 : : {
97 : 0 : uno::Sequence< ::rtl::OUString> aSupported(1);
98 [ # # ][ # # ]: 0 : aSupported.getArray()[0] = SERVICE_GROUP;
99 : 0 : return aSupported;
100 : : }
101 : : //-------------------------------------------------------------------------
102 : 0 : uno::Sequence< ::rtl::OUString> SAL_CALL OGroup::getSupportedServiceNames() throw(uno::RuntimeException)
103 : : {
104 : 0 : return getSupportedServiceNames_Static();
105 : : }
106 : : // -----------------------------------------------------------------------------
107 : 0 : sal_Bool SAL_CALL OGroup::supportsService( const ::rtl::OUString& _rServiceName ) throw(uno::RuntimeException)
108 : : {
109 [ # # ]: 0 : return ::comphelper::existsValue(_rServiceName,getSupportedServiceNames_Static());
110 : : }
111 : : // -----------------------------------------------------------------------------
112 : 0 : void SAL_CALL OGroup::dispose() throw(uno::RuntimeException)
113 : : {
114 : 0 : GroupPropertySet::dispose();
115 : 0 : cppu::WeakComponentImplHelperBase::dispose();
116 : 0 : }
117 : : // -----------------------------------------------------------------------------
118 : : // TODO: VirtualFunctionFinder: This is virtual function!
119 : : //
120 : 0 : void SAL_CALL OGroup::disposing()
121 : : {
122 : 0 : m_xHeader.clear();
123 : 0 : m_xFooter.clear();
124 : 0 : ::comphelper::disposeComponent(m_xFunctions);
125 : 0 : m_xContext.clear();
126 : 0 : }
127 : : // -----------------------------------------------------------------------------
128 : : // XGroup
129 : 0 : ::sal_Bool SAL_CALL OGroup::getSortAscending() throw (uno::RuntimeException)
130 : : {
131 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
132 [ # # ]: 0 : return m_aProps.m_eSortAscending;
133 : : }
134 : : // -----------------------------------------------------------------------------
135 : 0 : void SAL_CALL OGroup::setSortAscending( ::sal_Bool _sortascending ) throw (uno::RuntimeException)
136 : : {
137 [ # # ]: 0 : set(PROPERTY_SORTASCENDING,_sortascending,m_aProps.m_eSortAscending);
138 : 0 : }
139 : : // -----------------------------------------------------------------------------
140 : 0 : ::sal_Bool SAL_CALL OGroup::getHeaderOn() throw (uno::RuntimeException)
141 : : {
142 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
143 [ # # ]: 0 : return m_xHeader.is();
144 : : }
145 : : // -----------------------------------------------------------------------------
146 : 0 : void SAL_CALL OGroup::setHeaderOn( ::sal_Bool _headeron ) throw (uno::RuntimeException)
147 : : {
148 [ # # ]: 0 : if ( _headeron != m_xHeader.is() )
149 : : {
150 [ # # ][ # # ]: 0 : ::rtl::OUString sName(RPT_RESSTRING(RID_STR_GROUP_HEADER,m_xContext->getServiceManager()));
[ # # ]
151 [ # # ][ # # ]: 0 : setSection(PROPERTY_HEADERON,_headeron,sName,m_xHeader);
152 : : }
153 : 0 : }
154 : : // -----------------------------------------------------------------------------
155 : 0 : ::sal_Bool SAL_CALL OGroup::getFooterOn() throw (uno::RuntimeException)
156 : : {
157 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
158 [ # # ]: 0 : return m_xFooter.is();
159 : : }
160 : : // -----------------------------------------------------------------------------
161 : 0 : void SAL_CALL OGroup::setFooterOn( ::sal_Bool _footeron ) throw (uno::RuntimeException)
162 : : {
163 [ # # ]: 0 : if ( _footeron != m_xFooter.is() )
164 : : {
165 [ # # ][ # # ]: 0 : ::rtl::OUString sName(RPT_RESSTRING(RID_STR_GROUP_FOOTER,m_xContext->getServiceManager()));
[ # # ]
166 [ # # ][ # # ]: 0 : setSection(PROPERTY_FOOTERON,_footeron,sName,m_xFooter);
167 : : }
168 : 0 : }
169 : : // -----------------------------------------------------------------------------
170 : 0 : uno::Reference< report::XSection > SAL_CALL OGroup::getHeader() throw (container::NoSuchElementException, uno::RuntimeException)
171 : : {
172 : 0 : uno::Reference< report::XSection > xRet;
173 : : {
174 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
175 [ # # ][ # # ]: 0 : xRet = m_xHeader;
176 : : }
177 : :
178 [ # # ]: 0 : if ( !xRet.is() )
179 [ # # ]: 0 : throw container::NoSuchElementException();
180 : 0 : return xRet;
181 : : }
182 : : // -----------------------------------------------------------------------------
183 : 0 : uno::Reference< report::XSection > SAL_CALL OGroup::getFooter() throw (container::NoSuchElementException, uno::RuntimeException)
184 : : {
185 : 0 : uno::Reference< report::XSection > xRet;
186 : : {
187 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
188 [ # # ][ # # ]: 0 : xRet = m_xFooter;
189 : : }
190 : :
191 [ # # ]: 0 : if ( !xRet.is() )
192 [ # # ]: 0 : throw container::NoSuchElementException();
193 : 0 : return xRet;
194 : : }
195 : : // -----------------------------------------------------------------------------
196 : 0 : ::sal_Int16 SAL_CALL OGroup::getGroupOn() throw (uno::RuntimeException)
197 : : {
198 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
199 [ # # ]: 0 : return m_aProps.m_nGroupOn;
200 : : }
201 : : // -----------------------------------------------------------------------------
202 : 0 : void SAL_CALL OGroup::setGroupOn( ::sal_Int16 _groupon ) throw (lang::IllegalArgumentException, uno::RuntimeException)
203 : : {
204 [ # # ][ # # ]: 0 : if ( _groupon < report::GroupOn::DEFAULT || _groupon > report::GroupOn::INTERVAL )
205 : : throwIllegallArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com::sun::star::report::GroupOn"))
206 : : ,*this
207 : : ,1
208 [ # # ][ # # ]: 0 : ,m_xContext);
[ # # ]
209 [ # # ]: 0 : set(PROPERTY_GROUPON,_groupon,m_aProps.m_nGroupOn);
210 : 0 : }
211 : : // -----------------------------------------------------------------------------
212 : 0 : ::sal_Int32 SAL_CALL OGroup::getGroupInterval() throw (uno::RuntimeException)
213 : : {
214 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
215 [ # # ]: 0 : return m_aProps.m_nGroupInterval;
216 : : }
217 : : // -----------------------------------------------------------------------------
218 : 0 : void SAL_CALL OGroup::setGroupInterval( ::sal_Int32 _groupinterval ) throw (uno::RuntimeException)
219 : : {
220 [ # # ]: 0 : set(PROPERTY_GROUPINTERVAL,_groupinterval,m_aProps.m_nGroupInterval);
221 : 0 : }
222 : : // -----------------------------------------------------------------------------
223 : 0 : ::sal_Int16 SAL_CALL OGroup::getKeepTogether() throw (uno::RuntimeException)
224 : : {
225 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
226 [ # # ]: 0 : return m_aProps.m_nKeepTogether;
227 : : }
228 : : // -----------------------------------------------------------------------------
229 : 0 : void SAL_CALL OGroup::setKeepTogether( ::sal_Int16 _keeptogether ) throw (lang::IllegalArgumentException, uno::RuntimeException)
230 : : {
231 [ # # ][ # # ]: 0 : if ( _keeptogether < report::KeepTogether::NO || _keeptogether > report::KeepTogether::WITH_FIRST_DETAIL )
232 : : throwIllegallArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com::sun::star::report::KeepTogether"))
233 : : ,*this
234 : : ,1
235 [ # # ][ # # ]: 0 : ,m_xContext);
[ # # ]
236 [ # # ]: 0 : set(PROPERTY_KEEPTOGETHER,_keeptogether,m_aProps.m_nKeepTogether);
237 : 0 : }
238 : : // -----------------------------------------------------------------------------
239 : 0 : uno::Reference< report::XGroups > SAL_CALL OGroup::getGroups() throw (uno::RuntimeException)
240 : : {
241 : 0 : return m_xParent;
242 : : }
243 : : // -----------------------------------------------------------------------------
244 : 0 : ::rtl::OUString SAL_CALL OGroup::getExpression() throw (uno::RuntimeException)
245 : : {
246 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
247 [ # # ]: 0 : return m_aProps.m_sExpression;
248 : : }
249 : : // -----------------------------------------------------------------------------
250 : 0 : void SAL_CALL OGroup::setExpression( const ::rtl::OUString& _expression ) throw (uno::RuntimeException)
251 : : {
252 [ # # ]: 0 : set(PROPERTY_EXPRESSION,_expression,m_aProps.m_sExpression);
253 : 0 : }
254 : : // -----------------------------------------------------------------------------
255 : 0 : ::sal_Bool SAL_CALL OGroup::getStartNewColumn() throw (uno::RuntimeException)
256 : : {
257 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
258 [ # # ]: 0 : return m_aProps.m_bStartNewColumn;
259 : : }
260 : : // -----------------------------------------------------------------------------
261 : 0 : void SAL_CALL OGroup::setStartNewColumn( ::sal_Bool _startnewcolumn ) throw (uno::RuntimeException)
262 : : {
263 [ # # ]: 0 : set(PROPERTY_STARTNEWCOLUMN,_startnewcolumn,m_aProps.m_bStartNewColumn);
264 : 0 : }
265 : : // -----------------------------------------------------------------------------
266 : : // -----------------------------------------------------------------------------
267 : 0 : ::sal_Bool SAL_CALL OGroup::getResetPageNumber() throw (uno::RuntimeException)
268 : : {
269 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
270 [ # # ]: 0 : return m_aProps.m_bResetPageNumber;
271 : : }
272 : : // -----------------------------------------------------------------------------
273 : 0 : void SAL_CALL OGroup::setResetPageNumber( ::sal_Bool _resetpagenumber ) throw (uno::RuntimeException)
274 : : {
275 [ # # ]: 0 : set(PROPERTY_RESETPAGENUMBER,_resetpagenumber,m_aProps.m_bResetPageNumber);
276 : 0 : }
277 : : // -----------------------------------------------------------------------------
278 : : // XChild
279 : 0 : uno::Reference< uno::XInterface > SAL_CALL OGroup::getParent( ) throw (uno::RuntimeException)
280 : : {
281 : 0 : return m_xParent;
282 : : }
283 : : // -----------------------------------------------------------------------------
284 : 0 : void SAL_CALL OGroup::setParent( const uno::Reference< uno::XInterface >& /*Parent*/ ) throw (lang::NoSupportException, uno::RuntimeException)
285 : : {
286 [ # # ]: 0 : throw lang::NoSupportException();
287 : : }
288 : : // -----------------------------------------------------------------------------
289 : 0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL OGroup::getPropertySetInfo( ) throw(uno::RuntimeException)
290 : : {
291 : 0 : return GroupPropertySet::getPropertySetInfo();
292 : : }
293 : : // -----------------------------------------------------------------------------
294 : 0 : void SAL_CALL OGroup::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
295 : : {
296 : 0 : GroupPropertySet::setPropertyValue( aPropertyName, aValue );
297 : 0 : }
298 : : // -----------------------------------------------------------------------------
299 : 0 : uno::Any SAL_CALL OGroup::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
300 : : {
301 : 0 : return GroupPropertySet::getPropertyValue( PropertyName);
302 : : }
303 : : // -----------------------------------------------------------------------------
304 : 0 : void SAL_CALL OGroup::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
305 : : {
306 : 0 : GroupPropertySet::addPropertyChangeListener( aPropertyName, xListener );
307 : 0 : }
308 : : // -----------------------------------------------------------------------------
309 : 0 : void SAL_CALL OGroup::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
310 : : {
311 : 0 : GroupPropertySet::removePropertyChangeListener( aPropertyName, aListener );
312 : 0 : }
313 : : // -----------------------------------------------------------------------------
314 : 0 : void SAL_CALL OGroup::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
315 : : {
316 : 0 : GroupPropertySet::addVetoableChangeListener( PropertyName, aListener );
317 : 0 : }
318 : : // -----------------------------------------------------------------------------
319 : 0 : void SAL_CALL OGroup::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
320 : : {
321 : 0 : GroupPropertySet::removeVetoableChangeListener( PropertyName, aListener );
322 : 0 : }
323 : : // -----------------------------------------------------------------------------
324 : 0 : void OGroup::setSection( const ::rtl::OUString& _sProperty
325 : : ,const sal_Bool& _bOn
326 : : ,const ::rtl::OUString& _sName
327 : : ,uno::Reference< report::XSection>& _member)
328 : : {
329 [ # # ]: 0 : BoundListeners l;
330 : : {
331 [ # # ]: 0 : ::osl::MutexGuard aGuard(m_aMutex);
332 [ # # ][ # # ]: 0 : prepareSet(_sProperty, uno::makeAny(_member), uno::makeAny(_bOn), &l);
[ # # ]
333 [ # # ]: 0 : lcl_createSectionIfNeeded(_bOn ,this,_member);
334 [ # # ]: 0 : if ( _member.is() )
335 [ # # ][ # # ]: 0 : _member->setName(_sName);
[ # # ]
336 : : }
337 [ # # ][ # # ]: 0 : l.notify();
338 : 0 : }
339 : : // -----------------------------------------------------------------------------
340 : 0 : uno::Reference< report::XFunctions > SAL_CALL OGroup::getFunctions() throw (uno::RuntimeException)
341 : : {
342 : 0 : return m_xFunctions;
343 : : }
344 : : // =============================================================================
345 : : } // namespace reportdesign
346 : : // =============================================================================
347 : :
348 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|