LCOV - code coverage report
Current view: top level - sd/source/ui/view - GraphicObjectBar.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 4 57 7.0 %
Date: 2015-06-13 12:38:46 Functions: 5 18 27.8 %
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 "GraphicObjectBar.hxx"
      21             : 
      22             : #include <limits.h>
      23             : #include <vcl/msgbox.hxx>
      24             : #include <svl/whiter.hxx>
      25             : #include <svl/itempool.hxx>
      26             : #include <sfx2/app.hxx>
      27             : #include <sfx2/shell.hxx>
      28             : #include <svx/svxids.hrc>
      29             : #include <sfx2/request.hxx>
      30             : #include <sfx2/basedlgs.hxx>
      31             : #include <svx/svdograf.hxx>
      32             : #include <svx/grfflt.hxx>
      33             : #include <svl/aeitem.hxx>
      34             : #include <svx/grafctrl.hxx>
      35             : 
      36             : #include <sfx2/objface.hxx>
      37             : 
      38             : #include "app.hrc"
      39             : #include "res_bmp.hrc"
      40             : #include "glob.hrc"
      41             : #include "strings.hrc"
      42             : #include "DrawDocShell.hxx"
      43             : #include "ViewShell.hxx"
      44             : #include "Window.hxx"
      45             : #include "drawview.hxx"
      46             : #include "sdresid.hxx"
      47             : #include "drawdoc.hxx"
      48             : 
      49             : using namespace sd;
      50             : #define GraphicObjectBar
      51             : #include "sdslots.hxx"
      52             : 
      53             : namespace sd {
      54             : 
      55             : // - GraphicObjectBar -
      56             : 
      57          42 : SFX_IMPL_INTERFACE(GraphicObjectBar, SfxShell)
      58             : 
      59          21 : void GraphicObjectBar::InitInterface_Impl()
      60             : {
      61          21 : }
      62             : 
      63           0 : TYPEINIT1( GraphicObjectBar, SfxShell );
      64             : 
      65           0 : GraphicObjectBar::GraphicObjectBar (
      66             :     ViewShell* pSdViewShell,
      67             :     ::sd::View* pSdView )
      68             :     : SfxShell (pSdViewShell->GetViewShell()),
      69             :       mpView     ( pSdView ),
      70             :       mpViewSh ( pSdViewShell ),
      71           0 :       nMappedSlotFilter ( SID_GRFFILTER_INVERT )
      72             : {
      73           0 :     DrawDocShell* pDocShell = mpViewSh->GetDocSh();
      74             : 
      75           0 :     SetPool( &pDocShell->GetPool() );
      76           0 :     SetUndoManager( pDocShell->GetUndoManager() );
      77           0 :     SetRepeatTarget( mpView );
      78           0 :     SetHelpId( SD_IF_SDDRAWGRAFOBJECTBAR );
      79           0 :     SetName( OUString( "Graphic objectbar" ));
      80           0 : }
      81             : 
      82           0 : GraphicObjectBar::~GraphicObjectBar()
      83             : {
      84           0 :     SetRepeatTarget( NULL );
      85           0 : }
      86             : 
      87           0 : void GraphicObjectBar::GetAttrState( SfxItemSet& rSet )
      88             : {
      89           0 :     if( mpView )
      90           0 :         SvxGrafAttrHelper::GetGrafAttrState( rSet, *mpView );
      91           0 : }
      92             : 
      93           0 : void GraphicObjectBar::Execute( SfxRequest& rReq )
      94             : {
      95           0 :     if( mpView )
      96             :     {
      97           0 :         SvxGrafAttrHelper::ExecuteGrafAttr( rReq, *mpView );
      98           0 :         Invalidate();
      99             :     }
     100           0 : }
     101             : 
     102           0 : void GraphicObjectBar::GetFilterState( SfxItemSet& rSet )
     103             : {
     104           0 :     const SdrMarkList&  rMarkList = mpView->GetMarkedObjectList();
     105           0 :     bool                bEnable = false;
     106             : 
     107           0 :     if( rMarkList.GetMarkCount() == 1 )
     108             :     {
     109           0 :         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
     110             : 
     111           0 :         if( pObj && pObj->ISA( SdrGrafObj ) && ( static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GRAPHIC_BITMAP ) )
     112           0 :             bEnable = true;
     113             :     }
     114             : 
     115           0 :     if( !bEnable )
     116           0 :         SvxGraphicFilter::DisableGraphicFilterSlots( rSet );
     117           0 : }
     118             : 
     119           0 : void GraphicObjectBar::ExecuteFilter( SfxRequest& rReq )
     120             : {
     121           0 :     const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
     122             : 
     123           0 :     if( rMarkList.GetMarkCount() == 1 )
     124             :     {
     125           0 :         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
     126             : 
     127           0 :         if( pObj && pObj->ISA( SdrGrafObj ) && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GRAPHIC_BITMAP )
     128             :         {
     129           0 :             GraphicObject aFilterObj( static_cast<SdrGrafObj*>(pObj)->GetGraphicObject() );
     130             : 
     131           0 :             if( SVX_GRAPHICFILTER_ERRCODE_NONE ==
     132           0 :                 SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ) )
     133             :             {
     134           0 :                 SdrPageView* pPageView = mpView->GetSdrPageView();
     135             : 
     136           0 :                 if( pPageView )
     137             :                 {
     138           0 :                     SdrGrafObj* pFilteredObj = static_cast<SdrGrafObj*>( pObj->Clone() );
     139           0 :                     OUString    aStr = mpView->GetDescriptionOfMarkedObjects();
     140           0 :                     aStr += " " + SD_RESSTR(STR_UNDO_GRAFFILTER);
     141           0 :                     mpView->BegUndo( aStr );
     142           0 :                     pFilteredObj->SetGraphicObject( aFilterObj );
     143           0 :                     ::sd::View* const pView = mpView;
     144           0 :                     pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj );
     145           0 :                     pView->EndUndo();
     146           0 :                     return;
     147             :                 }
     148           0 :             }
     149             :         }
     150             :     }
     151             : 
     152           0 :     Invalidate();
     153             : }
     154             : 
     155          66 : } // end of namespace sd
     156             : 
     157             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11