LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - viewuno.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 698 1304 53.5 %
Date: 2015-06-13 12:38:46 Functions: 68 114 59.6 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11