1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #include "oox/drawingml/clrscheme.hxx"
25 #include "oox/token/tokens.hxx"
26
27 namespace oox { namespace drawingml {
28
getColorMap(sal_Int32 & nClrToken)29 sal_Bool ClrMap::getColorMap( sal_Int32& nClrToken )
30 {
31 sal_Int32 nMapped = 0;
32 std::map < sal_Int32, sal_Int32 >::const_iterator aIter( maClrMap.find( nClrToken ) );
33 if ( aIter != maClrMap.end() )
34 nMapped = (*aIter).second;
35 if ( nMapped )
36 {
37 nClrToken = nMapped;
38 return sal_True;
39 }
40 else
41 return sal_False;
42 }
43
setColorMap(sal_Int32 nClrToken,sal_Int32 nMappedClrToken)44 void ClrMap::setColorMap( sal_Int32 nClrToken, sal_Int32 nMappedClrToken )
45 {
46 maClrMap[ nClrToken ] = nMappedClrToken;
47 }
48
49 //-----------------------------------------------------------------------------------------
50
ClrScheme()51 ClrScheme::ClrScheme()
52 {
53 }
~ClrScheme()54 ClrScheme::~ClrScheme()
55 {
56 }
57
getColor(sal_Int32 nSchemeClrToken,sal_Int32 & rColor) const58 sal_Bool ClrScheme::getColor( sal_Int32 nSchemeClrToken, sal_Int32& rColor ) const
59 {
60 switch( nSchemeClrToken )
61 {
62 case XML_bg1 : nSchemeClrToken = XML_lt1; break;
63 case XML_bg2 : nSchemeClrToken = XML_lt2; break;
64 case XML_tx1 : nSchemeClrToken = XML_dk1; break;
65 case XML_tx2 : nSchemeClrToken = XML_dk2; break;
66 }
67 std::map < sal_Int32, sal_Int32 >::const_iterator aIter( maClrScheme.find( nSchemeClrToken ) );
68 if ( aIter != maClrScheme.end() )
69 rColor = (*aIter).second;
70 return aIter != maClrScheme.end();
71 }
72
setColor(sal_Int32 nSchemeClrToken,sal_Int32 nColor)73 void ClrScheme::setColor( sal_Int32 nSchemeClrToken, sal_Int32 nColor )
74 {
75 maClrScheme[ nSchemeClrToken ] = nColor;
76 }
77
78 } }
79