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 "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
;
34 // ============================================================================
36 ColorValueContext::ColorValueContext( ContextHandler
& rParent
, Color
& rColor
) :
37 ContextHandler( rParent
),
42 void ColorValueContext::startFastElement( sal_Int32 nElement
, const Reference
< XFastAttributeList
>& rxAttribs
)
43 throw (SAXException
, RuntimeException
)
45 AttributeList
aAttribs( rxAttribs
);
48 case A_TOKEN( scrgbClr
):
50 aAttribs
.getInteger( XML_r
, 0 ),
51 aAttribs
.getInteger( XML_g
, 0 ),
52 aAttribs
.getInteger( XML_b
, 0 ) );
55 case A_TOKEN( srgbClr
):
56 mrColor
.setSrgbClr( aAttribs
.getIntegerHex( XML_val
, 0 ) );
59 case A_TOKEN( hslClr
):
61 aAttribs
.getInteger( XML_hue
, 0 ),
62 aAttribs
.getInteger( XML_sat
, 0 ),
63 aAttribs
.getInteger( XML_lum
, 0 ) );
66 case A_TOKEN( sysClr
):
68 aAttribs
.getToken( XML_val
, XML_TOKEN_INVALID
),
69 aAttribs
.getIntegerHex( XML_lastClr
, -1 ) );
72 case A_TOKEN( schemeClr
):
73 mrColor
.setSchemeClr( aAttribs
.getToken( XML_val
, XML_TOKEN_INVALID
) );
76 case A_TOKEN( prstClr
):
77 mrColor
.setPrstClr( aAttribs
.getToken( XML_val
, XML_TOKEN_INVALID
) );
82 Reference
< XFastContextHandler
> ColorValueContext::createFastChildContext(
83 sal_Int32 nElement
, const Reference
< XFastAttributeList
>& rxAttribs
) throw (SAXException
, RuntimeException
)
85 AttributeList
aAttribs( rxAttribs
);
88 case A_TOKEN( alpha
):
89 case A_TOKEN( alphaMod
):
90 case A_TOKEN( alphaOff
):
92 case A_TOKEN( blueMod
):
93 case A_TOKEN( blueOff
):
95 case A_TOKEN( hueMod
):
96 case A_TOKEN( hueOff
):
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
):
104 case A_TOKEN( redMod
):
105 case A_TOKEN( redOff
):
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 ) );
113 case A_TOKEN( comp
):
114 case A_TOKEN( gamma
):
115 case A_TOKEN( gray
):
117 case A_TOKEN( invGamma
):
118 mrColor
.addTransformation( nElement
);
124 // ============================================================================
126 ColorContext::ColorContext( ContextHandler
& rParent
, Color
& rColor
) :
127 ContextHandler( rParent
),
132 Reference
< XFastContextHandler
> ColorContext::createFastChildContext(
133 sal_Int32 nElement
, const Reference
< XFastAttributeList
>& ) throw (SAXException
, RuntimeException
)
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
);
148 // ============================================================================
150 } // namespace drawingml
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */