LibreOffice Module sw (master) 1
unotextcursor.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_SW_INC_UNOTEXTCURSOR_HXX
21#define INCLUDED_SW_INC_UNOTEXTCURSOR_HXX
22
23#include <com/sun/star/lang/XServiceInfo.hpp>
24#include <com/sun/star/beans/XPropertySet.hpp>
25#include <com/sun/star/beans/XPropertyState.hpp>
26#include <com/sun/star/beans/XMultiPropertySet.hpp>
27#include <com/sun/star/beans/XMultiPropertyStates.hpp>
28#include <com/sun/star/container/XEnumerationAccess.hpp>
29#include <com/sun/star/container/XContentEnumerationAccess.hpp>
30#include <com/sun/star/util/XSortable.hpp>
31#include <com/sun/star/document/XDocumentInsertable.hpp>
32#include <com/sun/star/text/XSentenceCursor.hpp>
33#include <com/sun/star/text/XWordCursor.hpp>
34#include <com/sun/star/text/XParagraphCursor.hpp>
35#include <com/sun/star/text/XRedline.hpp>
36#include <com/sun/star/text/XMarkingAccess.hpp>
37
39
40#include <comphelper/uno3.hxx>
41
42#include "unobaseclass.hxx"
43#include "TextCursorHelper.hxx"
44#include "unocrsr.hxx"
45
46class SwDoc;
47struct SwPosition;
48class SwUnoCursor;
50
51typedef ::cppu::WeakImplHelper
52< css::lang::XServiceInfo
53, css::beans::XPropertySet
54, css::beans::XPropertyState
55, css::beans::XMultiPropertySet
56, css::beans::XMultiPropertyStates
57, css::container::XEnumerationAccess
58, css::container::XContentEnumerationAccess
59, css::util::XSortable
60, css::document::XDocumentInsertable
61, css::text::XSentenceCursor
62, css::text::XWordCursor
63, css::text::XParagraphCursor
64, css::text::XRedline
65, css::text::XMarkingAccess
67
68class SwXTextCursor final
69 : public SwXTextCursor_Base
70 , public OTextCursorHelper
71{
72
73private:
74
77 const css::uno::Reference< css::text::XText > m_xParentText;
79
81 if(!m_pUnoCursor)
82 throw css::uno::RuntimeException("SwXTextCursor: disposed or invalid", nullptr);
83 return *m_pUnoCursor;
84 }
85
86 virtual ~SwXTextCursor() override;
87
88public:
89
91 SwDoc & rDoc,
92 css::uno::Reference< css::text::XText > xParent,
93 const CursorType eType,
94 SwPosition const& rPos,
95 SwPosition const*const pMark = nullptr);
97 css::uno::Reference< css::text::XText > xParent,
98 SwPaM const& rSourceCursor,
99 const CursorType eType = CursorType::All);
100
102 bool IsAtEndOfMeta() const;
103 bool IsAtEndOfContentControl() const;
104
105 void DeleteAndInsert(OUString const& rText, ::sw::DeleteAndInsertMode eMode);
106 // OTextCursorHelper
107 virtual const SwPaM* GetPaM() const override;
108 virtual SwPaM* GetPaM() override;
109 virtual const SwDoc* GetDoc() const override;
110 virtual SwDoc* GetDoc() override;
111
113
114 static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
115
116 // XUnoTunnel
117 virtual sal_Int64 SAL_CALL getSomething(
118 const css::uno::Sequence< sal_Int8 >& rIdentifier) override;
119
120 // XServiceInfo
121 virtual OUString SAL_CALL getImplementationName() override;
122 virtual sal_Bool SAL_CALL supportsService(
123 const OUString& rServiceName) override;
124 virtual css::uno::Sequence< OUString > SAL_CALL
125 getSupportedServiceNames() override;
126
127 // XPropertySet
128 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
129 getPropertySetInfo() override;
130 virtual void SAL_CALL setPropertyValue(
131 const OUString& rPropertyName,
132 const css::uno::Any& rValue) override;
133 virtual css::uno::Any SAL_CALL getPropertyValue(
134 const OUString& rPropertyName) override;
135 virtual void SAL_CALL addPropertyChangeListener(
136 const OUString& rPropertyName,
137 const css::uno::Reference<
138 css::beans::XPropertyChangeListener >& xListener) override;
139 virtual void SAL_CALL removePropertyChangeListener(
140 const OUString& rPropertyName,
141 const css::uno::Reference<
142 css::beans::XPropertyChangeListener >& xListener) override;
143 virtual void SAL_CALL addVetoableChangeListener(
144 const OUString& rPropertyName,
145 const css::uno::Reference<
146 css::beans::XVetoableChangeListener >& xListener) override;
147 virtual void SAL_CALL removeVetoableChangeListener(
148 const OUString& rPropertyName,
149 const css::uno::Reference<
150 css::beans::XVetoableChangeListener >& xListener) override;
151
152 // XPropertyState
153 virtual css::beans::PropertyState SAL_CALL
154 getPropertyState(const OUString& rPropertyName) override;
155 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL
157 const css::uno::Sequence< OUString >& rPropertyNames) override;
158 virtual void SAL_CALL setPropertyToDefault(
159 const OUString& rPropertyName) override;
160 virtual css::uno::Any SAL_CALL getPropertyDefault(
161 const OUString& rPropertyName) override;
162
163 // XMultiPropertySet
164 virtual void SAL_CALL setPropertyValues(
165 const css::uno::Sequence< OUString >& aPropertyNames,
166 const css::uno::Sequence< css::uno::Any >& aValues ) override;
167
168 virtual css::uno::Sequence< css::uno::Any > SAL_CALL
169 getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override;
170
171 virtual void SAL_CALL addPropertiesChangeListener(
172 const css::uno::Sequence< OUString >& aPropertyNames,
173 const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
174
175 virtual void SAL_CALL removePropertiesChangeListener(
176 const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
177
178 virtual void SAL_CALL firePropertiesChangeEvent(
179 const css::uno::Sequence< OUString >& aPropertyNames,
180 const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
181
182 // XMultiPropertyStates
183 virtual void SAL_CALL setAllPropertiesToDefault() override;
184 virtual void SAL_CALL setPropertiesToDefault(
185 const css::uno::Sequence< OUString >& rPropertyNames) override;
186 virtual css::uno::Sequence< css::uno::Any >
187 SAL_CALL getPropertyDefaults(
188 const css::uno::Sequence< OUString >& rPropertyNames) override;
189
190 // XElementAccess
191 virtual css::uno::Type SAL_CALL getElementType() override;
192 virtual sal_Bool SAL_CALL hasElements() override;
193
194 // XEnumerationAccess
195 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
196 createEnumeration() override;
197
198 // XContentEnumerationAccess
199 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
200 createContentEnumeration(const OUString& rServiceName) override;
201 virtual css::uno::Sequence< OUString > SAL_CALL
202 getAvailableServiceNames() override;
203
204 // XSortable
205 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL
206 createSortDescriptor() override;
207 virtual void SAL_CALL sort(
208 const css::uno::Sequence< css::beans::PropertyValue >& xDescriptor) override;
209
210 // XDocumentInsertable
211 virtual void SAL_CALL insertDocumentFromURL(
212 const OUString& rURL,
213 const css::uno::Sequence< css::beans::PropertyValue >& rOptions) override;
214
215 // XTextRange
216 virtual css::uno::Reference< css::text::XText >
217 SAL_CALL getText() override;
218 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override;
219 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override;
220 virtual OUString SAL_CALL getString() override;
221 virtual void SAL_CALL setString(const OUString& rString) override;
222
223 // XTextCursor
224 virtual void SAL_CALL collapseToStart() override;
225 virtual void SAL_CALL collapseToEnd() override;
226 virtual sal_Bool SAL_CALL isCollapsed() override;
227 virtual sal_Bool SAL_CALL goLeft(sal_Int16 nCount, sal_Bool bExpand) override;
228 virtual sal_Bool SAL_CALL goRight(sal_Int16 nCount, sal_Bool bExpand) override;
229 virtual void SAL_CALL gotoStart(sal_Bool bExpand) override;
230 virtual void SAL_CALL gotoEnd(sal_Bool bExpand) override;
231 virtual void SAL_CALL gotoRange(
232 const css::uno::Reference< css::text::XTextRange >& xRange,
233 sal_Bool bExpand) override;
234
235 // XWordCursor
236 virtual sal_Bool SAL_CALL isStartOfWord() override;
237 virtual sal_Bool SAL_CALL isEndOfWord() override;
238 virtual sal_Bool SAL_CALL gotoNextWord(sal_Bool bExpand) override;
239 virtual sal_Bool SAL_CALL gotoPreviousWord(sal_Bool bExpand) override;
240 virtual sal_Bool SAL_CALL gotoEndOfWord(sal_Bool bExpand) override;
241 virtual sal_Bool SAL_CALL gotoStartOfWord(sal_Bool bExpand) override;
242
243 // XSentenceCursor
244 virtual sal_Bool SAL_CALL isStartOfSentence() override;
245 virtual sal_Bool SAL_CALL isEndOfSentence() override;
246 virtual sal_Bool SAL_CALL gotoNextSentence(sal_Bool Expand) override;
247 virtual sal_Bool SAL_CALL gotoPreviousSentence(sal_Bool Expand) override;
248 virtual sal_Bool SAL_CALL gotoStartOfSentence(sal_Bool Expand) override;
249 virtual sal_Bool SAL_CALL gotoEndOfSentence(sal_Bool Expand) override;
250
251 // XParagraphCursor
252 virtual sal_Bool SAL_CALL isStartOfParagraph() override;
253 virtual sal_Bool SAL_CALL isEndOfParagraph() override;
254 virtual sal_Bool SAL_CALL gotoStartOfParagraph(sal_Bool Expand) override;
255 virtual sal_Bool SAL_CALL gotoEndOfParagraph(sal_Bool Expand) override;
256 virtual sal_Bool SAL_CALL gotoNextParagraph(sal_Bool Expand) override;
257 virtual sal_Bool SAL_CALL gotoPreviousParagraph(sal_Bool Expand) override;
258
259 // XRedline
260 virtual void SAL_CALL makeRedline(
261 const OUString& rRedlineType,
262 const css::uno::Sequence< css::beans::PropertyValue >& RedlineProperties) override;
263
264 //XMarkingAccess
265 virtual void SAL_CALL invalidateMarkings(::sal_Int32 nType) override;
266
267};
268
269#endif // INCLUDED_SW_INC_UNOTEXTCURSOR_HXX
270
271/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: doc.hxx:192
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
virtual sal_Bool SAL_CALL gotoNextSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1530
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: unoobj.cxx:1764
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Sequence< css::uno::Any > &aValues) override
Definition: unoobj.cxx:2351
virtual sal_Bool SAL_CALL gotoEndOfWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1405
virtual void SAL_CALL setString(const OUString &rString) override
Definition: unoobj.cxx:1835
virtual sal_Bool SAL_CALL gotoPreviousWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1361
SwXTextCursor(SwDoc &rDoc, css::uno::Reference< css::text::XText > xParent, const CursorType eType, SwPosition const &rPos, SwPosition const *const pMark=nullptr)
virtual void SAL_CALL collapseToEnd() override
Definition: unoobj.cxx:976
virtual sal_Bool SAL_CALL gotoStartOfWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1444
virtual ~SwXTextCursor() override
Definition: unoobj.cxx:703
virtual sal_Bool SAL_CALL isEndOfParagraph() override
Definition: unoobj.cxx:1671
SwUnoCursor & GetCursorOrThrow()
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unoobj.cxx:2254
virtual void SAL_CALL collapseToStart() override
Definition: unoobj.cxx:960
virtual sal_Bool SAL_CALL gotoNextWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1310
virtual sal_Bool SAL_CALL gotoPreviousSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1570
virtual void SAL_CALL insertDocumentFromURL(const OUString &rURL, const css::uno::Sequence< css::beans::PropertyValue > &rOptions) override
Definition: unoobj.cxx:2630
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &rPropertyName) override
Definition: unoobj.cxx:2312
virtual sal_Bool SAL_CALL isStartOfSentence() override
Definition: unoobj.cxx:1483
virtual sal_Bool SAL_CALL goRight(sal_Int16 nCount, sal_Bool bExpand) override
Definition: unoobj.cxx:1029
virtual sal_Bool SAL_CALL gotoStartOfParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1682
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL createSortDescriptor() override
Definition: unoobj.cxx:2691
virtual void SAL_CALL setPropertiesToDefault(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj.cxx:2478
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoobj.cxx:2280
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: unoobj.cxx:2394
virtual OUString SAL_CALL getImplementationName() override
Definition: unoobj.cxx:922
virtual void SAL_CALL setAllPropertiesToDefault() override
Definition: unoobj.cxx:2456
sw::UnoCursorPointer m_pUnoCursor
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &rPropertyName) override
Definition: unoobj.cxx:2344
virtual const SwPaM * GetPaM() const override
Definition: unoobj.cxx:659
SwUnoCursor & GetCursor()
Definition: unoobj.cxx:656
const SfxItemPropertySet & m_rPropSet
virtual sal_Bool SAL_CALL gotoEndOfParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1707
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoobj.cxx:2304
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createContentEnumeration(const OUString &rServiceName) override
Definition: unoobj.cxx:2994
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: unoobj.cxx:3040
virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2415
virtual const SwDoc * GetDoc() const override
Definition: unoobj.cxx:665
virtual sal_Bool SAL_CALL gotoNextParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1732
virtual void SAL_CALL sort(const css::uno::Sequence< css::beans::PropertyValue > &xDescriptor) override
Definition: unoobj.cxx:2950
virtual sal_Bool SAL_CALL goLeft(sal_Int16 nCount, sal_Bool bExpand) override
Definition: unoobj.cxx:1006
virtual void SAL_CALL makeRedline(const OUString &rRedlineType, const css::uno::Sequence< css::beans::PropertyValue > &RedlineProperties) override
Definition: unoobj.cxx:2619
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoobj.cxx:3034
virtual sal_Bool SAL_CALL isStartOfWord() override
Definition: unoobj.cxx:1287
virtual void SAL_CALL gotoStart(sal_Bool bExpand) override
Definition: unoobj.cxx:1052
virtual void SAL_CALL gotoEnd(sal_Bool bExpand) override
Definition: unoobj.cxx:1104
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unoobj.cxx:3029
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: unoobj.cxx:1772
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoobj.cxx:2288
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2409
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: unoobj.cxx:1798
virtual OUString SAL_CALL getString() override
Definition: unoobj.cxx:1823
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2403
bool IsAtEndOfContentControl() const
Definition: unoobj.cxx:886
virtual sal_Bool SAL_CALL gotoPreviousParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1748
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unoobj.cxx:2212
virtual void SAL_CALL setPropertyToDefault(const OUString &rPropertyName) override
Definition: unoobj.cxx:2336
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoobj.cxx:927
virtual sal_Bool SAL_CALL isEndOfSentence() override
Definition: unoobj.cxx:1506
virtual sal_Bool SAL_CALL isEndOfWord() override
Definition: unoobj.cxx:1298
virtual sal_Bool SAL_CALL gotoEndOfSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1631
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj.cxx:2324
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unoobj.cxx:3004
bool IsAtEndOfMeta() const
Definition: unoobj.cxx:856
virtual void SAL_CALL gotoRange(const css::uno::Reference< css::text::XTextRange > &xRange, sal_Bool bExpand) override
Definition: unoobj.cxx:1136
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unoobj.cxx:2189
virtual sal_Bool SAL_CALL isCollapsed() override
Definition: unoobj.cxx:992
void DeleteAndInsert(OUString const &rText, ::sw::DeleteAndInsertMode eMode)
Definition: unoobj.cxx:709
const css::uno::Reference< css::text::XText > m_xParentText
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj.cxx:2541
SwXTextCursor(css::uno::Reference< css::text::XText > xParent, SwPaM const &rSourceCursor, const CursorType eType=CursorType::All)
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoobj.cxx:947
const CursorType m_eType
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoobj.cxx:933
virtual sal_Bool SAL_CALL isStartOfParagraph() override
Definition: unoobj.cxx:1660
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoobj.cxx:2296
virtual sal_Bool SAL_CALL gotoStartOfSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1603
virtual void SAL_CALL invalidateMarkings(::sal_Int32 nType) override
Definition: unoobj.cxx:2581
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
Definition: unoobj.cxx:954
Type
DeleteAndInsertMode
Marks a position in the document model.
Definition: pam.hxx:37
unsigned char sal_Bool
signed char sal_Int8
#define DECLARE_XINTERFACE()
CursorType
::cppu::WeakImplHelper< css::lang::XServiceInfo, css::beans::XPropertySet, css::beans::XPropertyState, css::beans::XMultiPropertySet, css::beans::XMultiPropertyStates, css::container::XEnumerationAccess, css::container::XContentEnumerationAccess, css::util::XSortable, css::document::XDocumentInsertable, css::text::XSentenceCursor, css::text::XWordCursor, css::text::XParagraphCursor, css::text::XRedline, css::text::XMarkingAccess > SwXTextCursor_Base