Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : : #include "oox/drawingml/colorchoicecontext.hxx"
21 : : #include "oox/helper/attributelist.hxx"
22 : : #include "oox/drawingml/color.hxx"
23 : :
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;
30 : :
31 : : namespace oox {
32 : : namespace drawingml {
33 : :
34 : : // ============================================================================
35 : :
36 : 846 : ColorValueContext::ColorValueContext( ContextHandler& rParent, Color& rColor ) :
37 : : ContextHandler( rParent ),
38 : 846 : mrColor( rColor )
39 : : {
40 : 846 : }
41 : :
42 : 846 : void ColorValueContext::startFastElement( sal_Int32 nElement, const Reference< XFastAttributeList >& rxAttribs )
43 : : throw (SAXException, RuntimeException)
44 : : {
45 [ + - ]: 846 : AttributeList aAttribs( rxAttribs );
46 [ + + - + : 846 : switch( nElement )
+ + - ]
47 : : {
48 : : case A_TOKEN( scrgbClr ):
49 : : mrColor.setScrgbClr(
50 : : aAttribs.getInteger( XML_r, 0 ),
51 : : aAttribs.getInteger( XML_g, 0 ),
52 [ + - ][ + - ]: 36 : aAttribs.getInteger( XML_b, 0 ) );
[ + - ][ + - ]
53 : 36 : break;
54 : :
55 : : case A_TOKEN( srgbClr ):
56 [ + - ][ + - ]: 183 : mrColor.setSrgbClr( aAttribs.getIntegerHex( XML_val, 0 ) );
57 : 183 : break;
58 : :
59 : : case A_TOKEN( hslClr ):
60 : : mrColor.setHslClr(
61 : : aAttribs.getInteger( XML_hue, 0 ),
62 : : aAttribs.getInteger( XML_sat, 0 ),
63 [ # # ][ # # ]: 0 : aAttribs.getInteger( XML_lum, 0 ) );
[ # # ][ # # ]
64 : 0 : break;
65 : :
66 : : case A_TOKEN( sysClr ):
67 : : mrColor.setSysClr(
68 : : aAttribs.getToken( XML_val, XML_TOKEN_INVALID ),
69 [ + - ][ + - ]: 36 : aAttribs.getIntegerHex( XML_lastClr, -1 ) );
[ + - ]
70 : 36 : break;
71 : :
72 : : case A_TOKEN( schemeClr ):
73 [ + - ][ + - ]: 588 : mrColor.setSchemeClr( aAttribs.getToken( XML_val, XML_TOKEN_INVALID ) );
74 : 588 : break;
75 : :
76 : : case A_TOKEN( prstClr ):
77 [ + - ][ + - ]: 3 : mrColor.setPrstClr( aAttribs.getToken( XML_val, XML_TOKEN_INVALID ) );
78 : 3 : break;
79 [ + - ]: 846 : }
80 : 846 : }
81 : :
82 : 582 : Reference< XFastContextHandler > ColorValueContext::createFastChildContext(
83 : : sal_Int32 nElement, const Reference< XFastAttributeList >& rxAttribs ) throw (SAXException, RuntimeException)
84 : : {
85 [ + - ]: 582 : AttributeList aAttribs( rxAttribs );
86 [ + - - ]: 582 : switch( nElement )
87 : : {
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 [ + - ][ + - ]: 582 : mrColor.addTransformation( nElement, aAttribs.getInteger( XML_val, 0 ) );
112 : 582 : 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 [ # # ]: 0 : mrColor.addTransformation( nElement );
119 : 0 : break;
120 : : }
121 [ + - ][ + - ]: 582 : return 0;
122 : : }
123 : :
124 : : // ============================================================================
125 : :
126 : 849 : ColorContext::ColorContext( ContextHandler& rParent, Color& rColor ) :
127 : : ContextHandler( rParent ),
128 : 849 : mrColor( rColor )
129 : : {
130 : 849 : }
131 : :
132 : 846 : Reference< XFastContextHandler > ColorContext::createFastChildContext(
133 : : sal_Int32 nElement, const Reference< XFastAttributeList >& ) throw (SAXException, RuntimeException)
134 : : {
135 [ + - ]: 846 : switch( nElement )
136 : : {
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 [ + - ][ + - ]: 846 : return new ColorValueContext( *this, mrColor );
144 : : }
145 : 846 : return 0;
146 : : }
147 : :
148 : : // ============================================================================
149 : :
150 : : } // namespace drawingml
151 : : } // namespace oox
152 : :
153 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|