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 .
21 #include <Section.hxx>
22 #include <com/sun/star/lang/NoSupportException.hpp>
23 #include <com/sun/star/report/GroupOn.hpp>
24 #include <com/sun/star/report/KeepTogether.hpp>
25 #include <strings.hxx>
26 #include <strings.hrc>
27 #include <core_resource.hxx>
29 #include <cppuhelper/supportsservice.hxx>
30 #include <comphelper/types.hxx>
31 #include <Functions.hxx>
34 namespace reportdesign
37 using namespace com::sun::star
;
39 OGroup::OGroup(const rtl::Reference
< OGroups
>& _xParent
40 ,const uno::Reference
< uno::XComponentContext
>& _xContext
)
42 ,GroupPropertySet(_xContext
,IMPLEMENTS_PROPERTY_SET
,uno::Sequence
< OUString
>())
43 ,m_xContext(_xContext
)
46 osl_atomic_increment(&m_refCount
);
48 m_xFunctions
= new OFunctions(this,m_xContext
);
50 osl_atomic_decrement( &m_refCount
);
53 // TODO: VirtualFunctionFinder: This is virtual function!
59 IMPLEMENT_FORWARD_XINTERFACE2(OGroup
,GroupBase
,GroupPropertySet
)
61 OUString SAL_CALL
OGroup::getImplementationName( )
63 return u
"com.sun.star.comp.report.Group"_ustr
;
66 uno::Sequence
< OUString
> OGroup::getSupportedServiceNames_Static()
68 uno::Sequence
<OUString
> aSupported
{ SERVICE_GROUP
};
72 uno::Sequence
< OUString
> SAL_CALL
OGroup::getSupportedServiceNames()
74 return getSupportedServiceNames_Static();
77 sal_Bool SAL_CALL
OGroup::supportsService( const OUString
& _rServiceName
)
79 return cppu::supportsService(this, _rServiceName
);
82 void SAL_CALL
OGroup::dispose()
84 GroupPropertySet::dispose();
85 cppu::WeakComponentImplHelperBase::dispose();
88 // TODO: VirtualFunctionFinder: This is virtual function!
90 void SAL_CALL
OGroup::disposing()
94 ::comphelper::disposeComponent(m_xFunctions
);
99 sal_Bool SAL_CALL
OGroup::getSortAscending()
101 ::osl::MutexGuard
aGuard(m_aMutex
);
102 return m_aProps
.m_eSortAscending
;
105 void SAL_CALL
OGroup::setSortAscending( sal_Bool _sortascending
)
107 set(PROPERTY_SORTASCENDING
,_sortascending
,m_aProps
.m_eSortAscending
);
110 sal_Bool SAL_CALL
OGroup::getHeaderOn()
112 ::osl::MutexGuard
aGuard(m_aMutex
);
113 return m_xHeader
.is();
116 void SAL_CALL
OGroup::setHeaderOn( sal_Bool _headeron
)
118 if ( bool(_headeron
) != m_xHeader
.is() )
120 OUString
sName(RptResId(RID_STR_GROUP_HEADER
));
121 setSection(PROPERTY_HEADERON
,_headeron
,sName
,m_xHeader
);
125 sal_Bool SAL_CALL
OGroup::getFooterOn()
127 ::osl::MutexGuard
aGuard(m_aMutex
);
128 return m_xFooter
.is();
131 void SAL_CALL
OGroup::setFooterOn( sal_Bool _footeron
)
133 if ( bool(_footeron
) != m_xFooter
.is() )
135 OUString
sName(RptResId(RID_STR_GROUP_FOOTER
));
136 setSection(PROPERTY_FOOTERON
,_footeron
,sName
,m_xFooter
);
140 uno::Reference
< report::XSection
> SAL_CALL
OGroup::getHeader()
142 uno::Reference
< report::XSection
> xRet
;
144 ::osl::MutexGuard
aGuard(m_aMutex
);
149 throw container::NoSuchElementException();
153 uno::Reference
< report::XSection
> SAL_CALL
OGroup::getFooter()
155 uno::Reference
< report::XSection
> xRet
;
157 ::osl::MutexGuard
aGuard(m_aMutex
);
162 throw container::NoSuchElementException();
166 ::sal_Int16 SAL_CALL
OGroup::getGroupOn()
168 ::osl::MutexGuard
aGuard(m_aMutex
);
169 return m_aProps
.m_nGroupOn
;
172 void SAL_CALL
OGroup::setGroupOn( ::sal_Int16 _groupon
)
174 if ( _groupon
< report::GroupOn::DEFAULT
|| _groupon
> report::GroupOn::INTERVAL
)
175 throwIllegallArgumentException(u
"css::report::GroupOn"
178 set(PROPERTY_GROUPON
,_groupon
,m_aProps
.m_nGroupOn
);
181 ::sal_Int32 SAL_CALL
OGroup::getGroupInterval()
183 ::osl::MutexGuard
aGuard(m_aMutex
);
184 return m_aProps
.m_nGroupInterval
;
187 void SAL_CALL
OGroup::setGroupInterval( ::sal_Int32 _groupinterval
)
189 set(PROPERTY_GROUPINTERVAL
,_groupinterval
,m_aProps
.m_nGroupInterval
);
192 ::sal_Int16 SAL_CALL
OGroup::getKeepTogether()
194 ::osl::MutexGuard
aGuard(m_aMutex
);
195 return m_aProps
.m_nKeepTogether
;
198 void SAL_CALL
OGroup::setKeepTogether( ::sal_Int16 _keeptogether
)
200 if ( _keeptogether
< report::KeepTogether::NO
|| _keeptogether
> report::KeepTogether::WITH_FIRST_DETAIL
)
201 throwIllegallArgumentException(u
"css::report::KeepTogether"
204 set(PROPERTY_KEEPTOGETHER
,_keeptogether
,m_aProps
.m_nKeepTogether
);
207 uno::Reference
< report::XGroups
> SAL_CALL
OGroup::getGroups()
209 return m_xParent
.get();
212 rtl::Reference
< OGroups
> OGroup::getOGroups() const
214 return m_xParent
.get();
217 OUString SAL_CALL
OGroup::getExpression()
219 ::osl::MutexGuard
aGuard(m_aMutex
);
220 return m_aProps
.m_sExpression
;
223 void SAL_CALL
OGroup::setExpression( const OUString
& _expression
)
225 set(PROPERTY_EXPRESSION
,_expression
,m_aProps
.m_sExpression
);
228 sal_Bool SAL_CALL
OGroup::getStartNewColumn()
230 ::osl::MutexGuard
aGuard(m_aMutex
);
231 return m_aProps
.m_bStartNewColumn
;
234 void SAL_CALL
OGroup::setStartNewColumn( sal_Bool _startnewcolumn
)
236 set(PROPERTY_STARTNEWCOLUMN
,_startnewcolumn
,m_aProps
.m_bStartNewColumn
);
240 sal_Bool SAL_CALL
OGroup::getResetPageNumber()
242 ::osl::MutexGuard
aGuard(m_aMutex
);
243 return m_aProps
.m_bResetPageNumber
;
246 void SAL_CALL
OGroup::setResetPageNumber( sal_Bool _resetpagenumber
)
248 set(PROPERTY_RESETPAGENUMBER
,_resetpagenumber
,m_aProps
.m_bResetPageNumber
);
252 uno::Reference
< uno::XInterface
> SAL_CALL
OGroup::getParent( )
257 void SAL_CALL
OGroup::setParent( const uno::Reference
< uno::XInterface
>& /*Parent*/ )
259 throw lang::NoSupportException();
262 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
OGroup::getPropertySetInfo( )
264 return GroupPropertySet::getPropertySetInfo();
267 void SAL_CALL
OGroup::setPropertyValue( const OUString
& aPropertyName
, const uno::Any
& aValue
)
269 GroupPropertySet::setPropertyValue( aPropertyName
, aValue
);
272 uno::Any SAL_CALL
OGroup::getPropertyValue( const OUString
& PropertyName
)
274 return GroupPropertySet::getPropertyValue( PropertyName
);
277 void SAL_CALL
OGroup::addPropertyChangeListener( const OUString
& aPropertyName
, const uno::Reference
< beans::XPropertyChangeListener
>& xListener
)
279 GroupPropertySet::addPropertyChangeListener( aPropertyName
, xListener
);
282 void SAL_CALL
OGroup::removePropertyChangeListener( const OUString
& aPropertyName
, const uno::Reference
< beans::XPropertyChangeListener
>& aListener
)
284 GroupPropertySet::removePropertyChangeListener( aPropertyName
, aListener
);
287 void SAL_CALL
OGroup::addVetoableChangeListener( const OUString
& PropertyName
, const uno::Reference
< beans::XVetoableChangeListener
>& aListener
)
289 GroupPropertySet::addVetoableChangeListener( PropertyName
, aListener
);
292 void SAL_CALL
OGroup::removeVetoableChangeListener( const OUString
& PropertyName
, const uno::Reference
< beans::XVetoableChangeListener
>& aListener
)
294 GroupPropertySet::removeVetoableChangeListener( PropertyName
, aListener
);
297 void OGroup::setSection( const OUString
& _sProperty
299 ,const OUString
& _sName
300 ,rtl::Reference
< OSection
>& _member
)
304 ::osl::MutexGuard
aGuard(m_aMutex
);
305 prepareSet(_sProperty
, uno::Any(uno::Reference
<report::XSection
>(_member
)), uno::Any(_bOn
), &l
);
307 // create section if needed
308 if ( _bOn
&& !_member
.is() )
309 _member
= OSection::createOSection(this, m_xContext
);
311 ::comphelper::disposeComponent(_member
);
314 _member
->setName(_sName
);
319 uno::Reference
< report::XFunctions
> SAL_CALL
OGroup::getFunctions()
324 } // namespace reportdesign
327 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */