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