LOK: tilebench improvements
[LibreOffice.git] / sc / inc / fielduno.hxx
blobe176ac862de99fd1f0a2fee8c1fa9eb4f2b724ea
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 #ifndef INCLUDED_SC_INC_FIELDUNO_HXX
21 #define INCLUDED_SC_INC_FIELDUNO_HXX
23 #include "address.hxx"
24 #include "mutexhlp.hxx"
26 #include <svl/lstner.hxx>
27 #include <svl/itemprop.hxx>
28 #include <editeng/editdata.hxx>
29 #include <com/sun/star/text/XTextField.hpp>
30 #include <com/sun/star/lang/XServiceInfo.hpp>
31 #include <com/sun/star/container/XContainer.hpp>
32 #include <com/sun/star/lang/XUnoTunnel.hpp>
33 #include <com/sun/star/container/XEnumerationAccess.hpp>
34 #include <com/sun/star/container/XIndexAccess.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/util/XRefreshable.hpp>
37 #include <com/sun/star/util/DateTime.hpp>
38 #include <cppuhelper/component.hxx>
39 #include <cppuhelper/implbase.hxx>
40 #include <comphelper/interfacecontainer2.hxx>
41 #include <osl/mutex.hxx>
43 #include <memory>
45 class ScEditSource;
46 class SvxFieldItem;
47 class SvxFieldData;
48 class ScEditFieldObj;
49 class ScDocShell;
50 class ScHeaderFooterTextData;
52 class ScCellFieldsObj : public cppu::WeakImplHelper<
53 css::container::XEnumerationAccess,
54 css::container::XIndexAccess,
55 css::container::XContainer,
56 css::util::XRefreshable,
57 css::lang::XServiceInfo >,
58 public SfxListener
60 private:
61 css::uno::Reference<css::text::XTextRange> mxContent;
62 ScDocShell* pDocShell;
63 ScAddress aCellPos;
64 ScEditSource* mpEditSource;
65 /// List of refresh listeners.
66 comphelper::OInterfaceContainerHelper2* mpRefreshListeners;
67 /// mutex to lock the InterfaceContainerHelper
68 osl::Mutex aMutex;
70 css::uno::Reference<css::text::XTextField>
71 GetObjectByIndex_Impl(sal_Int32 Index) const;
73 public:
74 ScCellFieldsObj(
75 const css::uno::Reference<css::text::XTextRange>& xContent,
76 ScDocShell* pDocSh, const ScAddress& rPos);
77 virtual ~ScCellFieldsObj() override;
79 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
81 // XIndexAccess
82 virtual sal_Int32 SAL_CALL getCount() override;
83 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
85 // XEnumerationAccess
86 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
87 createEnumeration() override;
89 // XElementAccess
90 virtual css::uno::Type SAL_CALL getElementType() override;
91 virtual sal_Bool SAL_CALL hasElements() override;
93 // XContainer
94 virtual void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
95 virtual void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
97 // XRefreshable
98 virtual void SAL_CALL refresh( ) override;
99 virtual void SAL_CALL addRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l ) override;
100 virtual void SAL_CALL removeRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l ) override;
102 // XServiceInfo
103 virtual OUString SAL_CALL getImplementationName() override;
104 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
105 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
108 class ScHeaderFieldsObj : public cppu::WeakImplHelper<
109 css::container::XEnumerationAccess,
110 css::container::XIndexAccess,
111 css::container::XContainer,
112 css::util::XRefreshable,
113 css::lang::XServiceInfo >
115 private:
116 ScHeaderFooterTextData& mrData;
117 ScEditSource* mpEditSource;
119 /// List of refresh listeners.
120 comphelper::OInterfaceContainerHelper2* mpRefreshListeners;
121 /// mutex to lock the InterfaceContainerHelper
122 osl::Mutex aMutex;
124 css::uno::Reference< css::text::XTextField>
125 GetObjectByIndex_Impl(sal_Int32 Index) const;
127 public:
128 ScHeaderFieldsObj(ScHeaderFooterTextData& rData);
129 virtual ~ScHeaderFieldsObj() override;
131 // XIndexAccess
132 virtual sal_Int32 SAL_CALL getCount() override;
133 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
135 // XEnumerationAccess
136 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
137 createEnumeration() override;
139 // XElementAccess
140 virtual css::uno::Type SAL_CALL getElementType() override;
141 virtual sal_Bool SAL_CALL hasElements() override;
143 // XContainer
144 virtual void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
145 virtual void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
147 // XRefreshable
148 virtual void SAL_CALL refresh( ) override;
149 virtual void SAL_CALL addRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l ) override;
150 virtual void SAL_CALL removeRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l ) override;
152 // XServiceInfo
153 virtual OUString SAL_CALL getImplementationName() override;
154 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
155 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
159 * Generic UNO wrapper for edit engine's field item in cells, headers, and
160 * footers.
162 class ScEditFieldObj : public cppu::WeakImplHelper<
163 css::text::XTextField,
164 css::beans::XPropertySet,
165 css::lang::XUnoTunnel,
166 css::lang::XServiceInfo>,
167 public ScMutexHelper,
168 public ::cppu::OComponentHelper
170 ScEditFieldObj() = delete;
171 ScEditFieldObj(const ScEditFieldObj&) = delete;
172 const ScEditFieldObj& operator=(const ScEditFieldObj&) = delete;
174 const SfxItemPropertySet* pPropSet;
175 std::unique_ptr<ScEditSource> mpEditSource;
176 ESelection aSelection;
178 sal_Int32 meType;
179 std::unique_ptr<SvxFieldData> mpData;
180 css::uno::Reference<css::text::XTextRange> mpContent;
182 css::util::DateTime maDateTime;
183 sal_Int32 mnNumFormat;
184 bool mbIsDate:1;
185 bool mbIsFixed:1;
187 private:
188 SvxFieldData* getData();
190 void setPropertyValueURL(const OUString& rName, const css::uno::Any& rVal);
191 css::uno::Any getPropertyValueURL(const OUString& rName);
193 void setPropertyValueFile(const OUString& rName, const css::uno::Any& rVal);
194 css::uno::Any getPropertyValueFile(const OUString& rName);
196 void setPropertyValueDateTime(const OUString& rName, const css::uno::Any& rVal);
197 css::uno::Any getPropertyValueDateTime(const OUString& rName);
199 void setPropertyValueSheet(const OUString& rName, const css::uno::Any& rVal);
201 public:
202 static const css::uno::Sequence<sal_Int8>& getUnoTunnelId();
203 static ScEditFieldObj* getImplementation(const css::uno::Reference<css::text::XTextContent>& xObj);
205 ScEditFieldObj(
206 const css::uno::Reference<css::text::XTextRange>& rContent,
207 ScEditSource* pEditSrc, sal_Int32 eType, const ESelection& rSel);
208 virtual ~ScEditFieldObj() override;
210 sal_Int32 GetFieldType() const { return meType;}
211 void DeleteField();
212 bool IsInserted() const;
213 SvxFieldItem CreateFieldItem();
214 void InitDoc(
215 const css::uno::Reference<css::text::XTextRange>& rContent,
216 ScEditSource* pEditSrc, const ESelection& rSel);
218 // XTextField
219 virtual OUString SAL_CALL getPresentation( sal_Bool bShowCommand ) override;
221 // XTextContent
222 virtual void SAL_CALL attach( const css::uno::Reference< css::text::XTextRange >& xTextRange ) override;
223 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
224 getAnchor() override;
226 // XComponent
227 virtual void SAL_CALL dispose() override;
228 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
229 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
231 // XPropertySet
232 virtual css::uno::Reference< css::beans::XPropertySetInfo >
233 SAL_CALL getPropertySetInfo() override;
234 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
235 const css::uno::Any& aValue ) override;
236 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
237 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
238 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
239 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
240 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
241 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
242 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
243 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
244 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
246 // XUnoTunnel
247 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
249 // XServiceInfo
250 virtual OUString SAL_CALL getImplementationName() override;
251 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
252 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
254 // XTypeProvider
255 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
256 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
259 #endif
261 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */