update dev300-m58
[ooovba.git] / oox / source / drawingml / clrschemecontext.cxx
blob6eedb908c00efffd30ff1ac9d315691f9757b3e2
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: clrschemecontext.cxx,v $
10 * $Revision: 1.5 $
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/clrschemecontext.hxx"
32 #include "oox/core/namespaces.hxx"
33 #include "tokens.hxx"
35 using namespace ::oox::core;
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::xml::sax;
39 namespace oox { namespace drawingml {
41 static void setClrMap( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes,
42 ClrMap& rClrMap, sal_Int32 nToken )
44 if ( xAttributes->hasAttribute( nToken ) )
46 sal_Int32 nMappedToken = xAttributes->getOptionalValueToken( nToken, 0 );
47 rClrMap.setColorMap( nToken, nMappedToken );
51 clrMapContext::clrMapContext( ContextHandler& rParent,
52 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, ClrMap& rClrMap )
53 : ContextHandler( rParent )
55 setClrMap( xAttributes, rClrMap, XML_bg1 );
56 setClrMap( xAttributes, rClrMap, XML_tx1 );
57 setClrMap( xAttributes, rClrMap, XML_bg2 );
58 setClrMap( xAttributes, rClrMap, XML_tx2 );
59 setClrMap( xAttributes, rClrMap, XML_accent1 );
60 setClrMap( xAttributes, rClrMap, XML_accent2 );
61 setClrMap( xAttributes, rClrMap, XML_accent3 );
62 setClrMap( xAttributes, rClrMap, XML_accent4 );
63 setClrMap( xAttributes, rClrMap, XML_accent5 );
64 setClrMap( xAttributes, rClrMap, XML_accent6 );
65 setClrMap( xAttributes, rClrMap, XML_hlink );
66 setClrMap( xAttributes, rClrMap, XML_folHlink );
69 clrSchemeColorContext::clrSchemeColorContext( ContextHandler& rParent, ClrScheme& rClrScheme, sal_Int32 nColorToken ) :
70 ColorContext( rParent, *this ),
71 mrClrScheme( rClrScheme ),
72 mnColorToken( nColorToken )
76 clrSchemeColorContext::~clrSchemeColorContext()
78 mrClrScheme.setColor( mnColorToken, getColor( getFilter() ) );
81 clrSchemeContext::clrSchemeContext( ContextHandler& rParent, ClrScheme& rClrScheme ) :
82 ContextHandler( rParent ),
83 mrClrScheme( rClrScheme )
87 Reference< XFastContextHandler > clrSchemeContext::createFastChildContext(
88 sal_Int32 nElement, const Reference< XFastAttributeList >& ) throw (SAXException, RuntimeException)
90 switch( nElement )
92 case A_TOKEN( dk1 ):
93 case A_TOKEN( lt1 ):
94 case A_TOKEN( dk2 ):
95 case A_TOKEN( lt2 ):
96 case A_TOKEN( accent1 ):
97 case A_TOKEN( accent2 ):
98 case A_TOKEN( accent3 ):
99 case A_TOKEN( accent4 ):
100 case A_TOKEN( accent5 ):
101 case A_TOKEN( accent6 ):
102 case A_TOKEN( hlink ):
103 case A_TOKEN( folHlink ):
104 return new clrSchemeColorContext( *this, mrClrScheme, getToken( nElement ) );
106 return 0;