1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "ColorPropertySet.hxx"
22 #include <cppuhelper/implbase.hxx>
24 #include <osl/diagnose.h>
26 using namespace ::com::sun::star
;
27 using namespace ::com::sun::star::beans
;
29 using ::com::sun::star::uno::Reference
;
30 using ::com::sun::star::uno::Sequence
;
34 class lcl_ColorPropertySetInfo
: public ::cppu::WeakImplHelper
<
38 explicit lcl_ColorPropertySetInfo();
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
;
47 static constexpr OUString g_aColorPropName
= u
"FillColor"_ustr
;
48 Property m_aColorProp
;
51 lcl_ColorPropertySetInfo::lcl_ColorPropertySetInfo() :
52 m_aColorProp( g_aColorPropName
, -1,
53 cppu::UnoType
<sal_Int32
>::get(), 0)
56 Sequence
< Property
> SAL_CALL
lcl_ColorPropertySetInfo::getProperties()
59 return Sequence
< Property
>( & m_aColorProp
, 1 );
62 Property SAL_CALL
lcl_ColorPropertySetInfo::getPropertyByName( const OUString
& aName
)
64 if( aName
== g_aColorPropName
)
66 throw UnknownPropertyException( g_aColorPropName
, getXWeak());
69 sal_Bool SAL_CALL
lcl_ColorPropertySetInfo::hasPropertyByName( const OUString
& Name
)
71 return Name
== g_aColorPropName
;
74 } // anonymous namespace
76 namespace xmloff::chart
79 ColorPropertySet::ColorPropertySet( ::Color nColor
) :
81 m_nDefaultColor( 0x0099ccff ) // blue 8
84 ColorPropertySet::~ColorPropertySet()
87 // ____ XPropertySet ____
89 Reference
< XPropertySetInfo
> SAL_CALL
ColorPropertySet::getPropertySetInfo()
92 m_xInfo
.set( new lcl_ColorPropertySetInfo
);
97 void SAL_CALL
ColorPropertySet::setPropertyValue( const OUString
& /* aPropertyName */, const uno::Any
& aValue
)
102 uno::Any SAL_CALL
ColorPropertySet::getPropertyValue( const OUString
& /* PropertyName */ )
104 return uno::Any( m_nColor
);
107 void SAL_CALL
ColorPropertySet::addPropertyChangeListener( const OUString
& /* aPropertyName */, const Reference
< XPropertyChangeListener
>& /* xListener */ )
109 OSL_FAIL( "Not Implemented" );
112 void SAL_CALL
ColorPropertySet::removePropertyChangeListener( const OUString
& /* aPropertyName */, const Reference
< XPropertyChangeListener
>& /* aListener */ )
114 OSL_FAIL( "Not Implemented" );
117 void SAL_CALL
ColorPropertySet::addVetoableChangeListener( const OUString
& /* PropertyName */, const Reference
< XVetoableChangeListener
>& /* aListener */ )
119 OSL_FAIL( "Not Implemented" );
122 void SAL_CALL
ColorPropertySet::removeVetoableChangeListener( const OUString
& /* PropertyName */, const Reference
< XVetoableChangeListener
>& /* aListener */ )
124 OSL_FAIL( "Not Implemented" );
127 // ____ XPropertyState ____
129 PropertyState SAL_CALL
ColorPropertySet::getPropertyState( const OUString
& /* PropertyName */ )
131 return PropertyState_DIRECT_VALUE
;
134 Sequence
< PropertyState
> SAL_CALL
ColorPropertySet::getPropertyStates( const Sequence
< OUString
>& /* aPropertyName */ )
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);
141 void SAL_CALL
ColorPropertySet::setPropertyToDefault( const OUString
& PropertyName
)
143 if( PropertyName
== g_aColorPropName
)
144 m_nColor
= m_nDefaultColor
;
147 uno::Any SAL_CALL
ColorPropertySet::getPropertyDefault( const OUString
& aPropertyName
)
149 if( aPropertyName
== g_aColorPropName
)
150 return uno::Any( m_nDefaultColor
);
154 } // namespace xmloff::chart
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */