NisusWrtStruct.hxx
Go to the documentation of this file.
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
/* libmwaw
* Version: MPL 2.0 / LGPLv2+
*
* The contents of this file are subject to the Mozilla Public License Version
* 2.0 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
* Copyright (C) 2006, 2007 Andrew Ziem
* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
*
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
* in which case the provisions of the LGPLv2+ are applicable
* instead of those above.
*/
#ifndef NISUS_WRT_STRUCT
# define NISUS_WRT_STRUCT
#include <iostream>
#include <vector>
#include "libmwaw_internal.hxx"
#include "MWAWEntry.hxx"
class NisusWrtParser;
namespace NisusWrtStruct
{
enum ZoneType : unsigned { Z_Main=0, Z_Footnote, Z_HeaderFooter };
enum VariableType { V_None=0, V_Numbering, V_Variable, V_Version };
struct Position {
Position()
: m_paragraph(0)
, m_word(0)
, m_char(0)
{
}
friend std::ostream &operator<< (std::ostream &o, Position const &pos);
bool operator==(Position const &p2) const
{
return cmp(p2)==0;
}
bool operator!=(Position const &p2) const
{
return cmp(p2)!=0;
}
int cmp(Position const &p2) const
{
if (m_paragraph < p2.m_paragraph) return -1;
if (m_paragraph > p2.m_paragraph) return 1;
if (m_word < p2.m_word) return -1;
if (m_word > p2.m_word) return 1;
if (m_char < p2.m_char) return -1;
if (m_char > p2.m_char) return 1;
return 0;
}
int m_paragraph;
int m_word;
int m_char;
struct Compare {
bool operator()(Position const &p1, Position const &p2) const
{
return p1.cmp(p2) < 0;
}
};
};
// Internal: low level
struct FootnoteInfo {
FootnoteInfo()
: m_flags(0)
, m_distToDocument(5)
, m_distSeparator(36)
, m_separatorLength(108)
, m_unknown(0)
{
}
friend std::ostream &operator<< (std::ostream &o, FootnoteInfo const &fnote);
bool endNotes() const
{
return (m_flags&0x8)!=0;
}
bool resetNumberOnNewPage() const
{
return (m_flags&0x8)==0 && (m_flags&0x10);
}
int m_flags;
int m_distToDocument;
int m_distSeparator;
int m_separatorLength;
int m_unknown;
};
struct RecursifData {
struct Node;
struct Info;
explicit RecursifData(NisusWrtStruct::ZoneType zone, NisusWrtStruct::VariableType vType=NisusWrtStruct::V_None, int level=0)
: m_info(new Info(zone, vType))
, m_level(level)
, m_childList()
{
}
RecursifData(RecursifData const &orig)
: m_info(orig.m_info)
, m_level(-1)
, m_childList()
{
}
RecursifData &operator=(RecursifData const &orig)
{
if (this != &orig) {
m_info = orig.m_info;
m_level = orig.m_level;
m_childList = orig.m_childList;
}
return *this;
}
bool read(NisusWrtParser &parser, MWAWEntry const &entry);
std::shared_ptr<Info> m_info;
int m_level;
std::vector<Node> m_childList;
struct Info {
explicit Info(NisusWrtStruct::ZoneType zType, NisusWrtStruct::VariableType vType=NisusWrtStruct::V_None)
: m_zoneType(zType)
, m_variableType(vType)
{
}
NisusWrtStruct::ZoneType m_zoneType;
NisusWrtStruct::VariableType m_variableType;
};
struct Node {
Node()
: m_type(0)
, m_entry()
, m_data()
{
}
bool isLeaf() const
{
return !m_data;
}
int m_type;
MWAWEntry m_entry;
std::shared_ptr<RecursifData> m_data;
};
};
}
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWEntry.hxx
MWAWEntry
basic class to store an entry in a file This contained :
Definition MWAWEntry.hxx:47
NisusWrtParser
the main class to read a Nisus Writer file
Definition NisusWrtParser.hxx:60
libmwaw_internal.hxx
NisusWrtStruct
a namespace used to regroup the different structure used to parse a Nisus File
Definition NisusWrtStruct.cxx:42
NisusWrtStruct::ZoneType
ZoneType
the different zone
Definition NisusWrtStruct.hxx:50
NisusWrtStruct::Z_Main
@ Z_Main
Definition NisusWrtStruct.hxx:50
NisusWrtStruct::Z_Footnote
@ Z_Footnote
Definition NisusWrtStruct.hxx:50
NisusWrtStruct::Z_HeaderFooter
@ Z_HeaderFooter
Definition NisusWrtStruct.hxx:50
NisusWrtStruct::VariableType
VariableType
the different variable type
Definition NisusWrtStruct.hxx:53
NisusWrtStruct::V_Version
@ V_Version
Definition NisusWrtStruct.hxx:53
NisusWrtStruct::V_Variable
@ V_Variable
Definition NisusWrtStruct.hxx:53
NisusWrtStruct::V_None
@ V_None
Definition NisusWrtStruct.hxx:53
NisusWrtStruct::V_Numbering
@ V_Numbering
Definition NisusWrtStruct.hxx:53
NisusWrtStruct::FootnoteInfo
Internal: low level a structure helping to store the footnote information.
Definition NisusWrtStruct.hxx:109
NisusWrtStruct::FootnoteInfo::FootnoteInfo
FootnoteInfo()
constructor
Definition NisusWrtStruct.hxx:111
NisusWrtStruct::FootnoteInfo::m_unknown
int m_unknown
a unknown value
Definition NisusWrtStruct.hxx:141
NisusWrtStruct::FootnoteInfo::m_distSeparator
int m_distSeparator
the distance between two footnotes ( or between a footnote and the line sep)
Definition NisusWrtStruct.hxx:137
NisusWrtStruct::FootnoteInfo::endNotes
bool endNotes() const
returns true if we have endnote
Definition NisusWrtStruct.hxx:123
NisusWrtStruct::FootnoteInfo::m_flags
int m_flags
the footnote flags
Definition NisusWrtStruct.hxx:133
NisusWrtStruct::FootnoteInfo::operator<<
friend std::ostream & operator<<(std::ostream &o, FootnoteInfo const &fnote)
operator<<: prints data
Definition NisusWrtStruct.cxx:54
NisusWrtStruct::FootnoteInfo::resetNumberOnNewPage
bool resetNumberOnNewPage() const
returns true if we have to reset index at the beginning of a page
Definition NisusWrtStruct.hxx:128
NisusWrtStruct::FootnoteInfo::m_distToDocument
int m_distToDocument
the distance between the footnote and the document
Definition NisusWrtStruct.hxx:135
NisusWrtStruct::FootnoteInfo::m_separatorLength
int m_separatorLength
the separator length
Definition NisusWrtStruct.hxx:139
NisusWrtStruct::Position::Compare
a comparaison structure used to sort the position
Definition NisusWrtStruct.hxx:96
NisusWrtStruct::Position::Compare::operator()
bool operator()(Position const &p1, Position const &p2) const
comparaison function
Definition NisusWrtStruct.hxx:98
NisusWrtStruct::Position
a position
Definition NisusWrtStruct.hxx:56
NisusWrtStruct::Position::Position
Position()
the constructor
Definition NisusWrtStruct.hxx:58
NisusWrtStruct::Position::m_paragraph
int m_paragraph
the paragraph
Definition NisusWrtStruct.hxx:89
NisusWrtStruct::Position::operator!=
bool operator!=(Position const &p2) const
operator!=
Definition NisusWrtStruct.hxx:73
NisusWrtStruct::Position::m_char
int m_char
the character position
Definition NisusWrtStruct.hxx:93
NisusWrtStruct::Position::cmp
int cmp(Position const &p2) const
a small compare operator
Definition NisusWrtStruct.hxx:78
NisusWrtStruct::Position::operator<<
friend std::ostream & operator<<(std::ostream &o, Position const &pos)
operator<<: prints data in form "XxYxZ"
Definition NisusWrtStruct.cxx:43
NisusWrtStruct::Position::operator==
bool operator==(Position const &p2) const
operator==
Definition NisusWrtStruct.hxx:68
NisusWrtStruct::Position::m_word
int m_word
the word
Definition NisusWrtStruct.hxx:91
NisusWrtStruct::RecursifData::Info
the zone information
Definition NisusWrtStruct.hxx:183
NisusWrtStruct::RecursifData::Info::m_zoneType
NisusWrtStruct::ZoneType m_zoneType
the zone id
Definition NisusWrtStruct.hxx:191
NisusWrtStruct::RecursifData::Info::m_variableType
NisusWrtStruct::VariableType m_variableType
the variable type
Definition NisusWrtStruct.hxx:193
NisusWrtStruct::RecursifData::Info::Info
Info(NisusWrtStruct::ZoneType zType, NisusWrtStruct::VariableType vType=NisusWrtStruct::V_None)
the constructor
Definition NisusWrtStruct.hxx:185
NisusWrtStruct::RecursifData::Node
the data data
Definition NisusWrtStruct.hxx:196
NisusWrtStruct::RecursifData::Node::isLeaf
bool isLeaf() const
returns true if the node is a final node
Definition NisusWrtStruct.hxx:205
NisusWrtStruct::RecursifData::Node::Node
Node()
constructor
Definition NisusWrtStruct.hxx:198
NisusWrtStruct::RecursifData::Node::m_type
int m_type
the variable type
Definition NisusWrtStruct.hxx:211
NisusWrtStruct::RecursifData::Node::m_data
std::shared_ptr< RecursifData > m_data
the recursif data
Definition NisusWrtStruct.hxx:215
NisusWrtStruct::RecursifData::Node::m_entry
MWAWEntry m_entry
the entry
Definition NisusWrtStruct.hxx:213
NisusWrtStruct::RecursifData::m_level
int m_level
the node level
Definition NisusWrtStruct.hxx:178
NisusWrtStruct::RecursifData::m_info
std::shared_ptr< Info > m_info
zone information
Definition NisusWrtStruct.hxx:176
NisusWrtStruct::RecursifData::read
bool read(NisusWrtParser &parser, MWAWEntry const &entry)
read the data
Definition NisusWrtStruct.cxx:77
NisusWrtStruct::RecursifData::RecursifData
RecursifData(RecursifData const &orig)
copy constructor
Definition NisusWrtStruct.hxx:156
NisusWrtStruct::RecursifData::RecursifData
RecursifData(NisusWrtStruct::ZoneType zone, NisusWrtStruct::VariableType vType=NisusWrtStruct::V_None, int level=0)
constructor
Definition NisusWrtStruct.hxx:149
NisusWrtStruct::RecursifData::m_childList
std::vector< Node > m_childList
the list of data entry
Definition NisusWrtStruct.hxx:180
NisusWrtStruct::RecursifData::operator=
RecursifData & operator=(RecursifData const &orig)
copy operator
Definition NisusWrtStruct.hxx:163