LibreOffice Module oox (master) 1
modelbase.hxx
Go to the documentation of this file.
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 <memory>
24
25#include <oox/helper/refmap.hxx>
27#include <rtl/ustring.hxx>
28#include <sal/types.h>
29
30namespace oox { class AttributeList; }
31
32namespace oox::drawingml::chart {
33
34template< typename ModelType >
35class ModelRef : public std::shared_ptr< ModelType >
36{
37public:
39 ModelRef( const std::shared_ptr< ModelType >& rxModel ) : std::shared_ptr< ModelType >( rxModel ) {}
40
41 bool is() const { return this->get() != nullptr; }
42
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; }
48
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; }
52};
53
54template< typename ModelType >
55class ModelVector : public RefVector< ModelType >
56{
57public:
60
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 ) ); }
66
67private:
68 ModelType& append( std::shared_ptr<ModelType> pModel )
69 {
70 assert(pModel);
71 auto pTmp = pModel.get();
72 this->push_back( std::move(pModel) );
73 return *pTmp;
74 }
75};
76
77template< typename KeyType, typename ModelType >
78class ModelMap : public RefMap< KeyType, ModelType >
79{
80public:
84
85 ModelType& create( KeyType eKey ) { return insert( eKey, new ModelType ); }
86
87private:
88 ModelType& insert( KeyType eKey, ModelType* pModel ) { (*this)[ eKey ].reset( pModel ); return *pModel; }
89};
90
92{
93 OUString maFormatCode;
95
97
98 void setAttributes( const AttributeList& rAttribs );
99};
100
102{
103 double mfX;
104 double mfY;
105 double mfW;
106 double mfH;
107 sal_Int32 mnXMode;
108 sal_Int32 mnYMode;
109 sal_Int32 mnWMode;
110 sal_Int32 mnHMode;
111 sal_Int32 mnTarget;
113
114 LayoutModel();
115};
116
117} // namespace oox::drawingml::chart
118
119#endif
120
121/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Provides access to attribute values of an element.
Template for a map of ref-counted objects with additional accessor functions.
Definition: refmap.hxx:41
Template for a vector of ref-counted objects with additional accessor functions.
Definition: refvector.hxx:43
ModelType & insert(KeyType eKey, ModelType *pModel)
Definition: modelbase.hxx:88
RefMap< KeyType, ModelType >::mapped_type mapped_type
Definition: modelbase.hxx:82
ModelType & create(KeyType eKey)
Definition: modelbase.hxx:85
RefMap< KeyType, ModelType >::value_type value_type
Definition: modelbase.hxx:83
RefMap< KeyType, ModelType >::key_type key_type
Definition: modelbase.hxx:81
ModelType & create(const Param1Type &rParam1)
Definition: modelbase.hxx:45
ModelType & getOrCreate(const Param1Type &rParam1)
Definition: modelbase.hxx:51
ModelType & create(const Param1Type &rParam1, const Param2Type &rParam2)
Definition: modelbase.hxx:47
ModelRef(const std::shared_ptr< ModelType > &rxModel)
Definition: modelbase.hxx:39
RefVector< ModelType >::size_type size_type
Definition: modelbase.hxx:59
RefVector< ModelType >::value_type value_type
Definition: modelbase.hxx:58
ModelType & append(std::shared_ptr< ModelType > pModel)
Definition: modelbase.hxx:68
ModelType & create(const Param1Type &rParam1, const Param2Type &rParam2)
Definition: modelbase.hxx:65
ModelType & create(const Param1Type &rParam1)
Definition: modelbase.hxx:63
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
sal_Int32 mnXMode
Height of this object.
Definition: modelbase.hxx:107
double mfW
Top position of this object.
Definition: modelbase.hxx:105
LayoutModel()
True = automatic positioning.
Definition: modelbase.cxx:38
sal_Int32 mnTarget
Mode for height.
Definition: modelbase.hxx:111
sal_Int32 mnYMode
Mode for left position.
Definition: modelbase.hxx:108
double mfY
Left position of this object.
Definition: modelbase.hxx:104
sal_Int32 mnHMode
Mode for width.
Definition: modelbase.hxx:110
sal_Int32 mnWMode
Mode for top position.
Definition: modelbase.hxx:109
bool mbAutoLayout
Layout target for plot area.
Definition: modelbase.hxx:112
double mfH
Width of this object.
Definition: modelbase.hxx:106
bool mbSourceLinked
Number format code.
Definition: modelbase.hxx:94
void setAttributes(const AttributeList &rAttribs)
Definition: modelbase.cxx:32
NumberFormat()
True = number format linked to source data.
Definition: modelbase.cxx:27