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