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/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>
38#include <osl/mutex.hxx>
39
40#include <memory>
41
42class ScEditSource;
43class SvxFieldItem;
44class SvxFieldData;
45class ScDocShell;
48
49class 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 >,
55 public SfxListener
56{
57private:
58 css::uno::Reference<css::text::XTextRange> mxContent;
61 std::unique_ptr<ScEditSource> mpEditSource;
65 std::mutex aMutex;
66
67 css::uno::Reference<css::text::XTextField>
68 GetObjectByIndex_Impl(sal_Int32 Index) const;
69
70public:
72 css::uno::Reference<css::text::XTextRange> xContent,
73 ScDocShell* pDocSh, const ScAddress& rPos);
74 virtual ~ScCellFieldsObj() override;
75
76 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
77
78 // XIndexAccess
79 virtual sal_Int32 SAL_CALL getCount() override;
80 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
81
82 // XEnumerationAccess
83 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
84 createEnumeration() override;
85
86 // XElementAccess
87 virtual css::uno::Type SAL_CALL getElementType() override;
88 virtual sal_Bool SAL_CALL hasElements() override;
89
90 // XContainer
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;
93
94 // XRefreshable
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;
98
99 // XServiceInfo
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;
103};
104
105class 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 >
111{
112private:
114 std::unique_ptr<ScEditSource> mpEditSource;
115
119 std::mutex aMutex;
120
121 css::uno::Reference< css::text::XTextField>
122 GetObjectByIndex_Impl(sal_Int32 Index) const;
123
124public:
126 virtual ~ScHeaderFieldsObj() override;
127
128 // XIndexAccess
129 virtual sal_Int32 SAL_CALL getCount() override;
130 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
131
132 // XEnumerationAccess
133 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
134 createEnumeration() override;
135
136 // XElementAccess
137 virtual css::uno::Type SAL_CALL getElementType() override;
138 virtual sal_Bool SAL_CALL hasElements() override;
139
140 // XContainer
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;
143
144 // XRefreshable
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;
148
149 // XServiceInfo
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;
153};
154
160 css::text::XTextField,
161 css::beans::XPropertySet,
162 css::lang::XServiceInfo> ScEditFieldObj_Base;
164{
165 ScEditFieldObj() = delete;
167 const ScEditFieldObj& operator=(const ScEditFieldObj&) = delete;
168
170 std::unique_ptr<ScEditSource> mpEditSource;
172
173 sal_Int32 meType;
174 std::unique_ptr<SvxFieldData> mpData;
175 css::uno::Reference<css::text::XTextRange> mpContent;
176
177 css::util::DateTime maDateTime;
178 sal_Int32 mnNumFormat;
179 bool mbIsDate:1;
180 bool mbIsFixed:1;
181
182private:
184
185 void setPropertyValueURL(const OUString& rName, const css::uno::Any& rVal);
186 css::uno::Any getPropertyValueURL(const OUString& rName);
187
188 void setPropertyValueFile(const OUString& rName, const css::uno::Any& rVal);
189 css::uno::Any getPropertyValueFile(const OUString& rName);
190
191 void setPropertyValueDateTime(const OUString& rName, const css::uno::Any& rVal);
192 css::uno::Any getPropertyValueDateTime(const OUString& rName);
193
194 void setPropertyValueSheet(const OUString& rName, const css::uno::Any& rVal);
195
196public:
198 css::uno::Reference<css::text::XTextRange> xContent,
199 std::unique_ptr<ScEditSource> pEditSrc, sal_Int32 eType, const ESelection& rSel);
200 virtual ~ScEditFieldObj() override;
201
202 sal_Int32 GetFieldType() const { return meType;}
203 void DeleteField();
204 bool IsInserted() const;
206 void InitDoc(
207 const css::uno::Reference<css::text::XTextRange>& rContent,
208 std::unique_ptr<ScEditSource> pEditSrc, const ESelection& rSel);
209
210 // XTextField
211 virtual OUString SAL_CALL getPresentation( sal_Bool bShowCommand ) override;
212
213 // XTextContent
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;
217
218 // XPropertySet
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;
232
233 // XServiceInfo
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;
237
238 // XTypeProvider
239 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
240 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
241};
242
243/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _ADOIndex Index
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
ScDocShell * pDocShell
Definition: fielduno.hxx:59
virtual void SAL_CALL removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
Definition: fielduno.cxx:407
virtual ~ScCellFieldsObj() override
Definition: fielduno.cxx:277
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL refresh() override
Definition: fielduno.cxx:386
css::uno::Reference< css::text::XTextField > GetObjectByIndex_Impl(sal_Int32 Index) const
Definition: fielduno.cxx:316
comphelper::OInterfaceContainerHelper4< css::util::XRefreshListener > maRefreshListeners
List of refresh listeners.
Definition: fielduno.hxx:63
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: fielduno.cxx:367
std::unique_ptr< ScEditSource > mpEditSource
Definition: fielduno.hxx:61
virtual void SAL_CALL removeContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
Definition: fielduno.cxx:379
ScCellFieldsObj(css::uno::Reference< css::text::XTextRange > xContent, ScDocShell *pDocSh, const ScAddress &rPos)
Definition: fielduno.cxx:265
virtual sal_Bool SAL_CALL hasElements() override
Definition: fielduno.cxx:361
virtual void SAL_CALL addRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
Definition: fielduno.cxx:398
ScAddress aCellPos
Definition: fielduno.hxx:60
virtual OUString SAL_CALL getImplementationName() override
css::uno::Reference< css::text::XTextRange > mxContent
Definition: fielduno.hxx:58
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: fielduno.cxx:346
virtual sal_Int32 SAL_CALL getCount() override
Definition: fielduno.cxx:335
virtual css::uno::Type SAL_CALL getElementType() override
Definition: fielduno.cxx:356
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: fielduno.cxx:300
virtual void SAL_CALL addContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
Definition: fielduno.cxx:373
std::mutex aMutex
mutex to lock the InterfaceContainerHelper
Definition: fielduno.hxx:65
std::unique_ptr< ScEditSource > mpEditSource
Definition: fielduno.hxx:170
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: fielduno.cxx:1167
const SfxItemPropertySet * pPropSet
Definition: fielduno.hxx:169
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: fielduno.cxx:1265
css::uno::Any getPropertyValueDateTime(const OUString &rName)
Definition: fielduno.cxx:883
void InitDoc(const css::uno::Reference< css::text::XTextRange > &rContent, std::unique_ptr< ScEditSource > pEditSrc, const ESelection &rSel)
Definition: fielduno.cxx:1062
SvxFieldData & getData()
Definition: fielduno.cxx:564
sal_Int32 mnNumFormat
Definition: fielduno.hxx:178
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: fielduno.cxx:1159
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: fielduno.cxx:1174
css::uno::Reference< css::text::XTextRange > mpContent
Definition: fielduno.hxx:175
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: fielduno.cxx:1206
css::util::DateTime maDateTime
Definition: fielduno.hxx:177
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
void DeleteField()
Definition: fielduno.cxx:1085
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: fielduno.cxx:1271
std::unique_ptr< SvxFieldData > mpData
Definition: fielduno.hxx:174
ScEditFieldObj()=delete
void setPropertyValueDateTime(const OUString &rName, const css::uno::Any &rVal)
Definition: fielduno.cxx:789
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: fielduno.cxx:1146
const ScEditFieldObj & operator=(const ScEditFieldObj &)=delete
css::uno::Any getPropertyValueURL(const OUString &rName)
Definition: fielduno.cxx:677
virtual OUString SAL_CALL getImplementationName() override
Definition: fielduno.cxx:1255
css::uno::Any getPropertyValueFile(const OUString &rName)
Definition: fielduno.cxx:759
void setPropertyValueSheet(const OUString &rName, const css::uno::Any &rVal)
Definition: fielduno.cxx:988
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:1108
sal_Int32 GetFieldType() const
Definition: fielduno.hxx:202
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: fielduno.cxx:1260
void setPropertyValueURL(const OUString &rName, const css::uno::Any &rVal)
Definition: fielduno.cxx:611
SvxFieldItem CreateFieldItem()
Definition: fielduno.cxx:1079
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: fielduno.cxx:1284
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
ScEditFieldObj(css::uno::Reference< css::text::XTextRange > xContent, std::unique_ptr< ScEditSource > pEditSrc, sal_Int32 eType, const ESelection &rSel)
ScEditFieldObj(const ScEditFieldObj &)=delete
ESelection aSelection
Definition: fielduno.hxx:171
bool IsInserted() const
Definition: fielduno.cxx:1101
sal_Int32 meType
Definition: fielduno.hxx:173
virtual ~ScEditFieldObj() override
Definition: fielduno.cxx:1075
void setPropertyValueFile(const OUString &rName, const css::uno::Any &rVal)
Definition: fielduno.cxx:726
virtual css::uno::Type SAL_CALL getElementType() override
Definition: fielduno.cxx:504
std::mutex aMutex
mutex to lock the InterfaceContainerHelper
Definition: fielduno.hxx:119
virtual void SAL_CALL addContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
Definition: fielduno.cxx:521
virtual sal_Bool SAL_CALL hasElements() override
Definition: fielduno.cxx:509
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: fielduno.cxx:494
ScHeaderFieldsObj(ScHeaderFooterTextData &rData)
Definition: fielduno.cxx:416
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
ScHeaderFooterTextData & mrData
Definition: fielduno.hxx:113
virtual void SAL_CALL addRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
Definition: fielduno.cxx:546
css::uno::Reference< css::text::XTextField > GetObjectByIndex_Impl(sal_Int32 Index) const
Definition: fielduno.cxx:440
virtual sal_Int32 SAL_CALL getCount() override
Definition: fielduno.cxx:484
virtual void SAL_CALL removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
Definition: fielduno.cxx:555
virtual void SAL_CALL refresh() override
Definition: fielduno.cxx:534
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual ~ScHeaderFieldsObj() override
Definition: fielduno.cxx:422
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: fielduno.cxx:515
std::unique_ptr< ScEditSource > mpEditSource
Definition: fielduno.hxx:114
comphelper::OInterfaceContainerHelper4< css::util::XRefreshListener > maRefreshListeners
List of refresh listeners.
Definition: fielduno.hxx:117
virtual OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL removeContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
Definition: fielduno.cxx:527
comphelper::WeakComponentImplHelper< css::text::XTextField, css::beans::XPropertySet, css::lang::XServiceInfo > ScEditFieldObj_Base
Generic UNO wrapper for edit engine's field item in cells, headers, and footers.
Definition: fielduno.hxx:162
unsigned char sal_Bool