1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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"
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
)
43 ,GroupPropertySet(_xContext
,static_cast< GroupPropertySet::Implements
>(IMPLEMENTS_PROPERTY_SET
),uno::Sequence
< OUString
>())
44 ,m_xContext(_xContext
)
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!
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(1);
70 aSupported
.getArray()[0] = SERVICE_GROUP
;
74 uno::Sequence
< OUString
> SAL_CALL
OGroup::getSupportedServiceNames() throw(uno::RuntimeException
, std::exception
)
76 return getSupportedServiceNames_Static();
79 sal_Bool SAL_CALL
OGroup::supportsService( const OUString
& _rServiceName
) throw(uno::RuntimeException
, std::exception
)
81 return cppu::supportsService(this, _rServiceName
);
84 void SAL_CALL
OGroup::dispose() throw(uno::RuntimeException
, std::exception
)
86 GroupPropertySet::dispose();
87 cppu::WeakComponentImplHelperBase::dispose();
90 // TODO: VirtualFunctionFinder: This is virtual function!
92 void SAL_CALL
OGroup::disposing()
96 ::comphelper::disposeComponent(m_xFunctions
);
101 sal_Bool SAL_CALL
OGroup::getSortAscending() throw (uno::RuntimeException
, std::exception
)
103 ::osl::MutexGuard
aGuard(m_aMutex
);
104 return m_aProps
.m_eSortAscending
;
107 void SAL_CALL
OGroup::setSortAscending( sal_Bool _sortascending
) throw (uno::RuntimeException
, std::exception
)
109 set(PROPERTY_SORTASCENDING
,_sortascending
,m_aProps
.m_eSortAscending
);
112 sal_Bool SAL_CALL
OGroup::getHeaderOn() throw (uno::RuntimeException
, std::exception
)
114 ::osl::MutexGuard
aGuard(m_aMutex
);
115 return m_xHeader
.is();
118 void SAL_CALL
OGroup::setHeaderOn( sal_Bool _headeron
) throw (uno::RuntimeException
, std::exception
)
120 if ( bool(_headeron
) != m_xHeader
.is() )
122 OUString
sName(RPT_RESSTRING(RID_STR_GROUP_HEADER
,m_xContext
->getServiceManager()));
123 setSection(PROPERTY_HEADERON
,_headeron
,sName
,m_xHeader
);
127 sal_Bool SAL_CALL
OGroup::getFooterOn() throw (uno::RuntimeException
, std::exception
)
129 ::osl::MutexGuard
aGuard(m_aMutex
);
130 return m_xFooter
.is();
133 void SAL_CALL
OGroup::setFooterOn( sal_Bool _footeron
) throw (uno::RuntimeException
, std::exception
)
135 if ( bool(_footeron
) != m_xFooter
.is() )
137 OUString
sName(RPT_RESSTRING(RID_STR_GROUP_FOOTER
,m_xContext
->getServiceManager()));
138 setSection(PROPERTY_FOOTERON
,_footeron
,sName
,m_xFooter
);
142 uno::Reference
< report::XSection
> SAL_CALL
OGroup::getHeader() throw (container::NoSuchElementException
, uno::RuntimeException
, std::exception
)
144 uno::Reference
< report::XSection
> xRet
;
146 ::osl::MutexGuard
aGuard(m_aMutex
);
151 throw container::NoSuchElementException();
155 uno::Reference
< report::XSection
> SAL_CALL
OGroup::getFooter() throw (container::NoSuchElementException
, uno::RuntimeException
, std::exception
)
157 uno::Reference
< report::XSection
> xRet
;
159 ::osl::MutexGuard
aGuard(m_aMutex
);
164 throw container::NoSuchElementException();
168 ::sal_Int16 SAL_CALL
OGroup::getGroupOn() throw (uno::RuntimeException
, std::exception
)
170 ::osl::MutexGuard
aGuard(m_aMutex
);
171 return m_aProps
.m_nGroupOn
;
174 void SAL_CALL
OGroup::setGroupOn( ::sal_Int16 _groupon
) throw (lang::IllegalArgumentException
, uno::RuntimeException
, std::exception
)
176 if ( _groupon
< report::GroupOn::DEFAULT
|| _groupon
> report::GroupOn::INTERVAL
)
177 throwIllegallArgumentException("com::sun::star::report::GroupOn"
181 set(PROPERTY_GROUPON
,_groupon
,m_aProps
.m_nGroupOn
);
184 ::sal_Int32 SAL_CALL
OGroup::getGroupInterval() throw (uno::RuntimeException
, std::exception
)
186 ::osl::MutexGuard
aGuard(m_aMutex
);
187 return m_aProps
.m_nGroupInterval
;
190 void SAL_CALL
OGroup::setGroupInterval( ::sal_Int32 _groupinterval
) throw (uno::RuntimeException
, std::exception
)
192 set(PROPERTY_GROUPINTERVAL
,_groupinterval
,m_aProps
.m_nGroupInterval
);
195 ::sal_Int16 SAL_CALL
OGroup::getKeepTogether() throw (uno::RuntimeException
, std::exception
)
197 ::osl::MutexGuard
aGuard(m_aMutex
);
198 return m_aProps
.m_nKeepTogether
;
201 void SAL_CALL
OGroup::setKeepTogether( ::sal_Int16 _keeptogether
) throw (lang::IllegalArgumentException
, uno::RuntimeException
, std::exception
)
203 if ( _keeptogether
< report::KeepTogether::NO
|| _keeptogether
> report::KeepTogether::WITH_FIRST_DETAIL
)
204 throwIllegallArgumentException("com::sun::star::report::KeepTogether"
208 set(PROPERTY_KEEPTOGETHER
,_keeptogether
,m_aProps
.m_nKeepTogether
);
211 uno::Reference
< report::XGroups
> SAL_CALL
OGroup::getGroups() throw (uno::RuntimeException
, std::exception
)
216 OUString SAL_CALL
OGroup::getExpression() throw (uno::RuntimeException
, std::exception
)
218 ::osl::MutexGuard
aGuard(m_aMutex
);
219 return m_aProps
.m_sExpression
;
222 void SAL_CALL
OGroup::setExpression( const OUString
& _expression
) throw (uno::RuntimeException
, std::exception
)
224 set(PROPERTY_EXPRESSION
,_expression
,m_aProps
.m_sExpression
);
227 sal_Bool SAL_CALL
OGroup::getStartNewColumn() throw (uno::RuntimeException
, std::exception
)
229 ::osl::MutexGuard
aGuard(m_aMutex
);
230 return m_aProps
.m_bStartNewColumn
;
233 void SAL_CALL
OGroup::setStartNewColumn( sal_Bool _startnewcolumn
) throw (uno::RuntimeException
, std::exception
)
235 set(PROPERTY_STARTNEWCOLUMN
,_startnewcolumn
,m_aProps
.m_bStartNewColumn
);
239 sal_Bool SAL_CALL
OGroup::getResetPageNumber() throw (uno::RuntimeException
, std::exception
)
241 ::osl::MutexGuard
aGuard(m_aMutex
);
242 return m_aProps
.m_bResetPageNumber
;
245 void SAL_CALL
OGroup::setResetPageNumber( sal_Bool _resetpagenumber
) throw (uno::RuntimeException
, std::exception
)
247 set(PROPERTY_RESETPAGENUMBER
,_resetpagenumber
,m_aProps
.m_bResetPageNumber
);
251 uno::Reference
< uno::XInterface
> SAL_CALL
OGroup::getParent( ) throw (uno::RuntimeException
, std::exception
)
256 void SAL_CALL
OGroup::setParent( const uno::Reference
< uno::XInterface
>& /*Parent*/ ) throw (lang::NoSupportException
, uno::RuntimeException
, std::exception
)
258 throw lang::NoSupportException();
261 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
OGroup::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
263 return GroupPropertySet::getPropertySetInfo();
266 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
)
268 GroupPropertySet::setPropertyValue( aPropertyName
, aValue
);
271 uno::Any SAL_CALL
OGroup::getPropertyValue( const OUString
& PropertyName
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
273 return GroupPropertySet::getPropertyValue( PropertyName
);
276 void SAL_CALL
OGroup::addPropertyChangeListener( const OUString
& aPropertyName
, const uno::Reference
< beans::XPropertyChangeListener
>& xListener
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
278 GroupPropertySet::addPropertyChangeListener( aPropertyName
, xListener
);
281 void SAL_CALL
OGroup::removePropertyChangeListener( const OUString
& aPropertyName
, const uno::Reference
< beans::XPropertyChangeListener
>& aListener
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
283 GroupPropertySet::removePropertyChangeListener( aPropertyName
, aListener
);
286 void SAL_CALL
OGroup::addVetoableChangeListener( const OUString
& PropertyName
, const uno::Reference
< beans::XVetoableChangeListener
>& aListener
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
288 GroupPropertySet::addVetoableChangeListener( PropertyName
, aListener
);
291 void SAL_CALL
OGroup::removeVetoableChangeListener( const OUString
& PropertyName
, const uno::Reference
< beans::XVetoableChangeListener
>& aListener
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
293 GroupPropertySet::removeVetoableChangeListener( PropertyName
, aListener
);
296 void OGroup::setSection( const OUString
& _sProperty
298 ,const OUString
& _sName
299 ,uno::Reference
< report::XSection
>& _member
)
303 ::osl::MutexGuard
aGuard(m_aMutex
);
304 prepareSet(_sProperty
, uno::makeAny(_member
), uno::makeAny(_bOn
), &l
);
305 lcl_createSectionIfNeeded(_bOn
,this,_member
);
307 _member
->setName(_sName
);
312 uno::Reference
< report::XFunctions
> SAL_CALL
OGroup::getFunctions() throw (uno::RuntimeException
, std::exception
)
317 } // namespace reportdesign
320 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */