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