Coverage Report

Created: 2026-10-14 09:33

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