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

Generated by: LCOV version 1.10