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 
33 namespace reportdesign
34 {
35 
36  using namespace com::sun::star;
37 
38 OGroup::OGroup(const uno::Reference< report::XGroups >& _xParent
39  ,const uno::Reference< uno::XComponentContext >& _xContext)
41 ,GroupPropertySet(_xContext,IMPLEMENTS_PROPERTY_SET,uno::Sequence< OUString >())
42 ,m_xContext(_xContext)
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 
55 {
56 }
57 
59 
60 OUString SAL_CALL OGroup::getImplementationName( )
61 {
62  return "com.sun.star.comp.report.Group";
63 }
64 
65 uno::Sequence< OUString> OGroup::getSupportedServiceNames_Static()
66 {
67  uno::Sequence<OUString> aSupported { SERVICE_GROUP };
68  return aSupported;
69 }
70 
71 uno::Sequence< OUString> SAL_CALL OGroup::getSupportedServiceNames()
72 {
74 }
75 
76 sal_Bool SAL_CALL OGroup::supportsService( const OUString& _rServiceName )
77 {
78  return cppu::supportsService(this, _rServiceName);
79 }
80 
81 void SAL_CALL OGroup::dispose()
82 {
84  cppu::WeakComponentImplHelperBase::dispose();
85 }
86 
87 // TODO: VirtualFunctionFinder: This is virtual function!
88 
89 void 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
99 {
100  ::osl::MutexGuard aGuard(m_aMutex);
101  return m_aProps.m_eSortAscending;
102 }
103 
104 void SAL_CALL OGroup::setSortAscending( sal_Bool _sortascending )
105 {
107 }
108 
110 {
111  ::osl::MutexGuard aGuard(m_aMutex);
112  return m_xHeader.is();
113 }
114 
115 void 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 
125 {
126  ::osl::MutexGuard aGuard(m_aMutex);
127  return m_xFooter.is();
128 }
129 
130 void 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 
139 uno::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 
152 uno::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 
171 void SAL_CALL OGroup::setGroupOn( ::sal_Int16 _groupon )
172 {
173  if ( _groupon < report::GroupOn::DEFAULT || _groupon > report::GroupOn::INTERVAL )
174  throwIllegallArgumentException("css::report::GroupOn"
175  ,*this
176  ,1);
178 }
179 
180 ::sal_Int32 SAL_CALL OGroup::getGroupInterval()
181 {
182  ::osl::MutexGuard aGuard(m_aMutex);
183  return m_aProps.m_nGroupInterval;
184 }
185 
186 void SAL_CALL OGroup::setGroupInterval( ::sal_Int32 _groupinterval )
187 {
189 }
190 
191 ::sal_Int16 SAL_CALL OGroup::getKeepTogether()
192 {
193  ::osl::MutexGuard aGuard(m_aMutex);
194  return m_aProps.m_nKeepTogether;
195 }
196 
197 void SAL_CALL OGroup::setKeepTogether( ::sal_Int16 _keeptogether )
198 {
199  if ( _keeptogether < report::KeepTogether::NO || _keeptogether > report::KeepTogether::WITH_FIRST_DETAIL )
200  throwIllegallArgumentException("css::report::KeepTogether"
201  ,*this
202  ,1);
204 }
205 
206 uno::Reference< report::XGroups > SAL_CALL OGroup::getGroups()
207 {
208  return m_xParent;
209 }
210 
211 OUString SAL_CALL OGroup::getExpression()
212 {
213  ::osl::MutexGuard aGuard(m_aMutex);
214  return m_aProps.m_sExpression;
215 }
216 
217 void SAL_CALL OGroup::setExpression( const OUString& _expression )
218 {
220 }
221 
223 {
224  ::osl::MutexGuard aGuard(m_aMutex);
226 }
227 
228 void SAL_CALL OGroup::setStartNewColumn( sal_Bool _startnewcolumn )
229 {
231 }
232 
233 
235 {
236  ::osl::MutexGuard aGuard(m_aMutex);
238 }
239 
240 void SAL_CALL OGroup::setResetPageNumber( sal_Bool _resetpagenumber )
241 {
243 }
244 
245 // XChild
246 uno::Reference< uno::XInterface > SAL_CALL OGroup::getParent( )
247 {
248  return m_xParent;
249 }
250 
251 void SAL_CALL OGroup::setParent( const uno::Reference< uno::XInterface >& /*Parent*/ )
252 {
253  throw lang::NoSupportException();
254 }
255 
256 uno::Reference< beans::XPropertySetInfo > SAL_CALL OGroup::getPropertySetInfo( )
257 {
259 }
260 
261 void SAL_CALL OGroup::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
262 {
263  GroupPropertySet::setPropertyValue( aPropertyName, aValue );
264 }
265 
266 uno::Any SAL_CALL OGroup::getPropertyValue( const OUString& PropertyName )
267 {
268  return GroupPropertySet::getPropertyValue( PropertyName);
269 }
270 
271 void SAL_CALL OGroup::addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener )
272 {
273  GroupPropertySet::addPropertyChangeListener( aPropertyName, xListener );
274 }
275 
276 void SAL_CALL OGroup::removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener )
277 {
278  GroupPropertySet::removePropertyChangeListener( aPropertyName, aListener );
279 }
280 
281 void SAL_CALL OGroup::addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener )
282 {
283  GroupPropertySet::addVetoableChangeListener( PropertyName, aListener );
284 }
285 
286 void SAL_CALL OGroup::removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener )
287 {
288  GroupPropertySet::removeVetoableChangeListener( PropertyName, aListener );
289 }
290 
291 void 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::makeAny(_member), uno::makeAny(_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 
313 uno::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: */
IMPLEMENT_FORWARD_XINTERFACE2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
implementation of a
Definition: Group.hxx:41
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() override
Definition: Group.cxx:246
#define PROPERTY_HEADERON
Definition: strings.hxx:71
osl::Mutex m_aMutex
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() SAL_OVERRIDE
::rptshared::GroupProperties m_aProps
Definition: Group.hxx:50
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: Group.cxx:71
::cppu::WeakComponentImplHelper< css::report::XGroup, css::lang::XServiceInfo > GroupBase
Definition: Group.hxx:34
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: Group.cxx:76
css::uno::Reference< css::report::XSection > m_xHeader
Definition: Group.hxx:47
virtual sal_Bool SAL_CALL getHeaderOn() override
Definition: Group.cxx:109
#define SERVICE_GROUP
Definition: strings.hxx:31
void throwIllegallArgumentException(const OUString &_sTypeName, const uno::Reference< uno::XInterface > &ExceptionContext_, sal_Int16 ArgumentPosition_)
Definition: Tools.cxx:43
#define PROPERTY_GROUPINTERVAL
Definition: strings.hxx:51
virtual void SAL_CALL removePropertyChangeListener(rtl::OUString const &propertyName, css::uno::Reference< css::beans::XPropertyChangeListener > const &listener) SAL_OVERRIDE
virtual void SAL_CALL setStartNewColumn(sal_Bool _startnewcolumn) override
Definition: Group.cxx:228
virtual void SAL_CALL dispose() override
Definition: Group.cxx:81
#define PROPERTY_FOOTERON
Definition: strings.hxx:72
#define PROPERTY_RESETPAGENUMBER
Definition: strings.hxx:112
static css::uno::Sequence< OUString > getSupportedServiceNames_Static()
Definition: Group.cxx:65
css::uno::Reference< css::uno::XComponentContext > m_xContext
virtual css::uno::Reference< css::report::XSection > SAL_CALL getHeader() override
Definition: Group.cxx:139
void setSection(const OUString &_sProperty, bool _bOn, const OUString &_sName, css::uno::Reference< css::report::XSection > &_member)
Definition: Group.cxx:291
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: Group.cxx:271
css::uno::WeakReference< css::report::XGroups > m_xParent
Definition: Group.hxx:46
#define PROPERTY_STARTNEWCOLUMN
Definition: strings.hxx:111
virtual sal_Bool SAL_CALL getStartNewColumn() override
Definition: Group.cxx:222
virtual css::uno::Reference< css::report::XGroups > SAL_CALL getGroups() override
Definition: Group.cxx:206
virtual void SAL_CALL setPropertyValue(rtl::OUString const &propertyName, css::uno::Any const &value) SAL_OVERRIDE
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: Group.cxx:256
const char * sName
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: Group.cxx:276
virtual void SAL_CALL setResetPageNumber(sal_Bool _resetpagenumber) override
Definition: Group.cxx:240
virtual ::sal_Int32 SAL_CALL getGroupInterval() override
Definition: Group.cxx:180
static css::uno::Reference< css::report::XSection > createOSection(const css::uno::Reference< css::report::XReportDefinition > &_xParent, const css::uno::Reference< css::uno::XComponentContext > &context, bool _bPageSection=false)
virtual css::uno::Reference< css::report::XFunctions > SAL_CALL getFunctions() override
Definition: Group.cxx:313
virtual sal_Bool SAL_CALL getFooterOn() override
Definition: Group.cxx:124
::cppu::PropertySetMixin< css::report::XGroup > GroupPropertySet
Definition: Group.hxx:35
virtual void SAL_CALL setParent(const css::uno::Reference< css::uno::XInterface > &Parent) override
Definition: Group.cxx:251
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: Group.hxx:45
unsigned char sal_Bool
virtual OUString SAL_CALL getExpression() override
Definition: Group.cxx:211
OUString RptResId(const char *pId)
OGroup(const OGroup &)=delete
virtual void SAL_CALL addPropertyChangeListener(rtl::OUString const &propertyName, css::uno::Reference< css::beans::XPropertyChangeListener > const &listener) SAL_OVERRIDE
virtual void SAL_CALL setHeaderOn(sal_Bool _headeron) override
Definition: Group.cxx:115
virtual void SAL_CALL setExpression(const OUString &_expression) override
Definition: Group.cxx:217
virtual void SAL_CALL disposing() override
this function is called upon disposing the component
Definition: Group.cxx:89
virtual void SAL_CALL setGroupInterval(::sal_Int32 _groupinterval) override
Definition: Group.cxx:186
css::uno::Reference< css::report::XSection > m_xFooter
Definition: Group.hxx:48
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: Group.cxx:286
#define PROPERTY_SORTASCENDING
Definition: strings.hxx:54
virtual css::uno::Reference< css::report::XSection > SAL_CALL getFooter() override
Definition: Group.cxx:152
#define PROPERTY_EXPRESSION
Definition: strings.hxx:52
virtual ::sal_Int16 SAL_CALL getKeepTogether() override
Definition: Group.cxx:191
void prepareSet(rtl::OUString const &propertyName, css::uno::Any const &oldValue, css::uno::Any const &newValue, BoundListeners *boundListeners)
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: Group.cxx:281
virtual css::uno::Any SAL_CALL getPropertyValue(rtl::OUString const &propertyName) SAL_OVERRIDE
virtual void SAL_CALL setKeepTogether(::sal_Int16 _keeptogether) override
Definition: Group.cxx:197
virtual void SAL_CALL addVetoableChangeListener(rtl::OUString const &propertyName, css::uno::Reference< css::beans::XVetoableChangeListener > const &listener) SAL_OVERRIDE
void set(const OUString &_sProperty, const T &Value, T &_member)
Definition: Group.hxx:56
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: Group.cxx:261
css::uno::Reference< css::report::XFunctions > m_xFunctions
Definition: Group.hxx:49
virtual void SAL_CALL removeVetoableChangeListener(rtl::OUString const &propertyName, css::uno::Reference< css::beans::XVetoableChangeListener > const &listener) SAL_OVERRIDE
virtual void SAL_CALL setFooterOn(sal_Bool _footeron) override
Definition: Group.cxx:130
virtual sal_Bool SAL_CALL getResetPageNumber() override
Definition: Group.cxx:234
Reference< XComponentContext > m_xContext
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: Group.cxx:266
virtual void SAL_CALL setSortAscending(sal_Bool _sortascending) override
Definition: Group.cxx:104
virtual void SAL_CALL setGroupOn(::sal_Int16 _groupon) override
Definition: Group.cxx:171
virtual sal_Bool SAL_CALL getSortAscending() override
Definition: Group.cxx:98
#define PROPERTY_KEEPTOGETHER
Definition: strings.hxx:44
virtual ::sal_Int16 SAL_CALL getGroupOn() override
Definition: Group.cxx:165
virtual ~OGroup() override
Definition: Group.cxx:54
#define PROPERTY_GROUPON
Definition: strings.hxx:53