1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
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::drawingml::chart
{
34 template< typename ModelType
>
35 class ModelRef
: public std::shared_ptr
< ModelType
>
39 ModelRef( const std::shared_ptr
< ModelType
>& rxModel
) : std::shared_ptr
< ModelType
>( rxModel
) {}
41 bool is() const { return this->get() != nullptr; }
43 ModelType
& create() { (*this) = std::make_shared
<ModelType
>(); return **this; }
44 template< typename Param1Type
>
45 ModelType
& create( const Param1Type
& rParam1
) { (*this) = std::make_shared
<ModelType
>( rParam1
); return **this; }
46 template< typename Param1Type
, typename Param2Type
>
47 ModelType
& create( const Param1Type
& rParam1
, const Param2Type
& rParam2
) { (*this) = std::make_shared
<ModelType
>( rParam1
, rParam2
); return **this; }
49 ModelType
& getOrCreate() { if( !*this ) (*this) = std::make_shared
<ModelType
>(); return **this; }
50 template< typename Param1Type
>
51 ModelType
& getOrCreate( const Param1Type
& rParam1
) { if( !*this ) (*this) = std::make_shared
<ModelType
>( rParam1
); return **this; }
54 template< typename ModelType
>
55 class ModelVector
: public RefVector
< ModelType
>
58 typedef typename RefVector
< ModelType
>::value_type value_type
;
59 typedef typename RefVector
< ModelType
>::size_type size_type
;
61 ModelType
& create() { return append( std::make_shared
<ModelType
>() ); }
62 template< typename Param1Type
>
63 ModelType
& create( const Param1Type
& rParam1
) { return append( std::make_shared
<ModelType
>( rParam1
) ); }
64 template< typename Param1Type
, typename Param2Type
>
65 ModelType
& create( const Param1Type
& rParam1
, const Param2Type
& rParam2
) { return append( std::make_shared
<ModelType
>( rParam1
, rParam2
) ); }
68 ModelType
& append( std::shared_ptr
<ModelType
> pModel
)
71 auto pTmp
= pModel
.get();
72 this->push_back( std::move(pModel
) );
77 template< typename KeyType
, typename ModelType
>
78 class ModelMap
: public RefMap
< KeyType
, ModelType
>
81 typedef typename RefMap
< KeyType
, ModelType
>::key_type key_type
;
82 typedef typename RefMap
< KeyType
, ModelType
>::mapped_type mapped_type
;
83 typedef typename RefMap
< KeyType
, ModelType
>::value_type value_type
;
85 ModelType
& create( KeyType eKey
) { return insert( eKey
, new ModelType
); }
88 ModelType
& insert( KeyType eKey
, ModelType
* pModel
) { (*this)[ eKey
].reset( pModel
); return *pModel
; }
93 OUString maFormatCode
; /// Number format code.
94 bool mbSourceLinked
; /// True = number format linked to source data.
98 void setAttributes( const AttributeList
& rAttribs
);
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.
117 } // namespace oox::drawingml::chart
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */