1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: colorchoicecontext.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/drawingml/colorchoicecontext.hxx"
32 #include "oox/helper/attributelist.hxx"
33 #include "oox/core/namespaces.hxx"
34 #include "oox/drawingml/color.hxx"
36 using ::com::sun::star::uno::Reference
;
37 using ::com::sun::star::uno::RuntimeException
;
38 using ::com::sun::star::xml::sax::SAXException
;
39 using ::com::sun::star::xml::sax::XFastAttributeList
;
40 using ::com::sun::star::xml::sax::XFastContextHandler
;
41 using ::oox::core::ContextHandler
;
46 // ============================================================================
48 ColorValueContext::ColorValueContext( ContextHandler
& rParent
, Color
& rColor
) :
49 ContextHandler( rParent
),
54 void ColorValueContext::startFastElement( sal_Int32 nElement
, const Reference
< XFastAttributeList
>& rxAttribs
)
55 throw (SAXException
, RuntimeException
)
57 AttributeList
aAttribs( rxAttribs
);
60 case A_TOKEN( scrgbClr
):
62 aAttribs
.getInteger( XML_r
, 0 ),
63 aAttribs
.getInteger( XML_g
, 0 ),
64 aAttribs
.getInteger( XML_b
, 0 ) );
67 case A_TOKEN( srgbClr
):
68 mrColor
.setSrgbClr( aAttribs
.getIntegerHex( XML_val
, 0 ) );
71 case A_TOKEN( hslClr
):
73 aAttribs
.getInteger( XML_hue
, 0 ),
74 aAttribs
.getInteger( XML_sat
, 0 ),
75 aAttribs
.getInteger( XML_lum
, 0 ) );
78 case A_TOKEN( sysClr
):
80 aAttribs
.getToken( XML_val
, XML_TOKEN_INVALID
),
81 aAttribs
.getIntegerHex( XML_lastClr
, -1 ) );
84 case A_TOKEN( schemeClr
):
85 mrColor
.setSchemeClr( aAttribs
.getToken( XML_val
, XML_TOKEN_INVALID
) );
88 case A_TOKEN( prstClr
):
89 mrColor
.setPrstClr( aAttribs
.getToken( XML_val
, XML_TOKEN_INVALID
) );
94 Reference
< XFastContextHandler
> ColorValueContext::createFastChildContext(
95 sal_Int32 nElement
, const Reference
< XFastAttributeList
>& rxAttribs
) throw (SAXException
, RuntimeException
)
97 AttributeList
aAttribs( rxAttribs
);
100 case A_TOKEN( alpha
):
101 case A_TOKEN( alphaMod
):
102 case A_TOKEN( alphaOff
):
103 case A_TOKEN( blue
):
104 case A_TOKEN( blueMod
):
105 case A_TOKEN( blueOff
):
107 case A_TOKEN( hueMod
):
108 case A_TOKEN( hueOff
):
110 case A_TOKEN( lumMod
):
111 case A_TOKEN( lumOff
):
112 case A_TOKEN( green
):
113 case A_TOKEN( greenMod
):
114 case A_TOKEN( greenOff
):
116 case A_TOKEN( redMod
):
117 case A_TOKEN( redOff
):
119 case A_TOKEN( satMod
):
120 case A_TOKEN( satOff
):
121 case A_TOKEN( shade
):
122 case A_TOKEN( tint
):
123 mrColor
.addTransformation( nElement
, aAttribs
.getInteger( XML_val
, 0 ) );
125 case A_TOKEN( comp
):
126 case A_TOKEN( gamma
):
127 case A_TOKEN( gray
):
129 case A_TOKEN( invGamma
):
130 mrColor
.addTransformation( nElement
);
136 // ============================================================================
138 ColorContext::ColorContext( ContextHandler
& rParent
, Color
& rColor
) :
139 ContextHandler( rParent
),
144 Reference
< XFastContextHandler
> ColorContext::createFastChildContext(
145 sal_Int32 nElement
, const Reference
< XFastAttributeList
>& ) throw (SAXException
, RuntimeException
)
149 case A_TOKEN( scrgbClr
):
150 case A_TOKEN( srgbClr
):
151 case A_TOKEN( hslClr
):
152 case A_TOKEN( sysClr
):
153 case A_TOKEN( schemeClr
):
154 case A_TOKEN( prstClr
):
155 return new ColorValueContext( *this, mrColor
);
160 // ============================================================================
162 } // namespace drawingml