1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _UNOTXVW_HXX 24 #define _UNOTXVW_HXX 25 #include <sfx2/sfxbasecontroller.hxx> 26 #include <com/sun/star/embed/XEmbeddedObject.hpp> 27 #include <com/sun/star/text/XTextViewCursor.hpp> 28 #include <com/sun/star/text/XTextViewCursorSupplier.hpp> 29 #include <com/sun/star/text/XRubySelection.hpp> 30 #include <com/sun/star/view/XFormLayerAccess.hpp> 31 #include <com/sun/star/view/XScreenCursor.hpp> 32 #include <com/sun/star/view/XViewSettingsSupplier.hpp> 33 #include <com/sun/star/view/XSelectionSupplier.hpp> 34 #include <com/sun/star/view/XLineCursor.hpp> 35 #include <com/sun/star/view/XViewCursor.hpp> 36 #include <com/sun/star/text/XPageCursor.hpp> 37 #include <com/sun/star/beans/XPropertySet.hpp> 38 #include <com/sun/star/beans/XPropertySetInfo.hpp> 39 #include <com/sun/star/beans/XPropertyState.hpp> 40 #include <com/sun/star/lang/XServiceInfo.hpp> 41 #include <com/sun/star/datatransfer/XTransferableSupplier.hpp> 42 #include <cppuhelper/implbase8.hxx> // helper for implementations 43 #include <svl/itemprop.hxx> 44 #include "calbck.hxx" 45 #include "TextCursorHelper.hxx" 46 #include <comphelper/uno3.hxx> 47 48 #include <sfx2/objsh.hxx> 49 50 class SdrObject; 51 class SwView; 52 53 typedef ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener > * XSelectionChangeListenerPtr; 54 SV_DECL_PTRARR_DEL( SelectionChangeListenerArr, XSelectionChangeListenerPtr, 4, 4 ) 55 56 /****************************************************************************** 57 * 58 ******************************************************************************/ 59 class SwXTextView : 60 public ::com::sun::star::view::XSelectionSupplier, 61 public ::com::sun::star::lang::XServiceInfo, 62 public ::com::sun::star::view::XFormLayerAccess, 63 public ::com::sun::star::text::XTextViewCursorSupplier, 64 public ::com::sun::star::text::XRubySelection, 65 public ::com::sun::star::view::XViewSettingsSupplier, 66 public ::com::sun::star::beans::XPropertySet, 67 public ::com::sun::star::datatransfer::XTransferableSupplier, 68 public SfxBaseController 69 { 70 SelectionChangeListenerArr aSelChangedListeners; 71 72 SwView* m_pView; 73 const SfxItemPropertySet* m_pPropSet; // property map for SwXTextView properties 74 // (not related to pxViewSettings!) 75 76 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > * pxViewSettings; 77 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextViewCursor > * pxTextViewCursor; 78 79 80 SdrObject* GetControl( 81 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & Model, 82 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& xToFill ); 83 84 protected: 85 virtual ~SwXTextView(); 86 public: 87 SwXTextView(SwView* pSwView); 88 89 90 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ); 91 virtual void SAL_CALL acquire( ) throw(); 92 virtual void SAL_CALL release( ) throw(); 93 94 //XTypeProvider 95 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ); 96 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ); 97 98 //XSelectionSupplier 99 virtual ::com::sun::star::uno::Any SAL_CALL getSelection(void); 100 virtual sal_Bool SAL_CALL select(const ::com::sun::star::uno::Any& aInterface); 101 virtual void SAL_CALL addSelectionChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener > & xListener); 102 virtual void SAL_CALL removeSelectionChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener > & xListener); 103 104 // XFormLayerAccess 105 virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > SAL_CALL getFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& Form ); 106 virtual ::sal_Bool SAL_CALL isFormDesignMode( ); 107 virtual void SAL_CALL setFormDesignMode( ::sal_Bool DesignMode ); 108 109 // XControlAccess 110 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > SAL_CALL getControl(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & Model); 111 112 //XTextViewCursorSupplier 113 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextViewCursor > SAL_CALL getViewCursor(void); 114 115 //XViewSettings 116 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getViewSettings(void); 117 118 //XRubySelection 119 virtual ::com::sun::star::uno::Sequence< 120 ::com::sun::star::uno::Sequence< 121 ::com::sun::star::beans::PropertyValue > > SAL_CALL getRubyList( sal_Bool bAutomatic ); 122 123 virtual void SAL_CALL setRubyList( 124 const ::com::sun::star::uno::Sequence< 125 ::com::sun::star::uno::Sequence< 126 ::com::sun::star::beans::PropertyValue > >& RubyList, sal_Bool bAutomatic ); 127 128 //XPropertySet 129 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ); 130 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ); 131 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ); 132 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ); 133 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ); 134 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ); 135 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ); 136 137 //XServiceInfo 138 virtual rtl::OUString SAL_CALL getImplementationName(void); 139 virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName); 140 virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void); 141 142 //XTransferableSupplier 143 virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getTransferable( ); 144 virtual void SAL_CALL insertTransferable( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans ); 145 146 void NotifySelChanged(); 147 void NotifyDBChanged(); 148 GetView()149 SwView* GetView() {return m_pView;} 150 void Invalidate(); 151 152 // temporary document used for PDF export of selections/multi-selections 153 SfxObjectShellLock BuildTmpSelectionDoc(); 154 }; 155 156 /* -----------------17.09.98 12:52------------------- 157 * 158 * --------------------------------------------------*/ 159 160 typedef cppu::WeakImplHelper8< 161 ::com::sun::star::text::XTextViewCursor, 162 ::com::sun::star::lang::XServiceInfo, 163 ::com::sun::star::text::XPageCursor, 164 ::com::sun::star::view::XScreenCursor, 165 ::com::sun::star::view::XViewCursor, 166 ::com::sun::star::view::XLineCursor, 167 ::com::sun::star::beans::XPropertySet, 168 ::com::sun::star::beans::XPropertyState 169 > SwXTextViewCursor_Base; 170 171 class SwXTextViewCursor : public SwXTextViewCursor_Base, 172 public SwClient, 173 public OTextCursorHelper 174 { 175 SwView* m_pView; 176 const SfxItemPropertySet* m_pPropSet; 177 protected: 178 sal_Bool IsTextSelection( sal_Bool bAllowTables = sal_True ) const; 179 virtual ~SwXTextViewCursor(); 180 public: 181 SwXTextViewCursor(SwView* pVw); 182 183 DECLARE_XINTERFACE() 184 185 //XTextViewCursor 186 virtual sal_Bool SAL_CALL isVisible(void); 187 virtual void SAL_CALL setVisible(sal_Bool bVisible); 188 virtual ::com::sun::star::awt::Point SAL_CALL getPosition(void); 189 190 //XTextCursor - neu 191 virtual void SAL_CALL collapseToStart( ); 192 virtual void SAL_CALL collapseToEnd( ); 193 virtual sal_Bool SAL_CALL isCollapsed( ); 194 virtual sal_Bool SAL_CALL goLeft( sal_Int16 nCount, sal_Bool bExpand ); 195 virtual sal_Bool SAL_CALL goRight( sal_Int16 nCount, sal_Bool bExpand ); 196 virtual void SAL_CALL gotoStart( sal_Bool bExpand ); 197 virtual void SAL_CALL gotoEnd( sal_Bool bExpand ); 198 virtual void SAL_CALL gotoRange( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xRange, sal_Bool bExpand ); 199 200 //XPageCursor 201 virtual sal_Bool SAL_CALL jumpToFirstPage(void); 202 virtual sal_Bool SAL_CALL jumpToLastPage(void); 203 virtual sal_Bool SAL_CALL jumpToPage(sal_Int16 nPage); 204 virtual sal_Bool SAL_CALL jumpToNextPage(void); 205 virtual sal_Bool SAL_CALL jumpToPreviousPage(void); 206 virtual sal_Bool SAL_CALL jumpToEndOfPage(void); 207 virtual sal_Bool SAL_CALL jumpToStartOfPage(void); 208 virtual sal_Int16 SAL_CALL getPage(void); 209 210 //XTextRange 211 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText(void); 212 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart(void); 213 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd(void); 214 virtual rtl::OUString SAL_CALL getString(void); 215 virtual void SAL_CALL setString(const rtl::OUString& aString); 216 217 //XScreenCursor 218 virtual sal_Bool SAL_CALL screenDown(void); 219 virtual sal_Bool SAL_CALL screenUp(void); 220 221 //XViewCursor 222 virtual sal_Bool SAL_CALL goDown(sal_Int16 nCount, sal_Bool bExpand); 223 virtual sal_Bool SAL_CALL goUp(sal_Int16 nCount, sal_Bool bExpand); 224 // virtual sal_Bool goLeft(sal_Int16 nCount, sal_Bool bExpand) throw( ::com::sun::star::uno::RuntimeException ); 225 // virtual sal_Bool goRight(sal_Int16 nCount, sal_Bool bExpand) throw( ::com::sun::star::uno::RuntimeException ); 226 227 //XLineCursor 228 virtual sal_Bool SAL_CALL isAtStartOfLine(void); 229 virtual sal_Bool SAL_CALL isAtEndOfLine(void); 230 virtual void SAL_CALL gotoEndOfLine(sal_Bool bExpand); 231 virtual void SAL_CALL gotoStartOfLine(sal_Bool bExpand); 232 233 //XPropertySet 234 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ); 235 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ); 236 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ); 237 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ); 238 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ); 239 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ); 240 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ); 241 242 //XPropertyState 243 virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ); 244 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ); 245 virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ); 246 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ); 247 248 //XServiceInfo 249 virtual rtl::OUString SAL_CALL getImplementationName(void); 250 virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName); 251 virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void); 252 253 static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); 254 255 //XUnoTunnel 256 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ); 257 Invalidate()258 void Invalidate(){m_pView = 0;} 259 260 // ITextCursorHelper 261 virtual const SwPaM* GetPaM() const; 262 virtual SwPaM* GetPaM(); 263 virtual const SwDoc* GetDoc() const; 264 virtual SwDoc* GetDoc(); 265 }; 266 #endif 267