LibreOffice Module chart2 (master) 1
GridProperties.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 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <GridProperties.hxx>
23#include <PropertyHelper.hxx>
25#include <com/sun/star/beans/PropertyAttribute.hpp>
26#include <com/sun/star/uno/Sequence.hxx>
28
29namespace com::sun::star::beans { class XPropertySetInfo; }
30namespace com::sun::star::uno { class XComponentContext; }
31
32using namespace ::com::sun::star;
33
34using ::com::sun::star::uno::Reference;
35using ::com::sun::star::uno::Sequence;
36using ::com::sun::star::beans::Property;
37
38namespace
39{
40
41enum
42{
43 PROP_GRID_SHOW
44};
45
46void lcl_AddPropertiesToVector(
47 std::vector< Property > & rOutProperties )
48{
49 rOutProperties.emplace_back( "Show",
50 PROP_GRID_SHOW,
52 beans::PropertyAttribute::BOUND
53 | beans::PropertyAttribute::MAYBEDEFAULT );
54}
55
56const ::chart::tPropertyValueMap & StaticGridDefaults()
57{
58 static ::chart::tPropertyValueMap aStaticDefaults = []()
59 {
62
63 ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_GRID_SHOW, false );
64
65 // override other defaults
66 ::chart::PropertyHelper::setPropertyValue< sal_Int32 >(
67 aTmp, ::chart::LinePropertiesHelper::PROP_LINE_COLOR, 0xb3b3b3 ); // gray30
68 return aTmp;
69 }();
70 return aStaticDefaults;
71};
72
73::cppu::OPropertyArrayHelper& StaticGridInfoHelper()
74{
75 static ::cppu::OPropertyArrayHelper aPropHelper = []()
76 {
77 std::vector< Property > aProperties;
78 lcl_AddPropertiesToVector( aProperties );
81
82 std::sort( aProperties.begin(), aProperties.end(),
84
85 return comphelper::containerToSequence( aProperties );
86 }();
87 return aPropHelper;
88};
89
90} // anonymous namespace
91
92namespace chart
93{
94
96 m_xModifyEventForwarder( new ModifyEventForwarder() )
97{}
98
100 impl::GridProperties_Base(rOther),
101 ::property::OPropertySet( rOther ),
102 m_xModifyEventForwarder( new ModifyEventForwarder() )
103{
104}
105
107{}
108
109// ____ OPropertySet ____
110void GridProperties::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
111{
112 const tPropertyValueMap& rStaticDefaults = StaticGridDefaults();
113 tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
114 if( aFound == rStaticDefaults.end() )
115 rAny.clear();
116 else
117 rAny = (*aFound).second;
118}
119
121{
122 return StaticGridInfoHelper();
123}
124
125// ____ XPropertySet ____
127{
128 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
129 ::cppu::OPropertySetHelper::createPropertySetInfo(StaticGridInfoHelper() ) );
130 return xPropertySetInfo;
131}
132
133// ____ XCloneable ____
135{
137}
138
139// ____ XModifyBroadcaster ____
141{
142 m_xModifyEventForwarder->addModifyListener( aListener );
143}
144
146{
147 m_xModifyEventForwarder->removeModifyListener( aListener );
148}
149
150// ____ XModifyListener ____
151void SAL_CALL GridProperties::modified( const lang::EventObject& aEvent )
152{
153 m_xModifyEventForwarder->modified( aEvent );
154}
155
156// ____ XEventListener (base of XModifyListener) ____
157void SAL_CALL GridProperties::disposing( const lang::EventObject& /* Source */ )
158{
159 // nothing
160}
161
162// ____ OPropertySet ____
164{
165 m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
166}
167
168// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
170{
171 return "com.sun.star.comp.chart2.GridProperties";
172}
173
174sal_Bool SAL_CALL GridProperties::supportsService( const OUString& rServiceName )
175{
176 return cppu::supportsService(this, rServiceName);
177}
178
179css::uno::Sequence< OUString > SAL_CALL GridProperties::getSupportedServiceNames()
180{
181 return {
182 "com.sun.star.chart2.GridProperties",
183 "com.sun.star.beans.PropertySet" };
184}
185
186// needed by MSC compiler
188
191
192} // namespace chart
193
194extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
196 css::uno::Sequence<css::uno::Any> const &)
197{
198 return cppu::acquire(new ::chart::GridProperties);
199}
200
201/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_chart2_GridProperties_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
PropertiesInfo aProperties
AnyEventRef aEvent
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
The InfoHelper table contains all property names and types of this object.
virtual void SAL_CALL addModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
virtual void firePropertyChangeEvent() override
implement this method in derived classes to get called when properties change.
virtual OUString SAL_CALL getImplementationName() override
XServiceInfo declarations.
virtual void SAL_CALL modified(const css::lang::EventObject &aEvent) override
virtual ~GridProperties() override
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
virtual void SAL_CALL removeModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
rtl::Reference< ModifyEventForwarder > m_xModifyEventForwarder
virtual void GetDefaultValue(sal_Int32 nHandle, css::uno::Any &rAny) const override
merge XInterface implementations
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
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.
::cppu::WeakImplHelper< css::lang::XServiceInfo, css::util::XCloneable, css::util::XModifyBroadcaster, css::util::XModifyListener > GridProperties_Base
std::unordered_map< tPropertyValueMapKey, css::uno::Any > tPropertyValueMap
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)
sal_Int32 nHandle
unsigned char sal_Bool