Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/oox/source/drawingml/shapepropertiescontext.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 <drawingml/shapepropertiescontext.hxx>
21
22
#include <drawingml/scene3dcontext.hxx>
23
#include <drawingml/linepropertiescontext.hxx>
24
#include <drawingml/misccontexts.hxx>
25
#include <drawingml/transform2dcontext.hxx>
26
#include <drawingml/customshapegeometry.hxx>
27
#include <drawingml/effectpropertiescontext.hxx>
28
#include <oox/helper/attributelist.hxx>
29
#include <oox/token/namespaces.hxx>
30
#include <oox/token/tokens.hxx>
31
#include <drawingml/customshapeproperties.hxx>
32
33
using namespace oox::core;
34
using namespace ::com::sun::star;
35
using namespace ::com::sun::star::uno;
36
using namespace ::com::sun::star::drawing;
37
38
namespace oox::drawingml {
39
40
// CT_ShapeProperties
41
ShapePropertiesContext::ShapePropertiesContext( ContextHandler2Helper const & rParent, Shape& rShape, bool bForChart )
42
115k
: ContextHandler2( rParent )
43
115k
, mrShape( rShape )
44
115k
, mbForChart(bForChart)
45
115k
{
46
115k
}
47
48
ContextHandlerRef ShapePropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
49
190k
{
50
190k
    switch( aElementToken )
51
190k
    {
52
    // CT_Transform2D
53
94.3k
    case A_TOKEN( xfrm ):
54
94.3k
        return new Transform2DContext( *this, rAttribs, mrShape );
55
56
    // GeometryGroup
57
525
    case A_TOKEN( custGeom ):   // custom geometry "CT_CustomGeometry2D"
58
525
        return new CustomShapeGeometryContext( *this, *mrShape.getCustomShapeProperties() );
59
60
67.0k
    case A_TOKEN( prstGeom ):   // preset geometry "CT_PresetGeometry2D"
61
67.0k
        {
62
67.0k
            sal_Int32 nToken = rAttribs.getToken( XML_prst, 0 );
63
            // TODO: Move the following checks to a separate place or as a separate function
64
67.0k
            if (nToken == XML_line && !mrShape.isConnectorShape())
65
172
            {
66
172
                mrShape.setServiceName(u"com.sun.star.drawing.LineShape"_ustr);
67
172
            }
68
69
            // We got a preset geometry, forget the geometry inherited from the placeholder shape.
70
67.0k
            mrShape.getCustomShapeProperties() = std::make_shared<CustomShapeProperties>();
71
72
67.0k
            return new PresetShapeGeometryContext( *this, rAttribs, *(mrShape.getCustomShapeProperties()) );
73
0
        }
74
75
0
    case A_TOKEN( prstTxWarp ):
76
0
        return new PresetTextShapeContext( *this, rAttribs, *(mrShape.getCustomShapeProperties()) );
77
78
    // CT_LineProperties
79
12.0k
    case A_TOKEN( ln ):
80
12.0k
        return new LinePropertiesContext( *this, rAttribs, mrShape.getLineProperties(), nullptr, mbForChart );
81
82
    // EffectPropertiesGroup
83
    // todo not supported by core
84
2.86k
    case A_TOKEN( effectLst ):  // CT_EffectList
85
2.86k
    case A_TOKEN( effectDag ):  // CT_EffectContainer
86
2.86k
        return new EffectPropertiesContext( *this, mrShape.getEffectProperties() );
87
88
    // todo not supported by core, only for preservation via grab bags
89
20
    case A_TOKEN( scene3d ):    // CT_Scene3D
90
20
        return new Scene3DPropertiesContext( *this, mrShape.get3DProperties() );
91
92
    // todo not supported by core, only for preservation via grab bags
93
3
    case A_TOKEN( sp3d ):       // CT_Shape3D
94
3
        return new Shape3DPropertiesContext( *this, rAttribs, mrShape.get3DProperties() );
95
190k
    }
96
97
13.1k
    return FillPropertiesContext::createFillContext(*this, aElementToken, rAttribs, mrShape.getFillProperties(), nullptr);
98
190k
}
99
100
}
101
102
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */