LCOV - code coverage report
Current view: top level - include/oox/drawingml/chart - modelbase.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 21 21 100.0 %
Date: 2015-06-13 12:38:46 Functions: 115 118 97.5 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11