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/tablestylecellstylecontext.hxx" 31 #include "oox/drawingml/fillpropertiesgroupcontext.hxx" 32 #include "oox/drawingml/linepropertiescontext.hxx" 33 #include "oox/helper/attributelist.hxx" 34 35 using namespace ::oox::core; 36 using namespace ::com::sun::star; 37 using namespace ::com::sun::star::uno; 38 using namespace ::com::sun::star::xml::sax; 39 using ::rtl::OUString; 40 41 namespace oox { namespace drawingml { namespace table { 42 43 TableStyleCellStyleContext::TableStyleCellStyleContext( ContextHandler& rParent, TableStylePart& rTableStylePart ) 44 : ContextHandler( rParent ) 45 , mrTableStylePart( rTableStylePart ) 46 , mnLineType( XML_none ) 47 { 48 } 49 50 TableStyleCellStyleContext::~TableStyleCellStyleContext() 51 { 52 } 53 54 // CT_TableStyleCellStyle 55 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL 56 TableStyleCellStyleContext::createFastChildContext( ::sal_Int32 aElementToken, const uno::Reference< xml::sax::XFastAttributeList >& xAttribs ) 57 throw ( xml::sax::SAXException, uno::RuntimeException) 58 { 59 uno::Reference< xml::sax::XFastContextHandler > xRet; 60 AttributeList aAttribs( xAttribs ); 61 switch( aElementToken ) 62 { 63 case A_TOKEN( tcBdr ): // CT_TableCellBorderStyle 64 break; 65 case A_TOKEN( left ): // CT_ThemeableLineStyle 66 case A_TOKEN( right ): 67 case A_TOKEN( top ): 68 case A_TOKEN( bottom ): 69 case A_TOKEN( insideH ): 70 case A_TOKEN( insideV ): 71 case A_TOKEN( tl2br ): 72 case A_TOKEN( tr2bl ): 73 mnLineType = getBaseToken( aElementToken ); 74 break; 75 76 case A_TOKEN( ln ): 77 { 78 if ( mnLineType != XML_none ) 79 { 80 std::map < sal_Int32, ::oox::drawingml::LinePropertiesPtr >& rLineBorders = mrTableStylePart.getLineBorders(); 81 ::oox::drawingml::LinePropertiesPtr mpLineProperties( new oox::drawingml::LineProperties ); 82 rLineBorders[ mnLineType ] = mpLineProperties; 83 xRet = new LinePropertiesContext( *this, xAttribs, *mpLineProperties ); 84 } 85 } 86 break; 87 case A_TOKEN( lnRef ): 88 { 89 if ( mnLineType != XML_none ) 90 { 91 ShapeStyleRef& rLineStyleRef = mrTableStylePart.getStyleRefs()[ mnLineType ]; 92 rLineStyleRef.mnThemedIdx = aAttribs.getInteger( XML_idx, 0 ); 93 xRet.set( new ColorContext( *this, rLineStyleRef.maPhClr ) ); 94 } 95 } 96 break; 97 98 // EG_ThemeableFillStyle (choice) 99 case A_TOKEN( fill ): // CT_FillProperties 100 { 101 FillPropertiesPtr& rxFillProperties = mrTableStylePart.getFillProperties(); 102 rxFillProperties.reset( new FillProperties ); 103 xRet.set( new FillPropertiesContext( *this, *rxFillProperties ) ); 104 } 105 break; 106 case A_TOKEN( fillRef ): // CT_StyleMatrixReference 107 { 108 ShapeStyleRef& rStyleRef = mrTableStylePart.getStyleRefs()[ XML_fillRef ]; 109 rStyleRef.mnThemedIdx = aAttribs.getInteger( XML_idx, 0 ); 110 xRet.set( new ColorContext( *this, rStyleRef.maPhClr ) ); 111 } 112 break; 113 114 case A_TOKEN( cell3D ): // CT_Cell3D 115 break; 116 } 117 if( !xRet.is() ) 118 { 119 uno::Reference<XFastContextHandler> xTmp(this); 120 xRet.set( xTmp ); 121 } 122 return xRet; 123 } 124 125 } } } 126