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