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

Generated by: LCOV version 1.10