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 .
22 #include <document.hxx>
24 #include <i18nlangtag/lang.h>
25 #include <svl/intitem.hxx>
27 #include <osl/diagnose.h>
30 const sal_uInt8 nFractionalStd
= 0; // Number of digits in fractional part for standard cells
31 const sal_uInt8 nFractionalFloat
= 2; // " " " " float cells
35 void PutFormString(LotusContext
& rContext
, SCCOL nCol
, SCROW nRow
, SCTAB nTab
, char *pString
);
37 void SetFormat(LotusContext
& rContext
, SCCOL nCol
, SCROW nRow
, SCTAB nTab
, sal_uInt8 nFormat
, sal_uInt8 nSt
);
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 of number of digits
47 // Bit 4...10 = Bit 0...6 of Formatbyte
52 StampTyp nStamp
; // ID key
53 std::unique_ptr
<SfxUInt32Item
> pAttr
; // associated attribute
61 FormIdent( sal_uInt8 nFormat
, sal_uInt8 nSt
, SfxUInt32Item
& rAttr
)
63 nStamp
= MAKE_STAMP( nFormat
, nSt
);
67 StampTyp
GetStamp( void ) const
72 SfxUInt32Item
* GetAttr( void )
77 void SetStamp( sal_uInt8 nFormat
, sal_uInt8 nSt
)
79 nStamp
= MAKE_STAMP( nFormat
, nSt
);
90 FormIdent aIdents
[ nSize_
]; //buffered formats
91 bool bValid
[ nSize_
];
92 FormIdent aCompareIdent
; // for comparing
93 SvNumberFormatter
* pFormTable
; // value format table anchor
95 LanguageType eLanguage
; // System language
97 SfxUInt32Item
* NewAttr( sal_uInt8 nFormat
, sal_uInt8 nSt
);
99 FormCache( const ScDocument
* );
102 inline const SfxUInt32Item
* GetAttr( sal_uInt8 nFormat
, sal_uInt8 nSt
);
106 inline const SfxUInt32Item
* FormCache::GetAttr( sal_uInt8 nFormat
, sal_uInt8 nSt
)
108 // PREC: nFormat = Lotus format byte
109 // nSt = Number of digit
110 // POST: return = SC-format fitting nFormat and nSt
111 SfxUInt32Item
* pAttr
;
114 aCompareIdent
.SetStamp( nFormat
, nSt
);
115 nIndex
= aCompareIdent
.GetStamp();
116 OSL_ENSURE( nIndex
< nSize_
, "FormCache::GetAttr(): Oups... not this way!" );
117 if( bValid
[ nIndex
] )
118 pRet
= aIdents
[ nIndex
].GetAttr();
121 // create new attribute
122 pAttr
= NewAttr( nFormat
, nSt
);
123 assert(pAttr
&& "FormCache::GetAttr(): Nothing to save");
125 aIdents
[ nIndex
] = FormIdent( nFormat
, nSt
, *pAttr
);
126 bValid
[ nIndex
] = true;
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */