1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "oox/helper/attributelist.hxx"
21 #include "drawingml/guidcontext.hxx"
22 #include "drawingml/table/tablecontext.hxx"
23 #include "drawingml/table/tableproperties.hxx"
24 #include "drawingml/table/tablestylecontext.hxx"
25 #include "drawingml/table/tablerowcontext.hxx"
26 #include <oox/token/namespaces.hxx>
27 #include <oox/token/tokens.hxx>
29 using namespace ::oox::core
;
30 using namespace ::com::sun::star
;
32 namespace oox
{ namespace drawingml
{ namespace table
{
34 TableContext::TableContext( ContextHandler2Helper
& rParent
, ShapePtr pShapePtr
)
35 : ShapeContext( rParent
, ShapePtr(), pShapePtr
)
36 , mrTableProperties( *pShapePtr
->getTableProperties().get() )
38 pShapePtr
->setTableType();
41 TableContext::~TableContext()
46 TableContext::onCreateContext( ::sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
48 switch( aElementToken
)
50 case A_TOKEN( tblPr
): // CT_TableProperties
52 mrTableProperties
.setFirstRow( rAttribs
.getBool( XML_firstRow
, false ) );
53 mrTableProperties
.setFirstCol( rAttribs
.getBool( XML_firstCol
, false ) );
54 mrTableProperties
.setLastRow( rAttribs
.getBool( XML_lastRow
, false ) );
55 mrTableProperties
.setLastCol( rAttribs
.getBool( XML_lastCol
, false ) );
56 mrTableProperties
.setBandRow( rAttribs
.getBool( XML_bandRow
, false ) );
57 mrTableProperties
.setBandCol( rAttribs
.getBool( XML_bandCol
, false ) );
60 case A_TOKEN( tableStyle
): // CT_TableStyle
62 std::shared_ptr
< TableStyle
>& rTableStyle
= mrTableProperties
.getTableStyle();
63 rTableStyle
.reset( new TableStyle() );
64 return new TableStyleContext( *this, rAttribs
, *rTableStyle
);
66 case A_TOKEN( tableStyleId
): // ST_Guid
67 return new oox::drawingml::GuidContext( *this, mrTableProperties
.getStyleId() );
69 case A_TOKEN( tblGrid
): // CT_TableGrid
71 case A_TOKEN( gridCol
): // CT_TableCol
73 std::vector
< sal_Int32
>& rvTableGrid( mrTableProperties
.getTableGrid() );
74 rvTableGrid
.push_back( rAttribs
.getString( XML_w
).get().toInt32() );
77 case A_TOKEN( tr
): // CT_TableRow
79 std::vector
< TableRow
>& rvTableRows( mrTableProperties
.getTableRows() );
80 rvTableRows
.resize( rvTableRows
.size() + 1 );
81 return new TableRowContext( *this, rAttribs
, rvTableRows
.back() );
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */