1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_filter.hxx"
26 
27 #include <string.h>
28 #include <dxfblkrd.hxx>
29 
30 
31 //----------------------------------------------------------------------------
32 //---------------- DXFBlock --------------------------------------------------
33 //----------------------------------------------------------------------------
34 
35 
DXFBlock()36 DXFBlock::DXFBlock()
37 {
38 	pSucc=NULL;
39 }
40 
41 
~DXFBlock()42 DXFBlock::~DXFBlock()
43 {
44 }
45 
46 
Read(DXFGroupReader & rDGR)47 void DXFBlock::Read(DXFGroupReader & rDGR)
48 {
49 	sName[0]=0;
50 	sAlsoName[0]=0;
51 	aBasePoint.fx=0.0;
52 	aBasePoint.fy=0.0;
53 	aBasePoint.fz=0.0;
54 	nFlags=0;
55 	sXRef[0]=0;
56 
57 	while (rDGR.Read()!=0)
58 	{
59 		switch (rDGR.GetG())
60 		{
61 			case  2: strncpy( sName, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
62 			case  3: strncpy( sAlsoName, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
63 			case 70: nFlags=rDGR.GetI(); break;
64 			case 10: aBasePoint.fx=rDGR.GetF(); break;
65 			case 20: aBasePoint.fy=rDGR.GetF(); break;
66 			case 30: aBasePoint.fz=rDGR.GetF(); break;
67 			case  1: strncpy( sXRef, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
68 		}
69 	}
70 	DXFEntities::Read(rDGR);
71 }
72 
73 
74 //----------------------------------------------------------------------------
75 //---------------- DXFBlocks -------------------------------------------------
76 //----------------------------------------------------------------------------
77 
78 
DXFBlocks()79 DXFBlocks::DXFBlocks()
80 {
81 	pFirst=NULL;
82 }
83 
84 
~DXFBlocks()85 DXFBlocks::~DXFBlocks()
86 {
87 	Clear();
88 }
89 
90 
Read(DXFGroupReader & rDGR)91 void DXFBlocks::Read(DXFGroupReader & rDGR)
92 {
93 	DXFBlock * pB, * * ppSucc;
94 
95 	ppSucc=&pFirst;
96 	while (*ppSucc!=NULL) ppSucc=&((*ppSucc)->pSucc);
97 
98 	for (;;) {
99 		while (rDGR.GetG()!=0) rDGR.Read();
100 		if (strcmp(rDGR.GetS(),"ENDSEC")==0 ||
101 			strcmp(rDGR.GetS(),"EOF")==0) break;
102 		if (strcmp(rDGR.GetS(),"BLOCK")==0) {
103 			pB=new DXFBlock;
104 			pB->Read(rDGR);
105 			*ppSucc=pB;
106 			ppSucc=&(pB->pSucc);
107 		}
108 		else rDGR.Read();
109 	}
110 }
111 
112 
Search(const char * sName) const113 DXFBlock * DXFBlocks::Search(const char * sName) const
114 {
115 	DXFBlock * pB;
116 	for (pB=pFirst; pB!=NULL; pB=pB->pSucc) {
117 		if (strcmp(sName,pB->sName)==0) break;
118 	}
119 	return pB;
120 }
121 
122 
Clear()123 void DXFBlocks::Clear()
124 {
125 	DXFBlock * ptmp;
126 
127 	while (pFirst!=NULL) {
128 		ptmp=pFirst;
129 		pFirst=ptmp->pSucc;
130 		delete ptmp;
131 	}
132 }
133 
134 
135 
136