Update ooo320-m1
[ooovba.git] / oox / source / drawingml / clrscheme.cxx
blob131fdb5419fa2ccf7044606b2b36f17c36eedd85
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: clrscheme.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/drawingml/clrscheme.hxx"
32 #include "tokens.hxx"
34 namespace oox { namespace drawingml {
36 sal_Bool ClrMap::getColorMap( sal_Int32& nClrToken )
38 sal_Int32 nMapped = 0;
39 std::map < sal_Int32, sal_Int32 >::const_iterator aIter( maClrMap.find( nClrToken ) );
40 if ( aIter != maClrMap.end() )
41 nMapped = (*aIter).second;
42 if ( nMapped )
44 nClrToken = nMapped;
45 return sal_True;
47 else
48 return sal_False;
51 void ClrMap::setColorMap( sal_Int32 nClrToken, sal_Int32 nMappedClrToken )
53 maClrMap[ nClrToken ] = nMappedClrToken;
56 //-----------------------------------------------------------------------------------------
58 ClrScheme::ClrScheme()
61 ClrScheme::~ClrScheme()
65 sal_Bool ClrScheme::getColor( sal_Int32 nSchemeClrToken, sal_Int32& rColor ) const
67 switch( nSchemeClrToken )
69 case XML_bg1 : nSchemeClrToken = XML_lt1; break;
70 case XML_bg2 : nSchemeClrToken = XML_lt2; break;
71 case XML_tx1 : nSchemeClrToken = XML_dk1; break;
72 case XML_tx2 : nSchemeClrToken = XML_dk2; break;
74 std::map < sal_Int32, sal_Int32 >::const_iterator aIter( maClrScheme.find( nSchemeClrToken ) );
75 if ( aIter != maClrScheme.end() )
76 rColor = (*aIter).second;
77 return aIter != maClrScheme.end();
80 void ClrScheme::setColor( sal_Int32 nSchemeClrToken, sal_Int32 nColor )
82 maClrScheme[ nSchemeClrToken ] = nColor;
85 } }