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_UNOTEXTRANGE_HXX 29 #define SW_UNOTEXTRANGE_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/container/XIndexAccess.hpp> 36 #include <com/sun/star/container/XEnumerationAccess.hpp> 37 #include <com/sun/star/container/XContentEnumerationAccess.hpp> 38 #include <com/sun/star/text/XTextRange.hpp> 39 #include <com/sun/star/text/XRedline.hpp> 40 41 #include <cppuhelper/implbase3.hxx> 42 #include <cppuhelper/implbase8.hxx> 43 44 #include <pam.hxx> 45 #include <unobaseclass.hxx> 46 47 48 class SwDoc; 49 struct SwPosition; 50 class SwPaM; 51 class SwUnoCrsr; 52 class SwFrmFmt; 53 54 /* -----------------29.04.98 07:35------------------- 55 * 56 * --------------------------------------------------*/ 57 class SwUnoInternalPaM 58 : public SwPaM 59 { 60 61 private: 62 SwUnoInternalPaM(const SwUnoInternalPaM&); 63 64 public: 65 SwUnoInternalPaM(SwDoc& rDoc); 66 virtual ~SwUnoInternalPaM(); 67 68 SwUnoInternalPaM& operator=(const SwPaM& rPaM); 69 }; 70 71 72 namespace sw { 73 74 void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget); 75 76 bool XTextRangeToSwPaM(SwUnoInternalPaM& rToFill, 77 const ::com::sun::star::uno::Reference< 78 ::com::sun::star::text::XTextRange > & xTextRange); 79 80 ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > 81 CreateParentXText(SwDoc & rDoc, const SwPosition& rPos); 82 83 bool GetDefaultTextContentValue(::com::sun::star::uno::Any& rAny, 84 const ::rtl::OUString& rPropertyName, sal_uInt16 nWID = 0); 85 86 } // namespace sw 87 88 89 typedef ::cppu::WeakImplHelper8 90 < ::com::sun::star::lang::XUnoTunnel 91 , ::com::sun::star::lang::XServiceInfo 92 , ::com::sun::star::beans::XPropertySet 93 , ::com::sun::star::beans::XPropertyState 94 , ::com::sun::star::container::XEnumerationAccess 95 , ::com::sun::star::container::XContentEnumerationAccess 96 , ::com::sun::star::text::XTextRange 97 , ::com::sun::star::text::XRedline 98 > SwXTextRange_Base; 99 100 class SW_DLLPUBLIC SwXTextRange 101 : public SwXTextRange_Base 102 { 103 104 private: 105 106 friend class SwXText; 107 108 class Impl; 109 ::sw::UnoImplPtr<Impl> m_pImpl; 110 111 enum RangePosition 112 { 113 RANGE_IN_TEXT, // "ordinary" ::com::sun::star::text::TextRange 114 RANGE_IN_CELL, // position created with a cell that has no uno object 115 RANGE_IS_TABLE, // anchor of a table 116 }; 117 118 void SetPositions(SwPaM const& rPam); 119 //TODO: new exception type for protected content 120 void DeleteAndInsert( 121 const ::rtl::OUString& rText, const bool bForceExpandHints) 122 throw (::com::sun::star::uno::RuntimeException); 123 void Invalidate(); 124 125 virtual ~SwXTextRange(); 126 127 public: 128 129 SwXTextRange(SwPaM& rPam, 130 const ::com::sun::star::uno::Reference< 131 ::com::sun::star::text::XText > & xParent, 132 const enum RangePosition eRange = RANGE_IN_TEXT); 133 // only for RANGE_IS_TABLE 134 SwXTextRange(SwFrmFmt& rTblFmt); 135 136 const SwDoc* GetDoc() const; 137 SwDoc* GetDoc(); 138 bool GetPositions(SwPaM & rToFill) const; 139 140 static ::com::sun::star::uno::Reference< 141 ::com::sun::star::text::XTextRange > CreateXTextRange( 142 SwDoc & rDoc, 143 const SwPosition& rPos, const SwPosition *const pMark); 144 145 static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); 146 147 // XUnoTunnel 148 virtual sal_Int64 SAL_CALL getSomething( 149 const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) 150 throw (::com::sun::star::uno::RuntimeException); 151 152 // XServiceInfo 153 virtual ::rtl::OUString SAL_CALL getImplementationName() 154 throw (::com::sun::star::uno::RuntimeException); 155 virtual sal_Bool SAL_CALL supportsService( 156 const ::rtl::OUString& rServiceName) 157 throw (::com::sun::star::uno::RuntimeException); 158 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL 159 getSupportedServiceNames() 160 throw (::com::sun::star::uno::RuntimeException); 161 162 // XPropertySet 163 virtual ::com::sun::star::uno::Reference< 164 ::com::sun::star::beans::XPropertySetInfo > SAL_CALL 165 getPropertySetInfo() 166 throw (::com::sun::star::uno::RuntimeException); 167 virtual void SAL_CALL setPropertyValue( 168 const ::rtl::OUString& rPropertyName, 169 const ::com::sun::star::uno::Any& rValue) 170 throw (::com::sun::star::beans::UnknownPropertyException, 171 ::com::sun::star::beans::PropertyVetoException, 172 ::com::sun::star::lang::IllegalArgumentException, 173 ::com::sun::star::lang::WrappedTargetException, 174 ::com::sun::star::uno::RuntimeException); 175 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( 176 const ::rtl::OUString& rPropertyName) 177 throw (::com::sun::star::beans::UnknownPropertyException, 178 ::com::sun::star::lang::WrappedTargetException, 179 ::com::sun::star::uno::RuntimeException); 180 virtual void SAL_CALL addPropertyChangeListener( 181 const ::rtl::OUString& rPropertyName, 182 const ::com::sun::star::uno::Reference< 183 ::com::sun::star::beans::XPropertyChangeListener >& xListener) 184 throw (::com::sun::star::beans::UnknownPropertyException, 185 ::com::sun::star::lang::WrappedTargetException, 186 ::com::sun::star::uno::RuntimeException); 187 virtual void SAL_CALL removePropertyChangeListener( 188 const ::rtl::OUString& rPropertyName, 189 const ::com::sun::star::uno::Reference< 190 ::com::sun::star::beans::XPropertyChangeListener >& xListener) 191 throw (::com::sun::star::beans::UnknownPropertyException, 192 ::com::sun::star::lang::WrappedTargetException, 193 ::com::sun::star::uno::RuntimeException); 194 virtual void SAL_CALL addVetoableChangeListener( 195 const ::rtl::OUString& rPropertyName, 196 const ::com::sun::star::uno::Reference< 197 ::com::sun::star::beans::XVetoableChangeListener >& xListener) 198 throw (::com::sun::star::beans::UnknownPropertyException, 199 ::com::sun::star::lang::WrappedTargetException, 200 ::com::sun::star::uno::RuntimeException); 201 virtual void SAL_CALL removeVetoableChangeListener( 202 const ::rtl::OUString& rPropertyName, 203 const ::com::sun::star::uno::Reference< 204 ::com::sun::star::beans::XVetoableChangeListener >& xListener) 205 throw (::com::sun::star::beans::UnknownPropertyException, 206 ::com::sun::star::lang::WrappedTargetException, 207 ::com::sun::star::uno::RuntimeException); 208 209 // XPropertyState 210 virtual ::com::sun::star::beans::PropertyState SAL_CALL 211 getPropertyState(const ::rtl::OUString& rPropertyName) 212 throw (::com::sun::star::beans::UnknownPropertyException, 213 ::com::sun::star::uno::RuntimeException); 214 virtual ::com::sun::star::uno::Sequence< 215 ::com::sun::star::beans::PropertyState > SAL_CALL 216 getPropertyStates( 217 const ::com::sun::star::uno::Sequence< 218 ::rtl::OUString >& rPropertyNames) 219 throw (::com::sun::star::beans::UnknownPropertyException, 220 ::com::sun::star::uno::RuntimeException); 221 virtual void SAL_CALL setPropertyToDefault( 222 const ::rtl::OUString& rPropertyName) 223 throw (::com::sun::star::beans::UnknownPropertyException, 224 ::com::sun::star::uno::RuntimeException); 225 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( 226 const ::rtl::OUString& rPropertyName) 227 throw (::com::sun::star::beans::UnknownPropertyException, 228 ::com::sun::star::lang::WrappedTargetException, 229 ::com::sun::star::uno::RuntimeException); 230 231 // XElementAccess 232 virtual ::com::sun::star::uno::Type SAL_CALL getElementType() 233 throw (::com::sun::star::uno::RuntimeException); 234 virtual sal_Bool SAL_CALL hasElements() 235 throw (::com::sun::star::uno::RuntimeException); 236 237 // XEnumerationAccess 238 virtual ::com::sun::star::uno::Reference< 239 ::com::sun::star::container::XEnumeration > SAL_CALL 240 createEnumeration() 241 throw (::com::sun::star::uno::RuntimeException); 242 243 // XContentEnumerationAccess 244 virtual ::com::sun::star::uno::Reference< 245 ::com::sun::star::container::XEnumeration > SAL_CALL 246 createContentEnumeration(const ::rtl::OUString& rServiceName) 247 throw (::com::sun::star::uno::RuntimeException); 248 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL 249 getAvailableServiceNames() 250 throw (::com::sun::star::uno::RuntimeException); 251 252 // XTextRange 253 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > 254 SAL_CALL getText() 255 throw (::com::sun::star::uno::RuntimeException); 256 virtual ::com::sun::star::uno::Reference< 257 ::com::sun::star::text::XTextRange > SAL_CALL getStart() 258 throw (::com::sun::star::uno::RuntimeException); 259 virtual ::com::sun::star::uno::Reference< 260 ::com::sun::star::text::XTextRange > SAL_CALL getEnd() 261 throw (::com::sun::star::uno::RuntimeException); 262 virtual ::rtl::OUString SAL_CALL getString() 263 throw (::com::sun::star::uno::RuntimeException); 264 virtual void SAL_CALL setString(const ::rtl::OUString& rString) 265 throw (::com::sun::star::uno::RuntimeException); 266 267 // XRedline 268 virtual void SAL_CALL makeRedline( 269 const ::rtl::OUString& rRedlineType, 270 const ::com::sun::star::uno::Sequence< 271 ::com::sun::star::beans::PropertyValue >& RedlineProperties) 272 throw (::com::sun::star::lang::IllegalArgumentException, 273 ::com::sun::star::uno::RuntimeException); 274 275 }; 276 277 /* -----------------15.05.98 08:29------------------- 278 * 279 * --------------------------------------------------*/ 280 281 typedef ::cppu::WeakImplHelper3 282 < ::com::sun::star::lang::XUnoTunnel 283 , ::com::sun::star::lang::XServiceInfo 284 , ::com::sun::star::container::XIndexAccess 285 > SwXTextRanges_Base; 286 287 class SwXTextRanges 288 : public SwXTextRanges_Base 289 { 290 291 private: 292 293 class Impl; 294 ::sw::UnoImplPtr<Impl> m_pImpl; 295 296 virtual ~SwXTextRanges(); 297 298 public: 299 300 SwXTextRanges(SwPaM *const pCrsr); 301 302 const SwUnoCrsr* GetCursor() const; 303 304 static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); 305 306 // XUnoTunnel 307 virtual sal_Int64 SAL_CALL getSomething( 308 const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier) 309 throw (::com::sun::star::uno::RuntimeException); 310 311 // XServiceInfo 312 virtual ::rtl::OUString SAL_CALL getImplementationName() 313 throw (::com::sun::star::uno::RuntimeException); 314 virtual sal_Bool SAL_CALL supportsService( 315 const ::rtl::OUString& rServiceName) 316 throw (::com::sun::star::uno::RuntimeException); 317 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL 318 getSupportedServiceNames() 319 throw (::com::sun::star::uno::RuntimeException); 320 321 // XElementAccess 322 virtual ::com::sun::star::uno::Type SAL_CALL getElementType() 323 throw (::com::sun::star::uno::RuntimeException); 324 virtual sal_Bool SAL_CALL hasElements() 325 throw (::com::sun::star::uno::RuntimeException); 326 327 // XIndexAccess 328 virtual sal_Int32 SAL_CALL getCount() 329 throw (::com::sun::star::uno::RuntimeException); 330 virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) 331 throw (::com::sun::star::lang::IndexOutOfBoundsException, 332 ::com::sun::star::lang::WrappedTargetException, 333 ::com::sun::star::uno::RuntimeException); 334 335 }; 336 337 #endif // SW_UNOTEXTRANGE_HXX 338 339