merge the formfield patch from ooo-build
[ooovba.git] / goodies / source / filter.vcl / idxf / dxftblrd.cxx
blob917a0c6ea2c398526de5e3a6de3eab9563f8b636
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dxftblrd.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_goodies.hxx"
34 #include <string.h>
35 #include <dxftblrd.hxx>
37 //----------------------------------DXFLType-----------------------------------
39 DXFLType::DXFLType()
41 pSucc=NULL;
42 sName[0]=0;
43 nFlags=0;
44 sDescription[0]=0;
45 nDashCount=0;
48 void DXFLType::Read(DXFGroupReader & rDGR)
50 long nDashIndex=-1;
52 while (rDGR.Read()!=0)
54 switch (rDGR.GetG())
56 case 2: strncpy( sName, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
57 case 70: nFlags=rDGR.GetI(); break;
58 case 3: strncpy( sDescription, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
59 case 73:
60 if (nDashIndex!=-1) {
61 rDGR.SetError();
62 return;
64 nDashCount=rDGR.GetI();
65 if (nDashCount>DXF_MAX_DASH_COUNT)
66 nDashCount=DXF_MAX_DASH_COUNT;
67 nDashIndex=0;
68 break;
69 case 40: fPatternLength=rDGR.GetF(); break;
70 case 49:
71 if (nDashCount==-1) {
72 rDGR.SetError();
73 return;
75 if (nDashIndex<nDashCount)
76 fDash[nDashIndex++]=rDGR.GetF();
77 break;
82 //----------------------------------DXFLayer-----------------------------------
84 DXFLayer::DXFLayer()
86 pSucc=NULL;
87 sName[0]=0;
88 nFlags=0;
89 nColor=-1;
90 sLineType[0]=0;
93 void DXFLayer::Read(DXFGroupReader & rDGR)
95 while (rDGR.Read()!=0) {
96 switch(rDGR.GetG()) {
97 case 2: strncpy( sName, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
98 case 70: nFlags=rDGR.GetI(); break;
99 case 62: nColor=rDGR.GetI(); break;
100 case 6: strncpy( sLineType, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
105 //----------------------------------DXFStyle-----------------------------------
107 DXFStyle::DXFStyle()
109 pSucc=NULL;
110 sName[0]=0;
111 nFlags=0;
112 fHeight=0.0;
113 fWidthFak=1.0;
114 fOblAngle=0.0;
115 nTextGenFlags=0;
116 fLastHeightUsed=0.0;
117 sPrimFontFile[0]=0;
118 sBigFontFile[0]=0;
121 void DXFStyle::Read(DXFGroupReader & rDGR)
123 while (rDGR.Read()!=0) {
124 switch(rDGR.GetG()) {
125 case 2: strncpy( sName, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
126 case 70: nFlags=rDGR.GetI(); break;
127 case 40: fHeight=rDGR.GetF(); break;
128 case 41: fWidthFak=rDGR.GetF(); break;
129 case 50: fOblAngle=rDGR.GetF(); break;
130 case 71: nTextGenFlags=rDGR.GetI(); break;
131 case 42: fLastHeightUsed=rDGR.GetF(); break;
132 case 3: strncpy( sPrimFontFile, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
133 case 4: strncpy( sBigFontFile, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
138 //----------------------------------DXFVPort-----------------------------------
140 DXFVPort::DXFVPort()
142 pSucc=NULL;
144 sName[0]=0;
145 nFlags=0;
146 fMinX=0;
147 fMinY=0;
148 fMaxX=0;
149 fMaxY=0;
150 fCenterX=0;
151 fCenterY=0;
152 fSnapBaseX=0;
153 fSnapBaseY=0;
154 fSnapSapcingX=0;
155 fSnapSpacingY=0;
156 fGridX=0;
157 fGridY=0;
158 aDirection=DXFVector(0,0,1);
159 aTarget=DXFVector(0,0,0);
160 fHeight=0;
161 fAspectRatio=0;
162 fLensLength=0;
163 fFrontClipPlane=0;
164 fBackClipPlane=0;
165 fTwistAngle=0;
166 nStatus=0;
167 nID=0;
168 nMode=0;
169 nCircleZoomPercent=0;
170 nFastZoom=0;
171 nUCSICON=0;
172 nSnap=0;
173 nGrid=0;
174 nSnapStyle=0;
175 nSnapIsopair=0;
178 void DXFVPort::Read(DXFGroupReader & rDGR)
180 while (rDGR.Read()!=0) {
181 switch(rDGR.GetG()) {
182 case 2: strncpy( sName, rDGR.GetS(), DXF_MAX_STRING_LEN + 1); break;
183 case 70: nFlags=rDGR.GetI(); break;
184 case 10: fMinX=rDGR.GetF(); break;
185 case 20: fMinY=rDGR.GetF(); break;
186 case 11: fMaxX=rDGR.GetF(); break;
187 case 21: fMaxY=rDGR.GetF(); break;
188 case 12: fCenterX=rDGR.GetF(); break;
189 case 22: fCenterY=rDGR.GetF(); break;
190 case 13: fSnapBaseX=rDGR.GetF(); break;
191 case 23: fSnapBaseY=rDGR.GetF(); break;
192 case 14: fSnapSapcingX=rDGR.GetF(); break;
193 case 24: fSnapSpacingY=rDGR.GetF(); break;
194 case 15: fGridX=rDGR.GetF(); break;
195 case 25: fGridY=rDGR.GetF(); break;
196 case 16: aDirection.fx=rDGR.GetF(); break;
197 case 26: aDirection.fy=rDGR.GetF(); break;
198 case 36: aDirection.fz=rDGR.GetF(); break;
199 case 17: aTarget.fx=rDGR.GetF(); break;
200 case 27: aTarget.fy=rDGR.GetF(); break;
201 case 37: aTarget.fz=rDGR.GetF(); break;
202 case 40: fHeight=rDGR.GetF(); break;
203 case 41: fAspectRatio=rDGR.GetF(); break;
204 case 42: fLensLength=rDGR.GetF(); break;
205 case 43: fFrontClipPlane=rDGR.GetF(); break;
206 case 44: fBackClipPlane=rDGR.GetF(); break;
207 case 51: fTwistAngle=rDGR.GetF(); break;
208 case 68: nStatus=rDGR.GetI(); break;
209 case 69: nID=rDGR.GetI(); break;
210 case 71: nMode=rDGR.GetI(); break;
211 case 72: nCircleZoomPercent=rDGR.GetI(); break;
212 case 73: nFastZoom=rDGR.GetI(); break;
213 case 74: nUCSICON=rDGR.GetI(); break;
214 case 75: nSnap=rDGR.GetI(); break;
215 case 76: nGrid=rDGR.GetI(); break;
216 case 77: nSnapStyle=rDGR.GetI(); break;
217 case 78: nSnapIsopair=rDGR.GetI(); break;
222 //----------------------------------DXFTables----------------------------------
225 DXFTables::DXFTables()
227 pLTypes=NULL;
228 pLayers=NULL;
229 pStyles=NULL;
230 pVPorts=NULL;
234 DXFTables::~DXFTables()
236 Clear();
240 void DXFTables::Read(DXFGroupReader & rDGR)
242 DXFLType * * ppLT, * pLT;
243 DXFLayer * * ppLa, * pLa;
244 DXFStyle * * ppSt, * pSt;
245 DXFVPort * * ppVP, * pVP;
247 ppLT=&pLTypes;
248 while(*ppLT!=NULL) ppLT=&((*ppLT)->pSucc);
250 ppLa=&pLayers;
251 while(*ppLa!=NULL) ppLa=&((*ppLa)->pSucc);
253 ppSt=&pStyles;
254 while(*ppSt!=NULL) ppSt=&((*ppSt)->pSucc);
256 ppVP=&pVPorts;
257 while(*ppVP!=NULL) ppVP=&((*ppVP)->pSucc);
259 for (;;) {
260 while (rDGR.GetG()!=0) rDGR.Read();
261 if (strcmp(rDGR.GetS(),"EOF")==0 ||
262 strcmp(rDGR.GetS(),"ENDSEC")==0) break;
263 else if (strcmp(rDGR.GetS(),"LTYPE")==0) {
264 pLT=new DXFLType;
265 pLT->Read(rDGR);
266 *ppLT=pLT;
267 ppLT=&(pLT->pSucc);
269 else if (strcmp(rDGR.GetS(),"LAYER")==0) {
270 pLa=new DXFLayer;
271 pLa->Read(rDGR);
272 *ppLa=pLa;
273 ppLa=&(pLa->pSucc);
275 else if (strcmp(rDGR.GetS(),"STYLE")==0) {
276 pSt=new DXFStyle;
277 pSt->Read(rDGR);
278 *ppSt=pSt;
279 ppSt=&(pSt->pSucc);
281 else if (strcmp(rDGR.GetS(),"VPORT")==0) {
282 pVP=new DXFVPort;
283 pVP->Read(rDGR);
284 *ppVP=pVP;
285 ppVP=&(pVP->pSucc);
287 else rDGR.Read();
292 void DXFTables::Clear()
294 DXFLType * pLT;
295 DXFLayer * pLa;
296 DXFStyle * pSt;
297 DXFVPort * pVP;
299 while (pStyles!=NULL) {
300 pSt=pStyles;
301 pStyles=pSt->pSucc;
302 delete pSt;
304 while (pLayers!=NULL) {
305 pLa=pLayers;
306 pLayers=pLa->pSucc;
307 delete pLa;
309 while (pLTypes!=NULL) {
310 pLT=pLTypes;
311 pLTypes=pLT->pSucc;
312 delete pLT;
314 while (pVPorts!=NULL) {
315 pVP=pVPorts;
316 pVPorts=pVP->pSucc;
317 delete pVP;
322 DXFLType * DXFTables::SearchLType(const char * pName) const
324 DXFLType * p;
325 for (p=pLTypes; p!=NULL; p=p->pSucc) {
326 if (strcmp(pName,p->sName)==0) break;
328 return p;
332 DXFLayer * DXFTables::SearchLayer(const char * pName) const
334 DXFLayer * p;
335 for (p=pLayers; p!=NULL; p=p->pSucc) {
336 if (strcmp(pName,p->sName)==0) break;
338 return p;
342 DXFVPort * DXFTables::SearchVPort(const char * pName) const
344 DXFVPort * p;
345 for (p=pVPorts; p!=NULL; p=p->pSucc) {
346 if (strcmp(pName,p->sName)==0) break;
348 return p;