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