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 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sc.hxx" 30 31 #include <com/sun/star/awt/MouseButton.hpp> 32 #include <com/sun/star/script/vba/VBAEventId.hpp> 33 #include <com/sun/star/script/vba/XVBAEventProcessor.hpp> 34 #include <com/sun/star/view/DocumentZoomType.hpp> 35 36 #include <editeng/outliner.hxx> 37 #include <svx/fmdpage.hxx> 38 #include <svx/svditer.hxx> 39 #include <svx/svdmark.hxx> 40 #include <svx/svdouno.hxx> 41 #include <svx/svdpage.hxx> 42 #include <svx/svdpagv.hxx> 43 #include <svx/svdview.hxx> 44 #include <svx/unoshape.hxx> 45 #include <svx/unoshcol.hxx> 46 #include <svx/fmshell.hxx> 47 #include <sfx2/bindings.hxx> 48 #include <sfx2/dispatch.hxx> 49 #include <sfx2/printer.hxx> 50 #include <sfx2/request.hxx> 51 #include <sfx2/viewfrm.hxx> 52 #include <rtl/uuid.h> 53 #include <toolkit/helper/convert.hxx> 54 #include <toolkit/helper/vclunohelper.hxx> 55 56 #include "drawsh.hxx" 57 #include "drtxtob.hxx" 58 #include "transobj.hxx" 59 #include "editsh.hxx" 60 #include "viewuno.hxx" 61 #include "cellsuno.hxx" 62 #include "miscuno.hxx" 63 #include "tabvwsh.hxx" 64 #include "docsh.hxx" 65 #include "drwlayer.hxx" 66 #include "drawview.hxx" 67 #include "fupoor.hxx" 68 #include "sc.hrc" 69 #include "unoguard.hxx" 70 #include "unonames.hxx" 71 #include "scmod.hxx" 72 #include "appoptio.hxx" 73 #include "gridwin.hxx" 74 #include "sheetevents.hxx" 75 #include "AccessibilityHints.hxx" 76 #include <svx/sdrhittesthelper.hxx> 77 78 using namespace com::sun::star; 79 80 //------------------------------------------------------------------------ 81 82 //! Clipping-Markierungen 83 84 // alles ohne Which-ID, Map nur fuer PropertySetInfo 85 86 const SfxItemPropertyMapEntry* lcl_GetViewOptPropertyMap() 87 { 88 static SfxItemPropertyMapEntry aViewOptPropertyMap_Impl[] = 89 { 90 {MAP_CHAR_LEN(OLD_UNO_COLROWHDR), 0, &getBooleanCppuType(), 0, 0}, 91 {MAP_CHAR_LEN(SC_UNO_GRIDCOLOR), 0, &getCppuType((sal_Int32*)0), 0, 0}, 92 {MAP_CHAR_LEN(SC_UNO_COLROWHDR), 0, &getBooleanCppuType(), 0, 0}, 93 {MAP_CHAR_LEN(SC_UNO_HORSCROLL), 0, &getBooleanCppuType(), 0, 0}, 94 {MAP_CHAR_LEN(SC_UNO_SHEETTABS), 0, &getBooleanCppuType(), 0, 0}, 95 {MAP_CHAR_LEN(SC_UNO_VERTSCROLL), 0, &getBooleanCppuType(), 0, 0}, 96 {MAP_CHAR_LEN(SC_UNO_HIDESPELL), 0, &getBooleanCppuType(), 0, 0}, /* deprecated #i91949 */ 97 {MAP_CHAR_LEN(OLD_UNO_HORSCROLL), 0, &getBooleanCppuType(), 0, 0}, 98 {MAP_CHAR_LEN(SC_UNO_OUTLSYMB), 0, &getBooleanCppuType(), 0, 0}, 99 {MAP_CHAR_LEN(SC_UNO_VALUEHIGH), 0, &getBooleanCppuType(), 0, 0}, 100 {MAP_CHAR_LEN(OLD_UNO_OUTLSYMB), 0, &getBooleanCppuType(), 0, 0}, 101 {MAP_CHAR_LEN(OLD_UNO_SHEETTABS), 0, &getBooleanCppuType(), 0, 0}, 102 {MAP_CHAR_LEN(SC_UNO_SHOWANCHOR), 0, &getBooleanCppuType(), 0, 0}, 103 {MAP_CHAR_LEN(SC_UNO_SHOWCHARTS), 0, &getCppuType((sal_Int16*)0), 0, 0}, 104 {MAP_CHAR_LEN(SC_UNO_SHOWDRAW), 0, &getCppuType((sal_Int16*)0), 0, 0}, 105 {MAP_CHAR_LEN(SC_UNO_SHOWFORM), 0, &getBooleanCppuType(), 0, 0}, 106 {MAP_CHAR_LEN(SC_UNO_SHOWGRID), 0, &getBooleanCppuType(), 0, 0}, 107 {MAP_CHAR_LEN(SC_UNO_SHOWHELP), 0, &getBooleanCppuType(), 0, 0}, 108 {MAP_CHAR_LEN(SC_UNO_SHOWNOTES), 0, &getBooleanCppuType(), 0, 0}, 109 {MAP_CHAR_LEN(SC_UNO_SHOWOBJ), 0, &getCppuType((sal_Int16*)0), 0, 0}, 110 {MAP_CHAR_LEN(SC_UNO_SHOWPAGEBR), 0, &getBooleanCppuType(), 0, 0}, 111 {MAP_CHAR_LEN(SC_UNO_SHOWZERO), 0, &getBooleanCppuType(), 0, 0}, 112 {MAP_CHAR_LEN(SC_UNO_SHOWSOLID), 0, &getBooleanCppuType(), 0, 0}, 113 {MAP_CHAR_LEN(OLD_UNO_VALUEHIGH), 0, &getBooleanCppuType(), 0, 0}, 114 {MAP_CHAR_LEN(OLD_UNO_VERTSCROLL), 0, &getBooleanCppuType(), 0, 0}, 115 {MAP_CHAR_LEN(SC_UNO_VISAREA), 0, &getCppuType((awt::Rectangle*)0), 0, 0}, 116 {MAP_CHAR_LEN(SC_UNO_ZOOMTYPE), 0, &getCppuType((sal_Int16*)0), 0, 0}, 117 {MAP_CHAR_LEN(SC_UNO_ZOOMVALUE), 0, &getCppuType((sal_Int16*)0), 0, 0}, 118 {MAP_CHAR_LEN(SC_UNO_VISAREASCREEN),0, &getCppuType((awt::Rectangle*)0), 0, 0}, 119 {0,0,0,0,0,0} 120 }; 121 return aViewOptPropertyMap_Impl; 122 } 123 124 //------------------------------------------------------------------------ 125 126 SV_IMPL_PTRARR( XRangeSelectionListenerArr_Impl, XRangeSelectionListenerPtr ); 127 SV_IMPL_PTRARR( XRangeSelectionChangeListenerArr_Impl, XRangeSelectionChangeListenerPtr ); 128 SV_IMPL_PTRARR( XSelectionChangeListenerArr_Impl, XSelectionChangeListenerPtr ); 129 SV_IMPL_PTRARR( XViewPropertyChangeListenerArr_Impl, XViewPropertyChangeListenerPtr ); 130 SV_IMPL_PTRARR( XMouseClickHandlerArr_Impl, XMouseClickHandlerPtr ); 131 SV_IMPL_PTRARR( XActivationEventListenerArr_Impl, XActivationEventListenerPtr ); 132 133 #define SCTABVIEWOBJ_SERVICE "com.sun.star.sheet.SpreadsheetView" 134 #define SCVIEWSETTINGS_SERVICE "com.sun.star.sheet.SpreadsheetViewSettings" 135 136 SC_SIMPLE_SERVICE_INFO( ScViewPaneBase, "ScViewPaneObj", "com.sun.star.sheet.SpreadsheetViewPane" ) 137 138 //------------------------------------------------------------------------ 139 140 ScViewPaneBase::ScViewPaneBase(ScTabViewShell* pViewSh, sal_uInt16 nP) : 141 pViewShell( pViewSh ), 142 nPane( nP ) 143 { 144 if (pViewShell) 145 StartListening(*pViewShell); 146 } 147 148 ScViewPaneBase::~ScViewPaneBase() 149 { 150 if (pViewShell) 151 EndListening(*pViewShell); 152 } 153 154 void ScViewPaneBase::Notify( SfxBroadcaster&, const SfxHint& rHint ) 155 { 156 if ( rHint.ISA( SfxSimpleHint ) && 157 ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING ) 158 pViewShell = NULL; 159 } 160 161 uno::Any SAL_CALL ScViewPaneBase::queryInterface( const uno::Type& rType ) 162 throw(uno::RuntimeException) 163 { 164 SC_QUERYINTERFACE( sheet::XViewPane ) 165 SC_QUERYINTERFACE( sheet::XCellRangeReferrer ) 166 SC_QUERYINTERFACE( view::XFormLayerAccess ) 167 SC_QUERYINTERFACE( view::XControlAccess ) 168 SC_QUERYINTERFACE( lang::XServiceInfo ) 169 SC_QUERYINTERFACE( lang::XTypeProvider ) 170 171 return uno::Any(); // OWeakObject is in derived objects 172 } 173 174 uno::Sequence<uno::Type> SAL_CALL ScViewPaneBase::getTypes() throw(uno::RuntimeException) 175 { 176 static uno::Sequence<uno::Type> aTypes; 177 if ( aTypes.getLength() == 0 ) 178 { 179 aTypes.realloc(5); 180 uno::Type* pPtr = aTypes.getArray(); 181 pPtr[0] = getCppuType((const uno::Reference<sheet::XViewPane>*)0); 182 pPtr[1] = getCppuType((const uno::Reference<sheet::XCellRangeReferrer>*)0); 183 pPtr[2] = getCppuType((const uno::Reference<view::XFormLayerAccess>*)0); 184 pPtr[3] = getCppuType((const uno::Reference<lang::XServiceInfo>*)0); 185 pPtr[4] = getCppuType((const uno::Reference<lang::XTypeProvider>*)0); 186 } 187 return aTypes; 188 } 189 190 uno::Sequence<sal_Int8> SAL_CALL ScViewPaneBase::getImplementationId() 191 throw(uno::RuntimeException) 192 { 193 static uno::Sequence< sal_Int8 > aId; 194 if( aId.getLength() == 0 ) 195 { 196 aId.realloc( 16 ); 197 rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); 198 } 199 return aId; 200 } 201 202 // XViewPane 203 204 sal_Int32 SAL_CALL ScViewPaneBase::getFirstVisibleColumn() throw(uno::RuntimeException) 205 { 206 ScUnoGuard aGuard; 207 if (pViewShell) 208 { 209 ScViewData* pViewData = pViewShell->GetViewData(); 210 ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ? 211 pViewData->GetActivePart() : 212 (ScSplitPos) nPane; 213 ScHSplitPos eWhichH = WhichH( eWhich ); 214 215 return pViewData->GetPosX( eWhichH ); 216 } 217 DBG_ERROR("keine View ?!?"); //! Exception? 218 return 0; 219 } 220 221 void SAL_CALL ScViewPaneBase::setFirstVisibleColumn( sal_Int32 nFirstVisibleColumn ) 222 throw(uno::RuntimeException) 223 { 224 ScUnoGuard aGuard; 225 if (pViewShell) 226 { 227 ScViewData* pViewData = pViewShell->GetViewData(); 228 ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ? 229 pViewData->GetActivePart() : 230 (ScSplitPos) nPane; 231 ScHSplitPos eWhichH = WhichH( eWhich ); 232 233 long nDeltaX = ((long)nFirstVisibleColumn) - pViewData->GetPosX( eWhichH ); 234 pViewShell->ScrollX( nDeltaX, eWhichH ); 235 } 236 } 237 238 sal_Int32 SAL_CALL ScViewPaneBase::getFirstVisibleRow() throw(uno::RuntimeException) 239 { 240 ScUnoGuard aGuard; 241 if (pViewShell) 242 { 243 ScViewData* pViewData = pViewShell->GetViewData(); 244 ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ? 245 pViewData->GetActivePart() : 246 (ScSplitPos) nPane; 247 ScVSplitPos eWhichV = WhichV( eWhich ); 248 249 return pViewData->GetPosY( eWhichV ); 250 } 251 DBG_ERROR("keine View ?!?"); //! Exception? 252 return 0; 253 } 254 255 void SAL_CALL ScViewPaneBase::setFirstVisibleRow( sal_Int32 nFirstVisibleRow ) 256 throw(uno::RuntimeException) 257 { 258 ScUnoGuard aGuard; 259 if (pViewShell) 260 { 261 ScViewData* pViewData = pViewShell->GetViewData(); 262 ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ? 263 pViewData->GetActivePart() : 264 (ScSplitPos) nPane; 265 ScVSplitPos eWhichV = WhichV( eWhich ); 266 267 long nDeltaY = ((long)nFirstVisibleRow) - pViewData->GetPosY( eWhichV ); 268 pViewShell->ScrollY( nDeltaY, eWhichV ); 269 } 270 } 271 272 table::CellRangeAddress SAL_CALL ScViewPaneBase::getVisibleRange() throw(uno::RuntimeException) 273 { 274 ScUnoGuard aGuard; 275 table::CellRangeAddress aAdr; 276 if (pViewShell) 277 { 278 ScViewData* pViewData = pViewShell->GetViewData(); 279 ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ? 280 pViewData->GetActivePart() : 281 (ScSplitPos) nPane; 282 ScHSplitPos eWhichH = WhichH( eWhich ); 283 ScVSplitPos eWhichV = WhichV( eWhich ); 284 285 // VisibleCellsX gibt nur komplett sichtbare Zellen, 286 // VisibleRange in Excel auch teilweise sichtbare. 287 //! anpassen ??? 288 289 SCCOL nVisX = pViewData->VisibleCellsX( eWhichH ); 290 SCROW nVisY = pViewData->VisibleCellsY( eWhichV ); 291 if (!nVisX) nVisX = 1; // irgendwas muss ja im Range sein 292 if (!nVisY) nVisY = 1; 293 aAdr.Sheet = pViewData->GetTabNo(); 294 aAdr.StartColumn = pViewData->GetPosX( eWhichH ); 295 aAdr.StartRow = pViewData->GetPosY( eWhichV ); 296 aAdr.EndColumn = aAdr.StartColumn + nVisX - 1; 297 aAdr.EndRow = aAdr.StartRow + nVisY - 1; 298 } 299 return aAdr; 300 } 301 302 // XCellRangeSource 303 304 uno::Reference<table::XCellRange> SAL_CALL ScViewPaneBase::getReferredCells() 305 throw(uno::RuntimeException) 306 { 307 ScUnoGuard aGuard; 308 if (pViewShell) 309 { 310 ScDocShell* pDocSh = pViewShell->GetViewData()->GetDocShell(); 311 312 table::CellRangeAddress aAdr(getVisibleRange()); //! Hilfsfunktion mit ScRange? 313 ScRange aRange( (SCCOL)aAdr.StartColumn, (SCROW)aAdr.StartRow, aAdr.Sheet, 314 (SCCOL)aAdr.EndColumn, (SCROW)aAdr.EndRow, aAdr.Sheet ); 315 if ( aRange.aStart == aRange.aEnd ) 316 return new ScCellObj( pDocSh, aRange.aStart ); 317 else 318 return new ScCellRangeObj( pDocSh, aRange ); 319 } 320 321 return NULL; 322 } 323 324 namespace 325 { 326 bool lcl_prepareFormShellCall( ScTabViewShell* _pViewShell, sal_uInt16 _nPane, FmFormShell*& _rpFormShell, Window*& _rpWindow, SdrView*& _rpSdrView ) 327 { 328 if ( !_pViewShell ) 329 return false; 330 331 ScViewData* pViewData = _pViewShell->GetViewData(); 332 ScSplitPos eWhich = ( _nPane == SC_VIEWPANE_ACTIVE ) ? 333 pViewData->GetActivePart() : 334 (ScSplitPos) _nPane; 335 _rpWindow = _pViewShell->GetWindowByPos( eWhich ); 336 _rpSdrView = _pViewShell->GetSdrView(); 337 _rpFormShell = _pViewShell->GetFormShell(); 338 return ( _rpFormShell != NULL ) && ( _rpSdrView != NULL )&& ( _rpWindow != NULL ); 339 } 340 } 341 342 // XFormLayerAccess 343 uno::Reference< form::runtime::XFormController > SAL_CALL ScViewPaneBase::getFormController( const uno::Reference< form::XForm >& _Form ) throw (uno::RuntimeException) 344 { 345 ScUnoGuard aGuard; 346 347 uno::Reference< form::runtime::XFormController > xController; 348 349 Window* pWindow( NULL ); 350 SdrView* pSdrView( NULL ); 351 FmFormShell* pFormShell( NULL ); 352 if ( lcl_prepareFormShellCall( pViewShell, nPane, pFormShell, pWindow, pSdrView ) ) 353 xController = pFormShell->GetFormController( _Form, *pSdrView, *pWindow ); 354 355 return xController; 356 } 357 358 ::sal_Bool SAL_CALL ScViewPaneBase::isFormDesignMode( ) throw (uno::RuntimeException) 359 { 360 ScUnoGuard aGuard; 361 362 sal_Bool bIsFormDesignMode( sal_True ); 363 364 FmFormShell* pFormShell( pViewShell ? pViewShell->GetFormShell() : NULL ); 365 if ( pFormShell ) 366 bIsFormDesignMode = pFormShell->IsDesignMode(); 367 368 return bIsFormDesignMode; 369 } 370 371 void SAL_CALL ScViewPaneBase::setFormDesignMode( ::sal_Bool _DesignMode ) throw (uno::RuntimeException) 372 { 373 ScUnoGuard aGuard; 374 375 Window* pWindow( NULL ); 376 SdrView* pSdrView( NULL ); 377 FmFormShell* pFormShell( NULL ); 378 if ( lcl_prepareFormShellCall( pViewShell, nPane, pFormShell, pWindow, pSdrView ) ) 379 pFormShell->SetDesignMode( _DesignMode ); 380 } 381 382 // XControlAccess 383 384 uno::Reference<awt::XControl> SAL_CALL ScViewPaneBase::getControl( 385 const uno::Reference<awt::XControlModel>& xModel ) 386 throw(container::NoSuchElementException, uno::RuntimeException) 387 { 388 ScUnoGuard aGuard; 389 390 uno::Reference<awt::XControl> xRet; 391 392 Window* pWindow( NULL ); 393 SdrView* pSdrView( NULL ); 394 FmFormShell* pFormShell( NULL ); 395 if ( lcl_prepareFormShellCall( pViewShell, nPane, pFormShell, pWindow, pSdrView ) ) 396 pFormShell->GetFormControl( xModel, *pSdrView, *pWindow, xRet ); 397 398 if ( !xRet.is() ) 399 throw container::NoSuchElementException(); // no control found 400 401 return xRet; 402 } 403 404 awt::Rectangle ScViewPaneBase::GetVisArea() const 405 { 406 awt::Rectangle aVisArea; 407 if (pViewShell) 408 { 409 ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ? 410 pViewShell->GetViewData()->GetActivePart() : 411 (ScSplitPos) nPane; 412 ScGridWindow* pWindow = (ScGridWindow*)pViewShell->GetWindowByPos(eWhich); 413 ScDocument* pDoc = pViewShell->GetViewData()->GetDocument(); 414 if (pWindow && pDoc) 415 { 416 ScHSplitPos eWhichH = ((eWhich == SC_SPLIT_TOPLEFT) || (eWhich == SC_SPLIT_BOTTOMLEFT)) ? 417 SC_SPLIT_LEFT : SC_SPLIT_RIGHT; 418 ScVSplitPos eWhichV = ((eWhich == SC_SPLIT_TOPLEFT) || (eWhich == SC_SPLIT_TOPRIGHT)) ? 419 SC_SPLIT_TOP : SC_SPLIT_BOTTOM; 420 ScAddress aCell(pViewShell->GetViewData()->GetPosX(eWhichH), 421 pViewShell->GetViewData()->GetPosY(eWhichV), 422 pViewShell->GetViewData()->GetTabNo()); 423 Rectangle aCellRect( pDoc->GetMMRect( aCell.Col(), aCell.Row(), aCell.Col(), aCell.Row(), aCell.Tab() ) ); 424 Size aVisSize( pWindow->PixelToLogic( pWindow->GetSizePixel(), pWindow->GetDrawMapMode( sal_True ) ) ); 425 Point aVisPos( aCellRect.TopLeft() ); 426 if ( pDoc->IsLayoutRTL( aCell.Tab() ) ) 427 { 428 aVisPos = aCellRect.TopRight(); 429 aVisPos.X() -= aVisSize.Width(); 430 } 431 Rectangle aVisRect( aVisPos, aVisSize ); 432 aVisArea = AWTRectangle(aVisRect); 433 } 434 } 435 return aVisArea; 436 } 437 438 //------------------------------------------------------------------------ 439 440 ScViewPaneObj::ScViewPaneObj(ScTabViewShell* pViewSh, sal_uInt16 nP) : 441 ScViewPaneBase( pViewSh, nP ) 442 { 443 } 444 445 ScViewPaneObj::~ScViewPaneObj() 446 { 447 } 448 449 uno::Any SAL_CALL ScViewPaneObj::queryInterface( const uno::Type& rType ) 450 throw(uno::RuntimeException) 451 { 452 // ScViewPaneBase has everything except OWeakObject 453 454 uno::Any aRet(ScViewPaneBase::queryInterface( rType )); 455 if (!aRet.hasValue()) 456 aRet = OWeakObject::queryInterface( rType ); 457 return aRet; 458 } 459 460 void SAL_CALL ScViewPaneObj::acquire() throw() 461 { 462 OWeakObject::acquire(); 463 } 464 465 void SAL_CALL ScViewPaneObj::release() throw() 466 { 467 OWeakObject::release(); 468 } 469 470 //------------------------------------------------------------------------ 471 472 // Default-ctor wird fuer SMART_REFLECTION_IMPLEMENTATION gebraucht 473 474 //UNUSED2008-05 ScTabViewObj::ScTabViewObj() : 475 //UNUSED2008-05 ScViewPaneBase( NULL, SC_VIEWPANE_ACTIVE ), 476 //UNUSED2008-05 SfxBaseController( NULL ), 477 //UNUSED2008-05 aPropSet( lcl_GetViewOptPropertyMap() ), 478 //UNUSED2008-05 aMouseClickHandlers( 0 ), 479 //UNUSED2008-05 aActivationListeners( 0 ), 480 //UNUSED2008-05 bDrawSelModeSet(sal_False), 481 //UNUSED2008-05 bFilteredRangeSelection(sal_True) 482 //UNUSED2008-05 { 483 //UNUSED2008-05 } 484 485 ScTabViewObj::ScTabViewObj( ScTabViewShell* pViewSh ) : 486 ScViewPaneBase( pViewSh, SC_VIEWPANE_ACTIVE ), 487 SfxBaseController( pViewSh ), 488 aPropSet( lcl_GetViewOptPropertyMap() ), 489 aMouseClickHandlers( 0 ), 490 aActivationListeners( 0 ), 491 nPreviousTab( 0 ), 492 bDrawSelModeSet(sal_False) 493 { 494 if (pViewSh) 495 nPreviousTab = pViewSh->GetViewData()->GetTabNo(); 496 } 497 498 ScTabViewObj::~ScTabViewObj() 499 { 500 //! Listening oder so 501 if (aMouseClickHandlers.Count()) 502 { 503 acquire(); 504 EndMouseListening(); 505 } 506 if (aActivationListeners.Count()) 507 { 508 acquire(); 509 EndActivationListening(); 510 } 511 } 512 513 uno::Any SAL_CALL ScTabViewObj::queryInterface( const uno::Type& rType ) 514 throw(uno::RuntimeException) 515 { 516 SC_QUERYINTERFACE( sheet::XSpreadsheetView ) 517 SC_QUERYINTERFACE( sheet::XEnhancedMouseClickBroadcaster ) 518 SC_QUERYINTERFACE( sheet::XActivationBroadcaster ) 519 SC_QUERYINTERFACE( container::XEnumerationAccess ) 520 SC_QUERYINTERFACE( container::XIndexAccess ) 521 SC_QUERY_MULTIPLE( container::XElementAccess, container::XIndexAccess ) 522 SC_QUERYINTERFACE( view::XSelectionSupplier ) 523 SC_QUERYINTERFACE( beans::XPropertySet ) 524 SC_QUERYINTERFACE( sheet::XViewSplitable ) 525 SC_QUERYINTERFACE( sheet::XViewFreezable ) 526 SC_QUERYINTERFACE( sheet::XRangeSelection ) 527 SC_QUERYINTERFACE( lang::XUnoTunnel ) 528 SC_QUERYINTERFACE( datatransfer::XTransferableSupplier ) 529 530 uno::Any aRet(ScViewPaneBase::queryInterface( rType )); 531 if (!aRet.hasValue()) 532 aRet = SfxBaseController::queryInterface( rType ); 533 return aRet; 534 } 535 536 void SAL_CALL ScTabViewObj::acquire() throw() 537 { 538 SfxBaseController::acquire(); 539 } 540 541 void SAL_CALL ScTabViewObj::release() throw() 542 { 543 SfxBaseController::release(); 544 } 545 546 void lcl_CallActivate( ScDocShell* pDocSh, SCTAB nTab, sal_Int32 nEvent ) 547 { 548 ScDocument* pDoc = pDocSh->GetDocument(); 549 // when deleting a sheet, nPreviousTab can be invalid 550 // (could be handled with reference updates) 551 if (!pDoc->HasTable(nTab)) 552 return; 553 554 const ScSheetEvents* pEvents = pDoc->GetSheetEvents(nTab); 555 if (pEvents) 556 { 557 const rtl::OUString* pScript = pEvents->GetScript(nEvent); 558 if (pScript) 559 { 560 uno::Any aRet; 561 uno::Sequence<uno::Any> aParams; 562 uno::Sequence<sal_Int16> aOutArgsIndex; 563 uno::Sequence<uno::Any> aOutArgs; 564 /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs ); 565 } 566 } 567 568 // execute VBA event handlers 569 try 570 { 571 uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW ); 572 // the parameter is the clicked object, as in the mousePressed call above 573 uno::Sequence< uno::Any > aArgs( 1 ); 574 aArgs[ 0 ] <<= nTab; 575 xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs ); 576 } 577 catch( uno::Exception& ) 578 { 579 } 580 } 581 582 void ScTabViewObj::SheetChanged( bool bSameTabButMoved ) 583 { 584 if ( !GetViewShell() ) 585 return; 586 587 ScViewData* pViewData = GetViewShell()->GetViewData(); 588 ScDocShell* pDocSh = pViewData->GetDocShell(); 589 if (aActivationListeners.Count() > 0) 590 { 591 sheet::ActivationEvent aEvent; 592 uno::Reference< sheet::XSpreadsheetView > xView(this); 593 uno::Reference< uno::XInterface > xSource(xView, uno::UNO_QUERY); 594 aEvent.Source = xSource; 595 aEvent.ActiveSheet = new ScTableSheetObj(pDocSh, pViewData->GetTabNo()); 596 for ( sal_uInt16 n=0; n<aActivationListeners.Count(); n++ ) 597 { 598 try 599 { 600 (*aActivationListeners[n])->activeSpreadsheetChanged( aEvent ); 601 } 602 catch( uno::Exception& ) 603 { 604 aActivationListeners.DeleteAndDestroy( n ); 605 --n; // because it will be increased again in the loop 606 } 607 } 608 } 609 610 /* Handle sheet events, but do not trigger event handlers, if the old 611 active sheet gets re-activated after inserting/deleting/moving a sheet. */ 612 SCTAB nNewTab = pViewData->GetTabNo(); 613 if ( !bSameTabButMoved && (nNewTab != nPreviousTab) ) 614 { 615 lcl_CallActivate( pDocSh, nPreviousTab, SC_SHEETEVENT_UNFOCUS ); 616 lcl_CallActivate( pDocSh, nNewTab, SC_SHEETEVENT_FOCUS ); 617 } 618 nPreviousTab = nNewTab; 619 } 620 621 uno::Sequence<uno::Type> SAL_CALL ScTabViewObj::getTypes() throw(uno::RuntimeException) 622 { 623 static uno::Sequence<uno::Type> aTypes; 624 if ( aTypes.getLength() == 0 ) 625 { 626 uno::Sequence<uno::Type> aViewPaneTypes(ScViewPaneBase::getTypes()); 627 long nViewPaneLen = aViewPaneTypes.getLength(); 628 const uno::Type* pViewPanePtr = aViewPaneTypes.getConstArray(); 629 630 uno::Sequence<uno::Type> aControllerTypes(SfxBaseController::getTypes()); 631 long nControllerLen = aControllerTypes.getLength(); 632 const uno::Type* pControllerPtr = aControllerTypes.getConstArray(); 633 634 long nParentLen = nViewPaneLen + nControllerLen; 635 636 aTypes.realloc( nParentLen + 12 ); 637 uno::Type* pPtr = aTypes.getArray(); 638 pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XSpreadsheetView>*)0); 639 pPtr[nParentLen + 1] = getCppuType((const uno::Reference<container::XEnumerationAccess>*)0); 640 pPtr[nParentLen + 2] = getCppuType((const uno::Reference<container::XIndexAccess>*)0); 641 pPtr[nParentLen + 3] = getCppuType((const uno::Reference<view::XSelectionSupplier>*)0); 642 pPtr[nParentLen + 4] = getCppuType((const uno::Reference<beans::XPropertySet>*)0); 643 pPtr[nParentLen + 5] = getCppuType((const uno::Reference<sheet::XViewSplitable>*)0); 644 pPtr[nParentLen + 6] = getCppuType((const uno::Reference<sheet::XViewFreezable>*)0); 645 pPtr[nParentLen + 7] = getCppuType((const uno::Reference<sheet::XRangeSelection>*)0); 646 pPtr[nParentLen + 8] = getCppuType((const uno::Reference<lang::XUnoTunnel>*)0); 647 pPtr[nParentLen + 9] = getCppuType((const uno::Reference<sheet::XEnhancedMouseClickBroadcaster>*)0); 648 pPtr[nParentLen + 10] = getCppuType((const uno::Reference<sheet::XActivationBroadcaster>*)0); 649 pPtr[nParentLen + 11] = getCppuType((const uno::Reference<datatransfer::XTransferableSupplier>*)0); 650 651 long i; 652 for (i=0; i<nViewPaneLen; i++) 653 pPtr[i] = pViewPanePtr[i]; // parent types first 654 for (i=0; i<nControllerLen; i++) 655 pPtr[nViewPaneLen+i] = pControllerPtr[i]; 656 } 657 return aTypes; 658 } 659 660 uno::Sequence<sal_Int8> SAL_CALL ScTabViewObj::getImplementationId() 661 throw(uno::RuntimeException) 662 { 663 static uno::Sequence< sal_Int8 > aId; 664 if( aId.getLength() == 0 ) 665 { 666 aId.realloc( 16 ); 667 rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); 668 } 669 return aId; 670 } 671 672 // XDocumentView 673 674 sal_Bool lcl_TabInRanges( SCTAB nTab, const ScRangeList& rRanges ) 675 { 676 sal_uLong nCount = rRanges.Count(); 677 for (sal_uLong i=0; i<nCount; i++) 678 { 679 const ScRange* pRange = rRanges.GetObject(i); 680 if ( nTab >= pRange->aStart.Tab() && nTab <= pRange->aEnd.Tab() ) 681 return sal_True; 682 } 683 return sal_False; 684 } 685 686 void lcl_ShowObject( ScTabViewShell& rViewSh, ScDrawView& rDrawView, SdrObject* pSelObj ) 687 { 688 sal_Bool bFound = sal_False; 689 SCTAB nObjectTab = 0; 690 691 SdrModel* pModel = rDrawView.GetModel(); 692 sal_uInt16 nPageCount = pModel->GetPageCount(); 693 for (sal_uInt16 i=0; i<nPageCount && !bFound; i++) 694 { 695 SdrPage* pPage = pModel->GetPage(i); 696 if (pPage) 697 { 698 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS ); 699 SdrObject* pObject = aIter.Next(); 700 while (pObject && !bFound) 701 { 702 if ( pObject == pSelObj ) 703 { 704 bFound = sal_True; 705 nObjectTab = static_cast<SCTAB>(i); 706 } 707 pObject = aIter.Next(); 708 } 709 } 710 } 711 712 if (bFound) 713 { 714 rViewSh.SetTabNo( nObjectTab ); 715 rViewSh.ScrollToObject( pSelObj ); 716 } 717 } 718 719 sal_Bool SAL_CALL ScTabViewObj::select( const uno::Any& aSelection ) 720 throw(lang::IllegalArgumentException, uno::RuntimeException) 721 { 722 ScUnoGuard aGuard; 723 ScTabViewShell* pViewSh = GetViewShell(); 724 725 if ( !pViewSh ) 726 return sal_False; 727 728 //! Type of aSelection can be some specific interface instead of XInterface 729 730 sal_Bool bRet = sal_False; 731 uno::Reference<uno::XInterface> xInterface(aSelection, uno::UNO_QUERY); 732 if ( !xInterface.is() ) //clear all selections 733 { 734 ScDrawView* pDrawView = pViewSh->GetScDrawView(); 735 if (pDrawView) 736 { 737 pDrawView->ScEndTextEdit(); 738 pDrawView->UnmarkAll(); 739 } 740 else //#102232#; if there is no DrawView remove range selection 741 pViewSh->Unmark(); 742 bRet = sal_True; 743 } 744 745 if (bDrawSelModeSet) // remove DrawSelMode if set by API; if necessary it will be set again later 746 { 747 pViewSh->SetDrawSelMode(sal_False); 748 pViewSh->UpdateLayerLocks(); 749 bDrawSelModeSet = sal_False; 750 } 751 752 if (bRet) 753 return bRet; 754 755 756 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xInterface ); 757 uno::Reference<drawing::XShapes> xShapeColl( xInterface, uno::UNO_QUERY ); 758 uno::Reference<drawing::XShape> xShapeSel( xInterface, uno::UNO_QUERY ); 759 SvxShape* pShapeImp = SvxShape::getImplementation( xShapeSel ); 760 761 if (pRangesImp) // Zell-Ranges 762 { 763 ScViewData* pViewData = pViewSh->GetViewData(); 764 if ( pViewData->GetDocShell() == pRangesImp->GetDocShell() ) 765 { 766 // Zuerst evtl. Drawing-Selektion aufheben 767 // (MarkListHasChanged hebt Tabellen-Selektion auf) 768 769 ScDrawView* pDrawView = pViewSh->GetScDrawView(); 770 if (pDrawView) 771 { 772 pDrawView->ScEndTextEdit(); 773 pDrawView->UnmarkAll(); 774 } 775 FuPoor* pFunc = pViewSh->GetDrawFuncPtr(); 776 if ( pFunc && pFunc->GetSlotID() != SID_OBJECT_SELECT ) 777 { 778 // Slot der Zeichenfunktion nochmal ausfuehren -> abschalten 779 SfxDispatcher* pDisp = pViewSh->GetDispatcher(); 780 if (pDisp) 781 pDisp->Execute( pFunc->GetSlotID(), SFX_CALLMODE_SYNCHRON ); 782 } 783 pViewSh->SetDrawShell(sal_False); 784 pViewSh->SetDrawSelMode(sal_False); // nach dem Dispatcher-Execute 785 786 // Ranges selektieren 787 788 const ScRangeList& rRanges = pRangesImp->GetRangeList(); 789 sal_uLong nRangeCount = rRanges.Count(); 790 // for empty range list, remove selection (cursor remains where it was) 791 if ( nRangeCount == 0 ) 792 pViewSh->Unmark(); 793 else if ( nRangeCount == 1 ) 794 pViewSh->MarkRange( *rRanges.GetObject(0) ); 795 else 796 { 797 // Mehrfachselektion 798 799 const ScRange* pFirst = rRanges.GetObject(0); 800 if ( pFirst && !lcl_TabInRanges( pViewData->GetTabNo(), rRanges ) ) 801 pViewSh->SetTabNo( pFirst->aStart.Tab() ); 802 pViewSh->DoneBlockMode(); 803 pViewSh->InitOwnBlockMode(); 804 pViewData->GetMarkData().MarkFromRangeList( rRanges, sal_True ); 805 pViewSh->MarkDataChanged(); 806 pViewData->GetDocShell()->PostPaintGridAll(); // Markierung (alt&neu) 807 if ( pFirst ) 808 { 809 pViewSh->AlignToCursor( pFirst->aStart.Col(), pFirst->aStart.Row(), 810 SC_FOLLOW_JUMP ); 811 pViewSh->SetCursor( pFirst->aStart.Col(), pFirst->aStart.Row() ); 812 } 813 814 //! Methode an der View, um RangeList zu selektieren 815 } 816 bRet = sal_True; 817 } 818 } 819 else if ( pShapeImp || xShapeColl.is() ) // Drawing-Layer 820 { 821 ScDrawView* pDrawView = pViewSh->GetScDrawView(); 822 if (pDrawView) 823 { 824 pDrawView->ScEndTextEdit(); 825 pDrawView->UnmarkAll(); 826 827 if (pShapeImp) // einzelnes Shape 828 { 829 SdrObject *pObj = pShapeImp->GetSdrObject(); 830 if (pObj) 831 { 832 lcl_ShowObject( *pViewSh, *pDrawView, pObj ); 833 SdrPageView* pPV = pDrawView->GetSdrPageView(); 834 if ( pPV && pObj->GetPage() == pPV->GetPage() ) 835 { 836 pDrawView->MarkObj( pObj, pPV ); 837 bRet = sal_True; 838 } 839 } 840 } 841 else // Shape-Collection (xShapeColl ist nicht 0) 842 { 843 // Es wird auf die Tabelle des ersten Objekts umgeschaltet, 844 // und alle Objekte selektiert, die auf dieser Tabelle liegen 845 //! Exception, wenn Objekte auf verschiedenen Tabellen? 846 847 SdrPageView* pPV = NULL; 848 long nCount = xShapeColl->getCount(); 849 if (nCount) 850 { 851 sal_Bool bAllMarked(sal_True); 852 for ( long i = 0; i < nCount; i++ ) 853 { 854 uno::Reference<drawing::XShape> xShapeInt(xShapeColl->getByIndex(i), uno::UNO_QUERY); 855 if (xShapeInt.is()) 856 { 857 SvxShape* pShape = SvxShape::getImplementation( xShapeInt ); 858 if (pShape) 859 { 860 SdrObject *pObj = pShape->GetSdrObject(); 861 if (pObj) 862 { 863 if (!bDrawSelModeSet && (pObj->GetLayer() == SC_LAYER_BACK)) 864 { 865 pViewSh->SetDrawSelMode(sal_True); 866 pViewSh->UpdateLayerLocks(); 867 bDrawSelModeSet = sal_True; 868 } 869 if (!pPV) // erstes Objekt 870 { 871 lcl_ShowObject( *pViewSh, *pDrawView, pObj ); 872 pPV = pDrawView->GetSdrPageView(); 873 } 874 if ( pPV && pObj->GetPage() == pPV->GetPage() ) 875 { 876 if (pDrawView->IsObjMarkable( pObj, pPV )) 877 pDrawView->MarkObj( pObj, pPV ); 878 else 879 bAllMarked = sal_False; 880 } 881 } 882 } 883 } 884 } 885 if (bAllMarked) 886 bRet = sal_True; 887 } 888 else 889 bRet = sal_True; // empty XShapes (all shapes are deselected) 890 } 891 892 if (bRet) 893 pViewSh->SetDrawShell(sal_True); 894 } 895 } 896 897 if (!bRet) 898 throw lang::IllegalArgumentException(); 899 900 return bRet; 901 } 902 903 uno::Any SAL_CALL ScTabViewObj::getSelection() throw(uno::RuntimeException) 904 { 905 ScUnoGuard aGuard; 906 ScTabViewShell* pViewSh = GetViewShell(); 907 ScCellRangesBase* pObj = NULL; 908 if (pViewSh) 909 { 910 // Ist auf dem Drawing-Layer etwas selektiert? 911 912 SdrView* pDrawView = pViewSh->GetSdrView(); 913 if (pDrawView) 914 { 915 const SdrMarkList& rMarkList = pDrawView->GetMarkedObjectList(); 916 sal_uLong nMarkCount = rMarkList.GetMarkCount(); 917 if (nMarkCount) 918 { 919 // ShapeCollection erzeugen (wie in SdXImpressView::getSelection im Draw) 920 // Zurueckgegeben wird XInterfaceRef, das muss das UsrObject-XInterface sein 921 922 SvxShapeCollection* pShapes = new SvxShapeCollection(); 923 uno::Reference<uno::XInterface> xRet(static_cast<cppu::OWeakObject*>(pShapes)); 924 925 for (sal_uLong i=0; i<nMarkCount; i++) 926 { 927 SdrObject* pDrawObj = rMarkList.GetMark(i)->GetMarkedSdrObj(); 928 if (pDrawObj) 929 { 930 uno::Reference<drawing::XShape> xShape( pDrawObj->getUnoShape(), uno::UNO_QUERY ); 931 if (xShape.is()) 932 pShapes->add(xShape); 933 } 934 } 935 return uno::makeAny(xRet); 936 } 937 } 938 939 // sonst Tabellen-(Zellen-)Selektion 940 941 ScViewData* pViewData = pViewSh->GetViewData(); 942 ScDocShell* pDocSh = pViewData->GetDocShell(); 943 944 const ScMarkData& rMark = pViewData->GetMarkData(); 945 SCTAB nTabs = rMark.GetSelectCount(); 946 947 ScRange aRange; 948 ScMarkType eMarkType = pViewData->GetSimpleArea(aRange); 949 if ( nTabs == 1 && (eMarkType == SC_MARK_SIMPLE) ) 950 { 951 if (aRange.aStart == aRange.aEnd) 952 pObj = new ScCellObj( pDocSh, aRange.aStart ); 953 else 954 pObj = new ScCellRangeObj( pDocSh, aRange ); 955 } 956 else if ( nTabs == 1 && (eMarkType == SC_MARK_SIMPLE_FILTERED) ) 957 { 958 ScMarkData aFilteredMark( rMark ); 959 ScViewUtil::UnmarkFiltered( aFilteredMark, pDocSh->GetDocument()); 960 ScRangeList aRangeList; 961 aFilteredMark.FillRangeListWithMarks( &aRangeList, sal_False); 962 // Theoretically a selection may start and end on a filtered row. 963 switch (aRangeList.Count()) 964 { 965 case 0: 966 // No unfiltered row, we have to return some object, so 967 // here is one with no ranges. 968 pObj = new ScCellRangesObj( pDocSh, aRangeList ); 969 break; 970 case 1: 971 { 972 const ScRange& rRange = *(aRangeList.GetObject(0)); 973 if (rRange.aStart == rRange.aEnd) 974 pObj = new ScCellObj( pDocSh, rRange.aStart ); 975 else 976 pObj = new ScCellRangeObj( pDocSh, rRange ); 977 } 978 break; 979 default: 980 pObj = new ScCellRangesObj( pDocSh, aRangeList ); 981 } 982 } 983 else // Mehrfachselektion 984 { 985 ScRangeListRef xRanges; 986 pViewData->GetMultiArea( xRanges ); 987 988 // bei mehreren Tabellen Ranges kopieren 989 //! sollte eigentlich schon in ScMarkData::FillRangeListWithMarks passieren? 990 if ( nTabs > 1 ) 991 rMark.ExtendRangeListTables( xRanges ); 992 993 pObj = new ScCellRangesObj( pDocSh, *xRanges ); 994 } 995 996 if ( !rMark.IsMarked() && !rMark.IsMultiMarked() ) 997 { 998 // remember if the selection was from the cursor position without anything selected 999 // (used when rendering the selection) 1000 1001 pObj->SetCursorOnly( sal_True ); 1002 } 1003 } 1004 1005 return uno::makeAny(uno::Reference<uno::XInterface>(static_cast<cppu::OWeakObject*>(pObj))); 1006 } 1007 1008 1009 #if 0 1010 // XPrintable 1011 1012 rtl::OUString ScTabViewObj::getPrinterName(void) const 1013 { 1014 ScUnoGuard aGuard; 1015 ScTabViewShell* pViewSh = GetViewShell(); 1016 if (pViewSh) 1017 { 1018 SfxPrinter* pPrinter = pViewSh->GetPrinter(sal_True); 1019 if (pPrinter) 1020 return pPrinter->GetName(); 1021 } 1022 1023 DBG_ERROR("getPrinterName: keine View oder kein Printer"); 1024 return rtl::OUString(); 1025 } 1026 1027 void ScTabViewObj::setPrinterName(const rtl::OUString& PrinterName) 1028 { 1029 ScUnoGuard aGuard; 1030 // Drucker setzen - wie in SfxViewShell::ExecPrint_Impl 1031 1032 ScTabViewShell* pViewSh = GetViewShell(); 1033 if (pViewSh) 1034 { 1035 SfxPrinter* pPrinter = pViewSh->GetPrinter(sal_True); 1036 if (pPrinter) 1037 { 1038 String aString(PrinterName); 1039 SfxPrinter* pNewPrinter = new SfxPrinter( pPrinter->GetOptions().Clone(), aString ); 1040 if (pNewPrinter->IsKnown()) 1041 pViewSh->SetPrinter( pNewPrinter, SFX_PRINTER_PRINTER ); 1042 else 1043 delete pNewPrinter; 1044 } 1045 } 1046 } 1047 1048 XPropertySetRef ScTabViewObj::createPrintOptions(void) 1049 { 1050 ScUnoGuard aGuard; 1051 return new ScPrintSettingsObj; //! ScPrintSettingsObj implementieren! 1052 } 1053 1054 void ScTabViewObj::print(const XPropertySetRef& xOptions) 1055 { 1056 ScUnoGuard aGuard; 1057 ScTabViewShell* pViewSh = GetViewShell(); 1058 if (pViewSh) 1059 { 1060 //! xOptions auswerten (wie denn?) 1061 1062 SfxRequest aReq( SID_PRINTDOCDIRECT, SFX_CALLMODE_SYNCHRON, pViewSh->GetPool() ); 1063 pViewSh->ExecuteSlot( aReq ); 1064 } 1065 } 1066 #endif 1067 1068 // XEnumerationAccess 1069 1070 uno::Reference<container::XEnumeration> SAL_CALL ScTabViewObj::createEnumeration() 1071 throw(uno::RuntimeException) 1072 { 1073 ScUnoGuard aGuard; 1074 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetViewPanesEnumeration"))); 1075 } 1076 1077 // XIndexAccess 1078 1079 sal_Int32 SAL_CALL ScTabViewObj::getCount() throw(uno::RuntimeException) 1080 { 1081 ScUnoGuard aGuard; 1082 ScTabViewShell* pViewSh = GetViewShell(); 1083 sal_uInt16 nPanes = 0; 1084 if (pViewSh) 1085 { 1086 nPanes = 1; 1087 ScViewData* pViewData = pViewSh->GetViewData(); 1088 if ( pViewData->GetHSplitMode() != SC_SPLIT_NONE ) 1089 nPanes *= 2; 1090 if ( pViewData->GetVSplitMode() != SC_SPLIT_NONE ) 1091 nPanes *= 2; 1092 } 1093 return nPanes; 1094 } 1095 1096 uno::Any SAL_CALL ScTabViewObj::getByIndex( sal_Int32 nIndex ) 1097 throw(lang::IndexOutOfBoundsException, 1098 lang::WrappedTargetException, uno::RuntimeException) 1099 { 1100 ScUnoGuard aGuard; 1101 uno::Reference<sheet::XViewPane> xPane(GetObjectByIndex_Impl((sal_uInt16)nIndex)); 1102 if (xPane.is()) 1103 return uno::makeAny(xPane); 1104 else 1105 throw lang::IndexOutOfBoundsException(); 1106 // return uno::Any(); 1107 } 1108 1109 uno::Type SAL_CALL ScTabViewObj::getElementType() throw(uno::RuntimeException) 1110 { 1111 ScUnoGuard aGuard; 1112 return getCppuType((uno::Reference<sheet::XViewPane>*)0); 1113 } 1114 1115 sal_Bool SAL_CALL ScTabViewObj::hasElements() throw(uno::RuntimeException) 1116 { 1117 ScUnoGuard aGuard; 1118 return ( getCount() != 0 ); 1119 } 1120 1121 // XSpreadsheetView 1122 1123 ScViewPaneObj* ScTabViewObj::GetObjectByIndex_Impl(sal_uInt16 nIndex) const 1124 { 1125 static ScSplitPos ePosHV[4] = 1126 { SC_SPLIT_TOPLEFT, SC_SPLIT_BOTTOMLEFT, SC_SPLIT_TOPRIGHT, SC_SPLIT_BOTTOMRIGHT }; 1127 1128 ScTabViewShell* pViewSh = GetViewShell(); 1129 if (pViewSh) 1130 { 1131 ScSplitPos eWhich = SC_SPLIT_BOTTOMLEFT; // default Position 1132 sal_Bool bError = sal_False; 1133 ScViewData* pViewData = pViewSh->GetViewData(); 1134 sal_Bool bHor = ( pViewData->GetHSplitMode() != SC_SPLIT_NONE ); 1135 sal_Bool bVer = ( pViewData->GetVSplitMode() != SC_SPLIT_NONE ); 1136 if ( bHor && bVer ) 1137 { 1138 // links oben, links unten, rechts oben, rechts unten - wie in Excel 1139 if ( nIndex < 4 ) 1140 eWhich = ePosHV[nIndex]; 1141 else 1142 bError = sal_True; 1143 } 1144 else if ( bHor ) 1145 { 1146 if ( nIndex > 1 ) 1147 bError = sal_True; 1148 else if ( nIndex == 1 ) 1149 eWhich = SC_SPLIT_BOTTOMRIGHT; 1150 // sonst SC_SPLIT_BOTTOMLEFT 1151 } 1152 else if ( bVer ) 1153 { 1154 if ( nIndex > 1 ) 1155 bError = sal_True; 1156 else if ( nIndex == 0 ) 1157 eWhich = SC_SPLIT_TOPLEFT; 1158 // sonst SC_SPLIT_BOTTOMLEFT 1159 } 1160 else if ( nIndex > 0 ) 1161 bError = sal_True; // nicht geteilt: nur 0 gueltig 1162 1163 if (!bError) 1164 return new ScViewPaneObj( pViewSh, sal::static_int_cast<sal_uInt16>(eWhich) ); 1165 } 1166 1167 return NULL; 1168 } 1169 1170 uno::Reference<sheet::XSpreadsheet> SAL_CALL ScTabViewObj::getActiveSheet() 1171 throw(uno::RuntimeException) 1172 { 1173 ScUnoGuard aGuard; 1174 ScTabViewShell* pViewSh = GetViewShell(); 1175 if (pViewSh) 1176 { 1177 ScViewData* pData = pViewSh->GetViewData(); 1178 SCTAB nTab = pData->GetTabNo(); 1179 return new ScTableSheetObj( pData->GetDocShell(), nTab ); 1180 } 1181 return NULL; 1182 } 1183 1184 void SAL_CALL ScTabViewObj::setActiveSheet( const uno::Reference<sheet::XSpreadsheet>& xActiveSheet ) 1185 throw(uno::RuntimeException) 1186 { 1187 ScUnoGuard aGuard; 1188 1189 ScTabViewShell* pViewSh = GetViewShell(); 1190 if ( pViewSh && xActiveSheet.is() ) 1191 { 1192 // XSpreadsheet und ScCellRangesBase -> muss ein Sheet sein 1193 1194 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xActiveSheet ); 1195 if ( pRangesImp && pViewSh->GetViewData()->GetDocShell() == pRangesImp->GetDocShell() ) 1196 { 1197 const ScRangeList& rRanges = pRangesImp->GetRangeList(); 1198 if ( rRanges.Count() == 1 ) 1199 { 1200 SCTAB nNewTab = rRanges.GetObject(0)->aStart.Tab(); 1201 if ( pViewSh->GetViewData()->GetDocument()->HasTable(nNewTab) ) 1202 pViewSh->SetTabNo( nNewTab ); 1203 } 1204 } 1205 } 1206 } 1207 1208 uno::Reference< uno::XInterface > ScTabViewObj::GetClickedObject(const Point& rPoint) const 1209 { 1210 uno::Reference< uno::XInterface > xTarget; 1211 if (GetViewShell()) 1212 { 1213 SCsCOL nX; 1214 SCsROW nY; 1215 ScViewData* pData = GetViewShell()->GetViewData(); 1216 ScSplitPos eSplitMode = pData->GetActivePart(); 1217 SCTAB nTab(pData->GetTabNo()); 1218 pData->GetPosFromPixel( rPoint.X(), rPoint.Y(), eSplitMode, nX, nY); 1219 1220 ScAddress aCellPos (nX, nY, nTab); 1221 ScCellObj* pCellObj = new ScCellObj(pData->GetDocShell(), aCellPos); 1222 1223 xTarget.set(uno::Reference<table::XCell>(pCellObj), uno::UNO_QUERY); 1224 1225 ScDocument* pDoc = pData->GetDocument(); 1226 if (pDoc && pDoc->GetDrawLayer()) 1227 { 1228 SdrPage* pDrawPage = NULL; 1229 ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer(); 1230 if (pDrawLayer->HasObjects() && (pDrawLayer->GetPageCount() > nTab)) 1231 pDrawPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab)); 1232 1233 SdrView* pDrawView = GetViewShell()->GetSdrView(); 1234 1235 if (pDrawPage && pDrawView && pDrawView->GetSdrPageView()) 1236 { 1237 Window* pActiveWin = pData->GetActiveWin(); 1238 Point aPos = pActiveWin->PixelToLogic(rPoint); 1239 1240 sal_uInt16 nHitLog = (sal_uInt16) pActiveWin->PixelToLogic( 1241 Size(pDrawView->GetHitTolerancePixel(),0)).Width(); 1242 1243 sal_uInt32 nCount(pDrawPage->GetObjCount()); 1244 sal_Bool bFound(sal_False); 1245 sal_uInt32 i(0); 1246 while (i < nCount && !bFound) 1247 { 1248 SdrObject* pObj = pDrawPage->GetObj(i); 1249 if (pObj && SdrObjectPrimitiveHit(*pObj, aPos, nHitLog, *pDrawView->GetSdrPageView(), 0, false)) 1250 { 1251 xTarget.set(pObj->getUnoShape(), uno::UNO_QUERY); 1252 bFound = sal_True; 1253 } 1254 ++i; 1255 } 1256 } 1257 } 1258 } 1259 return xTarget; 1260 } 1261 1262 bool ScTabViewObj::IsMouseListening() const 1263 { 1264 if ( aMouseClickHandlers.Count() > 0 ) 1265 return true; 1266 1267 // also include sheet events, because MousePressed must be called for them 1268 ScViewData* pViewData = GetViewShell()->GetViewData(); 1269 ScDocument* pDoc = pViewData->GetDocument(); 1270 SCTAB nTab = pViewData->GetTabNo(); 1271 return 1272 pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_RIGHTCLICK, true ) || 1273 pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_DOUBLECLICK, true ); 1274 } 1275 1276 sal_Bool ScTabViewObj::MousePressed( const awt::MouseEvent& e ) 1277 throw (::uno::RuntimeException) 1278 { 1279 sal_Bool bReturn(sal_False); 1280 1281 uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y)); 1282 if (aMouseClickHandlers.Count() && xTarget.is()) 1283 { 1284 awt::EnhancedMouseEvent aMouseEvent; 1285 1286 aMouseEvent.Buttons = e.Buttons; 1287 aMouseEvent.X = e.X; 1288 aMouseEvent.Y = e.Y; 1289 aMouseEvent.ClickCount = e.ClickCount; 1290 aMouseEvent.PopupTrigger = e.PopupTrigger; 1291 aMouseEvent.Target = xTarget; 1292 1293 for ( sal_uInt16 n=0; n<aMouseClickHandlers.Count(); n++ ) 1294 { 1295 try 1296 { 1297 if (!(*aMouseClickHandlers[n])->mousePressed( aMouseEvent )) 1298 bReturn = sal_True; 1299 } 1300 catch ( uno::Exception& ) 1301 { 1302 aMouseClickHandlers.DeleteAndDestroy(n); 1303 --n; // because it will be increased again in the loop 1304 } 1305 } 1306 } 1307 1308 // handle sheet events 1309 bool bDoubleClick = ( e.Buttons == awt::MouseButton::LEFT && e.ClickCount == 2 ); 1310 bool bRightClick = ( e.Buttons == awt::MouseButton::RIGHT && e.ClickCount == 1 ); 1311 if ( ( bDoubleClick || bRightClick ) && !bReturn && xTarget.is()) 1312 { 1313 sal_Int32 nEvent = bDoubleClick ? SC_SHEETEVENT_DOUBLECLICK : SC_SHEETEVENT_RIGHTCLICK; 1314 1315 ScTabViewShell* pViewSh = GetViewShell(); 1316 ScViewData* pViewData = pViewSh->GetViewData(); 1317 ScDocShell* pDocSh = pViewData->GetDocShell(); 1318 ScDocument* pDoc = pDocSh->GetDocument(); 1319 SCTAB nTab = pViewData->GetTabNo(); 1320 const ScSheetEvents* pEvents = pDoc->GetSheetEvents(nTab); 1321 if (pEvents) 1322 { 1323 const rtl::OUString* pScript = pEvents->GetScript(nEvent); 1324 if (pScript) 1325 { 1326 // the macro parameter is the clicked object, as in the mousePressed call above 1327 uno::Sequence<uno::Any> aParams(1); 1328 aParams[0] <<= xTarget; 1329 1330 uno::Any aRet; 1331 uno::Sequence<sal_Int16> aOutArgsIndex; 1332 uno::Sequence<uno::Any> aOutArgs; 1333 1334 /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs ); 1335 1336 // look for a boolean return value of true 1337 sal_Bool bRetValue = sal_False; 1338 if (aRet >>= bRetValue) 1339 { 1340 if (bRetValue) 1341 bReturn = sal_True; 1342 } 1343 } 1344 } 1345 1346 // execute VBA event handler 1347 if (!bReturn && xTarget.is()) try 1348 { 1349 uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW ); 1350 // the parameter is the clicked object, as in the mousePressed call above 1351 uno::Sequence< uno::Any > aArgs( 1 ); 1352 aArgs[ 0 ] <<= xTarget; 1353 xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs ); 1354 } 1355 catch( util::VetoException& ) 1356 { 1357 bReturn = sal_True; 1358 } 1359 catch( uno::Exception& ) 1360 { 1361 } 1362 } 1363 1364 return bReturn; 1365 } 1366 1367 sal_Bool ScTabViewObj::MouseReleased( const awt::MouseEvent& e ) 1368 throw (uno::RuntimeException) 1369 { 1370 sal_Bool bReturn(sal_False); 1371 1372 if (aMouseClickHandlers.Count()) 1373 { 1374 uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y)); 1375 1376 if (xTarget.is()) 1377 { 1378 awt::EnhancedMouseEvent aMouseEvent; 1379 1380 aMouseEvent.Buttons = e.Buttons; 1381 aMouseEvent.X = e.X; 1382 aMouseEvent.Y = e.Y; 1383 aMouseEvent.ClickCount = e.ClickCount; 1384 aMouseEvent.PopupTrigger = e.PopupTrigger; 1385 aMouseEvent.Target = xTarget; 1386 1387 for ( sal_uInt16 n=0; n<aMouseClickHandlers.Count(); n++ ) 1388 { 1389 try 1390 { 1391 if (!(*aMouseClickHandlers[n])->mouseReleased( aMouseEvent )) 1392 bReturn = sal_True; 1393 } 1394 catch ( uno::Exception& ) 1395 { 1396 aMouseClickHandlers.DeleteAndDestroy(n); 1397 --n; // because it will be increased again in the loop 1398 } 1399 } 1400 } 1401 } 1402 return bReturn; 1403 } 1404 1405 // XEnhancedMouseClickBroadcaster 1406 1407 void ScTabViewObj::StartMouseListening() 1408 { 1409 } 1410 1411 void ScTabViewObj::EndMouseListening() 1412 { 1413 sal_uInt16 nCount(aMouseClickHandlers.Count()); 1414 lang::EventObject aEvent; 1415 aEvent.Source = (cppu::OWeakObject*)this; 1416 for ( sal_uInt16 n=0; n<nCount; n++ ) 1417 { 1418 try 1419 { 1420 (*aMouseClickHandlers[n])->disposing(aEvent); 1421 } 1422 catch ( uno::Exception& ) 1423 { 1424 } 1425 } 1426 aMouseClickHandlers.DeleteAndDestroy(0, nCount); 1427 } 1428 1429 void ScTabViewObj::StartActivationListening() 1430 { 1431 } 1432 1433 void ScTabViewObj::EndActivationListening() 1434 { 1435 sal_uInt16 nCount = aActivationListeners.Count(); 1436 lang::EventObject aEvent; 1437 aEvent.Source = (cppu::OWeakObject*)this; 1438 for ( sal_uInt16 n=0; n<nCount; n++ ) 1439 { 1440 try 1441 { 1442 (*aActivationListeners[n])->disposing(aEvent); 1443 } 1444 catch ( uno::Exception& ) 1445 { 1446 } 1447 } 1448 aActivationListeners.DeleteAndDestroy(0, nCount); 1449 } 1450 1451 void SAL_CALL ScTabViewObj::addEnhancedMouseClickHandler( const uno::Reference< awt::XEnhancedMouseClickHandler >& aListener ) 1452 throw (uno::RuntimeException) 1453 { 1454 ScUnoGuard aGuard; 1455 1456 if (aListener.is()) 1457 { 1458 sal_uInt16 nCount = aMouseClickHandlers.Count(); 1459 uno::Reference<awt::XEnhancedMouseClickHandler> *pObj = 1460 new uno::Reference<awt::XEnhancedMouseClickHandler>( aListener ); 1461 aMouseClickHandlers.Insert( pObj, nCount ); 1462 1463 if (aMouseClickHandlers.Count() == 1 && nCount == 0) // only if a listener added 1464 StartMouseListening(); 1465 } 1466 } 1467 1468 void SAL_CALL ScTabViewObj::removeEnhancedMouseClickHandler( const uno::Reference< awt::XEnhancedMouseClickHandler >& aListener ) 1469 throw (uno::RuntimeException) 1470 { 1471 ScUnoGuard aGuard; 1472 sal_uInt16 nCount = aMouseClickHandlers.Count(); 1473 for ( sal_uInt16 n=nCount; n--; ) 1474 { 1475 uno::Reference<awt::XEnhancedMouseClickHandler> *pObj = aMouseClickHandlers[n]; 1476 if ( *pObj == aListener ) 1477 aMouseClickHandlers.DeleteAndDestroy( n ); 1478 } 1479 if ((aMouseClickHandlers.Count() == 0) && (nCount > 0)) // only if last listener removed 1480 EndMouseListening(); 1481 } 1482 1483 // XActivationBroadcaster 1484 1485 void SAL_CALL ScTabViewObj::addActivationEventListener( const uno::Reference< sheet::XActivationEventListener >& aListener ) 1486 throw (uno::RuntimeException) 1487 { 1488 ScUnoGuard aGuard; 1489 1490 if (aListener.is()) 1491 { 1492 sal_uInt16 nCount = aActivationListeners.Count(); 1493 uno::Reference<sheet::XActivationEventListener> *pObj = 1494 new uno::Reference<sheet::XActivationEventListener>( aListener ); 1495 aActivationListeners.Insert( pObj, nCount ); 1496 1497 if (aActivationListeners.Count() == 1 && nCount == 0) // only if a listener added 1498 StartActivationListening(); 1499 } 1500 } 1501 1502 void SAL_CALL ScTabViewObj::removeActivationEventListener( const uno::Reference< sheet::XActivationEventListener >& aListener ) 1503 throw (uno::RuntimeException) 1504 { 1505 ScUnoGuard aGuard; 1506 sal_uInt16 nCount = aActivationListeners.Count(); 1507 for ( sal_uInt16 n=nCount; n--; ) 1508 { 1509 uno::Reference<sheet::XActivationEventListener> *pObj = aActivationListeners[n]; 1510 if ( *pObj == aListener ) 1511 aActivationListeners.DeleteAndDestroy( n ); 1512 } 1513 if ((aActivationListeners.Count() == 0) && (nCount > 0)) // only if last listener removed 1514 EndActivationListening(); 1515 } 1516 1517 // PageBreakMode / Zoom sind Properties 1518 1519 #if 0 1520 1521 sal_Bool ScTabViewObj::getPagebreakMode(void) const 1522 { 1523 ScUnoGuard aGuard; 1524 ScTabViewShell* pViewSh = GetViewShell(); 1525 if (pViewSh) 1526 return pViewSh->GetViewData()->IsPagebreakMode(); 1527 return sal_False; 1528 } 1529 1530 void ScTabViewObj::setPagebreakMode(sal_Bool PagebreakMode) 1531 { 1532 ScUnoGuard aGuard; 1533 ScTabViewShell* pViewSh = GetViewShell(); 1534 if (pViewSh) 1535 pViewSh->SetPagebreakMode(PagebreakMode); 1536 } 1537 1538 #endif 1539 1540 sal_Int16 ScTabViewObj::GetZoom(void) const 1541 { 1542 ScTabViewShell* pViewSh = GetViewShell(); 1543 if (pViewSh) 1544 { 1545 const Fraction& rZoomY = pViewSh->GetViewData()->GetZoomY(); // Y wird angezeigt 1546 return (sal_Int16)(( rZoomY.GetNumerator() * 100 ) / rZoomY.GetDenominator()); 1547 } 1548 return 0; 1549 } 1550 1551 void ScTabViewObj::SetZoom(sal_Int16 nZoom) 1552 { 1553 ScTabViewShell* pViewSh = GetViewShell(); 1554 if (pViewSh) 1555 { 1556 if ( nZoom != GetZoom() && nZoom != 0 ) 1557 { 1558 if (!pViewSh->GetViewData()->IsPagebreakMode()) 1559 { 1560 ScModule* pScMod = SC_MOD(); 1561 ScAppOptions aNewOpt(pScMod->GetAppOptions()); 1562 aNewOpt.SetZoom( nZoom ); 1563 aNewOpt.SetZoomType( pViewSh->GetViewData()->GetView()->GetZoomType() ); 1564 pScMod->SetAppOptions( aNewOpt ); 1565 } 1566 } 1567 Fraction aFract( nZoom, 100 ); 1568 pViewSh->SetZoom( aFract, aFract, sal_True ); 1569 pViewSh->PaintGrid(); 1570 pViewSh->PaintTop(); 1571 pViewSh->PaintLeft(); 1572 pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM ); 1573 pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER ); 1574 } 1575 } 1576 1577 sal_Int16 ScTabViewObj::GetZoomType(void) const 1578 { 1579 sal_Int16 aZoomType = view::DocumentZoomType::OPTIMAL; 1580 ScTabViewShell* pViewSh = GetViewShell(); 1581 if (pViewSh) 1582 { 1583 SvxZoomType eZoomType = pViewSh->GetViewData()->GetView()->GetZoomType(); 1584 switch (eZoomType) 1585 { 1586 case SVX_ZOOM_PERCENT: 1587 aZoomType = view::DocumentZoomType::BY_VALUE; 1588 break; 1589 case SVX_ZOOM_OPTIMAL: 1590 aZoomType = view::DocumentZoomType::OPTIMAL; 1591 break; 1592 case SVX_ZOOM_WHOLEPAGE: 1593 aZoomType = view::DocumentZoomType::ENTIRE_PAGE; 1594 break; 1595 case SVX_ZOOM_PAGEWIDTH: 1596 aZoomType = view::DocumentZoomType::PAGE_WIDTH; 1597 break; 1598 case SVX_ZOOM_PAGEWIDTH_NOBORDER: 1599 aZoomType = view::DocumentZoomType::PAGE_WIDTH_EXACT; 1600 break; 1601 } 1602 } 1603 return aZoomType; 1604 } 1605 1606 void ScTabViewObj::SetZoomType(sal_Int16 aZoomType) 1607 { 1608 ScTabViewShell* pViewSh = GetViewShell(); 1609 if (pViewSh) 1610 { 1611 ScDBFunc* pView = pViewSh->GetViewData()->GetView(); 1612 if (pView) 1613 { 1614 SvxZoomType eZoomType; 1615 switch (aZoomType) 1616 { 1617 case view::DocumentZoomType::BY_VALUE: 1618 eZoomType = SVX_ZOOM_PERCENT; 1619 break; 1620 case view::DocumentZoomType::OPTIMAL: 1621 eZoomType = SVX_ZOOM_OPTIMAL; 1622 break; 1623 case view::DocumentZoomType::ENTIRE_PAGE: 1624 eZoomType = SVX_ZOOM_WHOLEPAGE; 1625 break; 1626 case view::DocumentZoomType::PAGE_WIDTH: 1627 eZoomType = SVX_ZOOM_PAGEWIDTH; 1628 break; 1629 case view::DocumentZoomType::PAGE_WIDTH_EXACT: 1630 eZoomType = SVX_ZOOM_PAGEWIDTH_NOBORDER; 1631 break; 1632 default: 1633 eZoomType = SVX_ZOOM_OPTIMAL; 1634 } 1635 sal_Int16 nZoom(GetZoom()); 1636 sal_Int16 nOldZoom(nZoom); 1637 if ( eZoomType == SVX_ZOOM_PERCENT ) 1638 { 1639 if ( nZoom < MINZOOM ) nZoom = MINZOOM; 1640 if ( nZoom > MAXZOOM ) nZoom = MAXZOOM; 1641 } 1642 else 1643 nZoom = pView->CalcZoom( eZoomType, nOldZoom ); 1644 1645 switch ( eZoomType ) 1646 { 1647 case SVX_ZOOM_WHOLEPAGE: 1648 case SVX_ZOOM_PAGEWIDTH: 1649 pView->SetZoomType( eZoomType, sal_True ); 1650 break; 1651 1652 default: 1653 pView->SetZoomType( SVX_ZOOM_PERCENT, sal_True ); 1654 } 1655 SetZoom( nZoom ); 1656 } 1657 } 1658 } 1659 1660 sal_Bool SAL_CALL ScTabViewObj::getIsWindowSplit() throw(uno::RuntimeException) 1661 { 1662 ScUnoGuard aGuard; 1663 // wie Menue-Slot SID_WINDOW_SPLIT 1664 1665 ScTabViewShell* pViewSh = GetViewShell(); 1666 if (pViewSh) 1667 { 1668 ScViewData* pViewData = pViewSh->GetViewData(); 1669 return ( pViewData->GetHSplitMode() == SC_SPLIT_NORMAL || 1670 pViewData->GetVSplitMode() == SC_SPLIT_NORMAL ); 1671 } 1672 1673 return sal_False; 1674 } 1675 1676 sal_Bool SAL_CALL ScTabViewObj::hasFrozenPanes() throw(uno::RuntimeException) 1677 { 1678 ScUnoGuard aGuard; 1679 // wie Menue-Slot SID_WINDOW_FIX 1680 1681 ScTabViewShell* pViewSh = GetViewShell(); 1682 if (pViewSh) 1683 { 1684 ScViewData* pViewData = pViewSh->GetViewData(); 1685 return ( pViewData->GetHSplitMode() == SC_SPLIT_FIX || 1686 pViewData->GetVSplitMode() == SC_SPLIT_FIX ); 1687 } 1688 1689 return sal_False; 1690 } 1691 1692 sal_Int32 SAL_CALL ScTabViewObj::getSplitHorizontal() throw(uno::RuntimeException) 1693 { 1694 ScUnoGuard aGuard; 1695 ScTabViewShell* pViewSh = GetViewShell(); 1696 if (pViewSh) 1697 { 1698 ScViewData* pViewData = pViewSh->GetViewData(); 1699 if ( pViewData->GetHSplitMode() != SC_SPLIT_NONE ) 1700 return pViewData->GetHSplitPos(); 1701 } 1702 return 0; 1703 } 1704 1705 sal_Int32 SAL_CALL ScTabViewObj::getSplitVertical() throw(uno::RuntimeException) 1706 { 1707 ScUnoGuard aGuard; 1708 ScTabViewShell* pViewSh = GetViewShell(); 1709 if (pViewSh) 1710 { 1711 ScViewData* pViewData = pViewSh->GetViewData(); 1712 if ( pViewData->GetVSplitMode() != SC_SPLIT_NONE ) 1713 return pViewData->GetVSplitPos(); 1714 } 1715 return 0; 1716 } 1717 1718 sal_Int32 SAL_CALL ScTabViewObj::getSplitColumn() throw(uno::RuntimeException) 1719 { 1720 ScUnoGuard aGuard; 1721 ScTabViewShell* pViewSh = GetViewShell(); 1722 if (pViewSh) 1723 { 1724 ScViewData* pViewData = pViewSh->GetViewData(); 1725 if ( pViewData->GetHSplitMode() != SC_SPLIT_NONE ) 1726 { 1727 long nSplit = pViewData->GetHSplitPos(); 1728 1729 ScSplitPos ePos = SC_SPLIT_BOTTOMLEFT; 1730 if ( pViewData->GetVSplitMode() != SC_SPLIT_NONE ) 1731 ePos = SC_SPLIT_TOPLEFT; 1732 1733 SCsCOL nCol; 1734 SCsROW nRow; 1735 pViewData->GetPosFromPixel( nSplit, 0, ePos, nCol, nRow, sal_False ); 1736 if ( nCol > 0 ) 1737 return nCol; 1738 } 1739 } 1740 return 0; 1741 } 1742 1743 sal_Int32 SAL_CALL ScTabViewObj::getSplitRow() throw(uno::RuntimeException) 1744 { 1745 ScUnoGuard aGuard; 1746 ScTabViewShell* pViewSh = GetViewShell(); 1747 if (pViewSh) 1748 { 1749 ScViewData* pViewData = pViewSh->GetViewData(); 1750 if ( pViewData->GetVSplitMode() != SC_SPLIT_NONE ) 1751 { 1752 long nSplit = pViewData->GetVSplitPos(); 1753 1754 ScSplitPos ePos = SC_SPLIT_TOPLEFT; // es ist vertikal geteilt 1755 SCsCOL nCol; 1756 SCsROW nRow; 1757 pViewData->GetPosFromPixel( 0, nSplit, ePos, nCol, nRow, sal_False ); 1758 if ( nRow > 0 ) 1759 return nRow; 1760 } 1761 } 1762 return 0; 1763 } 1764 1765 void SAL_CALL ScTabViewObj::splitAtPosition( sal_Int32 nPixelX, sal_Int32 nPixelY ) 1766 throw(uno::RuntimeException) 1767 { 1768 ScUnoGuard aGuard; 1769 ScTabViewShell* pViewSh = GetViewShell(); 1770 if (pViewSh) 1771 { 1772 pViewSh->SplitAtPixel( Point( nPixelX, nPixelY ), sal_True, sal_True ); 1773 pViewSh->FreezeSplitters( sal_False ); 1774 pViewSh->InvalidateSplit(); 1775 } 1776 } 1777 1778 void SAL_CALL ScTabViewObj::freezeAtPosition( sal_Int32 nColumns, sal_Int32 nRows ) 1779 throw(uno::RuntimeException) 1780 { 1781 ScUnoGuard aGuard; 1782 ScTabViewShell* pViewSh = GetViewShell(); 1783 if (pViewSh) 1784 { 1785 // erst alles aufheben -> kein Stress mit Scrolling zwischendurch o.ae. 1786 1787 pViewSh->RemoveSplit(); 1788 1789 Point aWinStart; 1790 Window* pWin = pViewSh->GetWindowByPos( SC_SPLIT_BOTTOMLEFT ); 1791 if (pWin) 1792 aWinStart = pWin->GetPosPixel(); 1793 1794 ScViewData* pViewData = pViewSh->GetViewData(); 1795 Point aSplit(pViewData->GetScrPos( (SCCOL)nColumns, (SCROW)nRows, SC_SPLIT_BOTTOMLEFT, sal_True )); 1796 aSplit += aWinStart; 1797 1798 pViewSh->SplitAtPixel( aSplit, sal_True, sal_True ); 1799 pViewSh->FreezeSplitters( sal_True ); 1800 pViewSh->InvalidateSplit(); 1801 } 1802 } 1803 1804 void SAL_CALL ScTabViewObj::addSelectionChangeListener( 1805 const uno::Reference<view::XSelectionChangeListener>& xListener ) 1806 throw(uno::RuntimeException) 1807 { 1808 ScUnoGuard aGuard; 1809 uno::Reference<view::XSelectionChangeListener>* pObj = 1810 new uno::Reference<view::XSelectionChangeListener>( xListener ); 1811 aSelectionListeners.Insert( pObj, aSelectionListeners.Count() ); 1812 } 1813 1814 void SAL_CALL ScTabViewObj::removeSelectionChangeListener( 1815 const uno::Reference< view::XSelectionChangeListener >& xListener ) 1816 throw(uno::RuntimeException) 1817 { 1818 ScUnoGuard aGuard; 1819 sal_uInt16 nCount = aSelectionListeners.Count(); 1820 for ( sal_uInt16 n=nCount; n--; ) 1821 { 1822 uno::Reference<view::XSelectionChangeListener> *pObj = aSelectionListeners[n]; 1823 if ( *pObj == xListener ) //! wozu der Mumpitz mit queryInterface? 1824 { 1825 aSelectionListeners.DeleteAndDestroy( n ); 1826 break; 1827 } 1828 } 1829 } 1830 1831 void ScTabViewObj::SelectionChanged() 1832 { 1833 lang::EventObject aEvent; 1834 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this)); 1835 for ( sal_uInt16 n=0; n<aSelectionListeners.Count(); n++ ) 1836 (*aSelectionListeners[n])->selectionChanged( aEvent ); 1837 1838 // handle sheet events 1839 ScTabViewShell* pViewSh = GetViewShell(); 1840 ScViewData* pViewData = pViewSh->GetViewData(); 1841 ScDocShell* pDocSh = pViewData->GetDocShell(); 1842 ScDocument* pDoc = pDocSh->GetDocument(); 1843 SCTAB nTab = pViewData->GetTabNo(); 1844 const ScSheetEvents* pEvents = pDoc->GetSheetEvents(nTab); 1845 if (pEvents) 1846 { 1847 const rtl::OUString* pScript = pEvents->GetScript(SC_SHEETEVENT_SELECT); 1848 if (pScript) 1849 { 1850 // the macro parameter is the selection as returned by getSelection 1851 uno::Sequence<uno::Any> aParams(1); 1852 aParams[0] = getSelection(); 1853 uno::Any aRet; 1854 uno::Sequence<sal_Int16> aOutArgsIndex; 1855 uno::Sequence<uno::Any> aOutArgs; 1856 /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs ); 1857 } 1858 } 1859 1860 // execute VBA event handler 1861 try 1862 { 1863 uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW ); 1864 // the parameter is the clicked object, as in the mousePressed call above 1865 uno::Sequence< uno::Any > aArgs( 1 ); 1866 aArgs[ 0 ] <<= getSelection(); 1867 xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( SC_SHEETEVENT_SELECT ), aArgs ); 1868 } 1869 catch( uno::Exception& ) 1870 { 1871 } 1872 } 1873 1874 1875 // XPropertySet (View-Optionen) 1876 //! auch an der Applikation anbieten? 1877 1878 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTabViewObj::getPropertySetInfo() 1879 throw(uno::RuntimeException) 1880 { 1881 ScUnoGuard aGuard; 1882 static uno::Reference<beans::XPropertySetInfo> aRef( 1883 new SfxItemPropertySetInfo( aPropSet.getPropertyMap() )); 1884 return aRef; 1885 } 1886 1887 void SAL_CALL ScTabViewObj::setPropertyValue( 1888 const rtl::OUString& aPropertyName, const uno::Any& aValue ) 1889 throw(beans::UnknownPropertyException, beans::PropertyVetoException, 1890 lang::IllegalArgumentException, lang::WrappedTargetException, 1891 uno::RuntimeException) 1892 { 1893 ScUnoGuard aGuard; 1894 String aString(aPropertyName); 1895 1896 ScTabViewShell* pViewSh = GetViewShell(); 1897 if (pViewSh) 1898 { 1899 ScViewData* pViewData = pViewSh->GetViewData(); 1900 const ScViewOptions& rOldOpt = pViewSh->GetViewData()->GetOptions(); 1901 ScViewOptions aNewOpt(rOldOpt); 1902 1903 if ( aString.EqualsAscii( SC_UNO_COLROWHDR ) || aString.EqualsAscii( OLD_UNO_COLROWHDR ) ) 1904 aNewOpt.SetOption( VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 1905 else if ( aString.EqualsAscii( SC_UNO_HORSCROLL ) || aString.EqualsAscii( OLD_UNO_HORSCROLL ) ) 1906 aNewOpt.SetOption( VOPT_HSCROLL, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 1907 else if ( aString.EqualsAscii( SC_UNO_OUTLSYMB ) || aString.EqualsAscii( OLD_UNO_OUTLSYMB ) ) 1908 aNewOpt.SetOption( VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 1909 else if ( aString.EqualsAscii( SC_UNO_SHEETTABS ) || aString.EqualsAscii( OLD_UNO_SHEETTABS ) ) 1910 aNewOpt.SetOption( VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 1911 else if ( aString.EqualsAscii( SC_UNO_SHOWANCHOR ) ) 1912 aNewOpt.SetOption( VOPT_ANCHOR, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 1913 else if ( aString.EqualsAscii( SC_UNO_SHOWFORM ) ) 1914 aNewOpt.SetOption( VOPT_FORMULAS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 1915 else if ( aString.EqualsAscii( SC_UNO_SHOWGRID ) ) 1916 aNewOpt.SetOption( VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 1917 else if ( aString.EqualsAscii( SC_UNO_SHOWHELP ) ) 1918 aNewOpt.SetOption( VOPT_HELPLINES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 1919 else if ( aString.EqualsAscii( SC_UNO_SHOWNOTES ) ) 1920 aNewOpt.SetOption( VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 1921 else if ( aString.EqualsAscii( SC_UNO_SHOWPAGEBR ) ) 1922 aNewOpt.SetOption( VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 1923 else if ( aString.EqualsAscii( SC_UNO_SHOWZERO ) ) 1924 aNewOpt.SetOption( VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 1925 else if ( aString.EqualsAscii( SC_UNO_SHOWSOLID ) ) 1926 aNewOpt.SetOption( VOPT_SOLIDHANDLES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 1927 else if ( aString.EqualsAscii( SC_UNO_VALUEHIGH ) || aString.EqualsAscii( OLD_UNO_VALUEHIGH ) ) 1928 aNewOpt.SetOption( VOPT_SYNTAX, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 1929 else if ( aString.EqualsAscii( SC_UNO_VERTSCROLL ) || aString.EqualsAscii( OLD_UNO_VERTSCROLL ) ) 1930 aNewOpt.SetOption( VOPT_VSCROLL, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 1931 else if ( aString.EqualsAscii( SC_UNO_SHOWOBJ ) ) 1932 { 1933 sal_Int16 nIntVal = 0; 1934 if ( aValue >>= nIntVal ) 1935 { 1936 //#i80528# adapt to new range eventually 1937 if((sal_Int16)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int16)VOBJ_MODE_SHOW; 1938 1939 aNewOpt.SetObjMode( VOBJ_TYPE_OLE, (ScVObjMode)nIntVal); 1940 } 1941 } 1942 else if ( aString.EqualsAscii( SC_UNO_SHOWCHARTS ) ) 1943 { 1944 sal_Int16 nIntVal = 0; 1945 if ( aValue >>= nIntVal ) 1946 { 1947 //#i80528# adapt to new range eventually 1948 if((sal_Int16)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int16)VOBJ_MODE_SHOW; 1949 1950 aNewOpt.SetObjMode( VOBJ_TYPE_CHART, (ScVObjMode)nIntVal); 1951 } 1952 } 1953 else if ( aString.EqualsAscii( SC_UNO_SHOWDRAW ) ) 1954 { 1955 sal_Int16 nIntVal = 0; 1956 if ( aValue >>= nIntVal ) 1957 { 1958 //#i80528# adapt to new range eventually 1959 if((sal_Int16)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int16)VOBJ_MODE_SHOW; 1960 1961 aNewOpt.SetObjMode( VOBJ_TYPE_DRAW, (ScVObjMode)nIntVal); 1962 } 1963 } 1964 else if ( aString.EqualsAscii( SC_UNO_GRIDCOLOR ) ) 1965 { 1966 sal_Int32 nIntVal = 0; 1967 if ( aValue >>= nIntVal ) 1968 aNewOpt.SetGridColor( nIntVal, String() ); 1969 } 1970 else if ( aString.EqualsAscii( SC_UNO_ZOOMTYPE ) ) 1971 { 1972 sal_Int16 nIntVal = 0; 1973 if ( aValue >>= nIntVal ) 1974 SetZoomType(nIntVal); 1975 } 1976 else if ( aString.EqualsAscii( SC_UNO_ZOOMVALUE ) ) 1977 { 1978 sal_Int16 nIntVal = 0; 1979 if ( aValue >>= nIntVal ) 1980 SetZoom(nIntVal); 1981 } 1982 1983 // Optionen werden an der View und am Dokument (fuer neue Views) gesetzt, 1984 // damit sie beim Speichern erhalten bleiben. 1985 //! An der App (Module) braeuchte man noch eine Extra-Moeglichkeit, 1986 //! das einzustellen (fuer neue Dokumente) 1987 1988 if ( aNewOpt != rOldOpt ) 1989 { 1990 pViewData->SetOptions( aNewOpt ); 1991 pViewData->GetDocument()->SetViewOptions( aNewOpt ); 1992 pViewData->GetDocShell()->SetDocumentModified(); //! wirklich? 1993 1994 pViewSh->UpdateFixPos(); 1995 pViewSh->PaintGrid(); 1996 pViewSh->PaintTop(); 1997 pViewSh->PaintLeft(); 1998 pViewSh->PaintExtras(); 1999 pViewSh->InvalidateBorder(); 2000 2001 SfxBindings& rBindings = pViewSh->GetViewFrame()->GetBindings(); 2002 rBindings.Invalidate( FID_TOGGLEHEADERS ); // -> Checks im Menue 2003 rBindings.Invalidate( FID_TOGGLESYNTAX ); 2004 } 2005 } 2006 } 2007 2008 uno::Any SAL_CALL ScTabViewObj::getPropertyValue( const rtl::OUString& aPropertyName ) 2009 throw(beans::UnknownPropertyException, lang::WrappedTargetException, 2010 uno::RuntimeException) 2011 { 2012 ScUnoGuard aGuard; 2013 String aString(aPropertyName); 2014 uno::Any aRet; 2015 2016 ScTabViewShell* pViewSh = GetViewShell(); 2017 if (pViewSh) 2018 { 2019 const ScViewOptions& rOpt = pViewSh->GetViewData()->GetOptions(); 2020 2021 if ( aString.EqualsAscii( SC_UNO_COLROWHDR ) || aString.EqualsAscii( OLD_UNO_COLROWHDR ) ) 2022 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_HEADER ) ); 2023 else if ( aString.EqualsAscii( SC_UNO_HORSCROLL ) || aString.EqualsAscii( OLD_UNO_HORSCROLL ) ) 2024 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_HSCROLL ) ); 2025 else if ( aString.EqualsAscii( SC_UNO_OUTLSYMB ) || aString.EqualsAscii( OLD_UNO_OUTLSYMB ) ) 2026 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_OUTLINER ) ); 2027 else if ( aString.EqualsAscii( SC_UNO_SHEETTABS ) || aString.EqualsAscii( OLD_UNO_SHEETTABS ) ) 2028 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_TABCONTROLS ) ); 2029 else if ( aString.EqualsAscii( SC_UNO_SHOWANCHOR ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_ANCHOR ) ); 2030 else if ( aString.EqualsAscii( SC_UNO_SHOWFORM ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_FORMULAS ) ); 2031 else if ( aString.EqualsAscii( SC_UNO_SHOWGRID ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_GRID ) ); 2032 else if ( aString.EqualsAscii( SC_UNO_SHOWHELP ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_HELPLINES ) ); 2033 else if ( aString.EqualsAscii( SC_UNO_SHOWNOTES ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_NOTES ) ); 2034 else if ( aString.EqualsAscii( SC_UNO_SHOWPAGEBR ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_PAGEBREAKS ) ); 2035 else if ( aString.EqualsAscii( SC_UNO_SHOWZERO ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_NULLVALS ) ); 2036 else if ( aString.EqualsAscii( SC_UNO_SHOWSOLID ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_SOLIDHANDLES ) ); 2037 else if ( aString.EqualsAscii( SC_UNO_VALUEHIGH ) || aString.EqualsAscii( OLD_UNO_VALUEHIGH ) ) 2038 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_SYNTAX ) ); 2039 else if ( aString.EqualsAscii( SC_UNO_VERTSCROLL ) || aString.EqualsAscii( OLD_UNO_VERTSCROLL ) ) 2040 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_VSCROLL ) ); 2041 else if ( aString.EqualsAscii( SC_UNO_SHOWOBJ ) ) aRet <<= (sal_Int16)( rOpt.GetObjMode( VOBJ_TYPE_OLE ) ); 2042 else if ( aString.EqualsAscii( SC_UNO_SHOWCHARTS ) ) aRet <<= (sal_Int16)( rOpt.GetObjMode( VOBJ_TYPE_CHART ) ); 2043 else if ( aString.EqualsAscii( SC_UNO_SHOWDRAW ) ) aRet <<= (sal_Int16)( rOpt.GetObjMode( VOBJ_TYPE_DRAW ) ); 2044 else if ( aString.EqualsAscii( SC_UNO_GRIDCOLOR ) ) aRet <<= (sal_Int32)( rOpt.GetGridColor().GetColor() ); 2045 else if ( aString.EqualsAscii( SC_UNO_VISAREA ) ) aRet <<= GetVisArea(); 2046 else if ( aString.EqualsAscii( SC_UNO_ZOOMTYPE ) ) aRet <<= GetZoomType(); 2047 else if ( aString.EqualsAscii( SC_UNO_ZOOMVALUE ) ) aRet <<= GetZoom(); 2048 else if ( aString.EqualsAscii( SC_UNO_VISAREASCREEN ) ) 2049 { 2050 ScViewData* pViewData = pViewSh->GetViewData(); 2051 Window* pActiveWin = ( pViewData ? pViewData->GetActiveWin() : NULL ); 2052 if ( pActiveWin ) 2053 { 2054 Rectangle aRect = pActiveWin->GetWindowExtentsRelative( NULL ); 2055 aRet <<= AWTRectangle( aRect ); 2056 } 2057 } 2058 } 2059 2060 return aRet; 2061 } 2062 2063 void SAL_CALL ScTabViewObj::addPropertyChangeListener( const ::rtl::OUString& /* aPropertyName */, 2064 const uno::Reference<beans::XPropertyChangeListener >& xListener ) 2065 throw(beans::UnknownPropertyException, 2066 lang::WrappedTargetException, 2067 uno::RuntimeException) 2068 { 2069 ScUnoGuard aGuard; 2070 uno::Reference<beans::XPropertyChangeListener>* pObj = 2071 new uno::Reference<beans::XPropertyChangeListener>( xListener ); 2072 aPropertyChgListeners.Insert( pObj, aPropertyChgListeners.Count() ); 2073 } 2074 2075 void SAL_CALL ScTabViewObj::removePropertyChangeListener( const ::rtl::OUString& /* aPropertyName */, 2076 const uno::Reference<beans::XPropertyChangeListener >& xListener ) 2077 throw(beans::UnknownPropertyException, 2078 lang::WrappedTargetException, 2079 uno::RuntimeException) 2080 { 2081 ScUnoGuard aGuard; 2082 sal_uInt16 nCount = aPropertyChgListeners.Count(); 2083 for ( sal_uInt16 n=nCount; n--; ) 2084 { 2085 uno::Reference<beans::XPropertyChangeListener> *pObj = aPropertyChgListeners[n]; 2086 if ( *pObj == xListener ) //! wozu der Mumpitz mit queryInterface? 2087 { 2088 aPropertyChgListeners.DeleteAndDestroy( n ); 2089 break; 2090 } 2091 } 2092 } 2093 2094 void SAL_CALL ScTabViewObj::addVetoableChangeListener( const ::rtl::OUString& /* PropertyName */, 2095 const uno::Reference<beans::XVetoableChangeListener >& /* aListener */ ) 2096 throw(beans::UnknownPropertyException, 2097 lang::WrappedTargetException, 2098 uno::RuntimeException) 2099 { 2100 } 2101 2102 void SAL_CALL ScTabViewObj::removeVetoableChangeListener( const ::rtl::OUString& /* PropertyName */, 2103 const uno::Reference<beans::XVetoableChangeListener >& /* aListener */ ) 2104 throw(beans::UnknownPropertyException, 2105 lang::WrappedTargetException, 2106 uno::RuntimeException) 2107 { 2108 } 2109 2110 void ScTabViewObj::VisAreaChanged() 2111 { 2112 beans::PropertyChangeEvent aEvent; 2113 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this)); 2114 for ( sal_uInt16 n=0; n<aPropertyChgListeners.Count(); n++ ) 2115 (*aPropertyChgListeners[n])->propertyChange( aEvent ); 2116 } 2117 2118 // XRangeSelection 2119 2120 void SAL_CALL ScTabViewObj::startRangeSelection( 2121 const uno::Sequence<beans::PropertyValue>& aArguments ) 2122 throw(uno::RuntimeException) 2123 { 2124 ScUnoGuard aGuard; 2125 ScTabViewShell* pViewSh = GetViewShell(); 2126 if (pViewSh) 2127 { 2128 String aInitVal, aTitle; 2129 sal_Bool bCloseOnButtonUp = sal_False; 2130 sal_Bool bSingleCell = sal_False; 2131 sal_Bool bMultiSelection = sal_False; 2132 2133 rtl::OUString aStrVal; 2134 const beans::PropertyValue* pPropArray = aArguments.getConstArray(); 2135 long nPropCount = aArguments.getLength(); 2136 for (long i = 0; i < nPropCount; i++) 2137 { 2138 const beans::PropertyValue& rProp = pPropArray[i]; 2139 String aPropName(rProp.Name); 2140 2141 if (aPropName.EqualsAscii( SC_UNONAME_CLOSEONUP )) 2142 bCloseOnButtonUp = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value ); 2143 else if (aPropName.EqualsAscii( SC_UNONAME_TITLE )) 2144 { 2145 if ( rProp.Value >>= aStrVal ) 2146 aTitle = String( aStrVal ); 2147 } 2148 else if (aPropName.EqualsAscii( SC_UNONAME_INITVAL )) 2149 { 2150 if ( rProp.Value >>= aStrVal ) 2151 aInitVal = String( aStrVal ); 2152 } 2153 else if (aPropName.EqualsAscii( SC_UNONAME_SINGLECELL )) 2154 bSingleCell = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value ); 2155 else if (aPropName.EqualsAscii( SC_UNONAME_MULTISEL )) 2156 bMultiSelection = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value ); 2157 } 2158 2159 pViewSh->StartSimpleRefDialog( aTitle, aInitVal, bCloseOnButtonUp, bSingleCell, bMultiSelection ); 2160 } 2161 } 2162 2163 void SAL_CALL ScTabViewObj::abortRangeSelection() throw(uno::RuntimeException) 2164 { 2165 ScUnoGuard aGuard; 2166 ScTabViewShell* pViewSh = GetViewShell(); 2167 if (pViewSh) 2168 pViewSh->StopSimpleRefDialog(); 2169 } 2170 2171 void SAL_CALL ScTabViewObj::addRangeSelectionListener( 2172 const uno::Reference<sheet::XRangeSelectionListener>& xListener ) 2173 throw(uno::RuntimeException) 2174 { 2175 ScUnoGuard aGuard; 2176 uno::Reference<sheet::XRangeSelectionListener>* pObj = 2177 new uno::Reference<sheet::XRangeSelectionListener>( xListener ); 2178 aRangeSelListeners.Insert( pObj, aRangeSelListeners.Count() ); 2179 } 2180 2181 void SAL_CALL ScTabViewObj::removeRangeSelectionListener( 2182 const uno::Reference<sheet::XRangeSelectionListener>& xListener ) 2183 throw(uno::RuntimeException) 2184 { 2185 ScUnoGuard aGuard; 2186 sal_uInt16 nCount = aRangeSelListeners.Count(); 2187 for ( sal_uInt16 n=nCount; n--; ) 2188 { 2189 uno::Reference<sheet::XRangeSelectionListener> *pObj = aRangeSelListeners[n]; 2190 if ( *pObj == xListener ) 2191 { 2192 aRangeSelListeners.DeleteAndDestroy( n ); 2193 break; 2194 } 2195 } 2196 } 2197 2198 void SAL_CALL ScTabViewObj::addRangeSelectionChangeListener( 2199 const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener ) 2200 throw(uno::RuntimeException) 2201 { 2202 ScUnoGuard aGuard; 2203 uno::Reference<sheet::XRangeSelectionChangeListener>* pObj = 2204 new uno::Reference<sheet::XRangeSelectionChangeListener>( xListener ); 2205 aRangeChgListeners.Insert( pObj, aRangeChgListeners.Count() ); 2206 } 2207 2208 void SAL_CALL ScTabViewObj::removeRangeSelectionChangeListener( 2209 const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener ) 2210 throw(uno::RuntimeException) 2211 { 2212 ScUnoGuard aGuard; 2213 sal_uInt16 nCount = aRangeChgListeners.Count(); 2214 for ( sal_uInt16 n=nCount; n--; ) 2215 { 2216 uno::Reference<sheet::XRangeSelectionChangeListener> *pObj = aRangeChgListeners[n]; 2217 if ( *pObj == xListener ) 2218 { 2219 aRangeChgListeners.DeleteAndDestroy( n ); 2220 break; 2221 } 2222 } 2223 } 2224 2225 void ScTabViewObj::RangeSelDone( const String& rText ) 2226 { 2227 sheet::RangeSelectionEvent aEvent; 2228 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this)); 2229 aEvent.RangeDescriptor = rtl::OUString( rText ); 2230 2231 for ( sal_uInt16 n=0; n<aRangeSelListeners.Count(); n++ ) 2232 (*aRangeSelListeners[n])->done( aEvent ); 2233 } 2234 2235 void ScTabViewObj::RangeSelAborted( const String& rText ) 2236 { 2237 sheet::RangeSelectionEvent aEvent; 2238 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this)); 2239 aEvent.RangeDescriptor = rtl::OUString( rText ); 2240 2241 for ( sal_uInt16 n=0; n<aRangeSelListeners.Count(); n++ ) 2242 (*aRangeSelListeners[n])->aborted( aEvent ); 2243 } 2244 2245 void ScTabViewObj::RangeSelChanged( const String& rText ) 2246 { 2247 sheet::RangeSelectionEvent aEvent; 2248 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this)); 2249 aEvent.RangeDescriptor = rtl::OUString( rText ); 2250 2251 for ( sal_uInt16 n=0; n<aRangeChgListeners.Count(); n++ ) 2252 (*aRangeChgListeners[n])->descriptorChanged( aEvent ); 2253 } 2254 2255 // XServiceInfo 2256 2257 rtl::OUString SAL_CALL ScTabViewObj::getImplementationName() throw(uno::RuntimeException) 2258 { 2259 return rtl::OUString::createFromAscii( "ScTabViewObj" ); 2260 } 2261 2262 sal_Bool SAL_CALL ScTabViewObj::supportsService( const rtl::OUString& rServiceName ) 2263 throw(uno::RuntimeException) 2264 { 2265 String aServiceStr( rServiceName ); 2266 return aServiceStr.EqualsAscii( SCTABVIEWOBJ_SERVICE ) || 2267 aServiceStr.EqualsAscii( SCVIEWSETTINGS_SERVICE ); 2268 } 2269 2270 uno::Sequence<rtl::OUString> SAL_CALL ScTabViewObj::getSupportedServiceNames() 2271 throw(uno::RuntimeException) 2272 { 2273 uno::Sequence<rtl::OUString> aRet(2); 2274 rtl::OUString* pArray = aRet.getArray(); 2275 pArray[0] = rtl::OUString::createFromAscii( SCTABVIEWOBJ_SERVICE ); 2276 pArray[1] = rtl::OUString::createFromAscii( SCVIEWSETTINGS_SERVICE ); 2277 return aRet; 2278 } 2279 2280 // XUnoTunnel 2281 2282 sal_Int64 SAL_CALL ScTabViewObj::getSomething( 2283 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException) 2284 { 2285 if ( rId.getLength() == 16 && 2286 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), 2287 rId.getConstArray(), 16 ) ) 2288 { 2289 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); 2290 } 2291 return 0; 2292 } 2293 2294 // static 2295 const uno::Sequence<sal_Int8>& ScTabViewObj::getUnoTunnelId() 2296 { 2297 static uno::Sequence<sal_Int8> * pSeq = 0; 2298 if( !pSeq ) 2299 { 2300 osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); 2301 if( !pSeq ) 2302 { 2303 static uno::Sequence< sal_Int8 > aSeq( 16 ); 2304 rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); 2305 pSeq = &aSeq; 2306 } 2307 } 2308 return *pSeq; 2309 } 2310 2311 // static 2312 ScTabViewObj* ScTabViewObj::getImplementation( const uno::Reference<uno::XInterface> xObj ) 2313 { 2314 ScTabViewObj* pRet = NULL; 2315 uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY ); 2316 if (xUT.is()) 2317 pRet = reinterpret_cast<ScTabViewObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId()))); 2318 return pRet; 2319 } 2320 2321 ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL ScTabViewObj::getTransferable( ) throw (::com::sun::star::uno::RuntimeException) 2322 { 2323 ScUnoGuard aGuard; 2324 ScEditShell* pShell = PTR_CAST( ScEditShell, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) ); 2325 if (pShell) 2326 return pShell->GetEditView()->GetTransferable(); 2327 2328 ScDrawTextObjectBar* pTextShell = PTR_CAST( ScDrawTextObjectBar, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) ); 2329 if (pTextShell) 2330 { 2331 ScViewData* pViewData = GetViewShell()->GetViewData(); 2332 ScDrawView* pView = pViewData->GetScDrawView(); 2333 OutlinerView* pOutView = pView->GetTextEditOutlinerView(); 2334 if (pOutView) 2335 return pOutView->GetEditView().GetTransferable(); 2336 } 2337 2338 ScDrawShell* pDrawShell = PTR_CAST( ScDrawShell, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) ); 2339 if (pDrawShell) 2340 return pDrawShell->GetDrawView()->CopyToTransferable(); 2341 2342 ScTransferObj* pObj = GetViewShell()->CopyToTransferable(); 2343 uno::Reference<datatransfer::XTransferable> xTransferable( pObj ); 2344 return xTransferable; 2345 } 2346 2347 void SAL_CALL ScTabViewObj::insertTransferable( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans ) throw (::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::uno::RuntimeException) 2348 { 2349 ScUnoGuard aGuard; 2350 ScEditShell* pShell = PTR_CAST( ScEditShell, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) ); 2351 if (pShell) 2352 pShell->GetEditView()->InsertText( xTrans, ::rtl::OUString(), sal_False ); 2353 else 2354 { 2355 ScDrawTextObjectBar* pTextShell = PTR_CAST( ScDrawTextObjectBar, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) ); 2356 if (pTextShell) 2357 { 2358 ScViewData* pViewData = GetViewShell()->GetViewData(); 2359 ScDrawView* pView = pViewData->GetScDrawView(); 2360 OutlinerView* pOutView = pView->GetTextEditOutlinerView(); 2361 if ( pOutView ) 2362 { 2363 pOutView->GetEditView().InsertText( xTrans, ::rtl::OUString(), sal_False ); 2364 return; 2365 } 2366 } 2367 2368 GetViewShell()->PasteFromTransferable( xTrans ); 2369 } 2370 } 2371 2372 //------------------------------------------------------------------------ 2373 2374 2375 2376 2377