LibreOffice Module xmloff (master) 1
ColorPropertySet.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 "ColorPropertySet.hxx"
21
23
24#include <osl/diagnose.h>
25
26using namespace ::com::sun::star;
27using namespace ::com::sun::star::beans;
28
29using ::com::sun::star::uno::Reference;
30using ::com::sun::star::uno::Sequence;
31
32namespace
33{
34class lcl_ColorPropertySetInfo : public ::cppu::WeakImplHelper<
35 XPropertySetInfo >
36{
37public:
38 explicit lcl_ColorPropertySetInfo();
39
40protected:
41 // ____ XPropertySetInfo ____
42 virtual Sequence< Property > SAL_CALL getProperties() override;
43 virtual Property SAL_CALL getPropertyByName( const OUString& aName ) override;
44 virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) override;
45
46private:
47 static constexpr OUStringLiteral g_aColorPropName = u"FillColor";
48 Property m_aColorProp;
49};
50
51lcl_ColorPropertySetInfo::lcl_ColorPropertySetInfo() :
52 m_aColorProp( g_aColorPropName, -1,
53 cppu::UnoType<sal_Int32>::get(), 0)
54{}
55
56Sequence< Property > SAL_CALL lcl_ColorPropertySetInfo::getProperties()
57{
58
59 return Sequence< Property >( & m_aColorProp, 1 );
60}
61
62Property SAL_CALL lcl_ColorPropertySetInfo::getPropertyByName( const OUString& aName )
63{
64 if( aName == g_aColorPropName )
65 return m_aColorProp;
66 throw UnknownPropertyException( g_aColorPropName, getXWeak());
67}
68
69sal_Bool SAL_CALL lcl_ColorPropertySetInfo::hasPropertyByName( const OUString& Name )
70{
71 return Name == g_aColorPropName;
72}
73
74} // anonymous namespace
75
77{
78
80 m_nColor( nColor ),
81 m_nDefaultColor( 0x0099ccff ) // blue 8
82{}
83
85{}
86
87// ____ XPropertySet ____
88
89Reference< XPropertySetInfo > SAL_CALL ColorPropertySet::getPropertySetInfo()
90{
91 if( ! m_xInfo.is())
92 m_xInfo.set( new lcl_ColorPropertySetInfo );
93
94 return m_xInfo;
95}
96
97void SAL_CALL ColorPropertySet::setPropertyValue( const OUString& /* aPropertyName */, const uno::Any& aValue )
98{
99 aValue >>= m_nColor;
100}
101
102uno::Any SAL_CALL ColorPropertySet::getPropertyValue( const OUString& /* PropertyName */ )
103{
104 return uno::Any( m_nColor );
105}
106
107void SAL_CALL ColorPropertySet::addPropertyChangeListener( const OUString& /* aPropertyName */, const Reference< XPropertyChangeListener >& /* xListener */ )
108{
109 OSL_FAIL( "Not Implemented" );
110}
111
112void SAL_CALL ColorPropertySet::removePropertyChangeListener( const OUString& /* aPropertyName */, const Reference< XPropertyChangeListener >& /* aListener */ )
113{
114 OSL_FAIL( "Not Implemented" );
115}
116
117void SAL_CALL ColorPropertySet::addVetoableChangeListener( const OUString& /* PropertyName */, const Reference< XVetoableChangeListener >& /* aListener */ )
118{
119 OSL_FAIL( "Not Implemented" );
120}
121
122void SAL_CALL ColorPropertySet::removeVetoableChangeListener( const OUString& /* PropertyName */, const Reference< XVetoableChangeListener >& /* aListener */ )
123{
124 OSL_FAIL( "Not Implemented" );
125}
126
127// ____ XPropertyState ____
128
129PropertyState SAL_CALL ColorPropertySet::getPropertyState( const OUString& /* PropertyName */ )
130{
131 return PropertyState_DIRECT_VALUE;
132}
133
134Sequence< PropertyState > SAL_CALL ColorPropertySet::getPropertyStates( const Sequence< OUString >& /* aPropertyName */ )
135{
136 PropertyState aState = PropertyState_DIRECT_VALUE;
137 // coverity[overrun-buffer-arg : FALSE] - coverity has difficulty with css::uno::Sequence
138 return Sequence<PropertyState>(&aState, 1);
139}
140
141void SAL_CALL ColorPropertySet::setPropertyToDefault( const OUString& PropertyName )
142{
143 if( PropertyName == g_aColorPropName )
145}
146
147uno::Any SAL_CALL ColorPropertySet::getPropertyDefault( const OUString& aPropertyName )
148{
149 if( aPropertyName == g_aColorPropName )
150 return uno::Any( m_nDefaultColor );
151 return uno::Any();
152}
153
154} // namespace xmloff::chart
155
156/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
css::uno::Reference< css::beans::XPropertySetInfo > m_xInfo
static constexpr OUStringLiteral g_aColorPropName
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &PropertyName) override
virtual void SAL_CALL setPropertyToDefault(const OUString &PropertyName) override
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &aPropertyName) override
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &aPropertyName) override
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
float u
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
OUString Name
unsigned char sal_Bool