1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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
>,
61 css::uno::Reference
<css::text::XTextRange
> mxContent
;
62 ScDocShell
* pDocShell
;
64 ScEditSource
* mpEditSource
;
65 /// List of refresh listeners.
66 comphelper::OInterfaceContainerHelper2
* mpRefreshListeners
;
67 /// mutex to lock the InterfaceContainerHelper
70 css::uno::Reference
<css::text::XTextField
>
71 GetObjectByIndex_Impl(sal_Int32 Index
) const;
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
;
82 virtual sal_Int32 SAL_CALL
getCount() throw(css::uno::RuntimeException
, std::exception
) override
;
83 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
)
84 throw(css::lang::IndexOutOfBoundsException
,
85 css::lang::WrappedTargetException
,
86 css::uno::RuntimeException
, std::exception
) override
;
89 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
90 createEnumeration() throw(css::uno::RuntimeException
, std::exception
) override
;
93 virtual css::uno::Type SAL_CALL
getElementType()
94 throw(css::uno::RuntimeException
, std::exception
) override
;
95 virtual sal_Bool SAL_CALL
hasElements() throw(css::uno::RuntimeException
, std::exception
) override
;
98 virtual void SAL_CALL
addContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
)
99 throw(css::uno::RuntimeException
, std::exception
) override
;
100 virtual void SAL_CALL
removeContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
)
101 throw(css::uno::RuntimeException
, std::exception
) override
;
104 virtual void SAL_CALL
refresh( )
105 throw (css::uno::RuntimeException
, std::exception
) override
;
106 virtual void SAL_CALL
addRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
)
107 throw (css::uno::RuntimeException
, std::exception
) override
;
108 virtual void SAL_CALL
removeRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
)
109 throw (css::uno::RuntimeException
, std::exception
) override
;
112 virtual OUString SAL_CALL
getImplementationName()
113 throw(css::uno::RuntimeException
, std::exception
) override
;
114 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
115 throw(css::uno::RuntimeException
, std::exception
) override
;
116 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
117 throw(css::uno::RuntimeException
, std::exception
) override
;
120 class ScHeaderFieldsObj
: public cppu::WeakImplHelper
<
121 css::container::XEnumerationAccess
,
122 css::container::XIndexAccess
,
123 css::container::XContainer
,
124 css::util::XRefreshable
,
125 css::lang::XServiceInfo
>
128 ScHeaderFooterTextData
& mrData
;
129 ScEditSource
* mpEditSource
;
131 /// List of refresh listeners.
132 comphelper::OInterfaceContainerHelper2
* mpRefreshListeners
;
133 /// mutex to lock the InterfaceContainerHelper
136 css::uno::Reference
< css::text::XTextField
>
137 GetObjectByIndex_Impl(sal_Int32 Index
) const;
140 ScHeaderFieldsObj(ScHeaderFooterTextData
& rData
);
141 virtual ~ScHeaderFieldsObj() override
;
144 virtual sal_Int32 SAL_CALL
getCount() throw(css::uno::RuntimeException
, std::exception
) override
;
145 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
)
146 throw(css::lang::IndexOutOfBoundsException
,
147 css::lang::WrappedTargetException
,
148 css::uno::RuntimeException
, std::exception
) override
;
150 // XEnumerationAccess
151 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
152 createEnumeration() throw(css::uno::RuntimeException
, std::exception
) override
;
155 virtual css::uno::Type SAL_CALL
getElementType()
156 throw(css::uno::RuntimeException
, std::exception
) override
;
157 virtual sal_Bool SAL_CALL
hasElements() throw(css::uno::RuntimeException
, std::exception
) override
;
160 virtual void SAL_CALL
addContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
)
161 throw(css::uno::RuntimeException
, std::exception
) override
;
162 virtual void SAL_CALL
removeContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
)
163 throw(css::uno::RuntimeException
, std::exception
) override
;
166 virtual void SAL_CALL
refresh( )
167 throw (css::uno::RuntimeException
, std::exception
) override
;
168 virtual void SAL_CALL
addRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
)
169 throw (css::uno::RuntimeException
, std::exception
) override
;
170 virtual void SAL_CALL
removeRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
)
171 throw (css::uno::RuntimeException
, std::exception
) override
;
174 virtual OUString SAL_CALL
getImplementationName()
175 throw(css::uno::RuntimeException
, std::exception
) override
;
176 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
177 throw(css::uno::RuntimeException
, std::exception
) override
;
178 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
179 throw(css::uno::RuntimeException
, std::exception
) override
;
183 * Generic UNO wrapper for edit engine's field item in cells, headers, and
186 class ScEditFieldObj
: public cppu::WeakImplHelper
<
187 css::text::XTextField
,
188 css::beans::XPropertySet
,
189 css::lang::XUnoTunnel
,
190 css::lang::XServiceInfo
>,
191 public ScMutexHelper
,
192 public ::cppu::OComponentHelper
194 ScEditFieldObj() = delete;
195 ScEditFieldObj(const ScEditFieldObj
&) = delete;
196 const ScEditFieldObj
& operator=(const ScEditFieldObj
&) = delete;
198 const SfxItemPropertySet
* pPropSet
;
199 ScEditSource
* mpEditSource
;
200 ESelection aSelection
;
203 std::unique_ptr
<SvxFieldData
> mpData
;
204 css::uno::Reference
<css::text::XTextRange
> mpContent
;
206 css::util::DateTime maDateTime
;
207 sal_Int32 mnNumFormat
;
212 SvxFieldData
* getData();
214 void setPropertyValueURL(const OUString
& rName
, const css::uno::Any
& rVal
);
215 css::uno::Any
getPropertyValueURL(const OUString
& rName
);
217 void setPropertyValueFile(const OUString
& rName
, const css::uno::Any
& rVal
);
218 css::uno::Any
getPropertyValueFile(const OUString
& rName
);
220 void setPropertyValueDateTime(const OUString
& rName
, const css::uno::Any
& rVal
);
221 css::uno::Any
getPropertyValueDateTime(const OUString
& rName
);
223 void setPropertyValueSheet(const OUString
& rName
, const css::uno::Any
& rVal
);
226 static const css::uno::Sequence
<sal_Int8
>& getUnoTunnelId();
227 static ScEditFieldObj
* getImplementation(const css::uno::Reference
<css::text::XTextContent
>& xObj
);
230 const css::uno::Reference
<css::text::XTextRange
>& rContent
,
231 ScEditSource
* pEditSrc
, sal_Int32 eType
, const ESelection
& rSel
);
232 virtual ~ScEditFieldObj() override
;
234 sal_Int32
GetFieldType() const { return meType
;}
236 bool IsInserted() const;
237 SvxFieldItem
CreateFieldItem();
239 const css::uno::Reference
<css::text::XTextRange
>& rContent
,
240 ScEditSource
* pEditSrc
, const ESelection
& rSel
);
243 virtual OUString SAL_CALL
getPresentation( sal_Bool bShowCommand
)
244 throw(css::uno::RuntimeException
, std::exception
) override
;
247 virtual void SAL_CALL
attach( const css::uno::Reference
< css::text::XTextRange
>& xTextRange
)
248 throw(css::lang::IllegalArgumentException
,
249 css::uno::RuntimeException
, std::exception
) override
;
250 virtual css::uno::Reference
< css::text::XTextRange
> SAL_CALL
251 getAnchor() throw(css::uno::RuntimeException
, std::exception
) override
;
254 virtual void SAL_CALL
dispose() throw(css::uno::RuntimeException
, std::exception
) override
;
255 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
)
256 throw(css::uno::RuntimeException
, std::exception
) override
;
257 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
)
258 throw(css::uno::RuntimeException
, std::exception
) override
;
261 virtual css::uno::Reference
< css::beans::XPropertySetInfo
>
262 SAL_CALL
getPropertySetInfo()
263 throw(css::uno::RuntimeException
, std::exception
) override
;
264 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
265 const css::uno::Any
& aValue
)
266 throw (css::beans::UnknownPropertyException
,
267 css::beans::PropertyVetoException
,
268 css::lang::IllegalArgumentException
,
269 css::lang::WrappedTargetException
,
270 css::uno::RuntimeException
,
271 std::exception
) override
;
272 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
)
273 throw(css::beans::UnknownPropertyException
,
274 css::lang::WrappedTargetException
,
275 css::uno::RuntimeException
, std::exception
) override
;
276 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
277 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
)
278 throw(css::beans::UnknownPropertyException
,
279 css::lang::WrappedTargetException
,
280 css::uno::RuntimeException
, std::exception
) override
;
281 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
282 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
)
283 throw(css::beans::UnknownPropertyException
,
284 css::lang::WrappedTargetException
,
285 css::uno::RuntimeException
, std::exception
) override
;
286 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
287 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
)
288 throw(css::beans::UnknownPropertyException
,
289 css::lang::WrappedTargetException
,
290 css::uno::RuntimeException
, std::exception
) override
;
291 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
292 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
)
293 throw(css::beans::UnknownPropertyException
,
294 css::lang::WrappedTargetException
,
295 css::uno::RuntimeException
, std::exception
) override
;
298 virtual sal_Int64 SAL_CALL
getSomething( const css::uno::Sequence
< sal_Int8
>& aIdentifier
)
299 throw(css::uno::RuntimeException
, std::exception
) override
;
302 virtual OUString SAL_CALL
getImplementationName()
303 throw(css::uno::RuntimeException
, std::exception
) override
;
304 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
305 throw(css::uno::RuntimeException
, std::exception
) override
;
306 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
307 throw(css::uno::RuntimeException
, std::exception
) override
;
310 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes()
311 throw(css::uno::RuntimeException
, std::exception
) override
;
312 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId()
313 throw(css::uno::RuntimeException
, std::exception
) override
;
318 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */