Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _DXFGRPRD_HXX
21 : #define _DXFGRPRD_HXX
22 :
23 : #include <sal/types.h>
24 :
25 : #include <tools/stream.hxx>
26 :
27 : #define DXF_MAX_STRING_LEN 256 // Max Stringlaenge (ohne die 0)
28 :
29 :
30 : class DXFGroupReader
31 : {
32 :
33 : public:
34 :
35 : // Anmerkkung:
36 : // sizeof(DXFGroupReader) ist gross, also nur dynamisch anlegen!
37 :
38 : DXFGroupReader( SvStream & rIStream, sal_uInt16 nMinPercent, sal_uInt16 nMaxPercent );
39 :
40 : sal_Bool GetStatus() const;
41 :
42 : void SetError();
43 :
44 : sal_uInt16 Read();
45 : // Liesst die naechste Gruppe ein und liefert den Gruppencode zurueck.
46 : // Im Falle eines Fehlers liefert GetStatus() sal_False, Gruppencode wird 0
47 : // gesetzt, und es wird SetS(0,"EOF") ausgefuehrt.
48 :
49 : sal_uInt16 GetG() const;
50 : // Liefert den letzten Gruppencode (also was Read() zuletzt lieferte)
51 :
52 : long GetI() const;
53 : // Liefert den Integer-Wert zur Gruppe, die vorher mit Read() gelesen wurde.
54 : // Dabei muss es sich um einen Gruppencode fuer den Datentyp Integer
55 : // gehandelt haben, wenn nicht, wird 0 gelieferet.
56 :
57 : double GetF() const;
58 : // Liefert den Floatingpoint-Wert zur Gruppe, die vorher mit Read() gelesen wurde.
59 : // Dabei muss es sich um einen Gruppencode fuer den Datentyp Floatingpoint
60 : // gehandelt haben, wenn nicht, wird 0 geliefert.
61 :
62 : const char * GetS() const;
63 : // Liefert den String zur Gruppe, die vorher mit Read() gelesen wurde.
64 : // Dabei muss es sich um einen Gruppencode fuer den Datentyp String
65 : // gehandelt haben, wenn nicht, wird NULL geliefert.
66 :
67 : // Folgende drei Methoden arbeiten wie die obigen, nur kann auch ein anderer als der
68 : // aktuelle Gruppencode angegeben werden. (DXFGroupReader speichert die Parameter
69 : // zu allen Gruppencodes. Dadurch ist es moeglich, dass zunaechst mit Read() einige
70 : // verschiedene Gruppen eingelesen werden, bevor sie ausgewertet werden.)
71 : long GetI(sal_uInt16 nG) const;
72 : double GetF(sal_uInt16 nG) const;
73 : const char * GetS(sal_uInt16 nG) const;
74 :
75 : // Mit folgenden Methoden koennen die aktuell gespeicherten Werte zu den
76 : // Gruppencodes veraendert werden. (z.B. um Defaultwerte zu setzen, bevor
77 : // 'blind' eine Menge von Gruppen eingelesen wird.)
78 : void SetF(sal_uInt16 nG, double fF);
79 : void SetS(sal_uInt16 nG, const char * sS); // (wird kopiert)
80 :
81 : private:
82 :
83 : void ReadLine(char * ptgt);
84 : long ReadI();
85 : double ReadF();
86 : void ReadS(char * ptgt);
87 :
88 : SvStream & rIS;
89 : sal_uInt16 nIBuffSize,nIBuffPos;
90 : sal_Bool bStatus;
91 : sal_uInt16 nLastG;
92 : sal_uLong nGCount;
93 :
94 : sal_uLong nMinPercent;
95 : sal_uLong nMaxPercent;
96 : sal_uLong nLastPercent;
97 : sal_uLong nFileSize;
98 :
99 : char S0_9 [10][DXF_MAX_STRING_LEN+1]; // Strings Gruppencodes 0..9
100 : double F10_59 [50]; // Floats Gruppencodes 10..59
101 : long I60_79 [20]; // Integers Gruppencodes 60..79
102 : long I90_99 [10];
103 : char S100 [DXF_MAX_STRING_LEN+1];
104 : char S102 [DXF_MAX_STRING_LEN+1];
105 : double F140_147 [ 8]; // Floats Gruppencodes 140..147
106 : long I170_175 [ 6]; // Integers Gruppencodes 170..175
107 : double F210_239 [30]; // Floats Gruppencodes 210..239
108 : char S999_1009 [11][DXF_MAX_STRING_LEN+1]; // Strings Gruppencodes 999..1009
109 : double F1010_1059[50]; // Floats Gruppencodes 1010..1059
110 : long I1060_1079[20]; // Integers Gruppencodes 1060..1079
111 :
112 : };
113 :
114 :
115 0 : inline sal_Bool DXFGroupReader::GetStatus() const
116 : {
117 0 : return bStatus;
118 : }
119 :
120 :
121 0 : inline void DXFGroupReader::SetError()
122 : {
123 0 : bStatus=sal_False;
124 0 : }
125 :
126 0 : inline sal_uInt16 DXFGroupReader::GetG() const
127 : {
128 0 : return nLastG;
129 : }
130 :
131 0 : inline long DXFGroupReader::GetI() const
132 : {
133 0 : return GetI(nLastG);
134 : }
135 :
136 0 : inline double DXFGroupReader::GetF() const
137 : {
138 0 : return GetF(nLastG);
139 : }
140 :
141 0 : inline const char * DXFGroupReader::GetS() const
142 : {
143 0 : return GetS(nLastG);
144 : }
145 :
146 : #endif
147 :
148 :
149 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|