LibreOffice Module sw (master)  1
unofield.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_SW_SOURCE_CORE_INC_UNOFIELD_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_UNOFIELD_HXX
22 
23 #include <com/sun/star/lang/XUnoTunnel.hpp>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/container/XEnumeration.hpp>
26 #include <com/sun/star/util/XUpdatable.hpp>
27 #include <com/sun/star/text/XDependentTextField.hpp>
28 
29 #include <cppuhelper/implbase.hxx>
30 
31 #include <unobaseclass.hxx>
32 #include <unocoll.hxx>
33 #include <fldbas.hxx>
34 
35 class SwDoc;
36 class SwFormatField;
38 
39 typedef ::cppu::WeakImplHelper
40 < css::beans::XPropertySet
41 , css::lang::XServiceInfo
42 , css::lang::XUnoTunnel
43 , css::lang::XComponent
45 
46 class SwXFieldMaster final
47  : public SwXFieldMaster_Base
48 {
49 
50 private:
51  class Impl;
53 
54  virtual ~SwXFieldMaster() override;
55 
56  SwXFieldMaster(SwFieldType& rType, SwDoc * pDoc);
57 
59  SwXFieldMaster(SwDoc* pDoc, SwFieldIds nResId);
60 
61 public:
62 
63  static css::uno::Reference<css::beans::XPropertySet>
64  CreateXFieldMaster(SwDoc * pDoc, SwFieldType * pType,
66 
67  static OUString GetProgrammaticName(const SwFieldType& rType, SwDoc& rDoc);
68  static OUString LocalizeFormula(const SwSetExpField& rField, const OUString& rFormula, bool bQuery);
69 
70  SwFieldType* GetFieldType(bool bDontCreate = false) const;
71 
72  static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
73 
74  // XUnoTunnel
75  virtual sal_Int64 SAL_CALL getSomething(
76  const css::uno::Sequence< sal_Int8 >& rIdentifier) override;
77 
78  // XServiceInfo
79  virtual OUString SAL_CALL getImplementationName() override;
80  virtual sal_Bool SAL_CALL supportsService(
81  const OUString& rServiceName) override;
82  virtual css::uno::Sequence< OUString > SAL_CALL
83  getSupportedServiceNames() override;
84 
85  // XComponent
86  virtual void SAL_CALL dispose() override;
87  virtual void SAL_CALL addEventListener(
88  const css::uno::Reference< css::lang::XEventListener > & xListener) override;
89  virtual void SAL_CALL removeEventListener(
90  const css::uno::Reference< css::lang::XEventListener > & xListener) override;
91 
92  // XPropertySet
93  virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
94  getPropertySetInfo() override;
95  virtual void SAL_CALL setPropertyValue(
96  const OUString& rPropertyName,
97  const css::uno::Any& rValue) override;
98  virtual css::uno::Any SAL_CALL getPropertyValue(
99  const OUString& rPropertyName) override;
100  virtual void SAL_CALL addPropertyChangeListener(
101  const OUString& rPropertyName,
102  const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
103  virtual void SAL_CALL removePropertyChangeListener(
104  const OUString& rPropertyName,
105  const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
106  virtual void SAL_CALL addVetoableChangeListener(
107  const OUString& rPropertyName,
108  const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
109  virtual void SAL_CALL removeVetoableChangeListener(
110  const OUString& rPropertyName,
111  const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
112 
113 };
114 
115 typedef ::cppu::WeakImplHelper
116 < css::text::XDependentTextField
117 , css::lang::XServiceInfo
118 , css::beans::XPropertySet
119 , css::lang::XUnoTunnel
120 , css::util::XUpdatable
122 
127 class SwXTextField final
128  : public SwXTextField_Base
129 {
130 
131 private:
132  class Impl;
134 
135  virtual ~SwXTextField() override;
136 
137  SwXTextField(SwFormatField& rFormat, SwDoc & rDoc);
138 
140  SwXTextField(SwServiceType nServiceId, SwDoc* pDoc);
141 
142 public:
143  SwServiceType GetServiceId() const;
144 
145  static void TransmuteLeadToInputField(SwSetExpField & rField);
146 
148  static css::uno::Reference< css::text::XTextField>
149  CreateXTextField(SwDoc * pDoc, SwFormatField const* pFormat,
151 
152  static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
153 
154  // XUnoTunnel
155  virtual sal_Int64 SAL_CALL getSomething(
156  const css::uno::Sequence< sal_Int8 >& rIdentifier) override;
157 
158  // XServiceInfo
159  virtual OUString SAL_CALL getImplementationName() override;
160  virtual sal_Bool SAL_CALL supportsService(
161  const OUString& rServiceName) override;
162  virtual css::uno::Sequence< OUString > SAL_CALL
163  getSupportedServiceNames() override;
164 
165  // XComponent
166  virtual void SAL_CALL dispose() override;
167  virtual void SAL_CALL addEventListener(
168  const css::uno::Reference< css::lang::XEventListener > & xListener) override;
169  virtual void SAL_CALL removeEventListener(
170  const css::uno::Reference< css::lang::XEventListener > & xListener) override;
171 
172  // XPropertySet
173  virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
174  getPropertySetInfo() override;
175  virtual void SAL_CALL setPropertyValue(
176  const OUString& rPropertyName,
177  const css::uno::Any& rValue) override;
178  virtual css::uno::Any SAL_CALL getPropertyValue(
179  const OUString& rPropertyName) override;
180  virtual void SAL_CALL addPropertyChangeListener(
181  const OUString& rPropertyName,
182  const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
183  virtual void SAL_CALL removePropertyChangeListener(
184  const OUString& rPropertyName,
185  const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
186  virtual void SAL_CALL addVetoableChangeListener(
187  const OUString& rPropertyName,
188  const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
189  virtual void SAL_CALL removeVetoableChangeListener(
190  const OUString& rPropertyName,
191  const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
192 
193  // XUpdatable
194  virtual void SAL_CALL update() override;
195 
196  // XTextContent
197  virtual void SAL_CALL attach(
198  const css::uno::Reference< css::text::XTextRange > & xTextRange) override;
199  virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override;
200 
201  // XTextField
202  virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override;
203 
204  // XDependentTextField
205  virtual void SAL_CALL attachTextFieldMaster(
206  const css::uno::Reference< css::beans::XPropertySet > & xFieldMaster) override;
207  virtual css::uno::Reference< css::beans::XPropertySet> SAL_CALL getTextFieldMaster() override;
208 
209 };
210 
211 typedef ::cppu::WeakImplHelper
212 < css::container::XEnumeration
213 , css::lang::XServiceInfo
215 
217  : public SwXFieldEnumeration_Base
218 {
219 
220 private:
221  class Impl;
223 
224  virtual ~SwXFieldEnumeration() override;
225 
226 public:
227  explicit SwXFieldEnumeration(SwDoc & rDoc);
228 
229  // XServiceInfo
230  virtual OUString SAL_CALL getImplementationName() override;
231  virtual sal_Bool SAL_CALL supportsService(
232  const OUString& rServiceName) override;
233  virtual css::uno::Sequence< OUString > SAL_CALL
234  getSupportedServiceNames() override;
235 
236  // XEnumeration
237  virtual sal_Bool SAL_CALL hasMoreElements() override;
238  virtual css::uno::Any SAL_CALL nextElement() override;
239 
240 };
241 
242 #endif
243 
244 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:241
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unofield.cxx:2117
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unofield.cxx:936
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unofield.cxx:571
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unofield.hxx:132
::cppu::WeakImplHelper< css::container::XEnumeration, css::lang::XServiceInfo > SwXFieldEnumeration_Base
Definition: unofield.hxx:214
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unofield.cxx:2125
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unofield.cxx:2952
SwServiceType GetServiceId() const
Definition: unofield.cxx:1243
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unofield.cxx:802
static OUString LocalizeFormula(const SwSetExpField &rField, const OUString &rFormula, bool bQuery)
Definition: unofield.cxx:1017
virtual void SAL_CALL dispose() override
Definition: unofield.cxx:946
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
Definition: unofield.cxx:467
Definition: doc.hxx:187
virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override
Definition: unofield.cxx:1333
static css::uno::Reference< css::text::XTextField > CreateXTextField(SwDoc *pDoc, SwFormatField const *pFormat, SwServiceType nServiceId=SwServiceType::Invalid)
Definition: unofield.cxx:1216
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unofield.cxx:562
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unofield.cxx:2496
virtual ~SwXFieldEnumeration() override
Definition: unofield.cxx:2988
static void TransmuteLeadToInputField(SwSetExpField &rField)
Convert between SwSetExpField with InputFlag false and InputFlag true.
Definition: unofield.cxx:1260
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unofield.cxx:2481
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unofield.cxx:2580
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unofield.cxx:2299
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unofield.cxx:941
SwXFieldEnumeration(SwDoc &rDoc)
Definition: unofield.cxx:2957
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unofield.hxx:51
virtual void SAL_CALL dispose() override
Definition: unofield.cxx:2091
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unofield.cxx:2486
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unofield.cxx:1171
virtual OUString SAL_CALL getImplementationName() override
Definition: unofield.cxx:2556
::cppu::WeakImplHelper< css::beans::XPropertySet, css::lang::XServiceInfo, css::lang::XUnoTunnel, css::lang::XComponent > SwXFieldMaster_Base
Definition: unofield.hxx:37
std::unique_ptr< T, UnoImplPtrDeleter< T > > UnoImplPtr
Smart pointer class ensuring that the pointed object is deleted with a locked SolarMutex.
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unofield.hxx:221
virtual OUString SAL_CALL getImplementationName() override
Definition: unofield.cxx:2941
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unofield.cxx:2491
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
Definition: unofield.cxx:1178
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unofield.cxx:2146
SwFieldIds
Definition: fldbas.hxx:45
virtual sal_Bool SAL_CALL hasMoreElements() override
Definition: unofield.cxx:2992
unsigned char sal_Bool
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unofield.cxx:926
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unofield.cxx:460
SwXFieldMaster(SwFieldType &rType, SwDoc *pDoc)
Definition: unofield.cxx:526
virtual ~SwXFieldMaster() override
Definition: unofield.cxx:531
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unofield.cxx:2054
SwFieldType * GetFieldType(bool bDontCreate=false) const
Definition: unofield.cxx:776
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unofield.cxx:1345
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unofield.cxx:516
SwXTextField(SwFormatField &rFormat, SwDoc &rDoc)
Definition: unofield.cxx:1206
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unofield.cxx:976
::cppu::WeakImplHelper< css::text::XDependentTextField, css::lang::XServiceInfo, css::beans::XPropertySet, css::lang::XUnoTunnel, css::util::XUpdatable > SwXTextField_Base
Definition: unofield.hxx:121
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unofield.cxx:2946
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unofield.cxx:931
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unofield.cxx:969
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unofield.cxx:510
virtual OUString SAL_CALL getImplementationName() override
Definition: unofield.cxx:473
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unofield.cxx:2110
UNO wrapper around an SwFormatField, i.e.
Definition: unofield.hxx:127
virtual ~SwXTextField() override
Definition: unofield.cxx:1211
virtual void SAL_CALL attachTextFieldMaster(const css::uno::Reference< css::beans::XPropertySet > &xFieldMaster) override
Definition: unofield.cxx:1300
virtual css::uno::Any SAL_CALL nextElement() override
Definition: unofield.cxx:2999
static OUString GetProgrammaticName(const SwFieldType &rType, SwDoc &rDoc)
Definition: unofield.cxx:1000
virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getTextFieldMaster() override
Definition: unofield.cxx:1323
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unofield.cxx:2575
SwServiceType
entries in this enum are mapped in an array in unocoll.cxx
Definition: unocoll.hxx:63
virtual void SAL_CALL update() override
Definition: unofield.cxx:2501
static css::uno::Reference< css::beans::XPropertySet > CreateXFieldMaster(SwDoc *pDoc, SwFieldType *pType, SwFieldIds nResId=SwFieldIds::Unknown)
Definition: unofield.cxx:536