/src/libreoffice/sw/source/uibase/shells/drawsh.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 <svx/svdview.hxx> |
21 | | #include <svx/svdotext.hxx> |
22 | | #include <svl/whiter.hxx> |
23 | | #include <svx/fontwork.hxx> |
24 | | #include <sfx2/request.hxx> |
25 | | #include <sfx2/bindings.hxx> |
26 | | #include <sfx2/objface.hxx> |
27 | | #include <sfx2/toolbarids.hxx> |
28 | | #include <sfx2/viewfrm.hxx> |
29 | | #include <svx/extrusionbar.hxx> |
30 | | #include <svx/fontworkbar.hxx> |
31 | | #include <uitool.hxx> |
32 | | #include <dcontact.hxx> |
33 | | #include <textboxhelper.hxx> |
34 | | #include <wview.hxx> |
35 | | #include <swmodule.hxx> |
36 | | |
37 | | #include <svx/svdoashp.hxx> |
38 | | #include <svx/xfillit0.hxx> |
39 | | #include <vcl/EnumContext.hxx> |
40 | | #include <svx/svdoole2.hxx> |
41 | | #include <sfx2/opengrf.hxx> |
42 | | #include <svx/svdograf.hxx> |
43 | | #include <svx/svdundo.hxx> |
44 | | #include <svx/xbtmpit.hxx> |
45 | | #include <svx/sdasitm.hxx> |
46 | | #include <osl/diagnose.h> |
47 | | |
48 | | #include <swundo.hxx> |
49 | | #include <wrtsh.hxx> |
50 | | #include <cmdid.h> |
51 | | #include <strings.hrc> |
52 | | #include <drwbassh.hxx> |
53 | | #include <drawsh.hxx> |
54 | | |
55 | | #define ShellClass_SwDrawShell |
56 | | #include <sfx2/msg.hxx> |
57 | | #include <swslots.hxx> |
58 | | |
59 | | using namespace ::com::sun::star; |
60 | | using namespace ::com::sun::star::uno; |
61 | | |
62 | | SFX_IMPL_INTERFACE(SwDrawShell, SwDrawBaseShell) |
63 | | |
64 | | void SwDrawShell::InitInterface_Impl() |
65 | 9 | { |
66 | 9 | GetStaticInterface()->RegisterPopupMenu(u"draw"_ustr); |
67 | | |
68 | 9 | GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Invisible, ToolbarId::Draw_Toolbox_Sw); |
69 | | |
70 | 9 | GetStaticInterface()->RegisterChildWindow(SvxFontWorkChildWindow::GetChildWindowId()); |
71 | 9 | } |
72 | | |
73 | | |
74 | | // #i123922# check as the name implies |
75 | | SdrObject* SwDrawShell::IsSingleFillableNonOLESelected() |
76 | 0 | { |
77 | 0 | SwWrtShell &rSh = GetShell(); |
78 | 0 | SdrView* pSdrView = rSh.GetDrawView(); |
79 | |
|
80 | 0 | if(!pSdrView) |
81 | 0 | { |
82 | 0 | return nullptr; |
83 | 0 | } |
84 | | |
85 | 0 | if(1 != pSdrView->GetMarkedObjectList().GetMarkCount()) |
86 | 0 | { |
87 | 0 | return nullptr; |
88 | 0 | } |
89 | | |
90 | 0 | SdrObject* pPickObj = pSdrView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(); |
91 | |
|
92 | 0 | if(!pPickObj) |
93 | 0 | { |
94 | 0 | return nullptr; |
95 | 0 | } |
96 | | |
97 | 0 | if(!pPickObj->IsClosedObj()) |
98 | 0 | { |
99 | 0 | return nullptr; |
100 | 0 | } |
101 | | |
102 | 0 | if(dynamic_cast< SdrOle2Obj* >(pPickObj)) |
103 | 0 | { |
104 | 0 | return nullptr; |
105 | 0 | } |
106 | | |
107 | 0 | return pPickObj; |
108 | 0 | } |
109 | | |
110 | | // #i123922# insert given graphic data dependent of the object type in focus |
111 | | void SwDrawShell::InsertPictureFromFile(SdrObject& rObject) |
112 | 0 | { |
113 | 0 | SwWrtShell &rSh = GetShell(); |
114 | 0 | SdrView* pSdrView = rSh.GetDrawView(); |
115 | |
|
116 | 0 | if(!pSdrView) |
117 | 0 | return; |
118 | | |
119 | 0 | SvxOpenGraphicDialog aDlg(SwResId(STR_INSERT_GRAPHIC), GetView().GetFrameWeld()); |
120 | |
|
121 | 0 | if (ERRCODE_NONE != aDlg.Execute()) |
122 | 0 | return; |
123 | | |
124 | 0 | Graphic aGraphic; |
125 | 0 | ErrCode nError = aDlg.GetGraphic(aGraphic); |
126 | |
|
127 | 0 | if(ERRCODE_NONE != nError) |
128 | 0 | return; |
129 | | |
130 | 0 | const bool bAsLink(aDlg.IsAsLink()); |
131 | 0 | SdrObject* pResult = &rObject; |
132 | |
|
133 | 0 | rSh.StartUndo(SwUndoId::PASTE_CLIPBOARD); |
134 | |
|
135 | 0 | if (SdrGrafObj* pSdrGrafObj = dynamic_cast<SdrGrafObj*>(&rObject)) |
136 | 0 | { |
137 | 0 | rtl::Reference<SdrGrafObj> pNewGrafObj = SdrObject::Clone(*pSdrGrafObj, pSdrGrafObj->getSdrModelFromSdrObject()); |
138 | |
|
139 | 0 | pNewGrafObj->SetGraphic(aGraphic); |
140 | | |
141 | | // #i123922# for handling MasterObject and virtual ones correctly, SW |
142 | | // wants us to call ReplaceObject at the page, but that also |
143 | | // triggers the same assertion (I tried it), so stay at the view method |
144 | 0 | pSdrView->ReplaceObjectAtView(&rObject, *pSdrView->GetSdrPageView(), pNewGrafObj.get()); |
145 | | |
146 | | // set in all cases - the Clone() will have copied an existing link (!) |
147 | 0 | pNewGrafObj->SetGraphicLink( |
148 | 0 | bAsLink ? aDlg.GetPath() : OUString()); |
149 | |
|
150 | 0 | pResult = pNewGrafObj.get(); |
151 | 0 | } |
152 | 0 | else // if(rObject.IsClosedObj() && !dynamic_cast< SdrOle2Obj* >(&rObject)) |
153 | 0 | { |
154 | 0 | pSdrView->AddUndo(std::make_unique<SdrUndoAttrObj>(rObject)); |
155 | |
|
156 | 0 | SfxItemSetFixed<XATTR_FILLSTYLE, XATTR_FILLBITMAP> aSet(pSdrView->GetModel().GetItemPool()); |
157 | |
|
158 | 0 | aSet.Put(XFillStyleItem(drawing::FillStyle_BITMAP)); |
159 | 0 | aSet.Put(XFillBitmapItem(OUString(), std::move(aGraphic))); |
160 | 0 | rObject.SetMergedItemSetAndBroadcast(aSet); |
161 | 0 | } |
162 | |
|
163 | 0 | rSh.EndUndo( SwUndoId::END ); |
164 | |
|
165 | 0 | if(pResult) |
166 | 0 | { |
167 | | // we are done; mark the modified/new object |
168 | 0 | pSdrView->MarkObj(pResult, pSdrView->GetSdrPageView()); |
169 | 0 | } |
170 | 0 | } |
171 | | |
172 | | void SwDrawShell::Execute(SfxRequest &rReq) |
173 | 0 | { |
174 | 0 | SwWrtShell &rSh = GetShell(); |
175 | 0 | SdrView *pSdrView = rSh.GetDrawView(); |
176 | 0 | const SfxItemSet *pArgs = rReq.GetArgs(); |
177 | 0 | SfxBindings &rBnd = GetView().GetViewFrame().GetBindings(); |
178 | 0 | sal_uInt16 nSlotId = rReq.GetSlot(); |
179 | 0 | bool bChanged = pSdrView->GetModel().IsChanged(); |
180 | |
|
181 | 0 | pSdrView->GetModel().SetChanged(false); |
182 | |
|
183 | 0 | const SfxPoolItem* pItem; |
184 | 0 | if(pArgs) |
185 | 0 | pArgs->GetItemState(nSlotId, false, &pItem); |
186 | |
|
187 | 0 | bool bMirror = true; |
188 | |
|
189 | 0 | switch (nSlotId) |
190 | 0 | { |
191 | 0 | case SID_OBJECT_ROTATE: |
192 | 0 | GetView().ToggleRotate(); |
193 | 0 | break; |
194 | 0 | case SID_MOVE_SHAPE_HANDLE: |
195 | 0 | { |
196 | 0 | if (pArgs && pArgs->Count() >= 3) |
197 | 0 | { |
198 | 0 | const SfxUInt32Item* handleNumItem = rReq.GetArg<SfxUInt32Item>(FN_PARAM_1); |
199 | 0 | const SfxUInt32Item* newPosXTwips = rReq.GetArg<SfxUInt32Item>(FN_PARAM_2); |
200 | 0 | const SfxUInt32Item* newPosYTwips = rReq.GetArg<SfxUInt32Item>(FN_PARAM_3); |
201 | 0 | const SfxInt32Item* OrdNum = rReq.GetArg<SfxInt32Item>(FN_PARAM_4); |
202 | |
|
203 | 0 | const sal_uLong handleNum = handleNumItem->GetValue(); |
204 | 0 | const sal_uLong newPosX = newPosXTwips->GetValue(); |
205 | 0 | const sal_uLong newPosY = newPosYTwips->GetValue(); |
206 | 0 | const Point mPoint(newPosX, newPosY); |
207 | 0 | const SdrHdl* handle = pSdrView->GetHdlList().GetHdl(handleNum); |
208 | 0 | if (!handle) |
209 | 0 | { |
210 | 0 | break; |
211 | 0 | } |
212 | | |
213 | 0 | if (handle->GetKind() == SdrHdlKind::Anchor || handle->GetKind() == SdrHdlKind::Anchor_TR) |
214 | 0 | { |
215 | 0 | rSh.FindAnchorPos(mPoint, /*bMoveIt=*/true); |
216 | 0 | pSdrView->ModelHasChanged(); |
217 | 0 | } |
218 | 0 | else |
219 | 0 | pSdrView->MoveShapeHandle(handleNum, mPoint, OrdNum ? OrdNum->GetValue() : -1); |
220 | 0 | } |
221 | 0 | } |
222 | 0 | break; |
223 | 0 | case SID_BEZIER_EDIT: |
224 | 0 | if (GetView().IsDrawRotate()) |
225 | 0 | { |
226 | 0 | rSh.SetDragMode(SdrDragMode::Move); |
227 | 0 | GetView().FlipDrawRotate(); |
228 | 0 | } |
229 | 0 | GetView().FlipDrawSelMode(); |
230 | 0 | pSdrView->SetFrameDragSingles(GetView().IsDrawSelMode()); |
231 | 0 | GetView().AttrChangedNotify(nullptr); // Shell switch |
232 | 0 | break; |
233 | | |
234 | 0 | case SID_OBJECT_HELL: |
235 | 0 | if (rSh.GetSelectedObjCount()) |
236 | 0 | { |
237 | 0 | rSh.StartUndo( SwUndoId::START ); |
238 | 0 | SetWrapMode(FN_FRAME_WRAPTHRU_TRANSP); |
239 | 0 | rSh.SelectionToHell(); |
240 | 0 | rSh.EndUndo( SwUndoId::END ); |
241 | 0 | rBnd.Invalidate(SID_OBJECT_HEAVEN); |
242 | 0 | } |
243 | 0 | break; |
244 | | |
245 | 0 | case SID_OBJECT_HEAVEN: |
246 | 0 | if (rSh.GetSelectedObjCount()) |
247 | 0 | { |
248 | 0 | rSh.StartUndo( SwUndoId::START ); |
249 | 0 | SetWrapMode(FN_FRAME_WRAPTHRU); |
250 | 0 | rSh.SelectionToHeaven(); |
251 | 0 | rSh.EndUndo( SwUndoId::END ); |
252 | 0 | rBnd.Invalidate(SID_OBJECT_HELL); |
253 | 0 | } |
254 | 0 | break; |
255 | | |
256 | 0 | case FN_TOOL_HIERARCHIE: |
257 | 0 | if (rSh.GetSelectedObjCount()) |
258 | 0 | { |
259 | 0 | rSh.StartUndo( SwUndoId::START ); |
260 | 0 | if (rSh.GetLayerId() == SdrLayerID(0)) |
261 | 0 | { |
262 | 0 | SetWrapMode(FN_FRAME_WRAPTHRU); |
263 | 0 | rSh.SelectionToHeaven(); |
264 | 0 | } |
265 | 0 | else |
266 | 0 | { |
267 | 0 | SetWrapMode(FN_FRAME_WRAPTHRU_TRANSP); |
268 | 0 | rSh.SelectionToHell(); |
269 | 0 | } |
270 | 0 | rSh.EndUndo( SwUndoId::END ); |
271 | 0 | rBnd.Invalidate( SID_OBJECT_HELL ); |
272 | 0 | rBnd.Invalidate( SID_OBJECT_HEAVEN ); |
273 | 0 | } |
274 | 0 | break; |
275 | | |
276 | 0 | case SID_FLIP_VERTICAL: |
277 | 0 | bMirror = false; |
278 | 0 | [[fallthrough]]; |
279 | 0 | case SID_FLIP_HORIZONTAL: |
280 | 0 | rSh.MirrorSelection( bMirror ); |
281 | 0 | break; |
282 | | |
283 | 0 | case SID_FONTWORK: |
284 | 0 | { |
285 | 0 | FieldUnit eMetric = ::GetDfltMetric( dynamic_cast<SwWebView*>( &rSh.GetView()) != nullptr ); |
286 | 0 | SwModule::get()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) ); |
287 | 0 | SfxViewFrame& rVFrame = GetView().GetViewFrame(); |
288 | 0 | if (pArgs) |
289 | 0 | { |
290 | 0 | rVFrame.SetChildWindow(SvxFontWorkChildWindow::GetChildWindowId(), |
291 | 0 | static_cast<const SfxBoolItem&>((pArgs->Get(SID_FONTWORK))).GetValue()); |
292 | 0 | } |
293 | 0 | else |
294 | 0 | rVFrame.ToggleChildWindow( SvxFontWorkChildWindow::GetChildWindowId() ); |
295 | 0 | rVFrame.GetBindings().Invalidate(SID_FONTWORK); |
296 | 0 | } |
297 | 0 | break; |
298 | 0 | case FN_FORMAT_FOOTNOTE_DLG: |
299 | 0 | { |
300 | 0 | GetView().ExecFormatFootnote(); |
301 | 0 | break; |
302 | 0 | } |
303 | 0 | case FN_NUMBERING_OUTLINE_DLG: |
304 | 0 | { |
305 | 0 | GetView().ExecNumberingOutline(GetPool()); |
306 | 0 | rReq.Done(); |
307 | 0 | } |
308 | 0 | break; |
309 | 0 | case SID_OPEN_XML_FILTERSETTINGS: |
310 | 0 | { |
311 | 0 | HandleOpenXmlFilterSettings(rReq); |
312 | 0 | } |
313 | 0 | break; |
314 | 0 | case FN_WORDCOUNT_DIALOG: |
315 | 0 | { |
316 | 0 | GetView().UpdateWordCount(this, nSlotId); |
317 | 0 | } |
318 | 0 | break; |
319 | 0 | case SID_EXTRUSION_TOGGLE: |
320 | 0 | case SID_EXTRUSION_TILT_DOWN: |
321 | 0 | case SID_EXTRUSION_TILT_UP: |
322 | 0 | case SID_EXTRUSION_TILT_LEFT: |
323 | 0 | case SID_EXTRUSION_TILT_RIGHT: |
324 | 0 | case SID_EXTRUSION_3D_COLOR: |
325 | 0 | case SID_EXTRUSION_DEPTH: |
326 | 0 | case SID_EXTRUSION_DIRECTION: |
327 | 0 | case SID_EXTRUSION_PROJECTION: |
328 | 0 | case SID_EXTRUSION_LIGHTING_DIRECTION: |
329 | 0 | case SID_EXTRUSION_LIGHTING_INTENSITY: |
330 | 0 | case SID_EXTRUSION_SURFACE: |
331 | 0 | case SID_EXTRUSION_DEPTH_FLOATER: |
332 | 0 | case SID_EXTRUSION_DIRECTION_FLOATER: |
333 | 0 | case SID_EXTRUSION_LIGHTING_FLOATER: |
334 | 0 | case SID_EXTRUSION_SURFACE_FLOATER: |
335 | 0 | case SID_EXTRUSION_DEPTH_DIALOG: |
336 | 0 | svx::ExtrusionBar::execute( pSdrView, rReq, rBnd ); |
337 | 0 | rReq.Ignore (); |
338 | 0 | break; |
339 | | |
340 | 0 | case SID_FONTWORK_SHAPE: |
341 | 0 | case SID_FONTWORK_SHAPE_TYPE: |
342 | 0 | case SID_FONTWORK_ALIGNMENT: |
343 | 0 | case SID_FONTWORK_SAME_LETTER_HEIGHTS: |
344 | 0 | case SID_FONTWORK_CHARACTER_SPACING: |
345 | 0 | case SID_FONTWORK_KERN_CHARACTER_PAIRS: |
346 | 0 | case SID_FONTWORK_CHARACTER_SPACING_FLOATER: |
347 | 0 | case SID_FONTWORK_ALIGNMENT_FLOATER: |
348 | 0 | case SID_FONTWORK_CHARACTER_SPACING_DIALOG: |
349 | 0 | svx::FontworkBar::execute(*pSdrView, rReq, rBnd); |
350 | 0 | rReq.Ignore (); |
351 | 0 | break; |
352 | | |
353 | 0 | case SID_INSERT_GRAPHIC: |
354 | 0 | { |
355 | | // #i123922# check if we can do something |
356 | 0 | SdrObject* pObj = IsSingleFillableNonOLESelected(); |
357 | |
|
358 | 0 | if(pObj) |
359 | 0 | { |
360 | | // ...and if yes, do something |
361 | 0 | InsertPictureFromFile(*pObj); |
362 | 0 | } |
363 | |
|
364 | 0 | break; |
365 | 0 | } |
366 | | |
367 | 0 | case FN_ADD_TEXT_BOX: |
368 | 0 | { |
369 | 0 | if (SdrObject* pObj = IsSingleFillableNonOLESelected()) |
370 | 0 | { |
371 | 0 | SwFrameFormat* pFrameFormat = ::FindFrameFormat(pObj); |
372 | 0 | if (pFrameFormat) |
373 | 0 | SwTextBoxHelper::create(pFrameFormat, pObj, pObj->HasText()); |
374 | 0 | } |
375 | 0 | break; |
376 | 0 | } |
377 | 0 | case FN_REMOVE_TEXT_BOX: |
378 | 0 | { |
379 | 0 | if (SdrObject* pObj = IsSingleFillableNonOLESelected()) |
380 | 0 | { |
381 | 0 | SwFrameFormat* pFrameFormat = ::FindFrameFormat(pObj); |
382 | 0 | if (pFrameFormat) |
383 | 0 | SwTextBoxHelper::destroy(pFrameFormat, pObj); |
384 | 0 | } |
385 | 0 | break; |
386 | 0 | } |
387 | 0 | default: |
388 | 0 | OSL_ENSURE(false, "wrong dispatcher"); |
389 | 0 | return; |
390 | 0 | } |
391 | 0 | if (pSdrView->GetModel().IsChanged()) |
392 | 0 | rSh.SetModified(); |
393 | 0 | else if (bChanged) |
394 | 0 | pSdrView->GetModel().SetChanged(); |
395 | 0 | } |
396 | | |
397 | | void SwDrawShell::GetState(SfxItemSet& rSet) |
398 | 0 | { |
399 | 0 | SwWrtShell &rSh = GetShell(); |
400 | 0 | SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList(); |
401 | 0 | SfxWhichIter aIter( rSet ); |
402 | 0 | sal_uInt16 nWhich = aIter.FirstWhich(); |
403 | 0 | bool bProtected = rSh.IsSelObjProtected(FlyProtectFlags::Content) != FlyProtectFlags::NONE; |
404 | |
|
405 | 0 | if (!bProtected) // Check the parent |
406 | 0 | bProtected |= rSh.IsSelObjProtected( FlyProtectFlags::Content|FlyProtectFlags::Parent ) != FlyProtectFlags::NONE; |
407 | |
|
408 | 0 | while( nWhich ) |
409 | 0 | { |
410 | 0 | switch( nWhich ) |
411 | 0 | { |
412 | 0 | case SID_OBJECT_HELL: |
413 | 0 | if ( !rSh.GetSelectedObjCount() || rSh.GetLayerId() == SdrLayerID(0) || bProtected ) |
414 | 0 | rSet.DisableItem( nWhich ); |
415 | 0 | break; |
416 | | |
417 | 0 | case SID_OBJECT_HEAVEN: |
418 | 0 | if ( !rSh.GetSelectedObjCount() || rSh.GetLayerId() == SdrLayerID(1) || bProtected ) |
419 | 0 | rSet.DisableItem( nWhich ); |
420 | 0 | break; |
421 | | |
422 | 0 | case FN_TOOL_HIERARCHIE: |
423 | 0 | if ( !rSh.GetSelectedObjCount() || bProtected ) |
424 | 0 | rSet.DisableItem( nWhich ); |
425 | 0 | break; |
426 | | |
427 | 0 | case SID_OBJECT_ROTATE: |
428 | 0 | { |
429 | 0 | const bool bIsRotate = GetView().IsDrawRotate(); |
430 | 0 | if ( (!bIsRotate && !pSdrView->IsRotateAllowed()) || bProtected ) |
431 | 0 | rSet.DisableItem( nWhich ); |
432 | 0 | else |
433 | 0 | rSet.Put( SfxBoolItem( nWhich, bIsRotate ) ); |
434 | 0 | } |
435 | 0 | break; |
436 | | |
437 | 0 | case SID_BEZIER_EDIT: |
438 | 0 | if (!Disable(rSet, nWhich)) |
439 | 0 | rSet.Put( SfxBoolItem( nWhich, !GetView().IsDrawSelMode())); |
440 | 0 | break; |
441 | | |
442 | 0 | case SID_FLIP_VERTICAL: |
443 | 0 | if ( !pSdrView->IsMirrorAllowed() || bProtected ) |
444 | 0 | { |
445 | 0 | rSet.DisableItem( nWhich ); |
446 | 0 | } |
447 | 0 | else |
448 | 0 | { |
449 | | // TTTT - needs to be adapted in aw080: |
450 | | // state is not kept for drawing objects --> provide not flipped state |
451 | 0 | rSet.Put( SfxBoolItem( nWhich, false ) ); |
452 | 0 | } |
453 | 0 | break; |
454 | | |
455 | 0 | case SID_FLIP_HORIZONTAL: |
456 | 0 | if ( !pSdrView->IsMirrorAllowed() || bProtected ) |
457 | 0 | { |
458 | 0 | rSet.DisableItem( nWhich ); |
459 | 0 | } |
460 | 0 | else |
461 | 0 | { |
462 | | // TTTT - needs to be adapted in aw080: |
463 | | // state is not kept for drawing objects --> provide not flipped state |
464 | 0 | rSet.Put( SfxBoolItem( nWhich, false ) ); |
465 | 0 | } |
466 | 0 | break; |
467 | | |
468 | 0 | case SID_FONTWORK: |
469 | 0 | { |
470 | 0 | if (bProtected) |
471 | 0 | rSet.DisableItem( nWhich ); |
472 | 0 | else |
473 | 0 | { |
474 | 0 | const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId(); |
475 | 0 | rSet.Put(SfxBoolItem( nWhich , GetView().GetViewFrame().HasChildWindow(nId))); |
476 | 0 | } |
477 | 0 | } |
478 | 0 | break; |
479 | | |
480 | 0 | case SID_INSERT_GRAPHIC: |
481 | 0 | { |
482 | | // #i123922# check if we can do something |
483 | 0 | SdrObject* pObj = IsSingleFillableNonOLESelected(); |
484 | |
|
485 | 0 | if(!pObj) |
486 | 0 | { |
487 | 0 | rSet.DisableItem(nWhich); |
488 | 0 | } |
489 | |
|
490 | 0 | break; |
491 | 0 | } |
492 | 0 | case FN_ADD_TEXT_BOX: |
493 | 0 | { |
494 | 0 | bool bDisable = true; |
495 | 0 | if (SdrObject* pObj = IsSingleFillableNonOLESelected()) |
496 | 0 | { |
497 | 0 | SwFrameFormat* pFrameFormat = ::FindFrameFormat(pObj); |
498 | | // Allow creating a TextBox only in case this is a draw format without a TextBox so far. |
499 | 0 | if (pFrameFormat && pFrameFormat->Which() == RES_DRAWFRMFMT && !SwTextBoxHelper::isTextBox(pFrameFormat, RES_DRAWFRMFMT, pObj)) |
500 | 0 | { |
501 | 0 | if (SdrObjCustomShape* pCustomShape = dynamic_cast<SdrObjCustomShape*>( pObj) ) |
502 | 0 | { |
503 | 0 | const SdrCustomShapeGeometryItem& rGeometryItem = pCustomShape->GetMergedItem(SDRATTR_CUSTOMSHAPE_GEOMETRY); |
504 | 0 | if (const uno::Any* pAny = rGeometryItem.GetPropertyValueByName(u"Type"_ustr)) |
505 | | // But still disallow fontwork shapes. |
506 | 0 | bDisable = pAny->get<OUString>().startsWith("fontwork-"); |
507 | 0 | } |
508 | 0 | } |
509 | 0 | } |
510 | |
|
511 | 0 | if (bDisable) |
512 | 0 | rSet.DisableItem(nWhich); |
513 | 0 | break; |
514 | 0 | } |
515 | 0 | case FN_REMOVE_TEXT_BOX: |
516 | 0 | { |
517 | 0 | bool bDisable = true; |
518 | 0 | if (SdrObject* pObj = IsSingleFillableNonOLESelected()) |
519 | 0 | { |
520 | 0 | SwFrameFormat* pFrameFormat = ::FindFrameFormat(pObj); |
521 | | // Allow removing a TextBox only in case it has one. |
522 | 0 | if (pFrameFormat && SwTextBoxHelper::isTextBox(pFrameFormat, RES_DRAWFRMFMT, pObj)) |
523 | 0 | bDisable = false; |
524 | 0 | } |
525 | |
|
526 | 0 | if (bDisable) |
527 | 0 | rSet.DisableItem(nWhich); |
528 | 0 | break; |
529 | 0 | } |
530 | 0 | } |
531 | 0 | nWhich = aIter.NextWhich(); |
532 | 0 | } |
533 | 0 | svx::ExtrusionBar::getState( pSdrView, rSet ); |
534 | 0 | svx::FontworkBar::getState( pSdrView, rSet ); |
535 | 0 | } |
536 | | |
537 | | SwDrawShell::SwDrawShell(SwView &_rView) : |
538 | 0 | SwDrawBaseShell(_rView) |
539 | 0 | { |
540 | 0 | SetName(u"Draw"_ustr); |
541 | |
|
542 | 0 | vcl::EnumContext::Context eContext = vcl::EnumContext::Context::Draw; |
543 | |
|
544 | 0 | SwWrtShell &rSh = GetShell(); |
545 | 0 | SdrView* pDrView = rSh.GetDrawView(); |
546 | |
|
547 | 0 | if (pDrView && svx::checkForSelectedFontWork(pDrView)) |
548 | 0 | eContext = vcl::EnumContext::Context::DrawFontwork; |
549 | |
|
550 | 0 | SfxShell::SetContextName(vcl::EnumContext::GetContextName(eContext)); |
551 | 0 | } |
552 | | |
553 | | // Edit SfxRequests for FontWork |
554 | | |
555 | | void SwDrawShell::ExecFormText(SfxRequest const & rReq) |
556 | 0 | { |
557 | 0 | SwWrtShell &rSh = GetShell(); |
558 | 0 | SdrView* pDrView = rSh.GetDrawView(); |
559 | 0 | bool bChanged = pDrView->GetModel().IsChanged(); |
560 | 0 | pDrView->GetModel().SetChanged(false); |
561 | |
|
562 | 0 | const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); |
563 | |
|
564 | 0 | if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() ) |
565 | 0 | { |
566 | 0 | const SfxItemSet& rSet = *rReq.GetArgs(); |
567 | |
|
568 | 0 | if ( pDrView->IsTextEdit() ) |
569 | 0 | { |
570 | 0 | pDrView->SdrEndTextEdit( true ); |
571 | 0 | GetView().AttrChangedNotify(nullptr); |
572 | 0 | } |
573 | |
|
574 | 0 | pDrView->SetAttributes(rSet); |
575 | 0 | } |
576 | 0 | if (pDrView->GetModel().IsChanged()) |
577 | 0 | rSh.SetModified(); |
578 | 0 | else |
579 | 0 | if (bChanged) |
580 | 0 | pDrView->GetModel().SetChanged(); |
581 | 0 | } |
582 | | |
583 | | //Return status values for FontWork |
584 | | |
585 | | void SwDrawShell::GetFormTextState(SfxItemSet& rSet) |
586 | 0 | { |
587 | 0 | SwWrtShell &rSh = GetShell(); |
588 | 0 | SdrView* pDrView = rSh.GetDrawView(); |
589 | 0 | const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); |
590 | 0 | const SdrObject* pObj = nullptr; |
591 | |
|
592 | 0 | if ( rMarkList.GetMarkCount() == 1 ) |
593 | 0 | pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); |
594 | |
|
595 | 0 | const SdrTextObj* pTextObj = DynCastSdrTextObj(pObj); |
596 | 0 | const bool bDeactivate( |
597 | 0 | !pObj || |
598 | 0 | !pTextObj || |
599 | 0 | !pTextObj->HasText() || |
600 | 0 | dynamic_cast< const SdrObjCustomShape* >(pObj)); // #121538# no FontWork for CustomShapes |
601 | |
|
602 | 0 | if(bDeactivate) |
603 | 0 | { |
604 | 0 | rSet.DisableItem(XATTR_FORMTXTSTYLE); |
605 | 0 | rSet.DisableItem(XATTR_FORMTXTADJUST); |
606 | 0 | rSet.DisableItem(XATTR_FORMTXTDISTANCE); |
607 | 0 | rSet.DisableItem(XATTR_FORMTXTSTART); |
608 | 0 | rSet.DisableItem(XATTR_FORMTXTMIRROR); |
609 | 0 | rSet.DisableItem(XATTR_FORMTXTHIDEFORM); |
610 | 0 | rSet.DisableItem(XATTR_FORMTXTOUTLINE); |
611 | 0 | rSet.DisableItem(XATTR_FORMTXTSHADOW); |
612 | 0 | rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR); |
613 | 0 | rSet.DisableItem(XATTR_FORMTXTSHDWXVAL); |
614 | 0 | rSet.DisableItem(XATTR_FORMTXTSHDWYVAL); |
615 | 0 | } |
616 | 0 | else |
617 | 0 | { |
618 | 0 | pDrView->GetAttributes( rSet ); |
619 | 0 | } |
620 | 0 | } |
621 | | |
622 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |