1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef SW_UNOTEXTCURSOR_HXX 29 #define SW_UNOTEXTCURSOR_HXX 30 31 #include <com/sun/star/lang/XUnoTunnel.hpp> 32 #include <com/sun/star/lang/XServiceInfo.hpp> 33 #include <com/sun/star/beans/XPropertySet.hpp> 34 #include <com/sun/star/beans/XPropertyState.hpp> 35 #include <com/sun/star/beans/XMultiPropertyStates.hpp> 36 #include <com/sun/star/container/XEnumerationAccess.hpp> 37 #include <com/sun/star/container/XContentEnumerationAccess.hpp> 38 #include <com/sun/star/util/XSortable.hpp> 39 #include <com/sun/star/document/XDocumentInsertable.hpp> 40 #include <com/sun/star/text/XSentenceCursor.hpp> 41 #include <com/sun/star/text/XWordCursor.hpp> 42 #include <com/sun/star/text/XParagraphCursor.hpp> 43 #include <com/sun/star/text/XRedline.hpp> 44 45 #include <cppuhelper/implbase12.hxx> 46 47 #include <comphelper/uno3.hxx> 48 49 #include <unobaseclass.hxx> 50 #include <TextCursorHelper.hxx> 51 52 53 class SwDoc; 54 struct SwPosition; 55 class SwUnoCrsr; 56 57 58 typedef ::cppu::WeakImplHelper12 59 < ::com::sun::star::lang::XServiceInfo 60 , ::com::sun::star::beans::XPropertySet 61 , ::com::sun::star::beans::XPropertyState 62 , ::com::sun::star::beans::XMultiPropertyStates 63 , ::com::sun::star::container::XEnumerationAccess 64 , ::com::sun::star::container::XContentEnumerationAccess 65 , ::com::sun::star::util::XSortable 66 , ::com::sun::star::document::XDocumentInsertable 67 , ::com::sun::star::text::XSentenceCursor 68 , ::com::sun::star::text::XWordCursor 69 , ::com::sun::star::text::XParagraphCursor 70 , ::com::sun::star::text::XRedline 71 > SwXTextCursor_Base; 72 73 class SwXTextCursor 74 : public SwXTextCursor_Base 75 , public OTextCursorHelper 76 { 77 78 private: 79 80 class Impl; 81 ::sw::UnoImplPtr<Impl> m_pImpl; 82 83 virtual ~SwXTextCursor(); 84 85 public: 86 87 SwXTextCursor( 88 SwDoc & rDoc, 89 ::com::sun::star::uno::Reference< 90 ::com::sun::star::text::XText > const& xParent, 91 const enum CursorType eType, 92 SwPosition const& rPos, 93 SwPosition const*const pMark = 0); 94 SwXTextCursor( 95 ::com::sun::star::uno::Reference< 96 ::com::sun::star::text::XText > const& xParent, 97 SwPaM const& rSourceCursor, 98 const enum CursorType eType = CURSOR_ALL); 99 100 SwUnoCrsr * GetCursor(); 101 const SwUnoCrsr * GetCursor() const; 102 103 bool IsAtEndOfMeta() const; 104 105 void DeleteAndInsert(::rtl::OUString const& rText, 106 const bool bForceExpandHints); 107 108 // OTextCursorHelper 109 virtual const SwPaM* GetPaM() const; 110 virtual SwPaM* GetPaM(); 111 virtual const SwDoc* GetDoc() const; 112 virtual SwDoc* GetDoc(); 113 114 DECLARE_XINTERFACE() 115 116 static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); 117 118 // XUnoTunnel 119 virtual sal_Int64 SAL_CALL getSomething( 120 const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) 121 throw (::com::sun::star::uno::RuntimeException); 122 123 // XServiceInfo 124 virtual ::rtl::OUString SAL_CALL getImplementationName() 125 throw (::com::sun::star::uno::RuntimeException); 126 virtual sal_Bool SAL_CALL supportsService( 127 const ::rtl::OUString& rServiceName) 128 throw (::com::sun::star::uno::RuntimeException); 129 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL 130 getSupportedServiceNames() 131 throw (::com::sun::star::uno::RuntimeException); 132 133 // XPropertySet 134 virtual ::com::sun::star::uno::Reference< 135 ::com::sun::star::beans::XPropertySetInfo > SAL_CALL 136 getPropertySetInfo() 137 throw (::com::sun::star::uno::RuntimeException); 138 virtual void SAL_CALL setPropertyValue( 139 const ::rtl::OUString& rPropertyName, 140 const ::com::sun::star::uno::Any& rValue) 141 throw (::com::sun::star::beans::UnknownPropertyException, 142 ::com::sun::star::beans::PropertyVetoException, 143 ::com::sun::star::lang::IllegalArgumentException, 144 ::com::sun::star::lang::WrappedTargetException, 145 ::com::sun::star::uno::RuntimeException); 146 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( 147 const ::rtl::OUString& rPropertyName) 148 throw (::com::sun::star::beans::UnknownPropertyException, 149 ::com::sun::star::lang::WrappedTargetException, 150 ::com::sun::star::uno::RuntimeException); 151 virtual void SAL_CALL addPropertyChangeListener( 152 const ::rtl::OUString& rPropertyName, 153 const ::com::sun::star::uno::Reference< 154 ::com::sun::star::beans::XPropertyChangeListener >& xListener) 155 throw (::com::sun::star::beans::UnknownPropertyException, 156 ::com::sun::star::lang::WrappedTargetException, 157 ::com::sun::star::uno::RuntimeException); 158 virtual void SAL_CALL removePropertyChangeListener( 159 const ::rtl::OUString& rPropertyName, 160 const ::com::sun::star::uno::Reference< 161 ::com::sun::star::beans::XPropertyChangeListener >& xListener) 162 throw (::com::sun::star::beans::UnknownPropertyException, 163 ::com::sun::star::lang::WrappedTargetException, 164 ::com::sun::star::uno::RuntimeException); 165 virtual void SAL_CALL addVetoableChangeListener( 166 const ::rtl::OUString& rPropertyName, 167 const ::com::sun::star::uno::Reference< 168 ::com::sun::star::beans::XVetoableChangeListener >& xListener) 169 throw (::com::sun::star::beans::UnknownPropertyException, 170 ::com::sun::star::lang::WrappedTargetException, 171 ::com::sun::star::uno::RuntimeException); 172 virtual void SAL_CALL removeVetoableChangeListener( 173 const ::rtl::OUString& rPropertyName, 174 const ::com::sun::star::uno::Reference< 175 ::com::sun::star::beans::XVetoableChangeListener >& xListener) 176 throw (::com::sun::star::beans::UnknownPropertyException, 177 ::com::sun::star::lang::WrappedTargetException, 178 ::com::sun::star::uno::RuntimeException); 179 180 // XPropertyState 181 virtual ::com::sun::star::beans::PropertyState SAL_CALL 182 getPropertyState(const ::rtl::OUString& rPropertyName) 183 throw (::com::sun::star::beans::UnknownPropertyException, 184 ::com::sun::star::uno::RuntimeException); 185 virtual ::com::sun::star::uno::Sequence< 186 ::com::sun::star::beans::PropertyState > SAL_CALL 187 getPropertyStates( 188 const ::com::sun::star::uno::Sequence< 189 ::rtl::OUString >& rPropertyNames) 190 throw (::com::sun::star::beans::UnknownPropertyException, 191 ::com::sun::star::uno::RuntimeException); 192 virtual void SAL_CALL setPropertyToDefault( 193 const ::rtl::OUString& rPropertyName) 194 throw (::com::sun::star::beans::UnknownPropertyException, 195 ::com::sun::star::uno::RuntimeException); 196 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( 197 const ::rtl::OUString& rPropertyName) 198 throw (::com::sun::star::beans::UnknownPropertyException, 199 ::com::sun::star::lang::WrappedTargetException, 200 ::com::sun::star::uno::RuntimeException); 201 202 // XMultiPropertyStates 203 virtual void SAL_CALL setAllPropertiesToDefault() 204 throw (::com::sun::star::uno::RuntimeException); 205 virtual void SAL_CALL setPropertiesToDefault( 206 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& 207 rPropertyNames) 208 throw (::com::sun::star::beans::UnknownPropertyException, 209 ::com::sun::star::uno::RuntimeException); 210 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > 211 SAL_CALL getPropertyDefaults( 212 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& 213 rPropertyNames) 214 throw (::com::sun::star::beans::UnknownPropertyException, 215 ::com::sun::star::lang::WrappedTargetException, 216 ::com::sun::star::uno::RuntimeException); 217 218 // XElementAccess 219 virtual ::com::sun::star::uno::Type SAL_CALL getElementType() 220 throw (::com::sun::star::uno::RuntimeException); 221 virtual sal_Bool SAL_CALL hasElements() 222 throw (::com::sun::star::uno::RuntimeException); 223 224 // XEnumerationAccess 225 virtual ::com::sun::star::uno::Reference< 226 ::com::sun::star::container::XEnumeration > SAL_CALL 227 createEnumeration() 228 throw (::com::sun::star::uno::RuntimeException); 229 230 // XContentEnumerationAccess 231 virtual ::com::sun::star::uno::Reference< 232 ::com::sun::star::container::XEnumeration > SAL_CALL 233 createContentEnumeration(const ::rtl::OUString& rServiceName) 234 throw (::com::sun::star::uno::RuntimeException); 235 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL 236 getAvailableServiceNames() 237 throw (::com::sun::star::uno::RuntimeException); 238 239 // XSortable 240 virtual ::com::sun::star::uno::Sequence< 241 ::com::sun::star::beans::PropertyValue > SAL_CALL 242 createSortDescriptor() 243 throw (::com::sun::star::uno::RuntimeException); 244 virtual void SAL_CALL sort( 245 const ::com::sun::star::uno::Sequence< 246 ::com::sun::star::beans::PropertyValue >& xDescriptor) 247 throw (::com::sun::star::uno::RuntimeException); 248 249 // XDocumentInsertable 250 virtual void SAL_CALL insertDocumentFromURL( 251 const ::rtl::OUString& rURL, 252 const ::com::sun::star::uno::Sequence< 253 ::com::sun::star::beans::PropertyValue >& rOptions) 254 throw (::com::sun::star::lang::IllegalArgumentException, 255 ::com::sun::star::io::IOException, 256 ::com::sun::star::uno::RuntimeException); 257 258 // XTextRange 259 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > 260 SAL_CALL getText() 261 throw (::com::sun::star::uno::RuntimeException); 262 virtual ::com::sun::star::uno::Reference< 263 ::com::sun::star::text::XTextRange > SAL_CALL getStart() 264 throw (::com::sun::star::uno::RuntimeException); 265 virtual ::com::sun::star::uno::Reference< 266 ::com::sun::star::text::XTextRange > SAL_CALL getEnd() 267 throw (::com::sun::star::uno::RuntimeException); 268 virtual ::rtl::OUString SAL_CALL getString() 269 throw (::com::sun::star::uno::RuntimeException); 270 virtual void SAL_CALL setString(const ::rtl::OUString& rString) 271 throw (::com::sun::star::uno::RuntimeException); 272 273 // XTextCursor 274 virtual void SAL_CALL collapseToStart() 275 throw (::com::sun::star::uno::RuntimeException); 276 virtual void SAL_CALL collapseToEnd() 277 throw (::com::sun::star::uno::RuntimeException); 278 virtual sal_Bool SAL_CALL isCollapsed() 279 throw (::com::sun::star::uno::RuntimeException); 280 virtual sal_Bool SAL_CALL goLeft(sal_Int16 nCount, sal_Bool bExpand) 281 throw (::com::sun::star::uno::RuntimeException); 282 virtual sal_Bool SAL_CALL goRight(sal_Int16 nCount, sal_Bool bExpand) 283 throw (::com::sun::star::uno::RuntimeException); 284 virtual void SAL_CALL gotoStart(sal_Bool bExpand) 285 throw (::com::sun::star::uno::RuntimeException); 286 virtual void SAL_CALL gotoEnd(sal_Bool bExpand) 287 throw (::com::sun::star::uno::RuntimeException); 288 virtual void SAL_CALL gotoRange( 289 const ::com::sun::star::uno::Reference< 290 ::com::sun::star::text::XTextRange >& xRange, 291 sal_Bool bExpand) 292 throw (::com::sun::star::uno::RuntimeException); 293 294 // XWordCursor 295 virtual sal_Bool SAL_CALL isStartOfWord() 296 throw (::com::sun::star::uno::RuntimeException); 297 virtual sal_Bool SAL_CALL isEndOfWord() 298 throw (::com::sun::star::uno::RuntimeException); 299 virtual sal_Bool SAL_CALL gotoNextWord(sal_Bool bExpand) 300 throw (::com::sun::star::uno::RuntimeException); 301 virtual sal_Bool SAL_CALL gotoPreviousWord(sal_Bool bExpand) 302 throw (::com::sun::star::uno::RuntimeException); 303 virtual sal_Bool SAL_CALL gotoEndOfWord(sal_Bool bExpand) 304 throw (::com::sun::star::uno::RuntimeException); 305 virtual sal_Bool SAL_CALL gotoStartOfWord(sal_Bool bExpand) 306 throw (::com::sun::star::uno::RuntimeException); 307 308 // XSentenceCursor 309 virtual sal_Bool SAL_CALL isStartOfSentence() 310 throw (::com::sun::star::uno::RuntimeException); 311 virtual sal_Bool SAL_CALL isEndOfSentence() 312 throw (::com::sun::star::uno::RuntimeException); 313 virtual sal_Bool SAL_CALL gotoNextSentence(sal_Bool Expand) 314 throw (::com::sun::star::uno::RuntimeException); 315 virtual sal_Bool SAL_CALL gotoPreviousSentence(sal_Bool Expand) 316 throw (::com::sun::star::uno::RuntimeException); 317 virtual sal_Bool SAL_CALL gotoStartOfSentence(sal_Bool Expand) 318 throw (::com::sun::star::uno::RuntimeException); 319 virtual sal_Bool SAL_CALL gotoEndOfSentence(sal_Bool Expand) 320 throw (::com::sun::star::uno::RuntimeException); 321 322 // XParagraphCursor 323 virtual sal_Bool SAL_CALL isStartOfParagraph() 324 throw (::com::sun::star::uno::RuntimeException); 325 virtual sal_Bool SAL_CALL isEndOfParagraph() 326 throw (::com::sun::star::uno::RuntimeException); 327 virtual sal_Bool SAL_CALL gotoStartOfParagraph(sal_Bool Expand) 328 throw (::com::sun::star::uno::RuntimeException); 329 virtual sal_Bool SAL_CALL gotoEndOfParagraph(sal_Bool Expand) 330 throw (::com::sun::star::uno::RuntimeException); 331 virtual sal_Bool SAL_CALL gotoNextParagraph(sal_Bool Expand) 332 throw (::com::sun::star::uno::RuntimeException); 333 virtual sal_Bool SAL_CALL gotoPreviousParagraph(sal_Bool Expand) 334 throw (::com::sun::star::uno::RuntimeException); 335 336 // XRedline 337 virtual void SAL_CALL makeRedline( 338 const ::rtl::OUString& rRedlineType, 339 const ::com::sun::star::uno::Sequence< 340 ::com::sun::star::beans::PropertyValue >& RedlineProperties) 341 throw (::com::sun::star::lang::IllegalArgumentException, 342 ::com::sun::star::uno::RuntimeException); 343 344 }; 345 346 #endif // SW_UNOTEXTCURSOR_HXX 347 348