Branch data Line data Source code
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 OOX_DRAWINGML_CHART_MODELBASE_HXX
21 : : #define OOX_DRAWINGML_CHART_MODELBASE_HXX
22 : :
23 : : #include "oox/helper/helper.hxx"
24 : : #include "oox/helper/refmap.hxx"
25 : : #include "oox/helper/refvector.hxx"
26 : :
27 : : namespace oox { class AttributeList; }
28 : :
29 : : namespace oox {
30 : : namespace drawingml {
31 : : namespace chart {
32 : :
33 : : // ============================================================================
34 : :
35 : : template< typename ModelType >
36 : 0 : class ModelRef : public ::boost::shared_ptr< ModelType >
37 : : {
38 : : public:
39 : 0 : inline explicit ModelRef() {}
40 : 0 : inline ModelRef( const ::boost::shared_ptr< ModelType >& rxModel ) : ::boost::shared_ptr< ModelType >( rxModel ) {}
41 : 0 : inline ~ModelRef() {}
42 : :
43 : 0 : inline bool is() const { return this->get() != 0; }
44 : :
45 [ # # ][ # # ]: 0 : inline ModelType& create() { this->reset( new ModelType ); return **this; }
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
46 : : template< typename Param1Type >
47 [ # # ]: 0 : inline ModelType& create( const Param1Type& rParam1 ) { this->reset( new ModelType( rParam1 ) ); return **this; }
48 : :
49 [ # # ][ # # ]: 0 : inline ModelType& getOrCreate() { if( !*this ) this->reset( new ModelType ); return **this; }
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
50 : : template< typename Param1Type >
51 : : inline ModelType& getOrCreate( const Param1Type& rParam1 ) { if( !*this ) this->reset( new ModelType( rParam1 ) ); return **this; }
52 : : };
53 : :
54 : : // ============================================================================
55 : :
56 : : template< typename ModelType >
57 : : class ModelVector : public RefVector< ModelType >
58 : : {
59 : : public:
60 : : typedef typename RefVector< ModelType >::value_type value_type;
61 : : typedef typename RefVector< ModelType >::size_type size_type;
62 : :
63 : 0 : inline explicit ModelVector() {}
64 : 0 : inline ~ModelVector() {}
65 : :
66 [ # # ][ # # ]: 0 : inline ModelType& create() { return append( new ModelType ); }
[ # # ][ # # ]
67 : : template< typename Param1Type >
68 [ # # ][ # # ]: 0 : inline ModelType& create( const Param1Type& rParam1 ) { return append( new ModelType( rParam1 ) ); }
69 : :
70 : : private:
71 [ # # ][ # # ]: 0 : inline ModelType& append( ModelType* pModel ) { this->push_back( value_type( pModel ) ); return *pModel; }
[ # # ][ # # ]
72 : : };
73 : :
74 : : // ============================================================================
75 : :
76 : : template< typename KeyType, typename ModelType >
77 : : class ModelMap : public RefMap< KeyType, ModelType >
78 : : {
79 : : public:
80 : : typedef typename RefMap< KeyType, ModelType >::key_type key_type;
81 : : typedef typename RefMap< KeyType, ModelType >::mapped_type mapped_type;
82 : : typedef typename RefMap< KeyType, ModelType >::value_type value_type;
83 : :
84 : 0 : inline explicit ModelMap() {}
85 : 0 : inline ~ModelMap() {}
86 : :
87 [ # # ][ # # ]: 0 : inline ModelType& create( KeyType eKey ) { return insert( eKey, new ModelType ); }
88 : : template< typename Param1Type >
89 : : inline ModelType& create( KeyType eKey, const Param1Type& rParam1 ) { return insert( eKey, new ModelType( rParam1 ) ); }
90 : :
91 : : private:
92 : 0 : inline ModelType& insert( KeyType eKey, ModelType* pModel ) { (*this)[ eKey ].reset( pModel ); return *pModel; }
93 : : };
94 : :
95 : : // ============================================================================
96 : :
97 : 0 : struct NumberFormat
98 : : {
99 : : ::rtl::OUString maFormatCode; /// Number format code.
100 : : bool mbSourceLinked; /// True = number format linked to source data.
101 : :
102 : : explicit NumberFormat();
103 : :
104 : : void setAttributes( const AttributeList& rAttribs );
105 : : };
106 : :
107 : : // ============================================================================
108 : :
109 : : struct LayoutModel
110 : : {
111 : : double mfX; /// Left position of this object.
112 : : double mfY; /// Top position of this object.
113 : : double mfW; /// Width of this object.
114 : : double mfH; /// Height of this object.
115 : : sal_Int32 mnXMode; /// Mode for left position.
116 : : sal_Int32 mnYMode; /// Mode for top position.
117 : : sal_Int32 mnWMode; /// Mode for width.
118 : : sal_Int32 mnHMode; /// Mode for height.
119 : : sal_Int32 mnTarget; /// Layout target for plot area.
120 : : bool mbAutoLayout; /// True = automatic positioning.
121 : :
122 : : explicit LayoutModel();
123 : : ~LayoutModel();
124 : : };
125 : :
126 : : // ============================================================================
127 : :
128 : : } // namespace chart
129 : : } // namespace drawingml
130 : : } // namespace oox
131 : :
132 : : #endif
133 : :
134 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|