LCOV - code coverage report
Current view: top level - sc/inc - chartpos.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 22 32 68.8 %
Date: 2015-06-13 12:38:46 Functions: 12 13 92.3 %
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_SC_INC_CHARTPOS_HXX
      21             : #define INCLUDED_SC_INC_CHARTPOS_HXX
      22             : 
      23             : #include "rangelst.hxx"
      24             : #include <map>
      25             : 
      26             : class ScAddress;
      27             : 
      28             : // map of row number to ScAddress*
      29             : typedef std::map<sal_uLong, ScAddress*> RowMap;
      30             : // map of column number to RowMap*
      31             : typedef std::map<sal_uLong, RowMap*>    ColumnMap;
      32             : 
      33             : class ScChartPositionMap
      34             : {
      35             :     friend class ScChartPositioner;
      36             : 
      37             :             ScAddress**         ppData;
      38             :             ScAddress**         ppColHeader;
      39             :             ScAddress**         ppRowHeader;
      40             :             sal_uLong               nCount;
      41             :             SCCOL               nColCount;
      42             :             SCROW               nRowCount;
      43             : 
      44             :                                 ScChartPositionMap( SCCOL nChartCols, SCROW nChartRows,
      45             :                                     SCCOL nColAdd,      // header columns
      46             :                                     SCROW nRowAdd,      // header rows
      47             :                                     ColumnMap& rCols        // table with col tables with address*
      48             :                                     );
      49             :                                 ~ScChartPositionMap();  //! deletes all ScAddress*
      50             : 
      51             :                                 ScChartPositionMap( const ScChartPositionMap& ) SAL_DELETED_FUNCTION;
      52             :             ScChartPositionMap& operator=( const ScChartPositionMap& ) SAL_DELETED_FUNCTION;
      53             : 
      54             : public:
      55             : 
      56             :             sal_uLong               GetCount() const { return nCount; }
      57          16 :             SCCOL               GetColCount() const { return nColCount; }
      58          16 :             SCROW               GetRowCount() const { return nRowCount; }
      59             : 
      60          71 :             bool                IsValid( SCCOL nCol, SCROW nRow ) const
      61          71 :                                     { return nCol < nColCount && nRow < nRowCount; }
      62             :                                 // data column by column
      63          71 :             sal_uLong               GetIndex( SCCOL nCol, SCROW nRow ) const
      64          71 :                                     { return (sal_uLong) nCol * nRowCount + nRow; }
      65             : 
      66         136 :             const ScAddress*    GetPosition( sal_uLong nIndex ) const
      67             :                                     {
      68         136 :                                         if ( nIndex < nCount )
      69         136 :                                             return ppData[ nIndex ];
      70           0 :                                         return NULL;
      71             :                                     }
      72             : 
      73             :                                     //! might be NULL indicating "no value"
      74          71 :             const ScAddress*    GetPosition( SCCOL nChartCol, SCROW nChartRow ) const
      75             :                                     {
      76          71 :                                         if ( IsValid( nChartCol, nChartRow ) )
      77          71 :                                             return ppData[ GetIndex( nChartCol, nChartRow ) ];
      78           0 :                                         return NULL;
      79             :                                     }
      80          16 :             const ScAddress*    GetColHeaderPosition( SCCOL nChartCol ) const
      81             :                                     {
      82          16 :                                         if ( nChartCol < nColCount )
      83          16 :                                             return ppColHeader[ nChartCol ];
      84           0 :                                         return NULL;
      85             :                                     }
      86         127 :             const ScAddress*    GetRowHeaderPosition( SCROW nChartRow ) const
      87             :                                     {
      88         127 :                                         if ( nChartRow < nRowCount )
      89         127 :                                             return ppRowHeader[ nChartRow ];
      90           0 :                                         return NULL;
      91             :                                     }
      92             : };
      93             : 
      94             : enum ScChartGlue {
      95             :     SC_CHARTGLUE_NA,
      96             :     SC_CHARTGLUE_NONE,      // old mimic
      97             :     SC_CHARTGLUE_COLS,      // old mimic
      98             :     SC_CHARTGLUE_ROWS,
      99             :     SC_CHARTGLUE_BOTH
     100             : };
     101             : 
     102             : class ScDocument;
     103             : 
     104             : class ScChartPositioner             // only parameter struct
     105             : {
     106             :     ScRangeListRef  aRangeListRef;
     107             :     ScDocument* pDocument;
     108             :     ScChartPositionMap* pPositionMap;
     109             :     ScChartGlue eGlue;
     110             :     SCCOL       nStartCol;
     111             :     SCROW       nStartRow;
     112             :     bool        bColHeaders;
     113             :     bool        bRowHeaders;
     114             :     bool        bDummyUpperLeft;
     115             : 
     116             : private:
     117             :     void        CheckColRowHeaders();
     118             : 
     119             :     void        GlueState();        // summarised areas
     120             :     void        CreatePositionMap();
     121             : 
     122             : public:
     123             :     ScChartPositioner( ScDocument* pDoc, SCTAB nTab,
     124             :                     SCCOL nStartColP, SCROW nStartRowP,
     125             :                     SCCOL nEndColP, SCROW nEndRowP );
     126             :     ScChartPositioner( ScDocument* pDoc, const ScRangeListRef& rRangeList );
     127             :     ScChartPositioner( const ScChartPositioner& rPositioner );
     128             : 
     129             :     virtual ~ScChartPositioner();
     130             : 
     131          26 :     const ScRangeListRef&   GetRangeList() const { return aRangeListRef; }
     132             :     void    SetRangeList( const ScRangeListRef& rNew ) { aRangeListRef = rNew; }
     133             :     void    SetRangeList( const ScRange& rNew );
     134             : 
     135          26 :     void    SetHeaders(bool bCol, bool bRow) { bColHeaders=bCol; bRowHeaders=bRow; }
     136          44 :     bool    HasColHeaders() const            { return bColHeaders; }
     137         152 :     bool    HasRowHeaders() const            { return bRowHeaders; }
     138             :     void    SeteGlue(ScChartGlue eNew) { eGlue = eNew; }
     139             :     void    SetStartCol(SCCOL nNew) { nStartCol = nNew; }
     140             :     void    SetStartRow(SCROW nNew) { nStartRow = nNew; }
     141             : 
     142             :     bool    operator==(const ScChartPositioner& rCmp) const;
     143             : 
     144           0 :     void                    InvalidateGlue()
     145             :                                 {
     146           0 :                                     eGlue = SC_CHARTGLUE_NA;
     147           0 :                                     if ( pPositionMap )
     148             :                                     {
     149           0 :                                         delete pPositionMap;
     150           0 :                                         pPositionMap = NULL;
     151             :                                     }
     152           0 :                                 }
     153             :     const ScChartPositionMap*   GetPositionMap();
     154             : };
     155             : 
     156             : #endif
     157             : 
     158             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11