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;
80
82 if(!m_pUnoCursor)
83 throw css::uno::RuntimeException("SwXTextCursor: disposed or invalid", nullptr);
84 return *m_pUnoCursor;
85 }
86
87 virtual ~SwXTextCursor() override;
88
89public:
90
92 SwDoc & rDoc,
93 css::uno::Reference< css::text::XText > xParent,
94 const CursorType eType,
95 SwPosition const& rPos,
96 SwPosition const*const pMark = nullptr);
98 css::uno::Reference< css::text::XText > xParent,
99 SwPaM const& rSourceCursor,
100 const CursorType eType = CursorType::All);
101
103 bool IsAtEndOfMeta() const;
104 bool IsAtEndOfContentControl() const;
105
106 void DeleteAndInsert(std::u16string_view aText, ::sw::DeleteAndInsertMode eMode);
107 // OTextCursorHelper
108 virtual const SwPaM* GetPaM() const override;
109 virtual SwPaM* GetPaM() override;
110 virtual const SwDoc* GetDoc() const override;
111 virtual SwDoc* GetDoc() override;
112
113 // XServiceInfo
114 virtual OUString SAL_CALL getImplementationName() override;
115 virtual sal_Bool SAL_CALL supportsService(
116 const OUString& rServiceName) override;
117 virtual css::uno::Sequence< OUString > SAL_CALL
118 getSupportedServiceNames() override;
119
120 // XPropertySet
121 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
122 getPropertySetInfo() override;
123 virtual void SAL_CALL setPropertyValue(
124 const OUString& rPropertyName,
125 const css::uno::Any& rValue) override;
126 virtual css::uno::Any SAL_CALL getPropertyValue(
127 const OUString& rPropertyName) override;
128 virtual void SAL_CALL addPropertyChangeListener(
129 const OUString& rPropertyName,
130 const css::uno::Reference<
131 css::beans::XPropertyChangeListener >& xListener) override;
132 virtual void SAL_CALL removePropertyChangeListener(
133 const OUString& rPropertyName,
134 const css::uno::Reference<
135 css::beans::XPropertyChangeListener >& xListener) override;
136 virtual void SAL_CALL addVetoableChangeListener(
137 const OUString& rPropertyName,
138 const css::uno::Reference<
139 css::beans::XVetoableChangeListener >& xListener) override;
140 virtual void SAL_CALL removeVetoableChangeListener(
141 const OUString& rPropertyName,
142 const css::uno::Reference<
143 css::beans::XVetoableChangeListener >& xListener) override;
144
145 // XPropertyState
146 virtual css::beans::PropertyState SAL_CALL
147 getPropertyState(const OUString& rPropertyName) override;
148 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL
150 const css::uno::Sequence< OUString >& rPropertyNames) override;
151 virtual void SAL_CALL setPropertyToDefault(
152 const OUString& rPropertyName) override;
153 virtual css::uno::Any SAL_CALL getPropertyDefault(
154 const OUString& rPropertyName) override;
155
156 // XMultiPropertySet
157 virtual void SAL_CALL setPropertyValues(
158 const css::uno::Sequence< OUString >& aPropertyNames,
159 const css::uno::Sequence< css::uno::Any >& aValues ) override;
160
161 virtual css::uno::Sequence< css::uno::Any > SAL_CALL
162 getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override;
163
164 virtual void SAL_CALL addPropertiesChangeListener(
165 const css::uno::Sequence< OUString >& aPropertyNames,
166 const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
167
168 virtual void SAL_CALL removePropertiesChangeListener(
169 const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
170
171 virtual void SAL_CALL firePropertiesChangeEvent(
172 const css::uno::Sequence< OUString >& aPropertyNames,
173 const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
174
175 // XMultiPropertyStates
176 virtual void SAL_CALL setAllPropertiesToDefault() override;
177 virtual void SAL_CALL setPropertiesToDefault(
178 const css::uno::Sequence< OUString >& rPropertyNames) override;
179 virtual css::uno::Sequence< css::uno::Any >
180 SAL_CALL getPropertyDefaults(
181 const css::uno::Sequence< OUString >& rPropertyNames) override;
182
183 // XElementAccess
184 virtual css::uno::Type SAL_CALL getElementType() override;
185 virtual sal_Bool SAL_CALL hasElements() override;
186
187 // XEnumerationAccess
188 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
189 createEnumeration() override;
190
191 // XContentEnumerationAccess
192 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
193 createContentEnumeration(const OUString& rServiceName) override;
194 virtual css::uno::Sequence< OUString > SAL_CALL
195 getAvailableServiceNames() override;
196
197 // XSortable
198 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL
199 createSortDescriptor() override;
200 virtual void SAL_CALL sort(
201 const css::uno::Sequence< css::beans::PropertyValue >& xDescriptor) override;
202
203 // XDocumentInsertable
204 virtual void SAL_CALL insertDocumentFromURL(
205 const OUString& rURL,
206 const css::uno::Sequence< css::beans::PropertyValue >& rOptions) override;
207
208 // XTextRange
209 virtual css::uno::Reference< css::text::XText >
210 SAL_CALL getText() override;
211 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override;
212 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override;
213 virtual OUString SAL_CALL getString() override;
214 virtual void SAL_CALL setString(const OUString& rString) override;
215
216 // XTextCursor
217 virtual void SAL_CALL collapseToStart() override;
218 virtual void SAL_CALL collapseToEnd() override;
219 virtual sal_Bool SAL_CALL isCollapsed() override;
220 virtual sal_Bool SAL_CALL goLeft(sal_Int16 nCount, sal_Bool bExpand) override;
221 virtual sal_Bool SAL_CALL goRight(sal_Int16 nCount, sal_Bool bExpand) override;
222 virtual void SAL_CALL gotoStart(sal_Bool bExpand) override;
223 virtual void SAL_CALL gotoEnd(sal_Bool bExpand) override;
224 virtual void SAL_CALL gotoRange(
225 const css::uno::Reference< css::text::XTextRange >& xRange,
226 sal_Bool bExpand) override;
227
228 // XWordCursor
229 virtual sal_Bool SAL_CALL isStartOfWord() override;
230 virtual sal_Bool SAL_CALL isEndOfWord() override;
231 virtual sal_Bool SAL_CALL gotoNextWord(sal_Bool bExpand) override;
232 virtual sal_Bool SAL_CALL gotoPreviousWord(sal_Bool bExpand) override;
233 virtual sal_Bool SAL_CALL gotoEndOfWord(sal_Bool bExpand) override;
234 virtual sal_Bool SAL_CALL gotoStartOfWord(sal_Bool bExpand) override;
235
236 // XSentenceCursor
237 virtual sal_Bool SAL_CALL isStartOfSentence() override;
238 virtual sal_Bool SAL_CALL isEndOfSentence() override;
239 virtual sal_Bool SAL_CALL gotoNextSentence(sal_Bool Expand) override;
240 virtual sal_Bool SAL_CALL gotoPreviousSentence(sal_Bool Expand) override;
241 virtual sal_Bool SAL_CALL gotoStartOfSentence(sal_Bool Expand) override;
242 virtual sal_Bool SAL_CALL gotoEndOfSentence(sal_Bool Expand) override;
243
244 // XParagraphCursor
245 virtual sal_Bool SAL_CALL isStartOfParagraph() override;
246 virtual sal_Bool SAL_CALL isEndOfParagraph() override;
247 virtual sal_Bool SAL_CALL gotoStartOfParagraph(sal_Bool Expand) override;
248 virtual sal_Bool SAL_CALL gotoEndOfParagraph(sal_Bool Expand) override;
249 virtual sal_Bool SAL_CALL gotoNextParagraph(sal_Bool Expand) override;
250 virtual sal_Bool SAL_CALL gotoPreviousParagraph(sal_Bool Expand) override;
251
252 // XRedline
253 virtual void SAL_CALL makeRedline(
254 const OUString& rRedlineType,
255 const css::uno::Sequence< css::beans::PropertyValue >& RedlineProperties) override;
256
257 //XMarkingAccess
258 virtual void SAL_CALL invalidateMarkings(::sal_Int32 nType) override;
259
260};
261
262#endif // INCLUDED_SW_INC_UNOTEXTCURSOR_HXX
263
264/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: doc.hxx:195
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:1576
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: unoobj.cxx:1810
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Sequence< css::uno::Any > &aValues) override
Definition: unoobj.cxx:2424
virtual sal_Bool SAL_CALL gotoEndOfWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1451
virtual void SAL_CALL setString(const OUString &rString) override
Definition: unoobj.cxx:1881
virtual sal_Bool SAL_CALL gotoPreviousWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1407
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:1023
virtual sal_Bool SAL_CALL gotoStartOfWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1490
virtual ~SwXTextCursor() override
Definition: unoobj.cxx:763
virtual sal_Bool SAL_CALL isEndOfParagraph() override
Definition: unoobj.cxx:1717
SwUnoCursor & GetCursorOrThrow()
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unoobj.cxx:2327
virtual void SAL_CALL collapseToStart() override
Definition: unoobj.cxx:1007
virtual sal_Bool SAL_CALL gotoNextWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1356
virtual sal_Bool SAL_CALL gotoPreviousSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1616
virtual void SAL_CALL insertDocumentFromURL(const OUString &rURL, const css::uno::Sequence< css::beans::PropertyValue > &rOptions) override
Definition: unoobj.cxx:2704
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &rPropertyName) override
Definition: unoobj.cxx:2385
virtual sal_Bool SAL_CALL isStartOfSentence() override
Definition: unoobj.cxx:1529
virtual sal_Bool SAL_CALL goRight(sal_Int16 nCount, sal_Bool bExpand) override
Definition: unoobj.cxx:1076
virtual sal_Bool SAL_CALL gotoStartOfParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1728
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL createSortDescriptor() override
Definition: unoobj.cxx:2765
virtual void SAL_CALL setPropertiesToDefault(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj.cxx:2551
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoobj.cxx:2353
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: unoobj.cxx:2467
virtual OUString SAL_CALL getImplementationName() override
Definition: unoobj.cxx:982
virtual void SAL_CALL setAllPropertiesToDefault() override
Definition: unoobj.cxx:2529
sw::UnoCursorPointer m_pUnoCursor
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &rPropertyName) override
Definition: unoobj.cxx:2417
virtual const SwPaM * GetPaM() const override
Definition: unoobj.cxx:719
SwUnoCursor & GetCursor()
Definition: unoobj.cxx:716
const SfxItemPropertySet & m_rPropSet
virtual sal_Bool SAL_CALL gotoEndOfParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1753
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoobj.cxx:2377
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createContentEnumeration(const OUString &rServiceName) override
Definition: unoobj.cxx:3068
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: unoobj.cxx:3114
virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2488
virtual const SwDoc * GetDoc() const override
Definition: unoobj.cxx:725
virtual sal_Bool SAL_CALL gotoNextParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1778
virtual void SAL_CALL sort(const css::uno::Sequence< css::beans::PropertyValue > &xDescriptor) override
Definition: unoobj.cxx:3024
virtual sal_Bool SAL_CALL goLeft(sal_Int16 nCount, sal_Bool bExpand) override
Definition: unoobj.cxx:1053
virtual void SAL_CALL makeRedline(const OUString &rRedlineType, const css::uno::Sequence< css::beans::PropertyValue > &RedlineProperties) override
Definition: unoobj.cxx:2693
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoobj.cxx:3108
virtual sal_Bool SAL_CALL isStartOfWord() override
Definition: unoobj.cxx:1333
virtual void SAL_CALL gotoStart(sal_Bool bExpand) override
Definition: unoobj.cxx:1099
virtual void SAL_CALL gotoEnd(sal_Bool bExpand) override
Definition: unoobj.cxx:1151
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unoobj.cxx:3103
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: unoobj.cxx:1818
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoobj.cxx:2361
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2482
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: unoobj.cxx:1844
virtual OUString SAL_CALL getString() override
Definition: unoobj.cxx:1869
SetAttrMode m_nAttrMode
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2476
bool IsAtEndOfContentControl() const
Definition: unoobj.cxx:946
virtual sal_Bool SAL_CALL gotoPreviousParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1794
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unoobj.cxx:2269
virtual void SAL_CALL setPropertyToDefault(const OUString &rPropertyName) override
Definition: unoobj.cxx:2409
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoobj.cxx:987
virtual sal_Bool SAL_CALL isEndOfSentence() override
Definition: unoobj.cxx:1552
virtual sal_Bool SAL_CALL isEndOfWord() override
Definition: unoobj.cxx:1344
virtual sal_Bool SAL_CALL gotoEndOfSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1677
void DeleteAndInsert(std::u16string_view aText, ::sw::DeleteAndInsertMode eMode)
Definition: unoobj.cxx:769
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj.cxx:2397
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unoobj.cxx:3078
bool IsAtEndOfMeta() const
Definition: unoobj.cxx:916
virtual void SAL_CALL gotoRange(const css::uno::Reference< css::text::XTextRange > &xRange, sal_Bool bExpand) override
Definition: unoobj.cxx:1183
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unoobj.cxx:2245
virtual sal_Bool SAL_CALL isCollapsed() override
Definition: unoobj.cxx:1039
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:2614
SwXTextCursor(css::uno::Reference< css::text::XText > xParent, SwPaM const &rSourceCursor, const CursorType eType=CursorType::All)
const CursorType m_eType
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoobj.cxx:993
virtual sal_Bool SAL_CALL isStartOfParagraph() override
Definition: unoobj.cxx:1706
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoobj.cxx:2369
virtual sal_Bool SAL_CALL gotoStartOfSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1649
virtual void SAL_CALL invalidateMarkings(::sal_Int32 nType) override
Definition: unoobj.cxx:2655
DeleteAndInsertMode
Marks a position in the document model.
Definition: pam.hxx:37
SetAttrMode
Definition: swtypes.hxx:133
unsigned char sal_Bool
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