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