fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / reportdesign / source / core / api / Group.cxx
blob353d3695e08014dc4e14aaae6083582e66956f3f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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"
32 // =============================================================================
33 namespace reportdesign
35 // =============================================================================
36 using namespace com::sun::star;
37 using namespace comphelper;
38 DBG_NAME( rpt_OGroup )
39 // -----------------------------------------------------------------------------
40 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< OUString >())
44 ,m_xContext(_xContext)
45 ,m_xParent(_xParent)
47 DBG_CTOR( rpt_OGroup,NULL);
48 osl_atomic_increment(&m_refCount);
50 m_xFunctions = new OFunctions(this,m_xContext);
52 osl_atomic_decrement( &m_refCount );
54 //--------------------------------------------------------------------------
55 // TODO: VirtualFunctionFinder: This is virtual function!
57 OGroup::~OGroup()
59 DBG_DTOR( rpt_OGroup,NULL);
61 //--------------------------------------------------------------------------
62 void OGroup::copyGroup(const uno::Reference< report::XGroup >& _xSource)
64 ::comphelper::copyProperties(_xSource.get(),static_cast<GroupPropertySet*>(this));
66 if ( _xSource->getHeaderOn() )
68 setHeaderOn(sal_True);
69 OSection::lcl_copySection(_xSource->getHeader(),m_xHeader);
72 if ( _xSource->getFooterOn() )
74 setFooterOn(sal_True);
75 OSection::lcl_copySection(_xSource->getFooter(),m_xFooter);
78 //--------------------------------------------------------------------------
79 IMPLEMENT_FORWARD_XINTERFACE2(OGroup,GroupBase,GroupPropertySet)
80 //--------------------------------------------------------------------------
81 OUString SAL_CALL OGroup::getImplementationName( ) throw(uno::RuntimeException)
83 return OUString("com.sun.star.comp.report.Group");
85 //------------------------------------------------------------------------------
86 uno::Sequence< OUString> OGroup::getSupportedServiceNames_Static(void) throw( uno::RuntimeException )
88 uno::Sequence< OUString> aSupported(1);
89 aSupported.getArray()[0] = SERVICE_GROUP;
90 return aSupported;
92 //-------------------------------------------------------------------------
93 uno::Sequence< OUString> SAL_CALL OGroup::getSupportedServiceNames() throw(uno::RuntimeException)
95 return getSupportedServiceNames_Static();
97 // -----------------------------------------------------------------------------
98 sal_Bool SAL_CALL OGroup::supportsService( const OUString& _rServiceName ) throw(uno::RuntimeException)
100 return ::comphelper::existsValue(_rServiceName,getSupportedServiceNames_Static());
102 // -----------------------------------------------------------------------------
103 void SAL_CALL OGroup::dispose() throw(uno::RuntimeException)
105 GroupPropertySet::dispose();
106 cppu::WeakComponentImplHelperBase::dispose();
108 // -----------------------------------------------------------------------------
109 // TODO: VirtualFunctionFinder: This is virtual function!
111 void SAL_CALL OGroup::disposing()
113 m_xHeader.clear();
114 m_xFooter.clear();
115 ::comphelper::disposeComponent(m_xFunctions);
116 m_xContext.clear();
118 // -----------------------------------------------------------------------------
119 // XGroup
120 ::sal_Bool SAL_CALL OGroup::getSortAscending() throw (uno::RuntimeException)
122 ::osl::MutexGuard aGuard(m_aMutex);
123 return m_aProps.m_eSortAscending;
125 // -----------------------------------------------------------------------------
126 void SAL_CALL OGroup::setSortAscending( ::sal_Bool _sortascending ) throw (uno::RuntimeException)
128 set(PROPERTY_SORTASCENDING,_sortascending,m_aProps.m_eSortAscending);
130 // -----------------------------------------------------------------------------
131 ::sal_Bool SAL_CALL OGroup::getHeaderOn() throw (uno::RuntimeException)
133 ::osl::MutexGuard aGuard(m_aMutex);
134 return m_xHeader.is();
136 // -----------------------------------------------------------------------------
137 void SAL_CALL OGroup::setHeaderOn( ::sal_Bool _headeron ) throw (uno::RuntimeException)
139 if ( _headeron != m_xHeader.is() )
141 OUString sName(RPT_RESSTRING(RID_STR_GROUP_HEADER,m_xContext->getServiceManager()));
142 setSection(PROPERTY_HEADERON,_headeron,sName,m_xHeader);
145 // -----------------------------------------------------------------------------
146 ::sal_Bool SAL_CALL OGroup::getFooterOn() throw (uno::RuntimeException)
148 ::osl::MutexGuard aGuard(m_aMutex);
149 return m_xFooter.is();
151 // -----------------------------------------------------------------------------
152 void SAL_CALL OGroup::setFooterOn( ::sal_Bool _footeron ) throw (uno::RuntimeException)
154 if ( _footeron != m_xFooter.is() )
156 OUString sName(RPT_RESSTRING(RID_STR_GROUP_FOOTER,m_xContext->getServiceManager()));
157 setSection(PROPERTY_FOOTERON,_footeron,sName,m_xFooter);
160 // -----------------------------------------------------------------------------
161 uno::Reference< report::XSection > SAL_CALL OGroup::getHeader() throw (container::NoSuchElementException, uno::RuntimeException)
163 uno::Reference< report::XSection > xRet;
165 ::osl::MutexGuard aGuard(m_aMutex);
166 xRet = m_xHeader;
169 if ( !xRet.is() )
170 throw container::NoSuchElementException();
171 return xRet;
173 // -----------------------------------------------------------------------------
174 uno::Reference< report::XSection > SAL_CALL OGroup::getFooter() throw (container::NoSuchElementException, uno::RuntimeException)
176 uno::Reference< report::XSection > xRet;
178 ::osl::MutexGuard aGuard(m_aMutex);
179 xRet = m_xFooter;
182 if ( !xRet.is() )
183 throw container::NoSuchElementException();
184 return xRet;
186 // -----------------------------------------------------------------------------
187 ::sal_Int16 SAL_CALL OGroup::getGroupOn() throw (uno::RuntimeException)
189 ::osl::MutexGuard aGuard(m_aMutex);
190 return m_aProps.m_nGroupOn;
192 // -----------------------------------------------------------------------------
193 void SAL_CALL OGroup::setGroupOn( ::sal_Int16 _groupon ) throw (lang::IllegalArgumentException, uno::RuntimeException)
195 if ( _groupon < report::GroupOn::DEFAULT || _groupon > report::GroupOn::INTERVAL )
196 throwIllegallArgumentException(OUString("com::sun::star::report::GroupOn")
197 ,*this
199 ,m_xContext);
200 set(PROPERTY_GROUPON,_groupon,m_aProps.m_nGroupOn);
202 // -----------------------------------------------------------------------------
203 ::sal_Int32 SAL_CALL OGroup::getGroupInterval() throw (uno::RuntimeException)
205 ::osl::MutexGuard aGuard(m_aMutex);
206 return m_aProps.m_nGroupInterval;
208 // -----------------------------------------------------------------------------
209 void SAL_CALL OGroup::setGroupInterval( ::sal_Int32 _groupinterval ) throw (uno::RuntimeException)
211 set(PROPERTY_GROUPINTERVAL,_groupinterval,m_aProps.m_nGroupInterval);
213 // -----------------------------------------------------------------------------
214 ::sal_Int16 SAL_CALL OGroup::getKeepTogether() throw (uno::RuntimeException)
216 ::osl::MutexGuard aGuard(m_aMutex);
217 return m_aProps.m_nKeepTogether;
219 // -----------------------------------------------------------------------------
220 void SAL_CALL OGroup::setKeepTogether( ::sal_Int16 _keeptogether ) throw (lang::IllegalArgumentException, uno::RuntimeException)
222 if ( _keeptogether < report::KeepTogether::NO || _keeptogether > report::KeepTogether::WITH_FIRST_DETAIL )
223 throwIllegallArgumentException(OUString("com::sun::star::report::KeepTogether")
224 ,*this
226 ,m_xContext);
227 set(PROPERTY_KEEPTOGETHER,_keeptogether,m_aProps.m_nKeepTogether);
229 // -----------------------------------------------------------------------------
230 uno::Reference< report::XGroups > SAL_CALL OGroup::getGroups() throw (uno::RuntimeException)
232 return m_xParent;
234 // -----------------------------------------------------------------------------
235 OUString SAL_CALL OGroup::getExpression() throw (uno::RuntimeException)
237 ::osl::MutexGuard aGuard(m_aMutex);
238 return m_aProps.m_sExpression;
240 // -----------------------------------------------------------------------------
241 void SAL_CALL OGroup::setExpression( const OUString& _expression ) throw (uno::RuntimeException)
243 set(PROPERTY_EXPRESSION,_expression,m_aProps.m_sExpression);
245 // -----------------------------------------------------------------------------
246 ::sal_Bool SAL_CALL OGroup::getStartNewColumn() throw (uno::RuntimeException)
248 ::osl::MutexGuard aGuard(m_aMutex);
249 return m_aProps.m_bStartNewColumn;
251 // -----------------------------------------------------------------------------
252 void SAL_CALL OGroup::setStartNewColumn( ::sal_Bool _startnewcolumn ) throw (uno::RuntimeException)
254 set(PROPERTY_STARTNEWCOLUMN,_startnewcolumn,m_aProps.m_bStartNewColumn);
256 // -----------------------------------------------------------------------------
257 // -----------------------------------------------------------------------------
258 ::sal_Bool SAL_CALL OGroup::getResetPageNumber() throw (uno::RuntimeException)
260 ::osl::MutexGuard aGuard(m_aMutex);
261 return m_aProps.m_bResetPageNumber;
263 // -----------------------------------------------------------------------------
264 void SAL_CALL OGroup::setResetPageNumber( ::sal_Bool _resetpagenumber ) throw (uno::RuntimeException)
266 set(PROPERTY_RESETPAGENUMBER,_resetpagenumber,m_aProps.m_bResetPageNumber);
268 // -----------------------------------------------------------------------------
269 // XChild
270 uno::Reference< uno::XInterface > SAL_CALL OGroup::getParent( ) throw (uno::RuntimeException)
272 return m_xParent;
274 // -----------------------------------------------------------------------------
275 void SAL_CALL OGroup::setParent( const uno::Reference< uno::XInterface >& /*Parent*/ ) throw (lang::NoSupportException, uno::RuntimeException)
277 throw lang::NoSupportException();
279 // -----------------------------------------------------------------------------
280 uno::Reference< beans::XPropertySetInfo > SAL_CALL OGroup::getPropertySetInfo( ) throw(uno::RuntimeException)
282 return GroupPropertySet::getPropertySetInfo();
284 // -----------------------------------------------------------------------------
285 void SAL_CALL OGroup::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
287 GroupPropertySet::setPropertyValue( aPropertyName, aValue );
289 // -----------------------------------------------------------------------------
290 uno::Any SAL_CALL OGroup::getPropertyValue( const OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
292 return GroupPropertySet::getPropertyValue( PropertyName);
294 // -----------------------------------------------------------------------------
295 void SAL_CALL OGroup::addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
297 GroupPropertySet::addPropertyChangeListener( aPropertyName, xListener );
299 // -----------------------------------------------------------------------------
300 void SAL_CALL OGroup::removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
302 GroupPropertySet::removePropertyChangeListener( aPropertyName, aListener );
304 // -----------------------------------------------------------------------------
305 void SAL_CALL OGroup::addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
307 GroupPropertySet::addVetoableChangeListener( PropertyName, aListener );
309 // -----------------------------------------------------------------------------
310 void SAL_CALL OGroup::removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
312 GroupPropertySet::removeVetoableChangeListener( PropertyName, aListener );
314 // -----------------------------------------------------------------------------
315 void OGroup::setSection( const OUString& _sProperty
316 ,const sal_Bool& _bOn
317 ,const OUString& _sName
318 ,uno::Reference< report::XSection>& _member)
320 BoundListeners l;
322 ::osl::MutexGuard aGuard(m_aMutex);
323 prepareSet(_sProperty, uno::makeAny(_member), uno::makeAny(_bOn), &l);
324 lcl_createSectionIfNeeded(_bOn ,this,_member);
325 if ( _member.is() )
326 _member->setName(_sName);
328 l.notify();
330 // -----------------------------------------------------------------------------
331 uno::Reference< report::XFunctions > SAL_CALL OGroup::getFunctions() throw (uno::RuntimeException)
333 return m_xFunctions;
335 // =============================================================================
336 } // namespace reportdesign
337 // =============================================================================
339 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */