LibreOffice Module oox (master) 1
diagramdefinitioncontext.cxx
Go to the documentation of this file.
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
21#include "datamodel.hxx"
22#include "datamodelcontext.hxx"
23#include "layoutnodecontext.hxx"
25#include <oox/token/namespaces.hxx>
26#include <utility>
27
28using namespace ::oox::core;
29using namespace ::com::sun::star::uno;
30using namespace ::com::sun::star::xml::sax;
31
32namespace oox::drawingml {
33
34// CT_DiagramDefinition
35DiagramDefinitionContext::DiagramDefinitionContext( ContextHandler2Helper const & rParent,
36 const AttributeList& rAttributes,
37 DiagramLayoutPtr pLayout )
38 : ContextHandler2( rParent )
39 , mpLayout(std::move( pLayout ))
40{
41 mpLayout->setDefStyle( rAttributes.getStringDefaulted( XML_defStyle ) );
42 OUString sValue = rAttributes.getStringDefaulted( XML_minVer );
43 if( sValue.isEmpty() )
44 {
45 sValue = "http://schemas.openxmlformats.org/drawingml/2006/diagram";
46 }
47 mpLayout->setMinVer( sValue );
48 mpLayout->setUniqueId( rAttributes.getStringDefaulted( XML_uniqueId ) );
49}
50
52{
53 LayoutNodePtr node = mpLayout->getNode();
54 if (node)
55 node->dump();
56}
57
60 const AttributeList& rAttribs )
61{
62 switch( aElement )
63 {
64 case DGM_TOKEN( title ):
65 mpLayout->setTitle( rAttribs.getStringDefaulted( XML_val ) );
66 break;
67 case DGM_TOKEN( desc ):
68 mpLayout->setDesc( rAttribs.getStringDefaulted( XML_val ) );
69 break;
70 case DGM_TOKEN( layoutNode ):
71 {
72 LayoutNodePtr pNode = std::make_shared<LayoutNode>(mpLayout->getDiagram());
73 mpLayout->getNode() = pNode;
74 pNode->setChildOrder( rAttribs.getToken( XML_chOrder, XML_b ) );
75 pNode->setMoveWith( rAttribs.getStringDefaulted( XML_moveWith ) );
76 pNode->setStyleLabel( rAttribs.getStringDefaulted( XML_styleLbl ) );
77 return new LayoutNodeContext( *this, rAttribs, pNode );
78 }
79 case DGM_TOKEN( clrData ):
80 // TODO, does not matter for the UI. skip.
81 return nullptr;
82 case DGM_TOKEN( sampData ):
83 mpLayout->getSampData() = std::make_shared<DiagramData>();
84 return new DataModelContext( *this, mpLayout->getSampData() );
85 case DGM_TOKEN( styleData ):
86 mpLayout->getStyleData() = std::make_shared<DiagramData>();
87 return new DataModelContext( *this, mpLayout->getStyleData() );
88 case DGM_TOKEN( cat ):
89 case DGM_TOKEN( catLst ):
90 // TODO, does not matter for the UI
91 default:
92 break;
93 }
94
95 return this;
96}
97
98}
99
100/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Provides access to attribute values of an element.
OUString getStringDefaulted(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute, returns an empty string if attribute not present...
std::optional< sal_Int32 > getToken(sal_Int32 nAttrToken) const
Returns the token identifier of the value of the specified attribute.
DiagramDefinitionContext(::oox::core::ContextHandler2Helper const &rParent, const ::oox::AttributeList &rAttributes, DiagramLayoutPtr pLayout)
virtual ::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
std::shared_ptr< LayoutNode > LayoutNodePtr
std::shared_ptr< DiagramLayout > DiagramLayoutPtr