cURL: follow redirects
[LibreOffice.git] / reportdesign / source / core / api / Group.cxx
blobc25a8dc39be76feb7d68d7d19fd77d826ca390d1
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 <cppuhelper/supportsservice.hxx>
31 #include "Functions.hxx"
34 namespace reportdesign
37 using namespace com::sun::star;
38 using namespace comphelper;
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 osl_atomic_increment(&m_refCount);
49 m_xFunctions = new OFunctions(this,m_xContext);
51 osl_atomic_decrement( &m_refCount );
54 // TODO: VirtualFunctionFinder: This is virtual function!
56 OGroup::~OGroup()
60 IMPLEMENT_FORWARD_XINTERFACE2(OGroup,GroupBase,GroupPropertySet)
62 OUString SAL_CALL OGroup::getImplementationName( ) throw(uno::RuntimeException, std::exception)
64 return OUString("com.sun.star.comp.report.Group");
67 uno::Sequence< OUString> OGroup::getSupportedServiceNames_Static() throw( uno::RuntimeException )
69 uno::Sequence<OUString> aSupported { SERVICE_GROUP };
70 return aSupported;
73 uno::Sequence< OUString> SAL_CALL OGroup::getSupportedServiceNames() throw(uno::RuntimeException, std::exception)
75 return getSupportedServiceNames_Static();
78 sal_Bool SAL_CALL OGroup::supportsService( const OUString& _rServiceName ) throw(uno::RuntimeException, std::exception)
80 return cppu::supportsService(this, _rServiceName);
83 void SAL_CALL OGroup::dispose() throw(uno::RuntimeException, std::exception)
85 GroupPropertySet::dispose();
86 cppu::WeakComponentImplHelperBase::dispose();
89 // TODO: VirtualFunctionFinder: This is virtual function!
91 void SAL_CALL OGroup::disposing()
93 m_xHeader.clear();
94 m_xFooter.clear();
95 ::comphelper::disposeComponent(m_xFunctions);
96 m_xContext.clear();
99 // XGroup
100 sal_Bool SAL_CALL OGroup::getSortAscending() throw (uno::RuntimeException, std::exception)
102 ::osl::MutexGuard aGuard(m_aMutex);
103 return m_aProps.m_eSortAscending;
106 void SAL_CALL OGroup::setSortAscending( sal_Bool _sortascending ) throw (uno::RuntimeException, std::exception)
108 set(PROPERTY_SORTASCENDING,_sortascending,m_aProps.m_eSortAscending);
111 sal_Bool SAL_CALL OGroup::getHeaderOn() throw (uno::RuntimeException, std::exception)
113 ::osl::MutexGuard aGuard(m_aMutex);
114 return m_xHeader.is();
117 void SAL_CALL OGroup::setHeaderOn( sal_Bool _headeron ) throw (uno::RuntimeException, std::exception)
119 if ( bool(_headeron) != m_xHeader.is() )
121 OUString sName(RPT_RESSTRING(RID_STR_GROUP_HEADER));
122 setSection(PROPERTY_HEADERON,_headeron,sName,m_xHeader);
126 sal_Bool SAL_CALL OGroup::getFooterOn() throw (uno::RuntimeException, std::exception)
128 ::osl::MutexGuard aGuard(m_aMutex);
129 return m_xFooter.is();
132 void SAL_CALL OGroup::setFooterOn( sal_Bool _footeron ) throw (uno::RuntimeException, std::exception)
134 if ( bool(_footeron) != m_xFooter.is() )
136 OUString sName(RPT_RESSTRING(RID_STR_GROUP_FOOTER));
137 setSection(PROPERTY_FOOTERON,_footeron,sName,m_xFooter);
141 uno::Reference< report::XSection > SAL_CALL OGroup::getHeader() throw (container::NoSuchElementException, uno::RuntimeException, std::exception)
143 uno::Reference< report::XSection > xRet;
145 ::osl::MutexGuard aGuard(m_aMutex);
146 xRet = m_xHeader;
149 if ( !xRet.is() )
150 throw container::NoSuchElementException();
151 return xRet;
154 uno::Reference< report::XSection > SAL_CALL OGroup::getFooter() throw (container::NoSuchElementException, uno::RuntimeException, std::exception)
156 uno::Reference< report::XSection > xRet;
158 ::osl::MutexGuard aGuard(m_aMutex);
159 xRet = m_xFooter;
162 if ( !xRet.is() )
163 throw container::NoSuchElementException();
164 return xRet;
167 ::sal_Int16 SAL_CALL OGroup::getGroupOn() throw (uno::RuntimeException, std::exception)
169 ::osl::MutexGuard aGuard(m_aMutex);
170 return m_aProps.m_nGroupOn;
173 void SAL_CALL OGroup::setGroupOn( ::sal_Int16 _groupon ) throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
175 if ( _groupon < report::GroupOn::DEFAULT || _groupon > report::GroupOn::INTERVAL )
176 throwIllegallArgumentException("css::report::GroupOn"
177 ,*this
178 ,1);
179 set(PROPERTY_GROUPON,_groupon,m_aProps.m_nGroupOn);
182 ::sal_Int32 SAL_CALL OGroup::getGroupInterval() throw (uno::RuntimeException, std::exception)
184 ::osl::MutexGuard aGuard(m_aMutex);
185 return m_aProps.m_nGroupInterval;
188 void SAL_CALL OGroup::setGroupInterval( ::sal_Int32 _groupinterval ) throw (uno::RuntimeException, std::exception)
190 set(PROPERTY_GROUPINTERVAL,_groupinterval,m_aProps.m_nGroupInterval);
193 ::sal_Int16 SAL_CALL OGroup::getKeepTogether() throw (uno::RuntimeException, std::exception)
195 ::osl::MutexGuard aGuard(m_aMutex);
196 return m_aProps.m_nKeepTogether;
199 void SAL_CALL OGroup::setKeepTogether( ::sal_Int16 _keeptogether ) throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
201 if ( _keeptogether < report::KeepTogether::NO || _keeptogether > report::KeepTogether::WITH_FIRST_DETAIL )
202 throwIllegallArgumentException("css::report::KeepTogether"
203 ,*this
204 ,1);
205 set(PROPERTY_KEEPTOGETHER,_keeptogether,m_aProps.m_nKeepTogether);
208 uno::Reference< report::XGroups > SAL_CALL OGroup::getGroups() throw (uno::RuntimeException, std::exception)
210 return m_xParent;
213 OUString SAL_CALL OGroup::getExpression() throw (uno::RuntimeException, std::exception)
215 ::osl::MutexGuard aGuard(m_aMutex);
216 return m_aProps.m_sExpression;
219 void SAL_CALL OGroup::setExpression( const OUString& _expression ) throw (uno::RuntimeException, std::exception)
221 set(PROPERTY_EXPRESSION,_expression,m_aProps.m_sExpression);
224 sal_Bool SAL_CALL OGroup::getStartNewColumn() throw (uno::RuntimeException, std::exception)
226 ::osl::MutexGuard aGuard(m_aMutex);
227 return m_aProps.m_bStartNewColumn;
230 void SAL_CALL OGroup::setStartNewColumn( sal_Bool _startnewcolumn ) throw (uno::RuntimeException, std::exception)
232 set(PROPERTY_STARTNEWCOLUMN,_startnewcolumn,m_aProps.m_bStartNewColumn);
236 sal_Bool SAL_CALL OGroup::getResetPageNumber() throw (uno::RuntimeException, std::exception)
238 ::osl::MutexGuard aGuard(m_aMutex);
239 return m_aProps.m_bResetPageNumber;
242 void SAL_CALL OGroup::setResetPageNumber( sal_Bool _resetpagenumber ) throw (uno::RuntimeException, std::exception)
244 set(PROPERTY_RESETPAGENUMBER,_resetpagenumber,m_aProps.m_bResetPageNumber);
247 // XChild
248 uno::Reference< uno::XInterface > SAL_CALL OGroup::getParent( ) throw (uno::RuntimeException, std::exception)
250 return m_xParent;
253 void SAL_CALL OGroup::setParent( const uno::Reference< uno::XInterface >& /*Parent*/ ) throw (lang::NoSupportException, uno::RuntimeException, std::exception)
255 throw lang::NoSupportException();
258 uno::Reference< beans::XPropertySetInfo > SAL_CALL OGroup::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
260 return GroupPropertySet::getPropertySetInfo();
263 void SAL_CALL OGroup::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
265 GroupPropertySet::setPropertyValue( aPropertyName, aValue );
268 uno::Any SAL_CALL OGroup::getPropertyValue( const OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
270 return GroupPropertySet::getPropertyValue( PropertyName);
273 void SAL_CALL OGroup::addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
275 GroupPropertySet::addPropertyChangeListener( aPropertyName, xListener );
278 void SAL_CALL OGroup::removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
280 GroupPropertySet::removePropertyChangeListener( aPropertyName, aListener );
283 void SAL_CALL OGroup::addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
285 GroupPropertySet::addVetoableChangeListener( PropertyName, aListener );
288 void SAL_CALL OGroup::removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
290 GroupPropertySet::removeVetoableChangeListener( PropertyName, aListener );
293 void OGroup::setSection( const OUString& _sProperty
294 ,bool _bOn
295 ,const OUString& _sName
296 ,uno::Reference< report::XSection>& _member)
298 BoundListeners l;
300 ::osl::MutexGuard aGuard(m_aMutex);
301 prepareSet(_sProperty, uno::makeAny(_member), uno::makeAny(_bOn), &l);
302 lcl_createSectionIfNeeded(_bOn ,this,_member);
303 if ( _member.is() )
304 _member->setName(_sName);
306 l.notify();
309 uno::Reference< report::XFunctions > SAL_CALL OGroup::getFunctions() throw (uno::RuntimeException, std::exception)
311 return m_xFunctions;
314 } // namespace reportdesign
317 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */