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