use insert function instead of for loop
[LibreOffice.git] / oox / source / drawingml / diagram / diagram.hxx
blob5eb82069b91bcd536bfddad4ad319f5e20ec44ed
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_OOX_SOURCE_DRAWINGML_DIAGRAM_DIAGRAM_HXX
21 #define INCLUDED_OOX_SOURCE_DRAWINGML_DIAGRAM_DIAGRAM_HXX
23 #include <map>
24 #include <memory>
25 #include <vector>
27 #include <rtl/ustring.hxx>
29 #include "datamodel.hxx"
30 #include <oox/drawingml/shape.hxx>
32 namespace com::sun::star {
33 namespace xml::dom { class XDocument; }
36 namespace oox::drawingml {
38 class Diagram;
39 class LayoutNode;
40 typedef std::shared_ptr< LayoutNode > LayoutNodePtr;
41 class LayoutAtom;
42 typedef std::shared_ptr< LayoutAtom > LayoutAtomPtr;
43 typedef std::map< OUString, css::uno::Reference<css::xml::dom::XDocument> > DiagramDomMap;
44 typedef std::map< OUString, LayoutAtomPtr > LayoutAtomMap;
45 typedef std::map< const svx::diagram::Point*, ShapePtr > PresPointShapeMap;
47 class DiagramLayout
49 public:
50 DiagramLayout(Diagram& rDgm)
51 : mrDgm(rDgm)
54 void setDefStyle( const OUString & sDefStyle )
55 { msDefStyle = sDefStyle; }
56 void setMinVer( const OUString & sMinVer )
57 { msMinVer = sMinVer; }
58 void setUniqueId( const OUString & sUniqueId )
59 { msUniqueId = sUniqueId; }
60 void setTitle( const OUString & sTitle )
61 { msTitle = sTitle; }
62 void setDesc( const OUString & sDesc )
63 { msDesc = sDesc; }
64 Diagram& getDiagram() { return mrDgm; }
65 LayoutNodePtr & getNode()
66 { return mpNode; }
67 const LayoutNodePtr & getNode() const
68 { return mpNode; }
69 OoxDiagramDataPtr& getSampData()
70 { return mpSampData; }
71 const OoxDiagramDataPtr& getSampData() const
72 { return mpSampData; }
73 OoxDiagramDataPtr& getStyleData()
74 { return mpStyleData; }
75 const OoxDiagramDataPtr& getStyleData() const
76 { return mpStyleData; }
77 LayoutAtomMap & getLayoutAtomMap()
78 { return maLayoutAtomMap; }
79 PresPointShapeMap & getPresPointShapeMap()
80 { return maPresPointShapeMap; }
82 private:
83 Diagram& mrDgm;
84 OUString msDefStyle;
85 OUString msMinVer;
86 OUString msUniqueId;
88 OUString msTitle;
89 OUString msDesc;
90 LayoutNodePtr mpNode;
91 OoxDiagramDataPtr mpSampData;
92 OoxDiagramDataPtr mpStyleData;
93 // TODO
94 // catLst
95 // clrData
97 LayoutAtomMap maLayoutAtomMap;
98 PresPointShapeMap maPresPointShapeMap;
101 typedef std::shared_ptr< DiagramLayout > DiagramLayoutPtr;
103 struct DiagramStyle
105 ShapeStyleRef maFillStyle;
106 ShapeStyleRef maLineStyle;
107 ShapeStyleRef maEffectStyle;
108 ShapeStyleRef maTextStyle;
111 typedef std::map<OUString,DiagramStyle> DiagramQStyleMap;
113 struct DiagramColor
115 std::vector<oox::drawingml::Color> maFillColors;
116 std::vector<oox::drawingml::Color> maLineColors;
117 std::vector<oox::drawingml::Color> maEffectColors;
118 std::vector<oox::drawingml::Color> maTextFillColors;
119 std::vector<oox::drawingml::Color> maTextLineColors;
120 std::vector<oox::drawingml::Color> maTextEffectColors;
122 static const oox::drawingml::Color&
123 getColorByIndex(const std::vector<oox::drawingml::Color>& rColors, sal_Int32 nIndex);
126 typedef std::map<OUString,DiagramColor> DiagramColorMap;
128 class Diagram
130 public:
131 explicit Diagram();
132 void setData( OoxDiagramDataPtr& pData )
133 { mpData = pData; }
134 const OoxDiagramDataPtr& getData() const
135 { return mpData; }
136 void setLayout( const DiagramLayoutPtr & pLayout )
137 { mpLayout = pLayout; }
138 const DiagramLayoutPtr& getLayout() const
139 { return mpLayout; }
141 DiagramQStyleMap& getStyles() { return maStyles; }
142 const DiagramQStyleMap& getStyles() const { return maStyles; }
143 DiagramColorMap& getColors() { return maColors; }
144 const DiagramColorMap& getColors() const { return maColors; }
145 DiagramDomMap & getDomMap() { return maMainDomMap; }
146 css::uno::Sequence< css::uno::Sequence< css::uno::Any > > & getDataRelsMap() { return maDataRelsMap; }
147 void addTo( const ShapePtr & pShape, bool bCreate );
149 css::uno::Sequence<css::beans::PropertyValue> getDomsAsPropertyValues() const;
150 oox::core::NamedShapePairs& getDiagramFontHeights() { return maDiagramFontHeights; }
151 void syncDiagramFontHeights();
153 private:
154 // This contains groups of shapes: automatic font size is the same in each group.
155 oox::core::NamedShapePairs maDiagramFontHeights;
157 OoxDiagramDataPtr mpData;
158 DiagramLayoutPtr mpLayout;
159 DiagramQStyleMap maStyles;
160 DiagramColorMap maColors;
161 DiagramDomMap maMainDomMap;
162 css::uno::Sequence< css::uno::Sequence< css::uno::Any > > maDataRelsMap;
165 typedef std::shared_ptr< Diagram > DiagramPtr;
169 #endif
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */