LibreOffice Module chart2 (master) 1
VButton.cxx
Go to the documentation of this file.
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
22namespace chart
23{
24using namespace css;
25
27 : m_bShowArrow(true)
28 , m_nArrowColor(0x00000000)
29 , m_nBGColor(0x00E6E6E6)
30{
31}
32
34{
35 m_xTarget = xTargetPage;
36}
37
39{
41 xShape->setShapeKind(SdrObjKind::Polygon);
42
43 drawing::PolyPolygonShape3D aPolyPolygon;
44 aPolyPolygon.SequenceX.realloc(1);
45 aPolyPolygon.SequenceY.realloc(1);
46 aPolyPolygon.SequenceZ.realloc(1);
47
48 drawing::DoubleSequence* pOuterSequenceX = aPolyPolygon.SequenceX.getArray();
49 drawing::DoubleSequence* pOuterSequenceY = aPolyPolygon.SequenceY.getArray();
50 drawing::DoubleSequence* pOuterSequenceZ = aPolyPolygon.SequenceZ.getArray();
51
52 pOuterSequenceX->realloc(3);
53 pOuterSequenceY->realloc(3);
54 pOuterSequenceZ->realloc(3);
55
56 double* pInnerSequenceX = pOuterSequenceX->getArray();
57 double* pInnerSequenceY = pOuterSequenceY->getArray();
58 double* pInnerSequenceZ = pOuterSequenceZ->getArray();
59
60 pInnerSequenceX[0] = 0.0;
61 pInnerSequenceY[0] = 0.0;
62 pInnerSequenceZ[0] = 0.0;
63
64 pInnerSequenceX[1] = aSize.Width / 2.0;
65 pInnerSequenceY[1] = aSize.Height;
66 pInnerSequenceZ[1] = 0.0;
67
68 pInnerSequenceX[2] = aSize.Width;
69 pInnerSequenceY[2] = 0.0;
70 pInnerSequenceZ[2] = 0.0;
71
72 xShape->SvxShape::setPropertyValue("Name", uno::Any(m_sCID));
73 xShape->SvxShape::setPropertyValue(UNO_NAME_POLYPOLYGON,
74 uno::Any(PolyToPointSequence(aPolyPolygon)));
75 xShape->SvxShape::setPropertyValue("LineStyle", uno::Any(drawing::LineStyle_NONE));
76 xShape->SvxShape::setPropertyValue("FillColor", uno::Any(m_nArrowColor));
77
78 return xShape;
79}
80
82{
84 tAnySequence aPropValues;
85
87
89 m_xShape->setPosition(m_aPosition);
90 m_xShape->setSize(m_aSize);
91
93
94 tPropertyNameValueMap aTextValueMap;
95 aTextValueMap["CharHeight"] <<= 10.0f;
96 aTextValueMap["CharHeightAsian"] <<= 10.0f;
97 aTextValueMap["CharHeightComplex"] <<= 10.0f;
98 aTextValueMap["FillColor"] <<= m_nBGColor;
99 aTextValueMap["FillStyle"] <<= drawing::FillStyle_SOLID;
100 aTextValueMap["LineColor"] <<= sal_Int32(0xcccccc);
101 aTextValueMap["LineStyle"] <<= drawing::LineStyle_SOLID;
102 aTextValueMap["ParaAdjust"] <<= style::ParagraphAdjust_CENTER;
103 aTextValueMap["TextHorizontalAdjust"] <<= drawing::TextHorizontalAdjust_LEFT;
104 aTextValueMap["TextVerticalAdjust"] <<= drawing::TextVerticalAdjust_CENTER;
105 aTextValueMap["ParaLeftMargin"] <<= sal_Int32(100);
106 aTextValueMap["ParaRightMargin"] <<= sal_Int32(600);
107
108 aTextValueMap["Name"] <<= m_sCID; //CID OUString
109
111
113 = ShapeFactory::createText(xContainer, m_sLabel, aPropNames, aPropValues, uno::Any());
114
115 if (xEntry.is())
116 {
117 xEntry->setPosition(m_aPosition);
118 xEntry->setSize(m_aSize);
119 }
120
121 if (!m_bShowArrow)
122 return;
123
124 awt::Size aPolySize{ 280, 180 };
125
127 xPoly->setSize(aPolySize);
128 xPoly->setPosition(
129 { sal_Int32(m_aPosition.X + m_aSize.Width - aPolySize.Width - 100),
130 sal_Int32(m_aPosition.Y + (m_aSize.Height / 2.0) - (aPolySize.Height / 2.0)) });
131 xContainer->add(xPoly);
132}
133
134} //namespace chart
135
136/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void getMultiPropertyListsFromValueMap(tNameSequence &rNames, tAnySequence &rValues, const tPropertyNameValueMap &rValueMap)
static void getTextLabelMultiPropertyLists(const css::uno::Reference< css::beans::XPropertySet > &xSourceProp, tNameSequence &rPropNames, tAnySequence &rPropValues, bool bName=true, sal_Int32 nLimitedSpace=-1, bool bLimitedHeight=false, bool bSupportsLabelBorder=true)
static rtl::Reference< SvxShapeText > createText(const rtl::Reference< SvxShapeGroupAnyD > &xTarget2D, const OUString &rText, const tNameSequence &rPropNames, const tAnySequence &rPropValues, const css::uno::Any &rATransformation)
static rtl::Reference< SvxShapeGroup > createGroup2D(const rtl::Reference< SvxShapeGroupAnyD > &xTarget, const OUString &aName=OUString())
Color m_nBGColor
Definition: VButton.hxx:38
Color m_nArrowColor
Definition: VButton.hxx:37
rtl::Reference< SvxShapePolyPolygon > createTriangle(css::awt::Size aSize)
Definition: VButton.cxx:38
void createShapes(const css::uno::Reference< css::beans::XPropertySet > &xTextProp)
Definition: VButton.cxx:81
css::awt::Point m_aPosition
Definition: VButton.hxx:34
OUString m_sLabel
Definition: VButton.hxx:32
rtl::Reference< SvxShapeGroup > m_xShape
Definition: VButton.hxx:31
void init(const rtl::Reference< SvxShapeGroupAnyD > &xTargetPage)
Definition: VButton.cxx:33
OUString m_sCID
Definition: VButton.hxx:33
bool m_bShowArrow
Definition: VButton.hxx:36
css::awt::Size m_aSize
Definition: VButton.hxx:35
rtl::Reference< SvxShapeGroupAnyD > m_xTarget
Definition: VButton.hxx:30
css::uno::Sequence< OUString > tNameSequence
css::uno::Sequence< css::uno::Any > tAnySequence
std::unordered_map< OUString, css::uno::Any > tPropertyNameValueMap
OOO_DLLPUBLIC_CHARTTOOLS css::drawing::PointSequenceSequence PolyToPointSequence(const css::drawing::PolyPolygonShape3D &rPolyPolygon)
PolyPolygonShape3D -> drawing::PointSequenceSequence (2D)
const PropertyStruct aPropNames[]
constexpr OUStringLiteral UNO_NAME_POLYPOLYGON