1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include "oox/drawingml/clrschemecontext.hxx" 29 #include "oox/core/xmlfilterbase.hxx" 30 31 using namespace ::oox::core; 32 using namespace ::com::sun::star::uno; 33 using namespace ::com::sun::star::xml::sax; 34 35 namespace oox { namespace drawingml { 36 37 static void setClrMap( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, 38 ClrMap& rClrMap, sal_Int32 nToken ) 39 { 40 if ( xAttributes->hasAttribute( nToken ) ) 41 { 42 sal_Int32 nMappedToken = xAttributes->getOptionalValueToken( nToken, 0 ); 43 rClrMap.setColorMap( nToken, nMappedToken ); 44 } 45 } 46 47 clrMapContext::clrMapContext( ContextHandler& rParent, 48 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, ClrMap& rClrMap ) 49 : ContextHandler( rParent ) 50 { 51 setClrMap( xAttributes, rClrMap, XML_bg1 ); 52 setClrMap( xAttributes, rClrMap, XML_tx1 ); 53 setClrMap( xAttributes, rClrMap, XML_bg2 ); 54 setClrMap( xAttributes, rClrMap, XML_tx2 ); 55 setClrMap( xAttributes, rClrMap, XML_accent1 ); 56 setClrMap( xAttributes, rClrMap, XML_accent2 ); 57 setClrMap( xAttributes, rClrMap, XML_accent3 ); 58 setClrMap( xAttributes, rClrMap, XML_accent4 ); 59 setClrMap( xAttributes, rClrMap, XML_accent5 ); 60 setClrMap( xAttributes, rClrMap, XML_accent6 ); 61 setClrMap( xAttributes, rClrMap, XML_hlink ); 62 setClrMap( xAttributes, rClrMap, XML_folHlink ); 63 } 64 65 clrSchemeColorContext::clrSchemeColorContext( ContextHandler& rParent, ClrScheme& rClrScheme, sal_Int32 nColorToken ) : 66 ColorContext( rParent, *this ), 67 mrClrScheme( rClrScheme ), 68 mnColorToken( nColorToken ) 69 { 70 } 71 72 clrSchemeColorContext::~clrSchemeColorContext() 73 { 74 mrClrScheme.setColor( mnColorToken, getColor( getFilter().getGraphicHelper() ) ); 75 } 76 77 clrSchemeContext::clrSchemeContext( ContextHandler& rParent, ClrScheme& rClrScheme ) : 78 ContextHandler( rParent ), 79 mrClrScheme( rClrScheme ) 80 { 81 } 82 83 Reference< XFastContextHandler > clrSchemeContext::createFastChildContext( 84 sal_Int32 nElement, const Reference< XFastAttributeList >& ) throw (SAXException, RuntimeException) 85 { 86 switch( nElement ) 87 { 88 case A_TOKEN( dk1 ): 89 case A_TOKEN( lt1 ): 90 case A_TOKEN( dk2 ): 91 case A_TOKEN( lt2 ): 92 case A_TOKEN( accent1 ): 93 case A_TOKEN( accent2 ): 94 case A_TOKEN( accent3 ): 95 case A_TOKEN( accent4 ): 96 case A_TOKEN( accent5 ): 97 case A_TOKEN( accent6 ): 98 case A_TOKEN( hlink ): 99 case A_TOKEN( folHlink ): 100 return new clrSchemeColorContext( *this, mrClrScheme, getBaseToken( nElement ) ); 101 } 102 return 0; 103 } 104 105 } } 106