1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sc.hxx" 30 31 32 33 //------------------------------------------------------------------ 34 35 #include <sfx2/app.hxx> 36 #include <sfx2/objface.hxx> 37 #include <sfx2/request.hxx> 38 #include <svl/whiter.hxx> 39 #include <svx/svdograf.hxx> 40 #include <svx/grfflt.hxx> 41 #include <svx/grafctrl.hxx> 42 43 #include "graphsh.hxx" 44 #include "sc.hrc" 45 #include "viewdata.hxx" 46 #include "drawview.hxx" 47 #include "scresid.hxx" 48 49 #define ScGraphicShell 50 #include "scslots.hxx" 51 52 #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue() 53 54 55 SFX_IMPL_INTERFACE(ScGraphicShell, ScDrawShell, ScResId(SCSTR_GRAPHICSHELL) ) 56 { 57 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER, 58 ScResId(RID_GRAPHIC_OBJECTBAR) ); 59 SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_GRAPHIC) ); 60 } 61 62 TYPEINIT1( ScGraphicShell, ScDrawShell ); 63 64 ScGraphicShell::ScGraphicShell(ScViewData* pData) : 65 ScDrawShell(pData) 66 { 67 SetHelpId(HID_SCSHELL_GRAPHIC); 68 SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("GraphicObject"))); 69 } 70 71 ScGraphicShell::~ScGraphicShell() 72 { 73 } 74 75 void ScGraphicShell::GetAttrState( SfxItemSet& rSet ) 76 { 77 ScDrawView* pView = GetViewData()->GetScDrawView(); 78 79 if( pView ) 80 SvxGrafAttrHelper::GetGrafAttrState( rSet, *pView ); 81 } 82 83 void ScGraphicShell::Execute( SfxRequest& rReq ) 84 { 85 ScDrawView* pView = GetViewData()->GetScDrawView(); 86 87 if( pView ) 88 { 89 SvxGrafAttrHelper::ExecuteGrafAttr( rReq, *pView ); 90 Invalidate(); 91 } 92 } 93 94 void ScGraphicShell::GetFilterState( SfxItemSet& rSet ) 95 { 96 ScDrawView* pView = GetViewData()->GetScDrawView(); 97 const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); 98 sal_Bool bEnable = sal_False; 99 100 if( rMarkList.GetMarkCount() == 1 ) 101 { 102 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); 103 104 if( pObj && pObj->ISA( SdrGrafObj ) && ( ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) ) 105 bEnable = sal_True; 106 } 107 108 if( !bEnable ) 109 SvxGraphicFilter::DisableGraphicFilterSlots( rSet ); 110 } 111 112 void ScGraphicShell::ExecuteFilter( SfxRequest& rReq ) 113 { 114 ScDrawView* pView = GetViewData()->GetScDrawView(); 115 const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); 116 117 if( rMarkList.GetMarkCount() == 1 ) 118 { 119 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); 120 121 if( pObj && pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) 122 { 123 GraphicObject aFilterObj( ( (SdrGrafObj*) pObj )->GetGraphicObject() ); 124 125 if( SVX_GRAPHICFILTER_ERRCODE_NONE == 126 SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ) ) 127 { 128 SdrPageView* pPageView = pView->GetSdrPageView(); 129 130 if( pPageView ) 131 { 132 SdrGrafObj* pFilteredObj = (SdrGrafObj*) pObj->Clone(); 133 String aStr( pView->GetDescriptionOfMarkedObjects() ); 134 135 aStr.Append( sal_Unicode(' ') ); 136 aStr.Append( String( ScResId( SCSTR_UNDO_GRAFFILTER ) ) ); 137 pView->BegUndo( aStr ); 138 pFilteredObj->SetGraphicObject( aFilterObj ); 139 pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj ); 140 pView->EndUndo(); 141 } 142 } 143 } 144 } 145 146 Invalidate(); 147 } 148 149