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 <osl/diagnose.h> 29 30 #include "oox/drawingml/table/tablestyletextstylecontext.hxx" 31 #include "oox/drawingml/colorchoicecontext.hxx" 32 #include "oox/helper/attributelist.hxx" 33 34 using namespace ::oox::core; 35 using namespace ::com::sun::star; 36 using namespace ::com::sun::star::uno; 37 using namespace ::com::sun::star::xml::sax; 38 using ::rtl::OUString; 39 40 namespace oox { namespace drawingml { namespace table { 41 42 TableStyleTextStyleContext::TableStyleTextStyleContext( ContextHandler& rParent, 43 const Reference< XFastAttributeList >& xAttribs, TableStylePart& rTableStylePart ) 44 : ContextHandler( rParent ) 45 , mrTableStylePart( rTableStylePart ) 46 { 47 sal_Int32 nB = xAttribs->getOptionalValueToken( XML_b, XML_def ); 48 if ( nB == XML_on ) 49 mrTableStylePart.getTextBoldStyle() = ::boost::optional< sal_Bool >( sal_True ); 50 else if ( nB == XML_off ) 51 mrTableStylePart.getTextBoldStyle() = ::boost::optional< sal_Bool >( sal_False ); 52 53 sal_Int32 nI = xAttribs->getOptionalValueToken( XML_i, XML_def ); 54 if ( nI == XML_on ) 55 mrTableStylePart.getTextItalicStyle() = ::boost::optional< sal_Bool >( sal_True ); 56 else if ( nI == XML_off ) 57 mrTableStylePart.getTextItalicStyle() = ::boost::optional< sal_Bool >( sal_False ); 58 } 59 60 TableStyleTextStyleContext::~TableStyleTextStyleContext() 61 { 62 } 63 64 // CT_TableStyleTextStyle 65 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL 66 TableStyleTextStyleContext::createFastChildContext( ::sal_Int32 aElementToken, const uno::Reference< xml::sax::XFastAttributeList >& xAttribs ) 67 throw ( xml::sax::SAXException, uno::RuntimeException) 68 { 69 uno::Reference< xml::sax::XFastContextHandler > xRet; 70 AttributeList aAttribs( xAttribs ); 71 72 switch( aElementToken ) 73 { 74 // EG_ThemeableFontStyles (choice) 75 case A_TOKEN( font ): // CT_FontCollection 76 xRet.set( this ); 77 break; 78 case A_TOKEN( ea ): // CT_TextFont 79 mrTableStylePart.getAsianFont().setAttributes( aAttribs ); 80 return 0; 81 case A_TOKEN( cs ): // CT_TextFont 82 mrTableStylePart.getComplexFont().setAttributes( aAttribs ); 83 return 0; 84 case A_TOKEN( sym ): // CT_TextFont 85 mrTableStylePart.getSymbolFont().setAttributes( aAttribs ); 86 return 0; 87 case A_TOKEN( latin ): // CT_TextFont 88 mrTableStylePart.getLatinFont().setAttributes( aAttribs ); 89 return 0; 90 91 case A_TOKEN( fontRef ): // CT_FontReference 92 { 93 ShapeStyleRef& rFontStyle = mrTableStylePart.getStyleRefs()[ XML_fontRef ]; 94 rFontStyle.mnThemedIdx = aAttribs.getToken( XML_idx, XML_none ); 95 xRet.set( new ColorContext( *this, rFontStyle.maPhClr ) ); 96 } 97 break; 98 99 case A_TOKEN( extLst ): // CT_OfficeArtExtensionList 100 break; 101 } 102 if( !xRet.is() ) 103 xRet.set( new ColorValueContext( *this, mrTableStylePart.getTextColor() ) ); 104 105 return xRet; 106 } 107 108 } } } 109