LibreOffice Module reportdesign (master)  1
FixedText.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 
20 #ifndef INCLUDED_REPORTDESIGN_SOURCE_CORE_INC_FIXEDTEXT_HXX
21 #define INCLUDED_REPORTDESIGN_SOURCE_CORE_INC_FIXEDTEXT_HXX
22 
24 #include <com/sun/star/report/XFixedText.hpp>
25 #include "ReportControlModel.hxx"
26 #include <comphelper/uno3.hxx>
27 #include <cppuhelper/compbase.hxx>
28 #include <cppuhelper/basemutex.hxx>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <ReportHelperDefines.hxx>
31 
32 
33 namespace reportdesign
34 {
35  typedef ::cppu::PropertySetMixin< css::report::XFixedText > FixedTextPropertySet;
36  typedef ::cppu::WeakComponentImplHelper< css::report::XFixedText
37  ,css::lang::XServiceInfo > FixedTextBase;
38 
43  class OFixedText : public cppu::BaseMutex,
44  public FixedTextBase,
45  public FixedTextPropertySet
46  {
47  friend class OShapeHelper;
49  OUString m_sLabel;
50  private:
51  OFixedText(const OFixedText&) = delete;
52  OFixedText& operator=(const OFixedText&) = delete;
53 
54  // internally, we store PROPERTY_PARAADJUST as css::style::ParagraphAdjust, but externally the property is visible as a sal_Int16
55  void set( const OUString& _sProperty
56  ,sal_Int16 Value
57  ,css::style::ParagraphAdjust& _member)
58  {
59  BoundListeners l;
60  {
61  ::osl::MutexGuard aGuard(m_aMutex);
62  if ( static_cast<sal_Int16>(_member) != Value )
63  {
64  prepareSet(_sProperty, css::uno::makeAny(static_cast<sal_Int16>(_member)), css::uno::makeAny(Value), &l);
65  _member = static_cast<css::style::ParagraphAdjust>(Value);
66  }
67  }
68  l.notify();
69  }
70  template <typename T> void set( const OUString& _sProperty
71  ,const T& Value
72  ,T& _member)
73  {
74  BoundListeners l;
75  {
76  ::osl::MutexGuard aGuard(m_aMutex);
77  if ( _member != Value )
78  {
79  prepareSet(_sProperty, css::uno::makeAny(_member), css::uno::makeAny(Value), &l);
80  _member = Value;
81  }
82  }
83  l.notify();
84  }
85  void set( const OUString& _sProperty
86  ,bool Value
87  ,bool& _member)
88  {
89  BoundListeners l;
90  {
91  ::osl::MutexGuard aGuard(m_aMutex);
92  if ( _member != Value )
93  {
94  prepareSet(_sProperty, css::uno::makeAny(_member), css::uno::makeAny(Value), &l);
95  _member = Value;
96  }
97  }
98  l.notify();
99  }
100  protected:
101  virtual ~OFixedText() override;
102  public:
103  explicit OFixedText(css::uno::Reference< css::uno::XComponentContext > const & _xContext);
104  explicit OFixedText(css::uno::Reference< css::uno::XComponentContext > const & _xContext
105  ,const css::uno::Reference< css::lang::XMultiServiceFactory > & _xFactory
106  ,css::uno::Reference< css::drawing::XShape >& _xShape);
107 
109  // css::lang::XServiceInfo
110  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
111  virtual OUString SAL_CALL getImplementationName( ) override;
112  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
113 
115  static css::uno::Sequence< OUString > getSupportedServiceNames_Static();
117  static OUString getImplementationName_Static();
118  static css::uno::Reference< css::uno::XInterface >
119  create(css::uno::Reference< css::uno::XComponentContext > const & xContext);
120  // css::beans::XPropertySet
121  virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
122  virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
123  virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
124  virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
125  virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
126  virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
127  virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
128 
129  // XReportComponent
131  // XShape
132  SHAPE_HEADER()
133 
134  // XShapeDescriptor
135  virtual OUString SAL_CALL getShapeType( ) override;
136 
137  // XReportControlModel
139 
140  // XCloneable
141  virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) override;
142 
143  // XFixedText
144  virtual OUString SAL_CALL getLabel() override;
145  virtual void SAL_CALL setLabel( const OUString& _label ) override;
146 
147  // css::report::XReportControlFormat
149 
150  // XComponent
151  virtual void SAL_CALL dispose() override;
152  virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override
153  {
154  cppu::WeakComponentImplHelperBase::addEventListener(aListener);
155  }
156  virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override
157  {
158  cppu::WeakComponentImplHelperBase::removeEventListener(aListener);
159  }
160 
161  // XChild
162  virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent( ) override;
163  virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override;
164  // XContainer
165  virtual void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
166  virtual void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
167 
168  // XElementAccess
169  virtual css::uno::Type SAL_CALL getElementType( ) override;
170  virtual sal_Bool SAL_CALL hasElements( ) override;
171 
172  // XIndexReplace
173  virtual void SAL_CALL replaceByIndex( ::sal_Int32 Index, const css::uno::Any& Element ) override;
174 
175  // XIndexContainer
176  virtual void SAL_CALL insertByIndex( ::sal_Int32 Index, const css::uno::Any& Element ) override;
177  virtual void SAL_CALL removeByIndex( ::sal_Int32 Index ) override;
178 
179  // XIndexAccess
180  virtual ::sal_Int32 SAL_CALL getCount( ) override;
181  virtual css::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) override;
182  };
183 }
184 #endif // INCLUDED_REPORTDESIGN_SOURCE_CORE_INC_FIXEDTEXT_HXX
185 
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL dispose() override
Definition: FixedText.cxx:84
virtual OUString SAL_CALL getShapeType() override
Definition: FixedText.cxx:311
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: FixedText.hxx:156
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() override
Definition: FixedText.cxx:223
OFixedText & operator=(const OFixedText &)=delete
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: FixedText.cxx:136
virtual ::sal_Int32 SAL_CALL getCount() override
Definition: FixedText.cxx:278
static css::uno::Sequence< OUString > getSupportedServiceNames_Static()
Definition: FixedText.cxx:102
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: FixedText.cxx:131
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: FixedText.cxx:120
implementation of a
Definition: FixedText.hxx:43
virtual css::uno::Type SAL_CALL getElementType() override
Definition: FixedText.cxx:250
void set(const OUString &_sProperty, sal_Int16 Value, css::style::ParagraphAdjust &_member)
Definition: FixedText.hxx:55
::cppu::WeakComponentImplHelper< css::report::XFixedText,css::lang::XServiceInfo > FixedTextBase
Definition: FixedText.hxx:37
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
Definition: FixedText.cxx:202
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: FixedText.hxx:152
mutable::osl::Mutex m_aMutex
#define REPORTCONTROLFORMAT_HEADER()
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: FixedText.cxx:146
virtual void SAL_CALL insertByIndex(::sal_Int32 Index, const css::uno::Any &Element) override
Definition: FixedText.cxx:261
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: FixedText.cxx:161
OReportControlModel m_aProps
Definition: FixedText.hxx:48
virtual void SAL_CALL setLabel(const OUString &_label) override
Definition: FixedText.cxx:217
#define REPORTCOMPONENT_HEADER()
virtual void SAL_CALL removeByIndex(::sal_Int32 Index) override
Definition: FixedText.cxx:266
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: FixedText.cxx:115
static css::uno::Reference< css::uno::XInterface > create(css::uno::Reference< css::uno::XComponentContext > const &xContext)
Definition: FixedText.cxx:109
static OUString getImplementationName_Static()
Definition: FixedText.cxx:91
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: FixedText.cxx:156
virtual void SAL_CALL removeContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
Definition: FixedText.cxx:244
#define SHAPE_HEADER()
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: FixedText.cxx:141
unsigned char sal_Bool
OFixedText(const OFixedText &)=delete
virtual OUString SAL_CALL getLabel() override
Definition: FixedText.cxx:211
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: FixedText.cxx:151
void prepareSet(rtl::OUString const &propertyName, css::uno::Any const &oldValue, css::uno::Any const &newValue, BoundListeners *boundListeners)
virtual ~OFixedText() override
Definition: FixedText.cxx:66
void set(const OUString &_sProperty, const T &Value, T &_member)
Definition: FixedText.hxx:70
virtual css::uno::Any SAL_CALL getByIndex(::sal_Int32 Index) override
Definition: FixedText.cxx:283
virtual void SAL_CALL addContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
Definition: FixedText.cxx:239
virtual OUString SAL_CALL getImplementationName() override
Definition: FixedText.cxx:97
virtual sal_Bool SAL_CALL hasElements() override
Definition: FixedText.cxx:255
virtual void SAL_CALL replaceByIndex(::sal_Int32 Index, const css::uno::Any &Element) override
Definition: FixedText.cxx:272
virtual void SAL_CALL setParent(const css::uno::Reference< css::uno::XInterface > &Parent) override
Definition: FixedText.cxx:228
#define REPORTCONTROLMODEL_HEADER()
void set(const OUString &_sProperty, bool Value, bool &_member)
Definition: FixedText.hxx:85
struct _ADOIndex Index
::cppu::PropertySetMixin< css::report::XFixedText > FixedTextPropertySet
Definition: FixedText.hxx:35
#define DECLARE_XINTERFACE()