ClarisDrawParser.hxx Source File documentation

ClarisDrawParser.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2
3 /* libmwaw
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22 *
23 *
24 * All Rights Reserved.
25 *
26 * For minor contributions see the git repository.
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30 * in which case the provisions of the LGPLv2+ are applicable
31 * instead of those above.
32 */
33
34 #ifndef CLARISDRAW_PARSER
35 # define CLARISDRAW_PARSER
36
37 #include <string>
38 #include <vector>
39
40 #include <librevenge/librevenge.h>
41
42 #include "MWAWDebug.hxx"
43 #include "MWAWInputStream.hxx"
44
45 #include "MWAWParser.hxx"
46
47 #include "ClarisWksStruct.hxx"
48
49 namespace ClarisDrawParserInternal
50 {
51 struct State;
52
53 class SubDocument;
54 }
55
56 class ClarisDrawGraph;
57 class ClarisDrawText;
58 class ClarisDrawStyleManager;
59
63 class ClarisDrawParser final : public MWAWGraphicParser
64 {
65 friend class ClarisDrawGraph;
66 friend class ClarisDrawText;
67 public:
69 ClarisDrawParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
71 ~ClarisDrawParser() final;
72
74 bool checkHeader(MWAWHeader *header, bool strict=false) final;
75
77 void parse(librevenge::RVNGDrawingInterface *documentInterface) final;
78
80 int getFileType(int zoneId) const;
82 MWAWVec2f getPageLeftTop();
84 bool sendTextZone(int number, int subZone=-1);
85
86 protected:
88 void init();
89
91 void createDocument(librevenge::RVNGDrawingInterface *documentInterface);
92
93 protected:
95 bool createZones();
97 bool readZone();
98
99 // Intermediate level
100
102 bool readDocHeader();
104 bool readLibraryHeader();
106 std::shared_ptr<ClarisWksStruct::DSET> readDSET(bool isLibHeader=false);
107
109 bool readPrintInfo();
111 bool readDocInfo();
113 bool readLayouts();
115 bool readLibraryNames();
116
117 //
118 // low level
119 //
120
121 protected:
122 //
123 // data
124 //
125
127 std::shared_ptr<ClarisDrawParserInternal::State> m_state;
129 std::shared_ptr<ClarisDrawStyleManager> m_styleManager;
131 std::shared_ptr<ClarisDrawGraph> m_graphParser;
133 std::shared_ptr<ClarisDrawText> m_textParser;
134 };
135 #endif
136 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
ClarisWksStruct::DSET::m_size
long m_size
the size of the DSET header
Definition: ClarisWksStruct.hxx:178
ClarisDrawParser::getFileType
int getFileType(int zoneId) const
returns the file type corresponding to a zone id
Definition: ClarisDrawParser.cxx:166
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
ClarisWksStruct::DSET::m_id
int m_id
the zone identificator
Definition: ClarisWksStruct.hxx:199
ClarisDrawParserInternal::State::m_createMasterPage
bool m_createMasterPage
flag to know if we need or not to create a master
Definition: ClarisDrawParser.cxx:116
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:551
ClarisDrawParser::~ClarisDrawParser
~ClarisDrawParser() final
destructor
Definition: ClarisDrawParser.cxx:149
MWAWGraphicListenerPtr
std::shared_ptr< MWAWGraphicListener > MWAWGraphicListenerPtr
a smart pointer of MWAWGraphicListener
Definition: libmwaw_internal.hxx:549
MWAWPageSpan::setPageSpan
void setPageSpan(const int pageSpan)
set the page span ( default 1)
Definition: MWAWPageSpan.hxx:268
ClarisDrawParserInternal::State::m_headerId
int m_headerId
header id
Definition: ClarisDrawParser.cxx:124
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:129
MWAWVec2f
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition: libmwaw_internal.hxx:842
ClarisWksStruct.hxx
libmwaw::DebugFile::addDelimiter
void addDelimiter(long pos, char c)
adds a not breaking delimiter in position pos
Definition: MWAWDebug.cxx:73
MWAWParser::getGraphicListener
MWAWGraphicListenerPtr & getGraphicListener()
returns the graphic listener
Definition: MWAWParser.hxx:130
ClarisWksStruct::readStructZone
bool readStructZone(MWAWParserState &parserState, char const *zoneName, bool hasEntete)
try to read a structured zone with unknown content
Definition: ClarisWksStruct.cxx:162
MWAWPosition::setRelativePosition
void setRelativePosition(AnchorTo anchor, XPos X=XLeft, YPos Y=YTop)
sets the relative position
Definition: MWAWPosition.hxx:237
ClarisDrawParserInternal::Layer
Definition: ClarisDrawParser.cxx:65
ClarisDrawParser::createZones
bool createZones()
finds the different objects zones
Definition: ClarisDrawParser.cxx:321
ClarisDrawParser.hxx
libmwaw::DebugFile::open
bool open(std::string const &filename)
opens/creates a file to store a result
Definition: MWAWDebug.cxx:46
ClarisDrawParserInternal::State::m_actualLayer
int m_actualLayer
the actual layer
Definition: ClarisDrawParser.cxx:112
MWAWPageSpan::setMarginBottom
void setMarginBottom(const double marginBottom)
set the page bottom margin
Definition: MWAWPageSpan.hxx:208
MWAWFontConverter.hxx
libmwaw::appendUnicode
void appendUnicode(uint32_t val, librevenge::RVNGString &buffer)
adds an unicode character to a string
Definition: libmwaw_internal.cxx:63
ClarisWksStruct::DSET::m_textType
int m_textType
the text type (header/footer,footnote, ...)
Definition: ClarisWksStruct.hxx:209
ClarisDrawParserInternal::State::m_isLibrary
bool m_isLibrary
flag to know if the file is a library or not
Definition: ClarisDrawParser.cxx:106
MWAWDocument::MWAW_T_CLARISDRAW
@ MWAW_T_CLARISDRAW
Claris Draw: v1.0.1-v1.0.3.
Definition: MWAWDocument.hxx:174
MWAWPrinter.hxx
ClarisDrawParserInternal::Layer::Layer
Layer()
constructor
Definition: ClarisDrawParser.cxx:67
MWAWDocument::MWAW_K_DRAW
@ MWAW_K_DRAW
vectorized grphic
Definition: MWAWDocument.hxx:83
MWAWPageSpan::setMarginLeft
void setMarginLeft(const double marginLeft)
set the page left margin
Definition: MWAWPageSpan.hxx:193
ClarisDrawParser::readLayouts
bool readLayouts()
try to read the layout
Definition: ClarisDrawParser.cxx:1134
ClarisDrawParser::sendTextZone
bool sendTextZone(int number, int subZone=-1)
sends a text zone
Definition: ClarisDrawParser.cxx:175
libmwaw::PrinterInfo
the AppleŠ printer information : TPrint
Definition: MWAWPrinter.hxx:82
ClarisWksStruct::DSET::m_endSelection
int m_endSelection
the end of selection ( at least in text header)
Definition: ClarisWksStruct.hxx:206
ClarisDrawParserInternal::State::m_EOF
long m_EOF
the last data zone size
Definition: ClarisDrawParser.cxx:110
libmwaw::DebugFile::addNote
void addNote(char const *note)
adds a note in the file, in actual position
Definition: MWAWDebug.cxx:59
ClarisDrawParser::readDocHeader
bool readDocHeader()
try to read a document header
Definition: ClarisDrawParser.cxx:402
ClarisDrawParserInternal::State::m_version
int m_version
the file version
Definition: ClarisDrawParser.cxx:104
ClarisWksStruct
namespace to store the main structure which appears in a ClarisDraw/ClarisWorks file
Definition: ClarisWksStruct.cxx:49
ClarisWksStruct::DSET::m_flags
int m_flags[4]
some unknown flag
Definition: ClarisWksStruct.hxx:212
MWAWParser::ascii
libmwaw::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: MWAWParser.hxx:195
ClarisWksStruct::DSET::m_beginSelection
int m_beginSelection
the begin of selection ( at least in text header)
Definition: ClarisWksStruct.hxx:204
ClarisDrawParserInternal::State::m_pageSpanSet
bool m_pageSpanSet
flag to know if the page has been set
Definition: ClarisDrawParser.cxx:122
ClarisDrawParser::readLibraryHeader
bool readLibraryHeader()
try to read the library header
Definition: ClarisDrawParser.cxx:817
MWAWSubDocument.hxx
ClarisDrawParserInternal::State::m_displayAsSlide
bool m_displayAsSlide
flag to know if we need to display data as slide
Definition: ClarisDrawParser.cxx:118
ClarisDrawGraph.hxx
MWAWPageSpan::setFormLength
void setFormLength(const double formLength)
set the total page length
Definition: MWAWPageSpan.hxx:178
MWAWPageSpan::setMasterPageName
void setMasterPageName(librevenge::RVNGString const &name)
set the page master name
Definition: MWAWPageSpan.hxx:243
ClarisDrawParser::m_textParser
std::shared_ptr< ClarisDrawText > m_textParser
the text parser
Definition: ClarisDrawParser.hxx:133
ClarisDrawStyleManager.hxx
libmwaw::DebugFile::reset
void reset()
writes the current file and reset to zero
Definition: MWAWDebug.hxx:93
ClarisDrawParser::ClarisDrawText
friend class ClarisDrawText
Definition: ClarisDrawParser.hxx:66
ClarisDrawParserInternal::State::m_layerList
std::vector< Layer > m_layerList
the layer list
Definition: ClarisDrawParser.cxx:120
MWAWParser::setAsciiName
void setAsciiName(char const *name)
Debugging: change the default ascii file.
Definition: MWAWParser.hxx:227
MWAWParagraph.hxx
MWAWVec2::y
T y() const
second element
Definition: libmwaw_internal.hxx:673
ClarisDrawParserInternal::State::State
State()
constructor
Definition: ClarisDrawParser.cxx:85
MWAWParser::getPageSpan
const MWAWPageSpan & getPageSpan() const
returns the actual page dimension
Definition: MWAWParser.hxx:160
MWAWPageSpan::setFormWidth
void setFormWidth(const double formWidth)
set the total page width
Definition: MWAWPageSpan.hxx:183
MWAWPosition.hxx
MWAWVec2::x
T x() const
first element
Definition: libmwaw_internal.hxx:668
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document.
Definition: MWAWPosition.hxx:47
ClarisWksStruct::DSET::m_fileType
int m_fileType
the type ( 0: text, -1: graphic, ...)
Definition: ClarisWksStruct.hxx:189
ClarisDrawParserInternal::Layer::m_groupId
int m_groupId
the first group id
Definition: ClarisDrawParser.cxx:74
MWAWEntry::setBegin
void setBegin(long off)
sets the begin offset
Definition: MWAWEntry.hxx:67
MWAWParser::setGraphicListener
void setGraphicListener(MWAWGraphicListenerPtr &listener)
sets the graphic listener
Definition: MWAWParser.cxx:125
ClarisDrawParser::readZone
bool readZone()
try to read a zone
Definition: ClarisDrawParser.cxx:360
ClarisDrawStyleManager
the main class to read a ClarisDraw style
Definition: ClarisDrawStyleManager.hxx:59
MWAWParser::asciiName
const std::string & asciiName() const
return the ascii file name
Definition: MWAWParser.hxx:232
MWAWParser::setVersion
void setVersion(int vers)
sets the document's version
Definition: MWAWParser.hxx:206
MWAWRSRCParserPtr
std::shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:561
MWAWPictData.hxx
MWAWListener::PageBreak
@ PageBreak
Definition: MWAWListener.hxx:58
ClarisDrawParserInternal::Layer::m_isHidden
bool m_isHidden
true if the layer is hidden
Definition: ClarisDrawParser.cxx:76
libmwaw::DebugFile::setStream
void setStream(MWAWInputStreamPtr const &ip)
resets the input
Definition: MWAWDebug.hxx:81
ClarisWksStruct::Struct::readHeader
bool readHeader(MWAWInputStreamPtr input, bool strict=false)
try to read the header
Definition: ClarisWksStruct.cxx:72
MWAWVec2< int >
ClarisDrawParser::init
void init()
inits all internal variables
Definition: ClarisDrawParser.cxx:153
MWAWGraphicListener.hxx
MWAWGraphicShape.hxx
libmwaw::ParseException
Definition: libmwaw_internal.hxx:143
MWAWDebug.hxx
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:56
MWAWEntry::setLength
void setLength(long l)
sets the zone size
Definition: MWAWEntry.hxx:72
ClarisDrawParserInternal::State
Internal: the state of a ClarisDrawParser.
Definition: ClarisDrawParser.cxx:83
ClarisDrawParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition: ClarisDrawParser.cxx:1095
MWAWGraphicParser
virtual class which defines the ancestor of all graphic zone parser
Definition: MWAWParser.hxx:250
ClarisWksStruct::DSET
main structure which correspond to a document part
Definition: ClarisWksStruct.hxx:87
ClarisDrawParser::createDocument
void createDocument(librevenge::RVNGDrawingInterface *documentInterface)
creates the listener which will be associated to the document
Definition: ClarisDrawParser.cxx:254
ClarisDrawText.hxx
ClarisDrawParser::parse
void parse(librevenge::RVNGDrawingInterface *documentInterface) final
the main parse function
Definition: ClarisDrawParser.cxx:189
MWAWPageSpan::setMarginTop
void setMarginTop(const double marginTop)
set the page top margin
Definition: MWAWPageSpan.hxx:203
libmwaw::PrinterInfo::read
bool read(MWAWInputStreamPtr input)
reads the struture in a file
Definition: MWAWPrinter.cxx:235
ClarisDrawParserInternal::State::m_numLayers
int m_numLayers
the number of layer
Definition: ClarisDrawParser.cxx:114
MWAWPageSpan::setPageName
void setPageName(librevenge::RVNGString const &name)
set the page name
Definition: MWAWPageSpan.hxx:228
MWAWParser::getParserState
MWAWParserStatePtr getParserState()
returns the parser state
Definition: MWAWParser.hxx:113
MWAWHeader.hxx
MWAWEntry::end
long end() const
returns the end offset
Definition: MWAWEntry.hxx:88
ClarisWksStruct::Struct::m_size
long m_size
the size of the DSET header
Definition: ClarisWksStruct.hxx:69
MWAWGraphicStyle.hxx
ClarisDrawParser::m_styleManager
std::shared_ptr< ClarisDrawStyleManager > m_styleManager
the style manager
Definition: ClarisDrawParser.hxx:129
MWAWParser::getInput
MWAWInputStreamPtr & getInput()
returns the actual input
Definition: MWAWParser.hxx:123
ClarisWksStruct::DSET::m_numData
long m_numData
the number of header
Definition: ClarisWksStruct.hxx:180
ClarisDrawGraph
the main class to read the graphic part of Claris Works file
Definition: ClarisDrawGraph.hxx:73
ClarisDrawParser::readDSET
std::shared_ptr< ClarisWksStruct::DSET > readDSET(bool isLibHeader=false)
try to read a DSET structure
Definition: ClarisDrawParser.cxx:1453
ClarisWksStruct::DSET::m_dataSz
long m_dataSz
the data size
Definition: ClarisWksStruct.hxx:182
MWAWPosition::Page
@ Page
Definition: MWAWPosition.hxx:51
ClarisDrawParser::ClarisDrawGraph
friend class ClarisDrawGraph
Definition: ClarisDrawParser.hxx:65
libmwaw::DebugFile::addPos
void addPos(long pos)
adds a new position in the file
Definition: MWAWDebug.cxx:53
ClarisDrawParser::m_state
std::shared_ptr< ClarisDrawParserInternal::State > m_state
the state
Definition: ClarisDrawParser.hxx:127
ClarisDrawParserInternal::State::m_footerId
int m_footerId
footer id
Definition: ClarisDrawParser.cxx:126
ClarisDrawParser::ClarisDrawParser
ClarisDrawParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition: ClarisDrawParser.cxx:139
MWAWPageSpan::setMarginRight
void setMarginRight(const double marginRight)
set the page right margin
Definition: MWAWPageSpan.hxx:198
ClarisDrawParserInternal
Internal: the structures of a ClarisDrawParser.
Definition: ClarisDrawParser.cxx:62
ClarisDrawParserInternal::State::m_pages
MWAWVec2i m_pages
the number of pages
Definition: ClarisDrawParser.cxx:128
ClarisDrawText
the main class to read the text part of ClarisDraw file
Definition: ClarisDrawText.hxx:72
libmwaw::DebugFile
an interface used to insert comment in a binary file, written in ascii form (if debug_with_files is n...
Definition: MWAWDebug.hxx:65
ClarisDrawParserInternal::State::m_numDSET
int m_numDSET
the number of DSET+FNTM
Definition: ClarisDrawParser.cxx:108
ClarisDrawParser::readPrintInfo
bool readPrintInfo()
try to read the print info zone
Definition: ClarisDrawParser.cxx:1394
ClarisWksStruct::Struct
a basic structure
Definition: ClarisWksStruct.hxx:53
MWAWInputStream.hxx
ClarisDrawParserInternal::Layer::m_name
librevenge::RVNGString m_name
the layer name
Definition: ClarisDrawParser.cxx:78
MWAWHeader::reset
void reset(MWAWDocument::Type type, int vers, Kind kind=MWAWDocument::MWAW_K_TEXT)
resets the data
Definition: MWAWHeader.hxx:84
ClarisDrawParser
the main class to read a ClarisDraw v1 file
Definition: ClarisDrawParser.hxx:63
ClarisDrawParserInternal::State::m_zoneIdToFileTypeMap
std::map< int, int > m_zoneIdToFileTypeMap
map zone id to file type
Definition: ClarisDrawParser.cxx:132
librevenge
Definition: MWAWDocument.hxx:56
ClarisDrawParser::getPageLeftTop
MWAWVec2f getPageLeftTop()
returns the page left top point ( in inches)
Definition: ClarisDrawParser.cxx:180
MWAWPictBitmap.hxx
MWAWPageSpan::setMargins
void setMargins(double margin, int wh=libmwaw::LeftBit|libmwaw::RightBit|libmwaw::TopBit|libmwaw::BottomBit)
set all the margins
Definition: MWAWPageSpan.hxx:213
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:43
ClarisWksStruct::DSET::m_headerSz
long m_headerSz
the header size
Definition: ClarisWksStruct.hxx:184
ClarisDrawParser::readLibraryNames
bool readLibraryNames()
try to read the library names(two zone)
Definition: ClarisDrawParser.cxx:1231
MWAWVec2i
MWAWVec2< int > MWAWVec2i
MWAWVec2 of int.
Definition: libmwaw_internal.hxx:838
libmwaw::DebugStream
std::stringstream DebugStream
a basic stream (if debug_with_files is not defined, does nothing)
Definition: MWAWDebug.hxx:61
MWAWParser.hxx
MWAWParser::resetGraphicListener
void resetGraphicListener()
resets the listener
Definition: MWAWParser.cxx:130
MWAWPageSpan
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:98
ClarisDrawParserInternal::State::m_zonesMap
std::map< int, std::shared_ptr< ClarisWksStruct::DSET > > m_zonesMap
the map of zone
Definition: ClarisDrawParser.cxx:130
MWAWGraphicListener
This class contains the code needed to create Graphic document.
Definition: MWAWGraphicListener.hxx:59
ClarisDrawParser::m_graphParser
std::shared_ptr< ClarisDrawGraph > m_graphParser
the graph parser
Definition: ClarisDrawParser.hxx:131
ClarisDrawParser::readDocInfo
bool readDocInfo()
try to read the document info zone
Definition: ClarisDrawParser.cxx:1348