Update ooo320-m1
[ooovba.git] / sd / source / ui / view / GraphicObjectBar.cxx
blob49a9f36401238dc4b8a5419f23af27695cdafe91
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: GraphicObjectBar.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_sd.hxx"
34 #include "GraphicObjectBar.hxx"
36 #include <limits.h>
37 #include <vcl/msgbox.hxx>
38 #include <svtools/whiter.hxx>
39 #include <svtools/itempool.hxx>
40 #include <sfx2/app.hxx>
41 #include <sfx2/shell.hxx>
42 #include <svx/svxids.hrc>
43 #include <sfx2/request.hxx>
44 #include <sfx2/basedlgs.hxx>
45 #include <svx/svdograf.hxx>
46 #include <svx/grfflt.hxx>
47 #include <svtools/aeitem.hxx>
48 #include <svx/grafctrl.hxx>
51 #include <sfx2/objface.hxx>
53 #include "app.hrc"
54 #include "res_bmp.hrc"
55 #include "glob.hrc"
56 #include "strings.hrc"
57 #include "DrawDocShell.hxx"
58 #include "ViewShell.hxx"
59 #include "Window.hxx"
60 #include "drawview.hxx"
61 #include "sdresid.hxx"
62 #include "drawdoc.hxx"
64 using namespace sd;
65 #define GraphicObjectBar
66 #include "sdslots.hxx"
68 namespace sd {
72 // -----------------------
73 // - GraphicObjectBar -
74 // -----------------------
76 SFX_IMPL_INTERFACE( GraphicObjectBar, SfxShell, SdResId( STR_GRAFOBJECTBARSHELL ) )
80 // -----------------------------------------------------------------------------
82 TYPEINIT1( GraphicObjectBar, SfxShell );
84 // -----------------------------------------------------------------------------
86 GraphicObjectBar::GraphicObjectBar (
87 ViewShell* pSdViewShell,
88 ::sd::View* pSdView )
89 : SfxShell (pSdViewShell->GetViewShell()),
90 mpView ( pSdView ),
91 mpViewSh ( pSdViewShell ),
92 nMappedSlotFilter ( SID_GRFFILTER_INVERT )
94 DrawDocShell* pDocShell = mpViewSh->GetDocSh();
96 SetPool( &pDocShell->GetPool() );
97 SetUndoManager( pDocShell->GetUndoManager() );
98 SetRepeatTarget( mpView );
99 SetHelpId( SD_IF_SDDRAWGRAFOBJECTBAR );
100 SetName( String( RTL_CONSTASCII_USTRINGPARAM( "Graphic objectbar" )));
103 // -----------------------------------------------------------------------------
105 GraphicObjectBar::~GraphicObjectBar()
107 SetRepeatTarget( NULL );
110 // -----------------------------------------------------------------------------
112 void GraphicObjectBar::GetAttrState( SfxItemSet& rSet )
114 if( mpView )
115 SvxGrafAttrHelper::GetGrafAttrState( rSet, *mpView );
118 // -----------------------------------------------------------------------------
120 void GraphicObjectBar::Execute( SfxRequest& rReq )
122 if( mpView )
124 SvxGrafAttrHelper::ExecuteGrafAttr( rReq, *mpView );
125 Invalidate();
129 // -----------------------------------------------------------------------------
131 void GraphicObjectBar::GetFilterState( SfxItemSet& rSet )
133 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
134 BOOL bEnable = FALSE;
136 if( rMarkList.GetMarkCount() == 1 )
138 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
140 if( pObj && pObj->ISA( SdrGrafObj ) && ( ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) )
141 bEnable = TRUE;
144 if( !bEnable )
145 SvxGraphicFilter::DisableGraphicFilterSlots( rSet );
148 // -----------------------------------------------------------------------------
150 void GraphicObjectBar::ExecuteFilter( SfxRequest& rReq )
152 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
154 if( rMarkList.GetMarkCount() == 1 )
156 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
158 if( pObj && pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP )
160 GraphicObject aFilterObj( ( (SdrGrafObj*) pObj )->GetGraphicObject() );
162 if( SVX_GRAPHICFILTER_ERRCODE_NONE ==
163 SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ) )
165 SdrPageView* pPageView = mpView->GetSdrPageView();
167 if( pPageView )
169 SdrGrafObj* pFilteredObj = (SdrGrafObj*) pObj->Clone();
170 String aStr( mpView->GetDescriptionOfMarkedObjects() );
172 aStr.Append( sal_Unicode(' ') );
173 aStr.Append( String( SdResId( STR_UNDO_GRAFFILTER ) ) );
174 mpView->BegUndo( aStr );
175 pFilteredObj->SetGraphicObject( aFilterObj );
176 ::sd::View* const pView = mpView;
177 pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj );
178 pView->EndUndo();
179 return;
185 Invalidate();
188 } // end of namespace sd