LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/view - tabvwsh9.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 8 99 8.1 %
Date: 2013-07-09 Functions: 4 10 40.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 <svx/svdmark.hxx>
      21             : #include <svx/svdview.hxx>
      22             : #include <svx/galbrws.hxx>
      23             : #include <svx/gallery.hxx>
      24             : #include <svx/hlnkitem.hxx>
      25             : #include <sfx2/bindings.hxx>
      26             : #include <sfx2/request.hxx>
      27             : #include <sfx2/viewfrm.hxx>
      28             : #include <sfx2/dispatch.hxx>
      29             : #include <svl/whiter.hxx>
      30             : 
      31             : #include "tabvwsh.hxx"
      32             : #include "viewdata.hxx"
      33             : #include "tabview.hxx"
      34             : #include "drwlayer.hxx"
      35             : #include "userdat.hxx"
      36             : #include "docsh.hxx"
      37             : 
      38             : #include <svx/galleryitem.hxx>
      39             : #include <com/sun/star/gallery/GalleryItemType.hpp>
      40             : 
      41             : class SvxIMapDlg;
      42             : 
      43             : sal_uInt16          ScIMapChildWindowId();
      44             : SvxIMapDlg*     ScGetIMapDlg();
      45             : const void*     ScIMapDlgGetObj( SvxIMapDlg* pDlg );
      46             : const ImageMap& ScIMapDlgGetMap( SvxIMapDlg* pDlg );
      47             : 
      48             : //------------------------------------------------------------------
      49             : 
      50           0 : void ScTabViewShell::ExecChildWin(SfxRequest& rReq)
      51             : {
      52           0 :     sal_uInt16 nSlot = rReq.GetSlot();
      53           0 :     switch(nSlot)
      54             :     {
      55             :         case SID_GALLERY:
      56             :         {
      57           0 :             SfxViewFrame* pThisFrame = GetViewFrame();
      58           0 :             pThisFrame->ToggleChildWindow( GalleryChildWindow::GetChildWindowId() );
      59           0 :             pThisFrame->GetBindings().Invalidate( SID_GALLERY );
      60           0 :             rReq.Ignore();
      61             :         }
      62           0 :         break;
      63             :     }
      64           0 : }
      65             : 
      66         191 : void ScTabViewShell::GetChildWinState( SfxItemSet& rSet )
      67             : {
      68         191 :     if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GALLERY ) )
      69             :     {
      70         191 :         sal_uInt16 nId = GalleryChildWindow::GetChildWindowId();
      71         191 :         rSet.Put( SfxBoolItem( SID_GALLERY, GetViewFrame()->HasChildWindow( nId ) ) );
      72             :     }
      73         191 : }
      74             : 
      75             : //------------------------------------------------------------------
      76             : 
      77           0 : void ScTabViewShell::ExecGallery( SfxRequest& rReq )
      78             : {
      79           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
      80             : 
      81           0 :     SFX_ITEMSET_ARG( pArgs, pGalleryItem, SvxGalleryItem, SID_GALLERY_FORMATS, sal_False );
      82           0 :     if ( !pGalleryItem )
      83           0 :         return;
      84             : 
      85           0 :     sal_Int8 nType( pGalleryItem->GetType() );
      86           0 :     if ( nType == com::sun::star::gallery::GalleryItemType::GRAPHIC )
      87             :     {
      88           0 :         MakeDrawLayer();
      89             : 
      90           0 :         Graphic aGraphic( pGalleryItem->GetGraphic() );
      91           0 :         Point   aPos     = GetInsertPos();
      92             : 
      93           0 :         String aPath, aFilter;
      94           0 :         if ( pGalleryItem->IsLink() ) // als Link einfuegen?
      95             :         {
      96           0 :             aPath = pGalleryItem->GetURL();
      97           0 :             aFilter = pGalleryItem->GetFilterName();
      98             :         }
      99             : 
     100           0 :         PasteGraphic( aPos, aGraphic, aPath, aFilter );
     101             :     }
     102           0 :     else if ( nType == com::sun::star::gallery::GalleryItemType::MEDIA )
     103             :     {
     104             :         //  for sounds (linked or not), insert a hyperlink button,
     105             :         //  like in Impress and Writer
     106           0 :         const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGalleryItem->GetURL() );
     107           0 :         GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L );
     108             :     }
     109             : }
     110             : 
     111           0 : void ScTabViewShell::GetGalleryState( SfxItemSet& /* rSet */ )
     112             : {
     113           0 : }
     114             : 
     115             : //------------------------------------------------------------------
     116             : 
     117       14646 : ScInputHandler* ScTabViewShell::GetInputHandler() const
     118             : {
     119       14646 :     return pInputHandler;
     120             : }
     121             : 
     122             : //------------------------------------------------------------------
     123             : 
     124           0 : String ScTabViewShell::GetDescription() const
     125             : {
     126           0 :     return OUString(" ** Test ** ");
     127             : }
     128             : 
     129           0 : void ScTabViewShell::ExecImageMap( SfxRequest& rReq )
     130             : {
     131           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     132           0 :     switch(nSlot)
     133             :     {
     134             :         case SID_IMAP:
     135             :         {
     136           0 :             SfxViewFrame* pThisFrame = GetViewFrame();
     137           0 :             sal_uInt16 nId = ScIMapChildWindowId();
     138           0 :             pThisFrame->ToggleChildWindow( nId );
     139           0 :             GetViewFrame()->GetBindings().Invalidate( SID_IMAP );
     140             : 
     141           0 :             if ( pThisFrame->HasChildWindow( nId ) )
     142             :             {
     143           0 :                 SvxIMapDlg* pDlg = ScGetIMapDlg();
     144           0 :                 if ( pDlg )
     145             :                 {
     146           0 :                     SdrView* pDrView = GetSdrView();
     147           0 :                     if ( pDrView )
     148             :                     {
     149           0 :                         const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
     150           0 :                         if ( rMarkList.GetMarkCount() == 1 )
     151           0 :                             UpdateIMap( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
     152             :                     }
     153             :                 }
     154             :             }
     155             : 
     156           0 :             rReq.Ignore();
     157             :         }
     158           0 :         break;
     159             : 
     160             :         case SID_IMAP_EXEC:
     161             :         {
     162           0 :             SdrView* pDrView = GetSdrView();
     163           0 :             SdrMark* pMark = pDrView ? pDrView->GetMarkedObjectList().GetMark(0) : 0;
     164             : 
     165           0 :             if ( pMark )
     166             :             {
     167           0 :                 SdrObject*  pSdrObj = pMark->GetMarkedSdrObj();
     168           0 :                 SvxIMapDlg* pDlg = ScGetIMapDlg();
     169             : 
     170           0 :                 if ( ScIMapDlgGetObj(pDlg) == (void*) pSdrObj )
     171             :                 {
     172           0 :                     const ImageMap& rImageMap = ScIMapDlgGetMap(pDlg);
     173           0 :                     ScIMapInfo*     pIMapInfo = ScDrawLayer::GetIMapInfo( pSdrObj );
     174             : 
     175           0 :                     if ( !pIMapInfo )
     176           0 :                         pSdrObj->AppendUserData( new ScIMapInfo( rImageMap ) );
     177             :                     else
     178           0 :                         pIMapInfo->SetImageMap( rImageMap );
     179             : 
     180           0 :                     GetViewData()->GetDocShell()->SetDrawModified();
     181             :                 }
     182             :             }
     183             :         }
     184           0 :         break;
     185             :     }
     186           0 : }
     187             : 
     188           0 : void ScTabViewShell::GetImageMapState( SfxItemSet& rSet )
     189             : {
     190           0 :     SfxWhichIter aIter(rSet);
     191           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     192           0 :     while ( nWhich )
     193             :     {
     194           0 :         switch ( nWhich )
     195             :         {
     196             :             case SID_IMAP:
     197             :                 {
     198             :                     //  Disabled wird nicht mehr...
     199             : 
     200           0 :                     sal_Bool bThere = false;
     201           0 :                     SfxViewFrame* pThisFrame = GetViewFrame();
     202           0 :                     sal_uInt16 nId = ScIMapChildWindowId();
     203           0 :                     if ( pThisFrame->KnowsChildWindow(nId) )
     204           0 :                         if ( pThisFrame->HasChildWindow(nId) )
     205           0 :                             bThere = sal_True;
     206             : 
     207           0 :                     ObjectSelectionType eType=GetCurObjectSelectionType();
     208           0 :                     sal_Bool bEnable=(eType==OST_OleObject) ||(eType==OST_Graphic);
     209           0 :                     if(!bThere && !bEnable)
     210             :                     {
     211           0 :                        rSet.DisableItem( nWhich );
     212             :                     }
     213             :                     else
     214             :                     {
     215           0 :                         rSet.Put( SfxBoolItem( nWhich, bThere ) );
     216             :                     }
     217             :                 }
     218           0 :                 break;
     219             : 
     220             :             case SID_IMAP_EXEC:
     221             :                 {
     222           0 :                     sal_Bool bDisable = sal_True;
     223             : 
     224           0 :                     SdrView* pDrView = GetSdrView();
     225           0 :                     if ( pDrView )
     226             :                     {
     227           0 :                         const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
     228           0 :                         if ( rMarkList.GetMarkCount() == 1 )
     229           0 :                             if ( ScIMapDlgGetObj(ScGetIMapDlg()) ==
     230           0 :                                         (void*) rMarkList.GetMark(0)->GetMarkedSdrObj() )
     231           0 :                                 bDisable = false;
     232             :                     }
     233             : 
     234           0 :                     rSet.Put( SfxBoolItem( SID_IMAP_EXEC, bDisable ) );
     235             :                 }
     236           0 :                 break;
     237             :         }
     238             : 
     239           0 :         nWhich = aIter.NextWhich();
     240           0 :     }
     241          93 : }
     242             : 
     243             : 
     244             : 
     245             : 
     246             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10