1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 #ifndef INCLUDED_REPORTDESIGN_SOURCE_CORE_INC_GROUP_HXX
20 #define INCLUDED_REPORTDESIGN_SOURCE_CORE_INC_GROUP_HXX
21 
22 #include <com/sun/star/report/XGroup.hpp>
23 #include <cppuhelper/compbase.hxx>
24 #include <comphelper/broadcasthelper.hxx>
25 #include <cppuhelper/propertysetmixin.hxx>
26 #include <com/sun/star/uno/XComponentContext.hpp>
27 #include <GroupProperties.hxx>
28 #include <comphelper/uno3.hxx>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 
31 namespace reportdesign
32 {
33     typedef ::cppu::WeakComponentImplHelper< css::report::XGroup
34                                          ,   css::lang::XServiceInfo> GroupBase;
35     typedef ::cppu::PropertySetMixin< css::report::XGroup> GroupPropertySet;
36 
37     /** \class OGroup Defines the implementation of a \interface com:::sun::star::report::XGroup
38      * \ingroup reportdesign_api
39      *
40      */
41     class OGroup :   public comphelper::OMutexAndBroadcastHelper
42                     ,public GroupBase
43                     ,public GroupPropertySet
44     {
45         css::uno::Reference< css::uno::XComponentContext >    m_xContext;
46         css::uno::WeakReference< css::report::XGroups >       m_xParent;
47         css::uno::Reference< css::report::XSection>           m_xHeader;
48         css::uno::Reference< css::report::XSection>           m_xFooter;
49         css::uno::Reference< css::report::XFunctions >        m_xFunctions;
50         ::rptshared::GroupProperties                          m_aProps;
51 
52     private:
53         OGroup& operator=(const OGroup&) = delete;
54         OGroup(const OGroup&) = delete;
55 
set(const OUString & _sProperty,const T & Value,T & _member)56         template <typename T> void set(  const OUString& _sProperty
57                                         ,const T& Value
58                                         ,T& _member)
59         {
60             BoundListeners l;
61             {
62                 ::osl::MutexGuard aGuard(m_aMutex);
63                 if ( _member != Value )
64                 {
65                     prepareSet(_sProperty, css::uno::makeAny(_member), css::uno::makeAny(Value), &l);
66                     _member = Value;
67                 }
68             }
69             l.notify();
70         }
set(const OUString & _sProperty,bool Value,bool & _member)71         void set(  const OUString& _sProperty
72                   ,bool Value
73                   ,bool& _member)
74         {
75             BoundListeners l;
76             {
77                 ::osl::MutexGuard aGuard(m_aMutex);
78                 if ( _member != Value )
79                 {
80                     prepareSet(_sProperty, css::uno::makeAny(_member), css::uno::makeAny(Value), &l);
81                     _member = Value;
82                 }
83             }
84             l.notify();
85         }
86         void setSection(     const OUString& _sProperty
87                             ,bool _bOn
88                             ,const OUString& _sName
89                             ,css::uno::Reference< css::report::XSection>& _member);
90     protected:
91         // TODO: VirtualFunctionFinder: This is virtual function!
92 
93         virtual ~OGroup() override;
94 
95         /** this function is called upon disposing the component
96         */
97         // TODO: VirtualFunctionFinder: This is virtual function!
98 
99         virtual void SAL_CALL disposing() override;
100     public:
101         OGroup(const css::uno::Reference< css::report::XGroups >& _xParent
102             ,const css::uno::Reference< css::uno::XComponentContext >& context);
103 
104         DECLARE_XINTERFACE( )
105         // css::lang::XServiceInfo
106         virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
107         virtual OUString SAL_CALL getImplementationName(  ) override;
108         virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) override;
109 
110         /// @throws css::uno::RuntimeException
111         static css::uno::Sequence< OUString > getSupportedServiceNames_Static();
112 
113         // css::beans::XPropertySet
114         virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) override;
115         virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
116         virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
117         virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
118         virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
119         virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
120         virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
121 
122         // XGroup
123         virtual sal_Bool SAL_CALL getSortAscending() override;
124         virtual void SAL_CALL setSortAscending( sal_Bool _sortascending ) override;
125         virtual sal_Bool SAL_CALL getHeaderOn() override;
126         virtual void SAL_CALL setHeaderOn( sal_Bool _headeron ) override;
127         virtual sal_Bool SAL_CALL getFooterOn() override;
128         virtual void SAL_CALL setFooterOn( sal_Bool _footeron ) override;
129         virtual css::uno::Reference< css::report::XSection > SAL_CALL getHeader() override;
130         virtual css::uno::Reference< css::report::XSection > SAL_CALL getFooter() override;
131         virtual ::sal_Int16 SAL_CALL getGroupOn() override;
132         virtual void SAL_CALL setGroupOn( ::sal_Int16 _groupon ) override;
133         virtual ::sal_Int32 SAL_CALL getGroupInterval() override;
134         virtual void SAL_CALL setGroupInterval( ::sal_Int32 _groupinterval ) override;
135         virtual ::sal_Int16 SAL_CALL getKeepTogether() override;
136         virtual void SAL_CALL setKeepTogether( ::sal_Int16 _keeptogether ) override;
137         virtual css::uno::Reference< css::report::XGroups > SAL_CALL getGroups() override;
138         virtual OUString SAL_CALL getExpression() override;
139         virtual void SAL_CALL setExpression( const OUString& _expression ) override;
140         virtual sal_Bool SAL_CALL getStartNewColumn() override;
141         virtual void SAL_CALL setStartNewColumn( sal_Bool _startnewcolumn ) override;
142         virtual sal_Bool SAL_CALL getResetPageNumber() override;
143         virtual void SAL_CALL setResetPageNumber( sal_Bool _resetpagenumber ) override;
144 
145         //XFunctionsSupplier
146         virtual css::uno::Reference< css::report::XFunctions > SAL_CALL getFunctions() override;
147 
148         // XChild
149         virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent(  ) override;
150         virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override;
151 
152         // XComponent
153         virtual void SAL_CALL dispose() override;
addEventListener(const css::uno::Reference<css::lang::XEventListener> & aListener)154         virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override
155         {
156             cppu::WeakComponentImplHelperBase::addEventListener(aListener);
157         }
removeEventListener(const css::uno::Reference<css::lang::XEventListener> & aListener)158         virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override
159         {
160             cppu::WeakComponentImplHelperBase::removeEventListener(aListener);
161         }
162 
getContext() const163         const css::uno::Reference< css::uno::XComponentContext >& getContext() const { return m_xContext; }
164     };
165 
166 } // namespace reportdesign
167 
168 #endif
169 
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
171