Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/chart2/source/controller/main/ShapeController.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 "ShapeController.hxx"
21
#include <ChartController.hxx>
22
#include <ViewElementListProvider.hxx>
23
#include <dlg_ShapeFont.hxx>
24
#include <dlg_ShapeParagraph.hxx>
25
#include <ChartModel.hxx>
26
#include <chartview/DrawModelWrapper.hxx>
27
#include <com/sun/star/drawing/XShapes.hpp>
28
#include <com/sun/star/frame/CommandGroup.hpp>
29
30
#include <vcl/svapp.hxx>
31
#include <editeng/formatbreakitem.hxx>
32
#include <editeng/editids.hrc>
33
#include <editeng/eeitem.hxx>
34
#include <editeng/hyphenzoneitem.hxx>
35
#include <editeng/orphitem.hxx>
36
#include <editeng/spltitem.hxx>
37
#include <svx/svxdlg.hxx>
38
#include <editeng/widwitem.hxx>
39
#include <comphelper/diagnose_ex.hxx>
40
41
using namespace ::com::sun::star;
42
using namespace ::com::sun::star::frame;
43
44
using ::com::sun::star::uno::Reference;
45
using ::com::sun::star::uno::Sequence;
46
47
namespace chart
48
{
49
50
ShapeController::ShapeController( const Reference< uno::XComponentContext >& rxContext,
51
        ChartController* pController )
52
0
    :FeatureCommandDispatchBase( rxContext )
53
0
    ,m_pChartController( pController )
54
0
{
55
0
}
Unexecuted instantiation: chart::ShapeController::ShapeController(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, chart::ChartController*)
Unexecuted instantiation: chart::ShapeController::ShapeController(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, chart::ChartController*)
56
57
ShapeController::~ShapeController()
58
0
{
59
0
}
60
61
// WeakComponentImplHelperBase
62
void ShapeController::disposing(std::unique_lock<std::mutex>& /*rGuard*/)
63
0
{
64
0
}
65
66
// XEventListener
67
void ShapeController::disposing( const lang::EventObject& /* Source */ )
68
0
{
69
0
}
70
71
FeatureState ShapeController::getState( const OUString& rCommand )
72
0
{
73
0
    FeatureState aReturn;
74
0
    aReturn.bEnabled = false;
75
0
    aReturn.aState <<= false;
76
77
0
    bool bWritable = false;
78
0
    if ( m_pChartController )
79
0
    {
80
0
        rtl::Reference< ChartModel > xStorable = m_pChartController->getChartModel();
81
0
        if ( xStorable.is() )
82
0
        {
83
0
            bWritable = !xStorable->isReadonly();
84
0
        }
85
0
    }
86
87
0
    SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rCommand );
88
0
    if ( aIter != m_aSupportedFeatures.end() )
89
0
    {
90
0
        ChartCommandID nFeatureId = aIter->second.nFeatureId;
91
0
        switch ( nFeatureId )
92
0
        {
93
0
            case ChartCommandID::ShapeFormatLine:
94
0
            case ChartCommandID::ShapeFormatArea:
95
0
            case ChartCommandID::ShapeTextAttributes:
96
0
            case ChartCommandID::ShapeTransformDialog:
97
0
            case ChartCommandID::ShapeObjectTitleDescription:
98
0
            case ChartCommandID::ShapeRenameObject:
99
0
            case ChartCommandID::ShapeFontDialog:
100
0
            case ChartCommandID::ShapeParagraphDialog:
101
0
                {
102
0
                    aReturn.bEnabled = bWritable;
103
0
                    aReturn.aState <<= false;
104
0
                }
105
0
                break;
106
0
            case ChartCommandID::ShapeBringToFront:
107
0
            case ChartCommandID::ShapeForward:
108
0
                {
109
0
                    aReturn.bEnabled = ( bWritable && isForwardPossible() );
110
0
                    aReturn.aState <<= false;
111
0
                }
112
0
                break;
113
0
            case ChartCommandID::ShapeBackward:
114
0
            case ChartCommandID::ShapeSendToBack:
115
0
                {
116
117
0
                    aReturn.bEnabled = ( bWritable && isBackwardPossible() );
118
0
                    aReturn.aState <<= false;
119
0
                }
120
0
                break;
121
0
            default:
122
0
                {
123
0
                    aReturn.bEnabled = false;
124
0
                    aReturn.aState <<= false;
125
0
                }
126
0
                break;
127
0
        }
128
0
    }
129
130
0
    return aReturn;
131
0
}
132
133
void ShapeController::execute( const OUString& rCommand, const Sequence< beans::PropertyValue>& )
134
0
{
135
0
    SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rCommand );
136
0
    if ( aIter == m_aSupportedFeatures.end() )
137
0
        return;
138
139
0
    ChartCommandID nFeatureId = aIter->second.nFeatureId;
140
0
    switch ( nFeatureId )
141
0
    {
142
0
        case ChartCommandID::ShapeFormatLine:
143
0
            {
144
0
                executeDispatch_FormatLine();
145
0
            }
146
0
            break;
147
0
        case ChartCommandID::ShapeFormatArea:
148
0
            {
149
0
                executeDispatch_FormatArea();
150
0
            }
151
0
            break;
152
0
        case ChartCommandID::ShapeTextAttributes:
153
0
            {
154
0
                executeDispatch_TextAttributes();
155
0
            }
156
0
            break;
157
0
        case ChartCommandID::ShapeTransformDialog:
158
0
            {
159
0
                executeDispatch_TransformDialog();
160
0
            }
161
0
            break;
162
0
        case ChartCommandID::ShapeObjectTitleDescription:
163
0
            {
164
0
                executeDispatch_ObjectTitleDescription();
165
0
            }
166
0
            break;
167
0
        case ChartCommandID::ShapeRenameObject:
168
0
            {
169
0
                executeDispatch_RenameObject();
170
0
            }
171
0
            break;
172
0
        case ChartCommandID::ShapeBringToFront:
173
0
        case ChartCommandID::ShapeForward:
174
0
        case ChartCommandID::ShapeBackward:
175
0
        case ChartCommandID::ShapeSendToBack:
176
0
            {
177
0
                executeDispatch_ChangeZOrder( nFeatureId );
178
0
            }
179
0
            break;
180
0
        case ChartCommandID::ShapeFontDialog:
181
0
            {
182
0
                executeDispatch_FontDialog();
183
0
            }
184
0
            break;
185
0
        case ChartCommandID::ShapeParagraphDialog:
186
0
            {
187
0
                executeDispatch_ParagraphDialog();
188
0
            }
189
0
            break;
190
0
        default:
191
0
            {
192
0
            }
193
0
            break;
194
0
    }
195
0
}
196
197
void ShapeController::describeSupportedFeatures()
198
0
{
199
0
    implDescribeSupportedFeature( u".uno:FormatLine"_ustr,             ChartCommandID::ShapeFormatLine,             CommandGroup::FORMAT );
200
0
    implDescribeSupportedFeature( u".uno:FormatArea"_ustr,             ChartCommandID::ShapeFormatArea,             CommandGroup::FORMAT );
201
0
    implDescribeSupportedFeature( u".uno:TextAttributes"_ustr,         ChartCommandID::ShapeTextAttributes,         CommandGroup::FORMAT );
202
0
    implDescribeSupportedFeature( u".uno:TransformDialog"_ustr,        ChartCommandID::ShapeTransformDialog,        CommandGroup::FORMAT );
203
0
    implDescribeSupportedFeature( u".uno:ObjectTitleDescription"_ustr, ChartCommandID::ShapeObjectTitleDescription, CommandGroup::FORMAT );
204
0
    implDescribeSupportedFeature( u".uno:RenameObject"_ustr,           ChartCommandID::ShapeRenameObject,           CommandGroup::FORMAT );
205
0
    implDescribeSupportedFeature( u".uno:BringToFront"_ustr,           ChartCommandID::ShapeBringToFront,           CommandGroup::FORMAT );
206
0
    implDescribeSupportedFeature( u".uno:Forward"_ustr,                ChartCommandID::ShapeForward,                CommandGroup::FORMAT );
207
0
    implDescribeSupportedFeature( u".uno:Backward"_ustr,               ChartCommandID::ShapeBackward,               CommandGroup::FORMAT );
208
0
    implDescribeSupportedFeature( u".uno:SendToBack"_ustr,             ChartCommandID::ShapeSendToBack,             CommandGroup::FORMAT );
209
0
    implDescribeSupportedFeature( u".uno:FontDialog"_ustr,             ChartCommandID::ShapeFontDialog,             CommandGroup::EDIT );
210
0
    implDescribeSupportedFeature( u".uno:ParagraphDialog"_ustr,        ChartCommandID::ShapeParagraphDialog,        CommandGroup::EDIT );
211
0
}
212
213
IMPL_LINK( ShapeController, CheckNameHdl, AbstractSvxObjectNameDialog&, rDialog, bool )
214
0
{
215
0
    OUString aName = rDialog.GetName();
216
217
0
    if ( !aName.isEmpty() )
218
0
    {
219
0
        DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : nullptr );
220
0
        if ( pDrawViewWrapper && pDrawViewWrapper->getNamedSdrObject( aName ) )
221
0
        {
222
0
            return false;
223
0
        }
224
0
    }
225
0
    return true;
226
0
}
227
228
void ShapeController::executeDispatch_FormatLine()
229
0
{
230
0
    SolarMutexGuard aGuard;
231
0
    if ( !m_pChartController )
232
0
        return;
233
234
0
    weld::Window* pChartWindow(m_pChartController->GetChartFrame());
235
0
    DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper();
236
0
    DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
237
0
    if ( !(pChartWindow && pDrawModelWrapper && pDrawViewWrapper) )
238
0
        return;
239
240
0
    SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
241
0
    SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() );
242
0
    bool bHasMarked = pDrawViewWrapper->GetMarkedObjectList().GetMarkCount() != 0;
243
0
    if ( bHasMarked )
244
0
    {
245
0
        pDrawViewWrapper->MergeAttrFromMarked( aAttr, false );
246
0
    }
247
0
    SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
248
0
    ScopedVclPtr< SfxAbstractTabDialog > pDlg(
249
0
        pFact->CreateSvxLineTabDialog(pChartWindow, &aAttr, &pDrawModelWrapper->getSdrModel(),
250
0
            pSelectedObj, bHasMarked));
251
0
    if ( pDlg->Execute() == RET_OK )
252
0
    {
253
0
        const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
254
0
        if ( bHasMarked )
255
0
        {
256
0
            pDrawViewWrapper->SetAttrToMarked( *pOutAttr, false );
257
0
        }
258
0
        else
259
0
        {
260
0
            pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false );
261
0
        }
262
0
    }
263
0
}
264
265
void ShapeController::executeDispatch_FormatArea()
266
0
{
267
0
    SolarMutexGuard aGuard;
268
0
    if ( !m_pChartController )
269
0
        return;
270
271
0
    weld::Window* pChartWindow(m_pChartController->GetChartFrame());
272
0
    DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper();
273
0
    DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
274
0
    if ( !(pChartWindow && pDrawModelWrapper && pDrawViewWrapper) )
275
0
        return;
276
277
0
    SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() );
278
0
    bool bHasMarked = pDrawViewWrapper->GetMarkedObjectList().GetMarkCount() != 0;
279
0
    if ( bHasMarked )
280
0
    {
281
0
        pDrawViewWrapper->MergeAttrFromMarked( aAttr, false );
282
0
    }
283
0
    SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
284
0
    ScopedVclPtr< AbstractSvxAreaTabDialog > pDlg(
285
0
            pFact->CreateSvxAreaTabDialog(pChartWindow, &aAttr, &pDrawModelWrapper->getSdrModel(), true, false));
286
0
    if ( pDlg->Execute() == RET_OK )
287
0
    {
288
0
        const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
289
0
        if ( bHasMarked )
290
0
        {
291
0
            pDrawViewWrapper->SetAttrToMarked( *pOutAttr, false );
292
0
        }
293
0
        else
294
0
        {
295
0
            pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false );
296
0
        }
297
0
    }
298
0
}
299
300
void ShapeController::executeDispatch_TextAttributes()
301
0
{
302
0
    SolarMutexGuard aGuard;
303
0
    if ( !m_pChartController )
304
0
        return;
305
306
0
    weld::Window* pChartWindow(m_pChartController->GetChartFrame());
307
0
    DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
308
0
    if ( !(pChartWindow && pDrawViewWrapper) )
309
0
        return;
310
311
0
    SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() );
312
0
    bool bHasMarked = pDrawViewWrapper->GetMarkedObjectList().GetMarkCount() != 0;
313
0
    if ( bHasMarked )
314
0
    {
315
0
        pDrawViewWrapper->MergeAttrFromMarked( aAttr, false );
316
0
    }
317
0
    SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
318
0
    VclPtr< SfxAbstractTabDialog > pDlg(
319
0
        pFact->CreateTextTabDialog(pChartWindow, &aAttr, pDrawViewWrapper));
320
0
    pDlg->StartExecuteAsync(
321
0
        [pDlg, bHasMarked, pDrawViewWrapper] (sal_Int32 nResult)->void
322
0
        {
323
0
            if ( RET_OK == nResult )
324
0
            {
325
0
                const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
326
0
                if ( bHasMarked )
327
0
                {
328
0
                    pDrawViewWrapper->SetAttributes( *pOutAttr );
329
0
                }
330
0
                else
331
0
                {
332
0
                    pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false );
333
0
                }
334
0
            }
335
0
            pDlg->disposeOnce();
336
0
        }
337
0
    );
338
0
}
339
340
void ShapeController::executeDispatch_TransformDialog()
341
0
{
342
0
    SolarMutexGuard aGuard;
343
0
    if ( !m_pChartController )
344
0
        return;
345
346
0
    weld::Window* pChartWindow(m_pChartController->GetChartFrame());
347
0
    DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
348
0
    if ( !(pChartWindow && pDrawViewWrapper) )
349
0
        return;
350
351
0
    SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
352
0
    if ( pSelectedObj && pSelectedObj->GetObjIdentifier() == SdrObjKind::Caption )
353
0
    {
354
        // item set for caption
355
0
        SfxItemSet aAttr(pDrawViewWrapper->GetModel().GetItemPool());
356
0
        pDrawViewWrapper->GetAttributes( aAttr );
357
        // item set for position and size
358
0
        SfxItemSet aGeoAttr( pDrawViewWrapper->GetGeoAttrFromMarked() );
359
0
        SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
360
0
        ScopedVclPtr< SfxAbstractTabDialog > pDlg(
361
0
            pFact->CreateCaptionDialog(pChartWindow, pDrawViewWrapper));
362
0
        SfxItemSet aCombAttr(*aAttr.GetPool(), pDlg->GetInputRanges(*aAttr.GetPool()));
363
0
        aCombAttr.Put( aAttr );
364
0
        aCombAttr.Put( aGeoAttr );
365
0
        pDlg->SetInputSet( &aCombAttr );
366
0
        if ( pDlg->Execute() == RET_OK )
367
0
        {
368
0
            const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
369
0
            pDrawViewWrapper->SetAttributes( *pOutAttr );
370
0
            pDrawViewWrapper->SetGeoAttrToMarked( *pOutAttr );
371
0
        }
372
0
    }
373
0
    else
374
0
    {
375
0
        SfxItemSet aGeoAttr( pDrawViewWrapper->GetGeoAttrFromMarked() );
376
0
        SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
377
0
        ScopedVclPtr< SfxAbstractTabDialog > pDlg(
378
0
            pFact->CreateSvxTransformTabDialog(pChartWindow, &aGeoAttr, pDrawViewWrapper));
379
0
        if ( pDlg->Execute() == RET_OK )
380
0
        {
381
0
            const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
382
0
            pDrawViewWrapper->SetGeoAttrToMarked( *pOutAttr );
383
0
        }
384
0
    }
385
0
}
386
387
void ShapeController::executeDispatch_ObjectTitleDescription()
388
0
{
389
0
    SolarMutexGuard aGuard;
390
0
    if ( !m_pChartController )
391
0
        return;
392
393
0
    DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
394
0
    if ( !(pDrawViewWrapper && pDrawViewWrapper->GetMarkedObjectList().GetMarkCount() == 1) )
395
0
        return;
396
397
0
    SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
398
0
    if ( !pSelectedObj )
399
0
        return;
400
401
0
    OUString aTitle( pSelectedObj->GetTitle() );
402
0
    OUString aDescription( pSelectedObj->GetDescription() );
403
0
    bool isDecorative(pSelectedObj->IsDecorative());
404
0
    SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
405
0
    weld::Window* pChartWindow(m_pChartController->GetChartFrame());
406
0
    VclPtr< AbstractSvxObjectTitleDescDialog > pDlg(
407
0
        pFact->CreateSvxObjectTitleDescDialog(pChartWindow, aTitle, aDescription, isDecorative));
408
0
    pDlg->StartExecuteAsync(
409
0
        [pDlg, pSelectedObj] (sal_Int32 nResult)->void
410
0
        {
411
0
            if (nResult == RET_OK)
412
0
            {
413
0
                pSelectedObj->SetTitle( pDlg->GetTitle() );
414
0
                pSelectedObj->SetDescription( pDlg->GetDescription() );
415
0
                pSelectedObj->SetDecorative(pDlg->IsDecorative());
416
0
            }
417
0
            pDlg->disposeOnce();
418
0
        }
419
0
    );
420
0
}
421
422
void ShapeController::executeDispatch_RenameObject()
423
0
{
424
0
    SolarMutexGuard aGuard;
425
0
    if ( !m_pChartController )
426
0
        return;
427
428
0
    DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
429
0
    if ( !(pDrawViewWrapper && pDrawViewWrapper->GetMarkedObjectList().GetMarkCount() == 1) )
430
0
        return;
431
432
0
    SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
433
0
    if ( !pSelectedObj )
434
0
        return;
435
436
0
    SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
437
0
    weld::Window* pChartWindow(m_pChartController->GetChartFrame());
438
0
    VclPtr< AbstractSvxObjectNameDialog > pDlg(
439
0
        pFact->CreateSvxObjectNameDialog(pChartWindow, pSelectedObj->GetName()));
440
0
    pDlg->SetCheckNameHdl( LINK( this, ShapeController, CheckNameHdl ) );
441
0
    pDlg->StartExecuteAsync(
442
0
        [pDlg, pSelectedObj] (sal_Int32 nResult)->void
443
0
        {
444
0
            if (nResult == RET_OK)
445
0
            {
446
0
                OUString aName = pDlg->GetName();
447
0
                if (pSelectedObj->GetName() != aName)
448
0
                {
449
0
                    pSelectedObj->SetName( aName );
450
0
                }
451
0
            }
452
0
            pDlg->disposeOnce();
453
0
        }
454
0
    );
455
0
}
456
457
void ShapeController::executeDispatch_ChangeZOrder( ChartCommandID nId )
458
0
{
459
0
    SolarMutexGuard aGuard;
460
0
    DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : nullptr );
461
0
    if ( !pDrawViewWrapper )
462
0
        return;
463
464
0
    switch ( nId )
465
0
    {
466
0
        case ChartCommandID::ShapeBringToFront:
467
0
            {
468
0
                if ( isForwardPossible() )
469
0
                {
470
0
                    pDrawViewWrapper->PutMarkedToTop();
471
0
                }
472
0
            }
473
0
            break;
474
0
        case ChartCommandID::ShapeForward:
475
0
            {
476
0
                if ( isForwardPossible() )
477
0
                {
478
0
                    pDrawViewWrapper->MovMarkedToTop();
479
0
                }
480
0
            }
481
0
            break;
482
0
        case ChartCommandID::ShapeBackward:
483
0
            {
484
0
                if ( isBackwardPossible() )
485
0
                {
486
0
                    pDrawViewWrapper->MovMarkedToBtm();
487
0
                }
488
0
            }
489
0
            break;
490
0
        case ChartCommandID::ShapeSendToBack:
491
0
            {
492
0
                if ( isBackwardPossible() )
493
0
                {
494
0
                    SdrObject* pFirstObj = getFirstAdditionalShape();
495
0
                    pDrawViewWrapper->PutMarkedBehindObj( pFirstObj );
496
0
                }
497
0
            }
498
0
            break;
499
0
        default:
500
0
            {
501
0
            }
502
0
            break;
503
0
    }
504
0
}
505
506
void ShapeController::executeDispatch_FontDialog()
507
0
{
508
0
    SolarMutexGuard aGuard;
509
0
    if ( !m_pChartController )
510
0
        return;
511
512
0
    weld::Window* pChartWindow(m_pChartController->GetChartFrame());
513
0
    DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper();
514
0
    DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
515
0
    if ( pChartWindow && pDrawModelWrapper && pDrawViewWrapper )
516
0
    {
517
0
        SfxItemSet aAttr(pDrawViewWrapper->GetModel().GetItemPool());
518
0
        pDrawViewWrapper->GetAttributes( aAttr );
519
0
        ViewElementListProvider aViewElementListProvider( pDrawModelWrapper );
520
0
        ShapeFontDialog aDlg(pChartWindow, &aAttr, &aViewElementListProvider);
521
0
        if (aDlg.run() == RET_OK)
522
0
        {
523
0
            const SfxItemSet* pOutAttr = aDlg.GetOutputItemSet();
524
0
            pDrawViewWrapper->SetAttributes( *pOutAttr );
525
0
        }
526
0
    }
527
0
}
528
529
void ShapeController::executeDispatch_ParagraphDialog()
530
0
{
531
0
    SolarMutexGuard aGuard;
532
0
    if ( !m_pChartController )
533
0
        return;
534
535
0
    weld::Window* pChartWindow(m_pChartController->GetChartFrame());
536
0
    DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
537
0
    if ( !(pChartWindow && pDrawViewWrapper) )
538
0
        return;
539
540
0
    SfxItemPool& rPool = pDrawViewWrapper->GetModel().GetItemPool();
541
0
    SfxItemSet aAttr( rPool );
542
0
    pDrawViewWrapper->GetAttributes( aAttr );
543
544
0
    SfxItemSetFixed<
545
0
            EE_ITEMS_START, EE_ITEMS_END,
546
0
            SID_ATTR_PARA_PAGEBREAK, SID_ATTR_PARA_WIDOWS>  aNewAttr(rPool);
547
0
    aNewAttr.Put( aAttr );
548
0
    aNewAttr.Put( SvxHyphenZoneItem( false, SID_ATTR_PARA_HYPHENZONE ) );
549
0
    aNewAttr.Put( SvxFormatBreakItem( SvxBreak::NONE, SID_ATTR_PARA_PAGEBREAK ) );
550
0
    aNewAttr.Put( SvxFormatSplitItem( true, SID_ATTR_PARA_SPLIT)  );
551
0
    aNewAttr.Put( SvxWidowsItem( 0, SID_ATTR_PARA_WIDOWS) );
552
0
    aNewAttr.Put( SvxOrphansItem( 0, SID_ATTR_PARA_ORPHANS) );
553
554
0
    ShapeParagraphDialog aDlg(pChartWindow, &aNewAttr);
555
0
    if (aDlg.run() == RET_OK)
556
0
    {
557
0
        const SfxItemSet* pOutAttr = aDlg.GetOutputItemSet();
558
0
        pDrawViewWrapper->SetAttributes( *pOutAttr );
559
0
    }
560
0
}
561
562
SdrObject* ShapeController::getFirstAdditionalShape()
563
0
{
564
0
    SdrObject* pFirstObj = nullptr;
565
566
0
    try
567
0
    {
568
0
        DrawModelWrapper* pDrawModelWrapper = ( m_pChartController ? m_pChartController->GetDrawModelWrapper() : nullptr );
569
0
        if ( pDrawModelWrapper )
570
0
        {
571
0
            Reference< drawing::XShape > xFirstShape;
572
0
            rtl::Reference<SvxDrawPage> xDrawPage( pDrawModelWrapper->getMainDrawPage() );
573
0
            Reference< drawing::XShapes > xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage ) );
574
0
            sal_Int32 nCount = xDrawPage->getCount();
575
0
            for ( sal_Int32 i = 0; i < nCount; ++i )
576
0
            {
577
0
                Reference< drawing::XShape > xShape;
578
0
                if ( xDrawPage->getByIndex( i ) >>= xShape )
579
0
                {
580
0
                    if ( xShape.is() && xShape != xChartRoot )
581
0
                    {
582
0
                        xFirstShape = std::move(xShape);
583
0
                        break;
584
0
                    }
585
0
                }
586
0
            }
587
0
            if ( xFirstShape.is() )
588
0
            {
589
0
                pFirstObj = DrawViewWrapper::getSdrObject( xFirstShape );
590
0
            }
591
0
        }
592
0
    }
593
0
    catch ( const uno::Exception& )
594
0
    {
595
0
        DBG_UNHANDLED_EXCEPTION("chart2");
596
0
    }
597
598
0
    return pFirstObj;
599
0
}
600
601
SdrObject* ShapeController::getLastAdditionalShape()
602
0
{
603
0
    SdrObject* pLastObj = nullptr;
604
605
0
    try
606
0
    {
607
0
        DrawModelWrapper* pDrawModelWrapper = ( m_pChartController ? m_pChartController->GetDrawModelWrapper() : nullptr );
608
0
        if ( pDrawModelWrapper )
609
0
        {
610
0
            Reference< drawing::XShape > xLastShape;
611
0
            rtl::Reference<SvxDrawPage> xDrawPage( pDrawModelWrapper->getMainDrawPage() );
612
0
            Reference< drawing::XShapes > xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage ) );
613
0
            sal_Int32 nCount = xDrawPage->getCount();
614
0
            for ( sal_Int32 i = nCount - 1; i >= 0; --i )
615
0
            {
616
0
                Reference< drawing::XShape > xShape;
617
0
                if ( xDrawPage->getByIndex( i ) >>= xShape )
618
0
                {
619
0
                    if ( xShape.is() && xShape != xChartRoot )
620
0
                    {
621
0
                        xLastShape = std::move(xShape);
622
0
                        break;
623
0
                    }
624
0
                }
625
0
            }
626
0
            if ( xLastShape.is() )
627
0
            {
628
0
                pLastObj = DrawViewWrapper::getSdrObject( xLastShape );
629
0
            }
630
0
        }
631
0
    }
632
0
    catch ( const uno::Exception& )
633
0
    {
634
0
        DBG_UNHANDLED_EXCEPTION("chart2");
635
0
    }
636
637
0
    return pLastObj;
638
0
}
639
640
bool ShapeController::isBackwardPossible()
641
0
{
642
0
    if ( m_pChartController && m_pChartController->isAdditionalShapeSelected() )
643
0
    {
644
0
        SolarMutexGuard aGuard;
645
0
        DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
646
0
        if ( pDrawViewWrapper )
647
0
        {
648
0
            SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
649
0
            SdrObject* pFirstObj = getFirstAdditionalShape();
650
0
            if ( pSelectedObj && pFirstObj && pSelectedObj != pFirstObj )
651
0
            {
652
0
                return true;
653
0
            }
654
0
        }
655
0
    }
656
0
    return false;
657
0
}
658
659
bool ShapeController::isForwardPossible()
660
0
{
661
0
    if ( m_pChartController && m_pChartController->isAdditionalShapeSelected() )
662
0
    {
663
0
        SolarMutexGuard aGuard;
664
0
        DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
665
0
        if ( pDrawViewWrapper )
666
0
        {
667
0
            SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
668
0
            SdrObject* pLastObj = getLastAdditionalShape();
669
0
            if ( pSelectedObj && pLastObj && pSelectedObj != pLastObj )
670
0
            {
671
0
                return true;
672
0
            }
673
0
        }
674
0
    }
675
0
    return false;
676
0
}
677
678
} //  namespace chart
679
680
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */