LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/view - tabvwshb.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 253 0.4 %
Date: 2012-12-27 Functions: 2 10 20.0 %
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/embed/NoVisualAreaSizeException.hpp>
      21             : #include <com/sun/star/chart2/data/XDataReceiver.hpp>
      22             : 
      23             : #ifdef _MSC_VER
      24             : #pragma optimize ("", off)
      25             : #endif
      26             : 
      27             : #include <com/sun/star/embed/EmbedMisc.hpp>
      28             : #include <com/sun/star/embed/EmbedStates.hpp>
      29             : #include <sfx2/app.hxx>
      30             : #include <toolkit/helper/vclunohelper.hxx>
      31             : #include <svx/svxdlg.hxx>
      32             : #include <svx/dataaccessdescriptor.hxx>
      33             : #include <svx/pfiledlg.hxx>
      34             : #include <svx/svditer.hxx>
      35             : #include <svx/svdmark.hxx>
      36             : #include <svx/svdograf.hxx>
      37             : #include <svx/svdogrp.hxx>
      38             : #include <svx/svdoole2.hxx>
      39             : #include <svx/svdouno.hxx>
      40             : #include <svx/svdview.hxx>
      41             : #include <sfx2/linkmgr.hxx>
      42             : #include <svx/fontworkbar.hxx>
      43             : #include <sfx2/bindings.hxx>
      44             : #include <sfx2/dispatch.hxx>
      45             : #include <sfx2/viewfrm.hxx>
      46             : #include <svtools/soerr.hxx>
      47             : #include <svl/rectitem.hxx>
      48             : #include <svl/slstitm.hxx>
      49             : #include <svl/whiter.hxx>
      50             : #include <unotools/moduleoptions.hxx>
      51             : #include <sot/exchange.hxx>
      52             : #include <tools/diagnose_ex.h>
      53             : 
      54             : #include "tabvwsh.hxx"
      55             : #include "globstr.hrc"
      56             : #include "scmod.hxx"
      57             : #include "document.hxx"
      58             : #include "sc.hrc"
      59             : #include "client.hxx"
      60             : #include "fuinsert.hxx"
      61             : #include "docsh.hxx"
      62             : #include "chartarr.hxx"
      63             : #include "drawview.hxx"
      64             : #include "ChartRangeSelectionListener.hxx"
      65             : 
      66             : using namespace com::sun::star;
      67             : 
      68             : // STATIC DATA -----------------------------------------------------------
      69             : 
      70           0 : void ScTabViewShell::ConnectObject( SdrOle2Obj* pObj )
      71             : {
      72             :     //  wird aus dem Paint gerufen
      73             : 
      74           0 :     uno::Reference < embed::XEmbeddedObject > xObj = pObj->GetObjRef();
      75           0 :     Window* pWin = GetActiveWin();
      76             : 
      77             :     //  wenn schon connected ist, nicht nochmal SetObjArea/SetSizeScale
      78             : 
      79           0 :     SfxInPlaceClient* pClient = FindIPClient( xObj, pWin );
      80           0 :     if ( !pClient )
      81             :     {
      82           0 :         pClient = new ScClient( this, pWin, GetSdrView()->GetModel(), pObj );
      83           0 :         Rectangle aRect = pObj->GetLogicRect();
      84           0 :         Size aDrawSize = aRect.GetSize();
      85             : 
      86           0 :         Size aOleSize = pObj->GetOrigObjSize();
      87             : 
      88           0 :         Fraction aScaleWidth (aDrawSize.Width(),  aOleSize.Width() );
      89           0 :         Fraction aScaleHeight(aDrawSize.Height(), aOleSize.Height() );
      90           0 :         aScaleWidth.ReduceInaccurate(10);       // kompatibel zum SdrOle2Obj
      91           0 :         aScaleHeight.ReduceInaccurate(10);
      92           0 :         pClient->SetSizeScale(aScaleWidth,aScaleHeight);
      93             : 
      94             :         // sichtbarer Ausschnitt wird nur inplace veraendert!
      95             :         // the object area must be set after the scaling since it triggers the resizing
      96           0 :         aRect.SetSize( aOleSize );
      97           0 :         pClient->SetObjArea( aRect );
      98             : 
      99           0 :         ((ScClient*)pClient)->SetGrafEdit( NULL );
     100           0 :     }
     101           0 : }
     102             : 
     103           0 : sal_Bool ScTabViewShell::ActivateObject( SdrOle2Obj* pObj, long nVerb )
     104             : {
     105             :     // Gueltigkeits-Hinweisfenster nicht ueber dem Objekt stehenlassen
     106           0 :     RemoveHintWindow();
     107             : 
     108           0 :     uno::Reference < embed::XEmbeddedObject > xObj = pObj->GetObjRef();
     109           0 :     Window* pWin = GetActiveWin();
     110           0 :     ErrCode nErr = ERRCODE_NONE;
     111           0 :     sal_Bool bErrorShown = false;
     112             : 
     113             :     {
     114           0 :         SfxInPlaceClient* pClient = FindIPClient( xObj, pWin );
     115           0 :         if ( !pClient )
     116           0 :             pClient = new ScClient( this, pWin, GetSdrView()->GetModel(), pObj );
     117             : 
     118           0 :         if ( !(nErr & ERRCODE_ERROR_MASK) && xObj.is() )
     119             :         {
     120           0 :             Rectangle aRect = pObj->GetLogicRect();
     121             : 
     122             :             {
     123             :                 // #i118485# center on BoundRect for activation,
     124             :                 // OLE may be sheared/rotated now
     125           0 :                 const Rectangle& rBoundRect = pObj->GetCurrentBoundRect();
     126           0 :                 const Point aDelta(rBoundRect.Center() - aRect.Center());
     127           0 :                 aRect.Move(aDelta.X(), aDelta.Y());
     128             :             }
     129             : 
     130           0 :             Size aDrawSize = aRect.GetSize();
     131             : 
     132           0 :             MapMode aMapMode( MAP_100TH_MM );
     133           0 :             Size aOleSize = pObj->GetOrigObjSize( &aMapMode );
     134             : 
     135           0 :             if ( pClient->GetAspect() != embed::Aspects::MSOLE_ICON
     136           0 :               && ( xObj->getStatus( pClient->GetAspect() ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE ) )
     137             :             {
     138             :                 //  scale must always be 1 - change VisArea if different from client size
     139             : 
     140           0 :                 if ( aDrawSize != aOleSize )
     141             :                 {
     142           0 :                     MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( pClient->GetAspect() ) );
     143             :                     aOleSize = OutputDevice::LogicToLogic( aDrawSize,
     144           0 :                                             MAP_100TH_MM, aUnit );
     145           0 :                     awt::Size aSz( aOleSize.Width(), aOleSize.Height() );
     146           0 :                     xObj->setVisualAreaSize( pClient->GetAspect(), aSz );
     147             :                 }
     148           0 :                 Fraction aOne( 1, 1 );
     149           0 :                 pClient->SetSizeScale( aOne, aOne );
     150             :             }
     151             :             else
     152             :             {
     153             :                 //  calculate scale from client and VisArea size
     154             : 
     155           0 :                 Fraction aScaleWidth (aDrawSize.Width(),  aOleSize.Width() );
     156           0 :                 Fraction aScaleHeight(aDrawSize.Height(), aOleSize.Height() );
     157           0 :                 aScaleWidth.ReduceInaccurate(10);       // kompatibel zum SdrOle2Obj
     158           0 :                 aScaleHeight.ReduceInaccurate(10);
     159           0 :                 pClient->SetSizeScale(aScaleWidth,aScaleHeight);
     160             :             }
     161             : 
     162             :             // sichtbarer Ausschnitt wird nur inplace veraendert!
     163             :             // the object area must be set after the scaling since it triggers the resizing
     164           0 :             aRect.SetSize( aOleSize );
     165           0 :             pClient->SetObjArea( aRect );
     166             : 
     167           0 :             ((ScClient*)pClient)->SetGrafEdit( NULL );
     168             : 
     169           0 :             nErr = pClient->DoVerb( nVerb );
     170           0 :             bErrorShown = sal_True;
     171             :             // SfxViewShell::DoVerb zeigt seine Fehlermeldungen selber an
     172             : 
     173             :             // attach listener to selection changes in chart that affect cell
     174             :             // ranges, so those can be highlighted
     175             :             // note: do that after DoVerb, so that the chart controller exists
     176           0 :             if ( SvtModuleOptions().IsChart() )
     177             :             {
     178           0 :                 SvGlobalName aObjClsId ( xObj->getClassID() );
     179           0 :                 if (SotExchange::IsChart( aObjClsId ))
     180             :                 {
     181             :                     try
     182             :                     {
     183           0 :                         uno::Reference < embed::XComponentSupplier > xSup( xObj, uno::UNO_QUERY_THROW );
     184             :                         uno::Reference< chart2::data::XDataReceiver > xDataReceiver(
     185           0 :                             xSup->getComponent(), uno::UNO_QUERY_THROW );
     186             :                         uno::Reference< chart2::data::XRangeHighlighter > xRangeHightlighter(
     187           0 :                             xDataReceiver->getRangeHighlighter());
     188           0 :                         if( xRangeHightlighter.is())
     189             :                         {
     190             :                             uno::Reference< view::XSelectionChangeListener > xListener(
     191           0 :                                 new ScChartRangeSelectionListener( this ));
     192           0 :                             xRangeHightlighter->addSelectionChangeListener( xListener );
     193           0 :                         }
     194             :                     }
     195           0 :                     catch( const uno::Exception & )
     196             :                     {
     197             :                         OSL_FAIL( "Exception caught while querying chart" );
     198             :                     }
     199           0 :                 }
     200           0 :             }
     201             :         }
     202             :     }
     203           0 :     if (nErr != ERRCODE_NONE && !bErrorShown)
     204           0 :         ErrorHandler::HandleError(nErr);
     205             : 
     206             :     // #i118524# refresh handles to suppress for activated OLE
     207           0 :     if(GetSdrView())
     208             :     {
     209           0 :         GetSdrView()->AdjustMarkHdl();
     210             :     }
     211             :     //! SetDocumentName sollte schon im Sfx passieren ???
     212             :     //TODO/LATER: how "SetDocumentName"?
     213             :     //xIPObj->SetDocumentName( GetViewData()->GetDocShell()->GetTitle() );
     214             : 
     215           0 :     return ( !(nErr & ERRCODE_ERROR_MASK) );
     216             : }
     217             : 
     218           0 : ErrCode ScTabViewShell::DoVerb(long nVerb)
     219             : {
     220           0 :     SdrView* pView = GetSdrView();
     221           0 :     if (!pView)
     222           0 :         return ERRCODE_SO_NOTIMPL;          // soll nicht sein
     223             : 
     224           0 :     SdrOle2Obj* pOle2Obj = NULL;
     225           0 :     SdrObject* pObj = NULL;
     226           0 :     ErrCode nErr = ERRCODE_NONE;
     227             : 
     228           0 :     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     229           0 :     if (rMarkList.GetMarkCount() == 1)
     230             :     {
     231           0 :         pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
     232           0 :         if (pObj->GetObjIdentifier() == OBJ_OLE2)
     233           0 :             pOle2Obj = (SdrOle2Obj*) pObj;
     234             :     }
     235             : 
     236           0 :     if (pOle2Obj)
     237             :     {
     238           0 :         ActivateObject( pOle2Obj, nVerb );
     239             :     }
     240             :     else
     241             :     {
     242             :         OSL_FAIL("kein Objekt fuer Verb gefunden");
     243             :     }
     244             : 
     245           0 :     return nErr;
     246             : }
     247             : 
     248           0 : void ScTabViewShell::DeactivateOle()
     249             : {
     250             :     // deactivate inplace editing if currently active
     251             : 
     252           0 :     ScModule* pScMod = SC_MOD();
     253           0 :     bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF;
     254             : 
     255           0 :     ScClient* pClient = (ScClient*) GetIPClient();
     256           0 :     if ( pClient && pClient->IsObjectInPlaceActive() && !bUnoRefDialog )
     257           0 :         pClient->DeactivateObject();
     258           0 : }
     259             : 
     260           0 : void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
     261             : {
     262           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     263           0 :     if (nSlot != SID_OBJECTRESIZE )
     264             :     {
     265           0 :         SC_MOD()->InputEnterHandler();
     266           0 :         UpdateInputHandler();
     267             :     }
     268             : 
     269             :     //  Rahmen fuer Chart einfuegen wird abgebrochen:
     270           0 :     FuPoor* pPoor = GetDrawFuncPtr();
     271           0 :     if ( pPoor && pPoor->GetSlotID() == SID_DRAW_CHART )
     272           0 :         GetViewData()->GetDispatcher().Execute(SID_DRAW_CHART, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
     273             : 
     274           0 :     MakeDrawLayer();
     275             : 
     276           0 :     SfxBindings& rBindings = GetViewFrame()->GetBindings();
     277           0 :     ScTabView*   pTabView  = GetViewData()->GetView();
     278           0 :     Window*      pWin      = pTabView->GetActiveWin();
     279           0 :     ScDrawView*  pView     = pTabView->GetScDrawView();
     280           0 :     ScDocShell*  pDocSh    = GetViewData()->GetDocShell();
     281           0 :     ScDocument*  pDoc      = pDocSh->GetDocument();
     282           0 :     SdrModel*    pDrModel  = pView->GetModel();
     283             : 
     284           0 :     switch ( nSlot )
     285             :     {
     286             :         case SID_INSERT_GRAPHIC:
     287           0 :             FuInsertGraphic(this, pWin, pView, pDrModel, rReq);
     288             :             // shell is set in MarkListHasChanged
     289           0 :             break;
     290             : 
     291             :         case SID_INSERT_AVMEDIA:
     292           0 :             FuInsertMedia(this, pWin, pView, pDrModel, rReq);
     293             :             // shell is set in MarkListHasChanged
     294           0 :             break;
     295             : 
     296             :         case SID_INSERT_DIAGRAM:
     297           0 :             FuInsertChart(this, pWin, pView, pDrModel, rReq);
     298           0 :             break;
     299             : 
     300             :         case SID_INSERT_OBJECT:
     301             :         case SID_INSERT_PLUGIN:
     302             :         case SID_INSERT_SOUND:
     303             :         case SID_INSERT_VIDEO:
     304             :         case SID_INSERT_SMATH:
     305             :         case SID_INSERT_FLOATINGFRAME:
     306           0 :             FuInsertOLE(this, pWin, pView, pDrModel, rReq);
     307           0 :             break;
     308             : 
     309             :         case SID_OBJECTRESIZE:
     310             :             {
     311             :                 //          Der Server moechte die Clientgrosse verandern
     312             : 
     313           0 :                 SfxInPlaceClient* pClient = GetIPClient();
     314             : 
     315           0 :                 if ( pClient && pClient->IsObjectInPlaceActive() )
     316             :                 {
     317             :                     const SfxRectangleItem& rRect =
     318           0 :                         (SfxRectangleItem&)rReq.GetArgs()->Get(SID_OBJECTRESIZE);
     319           0 :                     Rectangle aRect( pWin->PixelToLogic( rRect.GetValue() ) );
     320             : 
     321           0 :                     if ( pView->AreObjectsMarked() )
     322             :                     {
     323           0 :                         const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     324             : 
     325           0 :                         if (rMarkList.GetMarkCount() == 1)
     326             :                         {
     327           0 :                             SdrMark* pMark = rMarkList.GetMark(0);
     328           0 :                             SdrObject* pObj = pMark->GetMarkedSdrObj();
     329             : 
     330           0 :                             sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
     331             : 
     332           0 :                             if (nSdrObjKind == OBJ_OLE2)
     333             :                             {
     334           0 :                                 if ( ( (SdrOle2Obj*) pObj)->GetObjRef().is() )
     335             :                                 {
     336           0 :                                     pObj->SetLogicRect(aRect);
     337             :                                 }
     338             :                             }
     339             :                         }
     340             :                     }
     341             :                 }
     342             :             }
     343           0 :             break;
     344             : 
     345             :         case SID_LINKS:
     346             :             {
     347           0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     348           0 :                 SfxAbstractLinksDialog* pDlg = pFact->CreateLinksDialog( pWin, pDoc->GetLinkManager() );
     349           0 :                 if ( pDlg )
     350             :                 {
     351           0 :                     pDlg->Execute();
     352           0 :                     rBindings.Invalidate( nSlot );
     353           0 :                     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );     // Navigator
     354           0 :                     rReq.Done();
     355             :                 }
     356             :             }
     357           0 :             break;
     358             : 
     359             :         // #98721#
     360             :         case SID_FM_CREATE_FIELDCONTROL:
     361             :             {
     362           0 :                 SFX_REQUEST_ARG( rReq, pDescriptorItem, SfxUnoAnyItem, SID_FM_DATACCESS_DESCRIPTOR, false );
     363             :                 OSL_ENSURE( pDescriptorItem, "SID_FM_CREATE_FIELDCONTROL: invalid request args!" );
     364             : 
     365           0 :                 if(pDescriptorItem)
     366             :                 {
     367             :                     //! merge with ScViewFunc::PasteDataFormat (SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE)?
     368             : 
     369           0 :                     ScDrawView* pDrView = GetScDrawView();
     370           0 :                     SdrPageView* pPageView = pDrView ? pDrView->GetSdrPageView() : NULL;
     371           0 :                     if(pPageView)
     372             :                     {
     373           0 :                         ::svx::ODataAccessDescriptor aDescriptor(pDescriptorItem->GetValue());
     374           0 :                         SdrObject* pNewDBField = pDrView->CreateFieldControl(aDescriptor);
     375             : 
     376           0 :                         if(pNewDBField)
     377             :                         {
     378           0 :                             Rectangle aVisArea = pWin->PixelToLogic(Rectangle(Point(0,0), pWin->GetOutputSizePixel()));
     379           0 :                             Point aObjPos(aVisArea.Center());
     380           0 :                             Size aObjSize(pNewDBField->GetLogicRect().GetSize());
     381           0 :                             aObjPos.X() -= aObjSize.Width() / 2;
     382           0 :                             aObjPos.Y() -= aObjSize.Height() / 2;
     383           0 :                             Rectangle aNewObjectRectangle(aObjPos, aObjSize);
     384             : 
     385           0 :                             pNewDBField->SetLogicRect(aNewObjectRectangle);
     386             : 
     387             :                             // controls must be on control layer, groups on front layer
     388           0 :                             if ( pNewDBField->ISA(SdrUnoObj) )
     389           0 :                                 pNewDBField->NbcSetLayer(SC_LAYER_CONTROLS);
     390             :                             else
     391           0 :                                 pNewDBField->NbcSetLayer(SC_LAYER_FRONT);
     392           0 :                             if (pNewDBField->ISA(SdrObjGroup))
     393             :                             {
     394           0 :                                 SdrObjListIter aIter( *pNewDBField, IM_DEEPWITHGROUPS );
     395           0 :                                 SdrObject* pSubObj = aIter.Next();
     396           0 :                                 while (pSubObj)
     397             :                                 {
     398           0 :                                     if ( pSubObj->ISA(SdrUnoObj) )
     399           0 :                                         pSubObj->NbcSetLayer(SC_LAYER_CONTROLS);
     400             :                                     else
     401           0 :                                         pSubObj->NbcSetLayer(SC_LAYER_FRONT);
     402           0 :                                     pSubObj = aIter.Next();
     403           0 :                                 }
     404             :                             }
     405             : 
     406           0 :                             pView->InsertObjectAtView(pNewDBField, *pPageView);
     407           0 :                         }
     408             :                     }
     409             :                 }
     410           0 :                 rReq.Done();
     411             :             }
     412           0 :             break;
     413             : 
     414             :         case SID_FONTWORK_GALLERY_FLOATER:
     415           0 :             svx::FontworkBar::execute( pView, rReq, GetViewFrame()->GetBindings() );
     416           0 :             rReq.Ignore();
     417           0 :             break;
     418             :     }
     419           0 : }
     420             : 
     421           0 : void ScTabViewShell::GetDrawInsState(SfxItemSet &rSet)
     422             : {
     423           0 :     sal_Bool bOle = GetViewFrame()->GetFrame().IsInPlace();
     424           0 :     sal_Bool bTabProt = GetViewData()->GetDocument()->IsTabProtected(GetViewData()->GetTabNo());
     425           0 :     ScDocShell* pDocShell = ( GetViewData() ? GetViewData()->GetDocShell() : NULL );
     426           0 :     bool bShared = ( pDocShell ? pDocShell->IsDocShared() : false );
     427             : 
     428           0 :     SfxWhichIter aIter(rSet);
     429           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     430           0 :     while ( nWhich )
     431             :     {
     432           0 :         switch ( nWhich )
     433             :         {
     434             :             case SID_INSERT_DIAGRAM:
     435           0 :                 if ( bOle || bTabProt || !SvtModuleOptions().IsChart() || bShared )
     436           0 :                     rSet.DisableItem( nWhich );
     437           0 :                 break;
     438             : 
     439             :             case SID_INSERT_SMATH:
     440           0 :                 if ( bOle || bTabProt || !SvtModuleOptions().IsMath() || bShared )
     441           0 :                     rSet.DisableItem( nWhich );
     442           0 :                 break;
     443             : 
     444             :             case SID_INSERT_OBJECT:
     445             :             case SID_INSERT_PLUGIN:
     446             :             case SID_INSERT_FLOATINGFRAME:
     447           0 :                 if ( bOle || bTabProt || bShared )
     448           0 :                     rSet.DisableItem( nWhich );
     449           0 :                 break;
     450             : 
     451             :             case SID_INSERT_SOUND:
     452             :             case SID_INSERT_VIDEO:
     453             :                  /* #i102735# discussed with NN: removed for performance reasons
     454             :                  || !SvxPluginFileDlg::IsAvailable(nWhich)
     455             :                  */
     456           0 :                 if ( bOle || bTabProt || bShared )
     457           0 :                     rSet.DisableItem( nWhich );
     458           0 :                 break;
     459             : 
     460             :             case SID_INSERT_GRAPHIC:
     461             :             case SID_INSERT_AVMEDIA:
     462             :             case SID_FONTWORK_GALLERY_FLOATER:
     463           0 :                 if ( bTabProt || bShared )
     464           0 :                     rSet.DisableItem( nWhich );
     465           0 :                 break;
     466             : 
     467             :             case SID_LINKS:
     468             :                 {
     469           0 :                     if (GetViewData()->GetDocument()->GetLinkManager()->GetLinks().empty())
     470           0 :                         rSet.DisableItem( SID_LINKS );
     471             :                 }
     472           0 :                 break;
     473             :         }
     474           0 :         nWhich = aIter.NextWhich();
     475           0 :     }
     476           0 : }
     477             : 
     478             : 
     479             : //------------------------------------------------------------------
     480             : 
     481           0 : void ScTabViewShell::ExecuteUndo(SfxRequest& rReq)
     482             : {
     483           0 :     SfxShell* pSh = GetViewData()->GetDispatcher().GetShell(0);
     484           0 :     ::svl::IUndoManager* pUndoManager = pSh->GetUndoManager();
     485             : 
     486           0 :     const SfxItemSet* pReqArgs = rReq.GetArgs();
     487           0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
     488             : 
     489           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     490           0 :     switch ( nSlot )
     491             :     {
     492             :         case SID_UNDO:
     493             :         case SID_REDO:
     494           0 :             if ( pUndoManager )
     495             :             {
     496           0 :                 sal_Bool bIsUndo = ( nSlot == SID_UNDO );
     497             : 
     498           0 :                 sal_uInt16 nCount = 1;
     499             :                 const SfxPoolItem* pItem;
     500           0 :                 if ( pReqArgs && pReqArgs->GetItemState( nSlot, sal_True, &pItem ) == SFX_ITEM_SET )
     501           0 :                     nCount = ((const SfxUInt16Item*)pItem)->GetValue();
     502             : 
     503             :                 // lock paint for more than one cell undo action (not for editing within a cell)
     504           0 :                 sal_Bool bLockPaint = ( nCount > 1 && pUndoManager == GetUndoManager() );
     505           0 :                 if ( bLockPaint )
     506           0 :                     pDocSh->LockPaint();
     507             : 
     508             :                 try
     509             :                 {
     510           0 :                     for (sal_uInt16 i=0; i<nCount; i++)
     511             :                     {
     512           0 :                         if ( bIsUndo )
     513           0 :                             pUndoManager->Undo();
     514             :                         else
     515           0 :                             pUndoManager->Redo();
     516             :                     }
     517             :                 }
     518           0 :                 catch ( const uno::Exception& )
     519             :                 {
     520             :                     // no need to handle. By definition, the UndoManager handled this by clearing the
     521             :                     // Undo/Redo stacks
     522             :                 }
     523             : 
     524           0 :                 if ( bLockPaint )
     525           0 :                     pDocSh->UnlockPaint();
     526             : 
     527           0 :                 GetViewFrame()->GetBindings().InvalidateAll(false);
     528             :             }
     529           0 :             break;
     530             : //      default:
     531             : //          GetViewFrame()->ExecuteSlot( rReq );
     532             :     }
     533           0 : }
     534             : 
     535           0 : void ScTabViewShell::GetUndoState(SfxItemSet &rSet)
     536             : {
     537           0 :     SfxShell* pSh = GetViewData()->GetDispatcher().GetShell(0);
     538           0 :     ::svl::IUndoManager* pUndoManager = pSh->GetUndoManager();
     539             : 
     540           0 :     SfxWhichIter aIter(rSet);
     541           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     542           0 :     while ( nWhich )
     543             :     {
     544           0 :         switch (nWhich)
     545             :         {
     546             :             case SID_GETUNDOSTRINGS:
     547             :             case SID_GETREDOSTRINGS:
     548             :                 {
     549           0 :                     SfxStringListItem aStrLst( nWhich );
     550           0 :                     if ( pUndoManager )
     551             :                     {
     552           0 :                         std::vector<String> &aList = aStrLst.GetList();
     553           0 :                         sal_Bool bIsUndo = ( nWhich == SID_GETUNDOSTRINGS );
     554           0 :                         size_t nCount = bIsUndo ? pUndoManager->GetUndoActionCount() : pUndoManager->GetRedoActionCount();
     555           0 :                         for (size_t i=0; i<nCount; ++i)
     556             :                         {
     557           0 :                             aList.push_back( rtl::OUString( bIsUndo ? pUndoManager->GetUndoActionComment(i) :
     558           0 :                                                        pUndoManager->GetRedoActionComment(i) ) );
     559             :                         }
     560             :                     }
     561           0 :                     rSet.Put( aStrLst );
     562             :                 }
     563           0 :                 break;
     564             :             default:
     565             :                 // get state from sfx view frame
     566           0 :                 GetViewFrame()->GetSlotState( nWhich, NULL, &rSet );
     567             :         }
     568             : 
     569           0 :         nWhich = aIter.NextWhich();
     570           0 :     }
     571          15 : }
     572             : 
     573             : 
     574             : 
     575             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10