tdf#48459 sw inline heading: don't apply inside frames or over 120 chars
[LibreOffice.git] / sc / inc / fielduno.hxx
blob23b313b96e7c035d5bde968b9440999416b80bae
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #pragma once
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>
38 #include <memory>
40 class ScEditSource;
41 class SvxFieldItem;
42 class SvxFieldData;
43 class ScDocShell;
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 >,
53 public SfxListener
55 private:
56 css::uno::Reference<css::text::XTextRange> mxContent;
57 ScDocShell* pDocShell;
58 ScAddress aCellPos;
59 std::unique_ptr<ScEditSource> mpEditSource;
60 /// List of refresh listeners.
61 comphelper::OInterfaceContainerHelper4<css::util::XRefreshListener> maRefreshListeners;
62 /// mutex to lock the InterfaceContainerHelper
63 std::mutex aMutex;
65 css::uno::Reference<css::text::XTextField>
66 GetObjectByIndex_Impl(sal_Int32 Index) const;
68 public:
69 ScCellFieldsObj(
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;
76 // XIndexAccess
77 virtual sal_Int32 SAL_CALL getCount() override;
78 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
80 // XEnumerationAccess
81 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
82 createEnumeration() override;
84 // XElementAccess
85 virtual css::uno::Type SAL_CALL getElementType() override;
86 virtual sal_Bool SAL_CALL hasElements() override;
88 // XContainer
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;
92 // XRefreshable
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;
97 // XServiceInfo
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 >
110 private:
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
117 std::mutex aMutex;
119 css::uno::Reference< css::text::XTextField>
120 GetObjectByIndex_Impl(sal_Int32 Index) const;
122 public:
123 ScHeaderFieldsObj(ScHeaderFooterTextData& rData);
124 virtual ~ScHeaderFieldsObj() override;
126 // XIndexAccess
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;
134 // XElementAccess
135 virtual css::uno::Type SAL_CALL getElementType() override;
136 virtual sal_Bool SAL_CALL hasElements() override;
138 // XContainer
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;
142 // XRefreshable
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;
147 // XServiceInfo
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
155 * footers.
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;
171 sal_Int32 meType;
172 std::unique_ptr<SvxFieldData> mpData;
173 css::uno::Reference<css::text::XTextRange> mpContent;
175 css::util::DateTime maDateTime;
176 sal_Int32 mnNumFormat;
177 bool mbIsDate:1;
178 bool mbIsFixed:1;
180 private:
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);
194 public:
195 ScEditFieldObj(
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;}
201 void DeleteField();
202 bool IsInserted() const;
203 SvxFieldItem CreateFieldItem();
204 void InitDoc(
205 const css::uno::Reference<css::text::XTextRange>& rContent,
206 std::unique_ptr<ScEditSource> pEditSrc, const ESelection& rSel);
208 // XTextField
209 virtual OUString SAL_CALL getPresentation( sal_Bool bShowCommand ) override;
211 // XTextContent
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;
216 // XPropertySet
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;
231 // XServiceInfo
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;
236 // XTypeProvider
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: */