CWStruct.hxx
Go to the documentation of this file.
00001 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
00002 
00003 /* libmwaw
00004 * Version: MPL 2.0 / LGPLv2+
00005 *
00006 * The contents of this file are subject to the Mozilla Public License Version
00007 * 2.0 (the "License"); you may not use this file except in compliance with
00008 * the License or as specified alternatively below. You may obtain a copy of
00009 * the License at http://www.mozilla.org/MPL/
00010 *
00011 * Software distributed under the License is distributed on an "AS IS" basis,
00012 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013 * for the specific language governing rights and limitations under the
00014 * License.
00015 *
00016 * Major Contributor(s):
00017 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
00018 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
00019 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
00020 * Copyright (C) 2006, 2007 Andrew Ziem
00021 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
00022 *
00023 *
00024 * All Rights Reserved.
00025 *
00026 * For minor contributions see the git repository.
00027 *
00028 * Alternatively, the contents of this file may be used under the terms of
00029 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
00030 * in which case the provisions of the LGPLv2+ are applicable
00031 * instead of those above.
00032 */
00033 
00034 /*
00035  * Structures used by Claris Works parser
00036  *
00037  */
00038 #ifndef CW_MWAW_STRUCT
00039 #  define CW_MWAW_STRUCT
00040 
00041 #include <iostream>
00042 #include <map>
00043 #include <set>
00044 #include <string>
00045 #include <vector>
00046 
00047 #include "libmwaw_internal.hxx"
00048 
00049 class CWParser;
00050 
00052 namespace CWStruct
00053 {
00055 struct DSET {
00056   struct Child;
00057 
00059   enum Type { T_Main=0, T_Header, T_Footer, T_Frame, T_Footnote, T_Table, T_Slide, T_Unknown};
00060 
00062   DSET() : m_size(0), m_numData(0), m_dataSz(-1), m_headerSz(-1),
00063     m_type(T_Unknown), m_fileType(-1), m_id(0), m_fathersList(), m_validedChildList(),
00064     m_beginSelection(0), m_endSelection(-1), m_textType(0),
00065     m_childs(), m_otherChilds(), m_parsed(false), m_internal(0) {
00066     for (int i = 0; i < 4; i++) m_flags[i] = 0;
00067   }
00068 
00070   virtual ~DSET() {}
00071 
00073   bool okChildId(int zoneId) const {
00074     return m_validedChildList.find(zoneId) != m_validedChildList.end();
00075   }
00076 
00078   friend std::ostream &operator<<(std::ostream &o, DSET const &doc);
00079 
00081   long m_size;
00082 
00084   long m_numData;
00085 
00087   long m_dataSz;
00088 
00090   long m_headerSz;
00091 
00093   Type m_type;
00094 
00096   int m_fileType;
00097 
00099   int m_id;
00100 
00102   std::set<int> m_fathersList;
00103 
00105   std::set<int> m_validedChildList;
00106 
00108   int m_beginSelection;
00109 
00111   int m_endSelection;
00112 
00114   int m_textType;
00115 
00117   int m_flags[4];
00118 
00120   std::vector<Child> m_childs;
00121 
00123   std::vector<int> m_otherChilds;
00124 
00126   mutable bool m_parsed;
00127 
00129   mutable int m_internal;
00130 
00132   struct Child {
00134     enum Type { ZONE, TEXT, GRAPHIC, TABLE, UNKNOWN };
00135 
00137     Child() : m_type(UNKNOWN), m_id(-1), m_posC(-1), m_box() {
00138     }
00139 
00141     friend std::ostream &operator<<(std::ostream &o, Child const &ch) {
00142       switch(ch.m_type) {
00143       case TEXT:
00144         o << "text,";
00145         break;
00146       case ZONE:
00147         o << "zone,";
00148         break;
00149       case GRAPHIC:
00150         o << "graphic,";
00151         break;
00152       case TABLE:
00153         o << "table,";
00154         break;
00155       case UNKNOWN:
00156         o << "#type,";
00157       default:
00158         break;
00159       }
00160       if (ch.m_id != -1) o << "id=" << ch.m_id << ",";
00161       if (ch.m_posC != -1) o << "posC=" << ch.m_posC << ",";
00162       if (ch.m_box.size().x() > 0 || ch.m_box.size().y() > 0)
00163         o << "box=" << ch.m_box << ",";
00164       return o;
00165     }
00166 
00168     int m_type;
00170     int m_id;
00172     long m_posC;
00174     Box2i m_box;
00175   };
00176 };
00177 }
00178 
00179 #endif
00180 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: