LCOV - code coverage report
Current view: top level - sc/inc - chartpos.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 26 32 81.2 %
Date: 2012-08-25 Functions: 12 13 92.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 16 37.5 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef SC_CHARTPOS_HXX
      30                 :            : #define SC_CHARTPOS_HXX
      31                 :            : 
      32                 :            : // -----------------------------------------------------------------------
      33                 :            : 
      34                 :            : #include "rangelst.hxx"
      35                 :            : #include <map>
      36                 :            : 
      37                 :            : class ScAddress;
      38                 :            : 
      39                 :            : // map of row number to ScAddress*
      40                 :            : typedef std::map<sal_uLong, ScAddress*> RowMap;
      41                 :            : // map of column number to RowMap*
      42                 :            : typedef std::map<sal_uLong, RowMap*>    ColumnMap;
      43                 :            : 
      44                 :            : class ScChartPositionMap
      45                 :            : {
      46                 :            :     friend class ScChartPositioner;
      47                 :            : 
      48                 :            :             ScAddress**         ppData;
      49                 :            :             ScAddress**         ppColHeader;
      50                 :            :             ScAddress**         ppRowHeader;
      51                 :            :             sal_uLong               nCount;
      52                 :            :             SCCOL               nColCount;
      53                 :            :             SCROW               nRowCount;
      54                 :            : 
      55                 :            :                                 ScChartPositionMap( SCCOL nChartCols, SCROW nChartRows,
      56                 :            :                                     SCCOL nColAdd,      // header columns
      57                 :            :                                     SCROW nRowAdd,      // header rows
      58                 :            :                                     ColumnMap& rCols        // table with col tables with address*
      59                 :            :                                     );
      60                 :            :                                 ~ScChartPositionMap();  //! deletes all ScAddress*
      61                 :            : 
      62                 :            :                                 // not implemented
      63                 :            :                                 ScChartPositionMap( const ScChartPositionMap& );
      64                 :            :             ScChartPositionMap& operator=( const ScChartPositionMap& );
      65                 :            : 
      66                 :            : public:
      67                 :            : 
      68                 :            :             sal_uLong               GetCount() const { return nCount; }
      69                 :         19 :             SCCOL               GetColCount() const { return nColCount; }
      70                 :         19 :             SCROW               GetRowCount() const { return nRowCount; }
      71                 :            : 
      72                 :        119 :             sal_Bool                IsValid( SCCOL nCol, SCROW nRow ) const
      73 [ +  - ][ +  - ]:        119 :                                     { return nCol < nColCount && nRow < nRowCount; }
      74                 :            :                                 // data column by column
      75                 :        119 :             sal_uLong               GetIndex( SCCOL nCol, SCROW nRow ) const
      76                 :        119 :                                     { return (sal_uLong) nCol * nRowCount + nRow; }
      77                 :            : 
      78                 :        136 :             const ScAddress*    GetPosition( sal_uLong nIndex ) const
      79                 :            :                                     {
      80         [ +  - ]:        136 :                                         if ( nIndex < nCount )
      81                 :        136 :                                             return ppData[ nIndex ];
      82                 :        136 :                                         return NULL;
      83                 :            :                                     }
      84                 :            : 
      85                 :            :                                     //! might be NULL indicating "no value"
      86                 :        119 :             const ScAddress*    GetPosition( SCCOL nChartCol, SCROW nChartRow ) const
      87                 :            :                                     {
      88         [ +  - ]:        119 :                                         if ( IsValid( nChartCol, nChartRow ) )
      89                 :        119 :                                             return ppData[ GetIndex( nChartCol, nChartRow ) ];
      90                 :        119 :                                         return NULL;
      91                 :            :                                     }
      92                 :         16 :             const ScAddress*    GetColHeaderPosition( SCCOL nChartCol ) const
      93                 :            :                                     {
      94         [ +  - ]:         16 :                                         if ( nChartCol < nColCount )
      95                 :         16 :                                             return ppColHeader[ nChartCol ];
      96                 :         16 :                                         return NULL;
      97                 :            :                                     }
      98                 :        127 :             const ScAddress*    GetRowHeaderPosition( SCROW nChartRow ) const
      99                 :            :                                     {
     100         [ +  - ]:        127 :                                         if ( nChartRow < nRowCount )
     101                 :        127 :                                             return ppRowHeader[ nChartRow ];
     102                 :        127 :                                         return NULL;
     103                 :            :                                     }
     104                 :            : };
     105                 :            : 
     106                 :            : 
     107                 :            : enum ScChartGlue {
     108                 :            :     SC_CHARTGLUE_NA,
     109                 :            :     SC_CHARTGLUE_NONE,      // old mimic
     110                 :            :     SC_CHARTGLUE_COLS,      // old mimic
     111                 :            :     SC_CHARTGLUE_ROWS,
     112                 :            :     SC_CHARTGLUE_BOTH
     113                 :            : };
     114                 :            : 
     115                 :            : class ScDocument;
     116                 :            : 
     117                 :            : class ScChartPositioner             // only parameter struct
     118                 :            : {
     119                 :            :     ScRangeListRef  aRangeListRef;
     120                 :            :     ScDocument* pDocument;
     121                 :            :     ScChartPositionMap* pPositionMap;
     122                 :            :     ScChartGlue eGlue;
     123                 :            :     SCCOL       nStartCol;
     124                 :            :     SCROW       nStartRow;
     125                 :            :     sal_Bool        bColHeaders;
     126                 :            :     sal_Bool        bRowHeaders;
     127                 :            :     sal_Bool        bDummyUpperLeft;
     128                 :            : 
     129                 :            : private:
     130                 :            :     void        CheckColRowHeaders();
     131                 :            : 
     132                 :            :     void        GlueState();        // summarised areas
     133                 :            :     void        CreatePositionMap();
     134                 :            : 
     135                 :            : public:
     136                 :            :     ScChartPositioner( ScDocument* pDoc, SCTAB nTab,
     137                 :            :                     SCCOL nStartColP, SCROW nStartRowP,
     138                 :            :                     SCCOL nEndColP, SCROW nEndRowP );
     139                 :            :     ScChartPositioner( ScDocument* pDoc, const ScRangeListRef& rRangeList );
     140                 :            :     ScChartPositioner( const ScChartPositioner& rPositioner );
     141                 :            : 
     142                 :            :     virtual ~ScChartPositioner();
     143                 :            : 
     144                 :         42 :     const ScRangeListRef&   GetRangeList() const { return aRangeListRef; }
     145                 :            :     void    SetRangeList( const ScRangeListRef& rNew ) { aRangeListRef = rNew; }
     146                 :            :     void    SetRangeList( const ScRange& rNew );
     147                 :            : 
     148                 :         37 :     void    SetHeaders(sal_Bool bCol, sal_Bool bRow) { bColHeaders=bCol; bRowHeaders=bRow; }
     149                 :         84 :     sal_Bool    HasColHeaders() const            { return bColHeaders; }
     150                 :        192 :     sal_Bool    HasRowHeaders() const            { return bRowHeaders; }
     151                 :            :     void    SetDummyUpperLeft(sal_Bool bNew) { bDummyUpperLeft = bNew; }
     152                 :            :     void    SeteGlue(ScChartGlue eNew) { eGlue = eNew; }
     153                 :            :     void    SetStartCol(SCCOL nNew) { nStartCol = nNew; }
     154                 :            :     void    SetStartRow(SCROW nNew) { nStartRow = nNew; }
     155                 :            : 
     156                 :            :     sal_Bool    operator==(const ScChartPositioner& rCmp) const;
     157                 :            : 
     158                 :          0 :     void                    InvalidateGlue()
     159                 :            :                                 {
     160                 :          0 :                                     eGlue = SC_CHARTGLUE_NA;
     161         [ #  # ]:          0 :                                     if ( pPositionMap )
     162                 :            :                                     {
     163         [ #  # ]:          0 :                                         delete pPositionMap;
     164                 :          0 :                                         pPositionMap = NULL;
     165                 :            :                                     }
     166                 :          0 :                                 }
     167                 :            :     const ScChartPositionMap*   GetPositionMap();
     168                 :            : };
     169                 :            : 
     170                 :            : 
     171                 :            : #endif
     172                 :            : 
     173                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10