merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / inc / unometa.hxx
blob1dc1985f7dfefb94b6beb242a8025a0d067ba850
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unometa.hxx,v $
10 * $Revision: 1.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SW_UNOMETA_HXX
32 #define SW_UNOMETA_HXX
34 #include "calbck.hxx"
36 #include <sfx2/Metadatable.hxx>
37 #include <cppuhelper/implbase2.hxx>
38 #include <cppuhelper/implbase5.hxx>
40 #include <com/sun/star/lang/XServiceInfo.hpp>
41 #include <com/sun/star/lang/XUnoTunnel.hpp>
42 #include <com/sun/star/container/XEnumerationAccess.hpp>
43 #include <com/sun/star/text/XTextContent.hpp>
44 #include <com/sun/star/text/XTextField.hpp>
46 #include <deque>
49 typedef ::std::deque<
50 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > >
51 TextRangeList_t;
53 class SwXTextRange;
54 class SwPaM;
55 class SwTxtMeta;
56 namespace sw {
57 class Meta;
58 class MetaField;
61 typedef
62 ::cppu::ImplInheritanceHelper5
63 < ::sfx2::MetadatableMixin
64 , ::com::sun::star::lang::XUnoTunnel
65 , ::com::sun::star::lang::XServiceInfo
66 , ::com::sun::star::text::XTextContent
67 , ::com::sun::star::text::XText
68 , ::com::sun::star::container::XEnumerationAccess
69 > SwXMetaBaseClass;
71 class SwXMeta
72 : public SwXMetaBaseClass
73 , public SwClient
74 , private ::boost::noncopyable
76 private:
77 struct Impl;
78 ::std::auto_ptr<Impl> m_pImpl;
80 protected:
81 virtual ~SwXMeta();
83 public:
84 SwXMeta(SwDoc *const pDoc,
85 ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> const&
86 xParentText,
87 TextRangeList_t * const pPortions, SwTxtMeta * const pHint);
88 SwXMeta(SwDoc *const pDoc);
90 TYPEINFO();
92 static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
94 // XUnoTunnel
95 virtual sal_Int64 SAL_CALL getSomething(
96 const ::com::sun::star::uno::Sequence< sal_Int8 >& Identifier )
97 throw (::com::sun::star::uno::RuntimeException);
99 // XServiceInfo
100 virtual ::rtl::OUString SAL_CALL getImplementationName()
101 throw (::com::sun::star::uno::RuntimeException);
102 virtual sal_Bool SAL_CALL supportsService(
103 const ::rtl::OUString& rServiceName)
104 throw (::com::sun::star::uno::RuntimeException);
105 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
106 getSupportedServiceNames()
107 throw (::com::sun::star::uno::RuntimeException);
109 // XComponent
110 virtual void SAL_CALL dispose()
111 throw (::com::sun::star::uno::RuntimeException);
112 virtual void SAL_CALL addEventListener(
113 const ::com::sun::star::uno::Reference<
114 ::com::sun::star::lang::XEventListener > & xListener)
115 throw (::com::sun::star::uno::RuntimeException);
116 virtual void SAL_CALL removeEventListener(
117 const ::com::sun::star::uno::Reference<
118 ::com::sun::star::lang::XEventListener > & xListener)
119 throw (::com::sun::star::uno::RuntimeException);
121 // XTextContent
122 virtual void SAL_CALL attach(
123 const ::com::sun::star::uno::Reference<
124 ::com::sun::star::text::XTextRange > & xTextRange)
125 throw (::com::sun::star::lang::IllegalArgumentException,
126 ::com::sun::star::uno::RuntimeException);
127 virtual ::com::sun::star::uno::Reference<
128 ::com::sun::star::text::XTextRange > SAL_CALL getAnchor()
129 throw (::com::sun::star::uno::RuntimeException);
131 // XTextRange
132 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
133 SAL_CALL getText() throw (::com::sun::star::uno::RuntimeException);
134 virtual ::com::sun::star::uno::Reference<
135 ::com::sun::star::text::XTextRange > SAL_CALL getStart()
136 throw (::com::sun::star::uno::RuntimeException);
137 virtual ::com::sun::star::uno::Reference<
138 ::com::sun::star::text::XTextRange > SAL_CALL getEnd()
139 throw (::com::sun::star::uno::RuntimeException);
140 virtual rtl::OUString SAL_CALL getString()
141 throw (::com::sun::star::uno::RuntimeException);
142 virtual void SAL_CALL setString(const rtl::OUString& rString)
143 throw (::com::sun::star::uno::RuntimeException);
145 // XSimpleText
146 virtual ::com::sun::star::uno::Reference<
147 ::com::sun::star::text::XTextCursor > SAL_CALL
148 createTextCursor()
149 throw (::com::sun::star::uno::RuntimeException);
150 virtual ::com::sun::star::uno::Reference<
151 ::com::sun::star::text::XTextCursor > SAL_CALL
152 createTextCursorByRange(
153 const ::com::sun::star::uno::Reference<
154 ::com::sun::star::text::XTextRange > & xTextPosition)
155 throw (::com::sun::star::uno::RuntimeException);
156 virtual void SAL_CALL insertString(
157 const ::com::sun::star::uno::Reference<
158 ::com::sun::star::text::XTextRange > & xRange,
159 const rtl::OUString& aString, sal_Bool bAbsorb)
160 throw (::com::sun::star::uno::RuntimeException);
161 virtual void SAL_CALL insertControlCharacter(
162 const ::com::sun::star::uno::Reference<
163 ::com::sun::star::text::XTextRange > & xRange,
164 sal_Int16 nControlCharacter, sal_Bool bAbsorb)
165 throw (::com::sun::star::lang::IllegalArgumentException,
166 ::com::sun::star::uno::RuntimeException);
168 // XText
169 virtual void SAL_CALL insertTextContent(
170 const ::com::sun::star::uno::Reference<
171 ::com::sun::star::text::XTextRange > & xRange,
172 const ::com::sun::star::uno::Reference<
173 ::com::sun::star::text::XTextContent > & xContent,
174 sal_Bool bAbsorb)
175 throw (::com::sun::star::lang::IllegalArgumentException,
176 ::com::sun::star::uno::RuntimeException);
177 virtual void SAL_CALL removeTextContent(
178 const ::com::sun::star::uno::Reference<
179 ::com::sun::star::text::XTextContent > & xContent)
180 throw (::com::sun::star::container::NoSuchElementException,
181 ::com::sun::star::uno::RuntimeException);
183 // XElementAccess
184 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
185 throw (::com::sun::star::uno::RuntimeException);
186 virtual sal_Bool SAL_CALL hasElements()
187 throw (::com::sun::star::uno::RuntimeException);
189 // XEnumerationAccess
190 virtual ::com::sun::star::uno::Reference<
191 ::com::sun::star::container::XEnumeration > SAL_CALL
192 createEnumeration()
193 throw (::com::sun::star::uno::RuntimeException);
195 // MetadatableMixin
196 virtual ::sfx2::Metadatable * GetCoreObject();
197 virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
198 GetModel();
200 // SwClient
201 virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew );
203 /// init params with position of the attribute content (w/out CH_TXTATR)
204 bool SetContentRange(
205 SwTxtNode *& rpNode, xub_StrLen & rStart, xub_StrLen & rEnd) const;
206 ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
207 GetParentText() const;
209 bool CheckForOwnMemberMeta(const SwXTextRange* const pRange,
210 const SwPaM* const pPam, bool bAbsorb)
211 throw (::com::sun::star::lang::IllegalArgumentException,
212 ::com::sun::star::uno::RuntimeException);
214 protected:
215 virtual void SAL_CALL AttachImpl(
216 const ::com::sun::star::uno::Reference<
217 ::com::sun::star::text::XTextRange > & xTextRange,
218 const USHORT nWhich)
219 throw ( ::com::sun::star::lang::IllegalArgumentException,
220 ::com::sun::star::uno::RuntimeException );
222 private:
223 inline const ::sw::Meta * GetMeta() const;
228 typedef
229 ::cppu::ImplInheritanceHelper2
230 < SwXMeta
231 , ::com::sun::star::beans::XPropertySet
232 , ::com::sun::star::text::XTextField
233 > SwXMetaFieldBaseClass;
235 class SwXMetaField
236 : public SwXMetaFieldBaseClass
238 private:
239 virtual ~SwXMetaField();
241 private:
242 inline const ::sw::MetaField * GetMetaField() const;
244 public:
245 SwXMetaField(SwDoc *const pDoc,
246 ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> const&
247 xParentText,
248 TextRangeList_t * const pPortions, SwTxtMeta * const pHint);
249 SwXMetaField(SwDoc *const pDoc);
251 // XServiceInfo
252 virtual ::rtl::OUString SAL_CALL getImplementationName()
253 throw (::com::sun::star::uno::RuntimeException);
254 virtual sal_Bool SAL_CALL supportsService(
255 const ::rtl::OUString& ServiceName)
256 throw (::com::sun::star::uno::RuntimeException);
257 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
258 getSupportedServiceNames( )
259 throw (::com::sun::star::uno::RuntimeException);
261 // XComponent
262 virtual void SAL_CALL dispose()
263 throw (::com::sun::star::uno::RuntimeException);
264 virtual void SAL_CALL addEventListener(
265 const ::com::sun::star::uno::Reference<
266 ::com::sun::star::lang::XEventListener > & xListener)
267 throw (::com::sun::star::uno::RuntimeException);
268 virtual void SAL_CALL removeEventListener(
269 const ::com::sun::star::uno::Reference<
270 ::com::sun::star::lang::XEventListener > & xListener)
271 throw (::com::sun::star::uno::RuntimeException);
273 // XTextContent
274 virtual void SAL_CALL attach(
275 const ::com::sun::star::uno::Reference<
276 ::com::sun::star::text::XTextRange > & xTextRange)
277 throw ( ::com::sun::star::lang::IllegalArgumentException,
278 ::com::sun::star::uno::RuntimeException );
279 virtual ::com::sun::star::uno::Reference<
280 ::com::sun::star::text::XTextRange > SAL_CALL getAnchor()
281 throw (::com::sun::star::uno::RuntimeException);
283 // XPropertySet
284 virtual ::com::sun::star::uno::Reference<
285 ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
286 getPropertySetInfo()
287 throw (::com::sun::star::uno::RuntimeException);
288 virtual void SAL_CALL setPropertyValue(
289 const ::rtl::OUString& rPropertyName,
290 const ::com::sun::star::uno::Any& rValue)
291 throw (::com::sun::star::beans::UnknownPropertyException,
292 ::com::sun::star::beans::PropertyVetoException,
293 ::com::sun::star::lang::IllegalArgumentException,
294 ::com::sun::star::lang::WrappedTargetException,
295 ::com::sun::star::uno::RuntimeException);
296 virtual ::com::sun::star::uno::Any SAL_CALL
297 getPropertyValue(const ::rtl::OUString& rPropertyName)
298 throw (::com::sun::star::beans::UnknownPropertyException,
299 ::com::sun::star::lang::WrappedTargetException,
300 ::com::sun::star::uno::RuntimeException);
301 virtual void SAL_CALL addPropertyChangeListener(
302 const ::rtl::OUString& rPropertyName,
303 const ::com::sun::star::uno::Reference<
304 ::com::sun::star::beans::XPropertyChangeListener >& xListener)
305 throw (::com::sun::star::beans::UnknownPropertyException,
306 ::com::sun::star::lang::WrappedTargetException,
307 ::com::sun::star::uno::RuntimeException);
308 virtual void SAL_CALL removePropertyChangeListener(
309 const ::rtl::OUString& rPropertyName,
310 const ::com::sun::star::uno::Reference<
311 ::com::sun::star::beans::XPropertyChangeListener >& xListener)
312 throw (::com::sun::star::beans::UnknownPropertyException,
313 ::com::sun::star::lang::WrappedTargetException,
314 ::com::sun::star::uno::RuntimeException);
315 virtual void SAL_CALL addVetoableChangeListener(
316 const ::rtl::OUString& rPropertyName,
317 const ::com::sun::star::uno::Reference<
318 ::com::sun::star::beans::XVetoableChangeListener >& xListener)
319 throw (::com::sun::star::beans::UnknownPropertyException,
320 ::com::sun::star::lang::WrappedTargetException,
321 ::com::sun::star::uno::RuntimeException);
322 virtual void SAL_CALL removeVetoableChangeListener(
323 const ::rtl::OUString& rPropertyName,
324 const ::com::sun::star::uno::Reference<
325 ::com::sun::star::beans::XVetoableChangeListener >& xListener)
326 throw (::com::sun::star::beans::UnknownPropertyException,
327 ::com::sun::star::lang::WrappedTargetException,
328 ::com::sun::star::uno::RuntimeException);
330 // XTextField
331 virtual rtl::OUString SAL_CALL getPresentation(sal_Bool bShowCommand)
332 throw (::com::sun::star::uno::RuntimeException);
336 /// get prefix/suffix from the RDF repository. @throws RuntimeException
337 void getPrefixAndSuffix(
338 const ::com::sun::star::uno::Reference<
339 ::com::sun::star::frame::XModel>& xModel,
340 const ::com::sun::star::uno::Reference<
341 ::com::sun::star::rdf::XMetadatable>& xMetaField,
342 ::rtl::OUString *const o_pPrefix, ::rtl::OUString *const o_pSuffix);
344 #endif // SW_UNOMETA_HXX