LibreOffice Module chart2 (master) 1
PageBackground.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 "PageBackground.hxx"
22#include <FillProperties.hxx>
24#include <PropertyHelper.hxx>
26
27#include <com/sun/star/drawing/LineStyle.hpp>
29
30#include <vector>
31#include <algorithm>
32
33namespace com::sun::star::uno { class XComponentContext; }
34
35using namespace ::com::sun::star;
36
37using ::com::sun::star::beans::Property;
38
39namespace
40{
41
42const ::chart::tPropertyValueMap& StaticPageBackgroundDefaults()
43{
44 static ::chart::tPropertyValueMap aStaticDefaults = []()
45 {
49
50 // override other defaults
51 ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( aTmp, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff );
53 return aTmp;
54 }();
55 return aStaticDefaults;
56};
57
58::cppu::OPropertyArrayHelper& StaticPageBackgroundInfoHelper()
59{
60 static ::cppu::OPropertyArrayHelper aPropHelper = []()
61 {
62 std::vector< css::beans::Property > aProperties;
66
67 std::sort( aProperties.begin(), aProperties.end(),
69
70 return comphelper::containerToSequence( aProperties );
71 }();
72 return aPropHelper;
73};
74
75} // anonymous namespace
76
77namespace chart
78{
79
81 m_xModifyEventForwarder( new ModifyEventForwarder() )
82{}
83
86 ::property::OPropertySet( rOther ),
87 m_xModifyEventForwarder( new ModifyEventForwarder() )
88{}
89
91{}
92
93// ____ XTypeProvider ____
95{
96 return ::comphelper::concatSequences(
97 impl::PageBackground_Base::getTypes(),
99}
100
101// ____ XCloneable ____
103{
105}
106
107// ____ OPropertySet ____
108void PageBackground::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
109{
110 const tPropertyValueMap& rStaticDefaults = StaticPageBackgroundDefaults();
111 tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
112 if( aFound == rStaticDefaults.end() )
113 rAny.clear();
114 else
115 rAny = (*aFound).second;
116}
117
119{
120 return StaticPageBackgroundInfoHelper();
121}
122
123// ____ XPropertySet ____
125{
126 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
127 ::cppu::OPropertySetHelper::createPropertySetInfo(StaticPageBackgroundInfoHelper() ) );
128 return xPropertySetInfo;
129}
130
131// ____ XModifyBroadcaster ____
133{
134 m_xModifyEventForwarder->addModifyListener( aListener );
135}
136
138{
139 m_xModifyEventForwarder->removeModifyListener( aListener );
140}
141
142// ____ XModifyListener ____
143void SAL_CALL PageBackground::modified( const lang::EventObject& aEvent )
144{
145 m_xModifyEventForwarder->modified( aEvent );
146}
147
148// ____ XEventListener (base of XModifyListener) ____
149void SAL_CALL PageBackground::disposing( const lang::EventObject& /* Source */ )
150{
151 // nothing
152}
153
154// ____ OPropertySet ____
156{
157 m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
158}
159
161{
162 return "com.sun.star.comp.chart2.PageBackground";
163}
164
165sal_Bool SAL_CALL PageBackground::supportsService( const OUString& rServiceName )
166{
167 return cppu::supportsService(this, rServiceName);
168}
169
170css::uno::Sequence< OUString > SAL_CALL PageBackground::getSupportedServiceNames()
171{
172 return {
173 "com.sun.star.chart2.PageBackground",
174 "com.sun.star.beans.PropertySet" };
175}
176
178
180
181} // namespace chart
182
183extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
185 css::uno::Sequence<css::uno::Any> const &)
186{
187 return cppu::acquire(new ::chart::PageBackground );
188}
189
190/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_chart2_PageBackground_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
PropertiesInfo aProperties
AnyEventRef aEvent
This helper class serves as forwarder of modify events.
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
The InfoHelper table contains all property names and types of this object.
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual void SAL_CALL removeModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
virtual void GetDefaultValue(sal_Int32 nHandle, css::uno::Any &rAny) const override
implement this method to provide default values for all properties supporting defaults.
rtl::Reference< ModifyEventForwarder > m_xModifyEventForwarder
virtual OUString SAL_CALL getImplementationName() override
XServiceInfo declarations.
virtual void SAL_CALL modified(const css::lang::EventObject &aEvent) override
virtual ~PageBackground() override
virtual void firePropertyChangeEvent() override
implement this method in derived classes to get called when properties change.
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
virtual void SAL_CALL addModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
static css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL createPropertySetInfo(IPropertyArrayHelper &rProperties)
void SAL_CALL disposing()
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
OOO_DLLPUBLIC_CHARTTOOLS void AddDefaultsToMap(::chart::tPropertyValueMap &rOutMap)
OOO_DLLPUBLIC_CHARTTOOLS void AddPropertiesToVector(std::vector< css::beans::Property > &rOutProperties)
void setPropertyValue(tPropertyValueMap &rOutMap, tPropertyValueMapKey key, const Value &value)
Set a property to a certain value in the given map.
::cppu::WeakImplHelper< css::util::XCloneable, css::util::XModifyBroadcaster, css::util::XModifyListener, css::lang::XServiceInfo > PageBackground_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_XINTERFACE2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
sal_Int32 nHandle
unsigned char sal_Bool