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

Generated by: LCOV version 1.11