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 "drawingml/clrschemecontext.hxx"
21 #include "oox/core/xmlfilterbase.hxx"
23 using namespace ::oox::core
;
24 using namespace ::com::sun::star::uno
;
25 using namespace ::com::sun::star::xml::sax
;
27 namespace oox
{ namespace drawingml
{
29 static void setClrMap( const ::oox::AttributeList
& rAttributes
,
30 ClrMap
& rClrMap
, sal_Int32 nToken
)
32 if ( rAttributes
.hasAttribute( nToken
) )
34 sal_Int32 nMappedToken
= rAttributes
.getToken( nToken
, 0 );
35 rClrMap
.setColorMap( nToken
, nMappedToken
);
39 clrMapContext::clrMapContext( ContextHandler2Helper
& rParent
,
40 const ::oox::AttributeList
& rAttributes
, ClrMap
& rClrMap
)
41 : ContextHandler2( rParent
)
43 setClrMap( rAttributes
, rClrMap
, XML_bg1
);
44 setClrMap( rAttributes
, rClrMap
, XML_tx1
);
45 setClrMap( rAttributes
, rClrMap
, XML_bg2
);
46 setClrMap( rAttributes
, rClrMap
, XML_tx2
);
47 setClrMap( rAttributes
, rClrMap
, XML_accent1
);
48 setClrMap( rAttributes
, rClrMap
, XML_accent2
);
49 setClrMap( rAttributes
, rClrMap
, XML_accent3
);
50 setClrMap( rAttributes
, rClrMap
, XML_accent4
);
51 setClrMap( rAttributes
, rClrMap
, XML_accent5
);
52 setClrMap( rAttributes
, rClrMap
, XML_accent6
);
53 setClrMap( rAttributes
, rClrMap
, XML_hlink
);
54 setClrMap( rAttributes
, rClrMap
, XML_folHlink
);
57 clrSchemeColorContext::clrSchemeColorContext( ContextHandler2Helper
& rParent
, ClrScheme
& rClrScheme
, sal_Int32 nColorToken
) :
58 ColorContext( rParent
, *this ),
59 mrClrScheme( rClrScheme
),
60 mnColorToken( nColorToken
)
64 clrSchemeColorContext::~clrSchemeColorContext()
66 mrClrScheme
.setColor( mnColorToken
, getColor( getFilter().getGraphicHelper() ) );
69 clrSchemeContext::clrSchemeContext( ContextHandler2Helper
& rParent
, ClrScheme
& rClrScheme
) :
70 ContextHandler2( rParent
),
71 mrClrScheme( rClrScheme
)
75 ContextHandlerRef
clrSchemeContext::onCreateContext(
76 sal_Int32 nElement
, const AttributeList
& )
84 case A_TOKEN( accent1
):
85 case A_TOKEN( accent2
):
86 case A_TOKEN( accent3
):
87 case A_TOKEN( accent4
):
88 case A_TOKEN( accent5
):
89 case A_TOKEN( accent6
):
90 case A_TOKEN( hlink
):
91 case A_TOKEN( folHlink
):
92 return new clrSchemeColorContext( *this, mrClrScheme
, getBaseToken( nElement
) );
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */