LibreOffice Module reportdesign (master)  1
Shape.hxx
Go to the documentation of this file.
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_SHAPE_HXX
20 #define INCLUDED_REPORTDESIGN_SOURCE_CORE_INC_SHAPE_HXX
21 
23 #include <com/sun/star/report/XShape.hpp>
24 #include "ReportControlModel.hxx"
25 #include <cppuhelper/compbase.hxx>
26 #include <cppuhelper/basemutex.hxx>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <ReportHelperDefines.hxx>
29 #include <comphelper/propagg.hxx>
30 #include <memory>
31 
32 namespace reportdesign
33 {
34  typedef ::cppu::PropertySetMixin< css::report::XShape > ShapePropertySet;
35  typedef ::cppu::WeakComponentImplHelper< css::report::XShape
36  ,css::lang::XServiceInfo > ShapeBase;
37 
42  class OShape : public cppu::BaseMutex,
43  public ShapeBase,
44  public ShapePropertySet
45  {
46  friend class OShapeHelper;
47  ::std::unique_ptr< ::comphelper::OPropertyArrayAggregationHelper> m_pAggHelper;
49  css::drawing::HomogenMatrix3 m_Transformation;
50  sal_Int32 m_nZOrder;
51  bool m_bOpaque;
52 
53  OUString m_sServiceName;
56  css::uno::Sequence< css::beans::PropertyValue > m_CustomShapeGeometry;
57 
58  private:
59  OShape(const OShape&) = delete;
60  OShape& operator=(const OShape&) = delete;
61 
62  // internally, we store PROPERTY_PARAADJUST as css::style::ParagraphAdjust, but externally the property is visible as a sal_Int16
63  void set( const OUString& _sProperty
64  ,sal_Int16 Value
65  ,css::style::ParagraphAdjust& _member)
66  {
67  BoundListeners l;
68  {
69  ::osl::MutexGuard aGuard(m_aMutex);
70  if ( static_cast<sal_Int16>(_member) != Value )
71  {
72  prepareSet(_sProperty, css::uno::makeAny(static_cast<sal_Int16>(_member)), css::uno::makeAny(Value), &l);
73  _member = static_cast<css::style::ParagraphAdjust>(Value);
74  }
75  }
76  l.notify();
77  }
78  template <typename T> void set( const OUString& _sProperty
79  ,const T& Value
80  ,T& _member)
81  {
82  BoundListeners l;
83  {
84  ::osl::MutexGuard aGuard(m_aMutex);
85  if ( _member != Value )
86  {
87  prepareSet(_sProperty, css::uno::makeAny(_member), css::uno::makeAny(Value), &l);
88  _member = Value;
89  }
90  }
91  l.notify();
92  }
93  void set( const OUString& _sProperty
94  ,bool Value
95  ,bool& _member)
96  {
97  BoundListeners l;
98  {
99  ::osl::MutexGuard aGuard(m_aMutex);
100  if ( _member != Value )
101  {
102  prepareSet(_sProperty, css::uno::makeAny(_member), css::uno::makeAny(Value), &l);
103  _member = Value;
104  }
105  }
106  l.notify();
107  }
109  protected:
110  virtual ~OShape() override;
111  public:
112  explicit OShape(css::uno::Reference< css::uno::XComponentContext > const & _xContext);
113  explicit OShape(css::uno::Reference< css::uno::XComponentContext > const & _xContext
114  ,const css::uno::Reference< css::lang::XMultiServiceFactory > & _xFactory
115  ,css::uno::Reference< css::drawing::XShape >& _xShape
116  ,const OUString& _sServiceName);
117 
119  // css::lang::XServiceInfo
120  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
121  virtual OUString SAL_CALL getImplementationName( ) override;
122  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
123 
125  static css::uno::Sequence< OUString > getSupportedServiceNames_Static();
127  static OUString getImplementationName_Static();
128  static css::uno::Reference< css::uno::XInterface >
129  create(css::uno::Reference< css::uno::XComponentContext > const & xContext);
130  // css::beans::XPropertySet
131  virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
132  virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
133  virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
134  virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
135  virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
136  virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
137  virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
138 
139  // XReportComponent
141 
142  // XShape
143  SHAPE_HEADER()
144 
145  virtual OUString SAL_CALL getCustomShapeEngine() override;
146  virtual void SAL_CALL setCustomShapeEngine( const OUString& _customshapeengine ) override;
147  virtual OUString SAL_CALL getCustomShapeData() override;
148  virtual void SAL_CALL setCustomShapeData( const OUString& _customshapedata ) override;
149  virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCustomShapeGeometry() override;
150  virtual void SAL_CALL setCustomShapeGeometry( const css::uno::Sequence< css::beans::PropertyValue >& _customshapegeometry ) override;
151 
152  virtual sal_Bool SAL_CALL getOpaque() override;
153  virtual void SAL_CALL setOpaque( sal_Bool _opaque ) override;
154 
155  // XShapeDescriptor
156  virtual OUString SAL_CALL getShapeType( ) override;
157 
158  // XReportControlModel
160 
161  // XReportControlFormat
163  // XShape
164  virtual ::sal_Int32 SAL_CALL getZOrder() override;
165  virtual void SAL_CALL setZOrder( ::sal_Int32 _zorder ) override;
166  virtual css::drawing::HomogenMatrix3 SAL_CALL getTransformation() override;
167  virtual void SAL_CALL setTransformation( const css::drawing::HomogenMatrix3& _transformation ) override;
168 
169  // XCloneable
170  virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) override;
171 
172  // XComponent
173  virtual void SAL_CALL dispose() override;
174  virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override
175  {
176  cppu::WeakComponentImplHelperBase::addEventListener(aListener);
177  }
178  virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override
179  {
180  cppu::WeakComponentImplHelperBase::removeEventListener(aListener);
181  }
182 
183  // XChild
184  virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent( ) override;
185  virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override;
186 
187  // XContainer
188  virtual void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
189  virtual void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
190 
191  // XElementAccess
192  virtual css::uno::Type SAL_CALL getElementType( ) override;
193  virtual sal_Bool SAL_CALL hasElements( ) override;
194 
195  // XIndexReplace
196  virtual void SAL_CALL replaceByIndex( ::sal_Int32 Index, const css::uno::Any& Element ) override;
197 
198  // XIndexContainer
199  virtual void SAL_CALL insertByIndex( ::sal_Int32 Index, const css::uno::Any& Element ) override;
200  virtual void SAL_CALL removeByIndex( ::sal_Int32 Index ) override;
201 
202  // XIndexAccess
203  virtual ::sal_Int32 SAL_CALL getCount( ) override;
204  virtual css::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) override;
205  };
206 }
207 #endif // INCLUDED_REPORTDESIGN_SOURCE_CORE_INC_SHAPE_HXX
208 
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL setOpaque(sal_Bool _opaque) override
Definition: Shape.cxx:431
OShape & operator=(const OShape &)=delete
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: Shape.cxx:205
virtual ::sal_Int32 SAL_CALL getZOrder() override
Definition: Shape.cxx:411
virtual ~OShape() override
Definition: Shape.cxx:84
mutable::osl::Mutex m_aMutex
#define REPORTCONTROLFORMAT_HEADER()
cppu::IPropertyArrayHelper & getInfoHelper()
Definition: Shape.cxx:182
css::drawing::HomogenMatrix3 m_Transformation
Definition: Shape.hxx:49
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCustomShapeGeometry() override
Definition: Shape.cxx:477
virtual void SAL_CALL addContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
Definition: Shape.cxx:331
::cppu::WeakComponentImplHelper< css::report::XShape,css::lang::XServiceInfo > ShapeBase
Definition: Shape.hxx:36
virtual OUString SAL_CALL getImplementationName() override
Definition: Shape.cxx:122
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: Shape.cxx:216
virtual ::sal_Int32 SAL_CALL getCount() override
Definition: Shape.cxx:370
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: Shape.cxx:246
virtual OUString SAL_CALL getCustomShapeData() override
Definition: Shape.cxx:464
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: Shape.cxx:132
sal_Int32 m_nZOrder
Definition: Shape.hxx:50
#define REPORTCOMPONENT_HEADER()
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: Shape.cxx:236
void set(const OUString &_sProperty, sal_Int16 Value, css::style::ParagraphAdjust &_member)
Definition: Shape.hxx:63
virtual void SAL_CALL setTransformation(const css::drawing::HomogenMatrix3 &_transformation) override
Definition: Shape.cxx:444
void set(const OUString &_sProperty, const T &Value, T &_member)
Definition: Shape.hxx:78
OReportControlModel m_aProps
Definition: Shape.hxx:48
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
Definition: Shape.cxx:291
OUString m_CustomShapeData
Definition: Shape.hxx:55
virtual void SAL_CALL removeByIndex(::sal_Int32 Index) override
Definition: Shape.cxx:358
virtual void SAL_CALL setCustomShapeEngine(const OUString &_customshapeengine) override
Definition: Shape.cxx:458
OUString m_sServiceName
Definition: Shape.hxx:53
#define SHAPE_HEADER()
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: Shape.cxx:175
virtual void SAL_CALL removeContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
Definition: Shape.cxx:336
implementation of a
Definition: Shape.hxx:42
virtual css::uno::Type SAL_CALL getElementType() override
Definition: Shape.cxx:342
unsigned char sal_Bool
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() override
Definition: Shape.cxx:315
OShape(const OShape &)=delete
virtual css::drawing::HomogenMatrix3 SAL_CALL getTransformation() override
Definition: Shape.cxx:437
virtual void SAL_CALL insertByIndex(::sal_Int32 Index, const css::uno::Any &Element) override
Definition: Shape.cxx:353
virtual OUString SAL_CALL getCustomShapeEngine() override
Definition: Shape.cxx:450
virtual void SAL_CALL setParent(const css::uno::Reference< css::uno::XInterface > &Parent) override
Definition: Shape.cxx:320
::std::unique_ptr< ::comphelper::OPropertyArrayAggregationHelper > m_pAggHelper
Definition: Shape.hxx:47
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: Shape.cxx:144
virtual void SAL_CALL setCustomShapeGeometry(const css::uno::Sequence< css::beans::PropertyValue > &_customshapegeometry) override
Definition: Shape.cxx:484
::cppu::PropertySetMixin< css::report::XShape > ShapePropertySet
Definition: Shape.hxx:34
css::uno::Sequence< css::beans::PropertyValue > m_CustomShapeGeometry
Definition: Shape.hxx:56
virtual void SAL_CALL replaceByIndex(::sal_Int32 Index, const css::uno::Any &Element) override
Definition: Shape.cxx:364
void prepareSet(rtl::OUString const &propertyName, css::uno::Any const &oldValue, css::uno::Any const &newValue, BoundListeners *boundListeners)
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: Shape.hxx:174
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: Shape.cxx:195
static OUString getImplementationName_Static()
Definition: Shape.cxx:116
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: Shape.cxx:226
OUString m_CustomShapeEngine
Definition: Shape.hxx:54
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: Shape.hxx:178
virtual css::uno::Any SAL_CALL getByIndex(::sal_Int32 Index) override
Definition: Shape.cxx:375
#define REPORTCONTROLMODEL_HEADER()
void set(const OUString &_sProperty, bool Value, bool &_member)
Definition: Shape.hxx:93
static css::uno::Sequence< OUString > getSupportedServiceNames_Static()
Definition: Shape.cxx:127
virtual void SAL_CALL setZOrder(::sal_Int32 _zorder) override
Definition: Shape.cxx:418
virtual void SAL_CALL setCustomShapeData(const OUString &_customshapedata) override
Definition: Shape.cxx:471
struct _ADOIndex Index
static css::uno::Reference< css::uno::XInterface > create(css::uno::Reference< css::uno::XComponentContext > const &xContext)
Definition: Shape.cxx:110
virtual sal_Bool SAL_CALL hasElements() override
Definition: Shape.cxx:347
virtual sal_Bool SAL_CALL getOpaque() override
Definition: Shape.cxx:425
virtual void SAL_CALL dispose() override
Definition: Shape.cxx:104
#define DECLARE_XINTERFACE()
virtual OUString SAL_CALL getShapeType() override
Definition: Shape.cxx:403