LCOV - code coverage report
Current view: top level - sc/source/ui/view - tabvwshb.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 25 248 10.1 %
Date: 2012-08-25 Functions: 2 8 25.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 35 516 6.8 %

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

Generated by: LCOV version 1.10