LCOV - code coverage report
Current view: top level - sc/source/filter/inc - tool.h (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 25 25 100.0 %
Date: 2014-11-03 Functions: 6 6 100.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 INCLUDED_SC_SOURCE_FILTER_INC_TOOL_H
      21             : #define INCLUDED_SC_SOURCE_FILTER_INC_TOOL_H
      22             : 
      23             : #include <attrib.hxx>
      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             : struct LotusContext;
      31             : 
      32             : void        PutFormString(LotusContext& rContext, SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Char *pString);
      33             : 
      34             : void        SetFormat(LotusContext& rContext, SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt8 nFormat, sal_uInt8 nSt);
      35             : 
      36             : void        InitPage( void );
      37             : 
      38             : OUString    DosToSystem( sal_Char *pSource );
      39             : 
      40             : double      SnumToDouble( sal_Int16 nVal );
      41             : 
      42             : double          Snum32ToDouble( sal_uInt32 nValue );
      43             : 
      44             : typedef sal_uInt16 StampTyp;
      45             : 
      46             : #define MAKE_STAMP(nF,nS) ((nS&0x0F)+((nF&0x7F)*16))
      47             :             // Bit 0...3  = Bit 0...3 von Stellenzahl
      48             :             // Bit 4...10 = Bit 0...6 von Formatbyte
      49             : 
      50             : class FormIdent
      51             : {
      52             : private:
      53             :     StampTyp        nStamp;         // Identifikations-Schluessel
      54             :     SfxUInt32Item*  pAttr;          // zugehoeriges Attribut
      55             : public:
      56       16392 :                     FormIdent( void )
      57             :                     {
      58       16392 :                         nStamp = 0;
      59       16392 :                         pAttr = NULL;
      60       16392 :                     }
      61             : 
      62           2 :                     FormIdent( sal_uInt8 nFormat, sal_uInt8 nSt, SfxUInt32Item& rAttr )
      63             :                     {
      64           2 :                         nStamp = MAKE_STAMP( nFormat, nSt );
      65           2 :                         pAttr = &rAttr;
      66           2 :                     }
      67             : 
      68             :                     FormIdent( sal_uInt8 nFormat, sal_uInt8 nSt )
      69             :                     {
      70             :                         nStamp = MAKE_STAMP( nFormat, nSt );
      71             :                         pAttr = NULL;
      72             :                     }
      73             : 
      74             :     bool            operator ==( const FormIdent& rComp ) const
      75             :                     {
      76             :                         return ( nStamp == rComp.nStamp );
      77             :                     }
      78             : 
      79             :     bool            operator ==( const StampTyp& rStamp ) const
      80             :                     {
      81             :                         return ( nStamp == rStamp );
      82             :                     }
      83             : 
      84          14 :     StampTyp        GetStamp( void ) const
      85             :                     {
      86          14 :                         return nStamp;
      87             :                     }
      88             : 
      89       12300 :     SfxUInt32Item*  GetAttr( void )
      90             :                     {
      91       12300 :                         return pAttr;
      92             :                     }
      93             : 
      94          14 :     void            SetStamp( sal_uInt8 nFormat, sal_uInt8 nSt )
      95             :                     {
      96          14 :                         nStamp = MAKE_STAMP( nFormat, nSt );
      97          14 :                     }
      98             : };
      99             : 
     100             : 
     101             : #define __nSize 2048
     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          14 : 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          14 :     aCompareIdent.SetStamp( nFormat, nSt );
     137          14 :     nIndex = aCompareIdent.GetStamp();
     138             :     OSL_ENSURE( nIndex < __nSize, "FormCache::GetAttr(): Oups... not this way!" );
     139          14 :     if( bValid[ nIndex ] )
     140          12 :         pRet = aIdents[ nIndex ].GetAttr();
     141             :     else
     142             :     {
     143             :         // neues Attribut anlegen
     144           2 :         pAttr = NewAttr( nFormat, nSt );
     145             :         OSL_ENSURE( pAttr, "FormCache::GetAttr(): Nothing to save" );
     146             : 
     147           2 :         aIdents[ nIndex ] = FormIdent( nFormat, nSt, *pAttr );
     148           2 :         bValid[ nIndex ] = sal_True;
     149             : 
     150           2 :         pRet = pAttr;
     151             :     }
     152          14 :     return pRet;
     153             : }
     154             : 
     155             : #endif
     156             : 
     157             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10