LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - viewuno.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 697 1316 53.0 %
Date: 2014-04-11 Functions: 68 116 58.6 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10