LibreOffice Module chart2 (master) 1
DataTable.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 <DataTable.hxx>
11
13#include <FillProperties.hxx>
16#include <PropertyHelper.hxx>
18
19#include <com/sun/star/beans/PropertyAttribute.hpp>
20#include <com/sun/star/uno/XComponentContext.hpp>
21#include <com/sun/star/drawing/FillStyle.hpp>
22
23#include <algorithm>
24
25using namespace css;
26
27namespace
28{
30enum
31{
32 DataTableProperty_HorizontalBorder,
33 DataTableProperty_VerticalBorder,
34 DataTableProperty_Outilne,
35 DataTableProperty_Keys,
36};
37
38void lcl_AddPropertiesToVector(std::vector<beans::Property>& rProps)
39{
40 auto const nBound = beans::PropertyAttribute::BOUND;
41 auto const nMaybeDefault = beans::PropertyAttribute::MAYBEDEFAULT;
42
43 rProps.emplace_back("HBorder", DataTableProperty_HorizontalBorder, cppu::UnoType<bool>::get(),
44 nBound | nMaybeDefault);
45 rProps.emplace_back("VBorder", DataTableProperty_VerticalBorder, cppu::UnoType<bool>::get(),
46 nBound | nMaybeDefault);
47 rProps.emplace_back("Outline", DataTableProperty_Outilne, cppu::UnoType<bool>::get(),
48 nBound | nMaybeDefault);
49 rProps.emplace_back("Keys", DataTableProperty_Keys, cppu::UnoType<bool>::get(),
50 nBound | nMaybeDefault);
51}
52
53const ::chart::tPropertyValueMap& StaticDataTableDefaults()
54{
55 static ::chart::tPropertyValueMap aStaticDefaults = []() {
60
61 ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_HorizontalBorder,
62 false);
63 ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_VerticalBorder,
64 false);
65 ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_Outilne, false);
66 ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_Keys, false);
67
70
72 aMap, ::chart::FillProperties::PROP_FILL_STYLE, drawing::FillStyle_NONE);
73
74 float fDefaultCharHeight = 10.0;
81 return aMap;
82 }();
83 return aStaticDefaults;
84};
85
86cppu::OPropertyArrayHelper& StaticDataTableInfoHelper()
87{
88 static cppu::OPropertyArrayHelper aPropHelper = []() {
89 std::vector<beans::Property> aProperties;
90 lcl_AddPropertiesToVector(aProperties);
94 std::sort(aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess());
95
96 return comphelper::containerToSequence(aProperties);
97 }();
98 return aPropHelper;
99};
100
101} // anonymous namespace
102
103namespace chart
104{
106 : m_xModifyEventForwarder(new ModifyEventForwarder())
107{
108}
109
111 : DataTable_Base(rOther)
112 , ::property::OPropertySet(rOther)
113 , m_xModifyEventForwarder(new ModifyEventForwarder())
114{
115}
116
117DataTable::~DataTable() = default;
118
119// ____ XCloneable ____
121{
123}
124
125// ____ XModifyBroadcaster ____
127{
128 m_xModifyEventForwarder->addModifyListener(aListener);
129}
130
131void SAL_CALL
133{
134 m_xModifyEventForwarder->removeModifyListener(aListener);
135}
136
137// ____ XModifyListener ____
138void SAL_CALL DataTable::modified(const lang::EventObject& aEvent)
139{
141}
142
143// ____ XEventListener (base of XModifyListener) ____
144void SAL_CALL DataTable::disposing(const lang::EventObject& /* Source */)
145{
146 // nothing
147}
148
149// ____ OPropertySet ____
151{
152 m_xModifyEventForwarder->modified(lang::EventObject(static_cast<uno::XWeak*>(this)));
153}
154
155// ____ OPropertySet ____
156void DataTable::GetDefaultValue(sal_Int32 nHandle, uno::Any& rAny) const
157{
158 const tPropertyValueMap& rStaticDefaults = StaticDataTableDefaults();
159 auto aFound = rStaticDefaults.find(nHandle);
160 if (aFound == rStaticDefaults.end())
161 rAny.clear();
162 else
163 rAny = (*aFound).second;
164}
165
167{
168 return StaticDataTableInfoHelper();
169}
170
171// ____ XPropertySet ____
173{
174 static uno::Reference<beans::XPropertySetInfo> xPropertySetInfo(
175 ::cppu::OPropertySetHelper::createPropertySetInfo(StaticDataTableInfoHelper()));
176 return xPropertySetInfo;
177}
178
179// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
181{
182 return "com.sun.star.comp.chart2.DataTable";
183}
184
185sal_Bool SAL_CALL DataTable::supportsService(const OUString& rServiceName)
186{
187 return cppu::supportsService(this, rServiceName);
188}
189
191{
192 return { "com.sun.star.chart2.DataTable", "com.sun.star.beans.PropertySet",
193 "com.sun.star.drawing.FillProperties", "com.sun.star.drawing.LineProperties",
194 "com.sun.star.style.CharacterProperties" };
195}
196
199
200} // namespace chart
201
202extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
204 css::uno::XComponentContext* /*pComponentContext*/, uno::Sequence<uno::Any> const& /*rAny*/)
205{
206 return cppu::acquire(new ::chart::DataTable);
207}
208
209/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_chart2_DataTable_get_implementation(css::uno::XComponentContext *, uno::Sequence< uno::Any > const &)
Definition: DataTable.cxx:203
PropertiesInfo aProperties
AnyEventRef aEvent
Data table implementation.
Definition: DataTable.hxx:32
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: DataTable.cxx:185
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: DataTable.cxx:190
rtl::Reference< ModifyEventForwarder > m_xModifyEventForwarder
Definition: DataTable.hxx:82
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
The InfoHelper table contains all property names and types of this object.
Definition: DataTable.cxx:166
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
Definition: DataTable.cxx:120
virtual void firePropertyChangeEvent() override
implement this method in derived classes to get called when properties change.
Definition: DataTable.cxx:150
virtual OUString SAL_CALL getImplementationName() override
XServiceInfo declarations.
Definition: DataTable.cxx:180
virtual void SAL_CALL removeModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
Definition: DataTable.cxx:132
virtual void SAL_CALL modified(const css::lang::EventObject &aEvent) override
Definition: DataTable.cxx:138
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: DataTable.cxx:172
virtual void GetDefaultValue(sal_Int32 nHandle, css::uno::Any &rAny) const override
implement this method to provide default values for all properties supporting defaults.
Definition: DataTable.cxx:156
virtual ~DataTable() override
virtual void SAL_CALL addModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
Definition: DataTable.cxx:126
This helper class serves as forwarder of modify events.
static css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL createPropertySetInfo(IPropertyArrayHelper &rProperties)
void SAL_CALL disposing()
OOO_DLLPUBLIC_CHARTTOOLS void AddDefaultsToMap(::chart::tPropertyValueMap &rOutMap)
OOO_DLLPUBLIC_CHARTTOOLS void AddPropertiesToVector(std::vector< css::beans::Property > &rOutProperties)
void setPropertyValueDefault(tPropertyValueMap &rOutMap, tPropertyValueMapKey key, const Value &value)
Calls setPropertyValue() but asserts that the given property hasn't been set before.
void setPropertyValue(tPropertyValueMap &rOutMap, tPropertyValueMapKey key, const Value &value)
Set a property to a certain value in the given map.
std::unordered_map< tPropertyValueMapKey, css::uno::Any > tPropertyValueMap
cppu::WeakImplHelper< css::chart2::XDataTable, css::lang::XServiceInfo, css::util::XCloneable, css::util::XModifyBroadcaster, css::util::XModifyListener > DataTable_Base
Definition: DataTable.hxx:27
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
IMPLEMENT_FORWARD_XTYPEPROVIDER2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
IMPLEMENT_FORWARD_XINTERFACE2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
HashMap_OWString_Interface aMap
sal_Int32 nHandle
unsigned char sal_Bool