LCOV - code coverage report
Current view: top level - sc/inc - chartpos.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 22 32 68.8 %
Date: 2014-11-03 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             :                                 // not implemented
      52             :                                 ScChartPositionMap( const ScChartPositionMap& );
      53             :             ScChartPositionMap& operator=( const ScChartPositionMap& );
      54             : 
      55             : public:
      56             : 
      57             :             sal_uLong               GetCount() const { return nCount; }
      58          32 :             SCCOL               GetColCount() const { return nColCount; }
      59          32 :             SCROW               GetRowCount() const { return nRowCount; }
      60             : 
      61         142 :             bool                IsValid( SCCOL nCol, SCROW nRow ) const
      62         142 :                                     { return nCol < nColCount && nRow < nRowCount; }
      63             :                                 // data column by column
      64         142 :             sal_uLong               GetIndex( SCCOL nCol, SCROW nRow ) const
      65         142 :                                     { return (sal_uLong) nCol * nRowCount + nRow; }
      66             : 
      67         272 :             const ScAddress*    GetPosition( sal_uLong nIndex ) const
      68             :                                     {
      69         272 :                                         if ( nIndex < nCount )
      70         272 :                                             return ppData[ nIndex ];
      71           0 :                                         return NULL;
      72             :                                     }
      73             : 
      74             :                                     //! might be NULL indicating "no value"
      75         142 :             const ScAddress*    GetPosition( SCCOL nChartCol, SCROW nChartRow ) const
      76             :                                     {
      77         142 :                                         if ( IsValid( nChartCol, nChartRow ) )
      78         142 :                                             return ppData[ GetIndex( nChartCol, nChartRow ) ];
      79           0 :                                         return NULL;
      80             :                                     }
      81          32 :             const ScAddress*    GetColHeaderPosition( SCCOL nChartCol ) const
      82             :                                     {
      83          32 :                                         if ( nChartCol < nColCount )
      84          32 :                                             return ppColHeader[ nChartCol ];
      85           0 :                                         return NULL;
      86             :                                     }
      87         254 :             const ScAddress*    GetRowHeaderPosition( SCROW nChartRow ) const
      88             :                                     {
      89         254 :                                         if ( nChartRow < nRowCount )
      90         254 :                                             return ppRowHeader[ nChartRow ];
      91           0 :                                         return NULL;
      92             :                                     }
      93             : };
      94             : 
      95             : enum ScChartGlue {
      96             :     SC_CHARTGLUE_NA,
      97             :     SC_CHARTGLUE_NONE,      // old mimic
      98             :     SC_CHARTGLUE_COLS,      // old mimic
      99             :     SC_CHARTGLUE_ROWS,
     100             :     SC_CHARTGLUE_BOTH
     101             : };
     102             : 
     103             : class ScDocument;
     104             : 
     105             : class ScChartPositioner             // only parameter struct
     106             : {
     107             :     ScRangeListRef  aRangeListRef;
     108             :     ScDocument* pDocument;
     109             :     ScChartPositionMap* pPositionMap;
     110             :     ScChartGlue eGlue;
     111             :     SCCOL       nStartCol;
     112             :     SCROW       nStartRow;
     113             :     bool        bColHeaders;
     114             :     bool        bRowHeaders;
     115             :     bool        bDummyUpperLeft;
     116             : 
     117             : private:
     118             :     void        CheckColRowHeaders();
     119             : 
     120             :     void        GlueState();        // summarised areas
     121             :     void        CreatePositionMap();
     122             : 
     123             : public:
     124             :     ScChartPositioner( ScDocument* pDoc, SCTAB nTab,
     125             :                     SCCOL nStartColP, SCROW nStartRowP,
     126             :                     SCCOL nEndColP, SCROW nEndRowP );
     127             :     ScChartPositioner( ScDocument* pDoc, const ScRangeListRef& rRangeList );
     128             :     ScChartPositioner( const ScChartPositioner& rPositioner );
     129             : 
     130             :     virtual ~ScChartPositioner();
     131             : 
     132          52 :     const ScRangeListRef&   GetRangeList() const { return aRangeListRef; }
     133             :     void    SetRangeList( const ScRangeListRef& rNew ) { aRangeListRef = rNew; }
     134             :     void    SetRangeList( const ScRange& rNew );
     135             : 
     136          52 :     void    SetHeaders(bool bCol, bool bRow) { bColHeaders=bCol; bRowHeaders=bRow; }
     137          88 :     bool    HasColHeaders() const            { return bColHeaders; }
     138         304 :     bool    HasRowHeaders() const            { return bRowHeaders; }
     139             :     void    SeteGlue(ScChartGlue eNew) { eGlue = eNew; }
     140             :     void    SetStartCol(SCCOL nNew) { nStartCol = nNew; }
     141             :     void    SetStartRow(SCROW nNew) { nStartRow = nNew; }
     142             : 
     143             :     bool    operator==(const ScChartPositioner& rCmp) const;
     144             : 
     145           0 :     void                    InvalidateGlue()
     146             :                                 {
     147           0 :                                     eGlue = SC_CHARTGLUE_NA;
     148           0 :                                     if ( pPositionMap )
     149             :                                     {
     150           0 :                                         delete pPositionMap;
     151           0 :                                         pPositionMap = NULL;
     152             :                                     }
     153           0 :                                 }
     154             :     const ScChartPositionMap*   GetPositionMap();
     155             : };
     156             : 
     157             : #endif
     158             : 
     159             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10