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 
38 #include <cppuhelper/implbase.hxx>
39 
40 #include <comphelper/uno3.hxx>
41 
42 #include "unobaseclass.hxx"
43 #include "TextCursorHelper.hxx"
44 
45 class SwDoc;
46 struct SwPosition;
48 
49 typedef ::cppu::WeakImplHelper
50 < css::lang::XServiceInfo
51 , css::beans::XPropertySet
52 , css::beans::XPropertyState
53 , css::beans::XMultiPropertySet
54 , css::beans::XMultiPropertyStates
55 , css::container::XEnumerationAccess
56 , css::container::XContentEnumerationAccess
57 , css::util::XSortable
58 , css::document::XDocumentInsertable
59 , css::text::XSentenceCursor
60 , css::text::XWordCursor
61 , css::text::XParagraphCursor
62 , css::text::XRedline
63 , css::text::XMarkingAccess
65 
67  : public SwXTextCursor_Base
68  , public OTextCursorHelper
69 {
70 
71 private:
72 
73  class Impl;
75 
76  virtual ~SwXTextCursor() override;
77 
78 public:
79 
81  SwDoc & rDoc,
82  css::uno::Reference< css::text::XText > const& xParent,
83  const CursorType eType,
84  SwPosition const& rPos,
85  SwPosition const*const pMark = nullptr);
87  css::uno::Reference< css::text::XText > const& xParent,
88  SwPaM const& rSourceCursor,
89  const CursorType eType = CursorType::All);
90 
92  bool IsAtEndOfMeta() const;
93 
94  void DeleteAndInsert(OUString const& rText,
95  const bool bForceExpandHints);
96 
97  // OTextCursorHelper
98  virtual const SwPaM* GetPaM() const override;
99  virtual SwPaM* GetPaM() override;
100  virtual const SwDoc* GetDoc() const override;
101  virtual SwDoc* GetDoc() override;
102 
104 
105  static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
106 
107  // XUnoTunnel
108  virtual sal_Int64 SAL_CALL getSomething(
109  const css::uno::Sequence< sal_Int8 >& rIdentifier) override;
110 
111  // XServiceInfo
112  virtual OUString SAL_CALL getImplementationName() override;
113  virtual sal_Bool SAL_CALL supportsService(
114  const OUString& rServiceName) override;
115  virtual css::uno::Sequence< OUString > SAL_CALL
116  getSupportedServiceNames() override;
117 
118  // XPropertySet
119  virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
120  getPropertySetInfo() override;
121  virtual void SAL_CALL setPropertyValue(
122  const OUString& rPropertyName,
123  const css::uno::Any& rValue) override;
124  virtual css::uno::Any SAL_CALL getPropertyValue(
125  const OUString& rPropertyName) override;
126  virtual void SAL_CALL addPropertyChangeListener(
127  const OUString& rPropertyName,
128  const css::uno::Reference<
129  css::beans::XPropertyChangeListener >& xListener) override;
130  virtual void SAL_CALL removePropertyChangeListener(
131  const OUString& rPropertyName,
132  const css::uno::Reference<
133  css::beans::XPropertyChangeListener >& xListener) override;
134  virtual void SAL_CALL addVetoableChangeListener(
135  const OUString& rPropertyName,
136  const css::uno::Reference<
137  css::beans::XVetoableChangeListener >& xListener) override;
138  virtual void SAL_CALL removeVetoableChangeListener(
139  const OUString& rPropertyName,
140  const css::uno::Reference<
141  css::beans::XVetoableChangeListener >& xListener) override;
142 
143  // XPropertyState
144  virtual css::beans::PropertyState SAL_CALL
145  getPropertyState(const OUString& rPropertyName) override;
146  virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL
148  const css::uno::Sequence< OUString >& rPropertyNames) override;
149  virtual void SAL_CALL setPropertyToDefault(
150  const OUString& rPropertyName) override;
151  virtual css::uno::Any SAL_CALL getPropertyDefault(
152  const OUString& rPropertyName) override;
153 
154  // XMultiPropertySet
155  virtual void SAL_CALL setPropertyValues(
156  const css::uno::Sequence< OUString >& aPropertyNames,
157  const css::uno::Sequence< css::uno::Any >& aValues ) override;
158 
159  virtual css::uno::Sequence< css::uno::Any > SAL_CALL
160  getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override;
161 
162  virtual void SAL_CALL addPropertiesChangeListener(
163  const css::uno::Sequence< OUString >& aPropertyNames,
164  const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
165 
166  virtual void SAL_CALL removePropertiesChangeListener(
167  const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
168 
169  virtual void SAL_CALL firePropertiesChangeEvent(
170  const css::uno::Sequence< OUString >& aPropertyNames,
171  const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
172 
173  // XMultiPropertyStates
174  virtual void SAL_CALL setAllPropertiesToDefault() override;
175  virtual void SAL_CALL setPropertiesToDefault(
176  const css::uno::Sequence< OUString >& rPropertyNames) override;
177  virtual css::uno::Sequence< css::uno::Any >
178  SAL_CALL getPropertyDefaults(
179  const css::uno::Sequence< OUString >& rPropertyNames) override;
180 
181  // XElementAccess
182  virtual css::uno::Type SAL_CALL getElementType() override;
183  virtual sal_Bool SAL_CALL hasElements() override;
184 
185  // XEnumerationAccess
186  virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
187  createEnumeration() override;
188 
189  // XContentEnumerationAccess
190  virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
191  createContentEnumeration(const OUString& rServiceName) override;
192  virtual css::uno::Sequence< OUString > SAL_CALL
193  getAvailableServiceNames() override;
194 
195  // XSortable
196  virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL
197  createSortDescriptor() override;
198  virtual void SAL_CALL sort(
199  const css::uno::Sequence< css::beans::PropertyValue >& xDescriptor) override;
200 
201  // XDocumentInsertable
202  virtual void SAL_CALL insertDocumentFromURL(
203  const OUString& rURL,
204  const css::uno::Sequence< css::beans::PropertyValue >& rOptions) override;
205 
206  // XTextRange
207  virtual css::uno::Reference< css::text::XText >
208  SAL_CALL getText() override;
209  virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override;
210  virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override;
211  virtual OUString SAL_CALL getString() override;
212  virtual void SAL_CALL setString(const OUString& rString) override;
213 
214  // XTextCursor
215  virtual void SAL_CALL collapseToStart() override;
216  virtual void SAL_CALL collapseToEnd() override;
217  virtual sal_Bool SAL_CALL isCollapsed() override;
218  virtual sal_Bool SAL_CALL goLeft(sal_Int16 nCount, sal_Bool bExpand) override;
219  virtual sal_Bool SAL_CALL goRight(sal_Int16 nCount, sal_Bool bExpand) override;
220  virtual void SAL_CALL gotoStart(sal_Bool bExpand) override;
221  virtual void SAL_CALL gotoEnd(sal_Bool bExpand) override;
222  virtual void SAL_CALL gotoRange(
223  const css::uno::Reference< css::text::XTextRange >& xRange,
224  sal_Bool bExpand) override;
225 
226  // XWordCursor
227  virtual sal_Bool SAL_CALL isStartOfWord() override;
228  virtual sal_Bool SAL_CALL isEndOfWord() override;
229  virtual sal_Bool SAL_CALL gotoNextWord(sal_Bool bExpand) override;
230  virtual sal_Bool SAL_CALL gotoPreviousWord(sal_Bool bExpand) override;
231  virtual sal_Bool SAL_CALL gotoEndOfWord(sal_Bool bExpand) override;
232  virtual sal_Bool SAL_CALL gotoStartOfWord(sal_Bool bExpand) override;
233 
234  // XSentenceCursor
235  virtual sal_Bool SAL_CALL isStartOfSentence() override;
236  virtual sal_Bool SAL_CALL isEndOfSentence() override;
237  virtual sal_Bool SAL_CALL gotoNextSentence(sal_Bool Expand) override;
238  virtual sal_Bool SAL_CALL gotoPreviousSentence(sal_Bool Expand) override;
239  virtual sal_Bool SAL_CALL gotoStartOfSentence(sal_Bool Expand) override;
240  virtual sal_Bool SAL_CALL gotoEndOfSentence(sal_Bool Expand) override;
241 
242  // XParagraphCursor
243  virtual sal_Bool SAL_CALL isStartOfParagraph() override;
244  virtual sal_Bool SAL_CALL isEndOfParagraph() override;
245  virtual sal_Bool SAL_CALL gotoStartOfParagraph(sal_Bool Expand) override;
246  virtual sal_Bool SAL_CALL gotoEndOfParagraph(sal_Bool Expand) override;
247  virtual sal_Bool SAL_CALL gotoNextParagraph(sal_Bool Expand) override;
248  virtual sal_Bool SAL_CALL gotoPreviousParagraph(sal_Bool Expand) override;
249 
250  // XRedline
251  virtual void SAL_CALL makeRedline(
252  const OUString& rRedlineType,
253  const css::uno::Sequence< css::beans::PropertyValue >& RedlineProperties) override;
254 
255  //XMarkingAccess
256  virtual void SAL_CALL invalidateMarkings(::sal_Int32 nType) override;
257 
258 };
259 
260 #endif // INCLUDED_SW_INC_UNOTEXTCURSOR_HXX
261 
262 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL invalidateMarkings(::sal_Int32 nType) override
Definition: unoobj.cxx:2457
Type
virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2289
virtual sal_Bool SAL_CALL goLeft(sal_Int16 nCount, sal_Bool bExpand) override
Definition: unoobj.cxx:927
virtual OUString SAL_CALL getImplementationName() override
Definition: unoobj.cxx:833
::sw::UnoImplPtr< Impl > m_pImpl
virtual sal_Bool SAL_CALL gotoEndOfSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1511
Marks a position in the document model.
Definition: pam.hxx:35
virtual sal_Bool SAL_CALL gotoStartOfParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1557
::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
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unoobj.cxx:2933
virtual sal_Bool SAL_CALL isStartOfParagraph() override
Definition: unoobj.cxx:1535
virtual sal_Bool SAL_CALL goRight(sal_Int16 nCount, sal_Bool bExpand) override
Definition: unoobj.cxx:945
CursorType
virtual sal_Bool SAL_CALL isEndOfWord() override
Definition: unoobj.cxx:1207
signed char sal_Int8
virtual const SwDoc * GetDoc() const override
Definition: unoobj.cxx:695
virtual sal_Bool SAL_CALL gotoPreviousWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1266
Definition: doc.hxx:185
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
Definition: unoobj.cxx:875
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoobj.cxx:2171
void DeleteAndInsert(OUString const &rText, const bool bForceExpandHints)
Definition: unoobj.cxx:723
bool IsAtEndOfMeta() const
Definition: unoobj.cxx:803
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unoobj.cxx:2072
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: unoobj.cxx:1639
virtual sal_Bool SAL_CALL gotoPreviousSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1460
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: unoobj.cxx:1647
virtual sal_Bool SAL_CALL gotoNextWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1219
virtual void SAL_CALL setPropertyToDefault(const OUString &rPropertyName) override
Definition: unoobj.cxx:2211
virtual void SAL_CALL sort(const css::uno::Sequence< css::beans::PropertyValue > &xDescriptor) override
Definition: unoobj.cxx:2843
virtual sal_Bool SAL_CALL gotoStartOfSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1488
virtual void SAL_CALL collapseToStart() override
Definition: unoobj.cxx:881
virtual sal_Bool SAL_CALL gotoEndOfWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1306
virtual sal_Bool SAL_CALL isEndOfParagraph() override
Definition: unoobj.cxx:1546
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: unoobj.cxx:1673
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: unoobj.cxx:2944
std::unique_ptr< T, UnoImplPtrDeleter< T > > UnoImplPtr
Smart pointer class ensuring that the pointed object is deleted with a locked SolarMutex.
SwXTextCursor(SwDoc &rDoc, css::uno::Reference< css::text::XText > const &xParent, const CursorType eType, SwPosition const &rPos, SwPosition const *const pMark=nullptr)
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoobj.cxx:2938
virtual void SAL_CALL setString(const OUString &rString) override
Definition: unoobj.cxx:1710
virtual sal_Bool SAL_CALL gotoNextSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1425
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL createSortDescriptor() override
Definition: unoobj.cxx:2583
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoobj.cxx:2155
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
virtual void SAL_CALL setPropertiesToDefault(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj.cxx:2352
virtual OUString SAL_CALL getString() override
Definition: unoobj.cxx:1698
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &rPropertyName) override
Definition: unoobj.cxx:2187
virtual ~SwXTextCursor() override
Definition: unoobj.cxx:719
virtual const SwPaM * GetPaM() const override
Definition: unoobj.cxx:689
virtual void SAL_CALL gotoStart(sal_Bool bExpand) override
Definition: unoobj.cxx:963
virtual sal_Bool SAL_CALL isCollapsed() override
Definition: unoobj.cxx:913
unsigned char sal_Bool
virtual sal_Bool SAL_CALL isStartOfSentence() override
Definition: unoobj.cxx:1378
virtual void SAL_CALL gotoRange(const css::uno::Reference< css::text::XTextRange > &xRange, sal_Bool bExpand) override
Definition: unoobj.cxx:1048
virtual void SAL_CALL makeRedline(const OUString &rRedlineType, const css::uno::Sequence< css::beans::PropertyValue > &RedlineProperties) override
Definition: unoobj.cxx:2495
virtual sal_Bool SAL_CALL gotoPreviousParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1623
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj.cxx:2199
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: unoobj.cxx:2268
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unoobj.cxx:2897
SwUnoCursor & GetCursor()
Definition: unoobj.cxx:686
virtual sal_Bool SAL_CALL gotoStartOfWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1342
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unoobj.cxx:2096
virtual void SAL_CALL insertDocumentFromURL(const OUString &rURL, const css::uno::Sequence< css::beans::PropertyValue > &rOptions) override
Definition: unoobj.cxx:2506
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2277
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoobj.cxx:869
virtual sal_Bool SAL_CALL gotoEndOfParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1582
virtual sal_Bool SAL_CALL isEndOfSentence() override
Definition: unoobj.cxx:1401
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createContentEnumeration(const OUString &rServiceName) override
Definition: unoobj.cxx:2887
virtual void SAL_CALL collapseToEnd() override
Definition: unoobj.cxx:897
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Sequence< css::uno::Any > &aValues) override
Definition: unoobj.cxx:2226
virtual void SAL_CALL setAllPropertiesToDefault() override
Definition: unoobj.cxx:2330
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2283
virtual sal_Bool SAL_CALL gotoNextParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1607
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoobj.cxx:2179
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoobj.cxx:852
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unoobj.cxx:2129
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoobj.cxx:2163
virtual sal_Bool SAL_CALL isStartOfWord() override
Definition: unoobj.cxx:1196
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoobj.cxx:858
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &rPropertyName) override
Definition: unoobj.cxx:2219
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj.cxx:2417
virtual void SAL_CALL gotoEnd(sal_Bool bExpand) override
Definition: unoobj.cxx:1020
#define DECLARE_XINTERFACE()