1e3508121SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3e3508121SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4e3508121SAndrew Rist * or more contributor license agreements. See the NOTICE file 5e3508121SAndrew Rist * distributed with this work for additional information 6e3508121SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7e3508121SAndrew Rist * to you under the Apache License, Version 2.0 (the 8e3508121SAndrew Rist * "License"); you may not use this file except in compliance 9e3508121SAndrew Rist * with the License. You may obtain a copy of the License at 10e3508121SAndrew Rist * 11e3508121SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12e3508121SAndrew Rist * 13e3508121SAndrew Rist * Unless required by applicable law or agreed to in writing, 14e3508121SAndrew Rist * software distributed under the License is distributed on an 15e3508121SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16e3508121SAndrew Rist * KIND, either express or implied. See the License for the 17e3508121SAndrew Rist * specific language governing permissions and limitations 18e3508121SAndrew Rist * under the License. 19e3508121SAndrew Rist * 20e3508121SAndrew Rist *************************************************************/ 21e3508121SAndrew Rist 22e3508121SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef OOX_DRAWINGML_CHART_MODELBASE_HXX 25cdf0e10cSrcweir #define OOX_DRAWINGML_CHART_MODELBASE_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "oox/helper/helper.hxx" 28cdf0e10cSrcweir #include "oox/helper/refmap.hxx" 29cdf0e10cSrcweir #include "oox/helper/refvector.hxx" 30cdf0e10cSrcweir 31cdf0e10cSrcweir namespace oox { class AttributeList; } 32cdf0e10cSrcweir 33cdf0e10cSrcweir namespace oox { 34cdf0e10cSrcweir namespace drawingml { 35cdf0e10cSrcweir namespace chart { 36cdf0e10cSrcweir 37cdf0e10cSrcweir // ============================================================================ 38cdf0e10cSrcweir 39cdf0e10cSrcweir template< typename ModelType > 40cdf0e10cSrcweir class ModelRef : public ::boost::shared_ptr< ModelType > 41cdf0e10cSrcweir { 42cdf0e10cSrcweir public: ModelRef()43cdf0e10cSrcweir inline explicit ModelRef() {} ModelRef(const::boost::shared_ptr<ModelType> & rxModel)44cdf0e10cSrcweir inline ModelRef( const ::boost::shared_ptr< ModelType >& rxModel ) : ::boost::shared_ptr< ModelType >( rxModel ) {} ~ModelRef()45cdf0e10cSrcweir inline ~ModelRef() {} 46cdf0e10cSrcweir is() const47cdf0e10cSrcweir inline bool is() const { return this->get() != 0; } 48cdf0e10cSrcweir create()49*7ee1d29cSAriel Constenla-Haile inline ModelType& create() { this->reset( new ModelType ); return **this; } 50cdf0e10cSrcweir template< typename Param1Type > create(const Param1Type & rParam1)51*7ee1d29cSAriel Constenla-Haile inline ModelType& create( const Param1Type& rParam1 ) { this->reset( new ModelType( rParam1 ) ); return **this; } 52cdf0e10cSrcweir getOrCreate()53*7ee1d29cSAriel Constenla-Haile inline ModelType& getOrCreate() { if( !*this ) this->reset( new ModelType ); return **this; } 54cdf0e10cSrcweir template< typename Param1Type > getOrCreate(const Param1Type & rParam1)55*7ee1d29cSAriel Constenla-Haile inline ModelType& getOrCreate( const Param1Type& rParam1 ) { if( !*this ) this->reset( new ModelType( rParam1 ) ); return **this; } 56cdf0e10cSrcweir }; 57cdf0e10cSrcweir 58cdf0e10cSrcweir // ============================================================================ 59cdf0e10cSrcweir 60cdf0e10cSrcweir template< typename ModelType > 61cdf0e10cSrcweir class ModelVector : public RefVector< ModelType > 62cdf0e10cSrcweir { 63cdf0e10cSrcweir public: 64cdf0e10cSrcweir typedef typename RefVector< ModelType >::value_type value_type; 65cdf0e10cSrcweir typedef typename RefVector< ModelType >::size_type size_type; 66cdf0e10cSrcweir ModelVector()67cdf0e10cSrcweir inline explicit ModelVector() {} ~ModelVector()68cdf0e10cSrcweir inline ~ModelVector() {} 69cdf0e10cSrcweir create()70cdf0e10cSrcweir inline ModelType& create() { return append( new ModelType ); } 71cdf0e10cSrcweir template< typename Param1Type > create(const Param1Type & rParam1)72cdf0e10cSrcweir inline ModelType& create( const Param1Type& rParam1 ) { return append( new ModelType( rParam1 ) ); } 73cdf0e10cSrcweir 74cdf0e10cSrcweir private: append(ModelType * pModel)75cdf0e10cSrcweir inline ModelType& append( ModelType* pModel ) { this->push_back( value_type( pModel ) ); return *pModel; } 76cdf0e10cSrcweir }; 77cdf0e10cSrcweir 78cdf0e10cSrcweir // ============================================================================ 79cdf0e10cSrcweir 80cdf0e10cSrcweir template< typename KeyType, typename ModelType > 81cdf0e10cSrcweir class ModelMap : public RefMap< KeyType, ModelType > 82cdf0e10cSrcweir { 83cdf0e10cSrcweir public: 84cdf0e10cSrcweir typedef typename RefMap< KeyType, ModelType >::key_type key_type; 85cdf0e10cSrcweir typedef typename RefMap< KeyType, ModelType >::mapped_type mapped_type; 86cdf0e10cSrcweir typedef typename RefMap< KeyType, ModelType >::value_type value_type; 87cdf0e10cSrcweir ModelMap()88cdf0e10cSrcweir inline explicit ModelMap() {} ~ModelMap()89cdf0e10cSrcweir inline ~ModelMap() {} 90cdf0e10cSrcweir create(KeyType eKey)91cdf0e10cSrcweir inline ModelType& create( KeyType eKey ) { return insert( eKey, new ModelType ); } 92cdf0e10cSrcweir template< typename Param1Type > create(KeyType eKey,const Param1Type & rParam1)93cdf0e10cSrcweir inline ModelType& create( KeyType eKey, const Param1Type& rParam1 ) { return insert( eKey, new ModelType( rParam1 ) ); } 94cdf0e10cSrcweir 95cdf0e10cSrcweir private: insert(KeyType eKey,ModelType * pModel)96cdf0e10cSrcweir inline ModelType& insert( KeyType eKey, ModelType* pModel ) { (*this)[ eKey ].reset( pModel ); return *pModel; } 97cdf0e10cSrcweir }; 98cdf0e10cSrcweir 99cdf0e10cSrcweir // ============================================================================ 100cdf0e10cSrcweir 101cdf0e10cSrcweir struct NumberFormat 102cdf0e10cSrcweir { 103cdf0e10cSrcweir ::rtl::OUString maFormatCode; /// Number format code. 104cdf0e10cSrcweir bool mbSourceLinked; /// True = number format linked to source data. 105cdf0e10cSrcweir 106cdf0e10cSrcweir explicit NumberFormat(); 107cdf0e10cSrcweir 108cdf0e10cSrcweir void setAttributes( const AttributeList& rAttribs ); 109cdf0e10cSrcweir }; 110cdf0e10cSrcweir 111cdf0e10cSrcweir // ============================================================================ 112cdf0e10cSrcweir 113cdf0e10cSrcweir struct LayoutModel 114cdf0e10cSrcweir { 115cdf0e10cSrcweir double mfX; /// Left position of this object. 116cdf0e10cSrcweir double mfY; /// Top position of this object. 117cdf0e10cSrcweir double mfW; /// Width of this object. 118cdf0e10cSrcweir double mfH; /// Height of this object. 119cdf0e10cSrcweir sal_Int32 mnXMode; /// Mode for left position. 120cdf0e10cSrcweir sal_Int32 mnYMode; /// Mode for top position. 121cdf0e10cSrcweir sal_Int32 mnWMode; /// Mode for width. 122cdf0e10cSrcweir sal_Int32 mnHMode; /// Mode for height. 123cdf0e10cSrcweir sal_Int32 mnTarget; /// Layout target for plot area. 124cdf0e10cSrcweir bool mbAutoLayout; /// True = automatic positioning. 125cdf0e10cSrcweir 126cdf0e10cSrcweir explicit LayoutModel(); 127cdf0e10cSrcweir ~LayoutModel(); 128cdf0e10cSrcweir }; 129cdf0e10cSrcweir 130cdf0e10cSrcweir // ============================================================================ 131cdf0e10cSrcweir 132cdf0e10cSrcweir } // namespace chart 133cdf0e10cSrcweir } // namespace drawingml 134cdf0e10cSrcweir } // namespace oox 135cdf0e10cSrcweir 136cdf0e10cSrcweir #endif 137