/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include #include //----------------------------------DXFLType----------------------------------- DXFLType::DXFLType() : pSucc(NULL) , nFlags(0) , nDashCount(0) , fPatternLength(0.0) { } void DXFLType::Read(DXFGroupReader & rDGR) { long nDashIndex=-1; while (rDGR.Read()!=0) { switch (rDGR.GetG()) { case 2: m_sName = rDGR.GetS(); break; case 3: m_sDescription = rDGR.GetS(); break; case 70: nFlags=rDGR.GetI(); break; case 73: if (nDashIndex!=-1) { rDGR.SetError(); return; } nDashCount=rDGR.GetI(); if (nDashCount>DXF_MAX_DASH_COUNT) { nDashCount=DXF_MAX_DASH_COUNT; } nDashIndex=0; break; case 40: fPatternLength=rDGR.GetF(); break; case 49: if (nDashCount==-1) { rDGR.SetError(); return; } if (nDashIndexpSucc); ppLa=&pLayers; while(*ppLa!=NULL) ppLa=&((*ppLa)->pSucc); ppSt=&pStyles; while(*ppSt!=NULL) ppSt=&((*ppSt)->pSucc); ppVP=&pVPorts; while(*ppVP!=NULL) ppVP=&((*ppVP)->pSucc); for (;;) { while (rDGR.GetG()!=0) rDGR.Read(); if (rDGR.GetS() == "EOF" || rDGR.GetS() == "ENDSEC") break; else if (rDGR.GetS() == "LTYPE") { pLT=new DXFLType; pLT->Read(rDGR); *ppLT=pLT; ppLT=&(pLT->pSucc); } else if (rDGR.GetS() == "LAYER") { pLa=new DXFLayer; pLa->Read(rDGR); *ppLa=pLa; ppLa=&(pLa->pSucc); } else if (rDGR.GetS() == "STYLE") { pSt=new DXFStyle; pSt->Read(rDGR); *ppSt=pSt; ppSt=&(pSt->pSucc); } else if (rDGR.GetS() == "VPORT") { pVP=new DXFVPort; pVP->Read(rDGR); *ppVP=pVP; ppVP=&(pVP->pSucc); } else rDGR.Read(); } } void DXFTables::Clear() { DXFLType * pLT; DXFLayer * pLa; DXFStyle * pSt; DXFVPort * pVP; while (pStyles!=NULL) { pSt=pStyles; pStyles=pSt->pSucc; delete pSt; } while (pLayers!=NULL) { pLa=pLayers; pLayers=pLa->pSucc; delete pLa; } while (pLTypes!=NULL) { pLT=pLTypes; pLTypes=pLT->pSucc; delete pLT; } while (pVPorts!=NULL) { pVP=pVPorts; pVPorts=pVP->pSucc; delete pVP; } } DXFLType * DXFTables::SearchLType(OString const& rName) const { DXFLType * p; for (p=pLTypes; p!=NULL; p=p->pSucc) { if (rName == p->m_sName) break; } return p; } DXFLayer * DXFTables::SearchLayer(OString const& rName) const { DXFLayer * p; for (p=pLayers; p!=NULL; p=p->pSucc) { if (rName == p->m_sName) break; } return p; } DXFVPort * DXFTables::SearchVPort(OString const& rName) const { DXFVPort * p; for (p=pVPorts; p!=NULL; p=p->pSucc) { if (rName == p->m_sName) break; } return p; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */