Update git submodules
[LibreOffice.git] / sw / source / core / inc / unofield.hxx
blobdabf724138cf9b04b031503724e5849bd24f59e0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <swdllapi.h>
23 #include <com/sun/star/lang/XServiceInfo.hpp>
24 #include <com/sun/star/container/XEnumeration.hpp>
25 #include <com/sun/star/util/XUpdatable.hpp>
26 #include <com/sun/star/text/XDependentTextField.hpp>
28 #include <cppuhelper/implbase.hxx>
30 #include <unobaseclass.hxx>
31 #include <unocoll.hxx>
32 #include <fldbas.hxx>
34 class SwDoc;
35 class SwFormatField;
36 class SwSetExpField;
37 class ProgName;
39 typedef ::cppu::WeakImplHelper
40 < css::beans::XPropertySet
41 , css::lang::XServiceInfo
42 , css::lang::XComponent
43 > SwXFieldMaster_Base;
45 class SW_DLLPUBLIC SwXFieldMaster final
46 : public SwXFieldMaster_Base
49 private:
50 class Impl;
51 ::sw::UnoImplPtr<Impl> m_pImpl;
53 virtual ~SwXFieldMaster() override;
55 SwXFieldMaster(SwFieldType& rType, SwDoc * pDoc);
57 /// descriptor
58 SwXFieldMaster(SwDoc& rDoc, SwFieldIds nResId);
60 public:
62 static rtl::Reference<SwXFieldMaster>
63 CreateXFieldMaster(SwDoc * pDoc, SwFieldType * pType,
64 SwFieldIds nResId = SwFieldIds::Unknown);
66 static ProgName GetProgrammaticName(const SwFieldType& rType, SwDoc& rDoc);
67 static OUString LocalizeFormula(const SwSetExpField& rField, const OUString& rFormula, bool bQuery);
69 SwFieldType* GetFieldType(bool bDontCreate = false) const;
71 // XServiceInfo
72 virtual OUString SAL_CALL getImplementationName() override;
73 virtual sal_Bool SAL_CALL supportsService(
74 const OUString& rServiceName) override;
75 virtual css::uno::Sequence< OUString > SAL_CALL
76 getSupportedServiceNames() override;
78 // XComponent
79 virtual void SAL_CALL dispose() override;
80 virtual void SAL_CALL addEventListener(
81 const css::uno::Reference< css::lang::XEventListener > & xListener) override;
82 virtual void SAL_CALL removeEventListener(
83 const css::uno::Reference< css::lang::XEventListener > & xListener) override;
85 // XPropertySet
86 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
87 getPropertySetInfo() override;
88 virtual void SAL_CALL setPropertyValue(
89 const OUString& rPropertyName,
90 const css::uno::Any& rValue) override;
91 virtual css::uno::Any SAL_CALL getPropertyValue(
92 const OUString& rPropertyName) override;
93 virtual void SAL_CALL addPropertyChangeListener(
94 const OUString& rPropertyName,
95 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
96 virtual void SAL_CALL removePropertyChangeListener(
97 const OUString& rPropertyName,
98 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
99 virtual void SAL_CALL addVetoableChangeListener(
100 const OUString& rPropertyName,
101 const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
102 virtual void SAL_CALL removeVetoableChangeListener(
103 const OUString& rPropertyName,
104 const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
108 typedef ::cppu::WeakImplHelper
109 < css::text::XDependentTextField
110 , css::lang::XServiceInfo
111 , css::beans::XPropertySet
112 , css::util::XUpdatable
113 > SwXTextField_Base;
116 * UNO wrapper around an SwFormatField, i.e. a Writer field that the user creates via Insert ->
117 * Field.
119 class SW_DLLPUBLIC SwXTextField final
120 : public SwXTextField_Base
123 private:
124 class Impl;
125 ::sw::UnoImplPtr<Impl> m_pImpl;
127 virtual ~SwXTextField() override;
129 SwXTextField(SwFormatField& rFormat, SwDoc & rDoc);
131 /// descriptor
132 SwXTextField(SwServiceType nServiceId, SwDoc* pDoc);
134 public:
135 SwServiceType GetServiceId() const;
137 static void TransmuteLeadToInputField(SwSetExpField & rField, sal_uInt16 const*const pSubType);
139 /// @return an SwXTextField, either an already existing one or a new one
140 static rtl::Reference<SwXTextField>
141 CreateXTextField(SwDoc * pDoc, SwFormatField const* pFormat,
142 SwServiceType nServiceId = SwServiceType::Invalid);
144 // XServiceInfo
145 virtual OUString SAL_CALL getImplementationName() override;
146 virtual sal_Bool SAL_CALL supportsService(
147 const OUString& rServiceName) override;
148 virtual css::uno::Sequence< OUString > SAL_CALL
149 getSupportedServiceNames() override;
151 // XComponent
152 virtual void SAL_CALL dispose() override;
153 virtual void SAL_CALL addEventListener(
154 const css::uno::Reference< css::lang::XEventListener > & xListener) override;
155 virtual void SAL_CALL removeEventListener(
156 const css::uno::Reference< css::lang::XEventListener > & xListener) override;
158 // XPropertySet
159 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
160 getPropertySetInfo() override;
161 virtual void SAL_CALL setPropertyValue(
162 const OUString& rPropertyName,
163 const css::uno::Any& rValue) override;
164 virtual css::uno::Any SAL_CALL getPropertyValue(
165 const OUString& rPropertyName) override;
166 virtual void SAL_CALL addPropertyChangeListener(
167 const OUString& rPropertyName,
168 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
169 virtual void SAL_CALL removePropertyChangeListener(
170 const OUString& rPropertyName,
171 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
172 virtual void SAL_CALL addVetoableChangeListener(
173 const OUString& rPropertyName,
174 const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
175 virtual void SAL_CALL removeVetoableChangeListener(
176 const OUString& rPropertyName,
177 const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
179 // XUpdatable
180 virtual void SAL_CALL update() override;
182 // XTextContent
183 virtual void SAL_CALL attach(
184 const css::uno::Reference< css::text::XTextRange > & xTextRange) override;
185 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override;
187 // XTextField
188 virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override;
190 // XDependentTextField
191 virtual void SAL_CALL attachTextFieldMaster(
192 const css::uno::Reference< css::beans::XPropertySet > & xFieldMaster) override;
193 virtual css::uno::Reference< css::beans::XPropertySet> SAL_CALL getTextFieldMaster() override;
195 void OnFormatFieldDelete();
199 typedef ::cppu::WeakImplHelper
200 < css::container::XEnumeration
201 , css::lang::XServiceInfo
202 > SwXFieldEnumeration_Base;
204 class SwXFieldEnumeration final
205 : public SwXFieldEnumeration_Base
208 private:
209 class Impl;
210 ::sw::UnoImplPtr<Impl> m_pImpl;
212 virtual ~SwXFieldEnumeration() override;
214 public:
215 explicit SwXFieldEnumeration(SwDoc & rDoc);
217 // XServiceInfo
218 virtual OUString SAL_CALL getImplementationName() override;
219 virtual sal_Bool SAL_CALL supportsService(
220 const OUString& rServiceName) override;
221 virtual css::uno::Sequence< OUString > SAL_CALL
222 getSupportedServiceNames() override;
224 // XEnumeration
225 virtual sal_Bool SAL_CALL hasMoreElements() override;
226 virtual css::uno::Any SAL_CALL nextElement() override;
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */