cid#1636693 COPY_INSTEAD_OF_MOVE
[LibreOffice.git] / reportdesign / source / core / inc / Section.hxx
blob0f12e551189cb7fc968250eb1feff32172919339
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 #ifndef INCLUDED_REPORTDESIGN_SOURCE_CORE_INC_SECTION_HXX
20 #define INCLUDED_REPORTDESIGN_SOURCE_CORE_INC_SECTION_HXX
22 #include <com/sun/star/report/XSection.hpp>
23 #include <cppuhelper/compbase.hxx>
24 #include <comphelper/broadcasthelper.hxx>
25 #include <comphelper/uno3.hxx>
26 #include <cppuhelper/propertysetmixin.hxx>
27 #include <comphelper/interfacecontainer3.hxx>
28 #include <unotools/weakref.hxx>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <com/sun/star/drawing/XDrawPage.hpp>
31 #include <com/sun/star/drawing/XShapeGrouper.hpp>
32 #include <com/sun/star/drawing/XShapes.hpp>
33 #include <com/sun/star/form/XFormsSupplier2.hpp>
34 #include <com/sun/star/lang/XUnoTunnel.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
37 namespace reportdesign
39 class OGroup;
40 class OReportDefinition;
42 typedef ::cppu::WeakComponentImplHelper
43 < css::report::XSection
44 , css::lang::XServiceInfo
45 , css::lang::XUnoTunnel
46 // SvxDrawPage forwards
47 , css::drawing::XDrawPage
48 , css::drawing::XShapeGrouper
49 , css::form::XFormsSupplier2
50 > SectionBase;
51 typedef ::cppu::PropertySetMixin<css::report::XSection> SectionPropertySet;
53 class OSection : public comphelper::OMutexAndBroadcastHelper,
54 public SectionBase,
55 public SectionPropertySet
57 ::comphelper::OInterfaceContainerHelper3<css::container::XContainerListener> m_aContainerListeners;
58 css::uno::Reference< css::drawing::XDrawPage > m_xDrawPage;
59 css::uno::Reference< css::drawing::XShapeGrouper > m_xDrawPage_ShapeGrouper;
60 css::uno::Reference< css::form::XFormsSupplier2 > m_xDrawPage_FormSupplier;
61 css::uno::Reference< css::lang::XUnoTunnel > m_xDrawPage_Tunnel;
62 unotools::WeakReference< OGroup > m_xGroup;
63 unotools::WeakReference< OReportDefinition > m_xReportDefinition;
64 OUString m_sName;
65 OUString m_sConditionalPrintExpression;
66 ::sal_uInt32 m_nHeight;
67 ::sal_Int32 m_nBackgroundColor;
68 ::sal_Int16 m_nForceNewPage;
69 ::sal_Int16 m_nNewRowOrCol;
70 bool m_bKeepTogether;
71 bool m_bRepeatSection;
72 bool m_bVisible;
73 bool m_bBacktransparent;
74 bool m_bInRemoveNotify;
75 bool m_bInInsertNotify;
77 private:
78 OSection(const OSection&) = delete;
79 OSection& operator=(const OSection&) = delete;
81 template <typename T> void set( const OUString& _sProperty
82 ,const T& Value
83 ,T& _member)
85 BoundListeners l;
87 ::osl::MutexGuard aGuard(m_aMutex);
88 if ( _member != Value )
90 prepareSet(_sProperty, css::uno::Any(_member), css::uno::Any(Value), &l);
91 _member = Value;
94 l.notify();
96 void set( const OUString& _sProperty
97 ,bool Value
98 ,bool& _member)
100 BoundListeners l;
102 ::osl::MutexGuard aGuard(m_aMutex);
103 if ( _member != Value )
105 prepareSet(_sProperty, css::uno::Any(_member), css::uno::Any(Value), &l);
106 _member = Value;
109 l.notify();
112 /** checks if this section is either the page header or footer and if so it throws an UnknownPropertyException
115 void checkNotPageHeaderFooter();
117 void init();
118 protected:
119 // TODO: VirtualFunctionFinder: This is virtual function!
121 virtual ~OSection() override;
123 /** this function is called upon disposing the component
125 // TODO: VirtualFunctionFinder: This is virtual function!
127 virtual void SAL_CALL disposing() override;
128 private:
129 OSection(const rtl::Reference< OReportDefinition >& xParentDef
130 ,const rtl::Reference< OGroup >& xParentGroup
131 ,const css::uno::Reference< css::uno::XComponentContext >& context,
132 css::uno::Sequence< OUString> const&);
133 public:
134 static rtl::Reference< OSection>
135 createOSection(const rtl::Reference< OReportDefinition >& _xParent
136 ,const css::uno::Reference< css::uno::XComponentContext >& context,bool _bPageSection=false);
137 static rtl::Reference< OSection>
138 createOSection(const rtl::Reference< OGroup >& _xParent
139 ,const css::uno::Reference< css::uno::XComponentContext >& context);
141 DECLARE_XINTERFACE( )
143 // css::lang::XServiceInfo
144 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
145 virtual OUString SAL_CALL getImplementationName( ) override;
146 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
148 /// @throws css::uno::RuntimeException
149 static css::uno::Sequence< OUString > getSupportedServiceNames_Static();
150 // css::beans::XPropertySet
151 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
152 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
153 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
154 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
155 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
156 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
157 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
159 // XSection
160 virtual sal_Bool SAL_CALL getVisible() override;
161 virtual void SAL_CALL setVisible( sal_Bool _visible ) override;
162 virtual OUString SAL_CALL getName() override;
163 virtual void SAL_CALL setName( const OUString& _name ) override;
164 virtual ::sal_uInt32 SAL_CALL getHeight() override;
165 virtual void SAL_CALL setHeight( ::sal_uInt32 _height ) override;
166 virtual ::sal_Int32 SAL_CALL getBackColor() override;
167 virtual void SAL_CALL setBackColor( ::sal_Int32 _backgroundcolor ) override;
168 virtual sal_Bool SAL_CALL getBackTransparent() override;
169 virtual void SAL_CALL setBackTransparent( sal_Bool _backtransparent ) override;
170 virtual OUString SAL_CALL getConditionalPrintExpression() override;
171 virtual void SAL_CALL setConditionalPrintExpression( const OUString& _conditionalprintexpression ) override;
172 virtual ::sal_Int16 SAL_CALL getForceNewPage() override;
173 virtual void SAL_CALL setForceNewPage( ::sal_Int16 _forcenewpage ) override;
174 virtual ::sal_Int16 SAL_CALL getNewRowOrCol() override;
175 virtual void SAL_CALL setNewRowOrCol( ::sal_Int16 _newroworcol ) override;
176 virtual sal_Bool SAL_CALL getKeepTogether() override;
177 virtual void SAL_CALL setKeepTogether( sal_Bool _keeptogether ) override;
178 virtual sal_Bool SAL_CALL getCanGrow() override;
179 virtual void SAL_CALL setCanGrow( sal_Bool _cangrow ) override;
180 virtual sal_Bool SAL_CALL getCanShrink() override;
181 virtual void SAL_CALL setCanShrink( sal_Bool _canshrink ) override;
182 virtual sal_Bool SAL_CALL getRepeatSection() override;
183 virtual void SAL_CALL setRepeatSection( sal_Bool _repeatsection ) override;
184 virtual css::uno::Reference< css::report::XGroup > SAL_CALL getGroup() override;
185 virtual css::uno::Reference< css::report::XReportDefinition > SAL_CALL getReportDefinition() override;
187 // XChild
188 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent( ) override;
189 virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override;
190 // XContainer
191 virtual void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
192 virtual void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
193 // XElementAccess
194 virtual css::uno::Type SAL_CALL getElementType( ) override;
195 virtual sal_Bool SAL_CALL hasElements( ) override;
196 // XShapes
197 virtual void SAL_CALL add( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
198 virtual void SAL_CALL remove( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
199 // XShapeGrouper
200 virtual css::uno::Reference< css::drawing::XShapeGroup > SAL_CALL group( const css::uno::Reference< css::drawing::XShapes >& xShapes ) override;
201 virtual void SAL_CALL ungroup( const css::uno::Reference< css::drawing::XShapeGroup >& aGroup ) override;
203 // XFormsSupplier
204 virtual css::uno::Reference< css::container::XNameContainer > SAL_CALL getForms() override;
205 // XFormsSupplier2
206 virtual sal_Bool SAL_CALL hasForms() override;
208 // XIndexAccess
209 virtual ::sal_Int32 SAL_CALL getCount( ) override;
210 virtual css::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) override;
211 // XEnumerationAccess
212 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration( ) override;
214 // XComponent
215 virtual void SAL_CALL dispose() override;
216 virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override
218 cppu::WeakComponentImplHelperBase::addEventListener(aListener);
220 virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override
222 cppu::WeakComponentImplHelperBase::removeEventListener(aListener);
225 // css::lang::XUnoTunnel
226 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
227 static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
229 void notifyElementAdded(const css::uno::Reference< css::drawing::XShape >& xShape);
230 void notifyElementRemoved(const css::uno::Reference< css::drawing::XShape >& xShape);
233 #endif // INCLUDED_REPORTDESIGN_SOURCE_CORE_INC_SECTION_HXX
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */