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

Generated by: LCOV version 1.10