1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #include "VButton.hxx"
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>
19 #include <CommonConverters.hxx>
20 #include <editeng/unoprnms.hxx>
28 , m_nArrowColor(0x00000000)
29 , m_nBGColor(0x00E6E6E6)
33 void VButton::init(const rtl::Reference
<SvxShapeGroupAnyD
>& xTargetPage
)
35 m_xTarget
= xTargetPage
;
38 rtl::Reference
<SvxShapePolyPolygon
> VButton::createTriangle(awt::Size aSize
)
40 rtl::Reference
<SvxShapePolyPolygon
> xShape
= new SvxShapePolyPolygon(nullptr);
41 xShape
->setShapeKind(SdrObjKind::Polygon
);
43 drawing::PolyPolygonShape3D aPolyPolygon
;
44 aPolyPolygon
.SequenceX
.realloc(1);
45 aPolyPolygon
.SequenceY
.realloc(1);
46 aPolyPolygon
.SequenceZ
.realloc(1);
48 drawing::DoubleSequence
* pOuterSequenceX
= aPolyPolygon
.SequenceX
.getArray();
49 drawing::DoubleSequence
* pOuterSequenceY
= aPolyPolygon
.SequenceY
.getArray();
50 drawing::DoubleSequence
* pOuterSequenceZ
= aPolyPolygon
.SequenceZ
.getArray();
52 pOuterSequenceX
->realloc(3);
53 pOuterSequenceY
->realloc(3);
54 pOuterSequenceZ
->realloc(3);
56 double* pInnerSequenceX
= pOuterSequenceX
->getArray();
57 double* pInnerSequenceY
= pOuterSequenceY
->getArray();
58 double* pInnerSequenceZ
= pOuterSequenceZ
->getArray();
60 pInnerSequenceX
[0] = 0.0;
61 pInnerSequenceY
[0] = 0.0;
62 pInnerSequenceZ
[0] = 0.0;
64 pInnerSequenceX
[1] = aSize
.Width
/ 2.0;
65 pInnerSequenceY
[1] = aSize
.Height
;
66 pInnerSequenceZ
[1] = 0.0;
68 pInnerSequenceX
[2] = aSize
.Width
;
69 pInnerSequenceY
[2] = 0.0;
70 pInnerSequenceZ
[2] = 0.0;
72 xShape
->SvxShape::setPropertyValue(u
"Name"_ustr
, uno::Any(m_sCID
));
73 xShape
->SvxShape::setPropertyValue(UNO_NAME_POLYPOLYGON
,
74 uno::Any(PolyToPointSequence(aPolyPolygon
)));
75 xShape
->SvxShape::setPropertyValue(u
"LineStyle"_ustr
, uno::Any(drawing::LineStyle_NONE
));
76 xShape
->SvxShape::setPropertyValue(u
"FillColor"_ustr
, uno::Any(m_nArrowColor
));
81 void VButton::createShapes(const uno::Reference
<beans::XPropertySet
>& xTextProp
)
83 tNameSequence aPropNames
;
84 tAnySequence aPropValues
;
86 PropertyMapper::getTextLabelMultiPropertyLists(xTextProp
, aPropNames
, aPropValues
);
88 m_xShape
= ShapeFactory::createGroup2D(m_xTarget
, m_sCID
);
89 m_xShape
->setPosition(m_aPosition
);
90 m_xShape
->setSize(m_aSize
);
92 rtl::Reference
<SvxShapeGroupAnyD
> xContainer
= m_xShape
;
94 tPropertyNameValueMap aTextValueMap
;
95 aTextValueMap
[u
"CharHeight"_ustr
] <<= 10.0f
;
96 aTextValueMap
[u
"CharHeightAsian"_ustr
] <<= 10.0f
;
97 aTextValueMap
[u
"CharHeightComplex"_ustr
] <<= 10.0f
;
98 aTextValueMap
[u
"FillColor"_ustr
] <<= m_nBGColor
;
99 aTextValueMap
[u
"FillStyle"_ustr
] <<= drawing::FillStyle_SOLID
;
100 aTextValueMap
[u
"LineColor"_ustr
] <<= sal_Int32(0xcccccc);
101 aTextValueMap
[u
"LineStyle"_ustr
] <<= drawing::LineStyle_SOLID
;
102 aTextValueMap
[u
"ParaAdjust"_ustr
] <<= style::ParagraphAdjust_CENTER
;
103 aTextValueMap
[u
"TextHorizontalAdjust"_ustr
] <<= drawing::TextHorizontalAdjust_LEFT
;
104 aTextValueMap
[u
"TextVerticalAdjust"_ustr
] <<= drawing::TextVerticalAdjust_CENTER
;
105 aTextValueMap
[u
"ParaLeftMargin"_ustr
] <<= sal_Int32(100);
106 aTextValueMap
[u
"ParaRightMargin"_ustr
] <<= sal_Int32(600);
108 aTextValueMap
[u
"Name"_ustr
] <<= m_sCID
; //CID OUString
110 PropertyMapper::getMultiPropertyListsFromValueMap(aPropNames
, aPropValues
, aTextValueMap
);
112 rtl::Reference
<SvxShapeText
> xEntry
113 = ShapeFactory::createText(xContainer
, m_sLabel
, aPropNames
, aPropValues
, uno::Any());
117 xEntry
->setPosition(m_aPosition
);
118 xEntry
->setSize(m_aSize
);
124 awt::Size aPolySize
{ 280, 180 };
126 rtl::Reference
<SvxShapePolyPolygon
> xPoly
= createTriangle(aPolySize
);
127 xPoly
->setSize(aPolySize
);
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
);
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */