Coverage Report

Created: 2026-08-14 10:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/oox/source/drawingml/diagram/diagramdefinitioncontext.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 "diagramdefinitioncontext.hxx"
21
#include "datamodel_oox.hxx"
22
#include "datamodelcontext.hxx"
23
#include "layoutnodecontext.hxx"
24
#include <oox/helper/attributelist.hxx>
25
#include <oox/token/namespaces.hxx>
26
#include <utility>
27
28
using namespace ::oox::core;
29
30
namespace oox::drawingml {
31
32
// CT_DiagramDefinition
33
DiagramDefinitionContext::DiagramDefinitionContext( SmartArtDiagram& rDgm,
34
                                                    ContextHandler2Helper const & rParent,
35
                                                    const AttributeList& rAttributes,
36
                                                    DiagramLayoutPtr pLayout )
37
268
    : ContextHandler2( rParent )
38
268
    , mpLayout(std::move( pLayout ))
39
268
    , mrDgm(rDgm)
40
268
{
41
268
    mpLayout->setDefStyle( rAttributes.getStringDefaulted( XML_defStyle ) );
42
268
    OUString sValue = rAttributes.getStringDefaulted( XML_minVer );
43
268
    if( sValue.isEmpty() )
44
268
    {
45
268
        sValue = "http://schemas.openxmlformats.org/drawingml/2006/diagram";
46
268
    }
47
268
    mpLayout->setMinVer( sValue );
48
268
    mpLayout->setUniqueId( rAttributes.getStringDefaulted( XML_uniqueId ) );
49
268
}
50
51
DiagramDefinitionContext::~DiagramDefinitionContext()
52
268
{
53
268
    LayoutNodePtr node = mpLayout->getNode();
54
268
    if (node)
55
263
        node->dump();
56
268
}
57
58
ContextHandlerRef
59
DiagramDefinitionContext::onCreateContext( ::sal_Int32 aElement,
60
                                           const AttributeList& rAttribs )
61
2.17k
{
62
2.17k
    switch( aElement )
63
2.17k
    {
64
263
    case DGM_TOKEN( title ):
65
263
        mpLayout->setTitle( rAttribs.getStringDefaulted( XML_val ) );
66
263
        break;
67
263
    case DGM_TOKEN( desc ):
68
263
        mpLayout->setDesc( rAttribs.getStringDefaulted( XML_val ) );
69
263
        break;
70
263
    case DGM_TOKEN( layoutNode ):
71
263
    {
72
263
        LayoutNodePtr pNode = std::make_shared<LayoutNode>();
73
263
        mpLayout->getNode() = pNode;
74
263
        pNode->setChildOrder( rAttribs.getToken( XML_chOrder, XML_b ) );
75
263
        pNode->setMoveWith( rAttribs.getStringDefaulted( XML_moveWith ) );
76
263
        pNode->setStyleLabel( rAttribs.getStringDefaulted( XML_styleLbl ) );
77
263
        return new LayoutNodeContext(mrDgm, *this, rAttribs, pNode );
78
0
    }
79
263
     case DGM_TOKEN( clrData ):
80
        // TODO, does not matter for the UI. skip.
81
263
        return nullptr;
82
263
    case DGM_TOKEN( sampData ):
83
263
        mpLayout->getSampData() = std::make_shared<DiagramData_oox>();
84
263
        return new DataModelContext( *this, mpLayout->getSampData() );
85
263
    case DGM_TOKEN( styleData ):
86
263
        mpLayout->getStyleData() = std::make_shared<DiagramData_oox>();
87
263
        return new DataModelContext( *this, mpLayout->getStyleData() );
88
330
    case DGM_TOKEN( cat ):
89
593
    case DGM_TOKEN( catLst ):
90
        // TODO, does not matter for the UI
91
593
    default:
92
593
        break;
93
2.17k
    }
94
95
1.11k
    return this;
96
2.17k
}
97
98
}
99
100
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */