fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / view / GraphicObjectBar.cxx
blobaed500bef3c64cff12b7d5af0aabbf59b12c243a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 #include "GraphicObjectBar.hxx"
23 #include <limits.h>
24 #include <vcl/msgbox.hxx>
25 #include <svl/whiter.hxx>
26 #include <svl/itempool.hxx>
27 #include <sfx2/app.hxx>
28 #include <sfx2/shell.hxx>
29 #include <svx/svxids.hrc>
30 #include <sfx2/request.hxx>
31 #include <sfx2/basedlgs.hxx>
32 #include <svx/svdograf.hxx>
33 #include <svx/grfflt.hxx>
34 #include <svl/aeitem.hxx>
35 #include <svx/grafctrl.hxx>
38 #include <sfx2/objface.hxx>
40 #include "app.hrc"
41 #include "res_bmp.hrc"
42 #include "glob.hrc"
43 #include "strings.hrc"
44 #include "DrawDocShell.hxx"
45 #include "ViewShell.hxx"
46 #include "Window.hxx"
47 #include "drawview.hxx"
48 #include "sdresid.hxx"
49 #include "drawdoc.hxx"
51 using namespace sd;
52 #define GraphicObjectBar
53 #include "sdslots.hxx"
55 namespace sd {
59 // -----------------------
60 // - GraphicObjectBar -
61 // -----------------------
63 SFX_IMPL_INTERFACE( GraphicObjectBar, SfxShell, SdResId( STR_GRAFOBJECTBARSHELL ) )
67 // -----------------------------------------------------------------------------
69 TYPEINIT1( GraphicObjectBar, SfxShell );
71 // -----------------------------------------------------------------------------
73 GraphicObjectBar::GraphicObjectBar (
74 ViewShell* pSdViewShell,
75 ::sd::View* pSdView )
76 : SfxShell (pSdViewShell->GetViewShell()),
77 mpView ( pSdView ),
78 mpViewSh ( pSdViewShell ),
79 nMappedSlotFilter ( SID_GRFFILTER_INVERT )
81 DrawDocShell* pDocShell = mpViewSh->GetDocSh();
83 SetPool( &pDocShell->GetPool() );
84 SetUndoManager( pDocShell->GetUndoManager() );
85 SetRepeatTarget( mpView );
86 SetHelpId( SD_IF_SDDRAWGRAFOBJECTBAR );
87 SetName( OUString( "Graphic objectbar" ));
90 // -----------------------------------------------------------------------------
92 GraphicObjectBar::~GraphicObjectBar()
94 SetRepeatTarget( NULL );
97 // -----------------------------------------------------------------------------
99 void GraphicObjectBar::GetAttrState( SfxItemSet& rSet )
101 if( mpView )
102 SvxGrafAttrHelper::GetGrafAttrState( rSet, *mpView );
105 // -----------------------------------------------------------------------------
107 void GraphicObjectBar::Execute( SfxRequest& rReq )
109 if( mpView )
111 SvxGrafAttrHelper::ExecuteGrafAttr( rReq, *mpView );
112 Invalidate();
116 // -----------------------------------------------------------------------------
118 void GraphicObjectBar::GetFilterState( SfxItemSet& rSet )
120 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
121 sal_Bool bEnable = sal_False;
123 if( rMarkList.GetMarkCount() == 1 )
125 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
127 if( pObj && pObj->ISA( SdrGrafObj ) && ( ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) )
128 bEnable = sal_True;
131 if( !bEnable )
132 SvxGraphicFilter::DisableGraphicFilterSlots( rSet );
135 // -----------------------------------------------------------------------------
137 void GraphicObjectBar::ExecuteFilter( SfxRequest& rReq )
139 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
141 if( rMarkList.GetMarkCount() == 1 )
143 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
145 if( pObj && pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP )
147 GraphicObject aFilterObj( ( (SdrGrafObj*) pObj )->GetGraphicObject() );
149 if( SVX_GRAPHICFILTER_ERRCODE_NONE ==
150 SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ) )
152 SdrPageView* pPageView = mpView->GetSdrPageView();
154 if( pPageView )
156 SdrGrafObj* pFilteredObj = (SdrGrafObj*) pObj->Clone();
157 String aStr( mpView->GetDescriptionOfMarkedObjects() );
159 aStr.Append( sal_Unicode(' ') );
160 aStr.Append( String( SdResId( STR_UNDO_GRAFFILTER ) ) );
161 mpView->BegUndo( aStr );
162 pFilteredObj->SetGraphicObject( aFilterObj );
163 ::sd::View* const pView = mpView;
164 pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj );
165 pView->EndUndo();
166 return;
172 Invalidate();
175 } // end of namespace sd
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */