Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include "GraphicObjectBar.hxx"
22 :
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>
36 :
37 :
38 : #include <sfx2/objface.hxx>
39 :
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"
50 :
51 : using namespace sd;
52 : #define GraphicObjectBar
53 : #include "sdslots.hxx"
54 :
55 : namespace sd {
56 :
57 :
58 :
59 :
60 : // - GraphicObjectBar -
61 :
62 :
63 0 : SFX_IMPL_INTERFACE( GraphicObjectBar, SfxShell, SdResId( STR_GRAFOBJECTBARSHELL ) )
64 : {
65 0 : }
66 :
67 :
68 :
69 0 : TYPEINIT1( GraphicObjectBar, SfxShell );
70 :
71 :
72 :
73 0 : GraphicObjectBar::GraphicObjectBar (
74 : ViewShell* pSdViewShell,
75 : ::sd::View* pSdView )
76 : : SfxShell (pSdViewShell->GetViewShell()),
77 : mpView ( pSdView ),
78 : mpViewSh ( pSdViewShell ),
79 0 : nMappedSlotFilter ( SID_GRFFILTER_INVERT )
80 : {
81 0 : DrawDocShell* pDocShell = mpViewSh->GetDocSh();
82 :
83 0 : SetPool( &pDocShell->GetPool() );
84 0 : SetUndoManager( pDocShell->GetUndoManager() );
85 0 : SetRepeatTarget( mpView );
86 0 : SetHelpId( SD_IF_SDDRAWGRAFOBJECTBAR );
87 0 : SetName( OUString( "Graphic objectbar" ));
88 0 : }
89 :
90 :
91 :
92 0 : GraphicObjectBar::~GraphicObjectBar()
93 : {
94 0 : SetRepeatTarget( NULL );
95 0 : }
96 :
97 :
98 :
99 0 : void GraphicObjectBar::GetAttrState( SfxItemSet& rSet )
100 : {
101 0 : if( mpView )
102 0 : SvxGrafAttrHelper::GetGrafAttrState( rSet, *mpView );
103 0 : }
104 :
105 :
106 :
107 0 : void GraphicObjectBar::Execute( SfxRequest& rReq )
108 : {
109 0 : if( mpView )
110 : {
111 0 : SvxGrafAttrHelper::ExecuteGrafAttr( rReq, *mpView );
112 0 : Invalidate();
113 : }
114 0 : }
115 :
116 :
117 :
118 0 : void GraphicObjectBar::GetFilterState( SfxItemSet& rSet )
119 : {
120 0 : const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
121 0 : sal_Bool bEnable = sal_False;
122 :
123 0 : if( rMarkList.GetMarkCount() == 1 )
124 : {
125 0 : SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
126 :
127 0 : if( pObj && pObj->ISA( SdrGrafObj ) && ( ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) )
128 0 : bEnable = sal_True;
129 : }
130 :
131 0 : if( !bEnable )
132 0 : SvxGraphicFilter::DisableGraphicFilterSlots( rSet );
133 0 : }
134 :
135 :
136 :
137 0 : void GraphicObjectBar::ExecuteFilter( SfxRequest& rReq )
138 : {
139 0 : const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
140 :
141 0 : if( rMarkList.GetMarkCount() == 1 )
142 : {
143 0 : SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
144 :
145 0 : if( pObj && pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP )
146 : {
147 0 : GraphicObject aFilterObj( ( (SdrGrafObj*) pObj )->GetGraphicObject() );
148 :
149 0 : if( SVX_GRAPHICFILTER_ERRCODE_NONE ==
150 0 : SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ) )
151 : {
152 0 : SdrPageView* pPageView = mpView->GetSdrPageView();
153 :
154 0 : if( pPageView )
155 : {
156 0 : SdrGrafObj* pFilteredObj = (SdrGrafObj*) pObj->Clone();
157 0 : OUString aStr = mpView->GetDescriptionOfMarkedObjects();
158 0 : aStr += " " + SD_RESSTR(STR_UNDO_GRAFFILTER);
159 0 : mpView->BegUndo( aStr );
160 0 : pFilteredObj->SetGraphicObject( aFilterObj );
161 0 : ::sd::View* const pView = mpView;
162 0 : pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj );
163 0 : pView->EndUndo();
164 0 : return;
165 : }
166 0 : }
167 : }
168 : }
169 :
170 0 : Invalidate();
171 : }
172 :
173 0 : } // end of namespace sd
174 :
175 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|