Update ooo320-m1
[ooovba.git] / sc / source / filter / inc / dif.hxx
blob270878bc645913ca80bd547fabd9afc2192040be
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dif.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #ifndef SC_DIF_HXX
33 #define SC_DIF_HXX
35 #include <tools/debug.hxx>
36 #include <tools/list.hxx>
37 #include <tools/string.hxx>
38 #include "global.hxx"
39 #include "address.hxx"
42 class SvStream;
43 class SvNumberFormatter;
44 class ScDocument;
45 class ScPatternAttr;
47 extern const sal_Unicode pKeyTABLE[];
48 extern const sal_Unicode pKeyVECTORS[];
49 extern const sal_Unicode pKeyTUPLES[];
50 extern const sal_Unicode pKeyDATA[];
51 extern const sal_Unicode pKeyBOT[];
52 extern const sal_Unicode pKeyEOD[];
53 extern const sal_Unicode pKeyTRUE[];
54 extern const sal_Unicode pKeyFALSE[];
55 extern const sal_Unicode pKeyNA[];
56 extern const sal_Unicode pKeyV[];
57 extern const sal_Unicode pKey1_0[];
60 enum TOPIC
62 T_UNKNOWN,
63 T_TABLE, T_VECTORS, T_TUPLES, T_DATA, T_LABEL, T_COMMENT, T_SIZE,
64 T_PERIODICITY, T_MAJORSTART, T_MINORSTART, T_TRUELENGTH, T_UINITS,
65 T_DISPLAYUNITS,
66 T_END
69 enum DATASET { D_BOT, D_EOD, D_NUMERIC, D_STRING, D_UNKNOWN, D_SYNT_ERROR };
72 class DifParser
74 public:
75 String aData;
76 double fVal;
77 UINT32 nVector;
78 UINT32 nVal;
79 UINT32 nNumFormat;
80 CharSet eCharSet;
81 private:
82 SvNumberFormatter* pNumFormatter;
83 SvStream& rIn;
84 BOOL bPlain;
85 String aLookAheadLine;
87 bool ReadNextLine( String& rStr );
88 bool LookAhead();
89 DATASET GetNumberDataset( const sal_Unicode* pPossibleNumericData );
90 static inline BOOL IsBOT( const sal_Unicode* pRef );
91 static inline BOOL IsEOD( const sal_Unicode* pRef );
92 static inline BOOL Is1_0( const sal_Unicode* pRef );
93 public:
94 DifParser( SvStream&, const UINT32 nOption, ScDocument&, CharSet );
96 TOPIC GetNextTopic( void );
98 DATASET GetNextDataset( void );
100 const sal_Unicode* ScanIntVal( const sal_Unicode* pStart, UINT32& rRet );
101 BOOL ScanFloatVal( const sal_Unicode* pStart );
103 inline BOOL IsNumber( const sal_Unicode cChar );
104 inline BOOL IsNumberEnding( const sal_Unicode cChar );
106 static inline BOOL IsV( const sal_Unicode* pRef );
108 inline BOOL IsPlain( void ) const;
112 inline BOOL DifParser::IsBOT( const sal_Unicode* pRef )
114 return ( pRef[ 0 ] == pKeyBOT[0] &&
115 pRef[ 1 ] == pKeyBOT[1] &&
116 pRef[ 2 ] == pKeyBOT[2] &&
117 pRef[ 3 ] == pKeyBOT[3] );
121 inline BOOL DifParser::IsEOD( const sal_Unicode* pRef )
123 return ( pRef[ 0 ] == pKeyEOD[0] &&
124 pRef[ 1 ] == pKeyEOD[1] &&
125 pRef[ 2 ] == pKeyEOD[2] &&
126 pRef[ 3 ] == pKeyEOD[3] );
130 inline BOOL DifParser::Is1_0( const sal_Unicode* pRef )
132 return ( pRef[ 0 ] == pKey1_0[0] &&
133 pRef[ 1 ] == pKey1_0[1] &&
134 pRef[ 2 ] == pKey1_0[2] &&
135 pRef[ 3 ] == pKey1_0[3] );
139 inline BOOL DifParser::IsV( const sal_Unicode* pRef )
141 return ( pRef[ 0 ] == pKeyV[0] &&
142 pRef[ 1 ] == pKeyV[1] );
146 inline BOOL DifParser::IsNumber( const sal_Unicode cChar )
148 return ( cChar >= '0' && cChar <= '9' );
152 inline BOOL DifParser::IsNumberEnding( const sal_Unicode cChar )
154 return ( cChar == 0x00 );
158 inline BOOL DifParser::IsPlain( void ) const
160 return bPlain;
166 class DifAttrCache;
167 class ScPatternAttr;
170 class DifColumn : private List
172 private:
173 friend class DifAttrCache;
174 struct ENTRY
176 UINT32 nNumFormat;
178 SCROW nStart;
179 SCROW nEnd;
182 ENTRY* pAkt;
184 inline DifColumn( void );
185 ~DifColumn();
186 void SetLogical( SCROW nRow );
187 void SetNumFormat( SCROW nRow, const UINT32 nNumFormat );
188 void NewEntry( const SCROW nPos, const UINT32 nNumFormat );
189 void Apply( ScDocument&, const SCCOL nCol, const SCTAB nTab, const ScPatternAttr& );
190 void Apply( ScDocument &rDoc, const SCCOL nCol, const SCTAB nTab );
191 public: // geht niemanden etwas an...
195 inline DifColumn::DifColumn( void )
197 pAkt = NULL;
203 class DifAttrCache
205 private:
206 DifColumn** ppCols;
207 BOOL bPlain;
208 public:
209 DifAttrCache( const BOOL bPlain );
210 ~DifAttrCache();
211 inline void SetLogical( const SCCOL nCol, const SCROW nRow );
212 void SetNumFormat( const SCCOL nCol, const SCROW nRow, const UINT32 nNumFormat );
213 void Apply( ScDocument&, SCTAB nTab );
217 inline void DifAttrCache::SetLogical( const SCCOL nCol, const SCROW nRow )
219 DBG_ASSERT( ValidCol(nCol), "-DifAttrCache::SetLogical(): Col zu gross!" );
220 DBG_ASSERT( bPlain, "*DifAttrCache::SetLogical(): muss Plain sein!" );
222 if( !ppCols[ nCol ] )
223 ppCols[ nCol ] = new DifColumn;
224 ppCols[ nCol ]->SetLogical( nRow );
228 #endif