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 : #include "DrawViewShell.hxx"
21 : #include <vcl/metaact.hxx>
22 : #include <sfx2/request.hxx>
23 : #include <sfx2/dispatch.hxx>
24 : #include <vcl/msgbox.hxx>
25 : #include <sfx2/viewfrm.hxx>
26 : #include <svx/svdograf.hxx>
27 : #include <svx/svxids.hrc>
28 : #include <svx/fontwork.hxx>
29 : #include <svx/bmpmask.hxx>
30 : #include <svx/galbrws.hxx>
31 : #include <svx/imapdlg.hxx>
32 : #include <svx/SvxColorChildWindow.hxx>
33 : #include <svx/f3dchild.hxx>
34 : #include "optsitem.hxx"
35 : #include <svx/extrusionbar.hxx>
36 : #include <svx/fontworkbar.hxx>
37 : #include <svx/tbxcustomshapes.hxx>
38 : #include <avmedia/mediaplayer.hxx>
39 :
40 : #include "app.hrc"
41 : #include "strings.hrc"
42 :
43 : #include "sdmod.hxx"
44 : #include "animobjs.hxx"
45 : #include "AnimationChildWindow.hxx"
46 : #include "NavigatorChildWindow.hxx"
47 : #include "LayerDialogChildWindow.hxx"
48 : #include "sdresid.hxx"
49 : #include "drawdoc.hxx"
50 : #include "drawview.hxx"
51 : #include "FrameView.hxx"
52 : #include "Window.hxx"
53 : #include "DrawDocShell.hxx"
54 : #include "sdabstdlg.hxx"
55 : #include "framework/FrameworkHelper.hxx"
56 : #include <svx/svdoashp.hxx>
57 :
58 : namespace sd {
59 :
60 : /**
61 : * handle SfxRequests for FontWork
62 : */
63 0 : void DrawViewShell::ExecFormText(SfxRequest& rReq)
64 : {
65 : // nothing is executed during a slide show!
66 0 : if(HasCurrentFunction(SID_PRESENTATION))
67 0 : return;
68 :
69 0 : CheckLineTo (rReq);
70 :
71 0 : const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
72 :
73 0 : if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() &&
74 0 : mpDrawView && !mpDrawView->IsPresObjSelected() )
75 : {
76 0 : const SfxItemSet& rSet = *rReq.GetArgs();
77 :
78 0 : if ( mpDrawView->IsTextEdit() )
79 0 : mpDrawView->SdrEndTextEdit();
80 :
81 0 : mpDrawView->SetAttributes(rSet);
82 : }
83 : }
84 :
85 : /**
86 : * Return state values for FontWork
87 : */
88 0 : void DrawViewShell::GetFormTextState(SfxItemSet& rSet)
89 : {
90 0 : const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
91 0 : const SdrObject* pObj = NULL;
92 0 : SvxFontWorkDialog* pDlg = NULL;
93 :
94 0 : sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
95 :
96 0 : if ( GetViewFrame()->HasChildWindow(nId) )
97 0 : pDlg = (SvxFontWorkDialog*)(GetViewFrame()->GetChildWindow(nId)->GetWindow());
98 :
99 0 : if ( rMarkList.GetMarkCount() == 1 )
100 0 : pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
101 :
102 0 : const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(pObj);
103 : const bool bDeactivate(
104 0 : !pObj ||
105 0 : !pTextObj ||
106 0 : !pTextObj->HasText() ||
107 0 : dynamic_cast< const SdrObjCustomShape* >(pObj)); // #121538# no FontWork for CustomShapes
108 :
109 0 : if(bDeactivate)
110 : {
111 : // automatic open/close the FontWork-Dialog; first deactivate it
112 :
113 0 : rSet.DisableItem(XATTR_FORMTXTSTYLE);
114 0 : rSet.DisableItem(XATTR_FORMTXTADJUST);
115 0 : rSet.DisableItem(XATTR_FORMTXTDISTANCE);
116 0 : rSet.DisableItem(XATTR_FORMTXTSTART);
117 0 : rSet.DisableItem(XATTR_FORMTXTMIRROR);
118 0 : rSet.DisableItem(XATTR_FORMTXTHIDEFORM);
119 0 : rSet.DisableItem(XATTR_FORMTXTOUTLINE);
120 0 : rSet.DisableItem(XATTR_FORMTXTSHADOW);
121 0 : rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR);
122 0 : rSet.DisableItem(XATTR_FORMTXTSHDWXVAL);
123 0 : rSet.DisableItem(XATTR_FORMTXTSHDWYVAL);
124 : }
125 : else
126 : {
127 0 : if ( pDlg )
128 0 : pDlg->SetColorList(GetDoc()->GetColorList());
129 :
130 0 : SfxItemSet aSet( GetDoc()->GetPool() );
131 0 : mpDrawView->GetAttributes( aSet );
132 0 : rSet.Set( aSet );
133 : }
134 0 : }
135 :
136 :
137 0 : void DrawViewShell::ExecAnimationWin( SfxRequest& rReq )
138 : {
139 : // nothing is executed during a slide show!
140 0 : if (HasCurrentFunction(SID_PRESENTATION))
141 0 : return;
142 :
143 0 : CheckLineTo (rReq);
144 :
145 0 : sal_uInt16 nSId = rReq.GetSlot();
146 :
147 0 : switch( nSId )
148 : {
149 : case SID_ANIMATOR_INIT:
150 : case SID_ANIMATOR_ADD:
151 : case SID_ANIMATOR_CREATE:
152 : {
153 : AnimationWindow* pAnimWin;
154 0 : sal_uInt16 nId = AnimationChildWindow::GetChildWindowId();
155 :
156 : pAnimWin = static_cast<AnimationWindow*>(
157 0 : GetViewFrame()->GetChildWindow(nId)->GetWindow());
158 :
159 0 : if ( pAnimWin )
160 : {
161 0 : if( nSId == SID_ANIMATOR_ADD )
162 0 : pAnimWin->AddObj( *mpDrawView );
163 0 : else if( nSId == SID_ANIMATOR_CREATE )
164 0 : pAnimWin->CreateAnimObj( *mpDrawView );
165 : }
166 : }
167 0 : break;
168 :
169 : default:
170 0 : break;
171 : }
172 : }
173 :
174 : /**
175 : * Return status values for animator
176 : *
177 : * nValue == 0 -> No button
178 : * nValue == 1 -> Button 'accept'
179 : * nValue == 2 -> Button 'accept individually'
180 : * nValue == 3 -> Buttons 'accept' and 'accept individually'
181 : */
182 0 : void DrawViewShell::GetAnimationWinState( SfxItemSet& rSet )
183 : {
184 : // here we could disable buttons etc.
185 : sal_uInt16 nValue;
186 :
187 0 : const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
188 0 : sal_uLong nMarkCount = rMarkList.GetMarkCount();
189 :
190 0 : if( nMarkCount == 0 )
191 0 : nValue = 0;
192 0 : else if( nMarkCount > 1 )
193 0 : nValue = 3;
194 : else // 1 Object
195 : {
196 0 : const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
197 0 : sal_uInt32 nInv = pObj->GetObjInventor();
198 0 : sal_uInt16 nId = pObj->GetObjIdentifier();
199 : // 1 selected group object
200 0 : if( nInv == SdrInventor && nId == OBJ_GRUP )
201 0 : nValue = 3;
202 0 : else if( nInv == SdrInventor && nId == OBJ_GRAF ) // Animated GIF ?
203 : {
204 0 : sal_uInt16 nCount = 0;
205 :
206 0 : if( ( (SdrGrafObj*) pObj )->IsAnimated() )
207 0 : nCount = ( (SdrGrafObj*) pObj )->GetGraphic().GetAnimation().Count();
208 0 : if( nCount > 0 )
209 0 : nValue = 2;
210 : else
211 0 : nValue = 1;
212 : }
213 : else
214 0 : nValue = 1;
215 : }
216 0 : rSet.Put( SfxUInt16Item( SID_ANIMATOR_STATE, nValue ) );
217 0 : }
218 :
219 :
220 3280 : void DrawViewShell::SetChildWindowState( SfxItemSet& rSet )
221 : {
222 : // State of SfxChild-Windows (Animator, Fontwork etc.)
223 3280 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_FONTWORK ) )
224 : {
225 0 : sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
226 0 : rSet.Put(SfxBoolItem(SID_FONTWORK, GetViewFrame()->HasChildWindow(nId)));
227 : }
228 3280 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_COLOR_CONTROL ) )
229 : {
230 0 : sal_uInt16 nId = SvxColorChildWindow::GetChildWindowId();
231 0 : rSet.Put(SfxBoolItem(SID_COLOR_CONTROL, GetViewFrame()->HasChildWindow(nId)));
232 : }
233 3280 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ANIMATION_OBJECTS ) )
234 : {
235 17 : sal_uInt16 nId = AnimationChildWindow::GetChildWindowId();
236 17 : rSet.Put( SfxBoolItem( SID_ANIMATION_OBJECTS, GetViewFrame()->HasChildWindow( nId ) ) );
237 : }
238 3280 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_NAVIGATOR ) )
239 : {
240 136 : sal_uInt16 nId = SID_NAVIGATOR;
241 136 : rSet.Put( SfxBoolItem( SID_NAVIGATOR, GetViewFrame()->HasChildWindow( nId ) ) );
242 : }
243 3280 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_BMPMASK ) )
244 : {
245 0 : sal_uInt16 nId = SvxBmpMaskChildWindow::GetChildWindowId();
246 0 : rSet.Put( SfxBoolItem( SID_BMPMASK, GetViewFrame()->HasChildWindow( nId ) ) );
247 : }
248 3280 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GALLERY ) )
249 : {
250 109 : sal_uInt16 nId = GalleryChildWindow::GetChildWindowId();
251 109 : rSet.Put( SfxBoolItem( SID_GALLERY, GetViewFrame()->HasChildWindow( nId ) ) );
252 : }
253 3280 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_IMAP ) )
254 : {
255 109 : sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId();
256 109 : rSet.Put( SfxBoolItem( SID_IMAP, GetViewFrame()->HasChildWindow( nId ) ) );
257 : }
258 3280 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_LAYER_DIALOG_WIN ) )
259 : {
260 0 : sal_uInt16 nId = LayerDialogChildWindow::GetChildWindowId();
261 0 : rSet.Put( SfxBoolItem( SID_LAYER_DIALOG_WIN, GetViewFrame()->HasChildWindow( nId ) ) );
262 : }
263 3280 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_3D_WIN ) )
264 : {
265 128 : sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
266 128 : rSet.Put( SfxBoolItem( SID_3D_WIN, GetViewFrame()->HasChildWindow( nId ) ) );
267 : }
268 3280 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_AVMEDIA_PLAYER ) )
269 : {
270 0 : sal_uInt16 nId = ::avmedia::MediaPlayer::GetChildWindowId();
271 0 : rSet.Put( SfxBoolItem( SID_AVMEDIA_PLAYER, GetViewFrame()->HasChildWindow( nId ) ) );
272 : }
273 3280 : }
274 :
275 :
276 : /**
277 : * Handle SfxRequests for pipette
278 : */
279 0 : void DrawViewShell::ExecBmpMask( SfxRequest& rReq )
280 : {
281 : // nothing is executed during a slide show!
282 0 : if (HasCurrentFunction(SID_PRESENTATION))
283 0 : return;
284 :
285 0 : switch ( rReq.GetSlot() )
286 : {
287 : case ( SID_BMPMASK_PIPETTE ) :
288 : {
289 0 : mbPipette = ( (const SfxBoolItem&) ( rReq.GetArgs()->
290 0 : Get( SID_BMPMASK_PIPETTE ) ) ).GetValue();
291 : }
292 0 : break;
293 :
294 : case ( SID_BMPMASK_EXEC ) :
295 : {
296 0 : SdrGrafObj* pObj = 0;
297 0 : if( mpDrawView && mpDrawView->GetMarkedObjectList().GetMarkCount() )
298 0 : pObj = dynamic_cast< SdrGrafObj* >( mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj() );
299 :
300 0 : if ( pObj && !mpDrawView->IsTextEdit() )
301 : {
302 0 : SdrGrafObj* pNewObj = (SdrGrafObj*) pObj->Clone();
303 0 : sal_Bool bCont = sal_True;
304 :
305 0 : if( pNewObj->IsLinkedGraphic() )
306 : {
307 0 : QueryBox aQBox( (Window*) GetActiveWindow(), WB_YES_NO | WB_DEF_YES,
308 0 : String( SdResId( STR_RELEASE_GRAPHICLINK ) ) );
309 :
310 0 : if( RET_YES == aQBox.Execute() )
311 0 : pNewObj->ReleaseGraphicLink();
312 : else
313 : {
314 0 : delete pNewObj;
315 0 : bCont = sal_False;
316 0 : }
317 : }
318 :
319 0 : if( bCont )
320 : {
321 0 : const Graphic& rOldGraphic = pNewObj->GetGraphic();
322 : const Graphic aNewGraphic( ( (SvxBmpMask*) GetViewFrame()->GetChildWindow(
323 0 : SvxBmpMaskChildWindow::GetChildWindowId() )->GetWindow() )->
324 0 : Mask( rOldGraphic ) );
325 :
326 0 : if( aNewGraphic != rOldGraphic )
327 : {
328 0 : SdrPageView* pPV = mpDrawView->GetSdrPageView();
329 :
330 0 : pNewObj->SetEmptyPresObj( sal_False );
331 : pNewObj->SetGraphic( ( (SvxBmpMask*) GetViewFrame()->GetChildWindow(
332 0 : SvxBmpMaskChildWindow::GetChildWindowId() )->GetWindow() )->
333 0 : Mask( pNewObj->GetGraphic() ) );
334 :
335 0 : String aStr( mpDrawView->GetDescriptionOfMarkedObjects() );
336 0 : aStr += (sal_Unicode)( ' ' ), aStr += String( SdResId( STR_EYEDROPPER ) );
337 :
338 0 : mpDrawView->BegUndo( aStr );
339 0 : mpDrawView->ReplaceObjectAtView( pObj, *pPV, pNewObj );
340 0 : mpDrawView->EndUndo();
341 0 : }
342 : }
343 : }
344 : }
345 0 : break;
346 :
347 : default:
348 0 : break;
349 : }
350 : }
351 :
352 0 : void DrawViewShell::GetBmpMaskState( SfxItemSet& rSet )
353 : {
354 0 : const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
355 0 : const SdrObject* pObj = NULL;
356 0 : sal_uInt16 nId = SvxBmpMaskChildWindow::GetChildWindowId();
357 0 : sal_Bool bEnable = sal_False;
358 :
359 0 : if ( GetViewFrame()->HasChildWindow( nId ) )
360 : {
361 0 : SvxBmpMask* pDlg = (SvxBmpMask*) ( GetViewFrame()->GetChildWindow( nId )->GetWindow() );
362 :
363 0 : if ( pDlg->NeedsColorList() )
364 0 : pDlg->SetColorList( GetDoc()->GetColorList() );
365 : }
366 :
367 0 : if ( rMarkList.GetMarkCount() == 1 )
368 0 : pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
369 :
370 : // valid graphic object?
371 0 : if( pObj && pObj->ISA( SdrGrafObj ) &&
372 0 : !((SdrGrafObj*) pObj)->IsEPS() &&
373 0 : !mpDrawView->IsTextEdit() )
374 : {
375 0 : bEnable = sal_True;
376 : }
377 :
378 : // put value
379 0 : rSet.Put( SfxBoolItem( SID_BMPMASK_EXEC, bEnable ) );
380 0 : }
381 :
382 33 : } // end of namespace sd
383 :
384 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|