fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / filter / inc / tool.h
blob3e6e799c73d1dbf9b5f9decf6dbce60ccab843f5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <attrib.hxx>
24 #include <document.hxx>
25 #include <osl/diagnose.h>
27 // Defaultwerte
28 const sal_uInt8 nDezStd = 0; // Dezimalstellen fuer Standard-Zellen
29 const sal_uInt8 nDezFloat = 2; // " " Float-Zellen
31 struct LotusContext;
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
49 class FormIdent
51 private:
52 StampTyp nStamp; // Identifikations-Schluessel
53 SfxUInt32Item* pAttr; // zugehoeriges Attribut
54 public:
55 FormIdent( void )
57 nStamp = 0;
58 pAttr = NULL;
61 FormIdent( sal_uInt8 nFormat, sal_uInt8 nSt, SfxUInt32Item& rAttr )
63 nStamp = MAKE_STAMP( nFormat, nSt );
64 pAttr = &rAttr;
67 FormIdent( sal_uInt8 nFormat, sal_uInt8 nSt )
69 nStamp = MAKE_STAMP( nFormat, nSt );
70 pAttr = NULL;
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
85 return nStamp;
88 SfxUInt32Item* GetAttr( void )
90 return pAttr;
93 void SetStamp( sal_uInt8 nFormat, sal_uInt8 nSt )
95 nStamp = MAKE_STAMP( nFormat, nSt );
100 #define __nSize 2048
103 class FormCache
105 private:
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
111 StampTyp nIndex;
112 LanguageType eLanguage; // Systemsprache
114 SfxUInt32Item* NewAttr( sal_uInt8 nFormat, sal_uInt8 nSt );
115 public:
116 FormCache( ScDocument*, sal_uInt8 nNewDefaultFormat = 0xFF );
117 ~FormCache();
119 inline const SfxUInt32Item* GetAttr( sal_uInt8 nFormat, sal_uInt8 nSt );
120 void SetDefaultFormat( sal_uInt8 nD = 0xFF )
122 nDefaultFormat = nD;
127 inline const SfxUInt32Item* FormCache::GetAttr( sal_uInt8 nFormat, sal_uInt8 nSt )
129 // PREC: nFormat = Lotus-Format-Byte
130 // nSt = Stellenzahl
131 // POST: return = zu nFormat und nSt passendes SC-Format
132 SfxUInt32Item* pAttr;
133 SfxUInt32Item* pRet;
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();
140 else
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;
149 pRet = pAttr;
151 return pRet;
154 #endif
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */