LCOV - code coverage report
Current view: top level - sc/source/ui/drawfunc - graphsh.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 121 0.0 %
Date: 2014-04-14 Functions: 0 26 0.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 <sfx2/app.hxx>
      21             : #include <sfx2/objface.hxx>
      22             : #include <sfx2/request.hxx>
      23             : #include <sfx2/sidebar/EnumContext.hxx>
      24             : #include <svl/whiter.hxx>
      25             : #include <svx/svdograf.hxx>
      26             : #include <svx/grfflt.hxx>
      27             : #include <svx/grafctrl.hxx>
      28             : #include <svx/compressgraphicdialog.hxx>
      29             : #include <vcl/msgbox.hxx>
      30             : 
      31             : #include "graphsh.hxx"
      32             : #include "sc.hrc"
      33             : #include "viewdata.hxx"
      34             : #include "drawview.hxx"
      35             : #include "scresid.hxx"
      36             : #include <svx/extedit.hxx>
      37             : 
      38             : #define ScGraphicShell
      39             : #include "scslots.hxx"
      40             : 
      41           0 : class ScExternalToolEdit : public ExternalToolEdit
      42             : {
      43             :     FmFormView* m_pView;
      44             :     SdrObject*  m_pObj;
      45             : 
      46             : public:
      47           0 :     ScExternalToolEdit ( FmFormView* pView, SdrObject* pObj ) :
      48             :         m_pView   (pView),
      49           0 :         m_pObj (pObj)
      50           0 :     {}
      51             : 
      52           0 :     virtual void Update( Graphic& aGraphic ) SAL_OVERRIDE
      53             :     {
      54           0 :         SdrPageView* pPageView = m_pView->GetSdrPageView();
      55           0 :         if( pPageView )
      56             :         {
      57           0 :             SdrGrafObj* pNewObj = (SdrGrafObj*) m_pObj->Clone();
      58           0 :             OUString    aStr = m_pView->GetDescriptionOfMarkedObjects() + " External Edit";
      59           0 :             m_pView->BegUndo( aStr );
      60           0 :             pNewObj->SetGraphicObject( aGraphic );
      61           0 :             m_pView->ReplaceObjectAtView( m_pObj, *pPageView, pNewObj );
      62           0 :             m_pView->EndUndo();
      63             :         }
      64           0 :     }
      65             : };
      66             : 
      67           0 : SFX_IMPL_INTERFACE(ScGraphicShell, ScDrawShell, ScResId(SCSTR_GRAPHICSHELL) )
      68             : {
      69           0 :     SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
      70           0 :                                 ScResId(RID_GRAPHIC_OBJECTBAR) );
      71           0 :     SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_GRAPHIC) );
      72           0 : }
      73             : 
      74           0 : TYPEINIT1( ScGraphicShell, ScDrawShell );
      75             : 
      76           0 : ScGraphicShell::ScGraphicShell(ScViewData* pData) :
      77           0 :     ScDrawShell(pData)
      78             : {
      79           0 :     SetHelpId(HID_SCSHELL_GRAPHIC);
      80           0 :     SetName(OUString("GraphicObject"));
      81           0 :         SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Graphic));
      82           0 : }
      83             : 
      84           0 : ScGraphicShell::~ScGraphicShell()
      85             : {
      86           0 : }
      87             : 
      88           0 : void ScGraphicShell::GetAttrState( SfxItemSet& rSet )
      89             : {
      90           0 :     ScDrawView* pView = GetViewData()->GetScDrawView();
      91             : 
      92           0 :     if( pView )
      93           0 :         SvxGrafAttrHelper::GetGrafAttrState( rSet, *pView );
      94           0 : }
      95             : 
      96           0 : void ScGraphicShell::Execute( SfxRequest& rReq )
      97             : {
      98           0 :     ScDrawView* pView = GetViewData()->GetScDrawView();
      99             : 
     100           0 :     if( pView )
     101             :     {
     102           0 :         SvxGrafAttrHelper::ExecuteGrafAttr( rReq, *pView );
     103           0 :         Invalidate();
     104             :     }
     105           0 : }
     106             : 
     107           0 : void ScGraphicShell::GetFilterState( SfxItemSet& rSet )
     108             : {
     109           0 :     ScDrawView* pView = GetViewData()->GetScDrawView();
     110           0 :     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     111           0 :     sal_Bool bEnable = false;
     112             : 
     113           0 :     if( rMarkList.GetMarkCount() == 1 )
     114             :     {
     115           0 :         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
     116             : 
     117           0 :         if( pObj && pObj->ISA( SdrGrafObj ) && ( ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) )
     118           0 :             bEnable = sal_True;
     119             :     }
     120             : 
     121           0 :     if( !bEnable )
     122           0 :         SvxGraphicFilter::DisableGraphicFilterSlots( rSet );
     123           0 : }
     124             : 
     125           0 : void ScGraphicShell::ExecuteFilter( SfxRequest& rReq )
     126             : {
     127           0 :     ScDrawView* pView = GetViewData()->GetScDrawView();
     128           0 :     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     129             : 
     130           0 :     if( rMarkList.GetMarkCount() == 1 )
     131             :     {
     132           0 :         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
     133             : 
     134           0 :         if( pObj && pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP )
     135             :         {
     136           0 :             GraphicObject aFilterObj( ( (SdrGrafObj*) pObj )->GetGraphicObject() );
     137             : 
     138           0 :             if( SVX_GRAPHICFILTER_ERRCODE_NONE ==
     139           0 :                 SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ) )
     140             :             {
     141           0 :                 SdrPageView* pPageView = pView->GetSdrPageView();
     142             : 
     143           0 :                 if( pPageView )
     144             :                 {
     145           0 :                     SdrGrafObj* pFilteredObj = (SdrGrafObj*) pObj->Clone();
     146           0 :                     OUString    aStr = pView->GetDescriptionOfMarkedObjects() + " " + OUString(ScResId( SCSTR_UNDO_GRAFFILTER ));
     147           0 :                     pView->BegUndo( aStr );
     148           0 :                     pFilteredObj->SetGraphicObject( aFilterObj );
     149           0 :                     pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj );
     150           0 :                     pView->EndUndo();
     151             :                 }
     152           0 :             }
     153             :         }
     154             :     }
     155             : 
     156           0 :     Invalidate();
     157           0 : }
     158             : 
     159           0 : void ScGraphicShell::GetExternalEditState( SfxItemSet& rSet )
     160             : {
     161           0 :     ScDrawView* pView = GetViewData()->GetScDrawView();
     162           0 :     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     163           0 :     bool bEnable = false;
     164           0 :     if( rMarkList.GetMarkCount() == 1 )
     165             :     {
     166           0 :         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
     167             : 
     168           0 :         if( pObj && pObj->ISA( SdrGrafObj ) && ( ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) )
     169           0 :             bEnable = true;
     170             :     }
     171             : 
     172           0 :     if( !bEnable )
     173           0 :         rSet.DisableItem( SID_EXTERNAL_EDIT );
     174           0 : }
     175             : 
     176           0 : void ScGraphicShell::ExecuteExternalEdit( SfxRequest& )
     177             : {
     178           0 :     ScDrawView* pView = GetViewData()->GetScDrawView();
     179           0 :     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     180             : 
     181           0 :     if( rMarkList.GetMarkCount() == 1 )
     182             :     {
     183           0 :         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
     184             : 
     185           0 :         if( pObj && pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP )
     186             :         {
     187           0 :             GraphicObject aGraphicObject( ( (SdrGrafObj*) pObj )->GetGraphicObject() );
     188           0 :             ScExternalToolEdit* aExternalToolEdit = new ScExternalToolEdit( pView, pObj );
     189           0 :             aExternalToolEdit->Edit( &aGraphicObject );
     190             :         }
     191             :     }
     192             : 
     193           0 :     Invalidate();
     194           0 : }
     195             : 
     196           0 : void ScGraphicShell::GetCompressGraphicState( SfxItemSet& rSet )
     197             : {
     198           0 :     ScDrawView* pView = GetViewData()->GetScDrawView();
     199           0 :     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     200           0 :     bool bEnable = false;
     201           0 :     if( rMarkList.GetMarkCount() == 1 )
     202             :     {
     203           0 :         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
     204             : 
     205           0 :         if( pObj && pObj->ISA( SdrGrafObj ) && ( ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) )
     206           0 :             bEnable = true;
     207             :     }
     208             : 
     209           0 :     if( !bEnable )
     210           0 :         rSet.DisableItem( SID_COMPRESS_GRAPHIC );
     211           0 : }
     212             : 
     213           0 : void ScGraphicShell::ExecuteCompressGraphic( SfxRequest& )
     214             : {
     215           0 :     ScDrawView* pView = GetViewData()->GetScDrawView();
     216           0 :     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     217             : 
     218           0 :     if( rMarkList.GetMarkCount() == 1 )
     219             :     {
     220           0 :         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
     221             : 
     222           0 :         if( pObj && pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP )
     223             :         {
     224           0 :             SdrGrafObj* pGraphicObj = (SdrGrafObj*) pObj;
     225           0 :             CompressGraphicsDialog dialog( GetViewData()->GetDialogParent(), pGraphicObj, GetViewData()->GetBindings() );
     226           0 :             if ( dialog.Execute() == RET_OK )
     227             :             {
     228           0 :                 SdrGrafObj* pNewObject = dialog.GetCompressedSdrGrafObj();
     229           0 :                 SdrPageView* pPageView = pView->GetSdrPageView();
     230           0 :                 OUString aUndoString = pView->GetDescriptionOfMarkedObjects() + " Compress";
     231           0 :                 pView->BegUndo( aUndoString );
     232           0 :                 pView->ReplaceObjectAtView( pObj, *pPageView, pNewObject );
     233           0 :                 pView->EndUndo();
     234           0 :             }
     235             :         }
     236             :     }
     237             : 
     238           0 :     Invalidate();
     239           0 : }
     240             : 
     241             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10