LCOV - code coverage report
Current view: top level - libreoffice/sc/source/filter/inc - tool.h (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 6 25 24.0 %
Date: 2012-12-27 Functions: 2 6 33.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_TOOL_H
      21             : #define SC_TOOL_H
      22             : 
      23             : #include <attrib.hxx>    //!!! noch noetig?????
      24             : #include <document.hxx>
      25             : 
      26             : // Defaultwerte
      27             : const sal_uInt8 nDezStd = 0;        // Dezimalstellen fuer Standard-Zellen
      28             : const sal_uInt8 nDezFloat = 2;  //        "         "  Float-Zellen
      29             : 
      30             : void        PutFormString( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Char *pString );
      31             : 
      32             : void        SetFormat( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt8 nFormat, sal_uInt8 nSt );
      33             : 
      34             : void        InitPage( void );
      35             : 
      36             : String      DosToSystem( sal_Char *pSource );
      37             : 
      38             : double      SnumToDouble( sal_Int16 nVal );
      39             : 
      40             : double          Snum32ToDouble( sal_uInt32 nValue );
      41             : 
      42             : typedef sal_uInt16 StampTyp;
      43             : 
      44             : #define MAKE_STAMP(nF,nS) ((nS&0x0F)+((nF&0x7F)*16))
      45             :             // Bit 0...3  = Bit 0...3 von Stellenzahl
      46             :             // Bit 4...10 = Bit 0...6 von Formatbyte
      47             : 
      48             : class FormIdent
      49             : {
      50             : private:
      51             :     StampTyp        nStamp;         // Identifikations-Schluessel
      52             :     SfxUInt32Item*  pAttr;          // zugehoeriges Attribut
      53             : public:
      54        2049 :                     FormIdent( void )
      55             :                     {
      56        2049 :                         nStamp = 0;
      57        2049 :                         pAttr = NULL;
      58        2049 :                     }
      59             : 
      60           0 :                     FormIdent( sal_uInt8 nFormat, sal_uInt8 nSt, SfxUInt32Item& rAttr )
      61             :                     {
      62           0 :                         nStamp = MAKE_STAMP( nFormat, nSt );
      63           0 :                         pAttr = &rAttr;
      64           0 :                     }
      65             : 
      66             :                     FormIdent( sal_uInt8 nFormat, sal_uInt8 nSt )
      67             :                     {
      68             :                         nStamp = MAKE_STAMP( nFormat, nSt );
      69             :                         pAttr = NULL;
      70             :                     }
      71             : 
      72             :     sal_Bool            operator ==( const FormIdent& rComp ) const
      73             :                     {
      74             :                         return ( nStamp == rComp.nStamp );
      75             :                     }
      76             : 
      77             :     sal_Bool            operator ==( const StampTyp& rStamp ) const
      78             :                     {
      79             :                         return ( nStamp == rStamp );
      80             :                     }
      81             : 
      82           0 :     StampTyp        GetStamp( void ) const
      83             :                     {
      84           0 :                         return nStamp;
      85             :                     }
      86             : 
      87        2048 :     SfxUInt32Item*  GetAttr( void )
      88             :                     {
      89        2048 :                         return pAttr;
      90             :                     }
      91             : 
      92           0 :     void            SetStamp( sal_uInt8 nFormat, sal_uInt8 nSt )
      93             :                     {
      94           0 :                         nStamp = MAKE_STAMP( nFormat, nSt );
      95           0 :                     }
      96             : };
      97             : 
      98             : 
      99             : #define __nSize 2048
     100             : 
     101             : 
     102             : 
     103             : 
     104             : class FormCache
     105             : {
     106             : private:
     107             :     FormIdent           aIdents[ __nSize ]; //gepufferte Formate
     108             :     sal_Bool                bValid[ __nSize ];
     109             :     FormIdent           aCompareIdent;      // zum Vergleichen
     110             :     sal_uInt8               nDefaultFormat;     // Defaultformat der Datei
     111             :     SvNumberFormatter*  pFormTable;         // Value-Format-Table-Anker
     112             :     StampTyp            nIndex;
     113             :     LanguageType        eLanguage;          // Systemsprache
     114             : 
     115             :     SfxUInt32Item*      NewAttr( sal_uInt8 nFormat, sal_uInt8 nSt );
     116             : public:
     117             :                         FormCache( ScDocument*, sal_uInt8 nNewDefaultFormat = 0xFF );
     118             :                         ~FormCache();
     119             : 
     120             :     inline const SfxUInt32Item* GetAttr( sal_uInt8 nFormat, sal_uInt8 nSt );
     121             :     void                SetDefaultFormat( sal_uInt8 nD = 0xFF )
     122             :                         {
     123             :                             nDefaultFormat = nD;
     124             :                         }
     125             : };
     126             : 
     127             : 
     128           0 : inline const SfxUInt32Item* FormCache::GetAttr( sal_uInt8 nFormat, sal_uInt8 nSt )
     129             : {
     130             :     // PREC:    nFormat = Lotus-Format-Byte
     131             :     //          nSt = Stellenzahl
     132             :     // POST:    return = zu nFormat und nSt passendes SC-Format
     133             :     SfxUInt32Item*      pAttr;
     134             :     SfxUInt32Item*      pRet;
     135             : 
     136           0 :     aCompareIdent.SetStamp( nFormat, nSt );
     137           0 :     nIndex = aCompareIdent.GetStamp();
     138             :     OSL_ENSURE( nIndex < __nSize, "FormCache::GetAttr(): Uuuuuuups... so nicht!" );
     139           0 :     if( bValid[ nIndex ] )
     140           0 :         pRet = aIdents[ nIndex ].GetAttr();
     141             :     else
     142             :     {
     143             :         // neues Attribut anlegen
     144           0 :         pAttr = NewAttr( nFormat, nSt );
     145             :         OSL_ENSURE( pAttr, "FormCache::GetAttr(): Nix Speicherus" );
     146             : 
     147           0 :         aIdents[ nIndex ] = FormIdent( nFormat, nSt, *pAttr );
     148           0 :         bValid[ nIndex ] = sal_True;
     149             : 
     150           0 :         pRet = pAttr;
     151             :     }
     152           0 :     return pRet;
     153             : }
     154             : 
     155             : #endif
     156             : 
     157             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10