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 .
22 #include "address.hxx"
23 #include "mutexhlp.hxx"
25 #include <svl/lstner.hxx>
26 #include <editeng/editdata.hxx>
27 #include <com/sun/star/text/XTextField.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/container/XContainer.hpp>
30 #include <com/sun/star/lang/XUnoTunnel.hpp>
31 #include <com/sun/star/container/XEnumerationAccess.hpp>
32 #include <com/sun/star/container/XIndexAccess.hpp>
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <com/sun/star/util/XRefreshable.hpp>
35 #include <com/sun/star/util/DateTime.hpp>
36 #include <comphelper/servicehelper.hxx>
37 #include <cppuhelper/component.hxx>
38 #include <cppuhelper/implbase.hxx>
39 #include <cppuhelper/compbase.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
;
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 typedef cppu::WeakComponentImplHelper
<
164 css::text::XTextField
,
165 css::beans::XPropertySet
,
166 css::lang::XUnoTunnel
,
167 css::lang::XServiceInfo
> ScEditFieldObj_Base
;
168 class ScEditFieldObj final
: public ScMutexHelper
, public ScEditFieldObj_Base
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
;
179 std::unique_ptr
<SvxFieldData
> mpData
;
180 css::uno::Reference
<css::text::XTextRange
> mpContent
;
182 css::util::DateTime maDateTime
;
183 sal_Int32 mnNumFormat
;
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
);
203 const css::uno::Reference
<css::text::XTextRange
>& rContent
,
204 std::unique_ptr
<ScEditSource
> pEditSrc
, sal_Int32 eType
, const ESelection
& rSel
);
205 virtual ~ScEditFieldObj() override
;
207 sal_Int32
GetFieldType() const { return meType
;}
209 bool IsInserted() const;
210 SvxFieldItem
CreateFieldItem();
212 const css::uno::Reference
<css::text::XTextRange
>& rContent
,
213 std::unique_ptr
<ScEditSource
> pEditSrc
, const ESelection
& rSel
);
216 virtual OUString SAL_CALL
getPresentation( sal_Bool bShowCommand
) override
;
219 virtual void SAL_CALL
attach( const css::uno::Reference
< css::text::XTextRange
>& xTextRange
) override
;
220 virtual css::uno::Reference
< css::text::XTextRange
> SAL_CALL
221 getAnchor() override
;
224 virtual css::uno::Reference
< css::beans::XPropertySetInfo
>
225 SAL_CALL
getPropertySetInfo() override
;
226 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
227 const css::uno::Any
& aValue
) override
;
228 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
229 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
230 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
231 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
232 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
233 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
234 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
235 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
236 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
239 UNO3_GETIMPLEMENTATION_DECL(ScEditFieldObj
)
242 virtual OUString SAL_CALL
getImplementationName() override
;
243 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
244 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
247 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes() override
;
248 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
251 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */