[Libreoffice-commits] core.git: chart2/Library_chartcore.mk chart2/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Sun Feb 12 20:09:22 UTC 2017
chart2/Library_chartcore.mk | 1
chart2/source/view/main/VButton.cxx | 86 ++++++++++++++++++++++++++++++++++++
chart2/source/view/main/VButton.hxx | 54 ++++++++++++++++++++++
3 files changed, 141 insertions(+)
New commits:
commit 30efd7cfdaa7d3faa85a775e2e4af17e74fccb78
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Tue Feb 7 12:18:31 2017 +0100
chart2: simple button (view) to add to a chart
Change-Id: I2001efe1e7eb9e92edb8f5e78535cea0e78935ad
Reviewed-on: https://gerrit.libreoffice.org/34003
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk
index 5653331..2acc34f 100644
--- a/chart2/Library_chartcore.mk
+++ b/chart2/Library_chartcore.mk
@@ -118,6 +118,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\
chart2/source/view/main/VLineProperties \
chart2/source/view/main/VPolarTransformation \
chart2/source/view/main/VTitle \
+ chart2/source/view/main/VButton \
))
ifeq ($(ENABLE_HEADLESS),)
$(eval $(call gb_Library_add_exception_objects,chartcore,\
diff --git a/chart2/source/view/main/VButton.cxx b/chart2/source/view/main/VButton.cxx
new file mode 100644
index 0000000..b89fdd1
--- /dev/null
+++ b/chart2/source/view/main/VButton.cxx
@@ -0,0 +1,86 @@
+/* -*- 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)
+ , m_rPosition(0, 0)
+{
+}
+
+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"] = uno::makeAny<float>(10.0f);
+ aTextValueMap["FillColor"] = uno::makeAny<sal_Int32>(0xe6e6e6);
+ aTextValueMap["FillStyle"] = uno::makeAny(drawing::FillStyle_SOLID);
+ aTextValueMap["LineColor"] = uno::makeAny<sal_Int32>(0xcccccc);
+ aTextValueMap["LineStyle"] = uno::makeAny(drawing::LineStyle_SOLID);
+ aTextValueMap["ParaAdjust"] = uno::makeAny(style::ParagraphAdjust_CENTER);
+ aTextValueMap["TextHorizontalAdjust"] = uno::makeAny(drawing::TextHorizontalAdjust_CENTER);
+ aTextValueMap["TextVerticalAdjust"] = uno::makeAny(drawing::TextVerticalAdjust_CENTER);
+
+ aTextValueMap["Name"] = uno::makeAny(OUString(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: */
diff --git a/chart2/source/view/main/VButton.hxx b/chart2/source/view/main/VButton.hxx
new file mode 100644
index 0000000..4a024e1
--- /dev/null
+++ b/chart2/source/view/main/VButton.hxx
@@ -0,0 +1,54 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_CHART2_SOURCE_VIEW_MAIN_VBUTTON_HXX
+#define INCLUDED_CHART2_SOURCE_VIEW_MAIN_VBUTTON_HXX
+
+#include <com/sun/star/drawing/XShapes.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+namespace chart
+{
+
+class VButton final
+{
+private:
+ css::uno::Reference<css::lang::XMultiServiceFactory> m_xShapeFactory;
+ css::uno::Reference<css::drawing::XShapes> m_xTarget;
+ css::uno::Reference<css::drawing::XShape> m_xShape;
+ css::awt::Point m_rPosition;
+ OUString m_sLabel;
+ OUString m_sCID;
+
+public:
+ VButton();
+
+ void init(const css::uno::Reference<css::drawing::XShapes>& xTargetPage,
+ const css::uno::Reference<css::lang::XMultiServiceFactory>& xFactory);
+
+ void createShapes(const css::awt::Point& rPosition,
+ const css::awt::Size& rReferenceSize,
+ const css::uno::Reference<css::beans::XPropertySet>& xTextProp);
+
+ void setWidth(sal_Int32 nWidth);
+ void setLabel(OUString const & sLabel)
+ {
+ m_sLabel = sLabel;
+ }
+ void setCID(OUString const & sCID)
+ {
+ m_sCID = sCID;
+ }
+};
+
+} //namespace chart
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list