From 267c6f2ac71f92999e969232431ba04678e7437e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 07:54:39 +0200 Subject: Adding upstream version 4:24.2.0. Signed-off-by: Daniel Baumann --- chart2/source/model/main/DataTable.cxx | 209 +++++++++++++++++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100644 chart2/source/model/main/DataTable.cxx (limited to 'chart2/source/model/main/DataTable.cxx') diff --git a/chart2/source/model/main/DataTable.cxx b/chart2/source/model/main/DataTable.cxx new file mode 100644 index 0000000000..6cec190615 --- /dev/null +++ b/chart2/source/model/main/DataTable.cxx @@ -0,0 +1,209 @@ +/* -*- 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 + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +using namespace css; + +namespace +{ +/** DataTable Properties */ +enum +{ + DataTableProperty_HorizontalBorder, + DataTableProperty_VerticalBorder, + DataTableProperty_Outilne, + DataTableProperty_Keys, +}; + +void lcl_AddPropertiesToVector(std::vector& rProps) +{ + auto const nBound = beans::PropertyAttribute::BOUND; + auto const nMaybeDefault = beans::PropertyAttribute::MAYBEDEFAULT; + + rProps.emplace_back("HBorder", DataTableProperty_HorizontalBorder, cppu::UnoType::get(), + nBound | nMaybeDefault); + rProps.emplace_back("VBorder", DataTableProperty_VerticalBorder, cppu::UnoType::get(), + nBound | nMaybeDefault); + rProps.emplace_back("Outline", DataTableProperty_Outilne, cppu::UnoType::get(), + nBound | nMaybeDefault); + rProps.emplace_back("Keys", DataTableProperty_Keys, cppu::UnoType::get(), + nBound | nMaybeDefault); +} + +const ::chart::tPropertyValueMap& StaticDataTableDefaults() +{ + static ::chart::tPropertyValueMap aStaticDefaults = []() { + ::chart::tPropertyValueMap aMap; + ::chart::LinePropertiesHelper::AddDefaultsToMap(aMap); + ::chart::FillProperties::AddDefaultsToMap(aMap); + ::chart::CharacterProperties::AddDefaultsToMap(aMap); + + ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_HorizontalBorder, + false); + ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_VerticalBorder, + false); + ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_Outilne, false); + ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_Keys, false); + + ::chart::PropertyHelper::setPropertyValue( + aMap, ::chart::LinePropertiesHelper::PROP_LINE_WIDTH, uno::Any(sal_Int32(1))); + + ::chart::PropertyHelper::setPropertyValueDefault( + aMap, ::chart::FillProperties::PROP_FILL_STYLE, drawing::FillStyle_NONE); + + float fDefaultCharHeight = 10.0; + ::chart::PropertyHelper::setPropertyValue( + aMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight); + ::chart::PropertyHelper::setPropertyValue( + aMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight); + ::chart::PropertyHelper::setPropertyValue( + aMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight); + return aMap; + }(); + return aStaticDefaults; +}; + +cppu::OPropertyArrayHelper& StaticDataTableInfoHelper() +{ + static cppu::OPropertyArrayHelper aPropHelper = []() { + std::vector aProperties; + lcl_AddPropertiesToVector(aProperties); + ::chart::LinePropertiesHelper::AddPropertiesToVector(aProperties); + ::chart::FillProperties::AddPropertiesToVector(aProperties); + ::chart::CharacterProperties::AddPropertiesToVector(aProperties); + std::sort(aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess()); + + return comphelper::containerToSequence(aProperties); + }(); + return aPropHelper; +}; + +} // anonymous namespace + +namespace chart +{ +DataTable::DataTable() + : m_xModifyEventForwarder(new ModifyEventForwarder()) +{ +} + +DataTable::DataTable(const DataTable& rOther) + : DataTable_Base(rOther) + , ::property::OPropertySet(rOther) + , m_xModifyEventForwarder(new ModifyEventForwarder()) +{ +} + +DataTable::~DataTable() = default; + +// ____ XCloneable ____ +uno::Reference SAL_CALL DataTable::createClone() +{ + return uno::Reference(new DataTable(*this)); +} + +// ____ XModifyBroadcaster ____ +void SAL_CALL DataTable::addModifyListener(const uno::Reference& aListener) +{ + m_xModifyEventForwarder->addModifyListener(aListener); +} + +void SAL_CALL +DataTable::removeModifyListener(const uno::Reference& aListener) +{ + m_xModifyEventForwarder->removeModifyListener(aListener); +} + +// ____ XModifyListener ____ +void SAL_CALL DataTable::modified(const lang::EventObject& aEvent) +{ + m_xModifyEventForwarder->modified(aEvent); +} + +// ____ XEventListener (base of XModifyListener) ____ +void SAL_CALL DataTable::disposing(const lang::EventObject& /* Source */) +{ + // nothing +} + +// ____ OPropertySet ____ +void DataTable::firePropertyChangeEvent() +{ + m_xModifyEventForwarder->modified(lang::EventObject(static_cast(this))); +} + +// ____ OPropertySet ____ +void DataTable::GetDefaultValue(sal_Int32 nHandle, uno::Any& rAny) const +{ + const tPropertyValueMap& rStaticDefaults = StaticDataTableDefaults(); + auto aFound = rStaticDefaults.find(nHandle); + if (aFound == rStaticDefaults.end()) + rAny.clear(); + else + rAny = (*aFound).second; +} + +::cppu::IPropertyArrayHelper& SAL_CALL DataTable::getInfoHelper() +{ + return StaticDataTableInfoHelper(); +} + +// ____ XPropertySet ____ +uno::Reference SAL_CALL DataTable::getPropertySetInfo() +{ + static uno::Reference xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(StaticDataTableInfoHelper())); + return xPropertySetInfo; +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +OUString SAL_CALL DataTable::getImplementationName() +{ + return "com.sun.star.comp.chart2.DataTable"; +} + +sal_Bool SAL_CALL DataTable::supportsService(const OUString& rServiceName) +{ + return cppu::supportsService(this, rServiceName); +} + +uno::Sequence SAL_CALL DataTable::getSupportedServiceNames() +{ + return { "com.sun.star.chart2.DataTable", "com.sun.star.beans.PropertySet", + "com.sun.star.drawing.FillProperties", "com.sun.star.drawing.LineProperties", + "com.sun.star.style.CharacterProperties" }; +} + +IMPLEMENT_FORWARD_XINTERFACE2(DataTable, DataTable_Base, ::property::OPropertySet) +IMPLEMENT_FORWARD_XTYPEPROVIDER2(DataTable, DataTable_Base, ::property::OPropertySet) + +} // namespace chart + +extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* +com_sun_star_comp_chart2_DataTable_get_implementation( + css::uno::XComponentContext* /*pComponentContext*/, uno::Sequence const& /*rAny*/) +{ + return cppu::acquire(new ::chart::DataTable); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3