1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #include <osl/diagnose.h> 25 #include "oox/helper/attributelist.hxx" 26 #include "oox/drawingml/guidcontext.hxx" 27 #include "oox/drawingml/table/tablecontext.hxx" 28 #include "oox/drawingml/table/tableproperties.hxx" 29 #include "oox/drawingml/table/tablestylecontext.hxx" 30 #include "oox/drawingml/table/tablerowcontext.hxx" 31 32 using namespace ::oox::core; 33 using namespace ::com::sun::star; 34 using ::rtl::OUString; 35 36 namespace oox { namespace drawingml { namespace table { 37 38 TableContext::TableContext( ContextHandler& rParent, ShapePtr pShapePtr ) 39 : ShapeContext( rParent, ShapePtr(), pShapePtr ) 40 , mrTableProperties( *pShapePtr->getTableProperties().get() ) 41 { 42 pShapePtr->setTableType(); 43 } 44 45 TableContext::~TableContext() 46 { 47 } 48 49 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL 50 TableContext::createFastChildContext( ::sal_Int32 aElementToken, const uno::Reference< xml::sax::XFastAttributeList >& xAttribs ) 51 throw ( xml::sax::SAXException, uno::RuntimeException) 52 { 53 uno::Reference< xml::sax::XFastContextHandler > xRet; 54 55 switch( aElementToken ) 56 { 57 case A_TOKEN( tblPr ): // CT_TableProperties 58 { 59 AttributeList aAttribs( xAttribs ); 60 mrTableProperties.isRtl() = aAttribs.getBool( XML_rtl, sal_False ); 61 mrTableProperties.isFirstRow() = aAttribs.getBool( XML_firstRow, sal_False ); 62 mrTableProperties.isFirstCol() = aAttribs.getBool( XML_firstCol, sal_False ); 63 mrTableProperties.isLastRow() = aAttribs.getBool( XML_lastRow, sal_False ); 64 mrTableProperties.isLastCol() = aAttribs.getBool( XML_lastCol, sal_False ); 65 mrTableProperties.isBandRow() = aAttribs.getBool( XML_bandRow, sal_False ); 66 mrTableProperties.isBandCol() = aAttribs.getBool( XML_bandCol, sal_False ); 67 } 68 break; 69 case A_TOKEN( tableStyle ): // CT_TableStyle 70 { 71 boost::shared_ptr< TableStyle >& rTableStyle = mrTableProperties.getTableStyle(); 72 rTableStyle.reset( new TableStyle() ); 73 xRet = new TableStyleContext( *this, xAttribs, *rTableStyle ); 74 } 75 break; 76 case A_TOKEN( tableStyleId ): // ST_Guid 77 xRet.set( new oox::drawingml::GuidContext( *this, mrTableProperties.getStyleId() ) ); 78 break; 79 80 case A_TOKEN( tblGrid ): // CT_TableGrid 81 break; 82 case A_TOKEN( gridCol ): // CT_TableCol 83 { 84 std::vector< sal_Int32 >& rvTableGrid( mrTableProperties.getTableGrid() ); 85 rvTableGrid.push_back( xAttribs->getOptionalValue( XML_w ).toInt32() ); 86 } 87 break; 88 case A_TOKEN( tr ): // CT_TableRow 89 { 90 std::vector< TableRow >& rvTableRows( mrTableProperties.getTableRows() ); 91 rvTableRows.resize( rvTableRows.size() + 1 ); 92 xRet.set( new TableRowContext( *this, xAttribs, rvTableRows.back() ) ); 93 } 94 break; 95 } 96 97 if( !xRet.is() ) 98 xRet.set( this ); 99 100 return xRet; 101 } 102 103 } } } 104