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