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
23 #include <i18nlangtag/lang.h>
24 #include <svl/intitem.hxx>
26 #include <osl/diagnose.h>
29 const sal_uInt8 nFractionalStd
= 0; // Number of digits in fractional part for standard cells
30 const sal_uInt8 nFractionalFloat
= 2; // " " " " float cells
34 void PutFormString(LotusContext
& rContext
, SCCOL nCol
, SCROW nRow
, SCTAB nTab
, sal_Char
*pString
);
36 void SetFormat(LotusContext
& rContext
, SCCOL nCol
, SCROW nRow
, SCTAB nTab
, sal_uInt8 nFormat
, sal_uInt8 nSt
);
38 double SnumToDouble( sal_Int16 nVal
);
40 double Snum32ToDouble( sal_uInt32 nValue
);
42 typedef sal_uInt16 StampTyp
;
44 #define MAKE_STAMP(nF,nS) ((nS&0x0F)+((nF&0x7F)*16))
45 // Bit 0...3 = Bit 0...3 of number of digits
46 // Bit 4...10 = Bit 0...6 of Formatbyte
51 StampTyp nStamp
; // ID key
52 std::unique_ptr
<SfxUInt32Item
> pAttr
; // associated attribute
60 FormIdent( sal_uInt8 nFormat
, sal_uInt8 nSt
, SfxUInt32Item
& rAttr
)
62 nStamp
= MAKE_STAMP( nFormat
, nSt
);
66 StampTyp
GetStamp( void ) const
71 SfxUInt32Item
* GetAttr( void )
76 void SetStamp( sal_uInt8 nFormat
, sal_uInt8 nSt
)
78 nStamp
= MAKE_STAMP( nFormat
, nSt
);
89 FormIdent aIdents
[ nSize_
]; //buffered formats
90 bool bValid
[ nSize_
];
91 FormIdent aCompareIdent
; // for comparing
92 SvNumberFormatter
* pFormTable
; // value format table anchor
94 LanguageType eLanguage
; // System language
96 SfxUInt32Item
* NewAttr( sal_uInt8 nFormat
, sal_uInt8 nSt
);
98 FormCache( const ScDocument
* );
101 inline const SfxUInt32Item
* GetAttr( sal_uInt8 nFormat
, sal_uInt8 nSt
);
105 inline const SfxUInt32Item
* FormCache::GetAttr( sal_uInt8 nFormat
, sal_uInt8 nSt
)
107 // PREC: nFormat = Lotus format byte
108 // nSt = Number of digit
109 // POST: return = SC-format fitting nFormat and nSt
110 SfxUInt32Item
* pAttr
;
113 aCompareIdent
.SetStamp( nFormat
, nSt
);
114 nIndex
= aCompareIdent
.GetStamp();
115 OSL_ENSURE( nIndex
< nSize_
, "FormCache::GetAttr(): Oups... not this way!" );
116 if( bValid
[ nIndex
] )
117 pRet
= aIdents
[ nIndex
].GetAttr();
120 // create new attribute
121 pAttr
= NewAttr( nFormat
, nSt
);
122 OSL_ENSURE( pAttr
, "FormCache::GetAttr(): Nothing to save" );
124 aIdents
[ nIndex
] = FormIdent( nFormat
, nSt
, *pAttr
);
125 bValid
[ nIndex
] = true;
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */