Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/oox/source/drawingml/table/tablestylecellstylecontext.cxx
Line
Count
Source (jump to first uncovered line)
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
21
#include <drawingml/table/tablestylecellstylecontext.hxx>
22
#include <drawingml/misccontexts.hxx>
23
#include <drawingml/lineproperties.hxx>
24
#include <drawingml/linepropertiescontext.hxx>
25
#include <oox/helper/attributelist.hxx>
26
#include <oox/token/namespaces.hxx>
27
#include <oox/token/tokens.hxx>
28
29
using namespace ::oox::core;
30
using namespace ::com::sun::star;
31
using namespace ::com::sun::star::uno;
32
33
namespace oox::drawingml::table {
34
35
TableStyleCellStyleContext::TableStyleCellStyleContext( ContextHandler2Helper const & rParent, TableStylePart& rTableStylePart )
36
506
: ContextHandler2( rParent )
37
506
, mrTableStylePart( rTableStylePart )
38
506
, mnLineType( XML_none )
39
506
{
40
506
}
41
42
TableStyleCellStyleContext::~TableStyleCellStyleContext()
43
506
{
44
506
}
45
46
// CT_TableStyleCellStyle
47
ContextHandlerRef
48
TableStyleCellStyleContext::onCreateContext( ::sal_Int32 aElementToken, const AttributeList& rAttribs )
49
1.82k
{
50
1.82k
    switch( aElementToken )
51
1.82k
    {
52
506
        case A_TOKEN( tcBdr ):      // CT_TableCellBorderStyle
53
506
            break;
54
58
        case A_TOKEN( left ):       // CT_ThemeableLineStyle
55
116
        case A_TOKEN( right ):
56
230
        case A_TOKEN( top ):
57
344
        case A_TOKEN( bottom ):
58
402
        case A_TOKEN( insideH ):
59
460
        case A_TOKEN( insideV ):
60
460
        case A_TOKEN( tl2br ):
61
460
        case A_TOKEN( tr2bl ):
62
460
            mnLineType = getBaseToken( aElementToken );
63
460
            break;
64
65
460
        case A_TOKEN( ln ):
66
460
            {
67
460
                if ( mnLineType != XML_none )
68
460
                {
69
460
                    std::map < sal_Int32, ::oox::drawingml::LinePropertiesPtr >& rLineBorders = mrTableStylePart.getLineBorders();
70
460
                    ::oox::drawingml::LinePropertiesPtr pLineProperties = std::make_shared<oox::drawingml::LineProperties>();
71
460
                    rLineBorders[ mnLineType ] = pLineProperties;
72
460
                    return new LinePropertiesContext( *this, rAttribs, *pLineProperties );
73
460
                }
74
460
            }
75
0
            break;
76
0
        case A_TOKEN( lnRef ):
77
0
            {
78
0
                if ( mnLineType != XML_none )
79
0
                {
80
0
                    ShapeStyleRef& rLineStyleRef = mrTableStylePart.getStyleRefs()[ mnLineType ];
81
0
                    rLineStyleRef.mnThemedIdx = rAttribs.getInteger( XML_idx, 0 );
82
0
                    return new ColorContext( *this, rLineStyleRef.maPhClr );
83
0
                }
84
0
            }
85
0
            break;
86
87
        // EG_ThemeableFillStyle (choice)
88
394
        case A_TOKEN( fill ):       // CT_FillProperties
89
394
            {
90
394
                FillPropertiesPtr& rxFillProperties = mrTableStylePart.getFillProperties();
91
394
                rxFillProperties = std::make_shared<FillProperties>();
92
394
                return new FillPropertiesContext( *this, *rxFillProperties );
93
0
            }
94
0
        case A_TOKEN( fillRef ):    // CT_StyleMatrixReference
95
0
            {
96
0
                ShapeStyleRef& rStyleRef = mrTableStylePart.getStyleRefs()[ XML_fillRef ];
97
0
                rStyleRef.mnThemedIdx = rAttribs.getInteger( XML_idx, 0 );
98
0
                return new ColorContext( *this, rStyleRef.maPhClr );
99
0
            }
100
0
        case A_TOKEN( cell3D ):     // CT_Cell3D
101
0
            break;
102
1.82k
    }
103
104
966
    return this;
105
1.82k
}
106
107
}
108
109
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */