xref: /trunk/main/sw/inc/unoparagraph.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SW_UNOPARAGRAPH_HXX
29 #define SW_UNOPARAGRAPH_HXX
30 
31 #include <memory>
32 
33 #include <com/sun/star/lang/XUnoTunnel.hpp>
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/beans/XPropertyState.hpp>
37 #include <com/sun/star/beans/XMultiPropertySet.hpp>
38 #include <com/sun/star/beans/XTolerantMultiPropertySet.hpp>
39 #include <com/sun/star/container/XEnumerationAccess.hpp>
40 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
41 #include <com/sun/star/text/XTextContent.hpp>
42 #include <com/sun/star/text/XTextRange.hpp>
43 
44 #include <cppuhelper/implbase10.hxx>
45 
46 #include <sfx2/Metadatable.hxx>
47 
48 #include <unobaseclass.hxx>
49 
50 
51 struct SwPosition;
52 class SwPaM;
53 class SwUnoCrsr;
54 class SwStartNode;
55 class SwTxtNode;
56 class SwTable;
57 class SwXText;
58 
59 
60 /*-----------------07.04.98 08:15-------------------
61 
62 --------------------------------------------------*/
63 typedef ::cppu::ImplInheritanceHelper10
64 <   ::sfx2::MetadatableMixin
65 ,   ::com::sun::star::lang::XUnoTunnel
66 ,   ::com::sun::star::lang::XServiceInfo
67 ,   ::com::sun::star::beans::XPropertySet
68 ,   ::com::sun::star::beans::XPropertyState
69 ,   ::com::sun::star::beans::XMultiPropertySet
70 ,   ::com::sun::star::beans::XTolerantMultiPropertySet
71 ,   ::com::sun::star::container::XEnumerationAccess
72 ,   ::com::sun::star::container::XContentEnumerationAccess
73 ,   ::com::sun::star::text::XTextContent
74 ,   ::com::sun::star::text::XTextRange
75 > SwXParagraph_Base;
76 
77 class SwXParagraph
78     : public SwXParagraph_Base
79 {
80 
81 private:
82 
83     class Impl;
84     ::sw::UnoImplPtr<Impl> m_pImpl;
85 
86     virtual ~SwXParagraph();
87 
88     SwXParagraph(::com::sun::star::uno::Reference<
89                     ::com::sun::star::text::XText > const & xParent,
90             SwTxtNode & rTxtNode,
91             const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = - 1);
92 
93 public:
94 
95     /// descriptor
96     SwXParagraph();
97 
98     static ::com::sun::star::uno::Reference<
99             ::com::sun::star::text::XTextContent>
100         CreateXParagraph(SwDoc & rDoc, SwTxtNode& rTxtNode,
101             ::com::sun::star::uno::Reference< ::com::sun::star::text::XText>
102                 const& xParentText = 0,
103             const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = - 1);
104 
105     const SwTxtNode * GetTxtNode() const;
106     bool            IsDescriptor() const;
107     /// make rPaM select the paragraph
108     bool SelectPaM(SwPaM & rPaM);
109     /// for SwXText
110     void attachToText(SwXText & rParent, SwTxtNode & rTxtNode);
111 
112     // MetadatableMixin
113     virtual ::sfx2::Metadatable* GetCoreObject();
114     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
115         GetModel();
116 
117     static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
118 
119     // XUnoTunnel
120     virtual sal_Int64 SAL_CALL getSomething(
121             const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier)
122         throw (::com::sun::star::uno::RuntimeException);
123 
124     // XServiceInfo
125     virtual ::rtl::OUString SAL_CALL getImplementationName()
126         throw (::com::sun::star::uno::RuntimeException);
127     virtual sal_Bool SAL_CALL supportsService(
128             const ::rtl::OUString& rServiceName)
129         throw (::com::sun::star::uno::RuntimeException);
130     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
131         getSupportedServiceNames()
132         throw (::com::sun::star::uno::RuntimeException);
133 
134     // XComponent
135     virtual void SAL_CALL dispose()
136         throw (::com::sun::star::uno::RuntimeException);
137     virtual void SAL_CALL addEventListener(
138             const ::com::sun::star::uno::Reference<
139                 ::com::sun::star::lang::XEventListener > & xListener)
140         throw (::com::sun::star::uno::RuntimeException);
141     virtual void SAL_CALL removeEventListener(
142             const ::com::sun::star::uno::Reference<
143                 ::com::sun::star::lang::XEventListener > & xListener)
144         throw (::com::sun::star::uno::RuntimeException);
145 
146     // XPropertySet
147     virtual ::com::sun::star::uno::Reference<
148                 ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
149         getPropertySetInfo()
150         throw (::com::sun::star::uno::RuntimeException);
151     virtual void SAL_CALL setPropertyValue(
152             const ::rtl::OUString& rPropertyName,
153             const ::com::sun::star::uno::Any& rValue)
154         throw (::com::sun::star::beans::UnknownPropertyException,
155                 ::com::sun::star::beans::PropertyVetoException,
156                 ::com::sun::star::lang::IllegalArgumentException,
157                 ::com::sun::star::lang::WrappedTargetException,
158                 ::com::sun::star::uno::RuntimeException);
159     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
160             const ::rtl::OUString& rPropertyName)
161         throw (::com::sun::star::beans::UnknownPropertyException,
162                 ::com::sun::star::lang::WrappedTargetException,
163                 ::com::sun::star::uno::RuntimeException);
164     virtual void SAL_CALL addPropertyChangeListener(
165             const ::rtl::OUString& rPropertyName,
166             const ::com::sun::star::uno::Reference<
167                 ::com::sun::star::beans::XPropertyChangeListener >& xListener)
168         throw (::com::sun::star::beans::UnknownPropertyException,
169                 ::com::sun::star::lang::WrappedTargetException,
170                 ::com::sun::star::uno::RuntimeException);
171     virtual void SAL_CALL removePropertyChangeListener(
172             const ::rtl::OUString& rPropertyName,
173             const ::com::sun::star::uno::Reference<
174                 ::com::sun::star::beans::XPropertyChangeListener >& xListener)
175         throw (::com::sun::star::beans::UnknownPropertyException,
176                 ::com::sun::star::lang::WrappedTargetException,
177                 ::com::sun::star::uno::RuntimeException);
178     virtual void SAL_CALL addVetoableChangeListener(
179             const ::rtl::OUString& rPropertyName,
180             const ::com::sun::star::uno::Reference<
181                 ::com::sun::star::beans::XVetoableChangeListener >& xListener)
182         throw (::com::sun::star::beans::UnknownPropertyException,
183                 ::com::sun::star::lang::WrappedTargetException,
184                 ::com::sun::star::uno::RuntimeException);
185     virtual void SAL_CALL removeVetoableChangeListener(
186             const ::rtl::OUString& rPropertyName,
187             const ::com::sun::star::uno::Reference<
188                 ::com::sun::star::beans::XVetoableChangeListener >& xListener)
189         throw (::com::sun::star::beans::UnknownPropertyException,
190                 ::com::sun::star::lang::WrappedTargetException,
191                 ::com::sun::star::uno::RuntimeException);
192 
193     // XPropertyState
194     virtual ::com::sun::star::beans::PropertyState SAL_CALL
195         getPropertyState(const ::rtl::OUString& rPropertyName)
196         throw (::com::sun::star::beans::UnknownPropertyException,
197                 ::com::sun::star::uno::RuntimeException);
198     virtual ::com::sun::star::uno::Sequence<
199             ::com::sun::star::beans::PropertyState > SAL_CALL
200         getPropertyStates(
201             const ::com::sun::star::uno::Sequence<
202                 ::rtl::OUString >& rPropertyNames)
203         throw (::com::sun::star::beans::UnknownPropertyException,
204                 ::com::sun::star::uno::RuntimeException);
205     virtual void SAL_CALL setPropertyToDefault(
206             const ::rtl::OUString& rPropertyName)
207         throw (::com::sun::star::beans::UnknownPropertyException,
208                 ::com::sun::star::uno::RuntimeException);
209     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault(
210             const ::rtl::OUString& rPropertyName)
211         throw (::com::sun::star::beans::UnknownPropertyException,
212                 ::com::sun::star::lang::WrappedTargetException,
213                 ::com::sun::star::uno::RuntimeException);
214 
215     // XMultiPropertySet
216     virtual void SAL_CALL setPropertyValues(
217             const ::com::sun::star::uno::Sequence< ::rtl::OUString >&
218                 rPropertyNames,
219             const ::com::sun::star::uno::Sequence<
220                 ::com::sun::star::uno::Any >& rValues)
221         throw (::com::sun::star::beans::PropertyVetoException,
222                 ::com::sun::star::lang::IllegalArgumentException,
223                 ::com::sun::star::lang::WrappedTargetException,
224                 ::com::sun::star::uno::RuntimeException);
225     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
226         SAL_CALL getPropertyValues(
227             const ::com::sun::star::uno::Sequence< ::rtl::OUString >&
228                 rPropertyNames)
229         throw (::com::sun::star::uno::RuntimeException);
230     virtual void SAL_CALL addPropertiesChangeListener(
231             const ::com::sun::star::uno::Sequence< ::rtl::OUString >&
232                 rPropertyNames,
233             const ::com::sun::star::uno::Reference<
234                 ::com::sun::star::beans::XPropertiesChangeListener >& xListener)
235         throw (::com::sun::star::uno::RuntimeException);
236     virtual void SAL_CALL removePropertiesChangeListener(
237             const ::com::sun::star::uno::Reference<
238                 ::com::sun::star::beans::XPropertiesChangeListener >& xListener)
239         throw (::com::sun::star::uno::RuntimeException);
240     virtual void SAL_CALL firePropertiesChangeEvent(
241             const ::com::sun::star::uno::Sequence< ::rtl::OUString >&
242                 rPropertyNames,
243             const ::com::sun::star::uno::Reference<
244                 ::com::sun::star::beans::XPropertiesChangeListener >& xListener)
245         throw (::com::sun::star::uno::RuntimeException);
246 
247     // XTolerantMultiPropertySet
248     virtual ::com::sun::star::uno::Sequence<
249                 ::com::sun::star::beans::SetPropertyTolerantFailed > SAL_CALL
250         setPropertyValuesTolerant(
251             const ::com::sun::star::uno::Sequence< ::rtl::OUString >&
252                 rPropertyNames,
253             const ::com::sun::star::uno::Sequence<
254                 ::com::sun::star::uno::Any >& rValues)
255         throw (::com::sun::star::lang::IllegalArgumentException,
256                 ::com::sun::star::uno::RuntimeException);
257     virtual ::com::sun::star::uno::Sequence<
258                 ::com::sun::star::beans::GetPropertyTolerantResult > SAL_CALL
259         getPropertyValuesTolerant(
260             const ::com::sun::star::uno::Sequence< ::rtl::OUString >&
261                 rPropertyNames)
262         throw (::com::sun::star::uno::RuntimeException);
263     virtual ::com::sun::star::uno::Sequence<
264             ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL
265         getDirectPropertyValuesTolerant(
266             const ::com::sun::star::uno::Sequence< ::rtl::OUString >&
267                 rPropertyNames)
268         throw (::com::sun::star::uno::RuntimeException);
269 
270     // XElementAccess
271     virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
272         throw (::com::sun::star::uno::RuntimeException);
273     virtual sal_Bool SAL_CALL hasElements()
274         throw (::com::sun::star::uno::RuntimeException);
275 
276     // XEnumerationAccess
277     virtual ::com::sun::star::uno::Reference<
278             ::com::sun::star::container::XEnumeration >  SAL_CALL
279         createEnumeration()
280         throw (::com::sun::star::uno::RuntimeException);
281 
282     // XContentEnumerationAccess
283     virtual ::com::sun::star::uno::Reference<
284                 ::com::sun::star::container::XEnumeration > SAL_CALL
285         createContentEnumeration(const ::rtl::OUString& rServiceName)
286         throw (::com::sun::star::uno::RuntimeException);
287     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
288         getAvailableServiceNames()
289         throw (::com::sun::star::uno::RuntimeException);
290 
291     // XTextContent
292     virtual void SAL_CALL attach(
293             const ::com::sun::star::uno::Reference<
294                 ::com::sun::star::text::XTextRange > & xTextRange)
295         throw (::com::sun::star::lang::IllegalArgumentException,
296                 ::com::sun::star::uno::RuntimeException);
297     virtual ::com::sun::star::uno::Reference<
298                 ::com::sun::star::text::XTextRange > SAL_CALL getAnchor()
299         throw (::com::sun::star::uno::RuntimeException);
300 
301     // XTextRange
302     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
303         SAL_CALL getText()
304         throw (::com::sun::star::uno::RuntimeException);
305     virtual ::com::sun::star::uno::Reference<
306                 ::com::sun::star::text::XTextRange > SAL_CALL getStart()
307         throw (::com::sun::star::uno::RuntimeException);
308     virtual ::com::sun::star::uno::Reference<
309                 ::com::sun::star::text::XTextRange > SAL_CALL getEnd()
310         throw (::com::sun::star::uno::RuntimeException);
311     virtual ::rtl::OUString SAL_CALL getString()
312         throw (::com::sun::star::uno::RuntimeException);
313     virtual void SAL_CALL setString(const ::rtl::OUString& rString)
314         throw (::com::sun::star::uno::RuntimeException);
315 
316 };
317 
318 
319 /*-----------------07.04.98 08:10-------------------
320 
321 --------------------------------------------------*/
322 class SwXParagraphEnumeration
323     : public SwSimpleEnumeration_Base
324 {
325 
326 private:
327 
328     class Impl;
329     ::sw::UnoImplPtr<Impl> m_pImpl;
330 
331     virtual ~SwXParagraphEnumeration();
332 
333 public:
334 
335     /// takes ownership of cursor
336     SwXParagraphEnumeration(
337             ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
338                 const & xParent,
339             ::std::auto_ptr<SwUnoCrsr> pCursor,
340             const CursorType eType,
341             SwStartNode const*const pStartNode = 0,
342             SwTable const*const pTable = 0);
343 
344     // XServiceInfo
345     virtual ::rtl::OUString SAL_CALL getImplementationName()
346         throw (::com::sun::star::uno::RuntimeException);
347     virtual sal_Bool SAL_CALL supportsService(
348             const ::rtl::OUString& rServiceName)
349         throw (::com::sun::star::uno::RuntimeException);
350     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
351         getSupportedServiceNames()
352         throw (::com::sun::star::uno::RuntimeException);
353 
354     // XEnumeration
355     virtual sal_Bool SAL_CALL hasMoreElements()
356         throw (::com::sun::star::uno::RuntimeException);
357     virtual ::com::sun::star::uno::Any SAL_CALL nextElement()
358         throw (::com::sun::star::container::NoSuchElementException,
359                 ::com::sun::star::lang::WrappedTargetException,
360                 ::com::sun::star::uno::RuntimeException);
361 
362 };
363 
364 #endif // SW_UNOPARAGRAPH_HXX
365 
366