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 <osl/diagnose.h>
21 #include "oox/drawingml/clrscheme.hxx"
22 #include "oox/token/tokens.hxx"
24 namespace oox
{ namespace drawingml
{
26 bool ClrMap::getColorMap( sal_Int32
& nClrToken
)
28 sal_Int32 nMapped
= 0;
29 std::map
< sal_Int32
, sal_Int32
>::const_iterator
aIter( maClrMap
.find( nClrToken
) );
30 if ( aIter
!= maClrMap
.end() )
31 nMapped
= (*aIter
).second
;
41 void ClrMap::setColorMap( sal_Int32 nClrToken
, sal_Int32 nMappedClrToken
)
43 maClrMap
[ nClrToken
] = nMappedClrToken
;
48 explicit find_by_token(sal_Int32 token
):
53 bool operator()(const std::pair
<sal_Int32
, sal_Int32
>& r
)
55 return r
.first
== m_token
;
62 bool ClrScheme::getColor( sal_Int32 nSchemeClrToken
, sal_Int32
& rColor
) const
64 OSL_ASSERT((nSchemeClrToken
& sal_Int32(0xFFFF0000))==0);
65 switch( nSchemeClrToken
)
67 case XML_bg1
: nSchemeClrToken
= XML_lt1
; break;
68 case XML_bg2
: nSchemeClrToken
= XML_lt2
; break;
69 case XML_tx1
: nSchemeClrToken
= XML_dk1
; break;
70 case XML_tx2
: nSchemeClrToken
= XML_dk2
; break;
73 auto aIter
= std::find_if(maClrScheme
.begin(), maClrScheme
.end(), find_by_token(nSchemeClrToken
) );
75 if ( aIter
!= maClrScheme
.end() )
76 rColor
= aIter
->second
;
78 return aIter
!= maClrScheme
.end();
81 void ClrScheme::setColor( sal_Int32 nSchemeClrToken
, sal_Int32 nColor
)
83 maClrScheme
.push_back(std::pair
<sal_Int32
, sal_Int32
>(nSchemeClrToken
, nColor
));
86 bool ClrScheme::getColorByIndex(size_t nIndex
, sal_Int32
& rColor
) const
88 if (nIndex
>= maClrScheme
.size())
91 rColor
= maClrScheme
[nIndex
].second
;
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */