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/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 <Functions.hxx>
33 namespace reportdesign
36 using namespace com::sun::star
;
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
)
45 osl_atomic_increment(&m_refCount
);
47 m_xFunctions
= new OFunctions(this,m_xContext
);
49 osl_atomic_decrement( &m_refCount
);
52 // TODO: VirtualFunctionFinder: This is virtual function!
58 IMPLEMENT_FORWARD_XINTERFACE2(OGroup
,GroupBase
,GroupPropertySet
)
60 OUString SAL_CALL
OGroup::getImplementationName( )
62 return OUString("com.sun.star.comp.report.Group");
65 uno::Sequence
< OUString
> OGroup::getSupportedServiceNames_Static()
67 uno::Sequence
<OUString
> aSupported
{ SERVICE_GROUP
};
71 uno::Sequence
< OUString
> SAL_CALL
OGroup::getSupportedServiceNames()
73 return getSupportedServiceNames_Static();
76 sal_Bool SAL_CALL
OGroup::supportsService( const OUString
& _rServiceName
)
78 return cppu::supportsService(this, _rServiceName
);
81 void SAL_CALL
OGroup::dispose()
83 GroupPropertySet::dispose();
84 cppu::WeakComponentImplHelperBase::dispose();
87 // TODO: VirtualFunctionFinder: This is virtual function!
89 void SAL_CALL
OGroup::disposing()
93 ::comphelper::disposeComponent(m_xFunctions
);
98 sal_Bool SAL_CALL
OGroup::getSortAscending()
100 ::osl::MutexGuard
aGuard(m_aMutex
);
101 return m_aProps
.m_eSortAscending
;
104 void SAL_CALL
OGroup::setSortAscending( sal_Bool _sortascending
)
106 set(PROPERTY_SORTASCENDING
,_sortascending
,m_aProps
.m_eSortAscending
);
109 sal_Bool SAL_CALL
OGroup::getHeaderOn()
111 ::osl::MutexGuard
aGuard(m_aMutex
);
112 return m_xHeader
.is();
115 void SAL_CALL
OGroup::setHeaderOn( sal_Bool _headeron
)
117 if ( bool(_headeron
) != m_xHeader
.is() )
119 OUString
sName(RptResId(RID_STR_GROUP_HEADER
));
120 setSection(PROPERTY_HEADERON
,_headeron
,sName
,m_xHeader
);
124 sal_Bool SAL_CALL
OGroup::getFooterOn()
126 ::osl::MutexGuard
aGuard(m_aMutex
);
127 return m_xFooter
.is();
130 void SAL_CALL
OGroup::setFooterOn( sal_Bool _footeron
)
132 if ( bool(_footeron
) != m_xFooter
.is() )
134 OUString
sName(RptResId(RID_STR_GROUP_FOOTER
));
135 setSection(PROPERTY_FOOTERON
,_footeron
,sName
,m_xFooter
);
139 uno::Reference
< report::XSection
> SAL_CALL
OGroup::getHeader()
141 uno::Reference
< report::XSection
> xRet
;
143 ::osl::MutexGuard
aGuard(m_aMutex
);
148 throw container::NoSuchElementException();
152 uno::Reference
< report::XSection
> SAL_CALL
OGroup::getFooter()
154 uno::Reference
< report::XSection
> xRet
;
156 ::osl::MutexGuard
aGuard(m_aMutex
);
161 throw container::NoSuchElementException();
165 ::sal_Int16 SAL_CALL
OGroup::getGroupOn()
167 ::osl::MutexGuard
aGuard(m_aMutex
);
168 return m_aProps
.m_nGroupOn
;
171 void SAL_CALL
OGroup::setGroupOn( ::sal_Int16 _groupon
)
173 if ( _groupon
< report::GroupOn::DEFAULT
|| _groupon
> report::GroupOn::INTERVAL
)
174 throwIllegallArgumentException("css::report::GroupOn"
177 set(PROPERTY_GROUPON
,_groupon
,m_aProps
.m_nGroupOn
);
180 ::sal_Int32 SAL_CALL
OGroup::getGroupInterval()
182 ::osl::MutexGuard
aGuard(m_aMutex
);
183 return m_aProps
.m_nGroupInterval
;
186 void SAL_CALL
OGroup::setGroupInterval( ::sal_Int32 _groupinterval
)
188 set(PROPERTY_GROUPINTERVAL
,_groupinterval
,m_aProps
.m_nGroupInterval
);
191 ::sal_Int16 SAL_CALL
OGroup::getKeepTogether()
193 ::osl::MutexGuard
aGuard(m_aMutex
);
194 return m_aProps
.m_nKeepTogether
;
197 void SAL_CALL
OGroup::setKeepTogether( ::sal_Int16 _keeptogether
)
199 if ( _keeptogether
< report::KeepTogether::NO
|| _keeptogether
> report::KeepTogether::WITH_FIRST_DETAIL
)
200 throwIllegallArgumentException("css::report::KeepTogether"
203 set(PROPERTY_KEEPTOGETHER
,_keeptogether
,m_aProps
.m_nKeepTogether
);
206 uno::Reference
< report::XGroups
> SAL_CALL
OGroup::getGroups()
211 OUString SAL_CALL
OGroup::getExpression()
213 ::osl::MutexGuard
aGuard(m_aMutex
);
214 return m_aProps
.m_sExpression
;
217 void SAL_CALL
OGroup::setExpression( const OUString
& _expression
)
219 set(PROPERTY_EXPRESSION
,_expression
,m_aProps
.m_sExpression
);
222 sal_Bool SAL_CALL
OGroup::getStartNewColumn()
224 ::osl::MutexGuard
aGuard(m_aMutex
);
225 return m_aProps
.m_bStartNewColumn
;
228 void SAL_CALL
OGroup::setStartNewColumn( sal_Bool _startnewcolumn
)
230 set(PROPERTY_STARTNEWCOLUMN
,_startnewcolumn
,m_aProps
.m_bStartNewColumn
);
234 sal_Bool SAL_CALL
OGroup::getResetPageNumber()
236 ::osl::MutexGuard
aGuard(m_aMutex
);
237 return m_aProps
.m_bResetPageNumber
;
240 void SAL_CALL
OGroup::setResetPageNumber( sal_Bool _resetpagenumber
)
242 set(PROPERTY_RESETPAGENUMBER
,_resetpagenumber
,m_aProps
.m_bResetPageNumber
);
246 uno::Reference
< uno::XInterface
> SAL_CALL
OGroup::getParent( )
251 void SAL_CALL
OGroup::setParent( const uno::Reference
< uno::XInterface
>& /*Parent*/ )
253 throw lang::NoSupportException();
256 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
OGroup::getPropertySetInfo( )
258 return GroupPropertySet::getPropertySetInfo();
261 void SAL_CALL
OGroup::setPropertyValue( const OUString
& aPropertyName
, const uno::Any
& aValue
)
263 GroupPropertySet::setPropertyValue( aPropertyName
, aValue
);
266 uno::Any SAL_CALL
OGroup::getPropertyValue( const OUString
& PropertyName
)
268 return GroupPropertySet::getPropertyValue( PropertyName
);
271 void SAL_CALL
OGroup::addPropertyChangeListener( const OUString
& aPropertyName
, const uno::Reference
< beans::XPropertyChangeListener
>& xListener
)
273 GroupPropertySet::addPropertyChangeListener( aPropertyName
, xListener
);
276 void SAL_CALL
OGroup::removePropertyChangeListener( const OUString
& aPropertyName
, const uno::Reference
< beans::XPropertyChangeListener
>& aListener
)
278 GroupPropertySet::removePropertyChangeListener( aPropertyName
, aListener
);
281 void SAL_CALL
OGroup::addVetoableChangeListener( const OUString
& PropertyName
, const uno::Reference
< beans::XVetoableChangeListener
>& aListener
)
283 GroupPropertySet::addVetoableChangeListener( PropertyName
, aListener
);
286 void SAL_CALL
OGroup::removeVetoableChangeListener( const OUString
& PropertyName
, const uno::Reference
< beans::XVetoableChangeListener
>& aListener
)
288 GroupPropertySet::removeVetoableChangeListener( PropertyName
, aListener
);
291 void OGroup::setSection( const OUString
& _sProperty
293 ,const OUString
& _sName
294 ,uno::Reference
< report::XSection
>& _member
)
298 ::osl::MutexGuard
aGuard(m_aMutex
);
299 prepareSet(_sProperty
, uno::makeAny(_member
), uno::makeAny(_bOn
), &l
);
301 // create section if needed
302 if ( _bOn
&& !_member
.is() )
303 _member
= OSection::createOSection(this, getContext());
305 ::comphelper::disposeComponent(_member
);
308 _member
->setName(_sName
);
313 uno::Reference
< report::XFunctions
> SAL_CALL
OGroup::getFunctions()
318 } // namespace reportdesign
321 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */