1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "GraphicObjectBar.hxx"
23 #include <vcl/msgbox.hxx>
24 #include <svl/whiter.hxx>
25 #include <svl/itempool.hxx>
26 #include <sfx2/app.hxx>
27 #include <sfx2/shell.hxx>
28 #include <svx/svxids.hrc>
29 #include <sfx2/request.hxx>
30 #include <sfx2/basedlgs.hxx>
31 #include <svx/svdograf.hxx>
32 #include <svx/grfflt.hxx>
33 #include <svl/aeitem.hxx>
34 #include <svx/grafctrl.hxx>
36 #include <sfx2/objface.hxx>
39 #include "res_bmp.hrc"
41 #include "strings.hrc"
42 #include "DrawDocShell.hxx"
43 #include "ViewShell.hxx"
45 #include "drawview.hxx"
46 #include "sdresid.hxx"
47 #include "drawdoc.hxx"
50 #define GraphicObjectBar
51 #include "sdslots.hxx"
55 // - GraphicObjectBar -
57 SFX_IMPL_INTERFACE(GraphicObjectBar
, SfxShell
)
59 void GraphicObjectBar::InitInterface_Impl()
63 TYPEINIT1( GraphicObjectBar
, SfxShell
);
65 GraphicObjectBar::GraphicObjectBar (
66 ViewShell
* pSdViewShell
,
68 : SfxShell (pSdViewShell
->GetViewShell()),
70 mpViewSh ( pSdViewShell
),
71 nMappedSlotFilter ( SID_GRFFILTER_INVERT
)
73 DrawDocShell
* pDocShell
= mpViewSh
->GetDocSh();
75 SetPool( &pDocShell
->GetPool() );
76 SetUndoManager( pDocShell
->GetUndoManager() );
77 SetRepeatTarget( mpView
);
78 SetHelpId( SD_IF_SDDRAWGRAFOBJECTBAR
);
79 SetName( OUString( "Graphic objectbar" ));
82 GraphicObjectBar::~GraphicObjectBar()
84 SetRepeatTarget( NULL
);
87 void GraphicObjectBar::GetAttrState( SfxItemSet
& rSet
)
90 SvxGrafAttrHelper::GetGrafAttrState( rSet
, *mpView
);
93 void GraphicObjectBar::Execute( SfxRequest
& rReq
)
97 SvxGrafAttrHelper::ExecuteGrafAttr( rReq
, *mpView
);
102 void GraphicObjectBar::GetFilterState( SfxItemSet
& rSet
)
104 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
105 bool bEnable
= false;
107 if( rMarkList
.GetMarkCount() == 1 )
109 SdrObject
* pObj
= rMarkList
.GetMark( 0 )->GetMarkedSdrObj();
111 if( pObj
&& pObj
->ISA( SdrGrafObj
) && ( static_cast<SdrGrafObj
*>(pObj
)->GetGraphicType() == GRAPHIC_BITMAP
) )
116 SvxGraphicFilter::DisableGraphicFilterSlots( rSet
);
119 void GraphicObjectBar::ExecuteFilter( SfxRequest
& rReq
)
121 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
123 if( rMarkList
.GetMarkCount() == 1 )
125 SdrObject
* pObj
= rMarkList
.GetMark( 0 )->GetMarkedSdrObj();
127 if( pObj
&& pObj
->ISA( SdrGrafObj
) && static_cast<SdrGrafObj
*>(pObj
)->GetGraphicType() == GRAPHIC_BITMAP
)
129 GraphicObject
aFilterObj( static_cast<SdrGrafObj
*>(pObj
)->GetGraphicObject() );
131 if( SVX_GRAPHICFILTER_ERRCODE_NONE
==
132 SvxGraphicFilter::ExecuteGrfFilterSlot( rReq
, aFilterObj
) )
134 SdrPageView
* pPageView
= mpView
->GetSdrPageView();
138 SdrGrafObj
* pFilteredObj
= static_cast<SdrGrafObj
*>( pObj
->Clone() );
139 OUString aStr
= mpView
->GetDescriptionOfMarkedObjects();
140 aStr
+= " " + SD_RESSTR(STR_UNDO_GRAFFILTER
);
141 mpView
->BegUndo( aStr
);
142 pFilteredObj
->SetGraphicObject( aFilterObj
);
143 ::sd::View
* const pView
= mpView
;
144 pView
->ReplaceObjectAtView( pObj
, *pPageView
, pFilteredObj
);
155 } // end of namespace sd
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */