xref: /trunk/main/sw/inc/unotextcursor.hxx (revision 9d37da743abb7db0a497688391f6e55a19f27c44)
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 #include <com/sun/star/text/XMarkingAccess.hpp>
41 
42 #include <cppuhelper/implbase12.hxx>
43 
44 #include <comphelper/uno3.hxx>
45 
46 #if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_13)
47 #define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_13
48 #define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 13
49 #include <comphelper/implbase_var.hxx>
50 #endif
51 
52 #include <unobaseclass.hxx>
53 #include <TextCursorHelper.hxx>
54 
55 
56 class SwDoc;
57 struct SwPosition;
58 class SwUnoCrsr;
59 
60 typedef ::comphelper::WeakImplHelper13
61 <   ::com::sun::star::lang::XServiceInfo
62 ,   ::com::sun::star::beans::XPropertySet
63 ,   ::com::sun::star::beans::XPropertyState
64 ,   ::com::sun::star::beans::XMultiPropertyStates
65 ,   ::com::sun::star::container::XEnumerationAccess
66 ,   ::com::sun::star::container::XContentEnumerationAccess
67 ,   ::com::sun::star::util::XSortable
68 ,   ::com::sun::star::document::XDocumentInsertable
69 ,   ::com::sun::star::text::XSentenceCursor
70 ,   ::com::sun::star::text::XWordCursor
71 ,   ::com::sun::star::text::XParagraphCursor
72 ,   ::com::sun::star::text::XRedline
73 ,   ::com::sun::star::text::XMarkingAccess
74 > SwXTextCursor_Base;
75 
76 class SwXTextCursor
77     : public SwXTextCursor_Base
78     , public OTextCursorHelper
79 {
80 
81 private:
82 
83     class Impl;
84     ::sw::UnoImplPtr<Impl> m_pImpl;
85 
86     virtual ~SwXTextCursor();
87 
88 public:
89 
90     SwXTextCursor(
91             SwDoc & rDoc,
92             ::com::sun::star::uno::Reference<
93                 ::com::sun::star::text::XText > const& xParent,
94             const enum CursorType eType,
95             SwPosition const& rPos,
96             SwPosition const*const pMark = 0);
97     SwXTextCursor(
98             ::com::sun::star::uno::Reference<
99                 ::com::sun::star::text::XText > const& xParent,
100             SwPaM const& rSourceCursor,
101             const enum CursorType eType = CURSOR_ALL);
102 
103           SwUnoCrsr *   GetCursor();
104     const SwUnoCrsr *   GetCursor() const;
105 
106     bool IsAtEndOfMeta() const;
107 
108     void DeleteAndInsert(::rtl::OUString const& rText,
109                 const bool bForceExpandHints);
110 
111     // OTextCursorHelper
112     virtual const SwPaM*        GetPaM() const;
113     virtual SwPaM*              GetPaM();
114     virtual const SwDoc*        GetDoc() const;
115     virtual SwDoc*              GetDoc();
116 
117     DECLARE_XINTERFACE()
118 
119     static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
120 
121     // XUnoTunnel
122     virtual sal_Int64 SAL_CALL getSomething(
123             const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier);
124 
125     // XServiceInfo
126     virtual ::rtl::OUString SAL_CALL getImplementationName();
127     virtual sal_Bool SAL_CALL supportsService(
128             const ::rtl::OUString& rServiceName);
129     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
130         getSupportedServiceNames();
131 
132     // XPropertySet
133     virtual ::com::sun::star::uno::Reference<
134                 ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
135         getPropertySetInfo();
136     virtual void SAL_CALL setPropertyValue(
137             const ::rtl::OUString& rPropertyName,
138             const ::com::sun::star::uno::Any& rValue);
139     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
140             const ::rtl::OUString& rPropertyName);
141     virtual void SAL_CALL addPropertyChangeListener(
142             const ::rtl::OUString& rPropertyName,
143             const ::com::sun::star::uno::Reference<
144                 ::com::sun::star::beans::XPropertyChangeListener >& xListener);
145     virtual void SAL_CALL removePropertyChangeListener(
146             const ::rtl::OUString& rPropertyName,
147             const ::com::sun::star::uno::Reference<
148                 ::com::sun::star::beans::XPropertyChangeListener >& xListener);
149     virtual void SAL_CALL addVetoableChangeListener(
150             const ::rtl::OUString& rPropertyName,
151             const ::com::sun::star::uno::Reference<
152                 ::com::sun::star::beans::XVetoableChangeListener >& xListener);
153     virtual void SAL_CALL removeVetoableChangeListener(
154             const ::rtl::OUString& rPropertyName,
155             const ::com::sun::star::uno::Reference<
156                 ::com::sun::star::beans::XVetoableChangeListener >& xListener);
157 
158     // XPropertyState
159     virtual ::com::sun::star::beans::PropertyState SAL_CALL
160         getPropertyState(const ::rtl::OUString& rPropertyName);
161     virtual ::com::sun::star::uno::Sequence<
162             ::com::sun::star::beans::PropertyState > SAL_CALL
163         getPropertyStates(
164             const ::com::sun::star::uno::Sequence<
165                 ::rtl::OUString >& rPropertyNames);
166     virtual void SAL_CALL setPropertyToDefault(
167             const ::rtl::OUString& rPropertyName);
168     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault(
169             const ::rtl::OUString& rPropertyName);
170 
171     // XMultiPropertyStates
172     virtual void SAL_CALL setAllPropertiesToDefault();
173     virtual void SAL_CALL setPropertiesToDefault(
174             const ::com::sun::star::uno::Sequence< ::rtl::OUString >&
175                 rPropertyNames);
176     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
177         SAL_CALL getPropertyDefaults(
178             const ::com::sun::star::uno::Sequence< ::rtl::OUString >&
179                 rPropertyNames);
180 
181     // XElementAccess
182     virtual ::com::sun::star::uno::Type SAL_CALL getElementType();
183     virtual sal_Bool SAL_CALL hasElements();
184 
185     // XEnumerationAccess
186     virtual ::com::sun::star::uno::Reference<
187             ::com::sun::star::container::XEnumeration >  SAL_CALL
188         createEnumeration();
189 
190     // XContentEnumerationAccess
191     virtual ::com::sun::star::uno::Reference<
192                 ::com::sun::star::container::XEnumeration > SAL_CALL
193         createContentEnumeration(const ::rtl::OUString& rServiceName);
194     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
195         getAvailableServiceNames();
196 
197     // XSortable
198     virtual ::com::sun::star::uno::Sequence<
199                 ::com::sun::star::beans::PropertyValue > SAL_CALL
200         createSortDescriptor();
201     virtual void SAL_CALL sort(
202             const ::com::sun::star::uno::Sequence<
203                 ::com::sun::star::beans::PropertyValue >& xDescriptor);
204 
205     // XDocumentInsertable
206     virtual void SAL_CALL insertDocumentFromURL(
207             const ::rtl::OUString& rURL,
208             const ::com::sun::star::uno::Sequence<
209                 ::com::sun::star::beans::PropertyValue >& rOptions);
210 
211     // XTextRange
212     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
213         SAL_CALL getText();
214     virtual ::com::sun::star::uno::Reference<
215                 ::com::sun::star::text::XTextRange > SAL_CALL getStart();
216     virtual ::com::sun::star::uno::Reference<
217                 ::com::sun::star::text::XTextRange > SAL_CALL getEnd();
218     virtual ::rtl::OUString SAL_CALL getString();
219     virtual void SAL_CALL setString(const ::rtl::OUString& rString);
220 
221     // XTextCursor
222     virtual void SAL_CALL collapseToStart();
223     virtual void SAL_CALL collapseToEnd();
224     virtual sal_Bool SAL_CALL isCollapsed();
225     virtual sal_Bool SAL_CALL goLeft(sal_Int16 nCount, sal_Bool bExpand);
226     virtual sal_Bool SAL_CALL goRight(sal_Int16 nCount, sal_Bool bExpand);
227     virtual void SAL_CALL gotoStart(sal_Bool bExpand);
228     virtual void SAL_CALL gotoEnd(sal_Bool bExpand);
229     virtual void SAL_CALL gotoRange(
230             const ::com::sun::star::uno::Reference<
231                 ::com::sun::star::text::XTextRange >& xRange,
232             sal_Bool bExpand);
233 
234     // XWordCursor
235     virtual sal_Bool SAL_CALL isStartOfWord();
236     virtual sal_Bool SAL_CALL isEndOfWord();
237     virtual sal_Bool SAL_CALL gotoNextWord(sal_Bool bExpand);
238     virtual sal_Bool SAL_CALL gotoPreviousWord(sal_Bool bExpand);
239     virtual sal_Bool SAL_CALL gotoEndOfWord(sal_Bool bExpand);
240     virtual sal_Bool SAL_CALL gotoStartOfWord(sal_Bool bExpand);
241 
242     // XSentenceCursor
243     virtual sal_Bool SAL_CALL isStartOfSentence();
244     virtual sal_Bool SAL_CALL isEndOfSentence();
245     virtual sal_Bool SAL_CALL gotoNextSentence(sal_Bool Expand);
246     virtual sal_Bool SAL_CALL gotoPreviousSentence(sal_Bool Expand);
247     virtual sal_Bool SAL_CALL gotoStartOfSentence(sal_Bool Expand);
248     virtual sal_Bool SAL_CALL gotoEndOfSentence(sal_Bool Expand);
249 
250     // XParagraphCursor
251     virtual sal_Bool SAL_CALL isStartOfParagraph();
252     virtual sal_Bool SAL_CALL isEndOfParagraph();
253     virtual sal_Bool SAL_CALL gotoStartOfParagraph(sal_Bool Expand);
254     virtual sal_Bool SAL_CALL gotoEndOfParagraph(sal_Bool Expand);
255     virtual sal_Bool SAL_CALL gotoNextParagraph(sal_Bool Expand);
256     virtual sal_Bool SAL_CALL gotoPreviousParagraph(sal_Bool Expand);
257 
258     // XRedline
259     virtual void SAL_CALL makeRedline(
260             const ::rtl::OUString& rRedlineType,
261             const ::com::sun::star::uno::Sequence<
262                 ::com::sun::star::beans::PropertyValue >& RedlineProperties);
263 
264     //XMarkingAccess
265     virtual void SAL_CALL invalidateMarkings(::sal_Int32 nType);
266 
267 };
268 
269 #endif // SW_UNOTEXTCURSOR_HXX
270