Coverage Report

Created: 2026-07-10 11:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/chart2/source/view/main/VButton.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 "VButton.hxx"
11
12
#include <ShapeFactory.hxx>
13
#include <com/sun/star/drawing/FillStyle.hpp>
14
#include <com/sun/star/drawing/LineStyle.hpp>
15
#include <com/sun/star/style/ParagraphAdjust.hpp>
16
#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
17
#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
18
19
#include <CommonConverters.hxx>
20
#include <editeng/unoprnms.hxx>
21
22
namespace chart
23
{
24
using namespace css;
25
26
VButton::VButton()
27
0
    : m_bShowArrow(true)
28
0
    , m_nArrowColor(0x00000000)
29
0
    , m_nBGColor(0x00E6E6E6)
30
0
{
31
0
}
32
33
void VButton::init(const rtl::Reference<SvxShapeGroupAnyD>& xTargetPage)
34
0
{
35
0
    m_xTarget = xTargetPage;
36
0
}
37
38
rtl::Reference<SvxShapePolyPolygon> VButton::createTriangle(awt::Size aSize)
39
0
{
40
0
    rtl::Reference<SvxShapePolyPolygon> xShape = new SvxShapePolyPolygon(nullptr);
41
0
    xShape->setShapeKind(SdrObjKind::Polygon);
42
43
0
    drawing::PolyPolygonShape3D aPolyPolygon;
44
0
    aPolyPolygon.SequenceX.realloc(1);
45
0
    aPolyPolygon.SequenceY.realloc(1);
46
0
    aPolyPolygon.SequenceZ.realloc(1);
47
48
0
    drawing::DoubleSequence* pOuterSequenceX = aPolyPolygon.SequenceX.getArray();
49
0
    drawing::DoubleSequence* pOuterSequenceY = aPolyPolygon.SequenceY.getArray();
50
0
    drawing::DoubleSequence* pOuterSequenceZ = aPolyPolygon.SequenceZ.getArray();
51
52
0
    pOuterSequenceX->realloc(3);
53
0
    pOuterSequenceY->realloc(3);
54
0
    pOuterSequenceZ->realloc(3);
55
56
0
    double* pInnerSequenceX = pOuterSequenceX->getArray();
57
0
    double* pInnerSequenceY = pOuterSequenceY->getArray();
58
0
    double* pInnerSequenceZ = pOuterSequenceZ->getArray();
59
60
0
    pInnerSequenceX[0] = 0.0;
61
0
    pInnerSequenceY[0] = 0.0;
62
0
    pInnerSequenceZ[0] = 0.0;
63
64
0
    pInnerSequenceX[1] = aSize.Width / 2.0;
65
0
    pInnerSequenceY[1] = aSize.Height;
66
0
    pInnerSequenceZ[1] = 0.0;
67
68
0
    pInnerSequenceX[2] = aSize.Width;
69
0
    pInnerSequenceY[2] = 0.0;
70
0
    pInnerSequenceZ[2] = 0.0;
71
72
0
    xShape->SvxShape::setPropertyValue(u"Name"_ustr, uno::Any(m_sCID));
73
0
    xShape->SvxShape::setPropertyValue(UNO_NAME_POLYPOLYGON,
74
0
                                       uno::Any(PolyToPointSequence(aPolyPolygon)));
75
0
    xShape->SvxShape::setPropertyValue(u"LineStyle"_ustr, uno::Any(drawing::LineStyle_NONE));
76
0
    xShape->SvxShape::setPropertyValue(u"FillColor"_ustr, uno::Any(m_nArrowColor));
77
78
0
    return xShape;
79
0
}
80
81
void VButton::createShapes(const uno::Reference<beans::XPropertySet>& xTextProp)
82
0
{
83
0
    tNameSequence aPropNames;
84
0
    tAnySequence aPropValues;
85
86
0
    PropertyMapper::getTextLabelMultiPropertyLists(xTextProp, aPropNames, aPropValues);
87
88
0
    m_xShape = ShapeFactory::createGroup2D(m_xTarget, m_sCID);
89
0
    m_xShape->setPosition(m_aPosition);
90
0
    m_xShape->setSize(m_aSize);
91
92
0
    rtl::Reference<SvxShapeGroupAnyD> xContainer = m_xShape;
93
94
0
    tPropertyNameValueMap aTextValueMap;
95
0
    aTextValueMap[u"CharHeight"_ustr] <<= 10.0f;
96
0
    aTextValueMap[u"CharHeightAsian"_ustr] <<= 10.0f;
97
0
    aTextValueMap[u"CharHeightComplex"_ustr] <<= 10.0f;
98
0
    aTextValueMap[u"FillColor"_ustr] <<= m_nBGColor;
99
0
    aTextValueMap[u"FillStyle"_ustr] <<= drawing::FillStyle_SOLID;
100
0
    aTextValueMap[u"LineColor"_ustr] <<= sal_Int32(0xcccccc);
101
0
    aTextValueMap[u"LineStyle"_ustr] <<= drawing::LineStyle_SOLID;
102
0
    aTextValueMap[u"ParaAdjust"_ustr] <<= style::ParagraphAdjust_CENTER;
103
0
    aTextValueMap[u"TextHorizontalAdjust"_ustr] <<= drawing::TextHorizontalAdjust_LEFT;
104
0
    aTextValueMap[u"TextVerticalAdjust"_ustr] <<= drawing::TextVerticalAdjust_CENTER;
105
0
    aTextValueMap[u"ParaLeftMargin"_ustr] <<= sal_Int32(100);
106
0
    aTextValueMap[u"ParaRightMargin"_ustr] <<= sal_Int32(600);
107
108
0
    aTextValueMap[u"Name"_ustr] <<= m_sCID; //CID OUString
109
110
0
    PropertyMapper::getMultiPropertyListsFromValueMap(aPropNames, aPropValues, aTextValueMap);
111
112
0
    rtl::Reference<SvxShapeText> xEntry
113
0
        = ShapeFactory::createText(xContainer, m_sLabel, aPropNames, aPropValues, uno::Any());
114
115
0
    if (xEntry.is())
116
0
    {
117
0
        xEntry->setPosition(m_aPosition);
118
0
        xEntry->setSize(m_aSize);
119
0
    }
120
121
0
    if (!m_bShowArrow)
122
0
        return;
123
124
0
    awt::Size aPolySize{ 280, 180 };
125
126
0
    rtl::Reference<SvxShapePolyPolygon> xPoly = createTriangle(aPolySize);
127
0
    xPoly->setSize(aPolySize);
128
0
    xPoly->setPosition(
129
0
        { sal_Int32(m_aPosition.X + m_aSize.Width - aPolySize.Width - 100),
130
0
          sal_Int32(m_aPosition.Y + (m_aSize.Height / 2.0) - (aPolySize.Height / 2.0)) });
131
0
    xContainer->add(xPoly);
132
0
}
133
134
} //namespace chart
135
136
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */