summaryrefslogtreecommitdiff
path: root/chart2/source/view/main/VButton.cxx
blob: 996ceff2c288ac2b9b05ee6f9790d2ede1f116a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include "VButton.hxx"

#include "AbstractShapeFactory.hxx"
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/style/ParagraphAdjust.hpp>
#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>

#include <memory>

namespace chart
{

using namespace css;

VButton::VButton()
    : m_xShapeFactory(nullptr)
    , m_xTarget(nullptr)
    , m_xShape(nullptr)
{
}

void VButton::init(const uno::Reference<drawing::XShapes>& xTargetPage,
                  const uno::Reference<lang::XMultiServiceFactory>& xFactory)
{
    m_xTarget = xTargetPage;
    m_xShapeFactory = xFactory;
}

void VButton::createShapes(const awt::Point& rPosition,
                           const awt::Size& rReferenceSize,
                           const uno::Reference<beans::XPropertySet>& xTextProp)
{
    AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(m_xShapeFactory);

    std::unique_ptr<tNameSequence> pPropNames(new tNameSequence);
    std::unique_ptr<tAnySequence> pPropValues(new tAnySequence);

    PropertyMapper::getTextLabelMultiPropertyLists(xTextProp, *pPropNames, *pPropValues);

    tPropertyNameValueMap aTextValueMap;
    aTextValueMap["CharHeight"] <<= 10.0f;
    aTextValueMap["FillColor"] <<= (sal_Int32)0xe6e6e6;
    aTextValueMap["FillStyle"] <<= drawing::FillStyle_SOLID;
    aTextValueMap["LineColor"] <<= (sal_Int32)0xcccccc;
    aTextValueMap["LineStyle"] <<= drawing::LineStyle_SOLID;
    aTextValueMap["ParaAdjust"] <<= style::ParagraphAdjust_CENTER;
    aTextValueMap["TextHorizontalAdjust"] <<= drawing::TextHorizontalAdjust_CENTER;
    aTextValueMap["TextVerticalAdjust"] <<= drawing::TextVerticalAdjust_CENTER;

    aTextValueMap["Name"] <<= m_sCID; //CID OUString

    PropertyMapper::getMultiPropertyListsFromValueMap(*pPropNames, *pPropValues, aTextValueMap);

    uno::Reference<drawing::XShape> xEntry = pShapeFactory->createText(
        m_xTarget, m_sLabel, *pPropNames, *pPropValues, uno::Any());

    if (xEntry.is())
    {
        m_xShape = xEntry;
        m_xShape->setPosition(rPosition);
        m_xShape->setSize(rReferenceSize);
    }
}

void VButton::setWidth(sal_Int32 nWidth)
{
    awt::Size aSize = m_xShape->getSize();
    aSize.Width = nWidth;
    m_xShape->setSize(aSize);
}

} //namespace chart

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */