Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/oox/source/drawingml/table/tablecontext.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
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/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
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 .
18
 */
19
20
#include <oox/helper/attributelist.hxx>
21
#include <drawingml/colorchoicecontext.hxx>
22
#include <drawingml/guidcontext.hxx>
23
#include <drawingml/table/tablecontext.hxx>
24
#include <drawingml/table/tableproperties.hxx>
25
#include <drawingml/table/tablestylecontext.hxx>
26
#include <drawingml/table/tablerowcontext.hxx>
27
#include <drawingml/effectpropertiescontext.hxx>
28
#include <oox/token/namespaces.hxx>
29
#include <oox/token/tokens.hxx>
30
31
using namespace ::oox::core;
32
using namespace ::com::sun::star;
33
34
namespace oox::drawingml::table {
35
36
TableContext::TableContext( ContextHandler2Helper const & rParent, const ShapePtr& pShapePtr )
37
116
: ShapeContext( rParent, ShapePtr(), pShapePtr )
38
116
, mrTableProperties( *pShapePtr->getTableProperties() )
39
116
{
40
116
    pShapePtr->setTableType();
41
116
}
42
43
TableContext::~TableContext()
44
116
{
45
116
}
46
47
ContextHandlerRef
48
TableContext::onCreateContext( ::sal_Int32 aElementToken, const AttributeList& rAttribs )
49
1.87k
{
50
1.87k
    switch( aElementToken )
51
1.87k
    {
52
116
    case A_TOKEN( tblPr ):              // CT_TableProperties
53
116
        {
54
116
            mrTableProperties.setFirstRow( rAttribs.getBool( XML_firstRow, false ) );
55
116
            mrTableProperties.setFirstCol( rAttribs.getBool( XML_firstCol, false ) );
56
116
            mrTableProperties.setLastRow( rAttribs.getBool( XML_lastRow, false ) );
57
116
            mrTableProperties.setLastCol( rAttribs.getBool( XML_lastCol, false ) );
58
116
            mrTableProperties.setBandRow( rAttribs.getBool( XML_bandRow, false ) );
59
116
            mrTableProperties.setBandCol( rAttribs.getBool( XML_bandCol, false ) );
60
116
        }
61
116
        break;
62
0
    case A_TOKEN(solidFill):
63
0
        return new ColorContext(*this, &mrTableProperties.getBgColor());
64
0
    case A_TOKEN( tableStyle ):         // CT_TableStyle
65
0
        {
66
0
            std::shared_ptr< TableStyle >& rTableStyle = mrTableProperties.getTableStyle();
67
0
            rTableStyle = std::make_shared<TableStyle>();
68
0
            return new TableStyleContext( *this, rAttribs, *rTableStyle );
69
0
        }
70
0
    case A_TOKEN( effectLst ):  // CT_EffectList
71
0
        {
72
0
            return new EffectPropertiesContext(*this, mpShapePtr->getEffectProperties());
73
0
        }
74
33
    case A_TOKEN( tableStyleId ):       // ST_Guid
75
33
        return new oox::drawingml::GuidContext( *this, mrTableProperties.getStyleId() );
76
77
116
    case A_TOKEN( tblGrid ):            // CT_TableGrid
78
116
        break;
79
551
    case A_TOKEN( gridCol ):            // CT_TableCol
80
551
        {
81
551
            std::vector< sal_Int32 >& rvTableGrid( mrTableProperties.getTableGrid() );
82
551
            rvTableGrid.push_back( rAttribs.getInteger( XML_w, 0 ) );
83
551
        }
84
551
        break;
85
578
    case A_TOKEN( tr ):                 // CT_TableRow
86
578
        {
87
578
            std::vector< TableRow >& rvTableRows( mrTableProperties.getTableRows() );
88
578
            rvTableRows.emplace_back();
89
578
            return new TableRowContext( *this, rAttribs, rvTableRows.back() );
90
0
        }
91
1.87k
    }
92
93
1.25k
    return this;
94
1.87k
}
95
96
}
97
98
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */