merge the formfield patch from ooo-build
[ooovba.git] / sc / source / ui / drawfunc / graphsh.cxx
blobce1218220878467c6bdd3b7c6bd94aa91d467ec2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: graphsh.cxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 //------------------------------------------------------------------
38 #include <sfx2/app.hxx>
39 #include <sfx2/objface.hxx>
40 #include <sfx2/request.hxx>
41 #include <svtools/whiter.hxx>
42 #include <svx/svdograf.hxx>
43 #include <svx/grfflt.hxx>
44 #include <svx/grafctrl.hxx>
46 #include "graphsh.hxx"
47 #include "sc.hrc"
48 #include "viewdata.hxx"
49 #include "drawview.hxx"
50 #include "scresid.hxx"
52 #define ScGraphicShell
53 #include "scslots.hxx"
55 #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
58 SFX_IMPL_INTERFACE(ScGraphicShell, ScDrawShell, ScResId(SCSTR_GRAPHICSHELL) )
60 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
61 ScResId(RID_GRAPHIC_OBJECTBAR) );
62 SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_GRAPHIC) );
65 TYPEINIT1( ScGraphicShell, ScDrawShell );
67 ScGraphicShell::ScGraphicShell(ScViewData* pData) :
68 ScDrawShell(pData)
70 SetHelpId(HID_SCSHELL_GRAPHIC);
71 SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("GraphicObject")));
74 ScGraphicShell::~ScGraphicShell()
78 void ScGraphicShell::GetAttrState( SfxItemSet& rSet )
80 ScDrawView* pView = GetViewData()->GetScDrawView();
82 if( pView )
83 SvxGrafAttrHelper::GetGrafAttrState( rSet, *pView );
86 void ScGraphicShell::Execute( SfxRequest& rReq )
88 ScDrawView* pView = GetViewData()->GetScDrawView();
90 if( pView )
92 SvxGrafAttrHelper::ExecuteGrafAttr( rReq, *pView );
93 Invalidate();
97 void ScGraphicShell::GetFilterState( SfxItemSet& rSet )
99 ScDrawView* pView = GetViewData()->GetScDrawView();
100 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
101 BOOL bEnable = FALSE;
103 if( rMarkList.GetMarkCount() == 1 )
105 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
107 if( pObj && pObj->ISA( SdrGrafObj ) && ( ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) )
108 bEnable = TRUE;
111 if( !bEnable )
112 SvxGraphicFilter::DisableGraphicFilterSlots( rSet );
115 void ScGraphicShell::ExecuteFilter( SfxRequest& rReq )
117 ScDrawView* pView = GetViewData()->GetScDrawView();
118 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
120 if( rMarkList.GetMarkCount() == 1 )
122 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
124 if( pObj && pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP )
126 GraphicObject aFilterObj( ( (SdrGrafObj*) pObj )->GetGraphicObject() );
128 if( SVX_GRAPHICFILTER_ERRCODE_NONE ==
129 SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ) )
131 SdrPageView* pPageView = pView->GetSdrPageView();
133 if( pPageView )
135 SdrGrafObj* pFilteredObj = (SdrGrafObj*) pObj->Clone();
136 String aStr( pView->GetDescriptionOfMarkedObjects() );
138 aStr.Append( sal_Unicode(' ') );
139 aStr.Append( String( ScResId( SCSTR_UNDO_GRAFFILTER ) ) );
140 pView->BegUndo( aStr );
141 pFilteredObj->SetGraphicObject( aFilterObj );
142 pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj );
143 pView->EndUndo();
149 Invalidate();