LibreOffice Module vcl (master)  1
dxftblrd.cxx
Go to the documentation of this file.
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 
21 #include "dxftblrd.hxx"
22 
23 //----------------------------------DXFLType-----------------------------------
24 
26  : pSucc(nullptr)
27  , nFlags(0)
28  , nDashCount(0)
29  , fPatternLength(0.0)
30 {
31 }
32 
34 {
35  tools::Long nDashIndex=-1;
36 
37  while (rDGR.Read()!=0)
38  {
39  switch (rDGR.GetG())
40  {
41  case 2:
42  m_sName = rDGR.GetS();
43  break;
44  case 3:
45  m_sDescription = rDGR.GetS();
46  break;
47  case 70:
48  nFlags=rDGR.GetI();
49  break;
50  case 73:
51  if (nDashIndex!=-1)
52  {
53  rDGR.SetError();
54  return;
55  }
56  nDashCount=rDGR.GetI();
58  {
60  }
61  nDashIndex=0;
62  break;
63  case 40: fPatternLength=rDGR.GetF(); break;
64  case 49:
65  if (nDashCount==-1)
66  {
67  rDGR.SetError();
68  return;
69  }
70  if (nDashIndex < nDashCount)
71  {
72  if (nDashIndex < 0)
73  {
74  rDGR.SetError();
75  return;
76  }
77  fDash[nDashIndex++] = rDGR.GetF();
78  }
79  break;
80  }
81  }
82 }
83 
84 //----------------------------------DXFLayer-----------------------------------
85 
87 {
88  pSucc=nullptr;
89  nFlags=0;
90  nColor=-1;
91 }
92 
94 {
95  while (rDGR.Read()!=0)
96  {
97  switch(rDGR.GetG())
98  {
99  case 2:
100  m_sName = rDGR.GetS();
101  break;
102  case 6:
103  m_sLineType = rDGR.GetS();
104  break;
105  case 70:
106  nFlags=rDGR.GetI();
107  break;
108  case 62:
109  nColor=rDGR.GetI();
110  break;
111  }
112  }
113 }
114 
115 //----------------------------------DXFStyle-----------------------------------
116 
118 {
119  pSucc=nullptr;
120  nFlags=0;
121  fHeight=0.0;
122  fWidthFak=1.0;
123  fOblAngle=0.0;
124  nTextGenFlags=0;
125  fLastHeightUsed=0.0;
126 }
127 
129 {
130  while (rDGR.Read()!=0)
131  {
132  switch(rDGR.GetG())
133  {
134  case 2:
135  m_sName = rDGR.GetS();
136  break;
137  case 3:
138  m_sPrimFontFile = rDGR.GetS();
139  break;
140  case 4:
141  m_sBigFontFile = rDGR.GetS();
142  break;
143  case 70:
144  nFlags=rDGR.GetI();
145  break;
146  case 40:
147  fHeight=rDGR.GetF();
148  break;
149  case 41:
150  fWidthFak=rDGR.GetF();
151  break;
152  case 42:
153  fLastHeightUsed=rDGR.GetF();
154  break;
155  case 50:
156  fOblAngle=rDGR.GetF();
157  break;
158  case 71:
159  nTextGenFlags=rDGR.GetI();
160  break;
161  }
162  }
163 }
164 
165 //----------------------------------DXFVPort-----------------------------------
166 
168  : pSucc(nullptr)
169  , nFlags(0)
170  , fMinX(0.0)
171  , fMinY(0.0)
172  , fMaxX(0.0)
173  , fMaxY(0.0)
174  , fCenterX(0.0)
175  , fCenterY(0.0)
176  , fSnapBaseX(0.0)
177  , fSnapBaseY(0.0)
178  , fSnapSpacingX(0.0)
179  , fSnapSpacingY(0.0)
180  , fGridX(0.0)
181  , fGridY(0.0)
182  , aDirection(DXFVector(0.0, 0.0, 1.0))
183  , fHeight(0.0)
184  , fAspectRatio(0.0)
185  , fLensLength(0.0)
186  , fFrontClipPlane(0.0)
187  , fBackClipPlane(0.0)
188  , fTwistAngle(0.0)
189  , nStatus(0)
190  , nID(0)
191  , nMode(0)
192  , nCircleZoomPercent(0)
193  , nFastZoom(0)
194  , nUCSICON(0)
195  , nSnap(0)
196  , nGrid(0)
197  , nSnapStyle(0)
198  , nSnapIsopair(0)
199 {
200 }
201 
203 {
204  while (rDGR.Read()!=0)
205  {
206  switch(rDGR.GetG())
207  {
208  case 2:
209  m_sName = rDGR.GetS();
210  break;
211  case 10: fMinX=rDGR.GetF(); break;
212  case 11: fMaxX=rDGR.GetF(); break;
213  case 12: fCenterX=rDGR.GetF(); break;
214  case 13: fSnapBaseX=rDGR.GetF(); break;
215  case 14: fSnapSpacingX=rDGR.GetF(); break;
216  case 15: fGridX=rDGR.GetF(); break;
217  case 16: aDirection.fx=rDGR.GetF(); break;
218  case 17: aTarget.fx=rDGR.GetF(); break;
219  case 20: fMinY=rDGR.GetF(); break;
220  case 21: fMaxY=rDGR.GetF(); break;
221  case 22: fCenterY=rDGR.GetF(); break;
222  case 23: fSnapBaseY=rDGR.GetF(); break;
223  case 24: fSnapSpacingY=rDGR.GetF(); break;
224  case 25: fGridY=rDGR.GetF(); break;
225  case 26: aDirection.fy=rDGR.GetF(); break;
226  case 27: aTarget.fy=rDGR.GetF(); break;
227  case 36: aDirection.fz=rDGR.GetF(); break;
228  case 37: aTarget.fz=rDGR.GetF(); break;
229  case 40: fHeight=rDGR.GetF(); break;
230  case 41: fAspectRatio=rDGR.GetF(); break;
231  case 42: fLensLength=rDGR.GetF(); break;
232  case 43: fFrontClipPlane=rDGR.GetF(); break;
233  case 44: fBackClipPlane=rDGR.GetF(); break;
234  case 51: fTwistAngle=rDGR.GetF(); break;
235  case 68: nStatus=rDGR.GetI(); break;
236  case 69: nID=rDGR.GetI(); break;
237  case 70: nFlags=rDGR.GetI(); break;
238  case 71: nMode=rDGR.GetI(); break;
239  case 72: nCircleZoomPercent=rDGR.GetI(); break;
240  case 73: nFastZoom=rDGR.GetI(); break;
241  case 74: nUCSICON=rDGR.GetI(); break;
242  case 75: nSnap=rDGR.GetI(); break;
243  case 76: nGrid=rDGR.GetI(); break;
244  case 77: nSnapStyle=rDGR.GetI(); break;
245  case 78: nSnapIsopair=rDGR.GetI(); break;
246  }
247  }
248 }
249 
250 //----------------------------------DXFTables----------------------------------
251 
252 
254 {
255  pLTypes=nullptr;
256  pLayers=nullptr;
257  pStyles=nullptr;
258  pVPorts=nullptr;
259 }
260 
261 
263 {
264  Clear();
265 }
266 
267 
269 {
270  DXFLType * * ppLT, * pLT;
271  DXFLayer * * ppLa, * pLa;
272  DXFStyle * * ppSt, * pSt;
273  DXFVPort * * ppVP, * pVP;
274 
275  ppLT=&pLTypes;
276  while(*ppLT!=nullptr) ppLT=&((*ppLT)->pSucc);
277 
278  ppLa=&pLayers;
279  while(*ppLa!=nullptr) ppLa=&((*ppLa)->pSucc);
280 
281  ppSt=&pStyles;
282  while(*ppSt!=nullptr) ppSt=&((*ppSt)->pSucc);
283 
284  ppVP=&pVPorts;
285  while(*ppVP!=nullptr) ppVP=&((*ppVP)->pSucc);
286 
287  for (;;) {
288  while (rDGR.GetG()!=0) rDGR.Read();
289  if (rDGR.GetS() == "EOF" ||
290  rDGR.GetS() == "ENDSEC") break;
291  else if (rDGR.GetS() == "LTYPE") {
292  pLT=new DXFLType;
293  pLT->Read(rDGR);
294  *ppLT=pLT;
295  ppLT=&(pLT->pSucc);
296  }
297  else if (rDGR.GetS() == "LAYER") {
298  pLa=new DXFLayer;
299  pLa->Read(rDGR);
300  *ppLa=pLa;
301  ppLa=&(pLa->pSucc);
302  }
303  else if (rDGR.GetS() == "STYLE") {
304  pSt=new DXFStyle;
305  pSt->Read(rDGR);
306  *ppSt=pSt;
307  ppSt=&(pSt->pSucc);
308  }
309  else if (rDGR.GetS() == "VPORT") {
310  pVP=new DXFVPort;
311  pVP->Read(rDGR);
312  *ppVP=pVP;
313  ppVP=&(pVP->pSucc);
314  }
315  else rDGR.Read();
316  }
317 }
318 
319 
321 {
322  DXFLType * pLT;
323  DXFLayer * pLa;
324  DXFStyle * pSt;
325  DXFVPort * pVP;
326 
327  while (pStyles!=nullptr) {
328  pSt=pStyles;
329  pStyles=pSt->pSucc;
330  delete pSt;
331  }
332  while (pLayers!=nullptr) {
333  pLa=pLayers;
334  pLayers=pLa->pSucc;
335  delete pLa;
336  }
337  while (pLTypes!=nullptr) {
338  pLT=pLTypes;
339  pLTypes=pLT->pSucc;
340  delete pLT;
341  }
342  while (pVPorts!=nullptr) {
343  pVP=pVPorts;
344  pVPorts=pVP->pSucc;
345  delete pVP;
346  }
347 }
348 
349 
350 DXFLType * DXFTables::SearchLType(std::string_view rName) const
351 {
352  DXFLType * p;
353  for (p=pLTypes; p!=nullptr; p=p->pSucc) {
354  if (rName == p->m_sName) break;
355  }
356  return p;
357 }
358 
359 
360 DXFLayer * DXFTables::SearchLayer(std::string_view rName) const
361 {
362  DXFLayer * p;
363  for (p=pLayers; p!=nullptr; p=p->pSucc) {
364  if (rName == p->m_sName) break;
365  }
366  return p;
367 }
368 
369 
370 DXFVPort * DXFTables::SearchVPort(std::string_view rName) const
371 {
372  DXFVPort * p;
373  for (p=pVPorts; p!=nullptr; p=p->pSucc) {
374  if (rName == p->m_sName) break;
375  }
376  return p;
377 }
378 
379 
380 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DXFVPort * pSucc
Definition: dxftblrd.hxx:104
void Read(DXFGroupReader &rDGR)
Definition: dxftblrd.cxx:268
double fx
Definition: dxfvec.hxx:55
double GetF() const
Definition: dxfgrprd.hxx:102
DXFLType * pSucc
Definition: dxftblrd.hxx:40
double fAspectRatio
Definition: dxftblrd.hxx:123
double fCenterY
Definition: dxftblrd.hxx:113
DXFVPort * pVPorts
Definition: dxftblrd.hxx:152
double fCenterX
Definition: dxftblrd.hxx:112
OString m_sName
Definition: dxftblrd.hxx:63
tools::Long nDashCount
Definition: dxftblrd.hxx:45
tools::Long GetI() const
Definition: dxfgrprd.hxx:97
DXFLayer * pSucc
Definition: dxftblrd.hxx:61
void Read(DXFGroupReader &rDGR)
Definition: dxftblrd.cxx:33
DXFVector aDirection
Definition: dxftblrd.hxx:120
long Long
DXFStyle * pStyles
Definition: dxftblrd.hxx:151
tools::Long nFlags
Definition: dxftblrd.hxx:43
tools::Long nSnap
Definition: dxftblrd.hxx:134
tools::Long nSnapStyle
Definition: dxftblrd.hxx:136
double fHeight
Definition: dxftblrd.hxx:122
void Read(DXFGroupReader &rDGR)
Definition: dxftblrd.cxx:128
tools::Long nSnapIsopair
Definition: dxftblrd.hxx:137
OString m_sName
Definition: dxftblrd.hxx:106
double fSnapBaseY
Definition: dxftblrd.hxx:115
tools::Long nFlags
Definition: dxftblrd.hxx:107
double fWidthFak
Definition: dxftblrd.hxx:85
DXFStyle * pSucc
Definition: dxftblrd.hxx:80
tools::Long nCircleZoomPercent
Definition: dxftblrd.hxx:131
tools::Long nUCSICON
Definition: dxftblrd.hxx:133
double fTwistAngle
Definition: dxftblrd.hxx:127
double fz
Definition: dxfvec.hxx:55
double fGridX
Definition: dxftblrd.hxx:118
tools::Long nMode
Definition: dxftblrd.hxx:130
double fHeight
Definition: dxftblrd.hxx:84
double fLensLength
Definition: dxftblrd.hxx:124
double fOblAngle
Definition: dxftblrd.hxx:86
void Clear()
Definition: dxftblrd.cxx:320
sal_uInt16 Read()
Definition: dxfgrprd.cxx:118
OString m_sName
Definition: dxftblrd.hxx:82
tools::Long nColor
Definition: dxftblrd.hxx:65
OString m_sName
Definition: dxftblrd.hxx:42
tools::Long nTextGenFlags
Definition: dxftblrd.hxx:87
css::drawing::Direction3D aDirection
double fPatternLength
Definition: dxftblrd.hxx:46
double fBackClipPlane
Definition: dxftblrd.hxx:126
tools::Long nFlags
Definition: dxftblrd.hxx:64
double fDash[DXF_MAX_DASH_COUNT]
Definition: dxftblrd.hxx:47
tools::Long nID
Definition: dxftblrd.hxx:129
double fy
Definition: dxfvec.hxx:55
void Read(DXFGroupReader &rDGR)
Definition: dxftblrd.cxx:93
OString m_sDescription
Definition: dxftblrd.hxx:44
double fMaxY
Definition: dxftblrd.hxx:111
double fFrontClipPlane
Definition: dxftblrd.hxx:125
double fSnapSpacingX
Definition: dxftblrd.hxx:116
DXFLayer()
Definition: dxftblrd.cxx:86
double fLastHeightUsed
Definition: dxftblrd.hxx:88
DXFVector aTarget
Definition: dxftblrd.hxx:121
sal_uInt16 GetG() const
Definition: dxfgrprd.hxx:92
DXFVPort * SearchVPort(std::string_view rName) const
Definition: dxftblrd.cxx:370
DXFLayer * SearchLayer(std::string_view rName) const
Definition: dxftblrd.cxx:360
OString m_sPrimFontFile
Definition: dxftblrd.hxx:89
double fMinX
Definition: dxftblrd.hxx:108
void SetError()
Definition: dxfgrprd.hxx:87
double fMinY
Definition: dxftblrd.hxx:109
OString m_sBigFontFile
Definition: dxftblrd.hxx:90
double fSnapSpacingY
Definition: dxftblrd.hxx:117
OString m_sLineType
Definition: dxftblrd.hxx:66
void Read(DXFGroupReader &rDGR)
Definition: dxftblrd.cxx:202
const OString & GetS() const
Definition: dxfgrprd.hxx:107
double fGridY
Definition: dxftblrd.hxx:119
double fMaxX
Definition: dxftblrd.hxx:110
tools::Long nStatus
Definition: dxftblrd.hxx:128
double fSnapBaseX
Definition: dxftblrd.hxx:114
#define DXF_MAX_DASH_COUNT
Definition: dxftblrd.hxx:34
DXFLType * SearchLType(std::string_view rName) const
Definition: dxftblrd.cxx:350
void * p
tools::Long nGrid
Definition: dxftblrd.hxx:135
DXFLType * pLTypes
Definition: dxftblrd.hxx:149
tools::Long nFlags
Definition: dxftblrd.hxx:83
DXFLayer * pLayers
Definition: dxftblrd.hxx:150
tools::Long nFastZoom
Definition: dxftblrd.hxx:132
DXFLType()
Definition: dxftblrd.cxx:25