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 .
22 #include <osl/diagnose.h>
23 #include "oox/drawingml/clrscheme.hxx"
24 #include "oox/token/tokens.hxx"
26 namespace oox
{ namespace drawingml
{
28 bool ClrMap::getColorMap( sal_Int32
& nClrToken
)
30 sal_Int32 nMapped
= 0;
31 std::map
< sal_Int32
, sal_Int32
>::const_iterator
aIter( maClrMap
.find( nClrToken
) );
32 if ( aIter
!= maClrMap
.end() )
33 nMapped
= (*aIter
).second
;
43 void ClrMap::setColorMap( sal_Int32 nClrToken
, sal_Int32 nMappedClrToken
)
45 maClrMap
[ nClrToken
] = nMappedClrToken
;
50 explicit find_by_token(sal_Int32 token
):
55 bool operator()(const std::pair
<sal_Int32
, sal_Int32
>& r
)
57 return r
.first
== m_token
;
64 bool ClrScheme::getColor( sal_Int32 nSchemeClrToken
, sal_Int32
& rColor
) const
66 OSL_ASSERT((nSchemeClrToken
& sal_Int32(0xFFFF0000))==0);
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;
75 auto aIter
= std::find_if(maClrScheme
.begin(), maClrScheme
.end(), find_by_token(nSchemeClrToken
) );
77 if ( aIter
!= maClrScheme
.end() )
78 rColor
= aIter
->second
;
80 return aIter
!= maClrScheme
.end();
83 void ClrScheme::setColor( sal_Int32 nSchemeClrToken
, sal_Int32 nColor
)
85 maClrScheme
.push_back(std::pair
<sal_Int32
, sal_Int32
>(nSchemeClrToken
, nColor
));
88 bool ClrScheme::getColorByIndex(size_t nIndex
, sal_Int32
& rColor
) const
90 if (nIndex
>= maClrScheme
.size())
93 rColor
= maClrScheme
[nIndex
].second
;
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */