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