1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_TOOL_H
21 #define INCLUDED_SC_SOURCE_FILTER_INC_TOOL_H
24 #include <document.hxx>
25 #include <osl/diagnose.h>
28 const sal_uInt8 nDezStd
= 0; // Dezimalstellen fuer Standard-Zellen
29 const sal_uInt8 nDezFloat
= 2; // " " Float-Zellen
33 void PutFormString(LotusContext
& rContext
, SCCOL nCol
, SCROW nRow
, SCTAB nTab
, sal_Char
*pString
);
35 void SetFormat(LotusContext
& rContext
, SCCOL nCol
, SCROW nRow
, SCTAB nTab
, sal_uInt8 nFormat
, sal_uInt8 nSt
);
37 OUString
DosToSystem( sal_Char
*pSource
);
39 double SnumToDouble( sal_Int16 nVal
);
41 double Snum32ToDouble( sal_uInt32 nValue
);
43 typedef sal_uInt16 StampTyp
;
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
52 StampTyp nStamp
; // Identifikations-Schluessel
53 SfxUInt32Item
* pAttr
; // zugehoeriges Attribut
61 FormIdent( sal_uInt8 nFormat
, sal_uInt8 nSt
, SfxUInt32Item
& rAttr
)
63 nStamp
= MAKE_STAMP( nFormat
, nSt
);
67 FormIdent( sal_uInt8 nFormat
, sal_uInt8 nSt
)
69 nStamp
= MAKE_STAMP( nFormat
, nSt
);
73 bool operator ==( const FormIdent
& rComp
) const
75 return ( nStamp
== rComp
.nStamp
);
78 bool operator ==( const StampTyp
& rStamp
) const
80 return ( nStamp
== rStamp
);
83 StampTyp
GetStamp( void ) const
88 SfxUInt32Item
* GetAttr( void )
93 void SetStamp( sal_uInt8 nFormat
, sal_uInt8 nSt
)
95 nStamp
= MAKE_STAMP( nFormat
, nSt
);
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
112 LanguageType eLanguage
; // Systemsprache
114 SfxUInt32Item
* NewAttr( sal_uInt8 nFormat
, sal_uInt8 nSt
);
116 FormCache( ScDocument
*, sal_uInt8 nNewDefaultFormat
= 0xFF );
119 inline const SfxUInt32Item
* GetAttr( sal_uInt8 nFormat
, sal_uInt8 nSt
);
120 void SetDefaultFormat( sal_uInt8 nD
= 0xFF )
127 inline const SfxUInt32Item
* FormCache::GetAttr( sal_uInt8 nFormat
, sal_uInt8 nSt
)
129 // PREC: nFormat = Lotus-Format-Byte
131 // POST: return = zu nFormat und nSt passendes SC-Format
132 SfxUInt32Item
* pAttr
;
135 aCompareIdent
.SetStamp( nFormat
, nSt
);
136 nIndex
= aCompareIdent
.GetStamp();
137 OSL_ENSURE( nIndex
< __nSize
, "FormCache::GetAttr(): Oups... not this way!" );
138 if( bValid
[ nIndex
] )
139 pRet
= aIdents
[ nIndex
].GetAttr();
142 // neues Attribut anlegen
143 pAttr
= NewAttr( nFormat
, nSt
);
144 OSL_ENSURE( pAttr
, "FormCache::GetAttr(): Nothing to save" );
146 aIdents
[ nIndex
] = FormIdent( nFormat
, nSt
, *pAttr
);
147 bValid
[ nIndex
] = sal_True
;
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */