Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/chart2/source/controller/main/DrawCommandDispatch.cxx
Line
Count
Source (jump to first uncovered line)
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 "DrawCommandDispatch.hxx"
21
#include <ChartController.hxx>
22
#include <DrawViewWrapper.hxx>
23
#include <chartview/DrawModelWrapper.hxx>
24
25
#include <com/sun/star/frame/CommandGroup.hpp>
26
#include <o3tl/unsafe_downcast.hxx>
27
#include <o3tl/string_view.hxx>
28
#include <vcl/svapp.hxx>
29
#include <editeng/eeitem.hxx>
30
#include <svx/strings.hrc>
31
#include <svx/dialmgr.hxx>
32
#include <svx/fmmodel.hxx>
33
#include <svx/gallery.hxx>
34
#include <svx/svdoashp.hxx>
35
#include <svx/svdocapt.hxx>
36
#include <svx/svdopath.hxx>
37
#include <svx/svdpage.hxx>
38
#include <svx/unoapi.hxx>
39
#include <svx/xlnedit.hxx>
40
#include <svx/xlnedwit.hxx>
41
#include <svx/xlnwtit.hxx>
42
#include <svx/xtable.hxx>
43
#include <svx/sdtagitm.hxx>
44
#include <basegfx/polygon/b2dpolygon.hxx>
45
46
using namespace ::com::sun::star;
47
using namespace ::com::sun::star::frame;
48
49
using ::com::sun::star::uno::Reference;
50
using ::com::sun::star::uno::Sequence;
51
52
53
namespace chart
54
{
55
56
DrawCommandDispatch::DrawCommandDispatch( const Reference< uno::XComponentContext >& rxContext,
57
    ChartController* pController )
58
0
    :FeatureCommandDispatchBase( rxContext )
59
0
    ,m_pChartController( pController )
60
0
{
61
0
}
Unexecuted instantiation: chart::DrawCommandDispatch::DrawCommandDispatch(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, chart::ChartController*)
Unexecuted instantiation: chart::DrawCommandDispatch::DrawCommandDispatch(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, chart::ChartController*)
62
63
DrawCommandDispatch::~DrawCommandDispatch()
64
0
{
65
0
}
66
67
bool DrawCommandDispatch::isFeatureSupported( const OUString& rCommandURL )
68
0
{
69
0
    ChartCommandID nFeatureId = ChartCommandID::NONE;
70
0
    OUString aBaseCommand;
71
0
    OUString aCustomShapeType;
72
0
    return parseCommandURL( rCommandURL, &nFeatureId, &aBaseCommand, &aCustomShapeType );
73
0
}
74
75
static ::basegfx::B2DPolyPolygon getPolygon(TranslateId pResId, const SdrModel& rModel)
76
0
{
77
0
    ::basegfx::B2DPolyPolygon aReturn;
78
0
    XLineEndListRef pLineEndList = rModel.GetLineEndList();
79
0
    if ( pLineEndList.is() )
80
0
    {
81
0
        OUString aName(SvxResId(pResId));
82
0
        tools::Long nCount = pLineEndList->Count();
83
0
        for ( tools::Long nIndex = 0; nIndex < nCount; ++nIndex )
84
0
        {
85
0
            const XLineEndEntry* pEntry = pLineEndList->GetLineEnd(nIndex);
86
0
            if ( pEntry->GetName() == aName )
87
0
            {
88
0
                aReturn = pEntry->GetLineEnd();
89
0
                break;
90
0
            }
91
0
        }
92
0
    }
93
0
    return aReturn;
94
0
}
95
96
void DrawCommandDispatch::setAttributes( SdrObject* pObj )
97
0
{
98
0
    if ( !m_pChartController )
99
0
        return;
100
101
0
    DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper();
102
0
    DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
103
0
    if ( !(pDrawModelWrapper && pDrawViewWrapper && pDrawViewWrapper->GetCurrentObjIdentifier() == SdrObjKind::CustomShape) )
104
0
        return;
105
106
0
    bool bAttributesAppliedFromGallery = false;
107
0
    if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) )
108
0
    {
109
0
        std::vector< OUString > aObjList;
110
0
        if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) )
111
0
        {
112
0
            for ( size_t i = 0; i < aObjList.size(); ++i )
113
0
            {
114
0
                if ( aObjList[ i ].equalsIgnoreAsciiCase( m_aCustomShapeType ) )
115
0
                {
116
0
                    FmFormModel aModel;
117
118
0
                    if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aModel ) )
119
0
                    {
120
0
                        const SdrObject* pSourceObj = aModel.GetPage( 0 )->GetObj( 0 );
121
0
                        if ( pSourceObj )
122
0
                        {
123
0
                            const SfxItemSet& rSource = pSourceObj->GetMergedItemSet();
124
                            // Create a dynamic SfxItemSet
125
0
                            SfxItemSet aDest(
126
0
                                SfxItemSet::makeFixedSfxItemSet<
127
                                    // Ranges from SdrAttrObj:
128
0
                                    SDRATTR_START, SDRATTR_SHADOW_LAST, SDRATTR_MISC_FIRST,
129
0
                                    SDRATTR_MISC_LAST, SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
130
                                    // Graphic attributes, 3D
131
                                    // properties, CustomShape
132
                                    // properties:
133
0
                                    SDRATTR_GRAF_FIRST, SDRATTR_CUSTOMSHAPE_LAST,
134
                                    // Range from SdrTextObj:
135
0
                                    EE_ITEMS_START, EE_ITEMS_END>(
136
0
                                    pObj->getSdrModelFromSdrObject().GetItemPool()));
137
0
                            aDest.Set( rSource );
138
0
                            pObj->SetMergedItemSet( aDest );
139
0
                            Degree100 nAngle = pSourceObj->GetRotateAngle();
140
0
                            if ( nAngle )
141
0
                                pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle );
142
0
                            bAttributesAppliedFromGallery = true;
143
0
                        }
144
0
                    }
145
0
                    break;
146
0
                }
147
0
            }
148
0
        }
149
0
    }
150
0
    if ( !bAttributesAppliedFromGallery )
151
0
    {
152
0
        pObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
153
0
        pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) );
154
0
        pObj->SetMergedItem( makeSdrTextAutoGrowHeightItem( false ) );
155
156
0
        o3tl::unsafe_downcast< SdrObjCustomShape* >( pObj )->MergeDefaultAttributes( &m_aCustomShapeType );
157
0
    }
158
0
}
159
160
void DrawCommandDispatch::setLineEnds( SfxItemSet& rAttr )
161
0
{
162
0
    if ( !(m_nFeatureId == ChartCommandID::DrawLineArrowEnd && m_pChartController) )
163
0
        return;
164
165
0
    DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper();
166
0
    DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
167
0
    if ( !(pDrawModelWrapper && pDrawViewWrapper) )
168
0
        return;
169
170
0
    ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, pDrawModelWrapper->getSdrModel() ) );
171
0
    if ( !aArrow.count() )
172
0
    {
173
0
        ::basegfx::B2DPolygon aNewArrow;
174
0
        aNewArrow.append( ::basegfx::B2DPoint( 10.0, 0.0 ) );
175
0
        aNewArrow.append( ::basegfx::B2DPoint( 0.0, 30.0) );
176
0
        aNewArrow.append( ::basegfx::B2DPoint( 20.0, 30.0 ) );
177
0
        aNewArrow.setClosed( true );
178
0
        aArrow.append( aNewArrow );
179
0
    }
180
181
0
    SfxItemSet aSet(pDrawViewWrapper->GetModel().GetItemPool());
182
0
    pDrawViewWrapper->GetAttributes( aSet );
183
184
0
    tools::Long nWidth = 300; // (1/100th mm)
185
0
    if ( aSet.GetItemState( XATTR_LINEWIDTH ) != SfxItemState::INVALID )
186
0
    {
187
0
        tools::Long nValue = aSet.Get( XATTR_LINEWIDTH ).GetValue();
188
0
        if ( nValue > 0 )
189
0
        {
190
0
            nWidth = nValue * 3;
191
0
        }
192
0
    }
193
194
0
    rAttr.Put( XLineEndItem( SvxResId( RID_SVXSTR_ARROW ), std::move(aArrow) ) );
195
0
    rAttr.Put( XLineEndWidthItem( nWidth ) );
196
0
}
197
198
// WeakComponentImplHelperBase
199
void DrawCommandDispatch::disposing(std::unique_lock<std::mutex>& /*rGuard*/)
200
0
{
201
0
}
202
203
// XEventListener
204
void DrawCommandDispatch::disposing( const lang::EventObject& /* Source */ )
205
0
{
206
0
}
207
208
FeatureState DrawCommandDispatch::getState( const OUString& rCommand )
209
0
{
210
0
    FeatureState aReturn;
211
0
    aReturn.bEnabled = false;
212
0
    aReturn.aState <<= false;
213
214
0
    ChartCommandID nFeatureId = ChartCommandID::NONE;
215
0
    OUString aBaseCommand;
216
0
    OUString aCustomShapeType;
217
0
    if ( parseCommandURL( rCommand, &nFeatureId, &aBaseCommand, &aCustomShapeType ) )
218
0
    {
219
0
        switch ( nFeatureId )
220
0
        {
221
0
            case ChartCommandID::DrawObjectSelect:
222
0
            case ChartCommandID::DrawLine:
223
0
            case ChartCommandID::DrawLineArrowEnd:
224
0
            case ChartCommandID::DrawRect:
225
0
            case ChartCommandID::DrawEllipse:
226
0
            case ChartCommandID::DrawFreelineNoFill:
227
0
            case ChartCommandID::DrawText:
228
0
            case ChartCommandID::DrawCaption:
229
0
            case ChartCommandID::DrawToolboxCsBasic:
230
0
            case ChartCommandID::DrawToolboxCsSymbol:
231
0
            case ChartCommandID::DrawToolboxCsArrow:
232
0
            case ChartCommandID::DrawToolboxCsFlowchart:
233
0
            case ChartCommandID::DrawToolboxCsCallout:
234
0
            case ChartCommandID::DrawToolboxCsStar:
235
0
                {
236
0
                    aReturn.bEnabled = true;
237
0
                    aReturn.aState <<= false;
238
0
                }
239
0
                break;
240
0
            default:
241
0
                {
242
0
                    aReturn.bEnabled = false;
243
0
                    aReturn.aState <<= false;
244
0
                }
245
0
                break;
246
0
        }
247
0
    }
248
249
0
    return aReturn;
250
0
}
251
252
void DrawCommandDispatch::execute( const OUString& rCommand, const Sequence< beans::PropertyValue>& rArgs )
253
0
{
254
0
    ChartDrawMode eDrawMode = CHARTDRAW_SELECT;
255
0
    SdrObjKind eKind = SdrObjKind::NONE;
256
257
0
    ChartCommandID nFeatureId = ChartCommandID::NONE;
258
0
    OUString aBaseCommand;
259
0
    OUString aCustomShapeType;
260
0
    if ( !parseCommandURL( rCommand, &nFeatureId, &aBaseCommand, &aCustomShapeType ) )
261
0
        return;
262
263
0
    bool bCreate = false;
264
0
    m_nFeatureId = nFeatureId;
265
0
    m_aCustomShapeType = aCustomShapeType;
266
267
0
    switch ( nFeatureId )
268
0
    {
269
0
        case ChartCommandID::DrawObjectSelect:
270
0
            {
271
0
                eDrawMode = CHARTDRAW_SELECT;
272
0
                eKind = SdrObjKind::NONE;
273
0
            }
274
0
            break;
275
0
        case ChartCommandID::DrawLine:
276
0
        case ChartCommandID::DrawLineArrowEnd:
277
0
            {
278
0
                eDrawMode = CHARTDRAW_INSERT;
279
0
                eKind = SdrObjKind::Line;
280
0
            }
281
0
            break;
282
0
        case ChartCommandID::DrawRect:
283
0
            {
284
0
                eDrawMode = CHARTDRAW_INSERT;
285
0
                eKind = SdrObjKind::Rectangle;
286
0
            }
287
0
            break;
288
0
        case ChartCommandID::DrawEllipse:
289
0
            {
290
0
                eDrawMode = CHARTDRAW_INSERT;
291
0
                eKind = SdrObjKind::CircleOrEllipse;
292
0
            }
293
0
            break;
294
0
        case ChartCommandID::DrawFreelineNoFill:
295
0
            {
296
0
                eDrawMode = CHARTDRAW_INSERT;
297
0
                eKind = SdrObjKind::FreehandLine;
298
0
            }
299
0
            break;
300
0
        case ChartCommandID::DrawText:
301
0
            {
302
0
                eDrawMode = CHARTDRAW_INSERT;
303
0
                eKind = SdrObjKind::Text;
304
0
                bCreate = true;
305
0
            }
306
0
            break;
307
0
        case ChartCommandID::DrawCaption:
308
0
            {
309
0
                eDrawMode = CHARTDRAW_INSERT;
310
0
                eKind = SdrObjKind::Caption;
311
0
            }
312
0
            break;
313
0
        case ChartCommandID::DrawToolboxCsBasic:
314
0
        case ChartCommandID::DrawToolboxCsSymbol:
315
0
        case ChartCommandID::DrawToolboxCsArrow:
316
0
        case ChartCommandID::DrawToolboxCsFlowchart:
317
0
        case ChartCommandID::DrawToolboxCsCallout:
318
0
        case ChartCommandID::DrawToolboxCsStar:
319
0
            {
320
0
                eDrawMode = CHARTDRAW_INSERT;
321
0
                eKind = SdrObjKind::CustomShape;
322
0
            }
323
0
            break;
324
0
        default:
325
0
            {
326
0
                eDrawMode = CHARTDRAW_SELECT;
327
0
                eKind = SdrObjKind::NONE;
328
0
            }
329
0
            break;
330
0
    }
331
332
0
    if ( !m_pChartController )
333
0
        return;
334
335
0
    DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
336
0
    if ( !pDrawViewWrapper )
337
0
        return;
338
339
0
    SolarMutexGuard aGuard;
340
0
    m_pChartController->setDrawMode( eDrawMode );
341
0
    setInsertObj(eKind);
342
0
    if ( bCreate )
343
0
    {
344
0
        pDrawViewWrapper->SetCreateMode();
345
0
    }
346
347
0
    const beans::PropertyValue* pKeyModifier = std::find_if(rArgs.begin(), rArgs.end(),
348
0
                                                    [](const beans::PropertyValue& lhs)
349
0
                                                    {return lhs.Name == "KeyModifier";} );
350
0
    sal_Int16 nKeyModifier = 0;
351
0
    if ( !(pKeyModifier != rArgs.end() && ( pKeyModifier->Value >>= nKeyModifier ) && nKeyModifier == KEY_MOD1) )
352
0
        return;
353
354
0
    if ( eDrawMode != CHARTDRAW_INSERT )
355
0
        return;
356
357
0
    rtl::Reference<SdrObject> pObj = createDefaultObject( nFeatureId );
358
0
    if ( pObj )
359
0
    {
360
0
        SdrPageView* pPageView = pDrawViewWrapper->GetSdrPageView();
361
0
        if (pDrawViewWrapper->InsertObjectAtView(pObj.get(), *pPageView))
362
0
            m_pChartController->SetAndApplySelection(Reference<drawing::XShape>(pObj->getUnoShape(), uno::UNO_QUERY));
363
0
        if ( nFeatureId == ChartCommandID::DrawText )
364
0
        {
365
0
            m_pChartController->StartTextEdit();
366
0
        }
367
0
    }
368
0
}
369
370
void DrawCommandDispatch::describeSupportedFeatures()
371
0
{
372
0
    implDescribeSupportedFeature( u".uno:SelectObject"_ustr,      ChartCommandID::DrawObjectSelect,       CommandGroup::INSERT );
373
0
    implDescribeSupportedFeature( u".uno:Line"_ustr,              ChartCommandID::DrawLine,               CommandGroup::INSERT );
374
0
    implDescribeSupportedFeature( u".uno:LineArrowEnd"_ustr,      ChartCommandID::DrawLineArrowEnd,       CommandGroup::INSERT );
375
0
    implDescribeSupportedFeature( u".uno:Rect"_ustr,              ChartCommandID::DrawRect,               CommandGroup::INSERT );
376
0
    implDescribeSupportedFeature( u".uno:Ellipse"_ustr,           ChartCommandID::DrawEllipse,            CommandGroup::INSERT );
377
0
    implDescribeSupportedFeature( u".uno:Freeline_Unfilled"_ustr, ChartCommandID::DrawFreelineNoFill,     CommandGroup::INSERT );
378
0
    implDescribeSupportedFeature( u".uno:DrawText"_ustr,          ChartCommandID::DrawText,               CommandGroup::INSERT );
379
0
    implDescribeSupportedFeature( u".uno:DrawCaption"_ustr,       ChartCommandID::DrawCaption,            CommandGroup::INSERT );
380
0
    implDescribeSupportedFeature( u".uno:BasicShapes"_ustr,       ChartCommandID::DrawToolboxCsBasic,     CommandGroup::INSERT );
381
0
    implDescribeSupportedFeature( u".uno:SymbolShapes"_ustr,      ChartCommandID::DrawToolboxCsSymbol,    CommandGroup::INSERT );
382
0
    implDescribeSupportedFeature( u".uno:ArrowShapes"_ustr,       ChartCommandID::DrawToolboxCsArrow,     CommandGroup::INSERT );
383
0
    implDescribeSupportedFeature( u".uno:FlowChartShapes"_ustr,   ChartCommandID::DrawToolboxCsFlowchart, CommandGroup::INSERT );
384
0
    implDescribeSupportedFeature( u".uno:CalloutShapes"_ustr,     ChartCommandID::DrawToolboxCsCallout,   CommandGroup::INSERT );
385
0
    implDescribeSupportedFeature( u".uno:StarShapes"_ustr,        ChartCommandID::DrawToolboxCsStar,      CommandGroup::INSERT );
386
0
}
387
388
void DrawCommandDispatch::setInsertObj(SdrObjKind eObj)
389
0
{
390
0
    DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : nullptr );
391
0
    if ( pDrawViewWrapper )
392
0
    {
393
0
        pDrawViewWrapper->SetCurrentObj( eObj /*, Inventor */);
394
0
    }
395
0
}
396
397
rtl::Reference<SdrObject> DrawCommandDispatch::createDefaultObject( const ChartCommandID nID )
398
0
{
399
0
    rtl::Reference<SdrObject> pObj;
400
0
    DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : nullptr );
401
0
    DrawModelWrapper* pDrawModelWrapper = ( m_pChartController ? m_pChartController->GetDrawModelWrapper() : nullptr );
402
403
0
    if ( pDrawViewWrapper && pDrawModelWrapper )
404
0
    {
405
0
        rtl::Reference< SvxDrawPage > xDrawPage( pDrawModelWrapper->getMainDrawPage() );
406
0
        SdrPage* pPage = GetSdrPageFromXDrawPage( xDrawPage );
407
0
        if ( pPage )
408
0
        {
409
0
            SolarMutexGuard aGuard;
410
411
0
            pObj = SdrObjFactory::MakeNewObject(
412
0
                pDrawModelWrapper->getSdrModel(),
413
0
                pDrawViewWrapper->GetCurrentObjInventor(),
414
0
                pDrawViewWrapper->GetCurrentObjIdentifier());
415
416
0
            if ( pObj )
417
0
            {
418
0
                Size aObjectSize( 4000, 2500 );
419
0
                tools::Rectangle aPageRect( tools::Rectangle( Point( 0, 0 ), pPage->GetSize() ) );
420
0
                Point aObjectPos = aPageRect.Center();
421
0
                aObjectPos.AdjustX( -(aObjectSize.Width() / 2) );
422
0
                aObjectPos.AdjustY( -(aObjectSize.Height() / 2) );
423
0
                tools::Rectangle aRect( aObjectPos, aObjectSize );
424
425
0
                switch ( nID )
426
0
                {
427
0
                    case ChartCommandID::DrawLine:
428
0
                    case ChartCommandID::DrawLineArrowEnd:
429
0
                        {
430
0
                            if ( auto const pathObj = dynamic_cast<SdrPathObj*>( pObj.get()) )
431
0
                            {
432
0
                                Point aStart = aRect.TopLeft();
433
0
                                Point aEnd = aRect.BottomRight();
434
0
                                sal_Int32 nYMiddle( ( aRect.Top() + aRect.Bottom() ) / 2 );
435
0
                                basegfx::B2DPolygon aPoly;
436
0
                                aPoly.append( basegfx::B2DPoint( aStart.X(), nYMiddle ) );
437
0
                                aPoly.append( basegfx::B2DPoint( aEnd.X(), nYMiddle ) );
438
0
                                pathObj->SetPathPoly(basegfx::B2DPolyPolygon(aPoly));
439
0
                                SfxItemSet aSet( pDrawModelWrapper->GetItemPool() );
440
0
                                setLineEnds( aSet );
441
0
                                pObj->SetMergedItemSet( aSet );
442
0
                            }
443
0
                        }
444
0
                        break;
445
0
                    case ChartCommandID::DrawFreelineNoFill:
446
0
                        {
447
0
                            if ( auto const pathObj = dynamic_cast<SdrPathObj*>( pObj.get()) )
448
0
                            {
449
0
                                basegfx::B2DPolygon aInnerPoly;
450
0
                                aInnerPoly.append( basegfx::B2DPoint( aRect.Left(), aRect.Bottom() ) );
451
0
                                aInnerPoly.appendBezierSegment(
452
0
                                    basegfx::B2DPoint( aRect.Left(), aRect.Top() ),
453
0
                                    basegfx::B2DPoint( aRect.Center().X(), aRect.Top() ),
454
0
                                    basegfx::B2DPoint( aRect.Center().X(), aRect.Center().Y() ) );
455
0
                                aInnerPoly.appendBezierSegment(
456
0
                                    basegfx::B2DPoint( aRect.Center().X(), aRect.Bottom() ),
457
0
                                    basegfx::B2DPoint( aRect.Right(), aRect.Bottom() ),
458
0
                                    basegfx::B2DPoint( aRect.Right(), aRect.Top() ) );
459
0
                                basegfx::B2DPolyPolygon aPoly;
460
0
                                aPoly.append( aInnerPoly );
461
0
                                pathObj->SetPathPoly(aPoly);
462
0
                            }
463
0
                        }
464
0
                        break;
465
0
                    case ChartCommandID::DrawText:
466
0
                    case ChartCommandID::DrawTextVertical:
467
0
                        {
468
0
                            if ( SdrTextObj* pTextObj = DynCastSdrTextObj( pObj.get()) )
469
0
                            {
470
0
                                pTextObj->SetLogicRect( aRect );
471
0
                                bool bVertical = ( nID == ChartCommandID::DrawTextVertical );
472
0
                                pTextObj->SetVerticalWriting( bVertical );
473
0
                                if ( bVertical )
474
0
                                {
475
0
                                    SfxItemSet aSet( pDrawModelWrapper->GetItemPool() );
476
0
                                    aSet.Put( makeSdrTextAutoGrowWidthItem( true ) );
477
0
                                    aSet.Put( makeSdrTextAutoGrowHeightItem( false ) );
478
0
                                    aSet.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_TOP ) );
479
0
                                    aSet.Put( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_RIGHT ) );
480
0
                                    pTextObj->SetMergedItemSet( aSet );
481
0
                                }
482
0
                            }
483
0
                        }
484
0
                        break;
485
0
                    case ChartCommandID::DrawCaption:
486
0
                    case ChartCommandID::DrawCaptionVertical:
487
0
                        {
488
0
                            if ( SdrCaptionObj* pCaptionObj = dynamic_cast<SdrCaptionObj*>( pObj.get()) )
489
0
                            {
490
0
                                bool bIsVertical( nID == ChartCommandID::DrawCaptionVertical );
491
0
                                pCaptionObj->SetVerticalWriting( bIsVertical );
492
0
                                if ( bIsVertical )
493
0
                                {
494
0
                                    SfxItemSet aSet( pObj->GetMergedItemSet() );
495
0
                                    aSet.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
496
0
                                    aSet.Put( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_RIGHT ) );
497
0
                                    pObj->SetMergedItemSet( aSet );
498
0
                                }
499
0
                                pCaptionObj->SetLogicRect( aRect );
500
0
                                pCaptionObj->SetTailPos(
501
0
                                    aRect.TopLeft() - Point( aRect.GetWidth() / 2, aRect.GetHeight() / 2 ) );
502
0
                            }
503
0
                        }
504
0
                        break;
505
0
                    default:
506
0
                        {
507
0
                            pObj->SetLogicRect( aRect );
508
0
                            SfxItemSet aSet( pDrawModelWrapper->GetItemPool() );
509
0
                            setAttributes( pObj.get() );
510
0
                            pObj->SetMergedItemSet( aSet );
511
0
                        }
512
0
                        break;
513
0
                }
514
0
            }
515
0
        }
516
0
    }
517
518
0
    return pObj;
519
0
}
520
521
bool DrawCommandDispatch::parseCommandURL( const OUString& rCommandURL, ChartCommandID* pnFeatureId,
522
    OUString* pBaseCommand, OUString* pCustomShapeType )
523
0
{
524
0
    bool bFound = true;
525
0
    ChartCommandID nFeatureId = ChartCommandID::NONE;
526
0
    OUString aBaseCommand;
527
0
    OUString aType;
528
529
0
    sal_Int32 nIndex = std::min(sal_Int32(1), rCommandURL.getLength());
530
0
    std::u16string_view aToken = o3tl::getToken(rCommandURL, 0, '.', nIndex );
531
0
    if ( nIndex == -1 || aToken.empty() )
532
0
    {
533
0
        aBaseCommand = rCommandURL;
534
0
        SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( aBaseCommand );
535
0
        if ( aIter != m_aSupportedFeatures.end() )
536
0
        {
537
0
            nFeatureId = aIter->second.nFeatureId;
538
539
0
            switch ( nFeatureId )
540
0
            {
541
0
                case ChartCommandID::DrawToolboxCsBasic:
542
0
                    {
543
0
                        aType = "diamond";
544
0
                    }
545
0
                    break;
546
0
                case ChartCommandID::DrawToolboxCsSymbol:
547
0
                    {
548
0
                        aType = "smiley";
549
0
                    }
550
0
                    break;
551
0
                case ChartCommandID::DrawToolboxCsArrow:
552
0
                    {
553
0
                        aType = "left-right-arrow";
554
0
                    }
555
0
                    break;
556
0
                case ChartCommandID::DrawToolboxCsFlowchart:
557
0
                    {
558
0
                        aType = "flowchart-internal-storage";
559
0
                    }
560
0
                    break;
561
0
                case ChartCommandID::DrawToolboxCsCallout:
562
0
                    {
563
0
                        aType = "round-rectangular-callout";
564
0
                    }
565
0
                    break;
566
0
                case ChartCommandID::DrawToolboxCsStar:
567
0
                    {
568
0
                        aType = "star5";
569
0
                    }
570
0
                    break;
571
0
                default:
572
0
                    {
573
0
                    }
574
0
                    break;
575
0
            }
576
0
        }
577
0
        else
578
0
        {
579
0
            bFound = false;
580
0
        }
581
0
    }
582
0
    else
583
0
    {
584
0
        aBaseCommand = rCommandURL.copy( 0, nIndex - 1 );
585
0
        SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( aBaseCommand );
586
0
        if ( aIter != m_aSupportedFeatures.end() )
587
0
        {
588
0
            nFeatureId = aIter->second.nFeatureId;
589
0
            aType = rCommandURL.getToken( 0, '.', nIndex );
590
0
        }
591
0
        else
592
0
        {
593
0
            bFound = false;
594
0
        }
595
0
    }
596
597
0
    *pnFeatureId = nFeatureId;
598
0
    *pBaseCommand = aBaseCommand;
599
0
    *pCustomShapeType = aType;
600
601
0
    return bFound;
602
0
}
603
604
} //  namespace chart
605
606
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */