xref: /aoo41x/main/sc/source/filter/inc/tool.h (revision feb022d5)
1*feb022d5SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*feb022d5SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*feb022d5SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*feb022d5SAndrew Rist  * distributed with this work for additional information
6*feb022d5SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*feb022d5SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*feb022d5SAndrew Rist  * "License"); you may not use this file except in compliance
9*feb022d5SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*feb022d5SAndrew Rist  *
11*feb022d5SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*feb022d5SAndrew Rist  *
13*feb022d5SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*feb022d5SAndrew Rist  * software distributed under the License is distributed on an
15*feb022d5SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*feb022d5SAndrew Rist  * KIND, either express or implied.  See the License for the
17*feb022d5SAndrew Rist  * specific language governing permissions and limitations
18*feb022d5SAndrew Rist  * under the License.
19*feb022d5SAndrew Rist  *
20*feb022d5SAndrew Rist  *************************************************************/
21*feb022d5SAndrew Rist 
22*feb022d5SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SC_TOOL_H
25cdf0e10cSrcweir #define SC_TOOL_H
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <attrib.hxx>    //!!! noch noetig?????
28cdf0e10cSrcweir #include <document.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir // Defaultwerte
31cdf0e10cSrcweir const sal_uInt8	nDezStd = 0;		// Dezimalstellen fuer Standard-Zellen
32cdf0e10cSrcweir const sal_uInt8	nDezFloat = 2;	//        "         "  Float-Zellen
33cdf0e10cSrcweir 
34cdf0e10cSrcweir void		PutFormString( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Char *pString );
35cdf0e10cSrcweir 
36cdf0e10cSrcweir void		SetFormat( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt8 nFormat, sal_uInt8 nSt );
37cdf0e10cSrcweir 
38cdf0e10cSrcweir void		InitPage( void );
39cdf0e10cSrcweir 
40cdf0e10cSrcweir String		DosToSystem( sal_Char *pSource );
41cdf0e10cSrcweir 
42cdf0e10cSrcweir double		SnumToDouble( sal_Int16 nVal );
43cdf0e10cSrcweir 
44cdf0e10cSrcweir double          Snum32ToDouble( sal_uInt32 nValue );
45cdf0e10cSrcweir 
46cdf0e10cSrcweir typedef sal_uInt16 StampTyp;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #define MAKE_STAMP(nF,nS) ((nS&0x0F)+((nF&0x7F)*16))
49cdf0e10cSrcweir 			// Bit 0...3  = Bit 0...3 von Stellenzahl
50cdf0e10cSrcweir 			// Bit 4...10 = Bit 0...6 von Formatbyte
51cdf0e10cSrcweir 
52cdf0e10cSrcweir class FormIdent
53cdf0e10cSrcweir {
54cdf0e10cSrcweir private:
55cdf0e10cSrcweir 	StampTyp		nStamp;			// Identifikations-Schluessel
56cdf0e10cSrcweir 	SfxUInt32Item*	pAttr;			// zugehoeriges Attribut
57cdf0e10cSrcweir public:
FormIdent(void)58cdf0e10cSrcweir 					FormIdent( void )
59cdf0e10cSrcweir 					{
60cdf0e10cSrcweir 						nStamp = 0;
61cdf0e10cSrcweir 						pAttr = NULL;
62cdf0e10cSrcweir 					}
63cdf0e10cSrcweir 
FormIdent(sal_uInt8 nFormat,sal_uInt8 nSt,SfxUInt32Item & rAttr)64cdf0e10cSrcweir 					FormIdent( sal_uInt8 nFormat, sal_uInt8 nSt, SfxUInt32Item& rAttr )
65cdf0e10cSrcweir 					{
66cdf0e10cSrcweir 						nStamp = MAKE_STAMP( nFormat, nSt );
67cdf0e10cSrcweir 						pAttr = &rAttr;
68cdf0e10cSrcweir 					}
69cdf0e10cSrcweir 
FormIdent(sal_uInt8 nFormat,sal_uInt8 nSt)70cdf0e10cSrcweir 					FormIdent( sal_uInt8 nFormat, sal_uInt8 nSt )
71cdf0e10cSrcweir 					{
72cdf0e10cSrcweir 						nStamp = MAKE_STAMP( nFormat, nSt );
73cdf0e10cSrcweir 						pAttr = NULL;
74cdf0e10cSrcweir 					}
75cdf0e10cSrcweir 
operator ==(const FormIdent & rComp) const76cdf0e10cSrcweir 	sal_Bool			operator ==( const FormIdent& rComp ) const
77cdf0e10cSrcweir 					{
78cdf0e10cSrcweir 						return ( nStamp == rComp.nStamp );
79cdf0e10cSrcweir 					}
80cdf0e10cSrcweir 
operator ==(const StampTyp & rStamp) const81cdf0e10cSrcweir 	sal_Bool			operator ==( const StampTyp& rStamp ) const
82cdf0e10cSrcweir 					{
83cdf0e10cSrcweir 						return ( nStamp == rStamp );
84cdf0e10cSrcweir 					}
85cdf0e10cSrcweir 
GetStamp(void) const86cdf0e10cSrcweir 	StampTyp		GetStamp( void ) const
87cdf0e10cSrcweir 					{
88cdf0e10cSrcweir 						return nStamp;
89cdf0e10cSrcweir 					}
90cdf0e10cSrcweir 
GetAttr(void)91cdf0e10cSrcweir 	SfxUInt32Item*	GetAttr( void )
92cdf0e10cSrcweir 					{
93cdf0e10cSrcweir 						return pAttr;
94cdf0e10cSrcweir 					}
95cdf0e10cSrcweir 
SetStamp(sal_uInt8 nFormat,sal_uInt8 nSt)96cdf0e10cSrcweir 	void			SetStamp( sal_uInt8 nFormat, sal_uInt8 nSt )
97cdf0e10cSrcweir 					{
98cdf0e10cSrcweir 						nStamp = MAKE_STAMP( nFormat, nSt );
99cdf0e10cSrcweir 					}
100cdf0e10cSrcweir };
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 
103cdf0e10cSrcweir #define __nSize 2048
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 
108cdf0e10cSrcweir class FormCache
109cdf0e10cSrcweir {
110cdf0e10cSrcweir private:
111cdf0e10cSrcweir 	FormIdent			aIdents[ __nSize ];	//gepufferte Formate
112cdf0e10cSrcweir 	sal_Bool				bValid[ __nSize ];
113cdf0e10cSrcweir 	FormIdent			aCompareIdent;		// zum Vergleichen
114cdf0e10cSrcweir 	sal_uInt8				nDefaultFormat;		// Defaultformat der Datei
115cdf0e10cSrcweir 	SvNumberFormatter*	pFormTable;			// Value-Format-Table-Anker
116cdf0e10cSrcweir 	StampTyp			nIndex;
117cdf0e10cSrcweir 	LanguageType		eLanguage;			// Systemsprache
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 	SfxUInt32Item*		NewAttr( sal_uInt8 nFormat, sal_uInt8 nSt );
120cdf0e10cSrcweir public:
121cdf0e10cSrcweir 						FormCache( ScDocument*, sal_uInt8 nNewDefaultFormat = 0xFF );
122cdf0e10cSrcweir 						~FormCache();
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 	inline const SfxUInt32Item*	GetAttr( sal_uInt8 nFormat, sal_uInt8 nSt );
SetDefaultFormat(sal_uInt8 nD=0xFF)125cdf0e10cSrcweir 	void				SetDefaultFormat( sal_uInt8 nD = 0xFF )
126cdf0e10cSrcweir 						{
127cdf0e10cSrcweir 							nDefaultFormat = nD;
128cdf0e10cSrcweir 						}
129cdf0e10cSrcweir };
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 
GetAttr(sal_uInt8 nFormat,sal_uInt8 nSt)132cdf0e10cSrcweir inline const SfxUInt32Item* FormCache::GetAttr( sal_uInt8 nFormat, sal_uInt8 nSt )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir 	// PREC:	nFormat = Lotus-Format-Byte
135cdf0e10cSrcweir 	//			nSt = Stellenzahl
136cdf0e10cSrcweir 	// POST:	return = zu nFormat und nSt passendes SC-Format
137cdf0e10cSrcweir 	SfxUInt32Item*		pAttr;
138cdf0e10cSrcweir 	SfxUInt32Item*		pRet;
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 	aCompareIdent.SetStamp( nFormat, nSt );
141cdf0e10cSrcweir 	nIndex = aCompareIdent.GetStamp();
142cdf0e10cSrcweir 	DBG_ASSERT( nIndex < __nSize, "FormCache::GetAttr(): Uuuuuuups... so nicht!" );
143cdf0e10cSrcweir 	if( bValid[ nIndex ] )
144cdf0e10cSrcweir 		pRet = aIdents[ nIndex ].GetAttr();
145cdf0e10cSrcweir 	else
146cdf0e10cSrcweir 	{
147cdf0e10cSrcweir 		// neues Attribut anlegen
148cdf0e10cSrcweir 		pAttr = NewAttr( nFormat, nSt );
149cdf0e10cSrcweir 		DBG_ASSERT( pAttr, "FormCache::GetAttr(): Nix Speicherus" );
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 		aIdents[ nIndex ] = FormIdent( nFormat, nSt, *pAttr );
152cdf0e10cSrcweir 		bValid[ nIndex ] = sal_True;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 		pRet = pAttr;
155cdf0e10cSrcweir 	}
156cdf0e10cSrcweir 	return pRet;
157cdf0e10cSrcweir }
158cdf0e10cSrcweir 
159cdf0e10cSrcweir #endif
160cdf0e10cSrcweir 
161