LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/view - tabvwsh9.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 103 1.0 %
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 <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             : // forwards -> galwrap.cxx (wg. CLOOKs)
      39             : 
      40             : sal_uInt16  GallerySGA_FORMAT_GRAPHIC();
      41             : Graphic GalleryGetGraphic       ();
      42             : sal_Bool    GalleryIsLinkage        ();
      43             : String  GalleryGetFullPath      ();
      44             : String  GalleryGetFilterName    ();
      45             : 
      46             : // forwards -> imapwrap.cxx (wg. CLOOKs)
      47             : 
      48             : class SvxIMapDlg;
      49             : 
      50             : sal_uInt16          ScIMapChildWindowId();
      51             : SvxIMapDlg*     ScGetIMapDlg();
      52             : const void*     ScIMapDlgGetObj( SvxIMapDlg* pDlg );
      53             : const ImageMap& ScIMapDlgGetMap( SvxIMapDlg* pDlg );
      54             : 
      55             : //------------------------------------------------------------------
      56             : 
      57           0 : void ScTabViewShell::ExecChildWin(SfxRequest& rReq)
      58             : {
      59           0 :     sal_uInt16 nSlot = rReq.GetSlot();
      60           0 :     switch(nSlot)
      61             :     {
      62             :         case SID_GALLERY:
      63             :         {
      64           0 :             SfxViewFrame* pThisFrame = GetViewFrame();
      65           0 :             pThisFrame->ToggleChildWindow( GalleryChildWindow::GetChildWindowId() );
      66           0 :             pThisFrame->GetBindings().Invalidate( SID_GALLERY );
      67           0 :             rReq.Ignore();
      68             :         }
      69           0 :         break;
      70             :     }
      71           0 : }
      72             : 
      73           0 : void ScTabViewShell::GetChildWinState( SfxItemSet& rSet )
      74             : {
      75           0 :     if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GALLERY ) )
      76             :     {
      77           0 :         sal_uInt16 nId = GalleryChildWindow::GetChildWindowId();
      78           0 :         rSet.Put( SfxBoolItem( SID_GALLERY, GetViewFrame()->HasChildWindow( nId ) ) );
      79             :     }
      80           0 : }
      81             : 
      82             : //------------------------------------------------------------------
      83             : 
      84           0 : void ScTabViewShell::ExecGallery( SfxRequest& rReq )
      85             : {
      86           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
      87             : 
      88           0 :     if ( pArgs )
      89             :     {
      90           0 :         const SfxPoolItem* pItem = NULL;
      91           0 :         SfxItemState eState = pArgs->GetItemState(SID_GALLERY_FORMATS, sal_True, &pItem);
      92           0 :         if ( eState == SFX_ITEM_SET )
      93             :         {
      94           0 :             sal_uInt32 nFormats = ((const SfxUInt32Item*)pItem)->GetValue();
      95             : 
      96             :             /******************************************************************
      97             :             * Graphik einfuegen
      98             :             ******************************************************************/
      99           0 :             if ( nFormats & GallerySGA_FORMAT_GRAPHIC() )
     100             :             {
     101           0 :                 MakeDrawLayer();
     102             : 
     103           0 :                 Graphic aGraphic = GalleryGetGraphic();
     104           0 :                 Point   aPos     = GetInsertPos();
     105             : 
     106           0 :                 String aPath, aFilter;
     107           0 :                 if ( GalleryIsLinkage() )           // als Link einfuegen?
     108             :                 {
     109           0 :                     aPath = GalleryGetFullPath();
     110           0 :                     aFilter = GalleryGetFilterName();
     111             :                 }
     112             : 
     113           0 :                 PasteGraphic( aPos, aGraphic, aPath, aFilter );
     114             :             }
     115           0 :             else if ( nFormats & SGA_FORMAT_SOUND )
     116             :             {
     117             :                 //  for sounds (linked or not), insert a hyperlink button,
     118             :                 //  like in Impress and Writer
     119             : 
     120           0 :                 GalleryExplorer* pGal = SVX_GALLERY();
     121           0 :                 if ( pGal )
     122             :                 {
     123           0 :                     const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGal->GetURL().GetMainURL( INetURLObject::NO_DECODE ) );
     124           0 :                        GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L );
     125             :                 }
     126             :             }
     127             :         }
     128             :     }
     129           0 : }
     130             : 
     131           0 : void ScTabViewShell::GetGalleryState( SfxItemSet& /* rSet */ )
     132             : {
     133           0 : }
     134             : 
     135             : //------------------------------------------------------------------
     136             : 
     137           0 : ScInputHandler* ScTabViewShell::GetInputHandler() const
     138             : {
     139           0 :     return pInputHandler;
     140             : }
     141             : 
     142             : //------------------------------------------------------------------
     143             : 
     144           0 : String ScTabViewShell::GetDescription() const
     145             : {
     146           0 :     return rtl::OUString(" ** Test ** ");
     147             : }
     148             : 
     149           0 : void ScTabViewShell::ExecImageMap( SfxRequest& rReq )
     150             : {
     151           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     152           0 :     switch(nSlot)
     153             :     {
     154             :         case SID_IMAP:
     155             :         {
     156           0 :             SfxViewFrame* pThisFrame = GetViewFrame();
     157           0 :             sal_uInt16 nId = ScIMapChildWindowId();
     158           0 :             pThisFrame->ToggleChildWindow( nId );
     159           0 :             GetViewFrame()->GetBindings().Invalidate( SID_IMAP );
     160             : 
     161           0 :             if ( pThisFrame->HasChildWindow( nId ) )
     162             :             {
     163           0 :                 SvxIMapDlg* pDlg = ScGetIMapDlg();
     164           0 :                 if ( pDlg )
     165             :                 {
     166           0 :                     SdrView* pDrView = GetSdrView();
     167           0 :                     if ( pDrView )
     168             :                     {
     169           0 :                         const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
     170           0 :                         if ( rMarkList.GetMarkCount() == 1 )
     171           0 :                             UpdateIMap( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
     172             :                     }
     173             :                 }
     174             :             }
     175             : 
     176           0 :             rReq.Ignore();
     177             :         }
     178           0 :         break;
     179             : 
     180             :         case SID_IMAP_EXEC:
     181             :         {
     182           0 :             SdrView* pDrView = GetSdrView();
     183           0 :             SdrMark* pMark = pDrView ? pDrView->GetMarkedObjectList().GetMark(0) : 0;
     184             : 
     185           0 :             if ( pMark )
     186             :             {
     187           0 :                 SdrObject*  pSdrObj = pMark->GetMarkedSdrObj();
     188           0 :                 SvxIMapDlg* pDlg = ScGetIMapDlg();
     189             : 
     190           0 :                 if ( ScIMapDlgGetObj(pDlg) == (void*) pSdrObj )
     191             :                 {
     192           0 :                     const ImageMap& rImageMap = ScIMapDlgGetMap(pDlg);
     193           0 :                     ScIMapInfo*     pIMapInfo = ScDrawLayer::GetIMapInfo( pSdrObj );
     194             : 
     195           0 :                     if ( !pIMapInfo )
     196           0 :                         pSdrObj->AppendUserData( new ScIMapInfo( rImageMap ) );
     197             :                     else
     198           0 :                         pIMapInfo->SetImageMap( rImageMap );
     199             : 
     200           0 :                     GetViewData()->GetDocShell()->SetDrawModified();
     201             :                 }
     202             :             }
     203             :         }
     204           0 :         break;
     205             :     }
     206           0 : }
     207             : 
     208           0 : void ScTabViewShell::GetImageMapState( SfxItemSet& rSet )
     209             : {
     210           0 :     SfxWhichIter aIter(rSet);
     211           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     212           0 :     while ( nWhich )
     213             :     {
     214           0 :         switch ( nWhich )
     215             :         {
     216             :             case SID_IMAP:
     217             :                 {
     218             :                     //  Disabled wird nicht mehr...
     219             : 
     220           0 :                     sal_Bool bThere = false;
     221           0 :                     SfxViewFrame* pThisFrame = GetViewFrame();
     222           0 :                     sal_uInt16 nId = ScIMapChildWindowId();
     223           0 :                     if ( pThisFrame->KnowsChildWindow(nId) )
     224           0 :                         if ( pThisFrame->HasChildWindow(nId) )
     225           0 :                             bThere = sal_True;
     226             : 
     227           0 :                     ObjectSelectionType eType=GetCurObjectSelectionType();
     228           0 :                     sal_Bool bEnable=(eType==OST_OleObject) ||(eType==OST_Graphic);
     229           0 :                     if(!bThere && !bEnable)
     230             :                     {
     231           0 :                        rSet.DisableItem( nWhich );
     232             :                     }
     233             :                     else
     234             :                     {
     235           0 :                         rSet.Put( SfxBoolItem( nWhich, bThere ) );
     236             :                     }
     237             :                 }
     238           0 :                 break;
     239             : 
     240             :             case SID_IMAP_EXEC:
     241             :                 {
     242           0 :                     sal_Bool bDisable = sal_True;
     243             : 
     244           0 :                     SdrView* pDrView = GetSdrView();
     245           0 :                     if ( pDrView )
     246             :                     {
     247           0 :                         const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
     248           0 :                         if ( rMarkList.GetMarkCount() == 1 )
     249           0 :                             if ( ScIMapDlgGetObj(ScGetIMapDlg()) ==
     250           0 :                                         (void*) rMarkList.GetMark(0)->GetMarkedSdrObj() )
     251           0 :                                 bDisable = false;
     252             :                     }
     253             : 
     254           0 :                     rSet.Put( SfxBoolItem( SID_IMAP_EXEC, bDisable ) );
     255             :                 }
     256           0 :                 break;
     257             :         }
     258             : 
     259           0 :         nWhich = aIter.NextWhich();
     260           0 :     }
     261          15 : }
     262             : 
     263             : 
     264             : 
     265             : 
     266             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10