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 
27 using namespace ::oox::core;
28 using namespace ::com::sun::star::uno;
29 using namespace ::com::sun::star::xml::sax;
30 
31 namespace 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.getString( XML_defStyle ).get() );
41  OUString sValue = rAttributes.getString( XML_minVer ).get();
42  if( sValue.isEmpty() )
43  {
44  sValue = "http://schemas.openxmlformats.org/drawingml/2006/diagram";
45  }
46  mpLayout->setMinVer( sValue );
47  mpLayout->setUniqueId( rAttributes.getString( XML_uniqueId ).get() );
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.getString( XML_val ).get() );
65  break;
66  case DGM_TOKEN( desc ):
67  mpLayout->setDesc( rAttribs.getString( XML_val ).get() );
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.getString( XML_moveWith ).get() );
75  pNode->setStyleLabel( rAttribs.getString( XML_styleLbl ).get() );
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: */
OptValue< OUString > getString(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute.
const Type & get() const
Definition: helper.hxx:185
std::shared_ptr< DiagramLayout > DiagramLayoutPtr
Provides access to attribute values of an element.
std::shared_ptr< LayoutNode > LayoutNodePtr
virtual ::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
Helper class that provides a context stack.
DiagramDefinitionContext(::oox::core::ContextHandler2Helper const &rParent, const ::oox::AttributeList &rAttributes, const DiagramLayoutPtr &pLayout)
OptValue< sal_Int32 > getToken(sal_Int32 nAttrToken) const
Returns the token identifier of the value of the specified attribute.