Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/source/ui/drawfunc/drawsh5.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 <editeng/eeitem.hxx>
21
22
#include <sfx2/viewfrm.hxx>
23
#include <sfx2/request.hxx>
24
#include <sfx2/bindings.hxx>
25
#include <tools/urlobj.hxx>
26
#include <cliputil.hxx>
27
#include <svx/svxdlg.hxx>
28
#include <svx/hlnkitem.hxx>
29
#include <svx/svdoole2.hxx>
30
#include <svx/svdouno.hxx>
31
#include <svx/extrusionbar.hxx>
32
#include <svx/fontworkbar.hxx>
33
#include <svx/svdogrp.hxx>
34
#include <sfx2/docfile.hxx>
35
#include <osl/diagnose.h>
36
#include <svx/diagram/DiagramHelper_svx.hxx>
37
38
#include <com/sun/star/form/FormButtonType.hpp>
39
#include <com/sun/star/beans/XPropertySet.hpp>
40
#include <com/sun/star/beans/XPropertySetInfo.hpp>
41
42
#include <drawsh.hxx>
43
#include <drawview.hxx>
44
#include <viewdata.hxx>
45
#include <tabvwsh.hxx>
46
#include <docsh.hxx>
47
#include <undotab.hxx>
48
#include <drwlayer.hxx>
49
#include <drtxtob.hxx>
50
#include <memory>
51
52
#include <sc.hrc>
53
54
using namespace com::sun::star;
55
56
void ScDrawShell::GetHLinkState( SfxItemSet& rSet )             //  Hyperlink
57
0
{
58
0
    ScDrawView* pView = rViewData.GetScDrawView();
59
0
    const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
60
61
        //  Hyperlink
62
63
0
    SvxHyperlinkItem aHLinkItem;
64
0
    aHLinkItem.SetShowName(false);
65
0
    aHLinkItem.SetShowText(false);
66
67
0
    if ( rMarkList.GetMarkCount() == 1 )              // URL-Button marked ?
68
0
    {
69
0
        SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
70
0
        if ( pObj && !pObj->getHyperlink().isEmpty() )
71
0
        {
72
0
            aHLinkItem.SetURL( pObj->getHyperlink() );
73
0
            aHLinkItem.SetInsertMode(HLINK_FIELD);
74
0
        }
75
0
        SdrUnoObj* pUnoCtrl = dynamic_cast<SdrUnoObj*>( pObj );
76
0
        if (pUnoCtrl && SdrInventor::FmForm == pUnoCtrl->GetObjInventor())
77
0
        {
78
0
            const uno::Reference<awt::XControlModel>& xControlModel = pUnoCtrl->GetUnoControlModel();
79
0
            OSL_ENSURE( xControlModel.is(), "UNO-Control without model" );
80
0
            if( !xControlModel.is() )
81
0
                return;
82
83
0
            uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
84
0
            uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
85
86
0
            OUString sPropButtonType( u"ButtonType"_ustr );
87
88
0
            if(xInfo->hasPropertyByName( sPropButtonType ))
89
0
            {
90
0
                uno::Any aAny = xPropSet->getPropertyValue( sPropButtonType );
91
0
                form::FormButtonType eTmp;
92
0
                if ( (aAny >>= eTmp) && eTmp == form::FormButtonType_URL )
93
0
                {
94
0
                    OUString sTmp;
95
                    // Label
96
0
                    OUString sPropLabel( u"Label"_ustr );
97
0
                    if(xInfo->hasPropertyByName( sPropLabel ))
98
0
                    {
99
0
                        aAny = xPropSet->getPropertyValue( sPropLabel );
100
0
                        if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
101
0
                        {
102
0
                            aHLinkItem.SetName(sTmp);
103
0
                        }
104
0
                    }
105
                    // URL
106
0
                    OUString sPropTargetURL( u"TargetURL"_ustr );
107
0
                    if(xInfo->hasPropertyByName( sPropTargetURL ))
108
0
                    {
109
0
                        aAny = xPropSet->getPropertyValue( sPropTargetURL );
110
0
                        if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
111
0
                        {
112
0
                            aHLinkItem.SetURL(sTmp);
113
0
                        }
114
0
                    }
115
                    // Target
116
0
                    OUString sPropTargetFrame( u"TargetFrame"_ustr );
117
0
                    if(xInfo->hasPropertyByName( sPropTargetFrame ))
118
0
                    {
119
0
                        aAny = xPropSet->getPropertyValue( sPropTargetFrame );
120
0
                        if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
121
0
                        {
122
0
                            aHLinkItem.SetTargetFrame(sTmp);
123
0
                        }
124
0
                    }
125
0
                    aHLinkItem.SetInsertMode(HLINK_BUTTON);
126
0
                }
127
0
            }
128
0
        }
129
0
    }
130
131
0
    rSet.Put(aHLinkItem);
132
0
}
133
134
void ScDrawShell::ExecuteHLink( const SfxRequest& rReq )
135
0
{
136
0
    const SfxItemSet* pReqArgs = rReq.GetArgs();
137
138
0
    sal_uInt16 nSlot = rReq.GetSlot();
139
0
    switch ( nSlot )
140
0
    {
141
0
        case SID_HYPERLINK_SETLINK:
142
0
            if( pReqArgs )
143
0
            {
144
0
                const SfxPoolItem* pItem;
145
0
                if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, true, &pItem ) == SfxItemState::SET )
146
0
                {
147
0
                    const SvxHyperlinkItem* pHyper = static_cast<const SvxHyperlinkItem*>(pItem);
148
0
                    const OUString& rName     = pHyper->GetName();
149
0
                    const OUString& rURL      = pHyper->GetURL();
150
0
                    const OUString& rTarget   = pHyper->GetTargetFrame();
151
0
                    SvxLinkInsertMode eMode = pHyper->GetInsertMode();
152
153
0
                    bool bDone = false;
154
0
                    if ( eMode == HLINK_FIELD || eMode == HLINK_BUTTON )
155
0
                    {
156
0
                        ScDrawView* pView = rViewData.GetScDrawView();
157
0
                        const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
158
0
                        if ( rMarkList.GetMarkCount() == 1 )
159
0
                        {
160
0
                            SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
161
0
                            SdrUnoObj* pUnoCtrl = dynamic_cast<SdrUnoObj*>( pObj  );
162
0
                            if (pUnoCtrl && SdrInventor::FmForm == pUnoCtrl->GetObjInventor())
163
0
                            {
164
0
                                const uno::Reference<awt::XControlModel>& xControlModel =
165
0
                                                        pUnoCtrl->GetUnoControlModel();
166
0
                                OSL_ENSURE( xControlModel.is(), "UNO-Control without model" );
167
0
                                if( !xControlModel.is() )
168
0
                                    return;
169
170
0
                                uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
171
0
                                uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
172
173
0
                                OUString sPropTargetURL( u"TargetURL"_ustr );
174
175
                                // Is it possible to set a URL in the object?
176
0
                                if (xInfo->hasPropertyByName( sPropTargetURL ))
177
0
                                {
178
179
0
                                    OUString sPropButtonType( u"ButtonType"_ustr);
180
0
                                    OUString sPropTargetFrame( u"TargetFrame"_ustr );
181
0
                                    OUString sPropLabel( u"Label"_ustr );
182
183
0
                                    if ( xInfo->hasPropertyByName( sPropLabel ) )
184
0
                                    {
185
0
                                        xPropSet->setPropertyValue( sPropLabel, uno::Any(rName) );
186
0
                                    }
187
188
0
                                    OUString aTmp = INetURLObject::GetAbsURL( rViewData.GetDocShell()->GetMedium()->GetBaseURL(), rURL );
189
0
                                    xPropSet->setPropertyValue( sPropTargetURL, uno::Any(aTmp) );
190
191
0
                                    if( !rTarget.isEmpty() && xInfo->hasPropertyByName( sPropTargetFrame ) )
192
0
                                    {
193
0
                                        xPropSet->setPropertyValue( sPropTargetFrame, uno::Any(rTarget) );
194
0
                                    }
195
196
0
                                    if ( xInfo->hasPropertyByName( sPropButtonType ) )
197
0
                                    {
198
0
                                        xPropSet->setPropertyValue( sPropButtonType, uno::Any(form::FormButtonType_URL) );
199
0
                                    }
200
201
                                    //! Undo ???
202
0
                                    rViewData.GetDocShell()->SetDocumentModified();
203
0
                                    bDone = true;
204
0
                                }
205
0
                            }
206
0
                            else
207
0
                            {
208
0
                                pObj->setHyperlink(rURL);
209
0
                                setModified();
210
0
                                bDone = true;
211
0
                            }
212
0
                        }
213
0
                    }
214
215
0
                    if (!bDone)
216
0
                        rViewData.GetViewShell()->
217
0
                            InsertURL( rName, rURL, rTarget, static_cast<sal_uInt16>(eMode) );
218
219
                    //  If "text" is received by InsertURL of ViewShell, then the DrawShell is turned off !!!
220
0
                }
221
0
            }
222
0
            break;
223
0
        default:
224
0
            OSL_FAIL("wrong slot");
225
0
    }
226
0
}
227
228
//          Functions on Drawing-Objects
229
230
void ScDrawShell::ExecDrawFunc( SfxRequest& rReq )
231
0
{
232
0
    SfxBindings& rBindings = rViewData.GetBindings();
233
0
    ScTabView*   pTabView  = rViewData.GetView();
234
0
    ScDrawView*  pView     = pTabView->GetScDrawView();
235
0
    sal_uInt16 nSlotId = rReq.GetSlot();
236
237
0
    switch (nSlotId)
238
0
    {
239
0
        case SID_OBJECT_HEAVEN:
240
0
            pView->SetMarkedToLayer( SC_LAYER_FRONT );
241
0
            rBindings.Invalidate(SID_OBJECT_HEAVEN);
242
0
            rBindings.Invalidate(SID_OBJECT_HELL);
243
0
            break;
244
0
        case SID_OBJECT_HELL:
245
0
            pView->SetMarkedToLayer( SC_LAYER_BACK );
246
0
            rBindings.Invalidate(SID_OBJECT_HEAVEN);
247
0
            rBindings.Invalidate(SID_OBJECT_HELL);
248
            //  leave draw shell if nothing selected (layer may be locked)
249
0
            rViewData.GetViewShell()->UpdateDrawShell();
250
0
            break;
251
252
0
        case SID_FRAME_TO_TOP:
253
0
            pView->PutMarkedToTop();
254
0
            break;
255
0
        case SID_FRAME_TO_BOTTOM:
256
0
            pView->PutMarkedToBtm();
257
0
            break;
258
0
        case SID_FRAME_UP:
259
0
            pView->MovMarkedToTop();
260
0
            break;
261
0
        case SID_FRAME_DOWN:
262
0
            pView->MovMarkedToBtm();
263
0
            break;
264
265
0
        case SID_GROUP:
266
0
            pView->GroupMarked();
267
0
            break;
268
0
        case SID_UNGROUP:
269
0
            pView->UnGroupMarked();
270
0
            break;
271
0
        case SID_ENTER_GROUP:
272
0
            pView->EnterMarkedGroup();
273
0
            break;
274
0
        case SID_LEAVE_GROUP:
275
0
            pView->LeaveOneGroup();
276
0
            break;
277
278
0
        case SID_REGENERATE_DIAGRAM:
279
0
        case SID_DIAGRAM_TO_GROUP:
280
0
        case SID_EDIT_DIAGRAM:
281
0
            {
282
0
                const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
283
284
0
                if (1 == rMarkList.GetMarkCount())
285
0
                {
286
0
                    SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
287
288
                    // Support advanced DiagramHelper
289
0
                    if(nullptr != pObj && pObj->isDiagram())
290
0
                    {
291
0
                        if(SID_REGENERATE_DIAGRAM == nSlotId)
292
0
                        {
293
0
                            pView->UnmarkAll();
294
0
                            pObj->getDiagramHelper()->reLayout();
295
0
                            pView->MarkObj(pObj, pView->GetSdrPageView());
296
0
                        }
297
0
                        else if (SID_EDIT_DIAGRAM == nSlotId)
298
0
                        {
299
0
                            VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create();
300
0
                            vcl::Window* pWin = rViewData.GetActiveWin();
301
0
                            VclPtr<VclAbstractDialog> pDlg = pFact->CreateDiagramDialog(
302
0
                                pWin ? pWin->GetFrameWeld() : nullptr,
303
0
                                *static_cast<SdrObjGroup*>(pObj));
304
0
                            pDlg->StartExecuteAsync(
305
0
                                [pDlg] (sal_Int32 /*nResult*/)->void
306
0
                                {
307
0
                                    pDlg->disposeOnce();
308
0
                                }
309
0
                            );
310
0
                        }
311
0
                        else // SID_DIAGRAM_TO_GROUP
312
0
                        {
313
0
                            pView->UnmarkAll();
314
0
                            pObj->getDiagramHelper()->disconnectFromSdrObjGroup(true);
315
0
                            pView->MarkObj(pObj, pView->GetSdrPageView());
316
0
                        }
317
0
                    }
318
0
                }
319
320
0
                rReq.Done();
321
0
            }
322
0
            break;
323
324
0
        case SID_MIRROR_HORIZONTAL:
325
0
        case SID_FLIP_HORIZONTAL:
326
0
            pView->MirrorAllMarkedHorizontal();
327
0
            rBindings.Invalidate( SID_ATTR_TRANSFORM_ANGLE );
328
0
            break;
329
0
        case SID_MIRROR_VERTICAL:
330
0
        case SID_FLIP_VERTICAL:
331
0
            pView->MirrorAllMarkedVertical();
332
0
            rBindings.Invalidate( SID_ATTR_TRANSFORM_ANGLE );
333
0
            break;
334
335
0
        case SID_OBJECT_ALIGN_LEFT:
336
0
        case SID_ALIGN_ANY_LEFT:
337
0
            if (pView->IsAlignPossible())
338
0
                pView->AlignMarkedObjects(SdrHorAlign::Left, SdrVertAlign::NONE);
339
0
            break;
340
0
        case SID_OBJECT_ALIGN_CENTER:
341
0
        case SID_ALIGN_ANY_HCENTER:
342
0
            if (pView->IsAlignPossible())
343
0
                pView->AlignMarkedObjects(SdrHorAlign::Center, SdrVertAlign::NONE);
344
0
            break;
345
0
        case SID_OBJECT_ALIGN_RIGHT:
346
0
        case SID_ALIGN_ANY_RIGHT:
347
0
            if (pView->IsAlignPossible())
348
0
                pView->AlignMarkedObjects(SdrHorAlign::Right, SdrVertAlign::NONE);
349
0
            break;
350
0
        case SID_OBJECT_ALIGN_UP:
351
0
        case SID_ALIGN_ANY_TOP:
352
0
            if (pView->IsAlignPossible())
353
0
                pView->AlignMarkedObjects(SdrHorAlign::NONE, SdrVertAlign::Top);
354
0
            break;
355
0
        case SID_OBJECT_ALIGN_MIDDLE:
356
0
        case SID_ALIGN_ANY_VCENTER:
357
0
            if (pView->IsAlignPossible())
358
0
                pView->AlignMarkedObjects(SdrHorAlign::NONE, SdrVertAlign::Center);
359
0
            break;
360
0
        case SID_OBJECT_ALIGN_DOWN:
361
0
        case SID_ALIGN_ANY_BOTTOM:
362
0
            if (pView->IsAlignPossible())
363
0
                pView->AlignMarkedObjects(SdrHorAlign::NONE, SdrVertAlign::Bottom);
364
0
            break;
365
366
0
        case SID_DELETE:
367
0
        case SID_DELETE_CONTENTS:
368
0
            pView->DeleteMarked();
369
0
            rViewData.GetViewShell()->UpdateDrawShell();
370
0
        break;
371
372
0
        case SID_CUT:
373
0
            pView->DoCut();
374
0
            rViewData.GetViewShell()->UpdateDrawShell();
375
0
            break;
376
377
0
        case SID_COPY:
378
0
            pView->DoCopy();
379
0
            break;
380
381
0
        case SID_PASTE:
382
0
            ScClipUtil::PasteFromClipboard(GetViewData(), GetViewData().GetViewShell(), true);
383
0
            break;
384
385
0
        case SID_SELECTALL:
386
0
            pView->MarkAll();
387
0
            break;
388
389
0
        case SID_ANCHOR_PAGE:
390
0
            pView->SetPageAnchored();
391
0
            rBindings.Invalidate( SID_ANCHOR_PAGE );
392
0
            rBindings.Invalidate( SID_ANCHOR_CELL );
393
0
            rBindings.Invalidate( SID_ANCHOR_CELL_RESIZE );
394
0
            break;
395
396
0
        case SID_ANCHOR_CELL:
397
0
            pView->SetCellAnchored(false);
398
0
            rBindings.Invalidate( SID_ANCHOR_PAGE );
399
0
            rBindings.Invalidate( SID_ANCHOR_CELL );
400
0
            rBindings.Invalidate( SID_ANCHOR_CELL_RESIZE );
401
0
            break;
402
403
0
        case SID_ANCHOR_CELL_RESIZE:
404
0
            pView->SetCellAnchored(true);
405
0
            rBindings.Invalidate( SID_ANCHOR_PAGE );
406
0
            rBindings.Invalidate( SID_ANCHOR_CELL );
407
0
            rBindings.Invalidate( SID_ANCHOR_CELL_RESIZE );
408
0
            break;
409
410
0
        case SID_ANCHOR_TOGGLE:
411
0
            {
412
0
                switch( pView->GetAnchorType() )
413
0
                {
414
0
                    case SCA_CELL:
415
0
                    case SCA_CELL_RESIZE:
416
0
                    pView->SetPageAnchored();
417
0
                    break;
418
0
                    default:
419
0
                    pView->SetCellAnchored(false);
420
0
                    break;
421
0
                }
422
0
            }
423
0
            rBindings.Invalidate( SID_ANCHOR_PAGE );
424
0
            rBindings.Invalidate( SID_ANCHOR_CELL );
425
0
            rBindings.Invalidate( SID_ANCHOR_CELL_RESIZE );
426
0
            break;
427
428
0
        case SID_OBJECT_ROTATE:
429
0
            rViewData.GetViewShell()->SwitchRotateMode();
430
0
            break;
431
0
        case SID_OBJECT_MIRROR:
432
0
            {
433
0
                SdrDragMode eMode;
434
0
                if (pView->GetDragMode() == SdrDragMode::Mirror)
435
0
                    eMode = SdrDragMode::Move;
436
0
                else
437
0
                    eMode = SdrDragMode::Mirror;
438
0
                pView->SetDragMode( eMode );
439
0
                rBindings.Invalidate( SID_OBJECT_ROTATE );
440
0
                rBindings.Invalidate( SID_OBJECT_MIRROR );
441
0
                if (eMode == SdrDragMode::Mirror && !pView->IsFrameDragSingles())
442
0
                {
443
0
                    pView->SetFrameDragSingles();
444
0
                    rBindings.Invalidate( SID_BEZIER_EDIT );
445
0
                }
446
0
            }
447
0
            break;
448
0
        case SID_BEZIER_EDIT:
449
0
            {
450
0
                bool bOld = pView->IsFrameDragSingles();
451
0
                pView->SetFrameDragSingles( !bOld );
452
0
                rBindings.Invalidate( SID_BEZIER_EDIT );
453
0
                if (bOld && pView->GetDragMode() != SdrDragMode::Move)
454
0
                {
455
0
                    pView->SetDragMode( SdrDragMode::Move );
456
0
                    rBindings.Invalidate( SID_OBJECT_ROTATE );
457
0
                    rBindings.Invalidate( SID_OBJECT_MIRROR );
458
0
                }
459
0
            }
460
0
            break;
461
462
0
        case SID_FONTWORK:
463
0
        {
464
0
            sal_uInt16 nId = ScGetFontWorkId();
465
0
            SfxViewFrame& rViewFrm = rViewData.GetViewShell()->GetViewFrame();
466
467
0
            if ( rReq.GetArgs() )
468
0
                rViewFrm.SetChildWindow( nId,
469
0
                                           static_cast<const SfxBoolItem&>(
470
0
                                            (rReq.GetArgs()->Get(SID_FONTWORK))).
471
0
                                                GetValue() );
472
0
            else
473
0
                rViewFrm.ToggleChildWindow( nId );
474
475
0
            rBindings.Invalidate( SID_FONTWORK );
476
0
            rReq.Done();
477
0
        }
478
0
        break;
479
480
0
        case SID_ORIGINALSIZE:
481
0
            pView->SetMarkedOriginalSize();
482
0
            break;
483
484
0
        case SID_FITCELLSIZE:
485
0
            pView->FitToCellSize();
486
0
            break;
487
488
0
        case SID_ENABLE_HYPHENATION:
489
0
            {
490
0
                const SfxBoolItem* pItem = rReq.GetArg<SfxBoolItem>(SID_ENABLE_HYPHENATION);
491
0
                if( pItem )
492
0
                {
493
0
                    SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<EE_PARA_HYPHENATE, EE_PARA_HYPHENATE>( GetPool() ));
494
0
                    bool bValue = pItem->GetValue();
495
0
                    aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
496
0
                    pView->SetAttributes( aSet );
497
0
                }
498
0
                rReq.Done();
499
0
            }
500
0
            break;
501
502
0
        case SID_RENAME_OBJECT:
503
0
            {
504
0
                const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
505
0
                if(1 == rMarkList.GetMarkCount())
506
0
                {
507
                    // #i68101#
508
0
                    SdrObject* pSelected = rMarkList.GetMark(0)->GetMarkedSdrObj();
509
0
                    assert(pSelected && "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)");
510
511
0
                    if(SC_LAYER_INTERN != pSelected->GetLayer())
512
0
                    {
513
0
                        OUString aOldName = pSelected->GetName();
514
515
0
                        SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
516
0
                        vcl::Window* pWin = rViewData.GetActiveWin();
517
0
                        VclPtr<AbstractSvxObjectNameDialog> pDlg(pFact->CreateSvxObjectNameDialog(pWin ? pWin->GetFrameWeld() : nullptr, aOldName));
518
519
0
                        pDlg->SetCheckNameHdl(LINK(this, ScDrawShell, NameObjectHdl));
520
521
0
                        pDlg->StartExecuteAsync(
522
0
                            [this, pDlg, pSelected] (sal_Int32 nResult)->void
523
0
                            {
524
0
                                if (nResult == RET_OK)
525
0
                                {
526
0
                                    ScDocShell* pDocSh = rViewData.GetDocShell();
527
0
                                    OUString aNewName = pDlg->GetName();
528
529
0
                                    if (aNewName != pSelected->GetName())
530
0
                                    {
531
                                        // handle name change
532
0
                                        const SdrObjKind nObjType(pSelected->GetObjIdentifier());
533
534
0
                                        if (SdrObjKind::Graphic == nObjType && aNewName.isEmpty())
535
0
                                        {
536
                                            //  graphics objects must have names
537
                                            //  (all graphics are supposed to be in the navigator)
538
0
                                            ScDrawLayer* pModel = rViewData.GetDocument().GetDrawLayer();
539
540
0
                                            if(pModel)
541
0
                                            {
542
0
                                                aNewName = pModel->GetNewGraphicName();
543
0
                                            }
544
0
                                        }
545
546
                                        //  An undo action for renaming is missing in svdraw (99363).
547
                                        //  For OLE objects (which can be identified using the persist name),
548
                                        //  ScUndoRenameObject can be used until there is a common action for all objects.
549
0
                                        if(SdrObjKind::OLE2 == nObjType)
550
0
                                        {
551
0
                                            const OUString aPersistName = static_cast<SdrOle2Obj*>(pSelected)->GetPersistName();
552
553
0
                                            if(!aPersistName.isEmpty())
554
0
                                            {
555
0
                                                pDocSh->GetUndoManager()->AddUndoAction(
556
0
                                                    std::make_unique<ScUndoRenameObject>(*pDocSh, aPersistName, pSelected->GetName(), aNewName));
557
0
                                            }
558
0
                                        }
559
560
                                        // set new name
561
0
                                        pSelected->SetName(aNewName);
562
0
                                    }
563
564
                                    // ChartListenerCollectionNeedsUpdate is needed for Navigator update
565
0
                                    pDocSh->GetDocument().SetChartListenerCollectionNeedsUpdate( true );
566
0
                                    pDocSh->SetDrawModified();
567
0
                                }
568
0
                                pDlg->disposeOnce();
569
0
                            }
570
0
                        );
571
0
                    }
572
0
                }
573
0
                break;
574
0
            }
575
576
        // #i68101#
577
0
        case SID_TITLE_DESCRIPTION_OBJECT:
578
0
            {
579
0
                const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
580
0
                if(1 == rMarkList.GetMarkCount())
581
0
                {
582
0
                    SdrObject* pSelected = rMarkList.GetMark(0)->GetMarkedSdrObj();
583
0
                    assert(pSelected && "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)");
584
585
0
                    if(SC_LAYER_INTERN != pSelected->GetLayer())
586
0
                    {
587
0
                        OUString aTitle(pSelected->GetTitle());
588
0
                        OUString aDescription(pSelected->GetDescription());
589
0
                        bool isDecorative(pSelected->IsDecorative());
590
591
0
                        SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
592
0
                        vcl::Window* pWin = rViewData.GetActiveWin();
593
0
                        VclPtr<AbstractSvxObjectTitleDescDialog> pDlg(pFact->CreateSvxObjectTitleDescDialog(
594
0
                                    pWin ? pWin->GetFrameWeld() : nullptr, aTitle, aDescription, isDecorative));
595
596
0
                        pDlg->StartExecuteAsync(
597
0
                            [this, pDlg, pSelected] (sal_Int32 nResult)->void
598
0
                            {
599
0
                                if (nResult == RET_OK)
600
0
                                {
601
0
                                    ScDocShell* pDocSh = rViewData.GetDocShell();
602
603
                                    // handle Title and Description
604
0
                                    pSelected->SetTitle(pDlg->GetTitle());
605
0
                                    pSelected->SetDescription(pDlg->GetDescription());
606
0
                                    pSelected->SetDecorative(pDlg->IsDecorative());
607
608
                                    // ChartListenerCollectionNeedsUpdate is needed for Navigator update
609
0
                                    pDocSh->GetDocument().SetChartListenerCollectionNeedsUpdate( true );
610
0
                                    pDocSh->SetDrawModified();
611
0
                                }
612
0
                                pDlg->disposeOnce();
613
0
                            }
614
0
                        );
615
0
                    }
616
0
                }
617
0
                break;
618
0
            }
619
620
0
        case SID_EXTRUSION_TOGGLE:
621
0
        case SID_EXTRUSION_TILT_DOWN:
622
0
        case SID_EXTRUSION_TILT_UP:
623
0
        case SID_EXTRUSION_TILT_LEFT:
624
0
        case SID_EXTRUSION_TILT_RIGHT:
625
0
        case SID_EXTRUSION_3D_COLOR:
626
0
        case SID_EXTRUSION_DEPTH:
627
0
        case SID_EXTRUSION_DIRECTION:
628
0
        case SID_EXTRUSION_PROJECTION:
629
0
        case SID_EXTRUSION_LIGHTING_DIRECTION:
630
0
        case SID_EXTRUSION_LIGHTING_INTENSITY:
631
0
        case SID_EXTRUSION_SURFACE:
632
0
        case SID_EXTRUSION_DEPTH_FLOATER:
633
0
        case SID_EXTRUSION_DIRECTION_FLOATER:
634
0
        case SID_EXTRUSION_LIGHTING_FLOATER:
635
0
        case SID_EXTRUSION_SURFACE_FLOATER:
636
0
        case SID_EXTRUSION_DEPTH_DIALOG:
637
0
            svx::ExtrusionBar::execute( pView, rReq, rBindings );
638
0
            rReq.Ignore ();
639
0
            break;
640
641
0
        case SID_FONTWORK_SHAPE:
642
0
        case SID_FONTWORK_SHAPE_TYPE:
643
0
        case SID_FONTWORK_ALIGNMENT:
644
0
        case SID_FONTWORK_SAME_LETTER_HEIGHTS:
645
0
        case SID_FONTWORK_CHARACTER_SPACING:
646
0
        case SID_FONTWORK_KERN_CHARACTER_PAIRS:
647
0
        case SID_FONTWORK_CHARACTER_SPACING_FLOATER:
648
0
        case SID_FONTWORK_ALIGNMENT_FLOATER:
649
0
        case SID_FONTWORK_CHARACTER_SPACING_DIALOG:
650
0
            svx::FontworkBar::execute( *pView, rReq, rBindings );
651
0
            rReq.Ignore ();
652
0
            break;
653
654
0
        default:
655
0
            break;
656
0
    }
657
0
}
658
659
IMPL_LINK( ScDrawShell, NameObjectHdl, AbstractSvxObjectNameDialog&, rDialog, bool )
660
0
{
661
0
    OUString aName = rDialog.GetName();
662
663
0
    ScDrawLayer* pModel = rViewData.GetDocument().GetDrawLayer();
664
0
    if ( !aName.isEmpty() && pModel )
665
0
    {
666
0
        SCTAB nDummyTab;
667
0
        if ( pModel->GetNamedObject( aName, SdrObjKind::NONE, nDummyTab ) )
668
0
        {
669
            // existing object found -> name invalid
670
0
            return false;
671
0
        }
672
0
    }
673
674
0
    return true;   // name is valid
675
0
}
676
677
void ScDrawShell::ExecFormText(const SfxRequest& rReq)
678
0
{
679
0
    ScDrawView*         pDrView     = rViewData.GetScDrawView();
680
0
    const SdrMarkList&  rMarkList   = pDrView->GetMarkedObjectList();
681
682
0
    if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
683
0
    {
684
0
        const SfxItemSet& rSet = *rReq.GetArgs();
685
686
0
        if ( pDrView->IsTextEdit() )
687
0
            pDrView->ScEndTextEdit();
688
689
0
        pDrView->SetAttributes(rSet);
690
0
    }
691
0
}
692
693
void ScDrawShell::ExecFormatPaintbrush( const SfxRequest& rReq )
694
0
{
695
0
    ScViewFunc* pView = rViewData.GetView();
696
0
    if ( pView->HasPaintBrush() )
697
0
    {
698
        // cancel paintbrush mode
699
0
        pView->ResetBrushDocument();
700
0
    }
701
0
    else
702
0
    {
703
0
        bool bLock = false;
704
0
        const SfxItemSet *pArgs = rReq.GetArgs();
705
0
        if( pArgs && pArgs->Count() >= 1 )
706
0
            bLock = pArgs->Get(SID_FORMATPAINTBRUSH).GetValue();
707
708
0
        ScDrawView* pDrawView = rViewData.GetScDrawView();
709
0
        if ( pDrawView && pDrawView->GetMarkedObjectList().GetMarkCount() != 0 )
710
0
        {
711
0
            std::unique_ptr<SfxItemSet> pItemSet(new SfxItemSet( pDrawView->GetAttrFromMarked(true/*bOnlyHardAttr*/) ));
712
0
            pView->SetDrawBrushSet( std::move(pItemSet), bLock );
713
0
        }
714
0
    }
715
0
}
716
717
void ScDrawShell::StateFormatPaintbrush( SfxItemSet& rSet )
718
0
{
719
0
    ScDrawView* pDrawView = rViewData.GetScDrawView();
720
0
    bool bSelection = pDrawView && pDrawView->GetMarkedObjectList().GetMarkCount() != 0;
721
0
    bool bHasPaintBrush = rViewData.GetView()->HasPaintBrush();
722
723
0
    if ( !bHasPaintBrush && !bSelection )
724
0
        rSet.DisableItem( SID_FORMATPAINTBRUSH );
725
0
    else
726
0
        rSet.Put( SfxBoolItem( SID_FORMATPAINTBRUSH, bHasPaintBrush ) );
727
0
}
728
729
ScDrawView* ScDrawShell::GetDrawView()
730
0
{
731
0
    return rViewData.GetView()->GetScDrawView();
732
0
}
733
734
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */