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