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 :
21 : #include <string.h>
22 : #include <dxfblkrd.hxx>
23 :
24 :
25 : //----------------------------------------------------------------------------
26 : //---------------- DXFBlock --------------------------------------------------
27 : //----------------------------------------------------------------------------
28 :
29 :
30 0 : DXFBlock::DXFBlock()
31 : {
32 0 : pSucc=NULL;
33 0 : }
34 :
35 :
36 0 : DXFBlock::~DXFBlock()
37 : {
38 0 : }
39 :
40 :
41 0 : void DXFBlock::Read(DXFGroupReader & rDGR)
42 : {
43 0 : sName[0]=0;
44 0 : sAlsoName[0]=0;
45 0 : aBasePoint.fx=0.0;
46 0 : aBasePoint.fy=0.0;
47 0 : aBasePoint.fz=0.0;
48 0 : nFlags=0;
49 0 : sXRef[0]=0;
50 :
51 0 : while (rDGR.Read()!=0)
52 : {
53 0 : switch (rDGR.GetG())
54 : {
55 0 : case 2: strncpy( sName, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
56 0 : case 3: strncpy( sAlsoName, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
57 0 : case 70: nFlags=rDGR.GetI(); break;
58 0 : case 10: aBasePoint.fx=rDGR.GetF(); break;
59 0 : case 20: aBasePoint.fy=rDGR.GetF(); break;
60 0 : case 30: aBasePoint.fz=rDGR.GetF(); break;
61 0 : case 1: strncpy( sXRef, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
62 : }
63 : }
64 0 : DXFEntities::Read(rDGR);
65 0 : }
66 :
67 :
68 : //----------------------------------------------------------------------------
69 : //---------------- DXFBlocks -------------------------------------------------
70 : //----------------------------------------------------------------------------
71 :
72 :
73 0 : DXFBlocks::DXFBlocks()
74 : {
75 0 : pFirst=NULL;
76 0 : }
77 :
78 :
79 0 : DXFBlocks::~DXFBlocks()
80 : {
81 0 : Clear();
82 0 : }
83 :
84 :
85 0 : void DXFBlocks::Read(DXFGroupReader & rDGR)
86 : {
87 : DXFBlock * pB, * * ppSucc;
88 :
89 0 : ppSucc=&pFirst;
90 0 : while (*ppSucc!=NULL) ppSucc=&((*ppSucc)->pSucc);
91 :
92 0 : for (;;) {
93 0 : while (rDGR.GetG()!=0) rDGR.Read();
94 0 : if (strcmp(rDGR.GetS(),"ENDSEC")==0 ||
95 0 : strcmp(rDGR.GetS(),"EOF")==0) break;
96 0 : if (strcmp(rDGR.GetS(),"BLOCK")==0) {
97 0 : pB=new DXFBlock;
98 0 : pB->Read(rDGR);
99 0 : *ppSucc=pB;
100 0 : ppSucc=&(pB->pSucc);
101 : }
102 0 : else rDGR.Read();
103 : }
104 0 : }
105 :
106 :
107 0 : DXFBlock * DXFBlocks::Search(const char * sName) const
108 : {
109 : DXFBlock * pB;
110 0 : for (pB=pFirst; pB!=NULL; pB=pB->pSucc) {
111 0 : if (strcmp(sName,pB->sName)==0) break;
112 : }
113 0 : return pB;
114 : }
115 :
116 :
117 0 : void DXFBlocks::Clear()
118 : {
119 : DXFBlock * ptmp;
120 :
121 0 : while (pFirst!=NULL) {
122 0 : ptmp=pFirst;
123 0 : pFirst=ptmp->pSucc;
124 0 : delete ptmp;
125 : }
126 0 : }
127 :
128 :
129 :
130 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|