xref: /aoo41x/main/sw/inc/unotextcursor.hxx (revision 1d2dbeb0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SW_UNOTEXTCURSOR_HXX
25 #define SW_UNOTEXTCURSOR_HXX
26 
27 #include <com/sun/star/lang/XUnoTunnel.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/beans/XPropertyState.hpp>
31 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
32 #include <com/sun/star/container/XEnumerationAccess.hpp>
33 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
34 #include <com/sun/star/util/XSortable.hpp>
35 #include <com/sun/star/document/XDocumentInsertable.hpp>
36 #include <com/sun/star/text/XSentenceCursor.hpp>
37 #include <com/sun/star/text/XWordCursor.hpp>
38 #include <com/sun/star/text/XParagraphCursor.hpp>
39 #include <com/sun/star/text/XRedline.hpp>
40 
41 #include <cppuhelper/implbase12.hxx>
42 
43 #include <comphelper/uno3.hxx>
44 
45 #include <unobaseclass.hxx>
46 #include <TextCursorHelper.hxx>
47 
48 
49 class SwDoc;
50 struct SwPosition;
51 class SwUnoCrsr;
52 
53 
54 typedef ::cppu::WeakImplHelper12
55 <   ::com::sun::star::lang::XServiceInfo
56 ,   ::com::sun::star::beans::XPropertySet
57 ,   ::com::sun::star::beans::XPropertyState
58 ,   ::com::sun::star::beans::XMultiPropertyStates
59 ,   ::com::sun::star::container::XEnumerationAccess
60 ,   ::com::sun::star::container::XContentEnumerationAccess
61 ,   ::com::sun::star::util::XSortable
62 ,   ::com::sun::star::document::XDocumentInsertable
63 ,   ::com::sun::star::text::XSentenceCursor
64 ,   ::com::sun::star::text::XWordCursor
65 ,   ::com::sun::star::text::XParagraphCursor
66 ,   ::com::sun::star::text::XRedline
67 > SwXTextCursor_Base;
68 
69 class SwXTextCursor
70     : public SwXTextCursor_Base
71     , public OTextCursorHelper
72 {
73 
74 private:
75 
76     class Impl;
77     ::sw::UnoImplPtr<Impl> m_pImpl;
78 
79     virtual ~SwXTextCursor();
80 
81 public:
82 
83     SwXTextCursor(
84             SwDoc & rDoc,
85             ::com::sun::star::uno::Reference<
86                 ::com::sun::star::text::XText > const& xParent,
87             const enum CursorType eType,
88             SwPosition const& rPos,
89             SwPosition const*const pMark = 0);
90     SwXTextCursor(
91             ::com::sun::star::uno::Reference<
92                 ::com::sun::star::text::XText > const& xParent,
93             SwPaM const& rSourceCursor,
94             const enum CursorType eType = CURSOR_ALL);
95 
96           SwUnoCrsr *   GetCursor();
97     const SwUnoCrsr *   GetCursor() const;
98 
99     bool IsAtEndOfMeta() const;
100 
101     void DeleteAndInsert(::rtl::OUString const& rText,
102                 const bool bForceExpandHints);
103 
104     // OTextCursorHelper
105     virtual const SwPaM*        GetPaM() const;
106     virtual SwPaM*              GetPaM();
107     virtual const SwDoc*        GetDoc() const;
108     virtual SwDoc*              GetDoc();
109 
110     DECLARE_XINTERFACE()
111 
112     static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
113 
114     // XUnoTunnel
115     virtual sal_Int64 SAL_CALL getSomething(
116             const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier)
117         throw (::com::sun::star::uno::RuntimeException);
118 
119     // XServiceInfo
120     virtual ::rtl::OUString SAL_CALL getImplementationName()
121         throw (::com::sun::star::uno::RuntimeException);
122     virtual sal_Bool SAL_CALL supportsService(
123             const ::rtl::OUString& rServiceName)
124         throw (::com::sun::star::uno::RuntimeException);
125     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
126         getSupportedServiceNames()
127         throw (::com::sun::star::uno::RuntimeException);
128 
129     // XPropertySet
130     virtual ::com::sun::star::uno::Reference<
131                 ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
132         getPropertySetInfo()
133         throw (::com::sun::star::uno::RuntimeException);
134     virtual void SAL_CALL setPropertyValue(
135             const ::rtl::OUString& rPropertyName,
136             const ::com::sun::star::uno::Any& rValue)
137         throw (::com::sun::star::beans::UnknownPropertyException,
138                 ::com::sun::star::beans::PropertyVetoException,
139                 ::com::sun::star::lang::IllegalArgumentException,
140                 ::com::sun::star::lang::WrappedTargetException,
141                 ::com::sun::star::uno::RuntimeException);
142     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
143             const ::rtl::OUString& rPropertyName)
144         throw (::com::sun::star::beans::UnknownPropertyException,
145                 ::com::sun::star::lang::WrappedTargetException,
146                 ::com::sun::star::uno::RuntimeException);
147     virtual void SAL_CALL addPropertyChangeListener(
148             const ::rtl::OUString& rPropertyName,
149             const ::com::sun::star::uno::Reference<
150                 ::com::sun::star::beans::XPropertyChangeListener >& xListener)
151         throw (::com::sun::star::beans::UnknownPropertyException,
152                 ::com::sun::star::lang::WrappedTargetException,
153                 ::com::sun::star::uno::RuntimeException);
154     virtual void SAL_CALL removePropertyChangeListener(
155             const ::rtl::OUString& rPropertyName,
156             const ::com::sun::star::uno::Reference<
157                 ::com::sun::star::beans::XPropertyChangeListener >& xListener)
158         throw (::com::sun::star::beans::UnknownPropertyException,
159                 ::com::sun::star::lang::WrappedTargetException,
160                 ::com::sun::star::uno::RuntimeException);
161     virtual void SAL_CALL addVetoableChangeListener(
162             const ::rtl::OUString& rPropertyName,
163             const ::com::sun::star::uno::Reference<
164                 ::com::sun::star::beans::XVetoableChangeListener >& xListener)
165         throw (::com::sun::star::beans::UnknownPropertyException,
166                 ::com::sun::star::lang::WrappedTargetException,
167                 ::com::sun::star::uno::RuntimeException);
168     virtual void SAL_CALL removeVetoableChangeListener(
169             const ::rtl::OUString& rPropertyName,
170             const ::com::sun::star::uno::Reference<
171                 ::com::sun::star::beans::XVetoableChangeListener >& xListener)
172         throw (::com::sun::star::beans::UnknownPropertyException,
173                 ::com::sun::star::lang::WrappedTargetException,
174                 ::com::sun::star::uno::RuntimeException);
175 
176     // XPropertyState
177     virtual ::com::sun::star::beans::PropertyState SAL_CALL
178         getPropertyState(const ::rtl::OUString& rPropertyName)
179         throw (::com::sun::star::beans::UnknownPropertyException,
180                 ::com::sun::star::uno::RuntimeException);
181     virtual ::com::sun::star::uno::Sequence<
182             ::com::sun::star::beans::PropertyState > SAL_CALL
183         getPropertyStates(
184             const ::com::sun::star::uno::Sequence<
185                 ::rtl::OUString >& rPropertyNames)
186         throw (::com::sun::star::beans::UnknownPropertyException,
187                 ::com::sun::star::uno::RuntimeException);
188     virtual void SAL_CALL setPropertyToDefault(
189             const ::rtl::OUString& rPropertyName)
190         throw (::com::sun::star::beans::UnknownPropertyException,
191                 ::com::sun::star::uno::RuntimeException);
192     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault(
193             const ::rtl::OUString& rPropertyName)
194         throw (::com::sun::star::beans::UnknownPropertyException,
195                 ::com::sun::star::lang::WrappedTargetException,
196                 ::com::sun::star::uno::RuntimeException);
197 
198     // XMultiPropertyStates
199     virtual void SAL_CALL setAllPropertiesToDefault()
200         throw (::com::sun::star::uno::RuntimeException);
201     virtual void SAL_CALL setPropertiesToDefault(
202             const ::com::sun::star::uno::Sequence< ::rtl::OUString >&
203                 rPropertyNames)
204         throw (::com::sun::star::beans::UnknownPropertyException,
205                 ::com::sun::star::uno::RuntimeException);
206     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
207         SAL_CALL getPropertyDefaults(
208             const ::com::sun::star::uno::Sequence< ::rtl::OUString >&
209                 rPropertyNames)
210         throw (::com::sun::star::beans::UnknownPropertyException,
211                 ::com::sun::star::lang::WrappedTargetException,
212                 ::com::sun::star::uno::RuntimeException);
213 
214     // XElementAccess
215     virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
216         throw (::com::sun::star::uno::RuntimeException);
217     virtual sal_Bool SAL_CALL hasElements()
218         throw (::com::sun::star::uno::RuntimeException);
219 
220     // XEnumerationAccess
221     virtual ::com::sun::star::uno::Reference<
222             ::com::sun::star::container::XEnumeration >  SAL_CALL
223         createEnumeration()
224         throw (::com::sun::star::uno::RuntimeException);
225 
226     // XContentEnumerationAccess
227     virtual ::com::sun::star::uno::Reference<
228                 ::com::sun::star::container::XEnumeration > SAL_CALL
229         createContentEnumeration(const ::rtl::OUString& rServiceName)
230         throw (::com::sun::star::uno::RuntimeException);
231     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
232         getAvailableServiceNames()
233         throw (::com::sun::star::uno::RuntimeException);
234 
235     // XSortable
236     virtual ::com::sun::star::uno::Sequence<
237                 ::com::sun::star::beans::PropertyValue > SAL_CALL
238         createSortDescriptor()
239         throw (::com::sun::star::uno::RuntimeException);
240     virtual void SAL_CALL sort(
241             const ::com::sun::star::uno::Sequence<
242                 ::com::sun::star::beans::PropertyValue >& xDescriptor)
243         throw (::com::sun::star::uno::RuntimeException);
244 
245     // XDocumentInsertable
246     virtual void SAL_CALL insertDocumentFromURL(
247             const ::rtl::OUString& rURL,
248             const ::com::sun::star::uno::Sequence<
249                 ::com::sun::star::beans::PropertyValue >& rOptions)
250         throw (::com::sun::star::lang::IllegalArgumentException,
251                 ::com::sun::star::io::IOException,
252                 ::com::sun::star::uno::RuntimeException);
253 
254     // XTextRange
255     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
256         SAL_CALL getText()
257         throw (::com::sun::star::uno::RuntimeException);
258     virtual ::com::sun::star::uno::Reference<
259                 ::com::sun::star::text::XTextRange > SAL_CALL getStart()
260         throw (::com::sun::star::uno::RuntimeException);
261     virtual ::com::sun::star::uno::Reference<
262                 ::com::sun::star::text::XTextRange > SAL_CALL getEnd()
263         throw (::com::sun::star::uno::RuntimeException);
264     virtual ::rtl::OUString SAL_CALL getString()
265         throw (::com::sun::star::uno::RuntimeException);
266     virtual void SAL_CALL setString(const ::rtl::OUString& rString)
267         throw (::com::sun::star::uno::RuntimeException);
268 
269     // XTextCursor
270     virtual void SAL_CALL collapseToStart()
271         throw (::com::sun::star::uno::RuntimeException);
272     virtual void SAL_CALL collapseToEnd()
273         throw (::com::sun::star::uno::RuntimeException);
274     virtual sal_Bool SAL_CALL isCollapsed()
275         throw (::com::sun::star::uno::RuntimeException);
276     virtual sal_Bool SAL_CALL goLeft(sal_Int16 nCount, sal_Bool bExpand)
277         throw (::com::sun::star::uno::RuntimeException);
278     virtual sal_Bool SAL_CALL goRight(sal_Int16 nCount, sal_Bool bExpand)
279         throw (::com::sun::star::uno::RuntimeException);
280     virtual void SAL_CALL gotoStart(sal_Bool bExpand)
281         throw (::com::sun::star::uno::RuntimeException);
282     virtual void SAL_CALL gotoEnd(sal_Bool bExpand)
283         throw (::com::sun::star::uno::RuntimeException);
284     virtual void SAL_CALL gotoRange(
285             const ::com::sun::star::uno::Reference<
286                 ::com::sun::star::text::XTextRange >& xRange,
287             sal_Bool bExpand)
288         throw (::com::sun::star::uno::RuntimeException);
289 
290     // XWordCursor
291     virtual sal_Bool SAL_CALL isStartOfWord()
292         throw (::com::sun::star::uno::RuntimeException);
293     virtual sal_Bool SAL_CALL isEndOfWord()
294         throw (::com::sun::star::uno::RuntimeException);
295     virtual sal_Bool SAL_CALL gotoNextWord(sal_Bool bExpand)
296         throw (::com::sun::star::uno::RuntimeException);
297     virtual sal_Bool SAL_CALL gotoPreviousWord(sal_Bool bExpand)
298         throw (::com::sun::star::uno::RuntimeException);
299     virtual sal_Bool SAL_CALL gotoEndOfWord(sal_Bool bExpand)
300         throw (::com::sun::star::uno::RuntimeException);
301     virtual sal_Bool SAL_CALL gotoStartOfWord(sal_Bool bExpand)
302         throw (::com::sun::star::uno::RuntimeException);
303 
304     // XSentenceCursor
305     virtual sal_Bool SAL_CALL isStartOfSentence()
306         throw (::com::sun::star::uno::RuntimeException);
307     virtual sal_Bool SAL_CALL isEndOfSentence()
308         throw (::com::sun::star::uno::RuntimeException);
309     virtual sal_Bool SAL_CALL gotoNextSentence(sal_Bool Expand)
310         throw (::com::sun::star::uno::RuntimeException);
311     virtual sal_Bool SAL_CALL gotoPreviousSentence(sal_Bool Expand)
312         throw (::com::sun::star::uno::RuntimeException);
313     virtual sal_Bool SAL_CALL gotoStartOfSentence(sal_Bool Expand)
314         throw (::com::sun::star::uno::RuntimeException);
315     virtual sal_Bool SAL_CALL gotoEndOfSentence(sal_Bool Expand)
316         throw (::com::sun::star::uno::RuntimeException);
317 
318     // XParagraphCursor
319     virtual sal_Bool SAL_CALL isStartOfParagraph()
320         throw (::com::sun::star::uno::RuntimeException);
321     virtual sal_Bool SAL_CALL isEndOfParagraph()
322         throw (::com::sun::star::uno::RuntimeException);
323     virtual sal_Bool SAL_CALL gotoStartOfParagraph(sal_Bool Expand)
324         throw (::com::sun::star::uno::RuntimeException);
325     virtual sal_Bool SAL_CALL gotoEndOfParagraph(sal_Bool Expand)
326         throw (::com::sun::star::uno::RuntimeException);
327     virtual sal_Bool SAL_CALL gotoNextParagraph(sal_Bool Expand)
328         throw (::com::sun::star::uno::RuntimeException);
329     virtual sal_Bool SAL_CALL gotoPreviousParagraph(sal_Bool Expand)
330         throw (::com::sun::star::uno::RuntimeException);
331 
332     // XRedline
333     virtual void SAL_CALL makeRedline(
334             const ::rtl::OUString& rRedlineType,
335             const ::com::sun::star::uno::Sequence<
336                 ::com::sun::star::beans::PropertyValue >& RedlineProperties)
337         throw (::com::sun::star::lang::IllegalArgumentException,
338                 ::com::sun::star::uno::RuntimeException);
339 
340 };
341 
342 #endif // SW_UNOTEXTCURSOR_HXX
343 
344