Coverage Report

Created: 2025-11-16 09:57

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.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( ContextHandler2Helper const & rParent,
34
                                                    const AttributeList& rAttributes,
35
                                                    DiagramLayoutPtr pLayout )
36
238
    : ContextHandler2( rParent )
37
238
    , mpLayout(std::move( pLayout ))
38
238
{
39
238
    mpLayout->setDefStyle( rAttributes.getStringDefaulted( XML_defStyle ) );
40
238
    OUString sValue = rAttributes.getStringDefaulted( XML_minVer );
41
238
    if( sValue.isEmpty() )
42
238
    {
43
238
        sValue = "http://schemas.openxmlformats.org/drawingml/2006/diagram";
44
238
    }
45
238
    mpLayout->setMinVer( sValue );
46
238
    mpLayout->setUniqueId( rAttributes.getStringDefaulted( XML_uniqueId ) );
47
238
}
48
49
DiagramDefinitionContext::~DiagramDefinitionContext()
50
238
{
51
238
    LayoutNodePtr node = mpLayout->getNode();
52
238
    if (node)
53
234
        node->dump();
54
238
}
55
56
ContextHandlerRef
57
DiagramDefinitionContext::onCreateContext( ::sal_Int32 aElement,
58
                                           const AttributeList& rAttribs )
59
1.94k
{
60
1.94k
    switch( aElement )
61
1.94k
    {
62
234
    case DGM_TOKEN( title ):
63
234
        mpLayout->setTitle( rAttribs.getStringDefaulted( XML_val ) );
64
234
        break;
65
234
    case DGM_TOKEN( desc ):
66
234
        mpLayout->setDesc( rAttribs.getStringDefaulted( XML_val ) );
67
234
        break;
68
234
    case DGM_TOKEN( layoutNode ):
69
234
    {
70
234
        LayoutNodePtr pNode = std::make_shared<LayoutNode>(mpLayout->getDiagram());
71
234
        mpLayout->getNode() = pNode;
72
234
        pNode->setChildOrder( rAttribs.getToken( XML_chOrder, XML_b ) );
73
234
        pNode->setMoveWith( rAttribs.getStringDefaulted( XML_moveWith ) );
74
234
        pNode->setStyleLabel( rAttribs.getStringDefaulted( XML_styleLbl ) );
75
234
        return new LayoutNodeContext( *this, rAttribs, pNode );
76
0
    }
77
234
     case DGM_TOKEN( clrData ):
78
        // TODO, does not matter for the UI. skip.
79
234
        return nullptr;
80
234
    case DGM_TOKEN( sampData ):
81
234
        mpLayout->getSampData() = std::make_shared<DiagramData>();
82
234
        return new DataModelContext( *this, mpLayout->getSampData() );
83
234
    case DGM_TOKEN( styleData ):
84
234
        mpLayout->getStyleData() = std::make_shared<DiagramData>();
85
234
        return new DataModelContext( *this, mpLayout->getStyleData() );
86
311
    case DGM_TOKEN( cat ):
87
545
    case DGM_TOKEN( catLst ):
88
        // TODO, does not matter for the UI
89
545
    default:
90
545
        break;
91
1.94k
    }
92
93
1.01k
    return this;
94
1.94k
}
95
96
}
97
98
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */