Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / oox / drawingml / chart / modelbase.hxx
blob312d3e35e2bfd08fdb1ee81a8c4433731b732c77
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_DRAWINGML_CHART_MODELBASE_HXX
21 #define INCLUDED_OOX_DRAWINGML_CHART_MODELBASE_HXX
23 #include <memory>
25 #include <oox/helper/refmap.hxx>
26 #include <oox/helper/refvector.hxx>
27 #include <rtl/ustring.hxx>
28 #include <sal/types.h>
30 namespace oox { class AttributeList; }
32 namespace oox {
33 namespace drawingml {
34 namespace chart {
36 template< typename ModelType >
37 class ModelRef : public std::shared_ptr< ModelType >
39 public:
40 ModelRef() {}
41 ModelRef( const std::shared_ptr< ModelType >& rxModel ) : std::shared_ptr< ModelType >( rxModel ) {}
43 bool is() const { return this->get() != 0; }
45 ModelType& create() { this->reset( new ModelType ); return **this; }
46 template< typename Param1Type >
47 ModelType& create( const Param1Type& rParam1 ) { this->reset( new ModelType( rParam1 ) ); return **this; }
48 template< typename Param1Type, typename Param2Type >
49 ModelType& create( const Param1Type& rParam1, const Param2Type& rParam2 ) { this->reset( new ModelType( rParam1, rParam2 ) ); return **this; }
51 ModelType& getOrCreate() { if( !*this ) this->reset( new ModelType ); return **this; }
52 template< typename Param1Type >
53 ModelType& getOrCreate( const Param1Type& rParam1 ) { if( !*this ) this->reset( new ModelType( rParam1 ) ); return **this; }
56 template< typename ModelType >
57 class ModelVector : public RefVector< ModelType >
59 public:
60 typedef typename RefVector< ModelType >::value_type value_type;
61 typedef typename RefVector< ModelType >::size_type size_type;
63 ModelVector() {}
65 ModelType& create() { return append( new ModelType ); }
66 template< typename Param1Type >
67 ModelType& create( const Param1Type& rParam1 ) { return append( new ModelType( rParam1 ) ); }
68 template< typename Param1Type, typename Param2Type >
69 ModelType& create( const Param1Type& rParam1, const Param2Type& rParam2 ) { return append( new ModelType( rParam1, rParam2 ) ); }
71 private:
72 ModelType& append( ModelType* pModel ) { this->push_back( value_type( pModel ) ); return *pModel; }
75 template< typename KeyType, typename ModelType >
76 class ModelMap : public RefMap< KeyType, ModelType >
78 public:
79 typedef typename RefMap< KeyType, ModelType >::key_type key_type;
80 typedef typename RefMap< KeyType, ModelType >::mapped_type mapped_type;
81 typedef typename RefMap< KeyType, ModelType >::value_type value_type;
83 ModelMap() {}
85 ModelType& create( KeyType eKey ) { return insert( eKey, new ModelType ); }
87 private:
88 ModelType& insert( KeyType eKey, ModelType* pModel ) { (*this)[ eKey ].reset( pModel ); return *pModel; }
91 struct NumberFormat
93 OUString maFormatCode; /// Number format code.
94 bool mbSourceLinked; /// True = number format linked to source data.
96 NumberFormat();
98 void setAttributes( const AttributeList& rAttribs );
101 struct LayoutModel
103 double mfX; /// Left position of this object.
104 double mfY; /// Top position of this object.
105 double mfW; /// Width of this object.
106 double mfH; /// Height of this object.
107 sal_Int32 mnXMode; /// Mode for left position.
108 sal_Int32 mnYMode; /// Mode for top position.
109 sal_Int32 mnWMode; /// Mode for width.
110 sal_Int32 mnHMode; /// Mode for height.
111 sal_Int32 mnTarget; /// Layout target for plot area.
112 bool mbAutoLayout; /// True = automatic positioning.
114 LayoutModel();
115 ~LayoutModel();
118 } // namespace chart
119 } // namespace drawingml
120 } // namespace oox
122 #endif
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */