LCOV - code coverage report
Current view: top level - sc/inc - refdata.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 27 0.0 %
Date: 2014-04-14 Functions: 0 16 0.0 %
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_REFDATA_HXX
      21             : #define SC_REFDATA_HXX
      22             : 
      23             : #include "global.hxx"
      24             : #include "address.hxx"
      25             : #include "scdllapi.h"
      26             : #include "calcmacros.hxx"
      27             : 
      28             : /// Single reference (one address) into the sheet
      29             : struct SC_DLLPUBLIC ScSingleRefData
      30             : {
      31             : private:
      32             :     SCCOL mnCol;
      33             :     SCROW mnRow;
      34             :     SCTAB mnTab;
      35             : 
      36             :     union
      37             :     {
      38             :         sal_uInt8 mnFlagValue;
      39             :         struct
      40             :         {
      41             :             bool bColRel     :1;
      42             :             bool bColDeleted :1;
      43             :             bool bRowRel     :1;
      44             :             bool bRowDeleted :1;
      45             :             bool bTabRel     :1;
      46             :             bool bTabDeleted :1;
      47             :             bool bFlag3D     :1;     ///< 3D-Ref
      48             :             bool bRelName    :1;     ///< Reference derived from RangeName with relative values
      49             :         } Flags;
      50             :     };
      51             : 
      52             : public:
      53             :     /// No default ctor, because used in ScRawToken union, set InitFlags!
      54           0 :     inline  void InitFlags() { mnFlagValue = 0; }    ///< all FALSE
      55             :     /// InitAddress: InitFlags and set address
      56             :     void InitAddress( const ScAddress& rAdr );
      57             :     void InitAddress( SCCOL nCol, SCROW nRow, SCTAB nTab );
      58             :     /// InitAddressRel: InitFlags and set address, everything relative to rPos
      59             :     void InitAddressRel( const ScAddress& rAdr, const ScAddress& rPos );
      60             :     sal_uInt8 FlagValue() const;
      61             : 
      62           0 :     void SetColRel( bool bVal ) { Flags.bColRel = bVal; }
      63           0 :     bool IsColRel() const { return Flags.bColRel; }
      64           0 :     void SetRowRel( bool bVal ) { Flags.bRowRel = bVal; }
      65           0 :     bool IsRowRel() const { return Flags.bRowRel; }
      66           0 :     void SetTabRel( bool bVal ) { Flags.bTabRel = bVal; }
      67           0 :     bool IsTabRel() const { return Flags.bTabRel; }
      68             : 
      69             :     void SetAbsCol( SCCOL nVal );
      70             :     void SetRelCol( SCCOL nVal );
      71             :     void IncCol( SCCOL nInc );
      72             :     void SetAbsRow( SCROW nVal );
      73             :     void SetRelRow( SCROW nVal );
      74             :     void IncRow( SCROW nInc );
      75             :     void SetAbsTab( SCTAB nVal );
      76             :     void SetRelTab( SCTAB nVal );
      77             :     void IncTab( SCTAB nInc );
      78             : 
      79             :     void SetColDeleted( bool bVal );
      80             :     bool IsColDeleted() const;
      81             :     void SetRowDeleted( bool bVal );
      82             :     bool IsRowDeleted() const;
      83             :     void SetTabDeleted( bool bVal );
      84             :     bool IsTabDeleted() const;
      85             :     bool IsDeleted() const;
      86             : 
      87           0 :     void SetFlag3D( bool bVal ) { Flags.bFlag3D = bVal; }
      88           0 :     bool IsFlag3D() const { return Flags.bFlag3D; }
      89           0 :     void SetRelName( bool bVal ) { Flags.bRelName = bVal; }
      90           0 :     bool IsRelName() const { return Flags.bRelName; }
      91             : 
      92             :     bool Valid() const;
      93             :     bool ColValid() const;
      94             :     bool RowValid() const;
      95             :     bool TabValid() const;
      96             :     /// In external references nTab is -1
      97             :     bool ValidExternal() const;
      98             : 
      99             :     ScAddress toAbs( const ScAddress& rPos ) const;
     100             :     void SetAddress( const ScAddress& rAddr, const ScAddress& rPos );
     101             :     SCROW Row() const;
     102             :     SCCOL Col() const;
     103             :     SCTAB Tab() const;
     104             : 
     105             :     bool operator==( const ScSingleRefData& ) const;
     106             :     bool operator!=( const ScSingleRefData& ) const;
     107             : 
     108             : #if DEBUG_FORMULA_COMPILER
     109             :     void Dump( int nIndent = 0 ) const;
     110             : #endif
     111             : };
     112             : 
     113             : /// Complex reference (a range) into the sheet
     114             : struct ScComplexRefData
     115             : {
     116             :     ScSingleRefData Ref1;
     117             :     ScSingleRefData Ref2;
     118             : 
     119           0 :     inline void InitFlags()
     120           0 :         { Ref1.InitFlags(); Ref2.InitFlags(); }
     121           0 :     inline void InitRange( const ScRange& rRange )
     122             :         {
     123           0 :             Ref1.InitAddress( rRange.aStart );
     124           0 :             Ref2.InitAddress( rRange.aEnd );
     125           0 :         }
     126           0 :     inline void InitRangeRel( const ScRange& rRange, const ScAddress& rPos )
     127             :         {
     128           0 :             Ref1.InitAddressRel( rRange.aStart, rPos );
     129           0 :             Ref2.InitAddressRel( rRange.aEnd, rPos );
     130           0 :         }
     131           0 :     inline void InitRange( SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
     132             :                             SCCOL nCol2, SCROW nRow2, SCTAB nTab2 )
     133             :         {
     134           0 :             Ref1.InitAddress( nCol1, nRow1, nTab1 );
     135           0 :             Ref2.InitAddress( nCol2, nRow2, nTab2 );
     136           0 :         }
     137             : 
     138             :     bool Valid() const;
     139             : 
     140             :     /** In external references nTab is -1 for the start tab and -1 for the end
     141             :         tab if one sheet, or >=0 if more than one sheets. */
     142             :     bool ValidExternal() const;
     143             : 
     144             :     SC_DLLPUBLIC ScRange toAbs( const ScAddress& rPos ) const;
     145             :     void SetRange( const ScRange& rRange, const ScAddress& rPos );
     146             : 
     147           0 :     inline bool operator==( const ScComplexRefData& r ) const
     148           0 :         { return Ref1 == r.Ref1 && Ref2 == r.Ref2; }
     149             :     /** Enlarge range if reference passed is not within existing range.
     150             :         ScAddress position is used to calculate absolute references from
     151             :         relative references. */
     152             :     ScComplexRefData& Extend( const ScSingleRefData & rRef, const ScAddress & rPos );
     153             :     ScComplexRefData& Extend( const ScComplexRefData & rRef, const ScAddress & rPos );
     154             : 
     155             : #if DEBUG_FORMULA_COMPILER
     156             :     void Dump( int nIndent = 0 ) const;
     157             : #endif
     158             : };
     159             : 
     160             : #endif
     161             : 
     162             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10