merge the formfield patch from ooo-build
[ooovba.git] / sc / source / filter / inc / tool.h
blob257467a68d1f078145f5494f95cc6d3014cff5e1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tool.h,v $
10 * $Revision: 1.5.32.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_TOOL_H
32 #define SC_TOOL_H
34 #include <attrib.hxx> //!!! noch noetig?????
35 #include <document.hxx>
37 // Defaultwerte
38 const BYTE nDezStd = 0; // Dezimalstellen fuer Standard-Zellen
39 const BYTE nDezFloat = 2; // " " Float-Zellen
41 void PutFormString( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Char *pString );
43 void SetFormat( SCCOL nCol, SCROW nRow, SCTAB nTab, BYTE nFormat, BYTE nSt );
45 void InitPage( void );
47 String DosToSystem( sal_Char *pSource );
49 double SnumToDouble( INT16 nVal );
51 double Snum32ToDouble( UINT32 nValue );
53 typedef UINT16 StampTyp;
55 #define MAKE_STAMP(nF,nS) ((nS&0x0F)+((nF&0x7F)*16))
56 // Bit 0...3 = Bit 0...3 von Stellenzahl
57 // Bit 4...10 = Bit 0...6 von Formatbyte
59 class FormIdent
61 private:
62 StampTyp nStamp; // Identifikations-Schluessel
63 SfxUInt32Item* pAttr; // zugehoeriges Attribut
64 public:
65 FormIdent( void )
67 nStamp = 0;
68 pAttr = NULL;
71 FormIdent( BYTE nFormat, BYTE nSt, SfxUInt32Item& rAttr )
73 nStamp = MAKE_STAMP( nFormat, nSt );
74 pAttr = &rAttr;
77 FormIdent( BYTE nFormat, BYTE nSt )
79 nStamp = MAKE_STAMP( nFormat, nSt );
80 pAttr = NULL;
83 BOOL operator ==( const FormIdent& rComp ) const
85 return ( nStamp == rComp.nStamp );
88 BOOL operator ==( const StampTyp& rStamp ) const
90 return ( nStamp == rStamp );
93 StampTyp GetStamp( void ) const
95 return nStamp;
98 SfxUInt32Item* GetAttr( void )
100 return pAttr;
103 void SetStamp( BYTE nFormat, BYTE nSt )
105 nStamp = MAKE_STAMP( nFormat, nSt );
110 #define __nSize 2048
115 class FormCache
117 private:
118 FormIdent aIdents[ __nSize ]; //gepufferte Formate
119 BOOL bValid[ __nSize ];
120 FormIdent aCompareIdent; // zum Vergleichen
121 BYTE nDefaultFormat; // Defaultformat der Datei
122 SvNumberFormatter* pFormTable; // Value-Format-Table-Anker
123 StampTyp nIndex;
124 LanguageType eLanguage; // Systemsprache
126 SfxUInt32Item* NewAttr( BYTE nFormat, BYTE nSt );
127 public:
128 FormCache( ScDocument*, BYTE nNewDefaultFormat = 0xFF );
129 ~FormCache();
131 inline const SfxUInt32Item* GetAttr( BYTE nFormat, BYTE nSt );
132 void SetDefaultFormat( BYTE nD = 0xFF )
134 nDefaultFormat = nD;
139 inline const SfxUInt32Item* FormCache::GetAttr( BYTE nFormat, BYTE nSt )
141 // PREC: nFormat = Lotus-Format-Byte
142 // nSt = Stellenzahl
143 // POST: return = zu nFormat und nSt passendes SC-Format
144 SfxUInt32Item* pAttr;
145 SfxUInt32Item* pRet;
147 aCompareIdent.SetStamp( nFormat, nSt );
148 nIndex = aCompareIdent.GetStamp();
149 DBG_ASSERT( nIndex < __nSize, "FormCache::GetAttr(): Uuuuuuups... so nicht!" );
150 if( bValid[ nIndex ] )
151 pRet = aIdents[ nIndex ].GetAttr();
152 else
154 // neues Attribut anlegen
155 pAttr = NewAttr( nFormat, nSt );
156 DBG_ASSERT( pAttr, "FormCache::GetAttr(): Nix Speicherus" );
158 aIdents[ nIndex ] = FormIdent( nFormat, nSt, *pAttr );
159 bValid[ nIndex ] = TRUE;
161 pRet = pAttr;
163 return pRet;
166 #endif