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 INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IDXF_DXFGRPRD_HXX
21 : #define INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IDXF_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 : // note:
36 : // sizeof(DXFGroupReader) is big, so only create dynamically
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 : // Reads next group and returns the group code.
46 : // In case of an error GetStatus() returns sal_False, group code will be set
47 : // to 0 and SetS(0,"EOF") will be executed.
48 :
49 : sal_uInt16 GetG() const;
50 : // Return the last group code (the one the last Read() did return).
51 :
52 : long GetI() const;
53 : // Returns the integer value of the group which was read earlier with Read().
54 : // This read must have returned a group code for datatype Integer.
55 : // If not 0 is returend
56 :
57 : double GetF() const;
58 : // Returns the floating point value of the group which was read earlier with Read().
59 : // This read must have returned a group code for datatype Floatingpoint.
60 : // If not 0 is returend
61 :
62 : const char * GetS() const;
63 : // Returns the string of the group which was read earlier with Read().
64 : // This read must have returned a group code for datatype String.
65 : // If not NULL is returend
66 :
67 : // The following three methods work like the above execp that a different than the
68 : // current group code can bet set. (DXFGroupReader stroes the parameters of all
69 : // group codes. Therefore it is possible to first Read() some groups and then analyze
70 : // them afterwards.)
71 :
72 : long GetI(sal_uInt16 nG) const;
73 : double GetF(sal_uInt16 nG) const;
74 : const char * GetS(sal_uInt16 nG) const;
75 :
76 : // The following methods can change the current values of group codes
77 : // (e.g. to set default values, before 'blindly' reading lots of groups)
78 :
79 : void SetF(sal_uInt16 nG, double fF);
80 : void SetS(); // (will be copied)
81 :
82 : private:
83 :
84 : void ReadLine(char * ptgt);
85 : long ReadI();
86 : double ReadF();
87 : void ReadS(char * ptgt);
88 :
89 : SvStream & rIS;
90 : sal_uInt16 nIBuffSize,nIBuffPos;
91 : sal_Bool bStatus;
92 : sal_uInt16 nLastG;
93 : sal_uLong nGCount;
94 :
95 : sal_uLong nMinPercent;
96 : sal_uLong nMaxPercent;
97 : sal_uLong nLastPercent;
98 : sal_uLong nFileSize;
99 :
100 : char S0_9 [10][DXF_MAX_STRING_LEN+1]; // Strings group codes 0..9
101 : double F10_59 [50]; // Floats group codes 10..59
102 : long I60_79 [20]; // Integers group codes 60..79
103 : long I90_99 [10];
104 : char S100 [DXF_MAX_STRING_LEN+1];
105 : char S102 [DXF_MAX_STRING_LEN+1];
106 : double F140_147 [ 8]; // Floats group codes 140..147
107 : long I170_175 [ 6]; // Integers group codes 170..175
108 : double F210_239 [30]; // Floats group codes 210..239
109 : char S999_1009 [11][DXF_MAX_STRING_LEN+1]; // Strings group codes 999..1009
110 : double F1010_1059[50]; // Floats group codes 1010..1059
111 : long I1060_1079[20]; // Integers group codes 1060..1079
112 :
113 : };
114 :
115 :
116 0 : inline sal_Bool DXFGroupReader::GetStatus() const
117 : {
118 0 : return bStatus;
119 : }
120 :
121 :
122 0 : inline void DXFGroupReader::SetError()
123 : {
124 0 : bStatus=sal_False;
125 0 : }
126 :
127 0 : inline sal_uInt16 DXFGroupReader::GetG() const
128 : {
129 0 : return nLastG;
130 : }
131 :
132 0 : inline long DXFGroupReader::GetI() const
133 : {
134 0 : return GetI(nLastG);
135 : }
136 :
137 0 : inline double DXFGroupReader::GetF() const
138 : {
139 0 : return GetF(nLastG);
140 : }
141 :
142 0 : inline const char * DXFGroupReader::GetS() const
143 : {
144 0 : return GetS(nLastG);
145 : }
146 :
147 : #endif
148 :
149 :
150 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|