LCOV - code coverage report
Current view: top level - sd/source/ui/view - GraphicObjectBar.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 56 3.6 %
Date: 2012-08-25 Functions: 3 16 18.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 96 3.1 %

           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                 :            : 
      30                 :            : #include "GraphicObjectBar.hxx"
      31                 :            : 
      32                 :            : #include <limits.h>
      33                 :            : #include <vcl/msgbox.hxx>
      34                 :            : #include <svl/whiter.hxx>
      35                 :            : #include <svl/itempool.hxx>
      36                 :            : #include <sfx2/app.hxx>
      37                 :            : #include <sfx2/shell.hxx>
      38                 :            : #include <svx/svxids.hrc>
      39                 :            : #include <sfx2/request.hxx>
      40                 :            : #include <sfx2/basedlgs.hxx>
      41                 :            : #include <svx/svdograf.hxx>
      42                 :            : #include <svx/grfflt.hxx>
      43                 :            : #include <svl/aeitem.hxx>
      44                 :            : #include <svx/grafctrl.hxx>
      45                 :            : 
      46                 :            : 
      47                 :            : #include <sfx2/objface.hxx>
      48                 :            : 
      49                 :            : #include "app.hrc"
      50                 :            : #include "res_bmp.hrc"
      51                 :            : #include "glob.hrc"
      52                 :            : #include "strings.hrc"
      53                 :            : #include "DrawDocShell.hxx"
      54                 :            : #include "ViewShell.hxx"
      55                 :            : #include "Window.hxx"
      56                 :            : #include "drawview.hxx"
      57                 :            : #include "sdresid.hxx"
      58                 :            : #include "drawdoc.hxx"
      59                 :            : 
      60                 :            : using namespace sd;
      61                 :            : #define GraphicObjectBar
      62                 :            : #include "sdslots.hxx"
      63                 :            : 
      64                 :            : namespace sd {
      65                 :            : 
      66                 :            : 
      67                 :            : 
      68                 :            : // -----------------------
      69                 :            : // - GraphicObjectBar -
      70                 :            : // -----------------------
      71                 :            : 
      72 [ +  - ][ +  - ]:         50 : SFX_IMPL_INTERFACE( GraphicObjectBar, SfxShell, SdResId( STR_GRAFOBJECTBARSHELL ) )
                 [ +  - ]
      73                 :            : {
      74                 :         25 : }
      75                 :            : 
      76                 :            : // -----------------------------------------------------------------------------
      77                 :            : 
      78 [ #  # ][ #  # ]:          0 : TYPEINIT1( GraphicObjectBar, SfxShell );
      79                 :            : 
      80                 :            : // -----------------------------------------------------------------------------
      81                 :            : 
      82                 :          0 : GraphicObjectBar::GraphicObjectBar (
      83                 :            :     ViewShell* pSdViewShell,
      84                 :            :     ::sd::View* pSdView )
      85                 :            :     : SfxShell (pSdViewShell->GetViewShell()),
      86                 :            :       mpView     ( pSdView ),
      87                 :            :       mpViewSh ( pSdViewShell ),
      88                 :          0 :       nMappedSlotFilter ( SID_GRFFILTER_INVERT )
      89                 :            : {
      90         [ #  # ]:          0 :     DrawDocShell* pDocShell = mpViewSh->GetDocSh();
      91                 :            : 
      92                 :          0 :     SetPool( &pDocShell->GetPool() );
      93 [ #  # ][ #  # ]:          0 :     SetUndoManager( pDocShell->GetUndoManager() );
      94 [ #  # ][ #  # ]:          0 :     SetRepeatTarget( mpView );
      95         [ #  # ]:          0 :     SetHelpId( SD_IF_SDDRAWGRAFOBJECTBAR );
      96 [ #  # ][ #  # ]:          0 :     SetName( rtl::OUString( "Graphic objectbar" ));
                 [ #  # ]
      97                 :          0 : }
      98                 :            : 
      99                 :            : // -----------------------------------------------------------------------------
     100                 :            : 
     101                 :          0 : GraphicObjectBar::~GraphicObjectBar()
     102                 :            : {
     103         [ #  # ]:          0 :     SetRepeatTarget( NULL );
     104         [ #  # ]:          0 : }
     105                 :            : 
     106                 :            : // -----------------------------------------------------------------------------
     107                 :            : 
     108                 :          0 : void GraphicObjectBar::GetAttrState( SfxItemSet& rSet )
     109                 :            : {
     110         [ #  # ]:          0 :     if( mpView )
     111                 :          0 :         SvxGrafAttrHelper::GetGrafAttrState( rSet, *mpView );
     112                 :          0 : }
     113                 :            : 
     114                 :            : // -----------------------------------------------------------------------------
     115                 :            : 
     116                 :          0 : void GraphicObjectBar::Execute( SfxRequest& rReq )
     117                 :            : {
     118         [ #  # ]:          0 :     if( mpView )
     119                 :            :     {
     120                 :          0 :         SvxGrafAttrHelper::ExecuteGrafAttr( rReq, *mpView );
     121                 :          0 :         Invalidate();
     122                 :            :     }
     123                 :          0 : }
     124                 :            : 
     125                 :            : // -----------------------------------------------------------------------------
     126                 :            : 
     127                 :          0 : void GraphicObjectBar::GetFilterState( SfxItemSet& rSet )
     128                 :            : {
     129                 :          0 :     const SdrMarkList&  rMarkList = mpView->GetMarkedObjectList();
     130                 :          0 :     sal_Bool                bEnable = sal_False;
     131                 :            : 
     132         [ #  # ]:          0 :     if( rMarkList.GetMarkCount() == 1 )
     133                 :            :     {
     134                 :          0 :         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
     135                 :            : 
     136 [ #  # ][ #  # ]:          0 :         if( pObj && pObj->ISA( SdrGrafObj ) && ( ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) )
         [ #  # ][ #  # ]
     137                 :          0 :             bEnable = sal_True;
     138                 :            :     }
     139                 :            : 
     140         [ #  # ]:          0 :     if( !bEnable )
     141                 :          0 :         SvxGraphicFilter::DisableGraphicFilterSlots( rSet );
     142                 :          0 : }
     143                 :            : 
     144                 :            : // -----------------------------------------------------------------------------
     145                 :            : 
     146                 :          0 : void GraphicObjectBar::ExecuteFilter( SfxRequest& rReq )
     147                 :            : {
     148                 :          0 :     const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
     149                 :            : 
     150         [ #  # ]:          0 :     if( rMarkList.GetMarkCount() == 1 )
     151                 :            :     {
     152                 :          0 :         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
     153                 :            : 
     154 [ #  # ][ #  # ]:          0 :         if( pObj && pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP )
         [ #  # ][ #  # ]
     155                 :            :         {
     156 [ #  # ][ #  # ]:          0 :             GraphicObject aFilterObj( ( (SdrGrafObj*) pObj )->GetGraphicObject() );
     157                 :            : 
     158         [ #  # ]:          0 :             if( SVX_GRAPHICFILTER_ERRCODE_NONE ==
     159         [ #  # ]:          0 :                 SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ) )
     160                 :            :             {
     161                 :          0 :                 SdrPageView* pPageView = mpView->GetSdrPageView();
     162                 :            : 
     163         [ #  # ]:          0 :                 if( pPageView )
     164                 :            :                 {
     165         [ #  # ]:          0 :                     SdrGrafObj* pFilteredObj = (SdrGrafObj*) pObj->Clone();
     166         [ #  # ]:          0 :                     String      aStr( mpView->GetDescriptionOfMarkedObjects() );
     167                 :            : 
     168         [ #  # ]:          0 :                     aStr.Append( sal_Unicode(' ') );
     169 [ #  # ][ #  # ]:          0 :                     aStr.Append( String( SdResId( STR_UNDO_GRAFFILTER ) ) );
         [ #  # ][ #  # ]
     170         [ #  # ]:          0 :                     mpView->BegUndo( aStr );
     171         [ #  # ]:          0 :                     pFilteredObj->SetGraphicObject( aFilterObj );
     172                 :          0 :                     ::sd::View* const pView = mpView;
     173         [ #  # ]:          0 :                     pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj );
     174         [ #  # ]:          0 :                     pView->EndUndo();
     175         [ #  # ]:          0 :                     return;
     176                 :            :                 }
     177 [ #  # ][ #  # ]:          0 :             }
     178                 :            :         }
     179                 :            :     }
     180                 :            : 
     181                 :          0 :     Invalidate();
     182                 :            : }
     183                 :            : 
     184                 :            : } // end of namespace sd
     185                 :            : 
     186                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10