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 <editeng/editdata.hxx>
28 #include <com/sun/star/text/XTextField.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/container/XContainer.hpp>
31 #include <com/sun/star/lang/XUnoTunnel.hpp>
32 #include <com/sun/star/container/XEnumerationAccess.hpp>
33 #include <com/sun/star/container/XIndexAccess.hpp>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/util/XRefreshable.hpp>
36 #include <com/sun/star/util/DateTime.hpp>
37 #include <comphelper/servicehelper.hxx>
38 #include <cppuhelper/component.hxx>
39 #include <cppuhelper/implbase.hxx>
40 #include <osl/mutex.hxx>
44 namespace comphelper
{ class OInterfaceContainerHelper2
; }
50 class ScHeaderFooterTextData
;
51 class SfxItemPropertySet
;
53 class ScCellFieldsObj final
: public cppu::WeakImplHelper
<
54 css::container::XEnumerationAccess
,
55 css::container::XIndexAccess
,
56 css::container::XContainer
,
57 css::util::XRefreshable
,
58 css::lang::XServiceInfo
>,
62 css::uno::Reference
<css::text::XTextRange
> mxContent
;
63 ScDocShell
* pDocShell
;
64 ScAddress
const aCellPos
;
65 std::unique_ptr
<ScEditSource
> mpEditSource
;
66 /// List of refresh listeners.
67 std::unique_ptr
<comphelper::OInterfaceContainerHelper2
> mpRefreshListeners
;
68 /// mutex to lock the InterfaceContainerHelper
71 css::uno::Reference
<css::text::XTextField
>
72 GetObjectByIndex_Impl(sal_Int32 Index
) const;
76 const css::uno::Reference
<css::text::XTextRange
>& xContent
,
77 ScDocShell
* pDocSh
, const ScAddress
& rPos
);
78 virtual ~ScCellFieldsObj() override
;
80 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
83 virtual sal_Int32 SAL_CALL
getCount() override
;
84 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
87 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
88 createEnumeration() override
;
91 virtual css::uno::Type SAL_CALL
getElementType() override
;
92 virtual sal_Bool SAL_CALL
hasElements() override
;
95 virtual void SAL_CALL
addContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
) override
;
96 virtual void SAL_CALL
removeContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
) override
;
99 virtual void SAL_CALL
refresh( ) override
;
100 virtual void SAL_CALL
addRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
101 virtual void SAL_CALL
removeRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
104 virtual OUString SAL_CALL
getImplementationName() override
;
105 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
106 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
109 class ScHeaderFieldsObj final
: public cppu::WeakImplHelper
<
110 css::container::XEnumerationAccess
,
111 css::container::XIndexAccess
,
112 css::container::XContainer
,
113 css::util::XRefreshable
,
114 css::lang::XServiceInfo
>
117 ScHeaderFooterTextData
& mrData
;
118 std::unique_ptr
<ScEditSource
> mpEditSource
;
120 /// List of refresh listeners.
121 std::unique_ptr
<comphelper::OInterfaceContainerHelper2
> mpRefreshListeners
;
122 /// mutex to lock the InterfaceContainerHelper
125 css::uno::Reference
< css::text::XTextField
>
126 GetObjectByIndex_Impl(sal_Int32 Index
) const;
129 ScHeaderFieldsObj(ScHeaderFooterTextData
& rData
);
130 virtual ~ScHeaderFieldsObj() override
;
133 virtual sal_Int32 SAL_CALL
getCount() override
;
134 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
136 // XEnumerationAccess
137 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
138 createEnumeration() override
;
141 virtual css::uno::Type SAL_CALL
getElementType() override
;
142 virtual sal_Bool SAL_CALL
hasElements() override
;
145 virtual void SAL_CALL
addContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
) override
;
146 virtual void SAL_CALL
removeContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
) override
;
149 virtual void SAL_CALL
refresh( ) override
;
150 virtual void SAL_CALL
addRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
151 virtual void SAL_CALL
removeRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
154 virtual OUString SAL_CALL
getImplementationName() override
;
155 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
156 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
160 * Generic UNO wrapper for edit engine's field item in cells, headers, and
163 class ScEditFieldObj final
: public cppu::WeakImplHelper
<
164 css::text::XTextField
,
165 css::beans::XPropertySet
,
166 css::lang::XUnoTunnel
,
167 css::lang::XServiceInfo
>,
168 public ScMutexHelper
,
169 public ::cppu::OComponentHelper
171 ScEditFieldObj() = delete;
172 ScEditFieldObj(const ScEditFieldObj
&) = delete;
173 const ScEditFieldObj
& operator=(const ScEditFieldObj
&) = delete;
175 const SfxItemPropertySet
* pPropSet
;
176 std::unique_ptr
<ScEditSource
> mpEditSource
;
177 ESelection aSelection
;
179 sal_Int32
const meType
;
180 std::unique_ptr
<SvxFieldData
> mpData
;
181 css::uno::Reference
<css::text::XTextRange
> mpContent
;
183 css::util::DateTime maDateTime
;
184 sal_Int32 mnNumFormat
;
189 SvxFieldData
& getData();
191 void setPropertyValueURL(const OUString
& rName
, const css::uno::Any
& rVal
);
192 css::uno::Any
getPropertyValueURL(const OUString
& rName
);
194 void setPropertyValueFile(const OUString
& rName
, const css::uno::Any
& rVal
);
195 css::uno::Any
getPropertyValueFile(const OUString
& rName
);
197 void setPropertyValueDateTime(const OUString
& rName
, const css::uno::Any
& rVal
);
198 css::uno::Any
getPropertyValueDateTime(const OUString
& rName
);
200 void setPropertyValueSheet(const OUString
& rName
, const css::uno::Any
& rVal
);
204 const css::uno::Reference
<css::text::XTextRange
>& rContent
,
205 std::unique_ptr
<ScEditSource
> pEditSrc
, sal_Int32 eType
, const ESelection
& rSel
);
206 virtual ~ScEditFieldObj() override
;
208 sal_Int32
GetFieldType() const { return meType
;}
210 bool IsInserted() const;
211 SvxFieldItem
CreateFieldItem();
213 const css::uno::Reference
<css::text::XTextRange
>& rContent
,
214 std::unique_ptr
<ScEditSource
> pEditSrc
, const ESelection
& rSel
);
217 virtual OUString SAL_CALL
getPresentation( sal_Bool bShowCommand
) override
;
220 virtual void SAL_CALL
attach( const css::uno::Reference
< css::text::XTextRange
>& xTextRange
) override
;
221 virtual css::uno::Reference
< css::text::XTextRange
> SAL_CALL
222 getAnchor() override
;
225 virtual void SAL_CALL
dispose() override
;
226 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
227 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) override
;
230 virtual css::uno::Reference
< css::beans::XPropertySetInfo
>
231 SAL_CALL
getPropertySetInfo() override
;
232 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
233 const css::uno::Any
& aValue
) override
;
234 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
235 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
236 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
237 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
238 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
239 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
240 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
241 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
242 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
245 UNO3_GETIMPLEMENTATION_DECL(ScEditFieldObj
)
248 virtual OUString SAL_CALL
getImplementationName() override
;
249 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
250 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
253 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes() override
;
254 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
259 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */