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 24 #ifndef SC_VIEWUNO_HXX 25 #define SC_VIEWUNO_HXX 26 27 #include <sfx2/sfxbasecontroller.hxx> 28 #include <svl/svarray.hxx> 29 #include <svl/itemprop.hxx> 30 #include <com/sun/star/view/XFormLayerAccess.hpp> 31 #include <com/sun/star/view/XSelectionChangeListener.hpp> 32 #include <com/sun/star/view/XSelectionSupplier.hpp> 33 #include <com/sun/star/sheet/XCellRangeReferrer.hpp> 34 #include <com/sun/star/sheet/XViewSplitable.hpp> 35 #include <com/sun/star/sheet/XViewFreezable.hpp> 36 #include <com/sun/star/sheet/XSpreadsheetView.hpp> 37 #include <com/sun/star/sheet/XEnhancedMouseClickBroadcaster.hpp> 38 #include <com/sun/star/sheet/XActivationBroadcaster.hpp> 39 #include <com/sun/star/sheet/XViewPane.hpp> 40 #include <com/sun/star/sheet/XRangeSelection.hpp> 41 #include <com/sun/star/lang/XServiceInfo.hpp> 42 #include <com/sun/star/container/XEnumerationAccess.hpp> 43 #include <com/sun/star/beans/XPropertySet.hpp> 44 #include <com/sun/star/lang/XUnoTunnel.hpp> 45 #include <com/sun/star/datatransfer/XTransferableSupplier.hpp> 46 47 #include "address.hxx" 48 49 class ScTabViewShell; 50 51 #define SC_VIEWPANE_ACTIVE 0xFFFF 52 53 54 typedef ::com::sun::star::uno::Reference< 55 ::com::sun::star::sheet::XRangeSelectionListener >* XRangeSelectionListenerPtr; 56 SV_DECL_PTRARR_DEL( XRangeSelectionListenerArr_Impl, XRangeSelectionListenerPtr, 4, 4 ) 57 58 typedef ::com::sun::star::uno::Reference< 59 ::com::sun::star::sheet::XRangeSelectionChangeListener >* XRangeSelectionChangeListenerPtr; 60 SV_DECL_PTRARR_DEL( XRangeSelectionChangeListenerArr_Impl, XRangeSelectionChangeListenerPtr, 4, 4 ) 61 62 typedef ::com::sun::star::uno::Reference< 63 ::com::sun::star::view::XSelectionChangeListener >* XSelectionChangeListenerPtr; 64 SV_DECL_PTRARR_DEL( XSelectionChangeListenerArr_Impl, XSelectionChangeListenerPtr, 4, 4 ) 65 66 typedef ::com::sun::star::uno::Reference< 67 ::com::sun::star::beans::XPropertyChangeListener >* XViewPropertyChangeListenerPtr; 68 SV_DECL_PTRARR_DEL( XViewPropertyChangeListenerArr_Impl, XViewPropertyChangeListenerPtr, 4, 4 ) 69 70 typedef ::com::sun::star::uno::Reference< 71 ::com::sun::star::awt::XEnhancedMouseClickHandler >* XMouseClickHandlerPtr; 72 SV_DECL_PTRARR_DEL( XMouseClickHandlerArr_Impl, XMouseClickHandlerPtr, 4, 4 ) 73 74 typedef ::com::sun::star::uno::Reference< 75 ::com::sun::star::sheet::XActivationEventListener >* XActivationEventListenerPtr; 76 SV_DECL_PTRARR_DEL( XActivationEventListenerArr_Impl, XActivationEventListenerPtr, 4, 4 ) 77 78 79 // ScViewPaneBase not derived from OWeakObject 80 // to avoid duplicate OWeakObject in ScTabViewObj 81 82 class ScViewPaneBase : public com::sun::star::sheet::XViewPane, 83 public com::sun::star::sheet::XCellRangeReferrer, 84 public com::sun::star::view::XFormLayerAccess, 85 public com::sun::star::lang::XServiceInfo, 86 public com::sun::star::lang::XTypeProvider, 87 public SfxListener 88 { 89 private: 90 ScTabViewShell* pViewShell; 91 sal_uInt16 nPane; // ScSplitPos oder SC_VIEWPANE_ACTIVE 92 93 protected: 94 ::com::sun::star::awt::Rectangle GetVisArea() const; 95 96 public: 97 ScViewPaneBase(ScTabViewShell* pViewSh, sal_uInt16 nP); 98 virtual ~ScViewPaneBase(); 99 GetViewShell() const100 ScTabViewShell* GetViewShell() const { return pViewShell; } 101 102 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( 103 const ::com::sun::star::uno::Type & rType ) 104 throw(::com::sun::star::uno::RuntimeException); 105 106 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 107 108 // XViewPane 109 virtual sal_Int32 SAL_CALL getFirstVisibleColumn() throw(::com::sun::star::uno::RuntimeException); 110 virtual void SAL_CALL setFirstVisibleColumn( sal_Int32 nFirstVisibleColumn ) 111 throw(::com::sun::star::uno::RuntimeException); 112 virtual sal_Int32 SAL_CALL getFirstVisibleRow() throw(::com::sun::star::uno::RuntimeException); 113 virtual void SAL_CALL setFirstVisibleRow( sal_Int32 nFirstVisibleRow ) 114 throw(::com::sun::star::uno::RuntimeException); 115 virtual ::com::sun::star::table::CellRangeAddress SAL_CALL getVisibleRange() 116 throw(::com::sun::star::uno::RuntimeException); 117 118 // XCellRangeReferrer 119 virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > SAL_CALL 120 getReferredCells() throw(::com::sun::star::uno::RuntimeException); 121 122 // XFormLayerAccess 123 virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > SAL_CALL 124 getFormController( const ::com::sun::star::uno::Reference< 125 ::com::sun::star::form::XForm >& Form ) 126 throw (::com::sun::star::uno::RuntimeException); 127 virtual ::sal_Bool SAL_CALL 128 isFormDesignMode( ) 129 throw (::com::sun::star::uno::RuntimeException); 130 virtual void SAL_CALL setFormDesignMode( ::sal_Bool DesignMode ) 131 throw (::com::sun::star::uno::RuntimeException); 132 133 // XControlAccess 134 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > SAL_CALL 135 getControl( const ::com::sun::star::uno::Reference< 136 ::com::sun::star::awt::XControlModel >& xModel ) 137 throw(::com::sun::star::container::NoSuchElementException, 138 ::com::sun::star::uno::RuntimeException); 139 140 // XServiceInfo 141 virtual ::rtl::OUString SAL_CALL getImplementationName() 142 throw(::com::sun::star::uno::RuntimeException); 143 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 144 throw(::com::sun::star::uno::RuntimeException); 145 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 146 throw(::com::sun::star::uno::RuntimeException); 147 148 // XTypeProvider 149 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() 150 throw(::com::sun::star::uno::RuntimeException); 151 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() 152 throw(::com::sun::star::uno::RuntimeException); 153 }; 154 155 156 // ScViewPaneObj for direct use (including OWeakObject) 157 158 class ScViewPaneObj : public ScViewPaneBase, public cppu::OWeakObject 159 { 160 public: 161 ScViewPaneObj(ScTabViewShell* pViewSh, sal_uInt16 nP); 162 virtual ~ScViewPaneObj(); 163 164 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( 165 const ::com::sun::star::uno::Type & rType ) 166 throw(::com::sun::star::uno::RuntimeException); 167 virtual void SAL_CALL acquire() throw(); 168 virtual void SAL_CALL release() throw(); 169 }; 170 171 // OWeakObject is base of SfxBaseController -> use ScViewPaneBase 172 173 class ScTabViewObj : public ScViewPaneBase, 174 public SfxBaseController, 175 public com::sun::star::sheet::XSpreadsheetView, 176 public com::sun::star::sheet::XEnhancedMouseClickBroadcaster, 177 public com::sun::star::sheet::XActivationBroadcaster, 178 public com::sun::star::container::XEnumerationAccess, 179 public com::sun::star::container::XIndexAccess, 180 public com::sun::star::view::XSelectionSupplier, 181 public com::sun::star::beans::XPropertySet, 182 public com::sun::star::sheet::XViewSplitable, 183 public com::sun::star::sheet::XViewFreezable, 184 public com::sun::star::sheet::XRangeSelection, 185 public com::sun::star::lang::XUnoTunnel, 186 public com::sun::star::datatransfer::XTransferableSupplier 187 { 188 private: 189 SfxItemPropertySet aPropSet; 190 XSelectionChangeListenerArr_Impl aSelectionListeners; 191 XRangeSelectionListenerArr_Impl aRangeSelListeners; 192 XRangeSelectionChangeListenerArr_Impl aRangeChgListeners; 193 XViewPropertyChangeListenerArr_Impl aPropertyChgListeners; 194 XMouseClickHandlerArr_Impl aMouseClickHandlers; 195 XActivationEventListenerArr_Impl aActivationListeners; 196 SCTAB nPreviousTab; 197 sal_Bool bDrawSelModeSet; 198 199 ScViewPaneObj* GetObjectByIndex_Impl(sal_uInt16 nIndex) const; 200 sal_Int16 GetZoom(void) const; 201 void SetZoom(sal_Int16 Zoom); 202 sal_Int16 GetZoomType(void) const; 203 void SetZoomType(sal_Int16 ZoomType); 204 205 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > GetClickedObject(const Point& rPoint) const; 206 void StartMouseListening(); 207 void EndMouseListening(); 208 void StartActivationListening(); 209 void EndActivationListening(); 210 211 ScTabViewObj(); // disabled 212 public: 213 ScTabViewObj(ScTabViewShell* pViewSh); 214 virtual ~ScTabViewObj(); 215 216 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( 217 const ::com::sun::star::uno::Type & rType ) 218 throw(::com::sun::star::uno::RuntimeException); 219 virtual void SAL_CALL acquire() throw(); 220 virtual void SAL_CALL release() throw(); 221 222 void SelectionChanged(); 223 void VisAreaChanged(); 224 // bSameTabButMoved = true if the same sheet as before is activated, used after moving/copying/inserting/deleting a sheet 225 void SheetChanged( bool bSameTabButMoved = false ); 226 bool IsMouseListening() const; 227 sal_Bool MousePressed( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException); 228 sal_Bool MouseReleased( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException); 229 230 void RangeSelDone( const String& rText ); 231 void RangeSelAborted( const String& rText ); 232 void RangeSelChanged( const String& rText ); 233 234 // XSelectionSupplier 235 virtual sal_Bool SAL_CALL select( const ::com::sun::star::uno::Any& aSelection ) 236 throw(::com::sun::star::lang::IllegalArgumentException, 237 ::com::sun::star::uno::RuntimeException); 238 virtual ::com::sun::star::uno::Any SAL_CALL getSelection() 239 throw(::com::sun::star::uno::RuntimeException); 240 virtual void SAL_CALL addSelectionChangeListener( const ::com::sun::star::uno::Reference< 241 ::com::sun::star::view::XSelectionChangeListener >& xListener ) 242 throw(::com::sun::star::uno::RuntimeException); 243 virtual void SAL_CALL removeSelectionChangeListener( const ::com::sun::star::uno::Reference< 244 ::com::sun::star::view::XSelectionChangeListener >& xListener ) 245 throw(::com::sun::star::uno::RuntimeException); 246 247 //! XPrintable? 248 249 // XPropertySet 250 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > 251 SAL_CALL getPropertySetInfo() 252 throw(::com::sun::star::uno::RuntimeException); 253 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, 254 const ::com::sun::star::uno::Any& aValue ) 255 throw(::com::sun::star::beans::UnknownPropertyException, 256 ::com::sun::star::beans::PropertyVetoException, 257 ::com::sun::star::lang::IllegalArgumentException, 258 ::com::sun::star::lang::WrappedTargetException, 259 ::com::sun::star::uno::RuntimeException); 260 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( 261 const ::rtl::OUString& PropertyName ) 262 throw(::com::sun::star::beans::UnknownPropertyException, 263 ::com::sun::star::lang::WrappedTargetException, 264 ::com::sun::star::uno::RuntimeException); 265 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, 266 const ::com::sun::star::uno::Reference< 267 ::com::sun::star::beans::XPropertyChangeListener >& xListener ) 268 throw(::com::sun::star::beans::UnknownPropertyException, 269 ::com::sun::star::lang::WrappedTargetException, 270 ::com::sun::star::uno::RuntimeException); 271 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, 272 const ::com::sun::star::uno::Reference< 273 ::com::sun::star::beans::XPropertyChangeListener >& aListener ) 274 throw(::com::sun::star::beans::UnknownPropertyException, 275 ::com::sun::star::lang::WrappedTargetException, 276 ::com::sun::star::uno::RuntimeException); 277 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, 278 const ::com::sun::star::uno::Reference< 279 ::com::sun::star::beans::XVetoableChangeListener >& aListener ) 280 throw(::com::sun::star::beans::UnknownPropertyException, 281 ::com::sun::star::lang::WrappedTargetException, 282 ::com::sun::star::uno::RuntimeException); 283 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, 284 const ::com::sun::star::uno::Reference< 285 ::com::sun::star::beans::XVetoableChangeListener >& aListener ) 286 throw(::com::sun::star::beans::UnknownPropertyException, 287 ::com::sun::star::lang::WrappedTargetException, 288 ::com::sun::star::uno::RuntimeException); 289 290 // XEnumerationAccess 291 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL 292 createEnumeration() throw(::com::sun::star::uno::RuntimeException); 293 294 // XIndexAccess 295 virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException); 296 virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) 297 throw(::com::sun::star::lang::IndexOutOfBoundsException, 298 ::com::sun::star::lang::WrappedTargetException, 299 ::com::sun::star::uno::RuntimeException); 300 301 // XElementAccess 302 virtual ::com::sun::star::uno::Type SAL_CALL getElementType() 303 throw(::com::sun::star::uno::RuntimeException); 304 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException); 305 306 // XSpreadsheetView 307 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet > SAL_CALL 308 getActiveSheet() throw(::com::sun::star::uno::RuntimeException); 309 virtual void SAL_CALL setActiveSheet( const ::com::sun::star::uno::Reference< 310 ::com::sun::star::sheet::XSpreadsheet >& xActiveSheet ) 311 throw(::com::sun::star::uno::RuntimeException); 312 313 //XEnhancedMouseClickBroadcaster 314 315 virtual void SAL_CALL addEnhancedMouseClickHandler( const ::com::sun::star::uno::Reference< 316 ::com::sun::star::awt::XEnhancedMouseClickHandler >& aListener ) 317 throw (::com::sun::star::uno::RuntimeException); 318 virtual void SAL_CALL removeEnhancedMouseClickHandler( const ::com::sun::star::uno::Reference< 319 ::com::sun::star::awt::XEnhancedMouseClickHandler >& aListener ) 320 throw (::com::sun::star::uno::RuntimeException); 321 322 //XActivationBroadcaster 323 324 virtual void SAL_CALL addActivationEventListener( const ::com::sun::star::uno::Reference< 325 ::com::sun::star::sheet::XActivationEventListener >& aListener ) 326 throw (::com::sun::star::uno::RuntimeException); 327 virtual void SAL_CALL removeActivationEventListener( const ::com::sun::star::uno::Reference< 328 ::com::sun::star::sheet::XActivationEventListener >& aListener ) 329 throw (::com::sun::star::uno::RuntimeException); 330 331 // XViewSplitable 332 virtual sal_Bool SAL_CALL getIsWindowSplit() throw(::com::sun::star::uno::RuntimeException); 333 virtual sal_Int32 SAL_CALL getSplitHorizontal() throw(::com::sun::star::uno::RuntimeException); 334 virtual sal_Int32 SAL_CALL getSplitVertical() throw(::com::sun::star::uno::RuntimeException); 335 virtual sal_Int32 SAL_CALL getSplitColumn() throw(::com::sun::star::uno::RuntimeException); 336 virtual sal_Int32 SAL_CALL getSplitRow() throw(::com::sun::star::uno::RuntimeException); 337 virtual void SAL_CALL splitAtPosition( sal_Int32 nPixelX, sal_Int32 nPixelY ) 338 throw(::com::sun::star::uno::RuntimeException); 339 340 // XViewFreezable 341 virtual sal_Bool SAL_CALL hasFrozenPanes() throw(::com::sun::star::uno::RuntimeException); 342 virtual void SAL_CALL freezeAtPosition( sal_Int32 nColumns, sal_Int32 nRows ) 343 throw(::com::sun::star::uno::RuntimeException); 344 345 // XRangeSelection 346 virtual void SAL_CALL startRangeSelection( const ::com::sun::star::uno::Sequence< 347 ::com::sun::star::beans::PropertyValue >& aArguments ) 348 throw(::com::sun::star::uno::RuntimeException); 349 virtual void SAL_CALL abortRangeSelection() throw(::com::sun::star::uno::RuntimeException); 350 virtual void SAL_CALL addRangeSelectionListener( const ::com::sun::star::uno::Reference< 351 ::com::sun::star::sheet::XRangeSelectionListener >& aListener ) 352 throw(::com::sun::star::uno::RuntimeException); 353 virtual void SAL_CALL removeRangeSelectionListener( const ::com::sun::star::uno::Reference< 354 ::com::sun::star::sheet::XRangeSelectionListener >& aListener ) 355 throw(::com::sun::star::uno::RuntimeException); 356 virtual void SAL_CALL addRangeSelectionChangeListener( const ::com::sun::star::uno::Reference< 357 ::com::sun::star::sheet::XRangeSelectionChangeListener >& aListener ) 358 throw(::com::sun::star::uno::RuntimeException); 359 virtual void SAL_CALL removeRangeSelectionChangeListener( const ::com::sun::star::uno::Reference< 360 ::com::sun::star::sheet::XRangeSelectionChangeListener >& aListener ) 361 throw(::com::sun::star::uno::RuntimeException); 362 363 // XServiceInfo 364 virtual ::rtl::OUString SAL_CALL getImplementationName() 365 throw(::com::sun::star::uno::RuntimeException); 366 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 367 throw(::com::sun::star::uno::RuntimeException); 368 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 369 throw(::com::sun::star::uno::RuntimeException); 370 371 // XUnoTunnel 372 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< 373 sal_Int8 >& aIdentifier ) 374 throw(::com::sun::star::uno::RuntimeException); 375 376 static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId(); 377 static ScTabViewObj* getImplementation( const com::sun::star::uno::Reference< 378 com::sun::star::uno::XInterface> xObj ); 379 380 // XTypeProvider 381 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() 382 throw(::com::sun::star::uno::RuntimeException); 383 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() 384 throw(::com::sun::star::uno::RuntimeException); 385 386 //XTransferableSupplier 387 virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getTransferable( ) throw (::com::sun::star::uno::RuntimeException); 388 virtual void SAL_CALL insertTransferable( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans ) throw (::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::uno::RuntimeException); 389 }; 390 391 392 #endif 393 394