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
27using namespace ::oox::core;
28using namespace ::com::sun::star::uno;
29using namespace ::com::sun::star::xml::sax;
30
31namespace oox::drawingml {
32
33// CT_DiagramDefinition
35 const AttributeList& rAttributes,
36 const DiagramLayoutPtr &pLayout )
37 : ContextHandler2( rParent )
38 , mpLayout( pLayout )
39{
40 mpLayout->setDefStyle( rAttributes.getStringDefaulted( XML_defStyle ) );
41 OUString sValue = rAttributes.getStringDefaulted( XML_minVer );
42 if( sValue.isEmpty() )
43 {
44 sValue = "http://schemas.openxmlformats.org/drawingml/2006/diagram";
45 }
46 mpLayout->setMinVer( sValue );
47 mpLayout->setUniqueId( rAttributes.getStringDefaulted( XML_uniqueId ) );
48}
49
51{
52 LayoutNodePtr node = mpLayout->getNode();
53 if (node)
54 node->dump();
55}
56
59 const AttributeList& rAttribs )
60{
61 switch( aElement )
62 {
63 case DGM_TOKEN( title ):
64 mpLayout->setTitle( rAttribs.getStringDefaulted( XML_val ) );
65 break;
66 case DGM_TOKEN( desc ):
67 mpLayout->setDesc( rAttribs.getStringDefaulted( XML_val ) );
68 break;
69 case DGM_TOKEN( layoutNode ):
70 {
71 LayoutNodePtr pNode = std::make_shared<LayoutNode>(mpLayout->getDiagram());
72 mpLayout->getNode() = pNode;
73 pNode->setChildOrder( rAttribs.getToken( XML_chOrder, XML_b ) );
74 pNode->setMoveWith( rAttribs.getStringDefaulted( XML_moveWith ) );
75 pNode->setStyleLabel( rAttribs.getStringDefaulted( XML_styleLbl ) );
76 return new LayoutNodeContext( *this, rAttribs, pNode );
77 }
78 case DGM_TOKEN( clrData ):
79 // TODO, does not matter for the UI. skip.
80 return nullptr;
81 case DGM_TOKEN( sampData ):
82 mpLayout->getSampData() = std::make_shared<DiagramData>();
83 return new DataModelContext( *this, mpLayout->getSampData() );
84 case DGM_TOKEN( styleData ):
85 mpLayout->getStyleData() = std::make_shared<DiagramData>();
86 return new DataModelContext( *this, mpLayout->getStyleData() );
87 case DGM_TOKEN( cat ):
88 case DGM_TOKEN( catLst ):
89 // TODO, does not matter for the UI
90 default:
91 break;
92 }
93
94 return this;
95}
96
97}
98
99/* 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.
Helper class that provides a context stack.
virtual ::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
DiagramDefinitionContext(::oox::core::ContextHandler2Helper const &rParent, const ::oox::AttributeList &rAttributes, const DiagramLayoutPtr &pLayout)
std::shared_ptr< LayoutNode > LayoutNodePtr
std::shared_ptr< DiagramLayout > DiagramLayoutPtr