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 : {
97 0 : SfxChildWindow* pWnd = GetViewFrame()->GetChildWindow(nId);
98 0 : pDlg = pWnd ? static_cast<SvxFontWorkDialog*>(pWnd->GetWindow()) : NULL;
99 : }
100 :
101 0 : if ( rMarkList.GetMarkCount() == 1 )
102 0 : pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
103 :
104 0 : const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(pObj);
105 : const bool bDeactivate(
106 0 : !pObj ||
107 0 : !pTextObj ||
108 0 : !pTextObj->HasText() ||
109 0 : dynamic_cast< const SdrObjCustomShape* >(pObj)); // #121538# no FontWork for CustomShapes
110 :
111 0 : if(bDeactivate)
112 : {
113 : // automatic open/close the FontWork-Dialog; first deactivate it
114 :
115 0 : rSet.DisableItem(XATTR_FORMTXTSTYLE);
116 0 : rSet.DisableItem(XATTR_FORMTXTADJUST);
117 0 : rSet.DisableItem(XATTR_FORMTXTDISTANCE);
118 0 : rSet.DisableItem(XATTR_FORMTXTSTART);
119 0 : rSet.DisableItem(XATTR_FORMTXTMIRROR);
120 0 : rSet.DisableItem(XATTR_FORMTXTHIDEFORM);
121 0 : rSet.DisableItem(XATTR_FORMTXTOUTLINE);
122 0 : rSet.DisableItem(XATTR_FORMTXTSHADOW);
123 0 : rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR);
124 0 : rSet.DisableItem(XATTR_FORMTXTSHDWXVAL);
125 0 : rSet.DisableItem(XATTR_FORMTXTSHDWYVAL);
126 : }
127 : else
128 : {
129 0 : if ( pDlg )
130 0 : pDlg->SetColorList(GetDoc()->GetColorList());
131 :
132 0 : SfxItemSet aSet( GetDoc()->GetPool() );
133 0 : mpDrawView->GetAttributes( aSet );
134 0 : rSet.Set( aSet );
135 : }
136 0 : }
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 0 : SfxChildWindow* pWnd = GetViewFrame()->GetChildWindow(nId);
158 :
159 0 : pAnimWin = pWnd ? static_cast<AnimationWindow*>(pWnd->GetWindow()) : NULL;
160 :
161 0 : if ( pAnimWin )
162 : {
163 0 : if( nSId == SID_ANIMATOR_ADD )
164 0 : pAnimWin->AddObj( *mpDrawView );
165 0 : else if( nSId == SID_ANIMATOR_CREATE )
166 0 : pAnimWin->CreateAnimObj( *mpDrawView );
167 : }
168 : }
169 0 : break;
170 :
171 : default:
172 0 : break;
173 : }
174 : }
175 :
176 : /**
177 : * Return status values for animator
178 : *
179 : * nValue == 0 -> No button
180 : * nValue == 1 -> Button 'accept'
181 : * nValue == 2 -> Button 'accept individually'
182 : * nValue == 3 -> Buttons 'accept' and 'accept individually'
183 : */
184 0 : void DrawViewShell::GetAnimationWinState( SfxItemSet& rSet )
185 : {
186 : // here we could disable buttons etc.
187 : sal_uInt16 nValue;
188 :
189 0 : const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
190 0 : const size_t nMarkCount = rMarkList.GetMarkCount();
191 :
192 0 : if( nMarkCount == 0 )
193 0 : nValue = 0;
194 0 : else if( nMarkCount > 1 )
195 0 : nValue = 3;
196 : else // 1 Object
197 : {
198 0 : const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
199 0 : sal_uInt32 nInv = pObj->GetObjInventor();
200 0 : sal_uInt16 nId = pObj->GetObjIdentifier();
201 : // 1 selected group object
202 0 : if( nInv == SdrInventor && nId == OBJ_GRUP )
203 0 : nValue = 3;
204 0 : else if( nInv == SdrInventor && nId == OBJ_GRAF ) // Animated GIF ?
205 : {
206 0 : sal_uInt16 nCount = 0;
207 :
208 0 : if( static_cast<const SdrGrafObj*>(pObj)->IsAnimated() )
209 0 : nCount = static_cast<const SdrGrafObj*>(pObj)->GetGraphic().GetAnimation().Count();
210 0 : if( nCount > 0 )
211 0 : nValue = 2;
212 : else
213 0 : nValue = 1;
214 : }
215 : else
216 0 : nValue = 1;
217 : }
218 0 : rSet.Put( SfxUInt16Item( SID_ANIMATOR_STATE, nValue ) );
219 0 : }
220 :
221 4175 : void DrawViewShell::SetChildWindowState( SfxItemSet& rSet )
222 : {
223 : // State of SfxChild-Windows (Animator, Fontwork etc.)
224 4175 : if( SfxItemState::DEFAULT == rSet.GetItemState( SID_FONTWORK ) )
225 : {
226 0 : sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
227 0 : rSet.Put(SfxBoolItem(SID_FONTWORK, GetViewFrame()->HasChildWindow(nId)));
228 : }
229 4175 : if( SfxItemState::DEFAULT == 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 4175 : if( SfxItemState::DEFAULT == 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 4175 : if( SfxItemState::DEFAULT == rSet.GetItemState( SID_NAVIGATOR ) )
240 : {
241 0 : sal_uInt16 nId = SID_NAVIGATOR;
242 0 : rSet.Put( SfxBoolItem( SID_NAVIGATOR, GetViewFrame()->HasChildWindow( nId ) ) );
243 : }
244 4175 : if( SfxItemState::DEFAULT == rSet.GetItemState( SID_BMPMASK ) )
245 : {
246 0 : sal_uInt16 nId = SvxBmpMaskChildWindow::GetChildWindowId();
247 0 : rSet.Put( SfxBoolItem( SID_BMPMASK, GetViewFrame()->HasChildWindow( nId ) ) );
248 : }
249 4175 : if( SfxItemState::DEFAULT == rSet.GetItemState( SID_IMAP ) )
250 : {
251 107 : sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId();
252 107 : rSet.Put( SfxBoolItem( SID_IMAP, GetViewFrame()->HasChildWindow( nId ) ) );
253 : }
254 4175 : if( SfxItemState::DEFAULT == rSet.GetItemState( SID_3D_WIN ) )
255 : {
256 107 : sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
257 107 : rSet.Put( SfxBoolItem( SID_3D_WIN, GetViewFrame()->HasChildWindow( nId ) ) );
258 : }
259 4175 : if( SfxItemState::DEFAULT == rSet.GetItemState( SID_AVMEDIA_PLAYER ) )
260 : {
261 0 : sal_uInt16 nId = ::avmedia::MediaPlayer::GetChildWindowId();
262 0 : rSet.Put( SfxBoolItem( SID_AVMEDIA_PLAYER, GetViewFrame()->HasChildWindow( nId ) ) );
263 : }
264 4175 : }
265 :
266 : /**
267 : * Handle SfxRequests for pipette
268 : */
269 0 : void DrawViewShell::ExecBmpMask( SfxRequest& rReq )
270 : {
271 : // nothing is executed during a slide show!
272 0 : if (HasCurrentFunction(SID_PRESENTATION))
273 0 : return;
274 :
275 0 : switch ( rReq.GetSlot() )
276 : {
277 : case ( SID_BMPMASK_PIPETTE ) :
278 : {
279 : mbPipette = static_cast<const SfxBoolItem&>( rReq.GetArgs()->
280 0 : Get( SID_BMPMASK_PIPETTE ) ).GetValue();
281 : }
282 0 : break;
283 :
284 : case ( SID_BMPMASK_EXEC ) :
285 : {
286 0 : SdrGrafObj* pObj = 0;
287 0 : if( mpDrawView && mpDrawView->GetMarkedObjectList().GetMarkCount() )
288 0 : pObj = dynamic_cast< SdrGrafObj* >( mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj() );
289 :
290 0 : if ( pObj && !mpDrawView->IsTextEdit() )
291 : {
292 0 : SdrGrafObj* pNewObj = pObj->Clone();
293 0 : bool bCont = true;
294 :
295 0 : if( pNewObj->IsLinkedGraphic() )
296 : {
297 0 : ScopedVclPtrInstance< MessageDialog > aQueryBox( static_cast<vcl::Window*>(GetActiveWindow()),"QueryUnlinkImageDialog","modules/sdraw/ui/queryunlinkimagedialog.ui");
298 :
299 0 : if (RET_YES == aQueryBox->Execute())
300 0 : pNewObj->ReleaseGraphicLink();
301 : else
302 : {
303 0 : delete pNewObj;
304 0 : bCont = false;
305 0 : }
306 : }
307 :
308 : SfxChildWindow* pWnd = GetViewFrame()->GetChildWindow(
309 0 : SvxBmpMaskChildWindow::GetChildWindowId());
310 0 : SvxBmpMask* pBmpMask = pWnd ? static_cast<SvxBmpMask*>(pWnd->GetWindow()) : NULL;
311 : assert(pBmpMask);
312 0 : if (bCont && pBmpMask)
313 : {
314 0 : const Graphic& rOldGraphic = pNewObj->GetGraphic();
315 0 : const Graphic aNewGraphic(pBmpMask->Mask(rOldGraphic));
316 :
317 0 : if( aNewGraphic != rOldGraphic )
318 : {
319 0 : SdrPageView* pPV = mpDrawView->GetSdrPageView();
320 :
321 0 : pNewObj->SetEmptyPresObj( false );
322 0 : pNewObj->SetGraphic(pBmpMask->Mask(pNewObj->GetGraphic()));
323 :
324 0 : OUString aStr( mpDrawView->GetDescriptionOfMarkedObjects() );
325 0 : aStr += " " + SD_RESSTR(STR_EYEDROPPER);
326 :
327 0 : mpDrawView->BegUndo( aStr );
328 0 : mpDrawView->ReplaceObjectAtView( pObj, *pPV, pNewObj );
329 0 : mpDrawView->EndUndo();
330 0 : }
331 : }
332 : }
333 : }
334 0 : break;
335 :
336 : default:
337 0 : break;
338 : }
339 : }
340 :
341 0 : void DrawViewShell::GetBmpMaskState( SfxItemSet& rSet )
342 : {
343 0 : const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
344 0 : const SdrObject* pObj = NULL;
345 0 : sal_uInt16 nId = SvxBmpMaskChildWindow::GetChildWindowId();
346 0 : bool bEnable = false;
347 :
348 0 : if ( GetViewFrame()->HasChildWindow( nId ) )
349 : {
350 0 : SfxChildWindow* pWnd = GetViewFrame()->GetChildWindow(nId);
351 0 : SvxBmpMask* pDlg = pWnd ? static_cast<SvxBmpMask*>(pWnd->GetWindow()) : NULL;
352 0 : if (pDlg && pDlg->NeedsColorList())
353 0 : pDlg->SetColorList(GetDoc()->GetColorList());
354 : }
355 :
356 0 : if ( rMarkList.GetMarkCount() == 1 )
357 0 : pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
358 :
359 : // valid graphic object?
360 0 : if( pObj && pObj->ISA( SdrGrafObj ) &&
361 0 : !static_cast<const SdrGrafObj*>(pObj)->IsEPS() &&
362 0 : !mpDrawView->IsTextEdit() )
363 : {
364 0 : bEnable = true;
365 : }
366 :
367 : // put value
368 0 : rSet.Put( SfxBoolItem( SID_BMPMASK_EXEC, bEnable ) );
369 0 : }
370 :
371 66 : } // end of namespace sd
372 :
373 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|