LibreOffice Module chart2 (master) 1
FormattedString.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 <FormattedString.hxx>
21
23#include <PropertyHelper.hxx>
26
27namespace com::sun::star::uno { class XComponentContext; }
28
29using namespace ::com::sun::star;
30
31using ::com::sun::star::beans::Property;
32using ::com::sun::star::uno::Sequence;
33using ::osl::MutexGuard;
34
35namespace chart
36{
38{
39 static ::chart::tPropertyValueMap aStaticDefaults = []
40 {
43 return aMap;
44 }();
45 return aStaticDefaults;
46};
47} // namespace chart
48
49namespace
50{
51
52::cppu::OPropertyArrayHelper& StaticFormattedStringInfoHelper()
53{
54 static ::cppu::OPropertyArrayHelper aPropHelper = []()
55 {
56 std::vector< css::beans::Property > aProperties;
58
59 std::sort( aProperties.begin(), aProperties.end(),
61
62 return comphelper::containerToSequence( aProperties );
63 }();
64 return aPropHelper;
65};
66
67} // anonymous namespace
68
69namespace chart
70{
71
73 m_aType(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT),
74 m_bDataLabelsRange(false),
75 m_xModifyEventForwarder( new ModifyEventForwarder() )
76{}
77
80 ::property::OPropertySet( rOther ),
81 m_aString( rOther.m_aString ),
82 m_aType(rOther.m_aType),
83 m_aGuid(rOther.m_aGuid),
84 m_bDataLabelsRange(rOther.m_bDataLabelsRange),
85 m_xModifyEventForwarder( new ModifyEventForwarder() )
86{}
87
89{}
90
91// ____ XCloneable ____
93{
95}
96
97// ____ XFormattedString ____
98OUString SAL_CALL FormattedString::getString()
99{
100 MutexGuard aGuard( m_aMutex);
101 return m_aString;
102}
103
104void SAL_CALL FormattedString::setString( const OUString& String )
105{
106 {
107 MutexGuard aGuard( m_aMutex);
109 }
110 //don't keep the mutex locked while calling out
112
113}
114
115// ____ XDataPointCustomLabelField ____
116css::chart2::DataPointCustomLabelFieldType SAL_CALL FormattedString::getFieldType()
117{
118 MutexGuard aGuard(m_aMutex);
119 return m_aType;
120}
121
122void SAL_CALL
123FormattedString::setFieldType(const css::chart2::DataPointCustomLabelFieldType Type)
124{
125 {
126 MutexGuard aGuard(m_aMutex);
127 m_aType = Type;
128 }
129 //don't keep the mutex locked while calling out
131}
132
133OUString SAL_CALL FormattedString::getGuid()
134{
135 MutexGuard aGuard( m_aMutex);
136 return m_aGuid;
137}
138
139void SAL_CALL FormattedString::setGuid( const OUString& guid )
140{
141 {
142 MutexGuard aGuard( m_aMutex);
143 m_aGuid= guid;
144 }
145 //don't keep the mutex locked while calling out
147
148}
149
151{
152 MutexGuard aGuard( m_aMutex);
153 return m_bDataLabelsRange;
154}
155
156void SAL_CALL FormattedString::setDataLabelsRange( sal_Bool dataLabelsRange )
157{
158 {
159 MutexGuard aGuard( m_aMutex);
160 m_bDataLabelsRange = dataLabelsRange;
161 }
162 //don't keep the mutex locked while calling out
164}
165
167{
168 MutexGuard aGuard( m_aMutex);
169 return m_aCellRange;
170}
171
172void SAL_CALL FormattedString::setCellRange( const OUString& cellRange )
173{
174 {
175 MutexGuard aGuard( m_aMutex);
176 m_aCellRange = cellRange;
177 }
178 //don't keep the mutex locked while calling out
180}
181
182// ____ XModifyBroadcaster ____
184{
185 m_xModifyEventForwarder->addModifyListener( aListener );
186}
187
189{
190 m_xModifyEventForwarder->removeModifyListener( aListener );
191}
192
193// ____ XModifyListener ____
194void SAL_CALL FormattedString::modified( const lang::EventObject& aEvent )
195{
196 m_xModifyEventForwarder->modified( aEvent );
197}
198
199// ____ XEventListener (base of XModifyListener) ____
200void SAL_CALL FormattedString::disposing( const lang::EventObject& /* Source */ )
201{
202 // nothing
203}
204
205// ____ OPropertySet ____
207{
209}
210
212{
213 m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
214}
215
216// ____ OPropertySet ____
217void FormattedString::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
218{
219 const tPropertyValueMap& rStaticDefaults = StaticFormattedStringDefaults();
220 tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
221 if( aFound == rStaticDefaults.end() )
222 rAny.clear();
223 else
224 rAny = (*aFound).second;
225}
226
227// ____ OPropertySet ____
229{
230 return StaticFormattedStringInfoHelper();
231}
232
233// ____ XPropertySet ____
235{
236 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
237 ::cppu::OPropertySetHelper::createPropertySetInfo(StaticFormattedStringInfoHelper() ) );
238 return xPropertySetInfo;
239}
240
242
245
246// do this in derived classes!
247
248// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
249OUString SAL_CALL FormattedString::getImplementationName()
250{
251 return "com.sun.star.comp.chart.FormattedString";
252}
253
254sal_Bool SAL_CALL FormattedString::supportsService( const OUString& rServiceName )
255{
256 return cppu::supportsService(this, rServiceName);
257}
258
259css::uno::Sequence< OUString > SAL_CALL FormattedString::getSupportedServiceNames()
260{
261 return {
262 "com.sun.star.chart2.DataPointCustomLabelField",
263 "com.sun.star.chart2.FormattedString",
264 "com.sun.star.beans.PropertySet" };
265}
266
267} // namespace chart
268
269extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
271 css::uno::Sequence<css::uno::Any> const &)
272{
273 return cppu::acquire(new ::chart::FormattedString);
274}
275
276/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_chart_FormattedString_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
uno::Type m_aType
PropertiesInfo aProperties
AnyEventRef aEvent
virtual void GetDefaultValue(sal_Int32 nHandle, css::uno::Any &rAny) const override
implement this method to provide default values for all properties supporting defaults.
virtual OUString SAL_CALL getGuid() override
virtual void SAL_CALL removeModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
css::chart2::DataPointCustomLabelFieldType m_aType
virtual OUString SAL_CALL getString() override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
rtl::Reference< ModifyEventForwarder > m_xModifyEventForwarder
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 SAL_CALL setFieldType(const css::chart2::DataPointCustomLabelFieldType FieldType) override
virtual OUString SAL_CALL getCellRange() override
virtual void SAL_CALL setDataLabelsRange(sal_Bool dataLabelsRange) override
virtual void SAL_CALL setCellRange(const OUString &cellRange) override
virtual css::chart2::DataPointCustomLabelFieldType SAL_CALL getFieldType() override
void SAL_CALL setGuid(const OUString &guid) override
virtual sal_Bool SAL_CALL getDataLabelsRange() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL modified(const css::lang::EventObject &aEvent) override
virtual void firePropertyChangeEvent() override
implement this method in derived classes to get called when properties change.
virtual ~FormattedString() override
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL setString(const OUString &String) override
This helper class serves as forwarder of modify events.
mutable::osl::Mutex m_aMutex
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)
::cppu::WeakImplHelper< css::chart2::XDataPointCustomLabelField, css::lang::XServiceInfo, css::util::XCloneable, css::util::XModifyBroadcaster, css::util::XModifyListener > FormattedString_Base
OOO_DLLPUBLIC_CHARTTOOLSconst ::chart::tPropertyValueMap & StaticFormattedStringDefaults()
std::unordered_map< tPropertyValueMapKey, css::uno::Any > tPropertyValueMap
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Type
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