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 #ifndef _UNOPORT_HXX 28 #define _UNOPORT_HXX 29 30 #include <unocrsr.hxx> 31 #include <unoevtlstnr.hxx> 32 #include <calbck.hxx> 33 34 #include <com/sun/star/beans/XPropertySet.hpp> 35 #include <com/sun/star/text/XTextRange.hpp> 36 #include <com/sun/star/container/XEnumeration.hpp> 37 #include <com/sun/star/container/XContentEnumerationAccess.hpp> 38 #include <com/sun/star/container/XEnumerationAccess.hpp> 39 #include <com/sun/star/beans/XPropertyState.hpp> 40 #include <com/sun/star/beans/XMultiPropertySet.hpp> 41 #include <com/sun/star/beans/XTolerantMultiPropertySet.hpp> 42 #include <com/sun/star/text/XTextField.hpp> 43 #include <com/sun/star/text/XFootnote.hpp> 44 #include <com/sun/star/lang/XServiceInfo.hpp> 45 #include <com/sun/star/lang/XUnoTunnel.hpp> 46 #include <cppuhelper/implbase8.hxx> 47 #include <cppuhelper/implbase3.hxx> 48 #include <svl/itemprop.hxx> 49 50 #include <memory> 51 #include <deque> 52 53 54 class SwFmtFld; 55 class SwFrmFmt; 56 class SwTxtRuby; 57 58 59 typedef ::std::deque< 60 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > > 61 TextRangeList_t; 62 63 64 /* -----------------29.05.98 14:42------------------- 65 * 66 * --------------------------------------------------*/ 67 enum SwTextPortionType 68 { 69 PORTION_TEXT, 70 PORTION_FIELD, 71 PORTION_FRAME, 72 PORTION_FOOTNOTE, 73 // obsolete! PORTION_CONTROL_CHAR, 74 PORTION_REFMARK_START, 75 PORTION_REFMARK_END, 76 PORTION_TOXMARK_START, 77 PORTION_TOXMARK_END, 78 PORTION_BOOKMARK_START, 79 PORTION_BOOKMARK_END, 80 PORTION_REDLINE_START, 81 PORTION_REDLINE_END, 82 PORTION_RUBY_START, 83 PORTION_RUBY_END, 84 PORTION_SOFT_PAGEBREAK, 85 PORTION_META, 86 PORTION_FIELD_START, 87 PORTION_FIELD_END, 88 PORTION_FIELD_START_END 89 }; 90 91 92 class SwXTextPortion : public cppu::WeakImplHelper8 93 < 94 ::com::sun::star::beans::XTolerantMultiPropertySet, 95 ::com::sun::star::beans::XMultiPropertySet, 96 ::com::sun::star::beans::XPropertySet, 97 ::com::sun::star::text::XTextRange, 98 ::com::sun::star::beans::XPropertyState, 99 ::com::sun::star::container::XContentEnumerationAccess, 100 ::com::sun::star::lang::XUnoTunnel, 101 ::com::sun::star::lang::XServiceInfo 102 >, 103 public SwClient 104 { 105 private: 106 107 SwEventListenerContainer m_ListenerContainer; 108 const SfxItemPropertySet * m_pPropSet; 109 const ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > 110 m_xParentText; 111 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > 112 m_xRefMark; 113 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > 114 m_xTOXMark; 115 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > 116 m_xBookmark; 117 ::com::sun::star::uno::Reference< ::com::sun::star::text::XFootnote > 118 m_xFootnote; 119 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField > 120 m_xTextField; 121 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > 122 m_xMeta; 123 ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyText; 124 ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyStyle; 125 ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyAdjust; 126 ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyIsAbove; 127 128 const SwDepend m_FrameDepend; 129 SwFrmFmt * m_pFrameFmt; 130 const SwTextPortionType m_ePortionType; 131 132 bool m_bIsCollapsed; 133 134 SwFmtFld * GetFldFmt(bool bInit = false); 135 136 void init(const SwUnoCrsr* pPortionCursor); 137 138 protected: 139 140 void SAL_CALL SetPropertyValues_Impl( 141 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, 142 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) 143 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 144 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL GetPropertyValues_Impl( 145 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) 146 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 147 148 void GetPropertyValues( const ::rtl::OUString *pPropertyNames, 149 ::com::sun::star::uno::Any *pValues, 150 sal_Int32 nLength ); 151 152 void GetPropertyValue( ::com::sun::star::uno::Any &rVal, 153 const SfxItemPropertySimpleEntry& rEntry, SwUnoCrsr *pUnoCrsr, SfxItemSet *&pSet ); 154 155 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL GetPropertyValuesTolerant_Impl( 156 const ::com::sun::star::uno::Sequence< rtl::OUString >& rPropertyNames, 157 sal_Bool bDirectValuesOnly ) throw (::com::sun::star::uno::RuntimeException); 158 159 virtual ~SwXTextPortion(); 160 161 //SwClient 162 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew); 163 164 public: 165 SwXTextPortion(const SwUnoCrsr* pPortionCrsr, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const& rParent, SwTextPortionType eType ); 166 SwXTextPortion(const SwUnoCrsr* pPortionCrsr, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const& rParent, SwFrmFmt& rFmt ); 167 168 // for Ruby 169 SwXTextPortion(const SwUnoCrsr* pPortionCrsr, 170 SwTxtRuby const& rAttr, 171 ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > 172 const& xParent, 173 sal_Bool bIsEnd ); 174 175 //XTextRange 176 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText() throw( ::com::sun::star::uno::RuntimeException ); 177 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart() throw( ::com::sun::star::uno::RuntimeException ); 178 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd() throw( ::com::sun::star::uno::RuntimeException ); 179 virtual rtl::OUString SAL_CALL getString() throw( ::com::sun::star::uno::RuntimeException ); 180 virtual void SAL_CALL setString(const rtl::OUString& aString) throw( ::com::sun::star::uno::RuntimeException ); 181 182 //XTolerantMultiPropertySet 183 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::SetPropertyTolerantFailed > SAL_CALL setPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 184 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::GetPropertyTolerantResult > SAL_CALL getPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException); 185 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL getDirectPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException); 186 187 //XMultiPropertySet 188 // virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 189 virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 190 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw(::com::sun::star::uno::RuntimeException); 191 virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); 192 virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); 193 virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); 194 195 //XPropertySet 196 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 197 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 198 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 199 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 200 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 201 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 202 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 203 204 //XPropertyState 205 virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 206 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 207 virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 208 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 209 210 //XTextContent 211 virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 212 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor( ) throw(::com::sun::star::uno::RuntimeException); 213 214 //XComponent 215 virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException ); 216 virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); 217 virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); 218 219 //XUnoTunnel 220 static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); 221 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); 222 223 //XServiceInfo 224 virtual rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); 225 virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); 226 virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); 227 228 //XContentEnumerationAccess 229 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createContentEnumeration(const rtl::OUString& aServiceName) throw( ::com::sun::star::uno::RuntimeException ); 230 virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames() throw( ::com::sun::star::uno::RuntimeException ); 231 232 void SetRefMark( ::com::sun::star::uno::Reference< 233 ::com::sun::star::text::XTextContent > xMark) 234 { m_xRefMark = xMark; } 235 236 void SetTOXMark( ::com::sun::star::uno::Reference< 237 ::com::sun::star::text::XTextContent > xMark) 238 { m_xTOXMark = xMark; } 239 240 void SetBookmark( ::com::sun::star::uno::Reference< 241 ::com::sun::star::text::XTextContent > xMark) 242 { m_xBookmark = xMark; } 243 244 void SetFootnote( ::com::sun::star::uno::Reference< 245 ::com::sun::star::text::XFootnote > xNote) 246 { m_xFootnote = xNote; } 247 248 void SetTextField( ::com::sun::star::uno::Reference< 249 ::com::sun::star::text::XTextField> xField) 250 { m_xTextField = xField; } 251 252 void SetMeta( ::com::sun::star::uno::Reference< 253 ::com::sun::star::text::XTextContent > xMeta) 254 { m_xMeta = xMeta; } 255 256 bool IsCollapsed() const { return m_bIsCollapsed; } 257 void SetCollapsed(bool bSet) { m_bIsCollapsed = bSet;} 258 259 SwTextPortionType GetTextPortionType() const { return m_ePortionType; } 260 261 SwUnoCrsr* GetCursor() const 262 {return static_cast<SwUnoCrsr*>(const_cast<SwModify*>(GetRegisteredIn()));} 263 }; 264 265 /* -----------------29.05.98 14:42------------------- 266 * 267 * --------------------------------------------------*/ 268 class SwXTextPortionEnumeration 269 : public ::cppu::WeakImplHelper3 270 < ::com::sun::star::container::XEnumeration 271 , ::com::sun::star::lang::XServiceInfo 272 , ::com::sun::star::lang::XUnoTunnel 273 > 274 , public SwClient 275 { 276 TextRangeList_t m_Portions; // contains all portions, filled by ctor 277 278 SwUnoCrsr* GetCursor() const 279 {return static_cast<SwUnoCrsr*>(const_cast<SwModify*>(GetRegisteredIn()));} 280 281 protected: 282 virtual ~SwXTextPortionEnumeration(); 283 284 public: 285 SwXTextPortionEnumeration(SwPaM& rParaCrsr, 286 ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > 287 const & xParent, 288 const sal_Int32 nStart, const sal_Int32 nEnd ); 289 290 SwXTextPortionEnumeration(SwPaM& rParaCrsr, 291 TextRangeList_t const & rPortions ); 292 293 294 static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); 295 296 //XUnoTunnel 297 virtual sal_Int64 SAL_CALL getSomething( 298 const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) 299 throw(::com::sun::star::uno::RuntimeException); 300 301 //XEnumeration 302 virtual sal_Bool SAL_CALL hasMoreElements() 303 throw( ::com::sun::star::uno::RuntimeException ); 304 virtual ::com::sun::star::uno::Any SAL_CALL nextElement() 305 throw( ::com::sun::star::container::NoSuchElementException, 306 ::com::sun::star::lang::WrappedTargetException, 307 ::com::sun::star::uno::RuntimeException ); 308 309 //XServiceInfo 310 virtual rtl::OUString SAL_CALL getImplementationName() 311 throw( ::com::sun::star::uno::RuntimeException ); 312 virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) 313 throw( ::com::sun::star::uno::RuntimeException ); 314 virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL 315 getSupportedServiceNames() 316 throw( ::com::sun::star::uno::RuntimeException ); 317 protected: 318 //SwClient 319 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew); 320 }; 321 322 #endif 323