Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _DXFGRPRD_HXX
30 : : #define _DXFGRPRD_HXX
31 : :
32 : : #include <svtools/fltcall.hxx>
33 : :
34 : : #define DXF_MAX_STRING_LEN 256 // Max Stringlaenge (ohne die 0)
35 : :
36 : :
37 : : class DXFGroupReader
38 : : {
39 : :
40 : : public:
41 : :
42 : : // Anmerkkung:
43 : : // sizeof(DXFGroupReader) ist gross, also nur dynamisch anlegen!
44 : :
45 : : DXFGroupReader( SvStream & rIStream, sal_uInt16 nMinPercent, sal_uInt16 nMaxPercent );
46 : :
47 : : sal_Bool GetStatus() const;
48 : :
49 : : void SetError();
50 : :
51 : : sal_uInt16 Read();
52 : : // Liesst die naechste Gruppe ein und liefert den Gruppencode zurueck.
53 : : // Im Falle eines Fehlers liefert GetStatus() sal_False, Gruppencode wird 0
54 : : // gesetzt, und es wird SetS(0,"EOF") ausgefuehrt.
55 : :
56 : : sal_uInt16 GetG() const;
57 : : // Liefert den letzten Gruppencode (also was Read() zuletzt lieferte)
58 : :
59 : : long GetI() const;
60 : : // Liefert den Integer-Wert zur Gruppe, die vorher mit Read() gelesen wurde.
61 : : // Dabei muss es sich um einen Gruppencode fuer den Datentyp Integer
62 : : // gehandelt haben, wenn nicht, wird 0 gelieferet.
63 : :
64 : : double GetF() const;
65 : : // Liefert den Floatingpoint-Wert zur Gruppe, die vorher mit Read() gelesen wurde.
66 : : // Dabei muss es sich um einen Gruppencode fuer den Datentyp Floatingpoint
67 : : // gehandelt haben, wenn nicht, wird 0 geliefert.
68 : :
69 : : const char * GetS() const;
70 : : // Liefert den String zur Gruppe, die vorher mit Read() gelesen wurde.
71 : : // Dabei muss es sich um einen Gruppencode fuer den Datentyp String
72 : : // gehandelt haben, wenn nicht, wird NULL geliefert.
73 : :
74 : : // Folgende drei Methoden arbeiten wie die obigen, nur kann auch ein anderer als der
75 : : // aktuelle Gruppencode angegeben werden. (DXFGroupReader speichert die Parameter
76 : : // zu allen Gruppencodes. Dadurch ist es moeglich, dass zunaechst mit Read() einige
77 : : // verschiedene Gruppen eingelesen werden, bevor sie ausgewertet werden.)
78 : : long GetI(sal_uInt16 nG) const;
79 : : double GetF(sal_uInt16 nG) const;
80 : : const char * GetS(sal_uInt16 nG) const;
81 : :
82 : : // Mit folgenden Methoden koennen die aktuell gespeicherten Werte zu den
83 : : // Gruppencodes veraendert werden. (z.B. um Defaultwerte zu setzen, bevor
84 : : // 'blind' eine Menge von Gruppen eingelesen wird.)
85 : : void SetF(sal_uInt16 nG, double fF);
86 : : void SetS(sal_uInt16 nG, const char * sS); // (wird kopiert)
87 : :
88 : : private:
89 : :
90 : : void ReadLine(char * ptgt);
91 : : long ReadI();
92 : : double ReadF();
93 : : void ReadS(char * ptgt);
94 : :
95 : : SvStream & rIS;
96 : : sal_uInt16 nIBuffSize,nIBuffPos;
97 : : sal_Bool bStatus;
98 : : sal_uInt16 nLastG;
99 : : sal_uLong nGCount;
100 : :
101 : : sal_uLong nMinPercent;
102 : : sal_uLong nMaxPercent;
103 : : sal_uLong nLastPercent;
104 : : sal_uLong nFileSize;
105 : :
106 : : char S0_9 [10][DXF_MAX_STRING_LEN+1]; // Strings Gruppencodes 0..9
107 : : double F10_59 [50]; // Floats Gruppencodes 10..59
108 : : long I60_79 [20]; // Integers Gruppencodes 60..79
109 : : long I90_99 [10];
110 : : char S100 [DXF_MAX_STRING_LEN+1];
111 : : char S102 [DXF_MAX_STRING_LEN+1];
112 : : double F140_147 [ 8]; // Floats Gruppencodes 140..147
113 : : long I170_175 [ 6]; // Integers Gruppencodes 170..175
114 : : double F210_239 [30]; // Floats Gruppencodes 210..239
115 : : char S999_1009 [11][DXF_MAX_STRING_LEN+1]; // Strings Gruppencodes 999..1009
116 : : double F1010_1059[50]; // Floats Gruppencodes 1010..1059
117 : : long I1060_1079[20]; // Integers Gruppencodes 1060..1079
118 : :
119 : : };
120 : :
121 : :
122 : 0 : inline sal_Bool DXFGroupReader::GetStatus() const
123 : : {
124 : 0 : return bStatus;
125 : : }
126 : :
127 : :
128 : 0 : inline void DXFGroupReader::SetError()
129 : : {
130 : 0 : bStatus=sal_False;
131 : 0 : }
132 : :
133 : 0 : inline sal_uInt16 DXFGroupReader::GetG() const
134 : : {
135 : 0 : return nLastG;
136 : : }
137 : :
138 : 0 : inline long DXFGroupReader::GetI() const
139 : : {
140 : 0 : return GetI(nLastG);
141 : : }
142 : :
143 : 0 : inline double DXFGroupReader::GetF() const
144 : : {
145 : 0 : return GetF(nLastG);
146 : : }
147 : :
148 : 0 : inline const char * DXFGroupReader::GetS() const
149 : : {
150 : 0 : return GetS(nLastG);
151 : : }
152 : :
153 : : #endif
154 : :
155 : :
156 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|