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/lang/XUnoTunnel.hpp>
30 #include <com/sun/star/container/XEnumerationAccess.hpp>
31 #include <com/sun/star/container/XIndexAccess.hpp>
32 #include <com/sun/star/beans/XPropertySet.hpp>
33 #include <com/sun/star/util/XRefreshable.hpp>
34 #include <com/sun/star/util/DateTime.hpp>
35 #include <comphelper/interfacecontainer3.hxx>
36 #include <comphelper/servicehelper.hxx>
37 #include <cppuhelper/implbase.hxx>
38 #include <comphelper/compbase.hxx>
39 #include <osl/mutex.hxx>
47 class ScHeaderFooterTextData
;
48 class SfxItemPropertySet
;
50 class ScCellFieldsObj final
: public cppu::WeakImplHelper
<
51 css::container::XEnumerationAccess
,
52 css::container::XIndexAccess
,
53 css::container::XContainer
,
54 css::util::XRefreshable
,
55 css::lang::XServiceInfo
>,
59 css::uno::Reference
<css::text::XTextRange
> mxContent
;
60 ScDocShell
* pDocShell
;
62 std::unique_ptr
<ScEditSource
> mpEditSource
;
63 /// List of refresh listeners.
64 std::unique_ptr
<comphelper::OInterfaceContainerHelper3
<css::util::XRefreshListener
>> mpRefreshListeners
;
65 /// mutex to lock the InterfaceContainerHelper
68 css::uno::Reference
<css::text::XTextField
>
69 GetObjectByIndex_Impl(sal_Int32 Index
) const;
73 css::uno::Reference
<css::text::XTextRange
> xContent
,
74 ScDocShell
* pDocSh
, const ScAddress
& rPos
);
75 virtual ~ScCellFieldsObj() override
;
77 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
80 virtual sal_Int32 SAL_CALL
getCount() override
;
81 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
84 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
85 createEnumeration() override
;
88 virtual css::uno::Type SAL_CALL
getElementType() override
;
89 virtual sal_Bool SAL_CALL
hasElements() override
;
92 virtual void SAL_CALL
addContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
) override
;
93 virtual void SAL_CALL
removeContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
) override
;
96 virtual void SAL_CALL
refresh( ) override
;
97 virtual void SAL_CALL
addRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
98 virtual void SAL_CALL
removeRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
101 virtual OUString SAL_CALL
getImplementationName() override
;
102 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
103 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
106 class ScHeaderFieldsObj final
: public cppu::WeakImplHelper
<
107 css::container::XEnumerationAccess
,
108 css::container::XIndexAccess
,
109 css::container::XContainer
,
110 css::util::XRefreshable
,
111 css::lang::XServiceInfo
>
114 ScHeaderFooterTextData
& mrData
;
115 std::unique_ptr
<ScEditSource
> mpEditSource
;
117 /// List of refresh listeners.
118 std::unique_ptr
<comphelper::OInterfaceContainerHelper3
<css::util::XRefreshListener
>> mpRefreshListeners
;
119 /// mutex to lock the InterfaceContainerHelper
122 css::uno::Reference
< css::text::XTextField
>
123 GetObjectByIndex_Impl(sal_Int32 Index
) const;
126 ScHeaderFieldsObj(ScHeaderFooterTextData
& rData
);
127 virtual ~ScHeaderFieldsObj() override
;
130 virtual sal_Int32 SAL_CALL
getCount() override
;
131 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
133 // XEnumerationAccess
134 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
135 createEnumeration() override
;
138 virtual css::uno::Type SAL_CALL
getElementType() override
;
139 virtual sal_Bool SAL_CALL
hasElements() override
;
142 virtual void SAL_CALL
addContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
) override
;
143 virtual void SAL_CALL
removeContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
) override
;
146 virtual void SAL_CALL
refresh( ) override
;
147 virtual void SAL_CALL
addRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
148 virtual void SAL_CALL
removeRefreshListener( const css::uno::Reference
< css::util::XRefreshListener
>& l
) override
;
151 virtual OUString SAL_CALL
getImplementationName() override
;
152 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
153 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
157 * Generic UNO wrapper for edit engine's field item in cells, headers, and
160 typedef comphelper::WeakComponentImplHelper
<
161 css::text::XTextField
,
162 css::beans::XPropertySet
,
163 css::lang::XUnoTunnel
,
164 css::lang::XServiceInfo
> ScEditFieldObj_Base
;
165 class ScEditFieldObj final
: public ScEditFieldObj_Base
167 ScEditFieldObj() = delete;
168 ScEditFieldObj(const ScEditFieldObj
&) = delete;
169 const ScEditFieldObj
& operator=(const ScEditFieldObj
&) = delete;
171 const SfxItemPropertySet
* pPropSet
;
172 std::unique_ptr
<ScEditSource
> mpEditSource
;
173 ESelection aSelection
;
176 std::unique_ptr
<SvxFieldData
> mpData
;
177 css::uno::Reference
<css::text::XTextRange
> mpContent
;
179 css::util::DateTime maDateTime
;
180 sal_Int32 mnNumFormat
;
185 SvxFieldData
& getData();
187 void setPropertyValueURL(const OUString
& rName
, const css::uno::Any
& rVal
);
188 css::uno::Any
getPropertyValueURL(const OUString
& rName
);
190 void setPropertyValueFile(const OUString
& rName
, const css::uno::Any
& rVal
);
191 css::uno::Any
getPropertyValueFile(const OUString
& rName
);
193 void setPropertyValueDateTime(const OUString
& rName
, const css::uno::Any
& rVal
);
194 css::uno::Any
getPropertyValueDateTime(const OUString
& rName
);
196 void setPropertyValueSheet(const OUString
& rName
, const css::uno::Any
& rVal
);
200 css::uno::Reference
<css::text::XTextRange
> xContent
,
201 std::unique_ptr
<ScEditSource
> pEditSrc
, sal_Int32 eType
, const ESelection
& rSel
);
202 virtual ~ScEditFieldObj() override
;
204 sal_Int32
GetFieldType() const { return meType
;}
206 bool IsInserted() const;
207 SvxFieldItem
CreateFieldItem();
209 const css::uno::Reference
<css::text::XTextRange
>& rContent
,
210 std::unique_ptr
<ScEditSource
> pEditSrc
, const ESelection
& rSel
);
213 virtual OUString SAL_CALL
getPresentation( sal_Bool bShowCommand
) override
;
216 virtual void SAL_CALL
attach( const css::uno::Reference
< css::text::XTextRange
>& xTextRange
) override
;
217 virtual css::uno::Reference
< css::text::XTextRange
> SAL_CALL
218 getAnchor() override
;
221 virtual css::uno::Reference
< css::beans::XPropertySetInfo
>
222 SAL_CALL
getPropertySetInfo() override
;
223 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
224 const css::uno::Any
& aValue
) override
;
225 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
226 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
227 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
228 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
229 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
230 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
231 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
232 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
233 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
236 UNO3_GETIMPLEMENTATION_DECL(ScEditFieldObj
)
239 virtual OUString SAL_CALL
getImplementationName() override
;
240 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
241 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
244 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes() override
;
245 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
248 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */