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 #ifndef INCLUDED_OOX_SOURCE_DRAWINGML_DIAGRAM_DIAGRAM_HXX
21 #define INCLUDED_OOX_SOURCE_DRAWINGML_DIAGRAM_DIAGRAM_HXX
22 
23 #include <map>
24 #include <memory>
25 #include <vector>
26 
27 #include <rtl/ustring.hxx>
28 
29 #include "datamodel.hxx"
30 #include <oox/drawingml/shape.hxx>
31 
32 namespace com::sun::star {
33     namespace xml::dom { class XDocument; }
34 }
35 
36 namespace oox::drawingml {
37 
38 class Diagram;
39 class LayoutNode;
40 typedef std::shared_ptr< LayoutNode > LayoutNodePtr;
41 class LayoutAtom;
42 typedef std::shared_ptr<LayoutAtom> LayoutAtomPtr;
43 
44 typedef std::map< OUString, css::uno::Reference<css::xml::dom::XDocument> > DiagramDomMap;
45 
46 typedef std::map<OUString, LayoutAtomPtr> LayoutAtomMap;
47 typedef std::map<const dgm::Point*, ShapePtr> PresPointShapeMap;
48 
49 class DiagramLayout
50 {
51 public:
DiagramLayout(Diagram & rDgm)52     DiagramLayout(Diagram& rDgm)
53         : mrDgm(rDgm)
54     {
55     }
setDefStyle(const OUString & sDefStyle)56     void setDefStyle( const OUString & sDefStyle )
57         { msDefStyle = sDefStyle; }
setMinVer(const OUString & sMinVer)58     void setMinVer( const OUString & sMinVer )
59         { msMinVer = sMinVer; }
setUniqueId(const OUString & sUniqueId)60     void setUniqueId( const OUString & sUniqueId )
61         { msUniqueId = sUniqueId; }
setTitle(const OUString & sTitle)62     void setTitle( const OUString & sTitle )
63         { msTitle = sTitle; }
setDesc(const OUString & sDesc)64     void setDesc( const OUString & sDesc )
65         { msDesc = sDesc; }
getDiagram()66     Diagram& getDiagram() { return mrDgm; }
getNode()67     LayoutNodePtr & getNode()
68         { return mpNode; }
getNode() const69     const LayoutNodePtr & getNode() const
70         { return mpNode; }
getSampData()71     DiagramDataPtr & getSampData()
72         { return mpSampData; }
getSampData() const73     const DiagramDataPtr & getSampData() const
74         { return mpSampData; }
getStyleData()75     DiagramDataPtr & getStyleData()
76         { return mpStyleData; }
getStyleData() const77     const DiagramDataPtr & getStyleData() const
78         { return mpStyleData; }
getLayoutAtomMap()79     LayoutAtomMap & getLayoutAtomMap()
80         { return maLayoutAtomMap; }
getPresPointShapeMap()81     PresPointShapeMap & getPresPointShapeMap()
82         { return maPresPointShapeMap; }
83 
84 private:
85     Diagram& mrDgm;
86     OUString msDefStyle;
87     OUString msMinVer;
88     OUString msUniqueId;
89 
90     OUString msTitle;
91     OUString msDesc;
92     LayoutNodePtr  mpNode;
93     DiagramDataPtr mpSampData;
94     DiagramDataPtr mpStyleData;
95     // TODO
96     // catLst
97     // clrData
98 
99     LayoutAtomMap maLayoutAtomMap;
100     PresPointShapeMap maPresPointShapeMap;
101 };
102 
103 typedef std::shared_ptr< DiagramLayout > DiagramLayoutPtr;
104 
105 struct DiagramStyle
106 {
107     ShapeStyleRef maFillStyle;
108     ShapeStyleRef maLineStyle;
109     ShapeStyleRef maEffectStyle;
110     ShapeStyleRef maTextStyle;
111 };
112 
113 typedef std::map<OUString,DiagramStyle> DiagramQStyleMap;
114 
115 struct DiagramColor
116 {
117     std::vector<oox::drawingml::Color> maFillColors;
118     std::vector<oox::drawingml::Color> maLineColors;
119     std::vector<oox::drawingml::Color> maEffectColors;
120     std::vector<oox::drawingml::Color> maTextFillColors;
121     std::vector<oox::drawingml::Color> maTextLineColors;
122     std::vector<oox::drawingml::Color> maTextEffectColors;
123 
124     static const oox::drawingml::Color&
125     getColorByIndex(const std::vector<oox::drawingml::Color>& rColors, sal_Int32 nIndex);
126 };
127 
128 typedef std::map<OUString,DiagramColor> DiagramColorMap;
129 
130 class Diagram
131 {
132 public:
133     explicit Diagram(const ShapePtr& pShape);
setData(const DiagramDataPtr & pData)134     void setData( const DiagramDataPtr & pData )
135         { mpData = pData; }
getData() const136     const DiagramDataPtr& getData() const
137         { return mpData; }
setLayout(const DiagramLayoutPtr & pLayout)138     void setLayout( const DiagramLayoutPtr & pLayout )
139         { mpLayout = pLayout; }
getLayout() const140     const DiagramLayoutPtr& getLayout() const
141         { return mpLayout; }
142 
getStyles()143     DiagramQStyleMap& getStyles() { return maStyles; }
getStyles() const144     const DiagramQStyleMap& getStyles() const { return maStyles; }
getColors()145     DiagramColorMap& getColors() { return maColors; }
getColors() const146     const DiagramColorMap& getColors() const { return maColors; }
getDomMap()147     DiagramDomMap & getDomMap() { return maMainDomMap; }
getDataRelsMap()148     css::uno::Sequence< css::uno::Sequence< css::uno::Any > > & getDataRelsMap() { return maDataRelsMap; }
149     void addTo( const ShapePtr & pShape );
150 
151     css::uno::Sequence<css::beans::PropertyValue> getDomsAsPropertyValues() const;
getShape() const152     const ShapePtr & getShape() const { return mpShape; }
153 
154 private:
155     ShapePtr mpShape;
156     DiagramDataPtr                 mpData;
157     DiagramLayoutPtr               mpLayout;
158     DiagramQStyleMap               maStyles;
159     DiagramColorMap                maColors;
160     DiagramDomMap                  maMainDomMap;
161     css::uno::Sequence< css::uno::Sequence< css::uno::Any > > maDataRelsMap;
162 };
163 
164 typedef std::shared_ptr< Diagram > DiagramPtr;
165 
166 }
167 
168 #endif
169 
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
171