bump product version to 4.1.6.2
[LibreOffice.git] / oox / source / drawingml / colorchoicecontext.cxx
blob40f1cd6974ebc9f5c2c43df4ffafc1ea12062a61
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "oox/drawingml/colorchoicecontext.hxx"
21 #include "oox/helper/attributelist.hxx"
22 #include "oox/drawingml/color.hxx"
24 using ::com::sun::star::uno::Reference;
25 using ::com::sun::star::uno::RuntimeException;
26 using ::com::sun::star::xml::sax::SAXException;
27 using ::com::sun::star::xml::sax::XFastAttributeList;
28 using ::com::sun::star::xml::sax::XFastContextHandler;
29 using ::oox::core::ContextHandler;
31 namespace oox {
32 namespace drawingml {
34 // ============================================================================
36 ColorValueContext::ColorValueContext( ContextHandler& rParent, Color& rColor ) :
37 ContextHandler( rParent ),
38 mrColor( rColor )
42 void ColorValueContext::startFastElement( sal_Int32 nElement, const Reference< XFastAttributeList >& rxAttribs )
43 throw (SAXException, RuntimeException)
45 AttributeList aAttribs( rxAttribs );
46 switch( nElement )
48 case A_TOKEN( scrgbClr ):
49 mrColor.setScrgbClr(
50 aAttribs.getInteger( XML_r, 0 ),
51 aAttribs.getInteger( XML_g, 0 ),
52 aAttribs.getInteger( XML_b, 0 ) );
53 break;
55 case A_TOKEN( srgbClr ):
56 mrColor.setSrgbClr( aAttribs.getIntegerHex( XML_val, 0 ) );
57 break;
59 case A_TOKEN( hslClr ):
60 mrColor.setHslClr(
61 aAttribs.getInteger( XML_hue, 0 ),
62 aAttribs.getInteger( XML_sat, 0 ),
63 aAttribs.getInteger( XML_lum, 0 ) );
64 break;
66 case A_TOKEN( sysClr ):
67 mrColor.setSysClr(
68 aAttribs.getToken( XML_val, XML_TOKEN_INVALID ),
69 aAttribs.getIntegerHex( XML_lastClr, -1 ) );
70 break;
72 case A_TOKEN( schemeClr ):
73 mrColor.setSchemeClr( aAttribs.getToken( XML_val, XML_TOKEN_INVALID ) );
74 break;
76 case A_TOKEN( prstClr ):
77 mrColor.setPrstClr( aAttribs.getToken( XML_val, XML_TOKEN_INVALID ) );
78 break;
82 Reference< XFastContextHandler > ColorValueContext::createFastChildContext(
83 sal_Int32 nElement, const Reference< XFastAttributeList >& rxAttribs ) throw (SAXException, RuntimeException)
85 AttributeList aAttribs( rxAttribs );
86 switch( nElement )
88 case A_TOKEN( alpha ):
89 case A_TOKEN( alphaMod ):
90 case A_TOKEN( alphaOff ):
91 case A_TOKEN( blue ):
92 case A_TOKEN( blueMod ):
93 case A_TOKEN( blueOff ):
94 case A_TOKEN( hue ):
95 case A_TOKEN( hueMod ):
96 case A_TOKEN( hueOff ):
97 case A_TOKEN( lum ):
98 case A_TOKEN( lumMod ):
99 case A_TOKEN( lumOff ):
100 case A_TOKEN( green ):
101 case A_TOKEN( greenMod ):
102 case A_TOKEN( greenOff ):
103 case A_TOKEN( red ):
104 case A_TOKEN( redMod ):
105 case A_TOKEN( redOff ):
106 case A_TOKEN( sat ):
107 case A_TOKEN( satMod ):
108 case A_TOKEN( satOff ):
109 case A_TOKEN( shade ):
110 case A_TOKEN( tint ):
111 mrColor.addTransformation( nElement, aAttribs.getInteger( XML_val, 0 ) );
112 break;
113 case A_TOKEN( comp ):
114 case A_TOKEN( gamma ):
115 case A_TOKEN( gray ):
116 case A_TOKEN( inv ):
117 case A_TOKEN( invGamma ):
118 mrColor.addTransformation( nElement );
119 break;
121 return 0;
124 // ============================================================================
126 ColorContext::ColorContext( ContextHandler& rParent, Color& rColor ) :
127 ContextHandler( rParent ),
128 mrColor( rColor )
132 Reference< XFastContextHandler > ColorContext::createFastChildContext(
133 sal_Int32 nElement, const Reference< XFastAttributeList >& ) throw (SAXException, RuntimeException)
135 switch( nElement )
137 case A_TOKEN( scrgbClr ):
138 case A_TOKEN( srgbClr ):
139 case A_TOKEN( hslClr ):
140 case A_TOKEN( sysClr ):
141 case A_TOKEN( schemeClr ):
142 case A_TOKEN( prstClr ):
143 return new ColorValueContext( *this, mrColor );
145 return 0;
148 // ============================================================================
150 } // namespace drawingml
151 } // namespace oox
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */