1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: GraphicObjectBar.cxx,v $
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"
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>
54 #include "res_bmp.hrc"
56 #include "strings.hrc"
57 #include "DrawDocShell.hxx"
58 #include "ViewShell.hxx"
60 #include "drawview.hxx"
61 #include "sdresid.hxx"
62 #include "drawdoc.hxx"
65 #define GraphicObjectBar
66 #include "sdslots.hxx"
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
,
89 : SfxShell (pSdViewShell
->GetViewShell()),
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
)
115 SvxGrafAttrHelper::GetGrafAttrState( rSet
, *mpView
);
118 // -----------------------------------------------------------------------------
120 void GraphicObjectBar::Execute( SfxRequest
& rReq
)
124 SvxGrafAttrHelper::ExecuteGrafAttr( rReq
, *mpView
);
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
) )
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();
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
);
188 } // end of namespace sd