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 <cppuhelper/implbase.hxx>
36 #include <comphelper/compbase.hxx>
44 class ScHeaderFooterTextData
;
45 class SfxItemPropertySet
;
47 class ScCellFieldsObj final
: public cppu::WeakImplHelper
<
48 css::container::XEnumerationAccess
,
49 css::container::XIndexAccess
,
50 css::container::XContainer
,
51 css::util::XRefreshable
,
52 css::lang::XServiceInfo
>,
56 css::uno::Reference
<css::text::XTextRange
> mxContent
;
57 ScDocShell
* pDocShell
;
59 std::unique_ptr
<ScEditSource
> mpEditSource
;
60 /// List of refresh listeners.
61 comphelper::OInterfaceContainerHelper4
<css::util::XRefreshListener
> maRefreshListeners
;
62 /// mutex to lock the InterfaceContainerHelper
65 css::uno::Reference
<css::text::XTextField
>
66 GetObjectByIndex_Impl(sal_Int32 Index
) const;
70 css::uno::Reference
<css::text::XTextRange
> xContent
,
71 ScDocShell
* pDocSh
, const ScAddress
& rPos
);
72 virtual ~ScCellFieldsObj() override
;
74 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
77 virtual sal_Int32 SAL_CALL
getCount() override
;
78 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
81 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
82 createEnumeration() override
;
85 virtual css::uno::Type SAL_CALL
getElementType() override
;
86 virtual sal_Bool SAL_CALL
hasElements() override
;
89 virtual void SAL_CALL
addContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
) override
;
90 virtual void SAL_CALL
removeContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
) override
;
93 virtual void SAL_CALL
refresh( ) override
;
94 virtual void SAL_CALL
addRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
95 virtual void SAL_CALL
removeRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
98 virtual OUString SAL_CALL
getImplementationName() override
;
99 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
100 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
103 class ScHeaderFieldsObj final
: public cppu::WeakImplHelper
<
104 css::container::XEnumerationAccess
,
105 css::container::XIndexAccess
,
106 css::container::XContainer
,
107 css::util::XRefreshable
,
108 css::lang::XServiceInfo
>
111 ScHeaderFooterTextData
& mrData
;
112 std::unique_ptr
<ScEditSource
> mpEditSource
;
114 /// List of refresh listeners.
115 comphelper::OInterfaceContainerHelper4
<css::util::XRefreshListener
> maRefreshListeners
;
116 /// mutex to lock the InterfaceContainerHelper
119 css::uno::Reference
< css::text::XTextField
>
120 GetObjectByIndex_Impl(sal_Int32 Index
) const;
123 ScHeaderFieldsObj(ScHeaderFooterTextData
& rData
);
124 virtual ~ScHeaderFieldsObj() override
;
127 virtual sal_Int32 SAL_CALL
getCount() override
;
128 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
130 // XEnumerationAccess
131 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
132 createEnumeration() override
;
135 virtual css::uno::Type SAL_CALL
getElementType() override
;
136 virtual sal_Bool SAL_CALL
hasElements() override
;
139 virtual void SAL_CALL
addContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
) override
;
140 virtual void SAL_CALL
removeContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
) override
;
143 virtual void SAL_CALL
refresh( ) override
;
144 virtual void SAL_CALL
addRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
145 virtual void SAL_CALL
removeRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
148 virtual OUString SAL_CALL
getImplementationName() override
;
149 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
150 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
154 * Generic UNO wrapper for edit engine's field item in cells, headers, and
157 typedef comphelper::WeakComponentImplHelper
<
158 css::text::XTextField
,
159 css::beans::XPropertySet
,
160 css::lang::XServiceInfo
> ScEditFieldObj_Base
;
161 class ScEditFieldObj final
: public ScEditFieldObj_Base
163 ScEditFieldObj() = delete;
164 ScEditFieldObj(const ScEditFieldObj
&) = delete;
165 const ScEditFieldObj
& operator=(const ScEditFieldObj
&) = delete;
167 const SfxItemPropertySet
* pPropSet
;
168 std::unique_ptr
<ScEditSource
> mpEditSource
;
169 ESelection aSelection
;
172 std::unique_ptr
<SvxFieldData
> mpData
;
173 css::uno::Reference
<css::text::XTextRange
> mpContent
;
175 css::util::DateTime maDateTime
;
176 sal_Int32 mnNumFormat
;
181 SvxFieldData
& getData();
183 void setPropertyValueURL(const OUString
& rName
, const css::uno::Any
& rVal
);
184 css::uno::Any
getPropertyValueURL(const OUString
& rName
);
186 void setPropertyValueFile(const OUString
& rName
, const css::uno::Any
& rVal
);
187 css::uno::Any
getPropertyValueFile(const OUString
& rName
);
189 void setPropertyValueDateTime(const OUString
& rName
, const css::uno::Any
& rVal
);
190 css::uno::Any
getPropertyValueDateTime(const OUString
& rName
);
192 void setPropertyValueSheet(const OUString
& rName
, const css::uno::Any
& rVal
);
196 css::uno::Reference
<css::text::XTextRange
> xContent
,
197 std::unique_ptr
<ScEditSource
> pEditSrc
, sal_Int32 eType
, const ESelection
& rSel
);
198 virtual ~ScEditFieldObj() override
;
200 sal_Int32
GetFieldType() const { return meType
;}
202 bool IsInserted() const;
203 SvxFieldItem
CreateFieldItem();
205 const css::uno::Reference
<css::text::XTextRange
>& rContent
,
206 std::unique_ptr
<ScEditSource
> pEditSrc
, const ESelection
& rSel
);
209 virtual OUString SAL_CALL
getPresentation( sal_Bool bShowCommand
) override
;
212 virtual void SAL_CALL
attach( const css::uno::Reference
< css::text::XTextRange
>& xTextRange
) override
;
213 virtual css::uno::Reference
< css::text::XTextRange
> SAL_CALL
214 getAnchor() override
;
217 virtual css::uno::Reference
< css::beans::XPropertySetInfo
>
218 SAL_CALL
getPropertySetInfo() override
;
219 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
220 const css::uno::Any
& aValue
) override
;
221 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
222 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
223 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
224 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
225 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
226 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
227 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
228 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
229 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
232 virtual OUString SAL_CALL
getImplementationName() override
;
233 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
234 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
237 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes() override
;
238 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
241 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */