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: tablecontext.cxx,v $
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 <osl/diagnose.h>
32 #include "oox/helper/attributelist.hxx"
33 #include "oox/drawingml/guidcontext.hxx"
34 #include "oox/drawingml/table/tablecontext.hxx"
35 #include "oox/drawingml/table/tableproperties.hxx"
36 #include "oox/drawingml/table/tablestylecontext.hxx"
37 #include "oox/drawingml/table/tablerowcontext.hxx"
38 #include "oox/core/namespaces.hxx"
40 using namespace ::oox::core
;
41 using namespace ::com::sun::star
;
42 using ::rtl::OUString
;
44 namespace oox
{ namespace drawingml
{ namespace table
{
46 TableContext::TableContext( ContextHandler
& rParent
, ShapePtr pShapePtr
)
47 : ShapeContext( rParent
, ShapePtr(), pShapePtr
)
48 , mrTableProperties( *pShapePtr
->getTableProperties().get() )
50 pShapePtr
->setServiceName( "com.sun.star.drawing.TableShape" );
51 pShapePtr
->setSubType( 0 );
54 TableContext::~TableContext()
58 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
59 TableContext::createFastChildContext( ::sal_Int32 aElementToken
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttribs
)
60 throw ( xml::sax::SAXException
, uno::RuntimeException
)
62 uno::Reference
< xml::sax::XFastContextHandler
> xRet
;
64 switch( aElementToken
)
66 case NMSP_DRAWINGML
|XML_tblPr
: // CT_TableProperties
68 AttributeList
aAttribs( xAttribs
);
69 mrTableProperties
.isRtl() = aAttribs
.getBool( XML_rtl
, sal_False
);
70 mrTableProperties
.isFirstRow() = aAttribs
.getBool( XML_firstRow
, sal_False
);
71 mrTableProperties
.isFirstCol() = aAttribs
.getBool( XML_firstCol
, sal_False
);
72 mrTableProperties
.isLastRow() = aAttribs
.getBool( XML_lastRow
, sal_False
);
73 mrTableProperties
.isLastCol() = aAttribs
.getBool( XML_lastCol
, sal_False
);
74 mrTableProperties
.isBandRow() = aAttribs
.getBool( XML_bandRow
, sal_False
);
75 mrTableProperties
.isBandCol() = aAttribs
.getBool( XML_bandCol
, sal_False
);
78 case NMSP_DRAWINGML
|XML_tableStyle
: // CT_TableStyle
80 boost::shared_ptr
< TableStyle
>& rTableStyle
= mrTableProperties
.getTableStyle();
81 rTableStyle
.reset( new TableStyle() );
82 xRet
= new TableStyleContext( *this, xAttribs
, *rTableStyle
);
85 case NMSP_DRAWINGML
|XML_tableStyleId
: // ST_Guid
86 xRet
.set( new oox::drawingml::GuidContext( *this, mrTableProperties
.getStyleId() ) );
89 case NMSP_DRAWINGML
|XML_tblGrid
: // CT_TableGrid
91 case NMSP_DRAWINGML
|XML_gridCol
: // CT_TableCol
93 std::vector
< sal_Int32
>& rvTableGrid( mrTableProperties
.getTableGrid() );
94 rvTableGrid
.push_back( xAttribs
->getOptionalValue( XML_w
).toInt32() );
97 case NMSP_DRAWINGML
|XML_tr
: // CT_TableRow
99 std::vector
< TableRow
>& rvTableRows( mrTableProperties
.getTableRows() );
100 rvTableRows
.resize( rvTableRows
.size() + 1 );
101 xRet
.set( new TableRowContext( *this, xAttribs
, rvTableRows
.back() ) );