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 
117  // css::beans::XPropertySet
118  virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
119  virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
120  virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
121  virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
122  virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
123  virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
124  virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
125 
126  // XContainer
127  virtual void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
128  virtual void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
129 
130  // XElementAccess
131  virtual css::uno::Type SAL_CALL getElementType( ) override;
132  virtual sal_Bool SAL_CALL hasElements( ) override;
133 
134  // XIndexReplace
135  virtual void SAL_CALL replaceByIndex( ::sal_Int32 Index, const css::uno::Any& Element ) override;
136 
137  // XIndexContainer
138  virtual void SAL_CALL insertByIndex( ::sal_Int32 Index, const css::uno::Any& Element ) override;
139  virtual void SAL_CALL removeByIndex( ::sal_Int32 Index ) override;
140 
141  // XIndexAccess
142  virtual ::sal_Int32 SAL_CALL getCount( ) override;
143  virtual css::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) override;
144 
145  // XReportComponent
147 
148  // XShape
149  SHAPE_HEADER()
150 
151  // XShapeDescriptor
152  virtual OUString SAL_CALL getShapeType( ) override;
153 
154  // XReportControlModel
156 
157  // XReportControlFormat
159 
160  // XCloneable
161  virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) override;
162 
163  // XFormattedField
164  virtual ::sal_Int32 SAL_CALL getFormatKey() override;
165  virtual void SAL_CALL setFormatKey(::sal_Int32 the_value) override;
166  virtual css::uno::Reference< css::util::XNumberFormatsSupplier > SAL_CALL getFormatsSupplier() override;
167  virtual void SAL_CALL setFormatsSupplier( const css::uno::Reference< css::util::XNumberFormatsSupplier >& _formatssupplier ) override;
168 
169  // XComponent
170  virtual void SAL_CALL dispose() override;
171  virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override
172  {
173  cppu::WeakComponentImplHelperBase::addEventListener(aListener);
174  }
175  virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override
176  {
177  cppu::WeakComponentImplHelperBase::removeEventListener(aListener);
178  }
179 
180  // XChild
181  virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent( ) override;
182  virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override;
183  };
184 }
185 #endif // INCLUDED_REPORTDESIGN_SOURCE_CORE_INC_FORMATTEDFIELD_HXX
186 
187 /* 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()
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
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