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 : #include <sfx2/sidebar/Sidebar.hxx>
58 :
59 : namespace sd {
60 :
61 : /**
62 : * handle SfxRequests for FontWork
63 : */
64 0 : void DrawViewShell::ExecFormText(SfxRequest& rReq)
65 : {
66 : // nothing is executed during a slide show!
67 0 : if(HasCurrentFunction(SID_PRESENTATION))
68 0 : return;
69 :
70 0 : CheckLineTo (rReq);
71 :
72 0 : const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
73 :
74 0 : if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() &&
75 0 : !mpDrawView->IsPresObjSelected() )
76 : {
77 0 : const SfxItemSet& rSet = *rReq.GetArgs();
78 :
79 0 : if ( mpDrawView->IsTextEdit() )
80 0 : mpDrawView->SdrEndTextEdit();
81 :
82 0 : mpDrawView->SetAttributes(rSet);
83 : }
84 : }
85 :
86 : /**
87 : * Return state values for FontWork
88 : */
89 0 : void DrawViewShell::GetFormTextState(SfxItemSet& rSet)
90 : {
91 0 : const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
92 0 : const SdrObject* pObj = NULL;
93 0 : SvxFontWorkDialog* pDlg = NULL;
94 :
95 0 : sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
96 :
97 0 : if ( GetViewFrame()->HasChildWindow(nId) )
98 0 : pDlg = (SvxFontWorkDialog*)(GetViewFrame()->GetChildWindow(nId)->GetWindow());
99 :
100 0 : if ( rMarkList.GetMarkCount() == 1 )
101 0 : pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
102 :
103 0 : const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(pObj);
104 : const bool bDeactivate(
105 0 : !pObj ||
106 0 : !pTextObj ||
107 0 : !pTextObj->HasText() ||
108 0 : dynamic_cast< const SdrObjCustomShape* >(pObj)); // #121538# no FontWork for CustomShapes
109 :
110 0 : if(bDeactivate)
111 : {
112 : // automatic open/close the FontWork-Dialog; first deactivate it
113 :
114 0 : rSet.DisableItem(XATTR_FORMTXTSTYLE);
115 0 : rSet.DisableItem(XATTR_FORMTXTADJUST);
116 0 : rSet.DisableItem(XATTR_FORMTXTDISTANCE);
117 0 : rSet.DisableItem(XATTR_FORMTXTSTART);
118 0 : rSet.DisableItem(XATTR_FORMTXTMIRROR);
119 0 : rSet.DisableItem(XATTR_FORMTXTHIDEFORM);
120 0 : rSet.DisableItem(XATTR_FORMTXTOUTLINE);
121 0 : rSet.DisableItem(XATTR_FORMTXTSHADOW);
122 0 : rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR);
123 0 : rSet.DisableItem(XATTR_FORMTXTSHDWXVAL);
124 0 : rSet.DisableItem(XATTR_FORMTXTSHDWYVAL);
125 : }
126 : else
127 : {
128 0 : if ( pDlg )
129 0 : pDlg->SetColorList(GetDoc()->GetColorList());
130 :
131 0 : SfxItemSet aSet( GetDoc()->GetPool() );
132 0 : mpDrawView->GetAttributes( aSet );
133 0 : rSet.Set( aSet );
134 : }
135 0 : }
136 :
137 :
138 0 : void DrawViewShell::ExecAnimationWin( SfxRequest& rReq )
139 : {
140 : // nothing is executed during a slide show!
141 0 : if (HasCurrentFunction(SID_PRESENTATION))
142 0 : return;
143 :
144 0 : CheckLineTo (rReq);
145 :
146 0 : sal_uInt16 nSId = rReq.GetSlot();
147 :
148 0 : switch( nSId )
149 : {
150 : case SID_ANIMATOR_INIT:
151 : case SID_ANIMATOR_ADD:
152 : case SID_ANIMATOR_CREATE:
153 : {
154 : AnimationWindow* pAnimWin;
155 0 : sal_uInt16 nId = AnimationChildWindow::GetChildWindowId();
156 :
157 : pAnimWin = static_cast<AnimationWindow*>(
158 0 : GetViewFrame()->GetChildWindow(nId)->GetWindow());
159 :
160 0 : if ( pAnimWin )
161 : {
162 0 : if( nSId == SID_ANIMATOR_ADD )
163 0 : pAnimWin->AddObj( *mpDrawView );
164 0 : else if( nSId == SID_ANIMATOR_CREATE )
165 0 : pAnimWin->CreateAnimObj( *mpDrawView );
166 : }
167 : }
168 0 : break;
169 :
170 : default:
171 0 : break;
172 : }
173 : }
174 :
175 : /**
176 : * Return status values for animator
177 : *
178 : * nValue == 0 -> No button
179 : * nValue == 1 -> Button 'accept'
180 : * nValue == 2 -> Button 'accept individually'
181 : * nValue == 3 -> Buttons 'accept' and 'accept individually'
182 : */
183 0 : void DrawViewShell::GetAnimationWinState( SfxItemSet& rSet )
184 : {
185 : // here we could disable buttons etc.
186 : sal_uInt16 nValue;
187 :
188 0 : const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
189 0 : sal_uLong nMarkCount = rMarkList.GetMarkCount();
190 :
191 0 : if( nMarkCount == 0 )
192 0 : nValue = 0;
193 0 : else if( nMarkCount > 1 )
194 0 : nValue = 3;
195 : else // 1 Object
196 : {
197 0 : const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
198 0 : sal_uInt32 nInv = pObj->GetObjInventor();
199 0 : sal_uInt16 nId = pObj->GetObjIdentifier();
200 : // 1 selected group object
201 0 : if( nInv == SdrInventor && nId == OBJ_GRUP )
202 0 : nValue = 3;
203 0 : else if( nInv == SdrInventor && nId == OBJ_GRAF ) // Animated GIF ?
204 : {
205 0 : sal_uInt16 nCount = 0;
206 :
207 0 : if( ( (SdrGrafObj*) pObj )->IsAnimated() )
208 0 : nCount = ( (SdrGrafObj*) pObj )->GetGraphic().GetAnimation().Count();
209 0 : if( nCount > 0 )
210 0 : nValue = 2;
211 : else
212 0 : nValue = 1;
213 : }
214 : else
215 0 : nValue = 1;
216 : }
217 0 : rSet.Put( SfxUInt16Item( SID_ANIMATOR_STATE, nValue ) );
218 0 : }
219 :
220 :
221 0 : void DrawViewShell::SetChildWindowState( SfxItemSet& rSet )
222 : {
223 : // State of SfxChild-Windows (Animator, Fontwork etc.)
224 0 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_FONTWORK ) )
225 : {
226 0 : sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
227 0 : rSet.Put(SfxBoolItem(SID_FONTWORK, GetViewFrame()->HasChildWindow(nId)));
228 : }
229 0 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_COLOR_CONTROL ) )
230 : {
231 0 : sal_uInt16 nId = SvxColorChildWindow::GetChildWindowId();
232 0 : rSet.Put(SfxBoolItem(SID_COLOR_CONTROL, GetViewFrame()->HasChildWindow(nId)));
233 : }
234 0 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ANIMATION_OBJECTS ) )
235 : {
236 0 : sal_uInt16 nId = AnimationChildWindow::GetChildWindowId();
237 0 : rSet.Put( SfxBoolItem( SID_ANIMATION_OBJECTS, GetViewFrame()->HasChildWindow( nId ) ) );
238 : }
239 0 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_NAVIGATOR ) )
240 : {
241 0 : sal_uInt16 nId = SID_NAVIGATOR;
242 0 : rSet.Put( SfxBoolItem( SID_NAVIGATOR, GetViewFrame()->HasChildWindow( nId ) ) );
243 : }
244 0 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_BMPMASK ) )
245 : {
246 0 : sal_uInt16 nId = SvxBmpMaskChildWindow::GetChildWindowId();
247 0 : rSet.Put( SfxBoolItem( SID_BMPMASK, GetViewFrame()->HasChildWindow( nId ) ) );
248 : }
249 0 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GALLERY ) )
250 : {
251 0 : sal_uInt16 nId = GalleryChildWindow::GetChildWindowId();
252 0 : rSet.Put( SfxBoolItem( SID_GALLERY, GetViewFrame()->HasChildWindow( nId ) ) );
253 : }
254 0 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_IMAP ) )
255 : {
256 0 : sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId();
257 0 : rSet.Put( SfxBoolItem( SID_IMAP, GetViewFrame()->HasChildWindow( nId ) ) );
258 : }
259 0 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_LAYER_DIALOG_WIN ) )
260 : {
261 0 : sal_uInt16 nId = LayerDialogChildWindow::GetChildWindowId();
262 0 : rSet.Put( SfxBoolItem( SID_LAYER_DIALOG_WIN, GetViewFrame()->HasChildWindow( nId ) ) );
263 : }
264 0 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_3D_WIN ) )
265 : {
266 0 : sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
267 0 : rSet.Put( SfxBoolItem( SID_3D_WIN, GetViewFrame()->HasChildWindow( nId ) ) );
268 : }
269 0 : if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_AVMEDIA_PLAYER ) )
270 : {
271 0 : sal_uInt16 nId = ::avmedia::MediaPlayer::GetChildWindowId();
272 0 : rSet.Put( SfxBoolItem( SID_AVMEDIA_PLAYER, GetViewFrame()->HasChildWindow( nId ) ) );
273 : }
274 0 : }
275 :
276 :
277 : /**
278 : * Handle SfxRequests for pipette
279 : */
280 0 : void DrawViewShell::ExecBmpMask( SfxRequest& rReq )
281 : {
282 : // nothing is executed during a slide show!
283 0 : if (HasCurrentFunction(SID_PRESENTATION))
284 0 : return;
285 :
286 0 : switch ( rReq.GetSlot() )
287 : {
288 : case ( SID_BMPMASK_PIPETTE ) :
289 : {
290 0 : mbPipette = ( (const SfxBoolItem&) ( rReq.GetArgs()->
291 0 : Get( SID_BMPMASK_PIPETTE ) ) ).GetValue();
292 : }
293 0 : break;
294 :
295 : case ( SID_BMPMASK_EXEC ) :
296 : {
297 0 : SdrGrafObj* pObj = 0;
298 0 : if( mpDrawView && mpDrawView->GetMarkedObjectList().GetMarkCount() )
299 0 : pObj = dynamic_cast< SdrGrafObj* >( mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj() );
300 :
301 0 : if ( pObj && !mpDrawView->IsTextEdit() )
302 : {
303 0 : SdrGrafObj* pNewObj = (SdrGrafObj*) pObj->Clone();
304 0 : bool bCont = true;
305 :
306 0 : if( pNewObj->IsLinkedGraphic() )
307 : {
308 0 : MessageDialog aQueryBox( (Window*) GetActiveWindow(),"QueryUnlinkImageDialog","modules/sdraw/ui/queryunlinkimagedialog.ui");
309 :
310 0 : if (RET_YES == aQueryBox.Execute())
311 0 : pNewObj->ReleaseGraphicLink();
312 : else
313 : {
314 0 : delete pNewObj;
315 0 : bCont = 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( false );
331 : pNewObj->SetGraphic( ( (SvxBmpMask*) GetViewFrame()->GetChildWindow(
332 0 : SvxBmpMaskChildWindow::GetChildWindowId() )->GetWindow() )->
333 0 : Mask( pNewObj->GetGraphic() ) );
334 :
335 0 : OUString aStr( mpDrawView->GetDescriptionOfMarkedObjects() );
336 0 : aStr += " " + SD_RESSTR(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 0 : } // end of namespace sd
383 :
384 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|