Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / inc / fielduno.hxx
blobd4d580d0b197ca7a2470497683450437208ab5f7
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 #ifndef SC_FIELDUNO_HXX
21 #define SC_FIELDUNO_HXX
23 #include "address.hxx"
24 #include "mutexhlp.hxx"
26 #include <svl/lstner.hxx>
27 #include <svl/itemprop.hxx>
28 #include <editeng/editdata.hxx>
29 #include <com/sun/star/text/XTextField.hpp>
30 #include <com/sun/star/lang/XServiceInfo.hpp>
31 #include <com/sun/star/container/XContainer.hpp>
32 #include <com/sun/star/lang/XUnoTunnel.hpp>
33 #include <com/sun/star/container/XEnumerationAccess.hpp>
34 #include <com/sun/star/container/XIndexAccess.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/util/XRefreshable.hpp>
37 #include <com/sun/star/util/DateTime.hpp>
38 #include <cppuhelper/component.hxx>
39 #include <cppuhelper/implbase5.hxx>
40 #include <cppuhelper/implbase4.hxx>
41 #include <osl/mutex.hxx>
43 #include <boost/noncopyable.hpp>
44 #include <boost/scoped_ptr.hpp>
46 class ScEditSource;
47 class SvxFieldItem;
48 class SvxFieldData;
49 class ScEditFieldObj;
50 class ScDocShell;
51 class ScHeaderFooterTextData;
53 class ScCellFieldsObj : public cppu::WeakImplHelper5<
54 com::sun::star::container::XEnumerationAccess,
55 com::sun::star::container::XIndexAccess,
56 com::sun::star::container::XContainer,
57 com::sun::star::util::XRefreshable,
58 com::sun::star::lang::XServiceInfo >,
59 public SfxListener
61 private:
62 com::sun::star::uno::Reference<com::sun::star::text::XTextRange> mxContent;
63 ScDocShell* pDocShell;
64 ScAddress aCellPos;
65 ScEditSource* mpEditSource;
66 /// List of refresh listeners.
67 cppu::OInterfaceContainerHelper* mpRefreshListeners;
68 /// mutex to lock the InterfaceContainerHelper
69 osl::Mutex aMutex;
71 com::sun::star::uno::Reference<
72 com::sun::star::text::XTextField>
73 GetObjectByIndex_Impl(sal_Int32 Index) const;
75 public:
76 ScCellFieldsObj(
77 const com::sun::star::uno::Reference<com::sun::star::text::XTextRange>& xContent,
78 ScDocShell* pDocSh, const ScAddress& rPos);
79 virtual ~ScCellFieldsObj();
81 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
83 // XIndexAccess
84 virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
85 virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
86 throw(::com::sun::star::lang::IndexOutOfBoundsException,
87 ::com::sun::star::lang::WrappedTargetException,
88 ::com::sun::star::uno::RuntimeException);
90 // XEnumerationAccess
91 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
92 createEnumeration() throw(::com::sun::star::uno::RuntimeException);
94 // XElementAccess
95 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
96 throw(::com::sun::star::uno::RuntimeException);
97 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
99 // XContainer
100 virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference<
101 ::com::sun::star::container::XContainerListener >& xListener )
102 throw(::com::sun::star::uno::RuntimeException);
103 virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference<
104 ::com::sun::star::container::XContainerListener >& xListener )
105 throw(::com::sun::star::uno::RuntimeException);
107 // XRefreshable
108 virtual void SAL_CALL refresh( )
109 throw (::com::sun::star::uno::RuntimeException);
110 virtual void SAL_CALL addRefreshListener( const ::com::sun::star::uno::Reference<
111 ::com::sun::star::util::XRefreshListener >& l )
112 throw (::com::sun::star::uno::RuntimeException);
113 virtual void SAL_CALL removeRefreshListener( const ::com::sun::star::uno::Reference<
114 ::com::sun::star::util::XRefreshListener >& l )
115 throw (::com::sun::star::uno::RuntimeException);
117 // XServiceInfo
118 virtual OUString SAL_CALL getImplementationName()
119 throw(::com::sun::star::uno::RuntimeException);
120 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
121 throw(::com::sun::star::uno::RuntimeException);
122 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
123 throw(::com::sun::star::uno::RuntimeException);
126 class ScHeaderFieldsObj : public cppu::WeakImplHelper5<
127 com::sun::star::container::XEnumerationAccess,
128 com::sun::star::container::XIndexAccess,
129 com::sun::star::container::XContainer,
130 com::sun::star::util::XRefreshable,
131 com::sun::star::lang::XServiceInfo >
133 private:
134 ScHeaderFooterTextData& mrData;
135 ScEditSource* mpEditSource;
137 /// List of refresh listeners.
138 cppu::OInterfaceContainerHelper* mpRefreshListeners;
139 /// mutex to lock the InterfaceContainerHelper
140 osl::Mutex aMutex;
142 com::sun::star::uno::Reference<
143 com::sun::star::text::XTextField>
144 GetObjectByIndex_Impl(sal_Int32 Index) const;
146 public:
147 ScHeaderFieldsObj(ScHeaderFooterTextData& rData);
148 virtual ~ScHeaderFieldsObj();
150 // XIndexAccess
151 virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
152 virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
153 throw(::com::sun::star::lang::IndexOutOfBoundsException,
154 ::com::sun::star::lang::WrappedTargetException,
155 ::com::sun::star::uno::RuntimeException);
157 // XEnumerationAccess
158 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
159 createEnumeration() throw(::com::sun::star::uno::RuntimeException);
161 // XElementAccess
162 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
163 throw(::com::sun::star::uno::RuntimeException);
164 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
166 // XContainer
167 virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference<
168 ::com::sun::star::container::XContainerListener >& xListener )
169 throw(::com::sun::star::uno::RuntimeException);
170 virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference<
171 ::com::sun::star::container::XContainerListener >& xListener )
172 throw(::com::sun::star::uno::RuntimeException);
174 // XRefreshable
175 virtual void SAL_CALL refresh( )
176 throw (::com::sun::star::uno::RuntimeException);
177 virtual void SAL_CALL addRefreshListener( const ::com::sun::star::uno::Reference<
178 ::com::sun::star::util::XRefreshListener >& l )
179 throw (::com::sun::star::uno::RuntimeException);
180 virtual void SAL_CALL removeRefreshListener( const ::com::sun::star::uno::Reference<
181 ::com::sun::star::util::XRefreshListener >& l )
182 throw (::com::sun::star::uno::RuntimeException);
184 // XServiceInfo
185 virtual OUString SAL_CALL getImplementationName()
186 throw(::com::sun::star::uno::RuntimeException);
187 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
188 throw(::com::sun::star::uno::RuntimeException);
189 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
190 throw(::com::sun::star::uno::RuntimeException);
194 * Generic UNO wrapper for edit engine's field item in cells, headers, and
195 * footers.
197 class ScEditFieldObj : public cppu::WeakImplHelper4<
198 com::sun::star::text::XTextField,
199 com::sun::star::beans::XPropertySet,
200 com::sun::star::lang::XUnoTunnel,
201 com::sun::star::lang::XServiceInfo>,
202 public ScMutexHelper,
203 public ::cppu::OComponentHelper,
204 private boost::noncopyable
206 const SfxItemPropertySet* pPropSet;
207 ScEditSource* mpEditSource;
208 ESelection aSelection;
210 sal_Int32 meType;
211 boost::scoped_ptr<SvxFieldData> mpData;
212 com::sun::star::uno::Reference<com::sun::star::text::XTextRange> mpContent;
214 com::sun::star::util::DateTime maDateTime;
215 sal_Int32 mnNumFormat;
216 bool mbIsDate:1;
217 bool mbIsFixed:1;
219 private:
220 ScEditFieldObj(); // disabled
222 SvxFieldData* getData();
224 void setPropertyValueURL(const OUString& rName, const com::sun::star::uno::Any& rVal);
225 com::sun::star::uno::Any getPropertyValueURL(const OUString& rName);
227 void setPropertyValueFile(const OUString& rName, const com::sun::star::uno::Any& rVal);
228 com::sun::star::uno::Any getPropertyValueFile(const OUString& rName);
230 void setPropertyValueDateTime(const OUString& rName, const com::sun::star::uno::Any& rVal);
231 com::sun::star::uno::Any getPropertyValueDateTime(const OUString& rName);
233 void setPropertyValueSheet(const OUString& rName, const com::sun::star::uno::Any& rVal);
235 public:
236 static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
237 static ScEditFieldObj* getImplementation(const com::sun::star::uno::Reference<com::sun::star::text::XTextContent>& xObj);
239 ScEditFieldObj(
240 const com::sun::star::uno::Reference<com::sun::star::text::XTextRange>& rContent,
241 ScEditSource* pEditSrc, sal_Int32 eType, const ESelection& rSel);
242 virtual ~ScEditFieldObj();
244 sal_Int32 GetFieldType() const;
245 void DeleteField();
246 bool IsInserted() const;
247 SvxFieldItem CreateFieldItem();
248 void InitDoc(
249 const com::sun::star::uno::Reference<com::sun::star::text::XTextRange>& rContent,
250 ScEditSource* pEditSrc, const ESelection& rSel);
252 // XTextField
253 virtual OUString SAL_CALL getPresentation( sal_Bool bShowCommand )
254 throw(::com::sun::star::uno::RuntimeException);
256 // XTextContent
257 virtual void SAL_CALL attach( const ::com::sun::star::uno::Reference<
258 ::com::sun::star::text::XTextRange >& xTextRange )
259 throw(::com::sun::star::lang::IllegalArgumentException,
260 ::com::sun::star::uno::RuntimeException);
261 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
262 getAnchor() throw(::com::sun::star::uno::RuntimeException);
264 // XComponent
265 virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
266 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference<
267 ::com::sun::star::lang::XEventListener >& xListener )
268 throw(::com::sun::star::uno::RuntimeException);
269 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference<
270 ::com::sun::star::lang::XEventListener >& aListener )
271 throw(::com::sun::star::uno::RuntimeException);
273 // XPropertySet
274 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
275 SAL_CALL getPropertySetInfo()
276 throw(::com::sun::star::uno::RuntimeException);
277 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
278 const ::com::sun::star::uno::Any& aValue )
279 throw(::com::sun::star::beans::UnknownPropertyException,
280 ::com::sun::star::beans::PropertyVetoException,
281 ::com::sun::star::lang::IllegalArgumentException,
282 ::com::sun::star::lang::WrappedTargetException,
283 ::com::sun::star::uno::RuntimeException);
284 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
285 const OUString& PropertyName )
286 throw(::com::sun::star::beans::UnknownPropertyException,
287 ::com::sun::star::lang::WrappedTargetException,
288 ::com::sun::star::uno::RuntimeException);
289 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
290 const ::com::sun::star::uno::Reference<
291 ::com::sun::star::beans::XPropertyChangeListener >& xListener )
292 throw(::com::sun::star::beans::UnknownPropertyException,
293 ::com::sun::star::lang::WrappedTargetException,
294 ::com::sun::star::uno::RuntimeException);
295 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
296 const ::com::sun::star::uno::Reference<
297 ::com::sun::star::beans::XPropertyChangeListener >& aListener )
298 throw(::com::sun::star::beans::UnknownPropertyException,
299 ::com::sun::star::lang::WrappedTargetException,
300 ::com::sun::star::uno::RuntimeException);
301 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
302 const ::com::sun::star::uno::Reference<
303 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
304 throw(::com::sun::star::beans::UnknownPropertyException,
305 ::com::sun::star::lang::WrappedTargetException,
306 ::com::sun::star::uno::RuntimeException);
307 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
308 const ::com::sun::star::uno::Reference<
309 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
310 throw(::com::sun::star::beans::UnknownPropertyException,
311 ::com::sun::star::lang::WrappedTargetException,
312 ::com::sun::star::uno::RuntimeException);
314 // XUnoTunnel
315 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
316 sal_Int8 >& aIdentifier )
317 throw(::com::sun::star::uno::RuntimeException);
319 // XServiceInfo
320 virtual OUString SAL_CALL getImplementationName()
321 throw(::com::sun::star::uno::RuntimeException);
322 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
323 throw(::com::sun::star::uno::RuntimeException);
324 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
325 throw(::com::sun::star::uno::RuntimeException);
327 // XTypeProvider
328 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
329 throw(::com::sun::star::uno::RuntimeException);
330 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
331 throw(::com::sun::star::uno::RuntimeException);
334 #endif
336 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */