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"
24 #include <svl/lstner.hxx>
25 #include <editeng/editdata.hxx>
26 #include <com/sun/star/text/XTextField.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/container/XContainer.hpp>
29 #include <com/sun/star/container/XEnumerationAccess.hpp>
30 #include <com/sun/star/container/XIndexAccess.hpp>
31 #include <com/sun/star/beans/XPropertySet.hpp>
32 #include <com/sun/star/util/XRefreshable.hpp>
33 #include <com/sun/star/util/DateTime.hpp>
34 #include <comphelper/interfacecontainer4.hxx>
35 #include <comphelper/servicehelper.hxx>
36 #include <cppuhelper/implbase.hxx>
37 #include <comphelper/compbase.hxx>
38 #include <osl/mutex.hxx>
46 class ScHeaderFooterTextData
;
47 class SfxItemPropertySet
;
49 class ScCellFieldsObj final
: public cppu::WeakImplHelper
<
50 css::container::XEnumerationAccess
,
51 css::container::XIndexAccess
,
52 css::container::XContainer
,
53 css::util::XRefreshable
,
54 css::lang::XServiceInfo
>,
58 css::uno::Reference
<css::text::XTextRange
> mxContent
;
59 ScDocShell
* pDocShell
;
61 std::unique_ptr
<ScEditSource
> mpEditSource
;
62 /// List of refresh listeners.
63 comphelper::OInterfaceContainerHelper4
<css::util::XRefreshListener
> maRefreshListeners
;
64 /// mutex to lock the InterfaceContainerHelper
67 css::uno::Reference
<css::text::XTextField
>
68 GetObjectByIndex_Impl(sal_Int32 Index
) const;
72 css::uno::Reference
<css::text::XTextRange
> xContent
,
73 ScDocShell
* pDocSh
, const ScAddress
& rPos
);
74 virtual ~ScCellFieldsObj() override
;
76 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
79 virtual sal_Int32 SAL_CALL
getCount() override
;
80 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
83 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
84 createEnumeration() override
;
87 virtual css::uno::Type SAL_CALL
getElementType() override
;
88 virtual sal_Bool SAL_CALL
hasElements() override
;
91 virtual void SAL_CALL
addContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
) override
;
92 virtual void SAL_CALL
removeContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
) override
;
95 virtual void SAL_CALL
refresh( ) override
;
96 virtual void SAL_CALL
addRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
97 virtual void SAL_CALL
removeRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
100 virtual OUString SAL_CALL
getImplementationName() override
;
101 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
102 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
105 class ScHeaderFieldsObj final
: public cppu::WeakImplHelper
<
106 css::container::XEnumerationAccess
,
107 css::container::XIndexAccess
,
108 css::container::XContainer
,
109 css::util::XRefreshable
,
110 css::lang::XServiceInfo
>
113 ScHeaderFooterTextData
& mrData
;
114 std::unique_ptr
<ScEditSource
> mpEditSource
;
116 /// List of refresh listeners.
117 comphelper::OInterfaceContainerHelper4
<css::util::XRefreshListener
> maRefreshListeners
;
118 /// mutex to lock the InterfaceContainerHelper
121 css::uno::Reference
< css::text::XTextField
>
122 GetObjectByIndex_Impl(sal_Int32 Index
) const;
125 ScHeaderFieldsObj(ScHeaderFooterTextData
& rData
);
126 virtual ~ScHeaderFieldsObj() override
;
129 virtual sal_Int32 SAL_CALL
getCount() override
;
130 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
132 // XEnumerationAccess
133 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
134 createEnumeration() override
;
137 virtual css::uno::Type SAL_CALL
getElementType() override
;
138 virtual sal_Bool SAL_CALL
hasElements() override
;
141 virtual void SAL_CALL
addContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
) override
;
142 virtual void SAL_CALL
removeContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
) override
;
145 virtual void SAL_CALL
refresh( ) override
;
146 virtual void SAL_CALL
addRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
147 virtual void SAL_CALL
removeRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
150 virtual OUString SAL_CALL
getImplementationName() override
;
151 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
152 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
156 * Generic UNO wrapper for edit engine's field item in cells, headers, and
159 typedef comphelper::WeakComponentImplHelper
<
160 css::text::XTextField
,
161 css::beans::XPropertySet
,
162 css::lang::XServiceInfo
> ScEditFieldObj_Base
;
163 class ScEditFieldObj final
: public ScEditFieldObj_Base
165 ScEditFieldObj() = delete;
166 ScEditFieldObj(const ScEditFieldObj
&) = delete;
167 const ScEditFieldObj
& operator=(const ScEditFieldObj
&) = delete;
169 const SfxItemPropertySet
* pPropSet
;
170 std::unique_ptr
<ScEditSource
> mpEditSource
;
171 ESelection aSelection
;
174 std::unique_ptr
<SvxFieldData
> mpData
;
175 css::uno::Reference
<css::text::XTextRange
> mpContent
;
177 css::util::DateTime maDateTime
;
178 sal_Int32 mnNumFormat
;
183 SvxFieldData
& getData();
185 void setPropertyValueURL(const OUString
& rName
, const css::uno::Any
& rVal
);
186 css::uno::Any
getPropertyValueURL(const OUString
& rName
);
188 void setPropertyValueFile(const OUString
& rName
, const css::uno::Any
& rVal
);
189 css::uno::Any
getPropertyValueFile(const OUString
& rName
);
191 void setPropertyValueDateTime(const OUString
& rName
, const css::uno::Any
& rVal
);
192 css::uno::Any
getPropertyValueDateTime(const OUString
& rName
);
194 void setPropertyValueSheet(const OUString
& rName
, const css::uno::Any
& rVal
);
198 css::uno::Reference
<css::text::XTextRange
> xContent
,
199 std::unique_ptr
<ScEditSource
> pEditSrc
, sal_Int32 eType
, const ESelection
& rSel
);
200 virtual ~ScEditFieldObj() override
;
202 sal_Int32
GetFieldType() const { return meType
;}
204 bool IsInserted() const;
205 SvxFieldItem
CreateFieldItem();
207 const css::uno::Reference
<css::text::XTextRange
>& rContent
,
208 std::unique_ptr
<ScEditSource
> pEditSrc
, const ESelection
& rSel
);
211 virtual OUString SAL_CALL
getPresentation( sal_Bool bShowCommand
) override
;
214 virtual void SAL_CALL
attach( const css::uno::Reference
< css::text::XTextRange
>& xTextRange
) override
;
215 virtual css::uno::Reference
< css::text::XTextRange
> SAL_CALL
216 getAnchor() override
;
219 virtual css::uno::Reference
< css::beans::XPropertySetInfo
>
220 SAL_CALL
getPropertySetInfo() override
;
221 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
222 const css::uno::Any
& aValue
) override
;
223 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
224 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
225 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
226 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
227 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
228 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
229 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
230 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
231 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
234 virtual OUString SAL_CALL
getImplementationName() override
;
235 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
236 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
239 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes() override
;
240 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
243 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */