1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SW_INC_UNOTEXTCURSOR_HXX
21 #define INCLUDED_SW_INC_UNOTEXTCURSOR_HXX
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>
38 #include <cppuhelper/implbase.hxx>
40 #include <comphelper/uno3.hxx>
42 #include "unobaseclass.hxx"
43 #include "TextCursorHelper.hxx"
44 #include "unocrsr.hxx"
50 class SfxItemPropertySet
;
52 typedef ::cppu::WeakImplHelper
53 < css::lang::XServiceInfo
54 , css::beans::XPropertySet
55 , css::beans::XPropertyState
56 , css::beans::XMultiPropertySet
57 , css::beans::XMultiPropertyStates
58 , css::container::XEnumerationAccess
59 , css::container::XContentEnumerationAccess
60 , css::util::XSortable
61 , css::document::XDocumentInsertable
62 , css::text::XSentenceCursor
63 , css::text::XWordCursor
64 , css::text::XParagraphCursor
66 , css::text::XMarkingAccess
69 class SW_DLLPUBLIC SwXTextCursor final
70 : public SwXTextCursor_Base
71 , public OTextCursorHelper
76 const SfxItemPropertySet
& m_rPropSet
;
77 const CursorType m_eType
;
78 const css::uno::Reference
< css::text::XText
> m_xParentText
;
79 sw::UnoCursorPointer m_pUnoCursor
;
80 SetAttrMode m_nAttrMode
= SetAttrMode::DEFAULT
;
82 SwUnoCursor
& GetCursorOrThrow() {
84 throw css::uno::RuntimeException(u
"SwXTextCursor: disposed or invalid"_ustr
, nullptr);
88 virtual ~SwXTextCursor() override
;
94 css::uno::Reference
< css::text::XText
> xParent
,
95 const CursorType eType
,
96 SwPosition
const& rPos
,
97 SwPosition
const*const pMark
= nullptr);
99 css::uno::Reference
< css::text::XText
> xParent
,
100 SwPaM
const& rSourceCursor
,
101 const CursorType eType
= CursorType::All
);
103 SwUnoCursor
& GetCursor();
104 bool IsAtEndOfMeta() const;
105 bool IsAtEndOfContentControl() const;
107 void DeleteAndInsert(std::u16string_view aText
, ::sw::DeleteAndInsertMode eMode
);
109 virtual const SwPaM
* GetPaM() const override
;
110 virtual SwPaM
* GetPaM() override
;
111 virtual const SwDoc
* GetDoc() const override
;
112 virtual SwDoc
* GetDoc() override
;
115 virtual OUString SAL_CALL
getImplementationName() override
;
116 virtual sal_Bool SAL_CALL
supportsService(
117 const OUString
& rServiceName
) override
;
118 virtual css::uno::Sequence
< OUString
> SAL_CALL
119 getSupportedServiceNames() override
;
122 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
123 getPropertySetInfo() override
;
124 virtual void SAL_CALL
setPropertyValue(
125 const OUString
& rPropertyName
,
126 const css::uno::Any
& rValue
) override
;
127 virtual css::uno::Any SAL_CALL
getPropertyValue(
128 const OUString
& rPropertyName
) override
;
129 virtual void SAL_CALL
addPropertyChangeListener(
130 const OUString
& rPropertyName
,
131 const css::uno::Reference
<
132 css::beans::XPropertyChangeListener
>& xListener
) override
;
133 virtual void SAL_CALL
removePropertyChangeListener(
134 const OUString
& rPropertyName
,
135 const css::uno::Reference
<
136 css::beans::XPropertyChangeListener
>& xListener
) override
;
137 virtual void SAL_CALL
addVetoableChangeListener(
138 const OUString
& rPropertyName
,
139 const css::uno::Reference
<
140 css::beans::XVetoableChangeListener
>& xListener
) override
;
141 virtual void SAL_CALL
removeVetoableChangeListener(
142 const OUString
& rPropertyName
,
143 const css::uno::Reference
<
144 css::beans::XVetoableChangeListener
>& xListener
) override
;
147 virtual css::beans::PropertyState SAL_CALL
148 getPropertyState(const OUString
& rPropertyName
) override
;
149 virtual css::uno::Sequence
< css::beans::PropertyState
> SAL_CALL
151 const css::uno::Sequence
< OUString
>& rPropertyNames
) override
;
152 virtual void SAL_CALL
setPropertyToDefault(
153 const OUString
& rPropertyName
) override
;
154 virtual css::uno::Any SAL_CALL
getPropertyDefault(
155 const OUString
& rPropertyName
) override
;
158 virtual void SAL_CALL
setPropertyValues(
159 const css::uno::Sequence
< OUString
>& aPropertyNames
,
160 const css::uno::Sequence
< css::uno::Any
>& aValues
) override
;
162 virtual css::uno::Sequence
< css::uno::Any
> SAL_CALL
163 getPropertyValues( const css::uno::Sequence
< OUString
>& aPropertyNames
) override
;
165 virtual void SAL_CALL
addPropertiesChangeListener(
166 const css::uno::Sequence
< OUString
>& aPropertyNames
,
167 const css::uno::Reference
< css::beans::XPropertiesChangeListener
>& xListener
) override
;
169 virtual void SAL_CALL
removePropertiesChangeListener(
170 const css::uno::Reference
< css::beans::XPropertiesChangeListener
>& xListener
) override
;
172 virtual void SAL_CALL
firePropertiesChangeEvent(
173 const css::uno::Sequence
< OUString
>& aPropertyNames
,
174 const css::uno::Reference
< css::beans::XPropertiesChangeListener
>& xListener
) override
;
176 // XMultiPropertyStates
177 virtual void SAL_CALL
setAllPropertiesToDefault() override
;
178 virtual void SAL_CALL
setPropertiesToDefault(
179 const css::uno::Sequence
< OUString
>& rPropertyNames
) override
;
180 virtual css::uno::Sequence
< css::uno::Any
>
181 SAL_CALL
getPropertyDefaults(
182 const css::uno::Sequence
< OUString
>& rPropertyNames
) override
;
185 virtual css::uno::Type SAL_CALL
getElementType() override
;
186 virtual sal_Bool SAL_CALL
hasElements() override
;
188 // XEnumerationAccess
189 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
190 createEnumeration() override
;
192 // XContentEnumerationAccess
193 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
194 createContentEnumeration(const OUString
& rServiceName
) override
;
195 virtual css::uno::Sequence
< OUString
> SAL_CALL
196 getAvailableServiceNames() override
;
199 virtual css::uno::Sequence
< css::beans::PropertyValue
> SAL_CALL
200 createSortDescriptor() override
;
201 virtual void SAL_CALL
sort(
202 const css::uno::Sequence
< css::beans::PropertyValue
>& xDescriptor
) override
;
204 // XDocumentInsertable
205 virtual void SAL_CALL
insertDocumentFromURL(
206 const OUString
& rURL
,
207 const css::uno::Sequence
< css::beans::PropertyValue
>& rOptions
) override
;
210 virtual css::uno::Reference
< css::text::XText
>
211 SAL_CALL
getText() override
;
212 virtual css::uno::Reference
< css::text::XTextRange
> SAL_CALL
getStart() override
;
213 virtual css::uno::Reference
< css::text::XTextRange
> SAL_CALL
getEnd() override
;
214 virtual OUString SAL_CALL
getString() override
;
215 virtual void SAL_CALL
setString(const OUString
& rString
) override
;
218 virtual void SAL_CALL
collapseToStart() override
;
219 virtual void SAL_CALL
collapseToEnd() override
;
220 virtual sal_Bool SAL_CALL
isCollapsed() override
;
221 virtual sal_Bool SAL_CALL
goLeft(sal_Int16 nCount
, sal_Bool bExpand
) override
;
222 virtual sal_Bool SAL_CALL
goRight(sal_Int16 nCount
, sal_Bool bExpand
) override
;
223 virtual void SAL_CALL
gotoStart(sal_Bool bExpand
) override
;
224 virtual void SAL_CALL
gotoEnd(sal_Bool bExpand
) override
;
225 virtual void SAL_CALL
gotoRange(
226 const css::uno::Reference
< css::text::XTextRange
>& xRange
,
227 sal_Bool bExpand
) override
;
230 virtual sal_Bool SAL_CALL
isStartOfWord() override
;
231 virtual sal_Bool SAL_CALL
isEndOfWord() override
;
232 virtual sal_Bool SAL_CALL
gotoNextWord(sal_Bool bExpand
) override
;
233 virtual sal_Bool SAL_CALL
gotoPreviousWord(sal_Bool bExpand
) override
;
234 virtual sal_Bool SAL_CALL
gotoEndOfWord(sal_Bool bExpand
) override
;
235 virtual sal_Bool SAL_CALL
gotoStartOfWord(sal_Bool bExpand
) override
;
238 virtual sal_Bool SAL_CALL
isStartOfSentence() override
;
239 virtual sal_Bool SAL_CALL
isEndOfSentence() override
;
240 virtual sal_Bool SAL_CALL
gotoNextSentence(sal_Bool Expand
) override
;
241 virtual sal_Bool SAL_CALL
gotoPreviousSentence(sal_Bool Expand
) override
;
242 virtual sal_Bool SAL_CALL
gotoStartOfSentence(sal_Bool Expand
) override
;
243 virtual sal_Bool SAL_CALL
gotoEndOfSentence(sal_Bool Expand
) override
;
246 virtual sal_Bool SAL_CALL
isStartOfParagraph() override
;
247 virtual sal_Bool SAL_CALL
isEndOfParagraph() override
;
248 virtual sal_Bool SAL_CALL
gotoStartOfParagraph(sal_Bool Expand
) override
;
249 virtual sal_Bool SAL_CALL
gotoEndOfParagraph(sal_Bool Expand
) override
;
250 virtual sal_Bool SAL_CALL
gotoNextParagraph(sal_Bool Expand
) override
;
251 virtual sal_Bool SAL_CALL
gotoPreviousParagraph(sal_Bool Expand
) override
;
254 virtual void SAL_CALL
makeRedline(
255 const OUString
& rRedlineType
,
256 const css::uno::Sequence
< css::beans::PropertyValue
>& RedlineProperties
) override
;
259 virtual void SAL_CALL
invalidateMarkings(::sal_Int32 nType
) override
;
263 SwXTextRange
* pRange
,
264 OTextCursorHelper
* pCursor
,
268 #endif // INCLUDED_SW_INC_UNOTEXTCURSOR_HXX
270 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */