Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/chart2/source/controller/sidebar/ChartAreaPanel.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
10
#include <sal/config.h>
11
12
#include <string_view>
13
14
#include "ChartAreaPanel.hxx"
15
16
#include <ChartController.hxx>
17
#include <ChartModel.hxx>
18
#include <ViewElementListProvider.hxx>
19
#include <PropertyHelper.hxx>
20
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
21
22
#include <chartview/DrawModelWrapper.hxx>
23
#include <com/sun/star/chart2/XDiagram.hpp>
24
#include <comphelper/lok.hxx>
25
#include <sfx2/viewsh.hxx>
26
27
#include <sfx2/weldutils.hxx>
28
#include <svx/xfltrit.hxx>
29
#include <svx/xflftrit.hxx>
30
#include <svx/xbtmpit.hxx>
31
#include <svx/unomid.hxx>
32
#include <vcl/svapp.hxx>
33
34
#include <svx/tbcontrl.hxx>
35
36
namespace chart::sidebar {
37
38
namespace {
39
40
SvxColorToolBoxControl* getColorToolBoxControl(const ToolbarUnoDispatcher& rColorDispatch)
41
0
{
42
0
    css::uno::Reference<css::frame::XToolbarController> xController = rColorDispatch.GetControllerForCommand(u".uno:FillColor"_ustr);
43
0
    SvxColorToolBoxControl* pToolBoxColorControl = dynamic_cast<SvxColorToolBoxControl*>(xController.get());
44
0
    return pToolBoxColorControl;
45
0
}
46
47
OUString getCID(const rtl::Reference<::chart::ChartModel>& xModel)
48
0
{
49
0
    css::uno::Reference<css::frame::XController> xController(xModel->getCurrentController());
50
0
    css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(xController, css::uno::UNO_QUERY);
51
0
    if (!xSelectionSupplier.is())
52
0
        return OUString();
53
54
0
    css::uno::Any aAny = xSelectionSupplier->getSelection();
55
0
    if (!aAny.hasValue())
56
0
    {
57
        // if no selection, default to diagram wall so sidebar can show some editable properties
58
0
        ChartController* pController = dynamic_cast<ChartController*>(xController.get());
59
0
        if (pController)
60
0
        {
61
0
            pController->select( css::uno::Any( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, u"" ) ) );
62
0
            xSelectionSupplier = css::uno::Reference<css::view::XSelectionSupplier>(xController, css::uno::UNO_QUERY);
63
0
            if (xSelectionSupplier.is())
64
0
                aAny = xSelectionSupplier->getSelection();
65
0
        }
66
67
0
        if (!aAny.hasValue())
68
0
            return OUString();
69
0
    }
70
71
0
    OUString aCID;
72
0
    aAny >>= aCID;
73
74
0
    return aCID;
75
0
}
76
77
css::uno::Reference<css::beans::XPropertySet> getPropSet(
78
        const rtl::Reference<::chart::ChartModel>& xModel)
79
0
{
80
0
    OUString aCID = getCID(xModel);
81
0
    css::uno::Reference<css::beans::XPropertySet> xPropSet =
82
0
        ObjectIdentifier::getObjectPropertySet(aCID, xModel);
83
84
0
    ObjectType eType = ObjectIdentifier::getObjectType(aCID);
85
0
    if (eType == OBJECTTYPE_DIAGRAM)
86
0
    {
87
0
        css::uno::Reference<css::chart2::XDiagram> xDiagram(
88
0
                xPropSet, css::uno::UNO_QUERY);
89
0
        if (!xDiagram.is())
90
0
            return xPropSet;
91
92
0
        xPropSet.set(xDiagram->getWall());
93
0
    }
94
95
0
    return xPropSet;
96
0
}
97
98
ChartController* getController(const css::uno::Reference<css::frame::XModel>& xModel)
99
0
{
100
0
    css::uno::Reference<css::frame::XController>xController = xModel->getCurrentController();
101
0
    if (!xController.is())
102
0
        throw std::exception();
103
104
0
    ChartController* pController = dynamic_cast<ChartController*>(xController.get());
105
0
    if (!pController)
106
0
        throw std::exception();
107
108
0
    return pController;
109
0
}
110
111
ViewElementListProvider getViewElementListProvider( const css::uno::Reference<css::frame::XModel>& xModel)
112
0
{
113
0
    ChartController* pController = getController(xModel);
114
0
    ViewElementListProvider aProvider = pController->getViewElementListProvider();
115
0
    return aProvider;
116
0
}
117
118
DrawModelWrapper* getDrawModelWrapper(const css::uno::Reference<css::frame::XModel>& xModel)
119
0
{
120
0
    ChartController* pController = getController(xModel);
121
0
    return pController->GetDrawModelWrapper();
122
0
}
123
124
XFillGradientItem getXGradientForName(const css::uno::Reference<css::frame::XModel>& xModel,
125
        const OUString& rName)
126
0
{
127
0
    css::uno::Reference<css::lang::XMultiServiceFactory> xFact(xModel, css::uno::UNO_QUERY);
128
0
    css::uno::Reference<css::container::XNameAccess> xNameAccess(
129
0
            xFact->createInstance(u"com.sun.star.drawing.GradientTable"_ustr), css::uno::UNO_QUERY);
130
0
    if (!xNameAccess.is())
131
0
        return XFillGradientItem();
132
133
0
    if (!xNameAccess->hasByName(rName))
134
0
        return XFillGradientItem();
135
136
0
    css::uno::Any aAny = xNameAccess->getByName(rName);
137
138
0
    XFillGradientItem aItem;
139
0
    aItem.SetName(rName);
140
0
    aItem.PutValue(aAny, MID_FILLGRADIENT);
141
142
0
    return aItem;
143
144
0
}
145
146
XFillFloatTransparenceItem getXTransparencyGradientForName(const css::uno::Reference<css::frame::XModel>& xModel,
147
        const OUString& rName)
148
0
{
149
0
    css::uno::Reference<css::lang::XMultiServiceFactory> xFact(xModel, css::uno::UNO_QUERY);
150
0
    css::uno::Reference<css::container::XNameAccess> xNameAccess(
151
0
            xFact->createInstance(u"com.sun.star.drawing.TransparencyGradientTable"_ustr), css::uno::UNO_QUERY);
152
0
    if (!xNameAccess.is())
153
0
        return XFillFloatTransparenceItem();
154
155
0
    if (!xNameAccess->hasByName(rName))
156
0
        return XFillFloatTransparenceItem();
157
158
0
    css::uno::Any aAny = xNameAccess->getByName(rName);
159
160
0
    XFillFloatTransparenceItem aItem;
161
0
    aItem.SetName(rName);
162
0
    aItem.PutValue(aAny, MID_FILLGRADIENT);
163
0
    aItem.SetEnabled(true);
164
165
0
    return aItem;
166
0
}
167
168
XHatch getXHatchFromName(const css::uno::Reference<css::frame::XModel>& xModel,
169
        OUString& rName)
170
0
{
171
0
    try
172
0
    {
173
0
        ViewElementListProvider aProvider = getViewElementListProvider(xModel);
174
0
        XHatchListRef aRef = aProvider.GetHatchList();
175
0
        size_t n = aRef->Count();
176
0
        for (size_t i = 0; i < n; ++i)
177
0
        {
178
0
            const XHatchEntry* pHatch = aRef->GetHatch(i);
179
0
            if (!pHatch)
180
0
                continue;
181
182
0
            if (pHatch->GetName().equalsIgnoreAsciiCase(rName))
183
0
            {
184
                // we need to update the hatch name
185
0
                rName = pHatch->GetName();
186
0
                return pHatch->GetHatch();
187
0
            }
188
0
        }
189
0
    }
190
0
    catch (...)
191
0
    {
192
        // ignore exception
193
0
    }
194
195
0
    return XHatch();
196
0
}
197
198
GraphicObject getXBitmapFromName(const css::uno::Reference<css::frame::XModel>& xModel,
199
        std::u16string_view rName)
200
0
{
201
0
    try
202
0
    {
203
0
        ViewElementListProvider aProvider = getViewElementListProvider(xModel);
204
0
        XBitmapListRef aBmpRef = aProvider.GetBitmapList();
205
0
        XPatternListRef aPatRef = aProvider.GetPatternList();
206
207
0
        size_t n = aBmpRef->Count();
208
0
        for (size_t i = 0; i < n; ++i)
209
0
        {
210
0
            const XBitmapEntry* pBitmap = aBmpRef->GetBitmap(i);
211
0
            if (!pBitmap)
212
0
                continue;
213
214
0
            if (pBitmap->GetName().equalsIgnoreAsciiCase(rName))
215
0
            {
216
0
                return pBitmap->GetGraphicObject();
217
0
            }
218
0
        }
219
220
        // perhaps it's a pattern
221
0
        size_t m = aPatRef->Count();
222
0
        for (size_t i = 0; i < m; ++i)
223
0
        {
224
0
            const XBitmapEntry* pBitmap = aPatRef->GetBitmap(i);
225
0
            if (!pBitmap)
226
0
                continue;
227
228
0
            if (pBitmap->GetName().equalsIgnoreAsciiCase(rName))
229
0
            {
230
0
                return pBitmap->GetGraphicObject();
231
0
            }
232
0
        }
233
0
    }
234
0
    catch (...)
235
0
    {
236
        // ignore exception
237
0
    }
238
239
0
    return GraphicObject();
240
0
}
241
242
class PreventUpdate
243
{
244
public:
245
    explicit PreventUpdate(bool& bUpdate):
246
0
        mbUpdate(bUpdate)
247
0
    {
248
0
        mbUpdate = false;
249
0
    }
250
251
    ~PreventUpdate()
252
0
    {
253
0
        mbUpdate = true;
254
0
    }
255
256
private:
257
    bool& mbUpdate;
258
};
259
260
}
261
262
std::unique_ptr<PanelLayout> ChartAreaPanel::Create(
263
        weld::Widget* pParent,
264
        const css::uno::Reference<css::frame::XFrame>& rxFrame,
265
        ChartController* pController)
266
0
{
267
0
    if (pParent == nullptr)
268
0
        throw css::lang::IllegalArgumentException(u"no parent Window given to ChartAxisPanel::Create"_ustr, nullptr, 0);
269
0
    if (!rxFrame.is())
270
0
        throw css::lang::IllegalArgumentException(u"no XFrame given to ChartAxisPanel::Create"_ustr, nullptr, 1);
271
272
0
    return std::make_unique<ChartAreaPanel>(pParent, rxFrame, pController);
273
0
}
274
275
ChartAreaPanel::ChartAreaPanel(weld::Widget* pParent,
276
        const css::uno::Reference<css::frame::XFrame>& rxFrame,
277
        ChartController* pController):
278
0
    svx::sidebar::AreaPropertyPanelBase(pParent, rxFrame),
279
0
    mxModel(pController->getChartModel()),
280
0
    mxListener(new ChartSidebarModifyListener(this)),
281
0
    mxSelectionListener(new ChartSidebarSelectionListener(this)),
282
0
    mbUpdate(true),
283
0
    mbModelValid(true),
284
0
    maFillColorWrapper(mxModel, getColorToolBoxControl(*mxColorDispatch), u"FillColor"_ustr)
285
0
{
286
0
    std::vector<ObjectType> aAcceptedTypes { OBJECTTYPE_PAGE, OBJECTTYPE_DIAGRAM,
287
0
        OBJECTTYPE_DATA_SERIES, OBJECTTYPE_DATA_POINT,
288
0
        OBJECTTYPE_TITLE, OBJECTTYPE_LEGEND};
289
0
    mxSelectionListener->setAcceptedTypes(std::move(aAcceptedTypes));
290
0
    Initialize();
291
0
}
292
293
ChartAreaPanel::~ChartAreaPanel()
294
0
{
295
0
    doUpdateModel(nullptr);
296
0
}
297
298
void ChartAreaPanel::Initialize()
299
0
{
300
0
    mxModel->addModifyListener(mxListener);
301
302
0
    css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
303
0
    if (xSelectionSupplier.is())
304
0
        xSelectionSupplier->addSelectionChangeListener(mxSelectionListener);
305
306
0
    SvxColorToolBoxControl* pToolBoxColor = getColorToolBoxControl(*mxColorDispatch);
307
0
    pToolBoxColor->setColorSelectFunction(maFillColorWrapper);
308
309
0
    updateData();
310
0
}
311
312
bool ChartAreaPanel::selectionIsDataSeries() const
313
0
{
314
0
    OUString aCID = getCID(mxModel);
315
0
    ObjectType eType = ObjectIdentifier::getObjectType(aCID);
316
0
    return eType == ObjectType::OBJECTTYPE_DATA_SERIES || eType == ObjectType::OBJECTTYPE_DATA_POINT;
317
0
}
318
319
void ChartAreaPanel::setFillTransparence(const XFillTransparenceItem& rItem)
320
0
{
321
0
    PreventUpdate aProtector(mbUpdate);
322
0
    css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
323
0
    if (!xPropSet.is())
324
0
        return;
325
326
0
    xPropSet->setPropertyValue(u"FillTransparence"_ustr, css::uno::Any(rItem.GetValue()));
327
0
}
328
329
void ChartAreaPanel::setFillFloatTransparence(
330
        const XFillFloatTransparenceItem& rItem)
331
0
{
332
0
    PreventUpdate aProtector(mbUpdate);
333
0
    css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
334
0
    if (!xPropSet.is())
335
0
        return;
336
337
0
    if (!rItem.IsEnabled())
338
0
    {
339
0
        xPropSet->setPropertyValue(u"FillTransparenceGradientName"_ustr, css::uno::Any(OUString()));
340
0
        return;
341
0
    }
342
343
0
    const OUString& aName = rItem.GetName();
344
0
    css::uno::Any aGradientVal;
345
0
    rItem.QueryValue(aGradientVal, MID_FILLGRADIENT);
346
0
    OUString aNewName = PropertyHelper::addTransparencyGradientUniqueNameToTable(aGradientVal, mxModel, aName);
347
0
    xPropSet->setPropertyValue(u"FillTransparenceGradientName"_ustr, css::uno::Any(aNewName));
348
0
}
349
350
void ChartAreaPanel::setFillStyle(const XFillStyleItem& rItem)
351
0
{
352
0
    PreventUpdate aProtector(mbUpdate);
353
0
    css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
354
0
    if (!xPropSet.is())
355
0
        return;
356
357
0
    xPropSet->setPropertyValue(u"FillStyle"_ustr, css::uno::Any(rItem.GetValue()));
358
0
}
359
360
void ChartAreaPanel::setFillStyleAndColor(const XFillStyleItem* pStyleItem,
361
        const XFillColorItem& rColorItem)
362
0
{
363
0
    css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
364
0
    if (!xPropSet.is())
365
0
        return;
366
367
0
    if (pStyleItem)
368
0
        xPropSet->setPropertyValue(u"FillStyle"_ustr, css::uno::Any(pStyleItem->GetValue()));
369
0
    xPropSet->setPropertyValue(u"FillColor"_ustr, css::uno::Any(rColorItem.GetValue()));
370
0
    if (selectionIsDataSeries())
371
0
    {
372
0
        mxModel->clearColorPalette();
373
0
    }
374
0
}
375
376
void ChartAreaPanel::setFillStyleAndGradient(const XFillStyleItem* pStyleItem,
377
        const XFillGradientItem& rGradientItem)
378
0
{
379
0
    PreventUpdate aProtector(mbUpdate);
380
0
    css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
381
0
    if (!xPropSet.is())
382
0
        return;
383
384
0
    if (pStyleItem)
385
0
        xPropSet->setPropertyValue(u"FillStyle"_ustr, css::uno::Any(pStyleItem->GetValue()));
386
387
0
    const OUString& aName = rGradientItem.GetName();
388
0
    css::uno::Any aGradientVal;
389
0
    rGradientItem.QueryValue(aGradientVal, MID_FILLGRADIENT);
390
0
    OUString aNewName = PropertyHelper::addGradientUniqueNameToTable(aGradientVal, mxModel, aName);
391
0
    xPropSet->setPropertyValue(u"FillGradientName"_ustr, css::uno::Any(aNewName));
392
0
}
393
394
void ChartAreaPanel::setFillStyleAndHatch(const XFillStyleItem* pStyleItem,
395
        const XFillHatchItem& rHatchItem)
396
0
{
397
0
    PreventUpdate aProtector(mbUpdate);
398
0
    css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
399
0
    if (!xPropSet.is())
400
0
        return;
401
402
0
    if (pStyleItem)
403
0
        xPropSet->setPropertyValue(u"FillStyle"_ustr, css::uno::Any(pStyleItem->GetValue()));
404
0
    xPropSet->setPropertyValue(u"FillHatchName"_ustr, css::uno::Any(rHatchItem.GetValue()));
405
0
}
406
407
void ChartAreaPanel::setFillStyleAndBitmap(const XFillStyleItem* pStyleItem,
408
        const XFillBitmapItem& rBitmapItem)
409
0
{
410
0
    PreventUpdate aProtector(mbUpdate);
411
0
    css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
412
0
    if (!xPropSet.is())
413
0
        return;
414
415
0
    if (pStyleItem)
416
0
        xPropSet->setPropertyValue(u"FillStyle"_ustr, css::uno::Any(pStyleItem->GetValue()));
417
418
0
    css::uno::Any aBitmap;
419
0
    rBitmapItem.QueryValue(aBitmap, MID_BITMAP);
420
0
    const OUString& aPreferredName = rBitmapItem.GetName();
421
0
    aBitmap <<= PropertyHelper::addBitmapUniqueNameToTable(aBitmap, mxModel, aPreferredName);
422
0
    xPropSet->setPropertyValue(u"FillBitmapName"_ustr, aBitmap);
423
0
}
424
425
void ChartAreaPanel::setFillUseBackground(const XFillStyleItem* pStyleItem,
426
                                          const XFillUseSlideBackgroundItem& /*rItem*/)
427
0
{
428
0
    setFillStyle(*pStyleItem);
429
0
}
430
431
void ChartAreaPanel::updateData()
432
0
{
433
0
    if (!mbUpdate || !mbModelValid)
434
0
        return;
435
436
0
    css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
437
0
    if (!xPropSet.is())
438
0
        return;
439
440
0
    css::uno::Reference<css::beans::XPropertySetInfo> xInfo(xPropSet->getPropertySetInfo());
441
0
    if (!xInfo.is())
442
0
        return;
443
444
0
    SolarMutexGuard aGuard;
445
0
    if (xInfo->hasPropertyByName(u"FillStyle"_ustr))
446
0
    {
447
0
        css::drawing::FillStyle eFillStyle = css::drawing::FillStyle_SOLID;
448
0
        xPropSet->getPropertyValue(u"FillStyle"_ustr) >>= eFillStyle;
449
0
        XFillStyleItem aFillStyleItem(eFillStyle);
450
0
        updateFillStyle(false, true, &aFillStyleItem);
451
0
    }
452
453
0
    if (xInfo->hasPropertyByName(u"FillTransparence"_ustr))
454
0
    {
455
0
        sal_uInt16 nFillTransparence = 0;
456
0
        xPropSet->getPropertyValue(u"FillTransparence"_ustr) >>= nFillTransparence;
457
0
        XFillTransparenceItem aTransparenceItem(nFillTransparence);
458
0
        updateFillTransparence(false, true, &aTransparenceItem);
459
0
    }
460
461
0
    if (xInfo->hasPropertyByName(u"FillGradientName"_ustr))
462
0
    {
463
0
        OUString aGradientName;
464
0
        xPropSet->getPropertyValue(u"FillGradientName"_ustr) >>= aGradientName;
465
0
        XFillGradientItem aGradientItem = getXGradientForName(mxModel, aGradientName);
466
0
        updateFillGradient(false, true, &aGradientItem);
467
0
    }
468
469
0
    if (xInfo->hasPropertyByName(u"FillHatchName"_ustr))
470
0
    {
471
0
        OUString aHatchName;
472
0
        xPropSet->getPropertyValue(u"FillHatchName"_ustr) >>= aHatchName;
473
0
        XHatch aHatch = getXHatchFromName(mxModel, aHatchName);
474
0
        XFillHatchItem aHatchItem(aHatchName, aHatch);
475
0
        updateFillHatch(false, true, &aHatchItem);
476
0
    }
477
478
0
    if (xInfo->hasPropertyByName(u"FillBitmapName"_ustr))
479
0
    {
480
0
        OUString aBitmapName;
481
0
        xPropSet->getPropertyValue(u"FillBitmapName"_ustr) >>= aBitmapName;
482
0
        GraphicObject aBitmap = getXBitmapFromName(mxModel, aBitmapName);
483
0
        XFillBitmapItem aBitmapItem(aBitmapName, aBitmap);
484
0
        std::unique_ptr<XFillBitmapItem> pBitmapItem;
485
0
        try
486
0
        {
487
0
            DrawModelWrapper* pModelWrapper = getDrawModelWrapper(mxModel);
488
0
            if (pModelWrapper)
489
0
            {
490
0
                pBitmapItem = aBitmapItem.checkForUniqueItem(pModelWrapper->getSdrModel());
491
0
            }
492
0
        }
493
0
        catch (...)
494
0
        {
495
0
        }
496
0
        updateFillBitmap(false, true, pBitmapItem ? pBitmapItem.get() : &aBitmapItem);
497
0
    }
498
499
0
    if (xInfo->hasPropertyByName(u"FillTransparenceGradientName"_ustr))
500
0
    {
501
0
        OUString aFillFloatTransparenceName;
502
0
        xPropSet->getPropertyValue(u"FillTransparenceGradientName"_ustr) >>= aFillFloatTransparenceName;
503
0
        XFillFloatTransparenceItem aFillFloatTransparenceItem = getXTransparencyGradientForName(mxModel, aFillFloatTransparenceName);
504
0
        updateFillFloatTransparence(false, true, &aFillFloatTransparenceItem);
505
506
0
        maFillColorWrapper.updateData();
507
0
    }
508
509
0
    if (xInfo->hasPropertyByName(u"FillColor"_ustr))
510
0
    {
511
0
        sal_uInt32 nFillColor = 0;
512
0
        xPropSet->getPropertyValue(u"FillColor"_ustr) >>= nFillColor;
513
0
        XFillColorItem aFillColorItem(u""_ustr, Color(ColorTransparency, nFillColor));
514
0
        updateFillColor(true, &aFillColorItem);
515
0
    }
516
0
}
517
518
void ChartAreaPanel::modelInvalid()
519
0
{
520
0
    mbModelValid = false;
521
0
}
522
523
void ChartAreaPanel::selectionChanged(bool bCorrectType)
524
0
{
525
0
    if (!bCorrectType)
526
0
        return;
527
528
    // set the initial correct color for the color picker
529
0
    if (comphelper::LibreOfficeKit::isActive())
530
0
    {
531
0
        css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
532
0
        if (xPropSet.is())
533
0
        {
534
0
            css::uno::Reference<css::beans::XPropertySetInfo> xInfo(xPropSet->getPropertySetInfo());
535
0
            if (xInfo.is())
536
0
            {
537
0
                SolarMutexGuard aGuard;
538
0
                if (xInfo->hasPropertyByName(u"FillStyle"_ustr))
539
0
                {
540
0
                    css::drawing::FillStyle eFillStyle = css::drawing::FillStyle::FillStyle_NONE;
541
0
                    xPropSet->getPropertyValue(u"FillStyle"_ustr) >>= eFillStyle;
542
0
                    if (eFillStyle == css::drawing::FillStyle_SOLID)
543
0
                    {
544
0
                        if (xInfo->hasPropertyByName(u"FillColor"_ustr))
545
0
                        {
546
0
                            sal_uInt32 nFillColor = static_cast<sal_uInt32>(-1);
547
0
                            xPropSet->getPropertyValue(u"FillColor"_ustr) >>= nFillColor;
548
0
                            if (nFillColor != static_cast<sal_uInt32>(-1))
549
0
                            {
550
0
                                if (SfxViewShell* pViewShell = SfxViewShell::Current())
551
0
                                {
552
0
                                    const OString sCommand = ".uno:FillColor"_ostr;
553
0
                                    pViewShell->libreOfficeKitViewCallback(
554
0
                                        LOK_CALLBACK_STATE_CHANGED,
555
0
                                        sCommand + "=" + OString::number(nFillColor));
556
0
                                }
557
0
                            }
558
0
                        }
559
0
                    }
560
0
                }
561
0
            }
562
0
        }
563
0
    }
564
565
0
    updateData();
566
0
}
567
568
void ChartAreaPanel::doUpdateModel(const rtl::Reference<::chart::ChartModel>& xModel)
569
0
{
570
0
    if (mbModelValid)
571
0
    {
572
0
        mxModel->removeModifyListener(mxListener);
573
574
0
        css::uno::Reference<css::view::XSelectionSupplier> oldSelectionSupplier(
575
0
            mxModel->getCurrentController(), css::uno::UNO_QUERY);
576
0
        if (oldSelectionSupplier.is()) {
577
0
            oldSelectionSupplier->removeSelectionChangeListener(mxSelectionListener);
578
0
        }
579
0
    }
580
581
0
    mxModel = xModel;
582
0
    mbModelValid = mxModel.is();
583
584
0
    if (!mbModelValid)
585
0
        return;
586
587
0
    mxModel->addModifyListener(mxListener);
588
589
0
    css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
590
0
    if (xSelectionSupplier.is())
591
0
        xSelectionSupplier->addSelectionChangeListener(mxSelectionListener);
592
0
}
593
594
void ChartAreaPanel::updateModel( css::uno::Reference<css::frame::XModel> xModel)
595
0
{
596
0
    ::chart::ChartModel* pModel = dynamic_cast<::chart::ChartModel*>(xModel.get());
597
    assert(!xModel || pModel);
598
0
    doUpdateModel(pModel);
599
0
}
600
601
602
}
603
604
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */