StarWriterStruct.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 /* libstaroffice
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  * StarWriterStruct to read/parse some basic writer structure in StarOffice documents
00036  *
00037  */
00038 #ifndef STAR_WRITER_STRUCT
00039 #  define STAR_WRITER_STRUCT
00040 
00041 #include <ostream>
00042 #include <vector>
00043 
00044 #include "libstaroffice_internal.hxx"
00045 
00046 #include "STOFFDebug.hxx"
00047 
00048 namespace StarFormatManagerInternal
00049 {
00050 struct FormatDef;
00051 }
00052 class StarAttribute;
00053 class StarObject;
00054 class StarZone;
00055 
00057 namespace StarWriterStruct
00058 {
00061 struct Attribute {
00062 public:
00064   Attribute() : m_attribute(), m_position(-1,-1)
00065   {
00066   }
00068   ~Attribute();
00070   friend std::ostream &operator<<(std::ostream &o, Attribute const &attribute);
00072   bool read(StarZone &zone, StarObject &object);
00074   static bool readList(StarZone &zone, std::vector<Attribute> &attributeList, StarObject &object);
00076   shared_ptr<StarAttribute> m_attribute;
00078   STOFFVec2i m_position;
00079 };
00080 
00083 class Bookmark
00084 {
00085 public:
00087   Bookmark() : m_shortName(""), m_name(""), m_offset(0), m_key(0), m_modifier(0)
00088   {
00089   }
00091   friend std::ostream &operator<<(std::ostream &o, Bookmark const &mark);
00093   bool read(StarZone &zone);
00095   static bool readList(StarZone &zone, std::vector<Bookmark> &markList);
00097   librevenge::RVNGString m_shortName;
00099   librevenge::RVNGString m_name;
00101   int m_offset;
00103   int m_key;
00105   int m_modifier;
00107   librevenge::RVNGString m_macroNames[4];
00108 };
00109 
00112 struct DatabaseName {
00113 public:
00115   DatabaseName() : m_sql(""), m_dataList()
00116   {
00117   }
00119   friend std::ostream &operator<<(std::ostream &o, DatabaseName const &databaseName);
00121   bool read(StarZone &zone);
00123   struct Data {
00125     Data() : m_name(""), m_selection(0,0)
00126     {
00127     }
00129     friend std::ostream &operator<<(std::ostream &o, Data const &data)
00130     {
00131       o << data.m_name.cstr() << ",";
00132       if (data.m_selection!=STOFFVec2i(0,0)) o << "select=" << STOFFVec2i(0,0) << ",";
00133       return o;
00134     }
00136     librevenge::RVNGString m_name;
00138     STOFFVec2i m_selection;
00139   };
00141   librevenge::RVNGString m_names[2];
00143   librevenge::RVNGString m_sql;
00145   std::vector<Data> m_dataList;
00146 };
00147 
00150 struct Dictionary {
00151 public:
00153   Dictionary() : m_dataList()
00154   {
00155   }
00157   friend std::ostream &operator<<(std::ostream &o, Dictionary const &dictionary);
00159   bool read(StarZone &zone);
00161   struct Data {
00163     Data() : m_name(""), m_language(0), m_id(0), m_spellWrong(true)
00164     {
00165     }
00167     friend std::ostream &operator<<(std::ostream &o, Data const &data)
00168     {
00169       o << data.m_name.cstr() << ",";
00170       if (data.m_language) o << "language=" << data.m_language << ",";
00171       if (data.m_id) o << "id=" << data.m_id << ",";
00172       if (data.m_spellWrong) o << "spellWrong,";
00173       return o;
00174     }
00176     librevenge::RVNGString m_name;
00178     int m_language;
00180     int m_id;
00182     bool m_spellWrong;
00183   };
00185   std::vector<Data> m_dataList;
00186 };
00187 
00190 struct DocStats {
00191 public:
00193   DocStats() : m_isModified(false)
00194   {
00195     for (int i=0; i<7; ++i) m_numbers[i]=0;
00196   }
00198   friend std::ostream &operator<<(std::ostream &o, DocStats const &docStats);
00200   bool read(StarZone &zone);
00202   long m_numbers[7];
00204   bool m_isModified;
00205 };
00206 
00209 struct Macro {
00210 public:
00212   Macro() : m_key(0), m_scriptType(0)
00213   {
00214   }
00216   friend std::ostream &operator<<(std::ostream &o, Macro const &macro);
00218   bool read(StarZone &zone);
00220   static bool readList(StarZone &zone, std::vector<Macro> &macroLis);
00222   int m_key;
00224   librevenge::RVNGString m_names[2];
00226   int m_scriptType;
00227 };
00228 
00231 struct Mark {
00232 public:
00234   Mark() : m_type(-1), m_id(-1), m_offset(-1)
00235   {
00236   }
00238   friend std::ostream &operator<<(std::ostream &o, Mark const &mark);
00240   bool read(StarZone &zone);
00242   int m_type;
00244   int m_id;
00246   int m_offset;
00247 };
00248 
00251 struct NodeRedline {
00252 public:
00254   NodeRedline() : m_id(-1), m_offset(-1), m_flags(0)
00255   {
00256   }
00258   friend std::ostream &operator<<(std::ostream &o, NodeRedline const &nodeRedline);
00260   bool read(StarZone &zone);
00262   int m_id;
00264   int m_offset;
00266   int m_flags;
00267 };
00268 
00271 struct NoteInfo {
00272 public:
00274   explicit NoteInfo(bool isFootnote) : m_isFootnote(isFootnote), m_type(0), m_ftnOffset(0), m_posType(0), m_numType(0)
00275   {
00276     for (int i=0; i<4; ++i) m_idx[i]=0xFFFF;
00277   }
00279   friend std::ostream &operator<<(std::ostream &o, NoteInfo const &noteInfo);
00281   bool read(StarZone &zone);
00283   bool m_isFootnote;
00285   int m_type;
00287   int m_idx[4];
00289   int m_ftnOffset;
00291   librevenge::RVNGString m_strings[4];
00293   int m_posType;
00295   int m_numType;
00296 };
00297 
00300 struct PrintData {
00301 public:
00303   PrintData() : m_flags(0), m_colRow(1,1)
00304   {
00305     for (int i=0; i<6; ++i) m_spacings[i]=0;
00306   }
00308   friend std::ostream &operator<<(std::ostream &o, PrintData const &printData);
00310   bool read(StarZone &zone);
00312   int m_flags;
00314   STOFFVec2i m_colRow;
00316   int m_spacings[6];
00317 };
00318 
00321 struct Redline {
00322 public:
00324   Redline() : m_type(0), m_stringId(0), m_date(0), m_time(0), m_comment()
00325   {
00326   }
00328   friend std::ostream &operator<<(std::ostream &o, Redline const &redline);
00330   bool read(StarZone &zone);
00332   static bool readList(StarZone &zone, std::vector<Redline> &redlineList);
00334   static bool readListList(StarZone &zone, std::vector<std::vector<Redline> > &redlineListList);
00336   int m_type;
00338   int m_stringId;
00340   long m_date;
00342   long m_time;
00344   librevenge::RVNGString m_comment;
00345 };
00346 
00349 struct TOX {
00350 public:
00352   TOX() : m_type(0), m_createType(0), m_captionDisplay(0), m_styleId(0xFFFF), m_data(0), m_formFlags(0)
00353     , m_title(""), m_name(""), m_OLEOptions(0), m_stringIdList(), m_styleList(), m_titleLength(), m_formatList()
00354   {
00355     for (int i=0; i<3; ++i) m_stringIds[i]=0xFFFF;
00356   }
00358   ~TOX();
00360   friend std::ostream &operator<<(std::ostream &o, TOX const &tox);
00362   bool read(StarZone &zone, StarObject &object);
00364   static bool readList(StarZone &zone, std::vector<TOX> &toxList, StarObject &object);
00365 
00367   struct Style {
00369     Style() : m_level(0), m_names()
00370     {
00371     }
00373     friend std::ostream &operator<<(std::ostream &o, Style const &style)
00374     {
00375       o << "level=" << style.m_level << ",";
00376       if (!style.m_names.empty()) {
00377         o << "names=[";
00378         for (size_t i=0; i<style.m_names.size(); ++i) o << style.m_names[i].cstr() << ",";
00379         o << "],";
00380       }
00381       return o;
00382     }
00384     int m_level;
00386     std::vector<librevenge::RVNGString> m_names;
00387   };
00389   int m_type;
00391   int m_createType;
00393   int m_captionDisplay;
00395   int m_stringIds[3];
00397   int m_styleId;
00399   int m_data;
00401   int m_formFlags;
00403   librevenge::RVNGString m_title;
00405   librevenge::RVNGString m_name;
00407   int m_OLEOptions;
00409   std::vector<int> m_stringIdList;
00411   std::vector<Style> m_styleList;
00413   long m_titleLength;
00415   std::vector<shared_ptr<StarFormatManagerInternal::FormatDef> > m_formatList;
00416 };
00417 
00420 struct TOX51 {
00421 public:
00423   TOX51() : m_typeName(""), m_type(0), m_createType(0), m_firstTabPos(0), m_title(""), m_patternList(), m_stringIdList(), m_infLevel(0)
00424   {
00425   }
00427   ~TOX51();
00429   friend std::ostream &operator<<(std::ostream &o, TOX51 const &tox);
00431   bool read(StarZone &zone, StarObject &object);
00433   static bool readList(StarZone &zone, std::vector<TOX51> &toxList, StarObject &object);
00434 
00436   librevenge::RVNGString m_typeName;
00438   int m_type;
00440   int m_createType;
00442   int m_firstTabPos;
00444   librevenge::RVNGString m_title;
00446   std::vector<librevenge::RVNGString> m_patternList;
00448   std::vector<int> m_stringIdList;
00450   int m_infLevel;
00451 };
00452 
00453 }
00454 #endif
00455 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: