Branch data Line data Source code
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/implbase1.hxx>
23 : : #include <com/sun/star/drawing/FillStyle.hpp>
24 : :
25 : : using namespace ::com::sun::star;
26 : : using namespace ::com::sun::star::beans;
27 : :
28 : : using ::com::sun::star::uno::Reference;
29 : : using ::com::sun::star::uno::Sequence;
30 : : using ::rtl::OUString;
31 : : using ::com::sun::star::uno::RuntimeException;
32 : :
33 : : // ================================================================================
34 : :
35 : : namespace
36 : : {
37 [ # # ]: 0 : class lcl_ColorPropertySetInfo : public ::cppu::WeakImplHelper1<
38 : : XPropertySetInfo >
39 : : {
40 : : public:
41 : : lcl_ColorPropertySetInfo( bool bFillColor );
42 : :
43 : : protected:
44 : : // ____ XPropertySetInfo ____
45 : : virtual Sequence< Property > SAL_CALL getProperties() throw (RuntimeException);
46 : : virtual Property SAL_CALL getPropertyByName( const OUString& aName ) throw (UnknownPropertyException, RuntimeException);
47 : : virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) throw (RuntimeException);
48 : :
49 : : private:
50 : : bool m_bIsFillColor;
51 : : OUString m_aColorPropName;
52 : : Property m_aColorProp;
53 : : };
54 : :
55 : 0 : lcl_ColorPropertySetInfo::lcl_ColorPropertySetInfo( bool bFillColor ) :
56 : : m_bIsFillColor( bFillColor ),
57 : : // note: length of FillColor and LineColor is 9
58 : : m_aColorPropName( (bFillColor ? "FillColor" : "LineColor"), 9, RTL_TEXTENCODING_ASCII_US ),
59 : : m_aColorProp( m_aColorPropName, -1,
60 [ # # ][ # # ]: 0 : ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), 0)
[ # # ]
61 : 0 : {}
62 : :
63 : 0 : Sequence< Property > SAL_CALL lcl_ColorPropertySetInfo::getProperties()
64 : : throw (RuntimeException)
65 : : {
66 : :
67 : 0 : return Sequence< Property >( & m_aColorProp, 1 );
68 : : }
69 : :
70 : 0 : Property SAL_CALL lcl_ColorPropertySetInfo::getPropertyByName( const OUString& aName )
71 : : throw (UnknownPropertyException, RuntimeException)
72 : : {
73 [ # # ]: 0 : if( aName.equals( m_aColorPropName ))
74 : 0 : return m_aColorProp;
75 [ # # ][ # # ]: 0 : throw UnknownPropertyException( m_aColorPropName, static_cast< uno::XWeak * >( this ));
76 : : }
77 : :
78 : 0 : sal_Bool SAL_CALL lcl_ColorPropertySetInfo::hasPropertyByName( const OUString& Name )
79 : : throw (RuntimeException)
80 : : {
81 : 0 : return Name.equals( m_aColorPropName );
82 : : }
83 : :
84 : : } // anonymous namespace
85 : :
86 : : // ================================================================================
87 : :
88 : : namespace oox
89 : : {
90 : : namespace drawingml
91 : : {
92 : :
93 : 0 : ColorPropertySet::ColorPropertySet( sal_Int32 nColor, bool bFillColor /* = true */ ) :
94 : : // note: length of FillColor and LineColor is 9
95 : : m_aColorPropName( (bFillColor ? "FillColor" : "LineColor"), 9, RTL_TEXTENCODING_ASCII_US ),
96 : : m_nColor( nColor ),
97 : : m_bIsFillColor( bFillColor ),
98 [ # # ][ # # ]: 0 : m_nDefaultColor( 0x0099ccff ) // blue 8
99 : 0 : {}
100 : :
101 : 0 : ColorPropertySet::~ColorPropertySet()
102 [ # # ]: 0 : {}
103 : :
104 : : // ____ XPropertySet ____
105 : :
106 : 0 : Reference< XPropertySetInfo > SAL_CALL ColorPropertySet::getPropertySetInfo()
107 : : throw (uno::RuntimeException)
108 : : {
109 [ # # ]: 0 : if( ! m_xInfo.is())
110 [ # # ][ # # ]: 0 : m_xInfo.set( new lcl_ColorPropertySetInfo( m_bIsFillColor ));
111 : :
112 : 0 : return m_xInfo;
113 : : }
114 : :
115 : 0 : void SAL_CALL ColorPropertySet::setPropertyValue( const OUString& /* aPropertyName */, const uno::Any& aValue )
116 : : throw (UnknownPropertyException,
117 : : PropertyVetoException,
118 : : lang::IllegalArgumentException,
119 : : lang::WrappedTargetException,
120 : : uno::RuntimeException)
121 : : {
122 : 0 : aValue >>= m_nColor;
123 : 0 : }
124 : :
125 : 0 : uno::Any SAL_CALL ColorPropertySet::getPropertyValue( const OUString& aPropertyName )
126 : : throw (UnknownPropertyException,
127 : : lang::WrappedTargetException,
128 : : uno::RuntimeException)
129 : : {
130 [ # # ][ # # ]: 0 : if( aPropertyName == "FillStyle" && m_bIsFillColor )
[ # # ]
131 : : {
132 : 0 : ::com::sun::star::drawing::FillStyle aFillStyle = ::com::sun::star::drawing::FillStyle_SOLID;
133 [ # # ]: 0 : return uno::makeAny(aFillStyle);
134 : : }
135 : 0 : return uno::makeAny( m_nColor );
136 : : }
137 : :
138 : 0 : void SAL_CALL ColorPropertySet::addPropertyChangeListener( const OUString& /* aPropertyName */, const Reference< XPropertyChangeListener >& /* xListener */ )
139 : : throw (UnknownPropertyException,
140 : : lang::WrappedTargetException,
141 : : uno::RuntimeException)
142 : : {
143 : : OSL_FAIL( "Not Implemented" );
144 : 0 : return;
145 : : }
146 : :
147 : 0 : void SAL_CALL ColorPropertySet::removePropertyChangeListener( const OUString& /* aPropertyName */, const Reference< XPropertyChangeListener >& /* aListener */ )
148 : : throw (UnknownPropertyException,
149 : : lang::WrappedTargetException,
150 : : uno::RuntimeException)
151 : : {
152 : : OSL_FAIL( "Not Implemented" );
153 : 0 : return;
154 : : }
155 : :
156 : 0 : void SAL_CALL ColorPropertySet::addVetoableChangeListener( const OUString& /* PropertyName */, const Reference< XVetoableChangeListener >& /* aListener */ )
157 : : throw (UnknownPropertyException,
158 : : lang::WrappedTargetException,
159 : : uno::RuntimeException)
160 : : {
161 : : OSL_FAIL( "Not Implemented" );
162 : 0 : return;
163 : : }
164 : :
165 : 0 : void SAL_CALL ColorPropertySet::removeVetoableChangeListener( const OUString& /* PropertyName */, const Reference< XVetoableChangeListener >& /* aListener */ )
166 : : throw (UnknownPropertyException,
167 : : lang::WrappedTargetException,
168 : : uno::RuntimeException)
169 : : {
170 : : OSL_FAIL( "Not Implemented" );
171 : 0 : return;
172 : : }
173 : :
174 : : // ____ XPropertyState ____
175 : :
176 : 0 : PropertyState SAL_CALL ColorPropertySet::getPropertyState( const OUString& /* PropertyName */ )
177 : : throw (UnknownPropertyException,
178 : : uno::RuntimeException)
179 : : {
180 : 0 : return PropertyState_DIRECT_VALUE;
181 : : }
182 : :
183 : 0 : Sequence< PropertyState > SAL_CALL ColorPropertySet::getPropertyStates( const Sequence< OUString >& /* aPropertyName */ )
184 : : throw (UnknownPropertyException,
185 : : uno::RuntimeException)
186 : : {
187 : 0 : PropertyState aState = PropertyState_DIRECT_VALUE;
188 [ # # ]: 0 : return Sequence< PropertyState >( & aState, 1 );
189 : : }
190 : :
191 : 0 : void SAL_CALL ColorPropertySet::setPropertyToDefault( const OUString& PropertyName )
192 : : throw (UnknownPropertyException,
193 : : uno::RuntimeException)
194 : : {
195 [ # # ]: 0 : if( PropertyName.equals( m_aColorPropName ))
196 : 0 : m_nColor = m_nDefaultColor;
197 : 0 : }
198 : :
199 : 0 : uno::Any SAL_CALL ColorPropertySet::getPropertyDefault( const OUString& aPropertyName )
200 : : throw (UnknownPropertyException,
201 : : lang::WrappedTargetException,
202 : : uno::RuntimeException)
203 : : {
204 [ # # ]: 0 : if( aPropertyName.equals( m_aColorPropName ))
205 : 0 : return uno::makeAny( m_nDefaultColor );
206 : 0 : return uno::Any();
207 : : }
208 : :
209 : : } // namespace chart
210 : : } // namespace xmloff
211 : :
212 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|