LibreOffice Module sc (master) 1
fielduno.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include "address.hxx"
23
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>
39#include <osl/mutex.hxx>
40
41#include <memory>
42
43class ScEditSource;
44class SvxFieldItem;
45class SvxFieldData;
46class ScDocShell;
49
50class 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 >,
56 public SfxListener
57{
58private:
59 css::uno::Reference<css::text::XTextRange> mxContent;
62 std::unique_ptr<ScEditSource> mpEditSource;
64 std::unique_ptr<comphelper::OInterfaceContainerHelper3<css::util::XRefreshListener>> mpRefreshListeners;
66 osl::Mutex aMutex;
67
68 css::uno::Reference<css::text::XTextField>
69 GetObjectByIndex_Impl(sal_Int32 Index) const;
70
71public:
73 const css::uno::Reference<css::text::XTextRange>& xContent,
74 ScDocShell* pDocSh, const ScAddress& rPos);
75 virtual ~ScCellFieldsObj() override;
76
77 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
78
79 // XIndexAccess
80 virtual sal_Int32 SAL_CALL getCount() override;
81 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
82
83 // XEnumerationAccess
84 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
85 createEnumeration() override;
86
87 // XElementAccess
88 virtual css::uno::Type SAL_CALL getElementType() override;
89 virtual sal_Bool SAL_CALL hasElements() override;
90
91 // XContainer
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;
94
95 // XRefreshable
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;
99
100 // XServiceInfo
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;
104};
105
106class 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 >
112{
113private:
115 std::unique_ptr<ScEditSource> mpEditSource;
116
118 std::unique_ptr<comphelper::OInterfaceContainerHelper3<css::util::XRefreshListener>> mpRefreshListeners;
120 osl::Mutex aMutex;
121
122 css::uno::Reference< css::text::XTextField>
123 GetObjectByIndex_Impl(sal_Int32 Index) const;
124
125public:
127 virtual ~ScHeaderFieldsObj() override;
128
129 // XIndexAccess
130 virtual sal_Int32 SAL_CALL getCount() override;
131 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
132
133 // XEnumerationAccess
134 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
135 createEnumeration() override;
136
137 // XElementAccess
138 virtual css::uno::Type SAL_CALL getElementType() override;
139 virtual sal_Bool SAL_CALL hasElements() override;
140
141 // XContainer
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;
144
145 // XRefreshable
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;
149
150 // XServiceInfo
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;
154};
155
161 css::text::XTextField,
162 css::beans::XPropertySet,
163 css::lang::XUnoTunnel,
164 css::lang::XServiceInfo> ScEditFieldObj_Base;
166{
167 ScEditFieldObj() = delete;
169 const ScEditFieldObj& operator=(const ScEditFieldObj&) = delete;
170
172 std::unique_ptr<ScEditSource> mpEditSource;
174
175 sal_Int32 meType;
176 std::unique_ptr<SvxFieldData> mpData;
177 css::uno::Reference<css::text::XTextRange> mpContent;
178
179 css::util::DateTime maDateTime;
180 sal_Int32 mnNumFormat;
181 bool mbIsDate:1;
182 bool mbIsFixed:1;
183
184private:
186
187 void setPropertyValueURL(const OUString& rName, const css::uno::Any& rVal);
188 css::uno::Any getPropertyValueURL(const OUString& rName);
189
190 void setPropertyValueFile(const OUString& rName, const css::uno::Any& rVal);
191 css::uno::Any getPropertyValueFile(const OUString& rName);
192
193 void setPropertyValueDateTime(const OUString& rName, const css::uno::Any& rVal);
194 css::uno::Any getPropertyValueDateTime(const OUString& rName);
195
196 void setPropertyValueSheet(const OUString& rName, const css::uno::Any& rVal);
197
198public:
200 const css::uno::Reference<css::text::XTextRange>& rContent,
201 std::unique_ptr<ScEditSource> pEditSrc, sal_Int32 eType, const ESelection& rSel);
202 virtual ~ScEditFieldObj() override;
203
204 sal_Int32 GetFieldType() const { return meType;}
205 void DeleteField();
206 bool IsInserted() const;
208 void InitDoc(
209 const css::uno::Reference<css::text::XTextRange>& rContent,
210 std::unique_ptr<ScEditSource> pEditSrc, const ESelection& rSel);
211
212 // XTextField
213 virtual OUString SAL_CALL getPresentation( sal_Bool bShowCommand ) override;
214
215 // XTextContent
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;
219
220 // XPropertySet
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;
234
235 // XUnoTunnel
237
238 // XServiceInfo
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;
242
243 // XTypeProvider
244 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
245 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
246};
247
248/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _ADOIndex Index
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
ScDocShell * pDocShell
Definition: fielduno.hxx:60
virtual void SAL_CALL removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
Definition: fielduno.cxx:413
osl::Mutex aMutex
mutex to lock the InterfaceContainerHelper
Definition: fielduno.hxx:66
virtual ~ScCellFieldsObj() override
Definition: fielduno.cxx:284
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL refresh() override
Definition: fielduno.cxx:391
css::uno::Reference< css::text::XTextField > GetObjectByIndex_Impl(sal_Int32 Index) const
Definition: fielduno.cxx:321
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: fielduno.cxx:372
ScCellFieldsObj(const css::uno::Reference< css::text::XTextRange > &xContent, ScDocShell *pDocSh, const ScAddress &rPos)
Definition: fielduno.cxx:272
std::unique_ptr< comphelper::OInterfaceContainerHelper3< css::util::XRefreshListener > > mpRefreshListeners
List of refresh listeners.
Definition: fielduno.hxx:64
std::unique_ptr< ScEditSource > mpEditSource
Definition: fielduno.hxx:62
virtual void SAL_CALL removeContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
Definition: fielduno.cxx:384
virtual sal_Bool SAL_CALL hasElements() override
Definition: fielduno.cxx:366
virtual void SAL_CALL addRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
Definition: fielduno.cxx:402
ScAddress aCellPos
Definition: fielduno.hxx:61
virtual OUString SAL_CALL getImplementationName() override
css::uno::Reference< css::text::XTextRange > mxContent
Definition: fielduno.hxx:59
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: fielduno.cxx:351
virtual sal_Int32 SAL_CALL getCount() override
Definition: fielduno.cxx:340
virtual css::uno::Type SAL_CALL getElementType() override
Definition: fielduno.cxx:361
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: fielduno.cxx:305
virtual void SAL_CALL addContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
Definition: fielduno.cxx:378
std::unique_ptr< ScEditSource > mpEditSource
Definition: fielduno.hxx:172
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: fielduno.cxx:1176
const SfxItemPropertySet * pPropSet
Definition: fielduno.hxx:171
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: fielduno.cxx:1278
css::uno::Any getPropertyValueDateTime(const OUString &rName)
Definition: fielduno.cxx:892
void InitDoc(const css::uno::Reference< css::text::XTextRange > &rContent, std::unique_ptr< ScEditSource > pEditSrc, const ESelection &rSel)
Definition: fielduno.cxx:1071
SvxFieldData & getData()
Definition: fielduno.cxx:573
sal_Int32 mnNumFormat
Definition: fielduno.hxx:180
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: fielduno.cxx:1168
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: fielduno.cxx:1183
css::uno::Reference< css::text::XTextRange > mpContent
Definition: fielduno.hxx:177
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: fielduno.cxx:1215
css::util::DateTime maDateTime
Definition: fielduno.hxx:179
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
void DeleteField()
Definition: fielduno.cxx:1094
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: fielduno.cxx:1284
std::unique_ptr< SvxFieldData > mpData
Definition: fielduno.hxx:176
ScEditFieldObj()=delete
void setPropertyValueDateTime(const OUString &rName, const css::uno::Any &rVal)
Definition: fielduno.cxx:798
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: fielduno.cxx:1155
const ScEditFieldObj & operator=(const ScEditFieldObj &)=delete
css::uno::Any getPropertyValueURL(const OUString &rName)
Definition: fielduno.cxx:686
virtual OUString SAL_CALL getImplementationName() override
Definition: fielduno.cxx:1268
css::uno::Any getPropertyValueFile(const OUString &rName)
Definition: fielduno.cxx:768
void setPropertyValueSheet(const OUString &rName, const css::uno::Any &rVal)
Definition: fielduno.cxx:997
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override
Definition: fielduno.cxx:1117
sal_Int32 GetFieldType() const
Definition: fielduno.hxx:204
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: fielduno.cxx:1273
void setPropertyValueURL(const OUString &rName, const css::uno::Any &rVal)
Definition: fielduno.cxx:620
SvxFieldItem CreateFieldItem()
Definition: fielduno.cxx:1088
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: fielduno.cxx:1297
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
ScEditFieldObj(const ScEditFieldObj &)=delete
ESelection aSelection
Definition: fielduno.hxx:173
bool IsInserted() const
Definition: fielduno.cxx:1110
ScEditFieldObj(const css::uno::Reference< css::text::XTextRange > &rContent, std::unique_ptr< ScEditSource > pEditSrc, sal_Int32 eType, const ESelection &rSel)
sal_Int32 meType
Definition: fielduno.hxx:175
virtual ~ScEditFieldObj() override
Definition: fielduno.cxx:1084
void setPropertyValueFile(const OUString &rName, const css::uno::Any &rVal)
Definition: fielduno.cxx:735
std::unique_ptr< comphelper::OInterfaceContainerHelper3< css::util::XRefreshListener > > mpRefreshListeners
List of refresh listeners.
Definition: fielduno.hxx:118
virtual css::uno::Type SAL_CALL getElementType() override
Definition: fielduno.cxx:511
virtual void SAL_CALL addContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
Definition: fielduno.cxx:528
virtual sal_Bool SAL_CALL hasElements() override
Definition: fielduno.cxx:516
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: fielduno.cxx:501
ScHeaderFieldsObj(ScHeaderFooterTextData &rData)
Definition: fielduno.cxx:423
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
osl::Mutex aMutex
mutex to lock the InterfaceContainerHelper
Definition: fielduno.hxx:120
ScHeaderFooterTextData & mrData
Definition: fielduno.hxx:114
virtual void SAL_CALL addRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
Definition: fielduno.cxx:552
css::uno::Reference< css::text::XTextField > GetObjectByIndex_Impl(sal_Int32 Index) const
Definition: fielduno.cxx:447
virtual sal_Int32 SAL_CALL getCount() override
Definition: fielduno.cxx:491
virtual void SAL_CALL removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
Definition: fielduno.cxx:563
virtual void SAL_CALL refresh() override
Definition: fielduno.cxx:541
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual ~ScHeaderFieldsObj() override
Definition: fielduno.cxx:429
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: fielduno.cxx:522
std::unique_ptr< ScEditSource > mpEditSource
Definition: fielduno.hxx:115
virtual OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL removeContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
Definition: fielduno.cxx:534
comphelper::WeakComponentImplHelper< css::text::XTextField, css::beans::XPropertySet, css::lang::XUnoTunnel, css::lang::XServiceInfo > ScEditFieldObj_Base
Generic UNO wrapper for edit engine's field item in cells, headers, and footers.
Definition: fielduno.hxx:164
#define UNO3_GETIMPLEMENTATION_DECL(classname)
unsigned char sal_Bool