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 #include "unocrsr.hxx"
45 
46 class SwDoc;
47 struct SwPosition;
48 class SwUnoCursor;
50 
51 typedef ::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 
68 class SwXTextCursor final
69  : public SwXTextCursor_Base
70  , public OTextCursorHelper
71 {
72 
73 private:
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 
88 public:
89 
91  SwDoc & rDoc,
92  css::uno::Reference< css::text::XText > const& xParent,
93  const CursorType eType,
94  SwPosition const& rPos,
95  SwPosition const*const pMark = nullptr);
97  css::uno::Reference< css::text::XText > const& 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,
106  const bool bForceExpandHints);
107 
108  // OTextCursorHelper
109  virtual const SwPaM* GetPaM() const override;
110  virtual SwPaM* GetPaM() override;
111  virtual const SwDoc* GetDoc() const override;
112  virtual SwDoc* GetDoc() override;
113 
115 
116  static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
117 
118  // XUnoTunnel
119  virtual sal_Int64 SAL_CALL getSomething(
120  const css::uno::Sequence< sal_Int8 >& rIdentifier) override;
121 
122  // XServiceInfo
123  virtual OUString SAL_CALL getImplementationName() override;
124  virtual sal_Bool SAL_CALL supportsService(
125  const OUString& rServiceName) override;
126  virtual css::uno::Sequence< OUString > SAL_CALL
127  getSupportedServiceNames() override;
128 
129  // XPropertySet
130  virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
131  getPropertySetInfo() override;
132  virtual void SAL_CALL setPropertyValue(
133  const OUString& rPropertyName,
134  const css::uno::Any& rValue) override;
135  virtual css::uno::Any SAL_CALL getPropertyValue(
136  const OUString& rPropertyName) override;
137  virtual void SAL_CALL addPropertyChangeListener(
138  const OUString& rPropertyName,
139  const css::uno::Reference<
140  css::beans::XPropertyChangeListener >& xListener) override;
141  virtual void SAL_CALL removePropertyChangeListener(
142  const OUString& rPropertyName,
143  const css::uno::Reference<
144  css::beans::XPropertyChangeListener >& xListener) override;
145  virtual void SAL_CALL addVetoableChangeListener(
146  const OUString& rPropertyName,
147  const css::uno::Reference<
148  css::beans::XVetoableChangeListener >& xListener) override;
149  virtual void SAL_CALL removeVetoableChangeListener(
150  const OUString& rPropertyName,
151  const css::uno::Reference<
152  css::beans::XVetoableChangeListener >& xListener) override;
153 
154  // XPropertyState
155  virtual css::beans::PropertyState SAL_CALL
156  getPropertyState(const OUString& rPropertyName) override;
157  virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL
159  const css::uno::Sequence< OUString >& rPropertyNames) override;
160  virtual void SAL_CALL setPropertyToDefault(
161  const OUString& rPropertyName) override;
162  virtual css::uno::Any SAL_CALL getPropertyDefault(
163  const OUString& rPropertyName) override;
164 
165  // XMultiPropertySet
166  virtual void SAL_CALL setPropertyValues(
167  const css::uno::Sequence< OUString >& aPropertyNames,
168  const css::uno::Sequence< css::uno::Any >& aValues ) override;
169 
170  virtual css::uno::Sequence< css::uno::Any > SAL_CALL
171  getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override;
172 
173  virtual void SAL_CALL addPropertiesChangeListener(
174  const css::uno::Sequence< OUString >& aPropertyNames,
175  const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
176 
177  virtual void SAL_CALL removePropertiesChangeListener(
178  const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
179 
180  virtual void SAL_CALL firePropertiesChangeEvent(
181  const css::uno::Sequence< OUString >& aPropertyNames,
182  const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
183 
184  // XMultiPropertyStates
185  virtual void SAL_CALL setAllPropertiesToDefault() override;
186  virtual void SAL_CALL setPropertiesToDefault(
187  const css::uno::Sequence< OUString >& rPropertyNames) override;
188  virtual css::uno::Sequence< css::uno::Any >
189  SAL_CALL getPropertyDefaults(
190  const css::uno::Sequence< OUString >& rPropertyNames) override;
191 
192  // XElementAccess
193  virtual css::uno::Type SAL_CALL getElementType() override;
194  virtual sal_Bool SAL_CALL hasElements() override;
195 
196  // XEnumerationAccess
197  virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
198  createEnumeration() override;
199 
200  // XContentEnumerationAccess
201  virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
202  createContentEnumeration(const OUString& rServiceName) override;
203  virtual css::uno::Sequence< OUString > SAL_CALL
204  getAvailableServiceNames() override;
205 
206  // XSortable
207  virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL
208  createSortDescriptor() override;
209  virtual void SAL_CALL sort(
210  const css::uno::Sequence< css::beans::PropertyValue >& xDescriptor) override;
211 
212  // XDocumentInsertable
213  virtual void SAL_CALL insertDocumentFromURL(
214  const OUString& rURL,
215  const css::uno::Sequence< css::beans::PropertyValue >& rOptions) override;
216 
217  // XTextRange
218  virtual css::uno::Reference< css::text::XText >
219  SAL_CALL getText() override;
220  virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override;
221  virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override;
222  virtual OUString SAL_CALL getString() override;
223  virtual void SAL_CALL setString(const OUString& rString) override;
224 
225  // XTextCursor
226  virtual void SAL_CALL collapseToStart() override;
227  virtual void SAL_CALL collapseToEnd() override;
228  virtual sal_Bool SAL_CALL isCollapsed() override;
229  virtual sal_Bool SAL_CALL goLeft(sal_Int16 nCount, sal_Bool bExpand) override;
230  virtual sal_Bool SAL_CALL goRight(sal_Int16 nCount, sal_Bool bExpand) override;
231  virtual void SAL_CALL gotoStart(sal_Bool bExpand) override;
232  virtual void SAL_CALL gotoEnd(sal_Bool bExpand) override;
233  virtual void SAL_CALL gotoRange(
234  const css::uno::Reference< css::text::XTextRange >& xRange,
235  sal_Bool bExpand) override;
236 
237  // XWordCursor
238  virtual sal_Bool SAL_CALL isStartOfWord() override;
239  virtual sal_Bool SAL_CALL isEndOfWord() override;
240  virtual sal_Bool SAL_CALL gotoNextWord(sal_Bool bExpand) override;
241  virtual sal_Bool SAL_CALL gotoPreviousWord(sal_Bool bExpand) override;
242  virtual sal_Bool SAL_CALL gotoEndOfWord(sal_Bool bExpand) override;
243  virtual sal_Bool SAL_CALL gotoStartOfWord(sal_Bool bExpand) override;
244 
245  // XSentenceCursor
246  virtual sal_Bool SAL_CALL isStartOfSentence() override;
247  virtual sal_Bool SAL_CALL isEndOfSentence() override;
248  virtual sal_Bool SAL_CALL gotoNextSentence(sal_Bool Expand) override;
249  virtual sal_Bool SAL_CALL gotoPreviousSentence(sal_Bool Expand) override;
250  virtual sal_Bool SAL_CALL gotoStartOfSentence(sal_Bool Expand) override;
251  virtual sal_Bool SAL_CALL gotoEndOfSentence(sal_Bool Expand) override;
252 
253  // XParagraphCursor
254  virtual sal_Bool SAL_CALL isStartOfParagraph() override;
255  virtual sal_Bool SAL_CALL isEndOfParagraph() override;
256  virtual sal_Bool SAL_CALL gotoStartOfParagraph(sal_Bool Expand) override;
257  virtual sal_Bool SAL_CALL gotoEndOfParagraph(sal_Bool Expand) override;
258  virtual sal_Bool SAL_CALL gotoNextParagraph(sal_Bool Expand) override;
259  virtual sal_Bool SAL_CALL gotoPreviousParagraph(sal_Bool Expand) override;
260 
261  // XRedline
262  virtual void SAL_CALL makeRedline(
263  const OUString& rRedlineType,
264  const css::uno::Sequence< css::beans::PropertyValue >& RedlineProperties) override;
265 
266  //XMarkingAccess
267  virtual void SAL_CALL invalidateMarkings(::sal_Int32 nType) override;
268 
269 };
270 
271 #endif // INCLUDED_SW_INC_UNOTEXTCURSOR_HXX
272 
273 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL invalidateMarkings(::sal_Int32 nType) override
Definition: unoobj.cxx:2465
sw::UnoCursorPointer m_pUnoCursor
Type
virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2299
virtual sal_Bool SAL_CALL goLeft(sal_Int16 nCount, sal_Bool bExpand) override
Definition: unoobj.cxx:941
virtual OUString SAL_CALL getImplementationName() override
Definition: unoobj.cxx:857
virtual sal_Bool SAL_CALL gotoEndOfSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1519
Marks a position in the document model.
Definition: pam.hxx:36
virtual sal_Bool SAL_CALL gotoStartOfParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1565
::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:2913
virtual sal_Bool SAL_CALL isStartOfParagraph() override
Definition: unoobj.cxx:1543
virtual sal_Bool SAL_CALL goRight(sal_Int16 nCount, sal_Bool bExpand) override
Definition: unoobj.cxx:959
CursorType
virtual sal_Bool SAL_CALL isEndOfWord() override
Definition: unoobj.cxx:1215
signed char sal_Int8
virtual const SwDoc * GetDoc() const override
Definition: unoobj.cxx:663
virtual sal_Bool SAL_CALL gotoPreviousWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1274
Definition: doc.hxx:187
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
Definition: unoobj.cxx:889
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoobj.cxx:2180
void DeleteAndInsert(OUString const &rText, const bool bForceExpandHints)
Definition: unoobj.cxx:707
bool IsAtEndOfMeta() const
Definition: unoobj.cxx:791
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:1647
virtual sal_Bool SAL_CALL gotoPreviousSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1468
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: unoobj.cxx:1655
virtual sal_Bool SAL_CALL gotoNextWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1227
virtual void SAL_CALL setPropertyToDefault(const OUString &rPropertyName) override
Definition: unoobj.cxx:2220
virtual void SAL_CALL sort(const css::uno::Sequence< css::beans::PropertyValue > &xDescriptor) override
Definition: unoobj.cxx:2834
virtual sal_Bool SAL_CALL gotoStartOfSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1496
virtual void SAL_CALL collapseToStart() override
Definition: unoobj.cxx:895
virtual sal_Bool SAL_CALL gotoEndOfWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1314
const CursorType m_eType
virtual sal_Bool SAL_CALL isEndOfParagraph() override
Definition: unoobj.cxx:1554
SwUnoCursor & GetCursorOrThrow()
const SfxItemPropertySet & m_rPropSet
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: unoobj.cxx:1681
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: unoobj.cxx:2924
SwXTextCursor(SwDoc &rDoc, css::uno::Reference< css::text::XText > const &xParent, const CursorType eType, SwPosition const &rPos, SwPosition const *const pMark=nullptr)
bool IsAtEndOfContentControl() const
Definition: unoobj.cxx:821
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoobj.cxx:2918
virtual void SAL_CALL setString(const OUString &rString) override
Definition: unoobj.cxx:1718
virtual sal_Bool SAL_CALL gotoNextSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1433
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL createSortDescriptor() override
Definition: unoobj.cxx:2575
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoobj.cxx:2164
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
virtual void SAL_CALL setPropertiesToDefault(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj.cxx:2362
virtual OUString SAL_CALL getString() override
Definition: unoobj.cxx:1706
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &rPropertyName) override
Definition: unoobj.cxx:2196
virtual ~SwXTextCursor() override
Definition: unoobj.cxx:701
virtual const SwPaM * GetPaM() const override
Definition: unoobj.cxx:657
virtual void SAL_CALL gotoStart(sal_Bool bExpand) override
Definition: unoobj.cxx:977
virtual sal_Bool SAL_CALL isCollapsed() override
Definition: unoobj.cxx:927
unsigned char sal_Bool
virtual sal_Bool SAL_CALL isStartOfSentence() override
Definition: unoobj.cxx:1386
virtual void SAL_CALL gotoRange(const css::uno::Reference< css::text::XTextRange > &xRange, sal_Bool bExpand) override
Definition: unoobj.cxx:1062
virtual void SAL_CALL makeRedline(const OUString &rRedlineType, const css::uno::Sequence< css::beans::PropertyValue > &RedlineProperties) override
Definition: unoobj.cxx:2503
virtual sal_Bool SAL_CALL gotoPreviousParagraph(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:2208
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: unoobj.cxx:2278
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unoobj.cxx:2888
SwUnoCursor & GetCursor()
Definition: unoobj.cxx:654
virtual sal_Bool SAL_CALL gotoStartOfWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1350
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:2514
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2287
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoobj.cxx:882
virtual sal_Bool SAL_CALL gotoEndOfParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1590
virtual sal_Bool SAL_CALL isEndOfSentence() override
Definition: unoobj.cxx:1409
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createContentEnumeration(const OUString &rServiceName) override
Definition: unoobj.cxx:2878
virtual void SAL_CALL collapseToEnd() override
Definition: unoobj.cxx:911
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Sequence< css::uno::Any > &aValues) override
Definition: unoobj.cxx:2235
virtual void SAL_CALL setAllPropertiesToDefault() override
Definition: unoobj.cxx:2340
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2293
virtual sal_Bool SAL_CALL gotoNextParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1615
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoobj.cxx:2188
const css::uno::Reference< css::text::XText > m_xParentText
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoobj.cxx:862
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unoobj.cxx:2138
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoobj.cxx:2172
virtual sal_Bool SAL_CALL isStartOfWord() override
Definition: unoobj.cxx:1204
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoobj.cxx:868
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &rPropertyName) override
Definition: unoobj.cxx:2228
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj.cxx:2425
virtual void SAL_CALL gotoEnd(sal_Bool bExpand) override
Definition: unoobj.cxx:1034
#define DECLARE_XINTERFACE()