BeagleWksBMParser.hxx Source File documentation

BeagleWksBMParser.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 BEAGLE_WKS_BM_PARSER
35 # define BEAGLE_WKS_BM_PARSER
36
37 #include <string>
38 #include <vector>
39
40 #include <librevenge/librevenge.h>
41
42 #include "MWAWCell.hxx"
43 #include "MWAWDebug.hxx"
44 #include "MWAWGraphicStyle.hxx"
45 #include "MWAWInputStream.hxx"
46
47 #include "MWAWParser.hxx"
48
49 namespace BeagleWksBMParserInternal
50 {
51 struct Bitmap;
52
53 struct State;
54 }
55
56 class BeagleWksStructManager;
57
60 class BeagleWksBMParser final : public MWAWGraphicParser
61 {
62 public:
64 BeagleWksBMParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
66 ~BeagleWksBMParser() final;
67
69 bool checkHeader(MWAWHeader *header, bool strict=false) final;
70
71 // the main parse function
72 void parse(librevenge::RVNGDrawingInterface *documentInterface) final;
73
74 protected:
76 void init();
77
79 void createDocument(librevenge::RVNGDrawingInterface *documentInterface);
80
82 MWAWVec2f getPageLeftTop() const;
84 void newPage(int number);
85
86 protected:
88 bool createZones();
89
91 bool readRSRCZones();
92
93 // send data
94
96 bool sendBitmap();
98 bool sendPageFrames();
100 bool sendFrame(BeagleWksStructManager::Frame const &frame);
102 bool sendPicture(int pId, MWAWPosition const &pos,
103 MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
104
105 //
106 // low level
107 //
108
109 // data fork similar than in BeagleWksParser ...
110
112 bool readPrintInfo();
113
114 // data fork
115
117 bool readPrefColorMap();
119 bool readColorMap();
121 bool readBitmap(bool onlyCheck = false);
122
123 // resource fork
124
126 MWAWInputStreamPtr rsrcInput();
127
129 libmwaw::DebugFile &rsrcAscii();
130
131
133 std::shared_ptr<BeagleWksBMParserInternal::State> m_state;
134
136 std::shared_ptr<BeagleWksStructManager> m_structureManager;
137 };
138 #endif
139 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:47
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:551
BeagleWksStructManager::Frame::m_dim
MWAWVec2f m_dim
the dimension
Definition: BeagleWksStructManager.hxx:139
BeagleWksBMParserInternal::State::m_footerHeight
int m_footerHeight
the footer height if known
Definition: BeagleWksBMParser.cxx:104
BeagleWksBMParserInternal::State::m_headerHeight
int m_headerHeight
the header height if known
Definition: BeagleWksBMParser.cxx:103
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
BeagleWksBMParser::init
void init()
inits all internal variables
Definition: BeagleWksBMParser.cxx:125
MWAWPosition::setPagePos
void setPagePos(int pg, MWAWVec2f const &newOrig) const
sets/resets the page and the origin
Definition: MWAWPosition.hxx:230
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
MWAWParser::getGraphicListener
MWAWGraphicListenerPtr & getGraphicListener()
returns the graphic listener
Definition: MWAWParser.hxx:130
MWAWPosition::setRelativePosition
void setRelativePosition(AnchorTo anchor, XPos X=XLeft, YPos Y=YTop)
sets the relative position
Definition: MWAWPosition.hxx:237
MWAWDocument::MWAW_K_PAINT
@ MWAW_K_PAINT
bitmap graphic
Definition: MWAWDocument.hxx:84
BeagleWksBMParser.hxx
MWAWEntry::isParsed
bool isParsed() const
a flag to know if the entry was parsed or not
Definition: MWAWEntry.hxx:121
BeagleWksStructManager::Frame::m_border
MWAWBorder m_border
the border
Definition: BeagleWksStructManager.hxx:145
MWAWColor::white
static MWAWColor white()
return the white color
Definition: libmwaw_internal.hxx:250
libmwaw::DebugFile::open
bool open(std::string const &filename)
opens/creates a file to store a result
Definition: MWAWDebug.cxx:46
BeagleWksBMParserInternal::State::m_pict
std::shared_ptr< MWAWPict > m_pict
the bitmap
Definition: BeagleWksBMParser.cxx:97
BeagleWksBMParser
the main class to read a BeagleWorks bitmap file
Definition: BeagleWksBMParser.hxx:61
BeagleWksBMParserInternal::Bitmap::m_dim
MWAWVec2i m_dim
the bitmap dimension
Definition: BeagleWksBMParser.cxx:71
BeagleWksBMParser::readBitmap
bool readBitmap(bool onlyCheck=false)
try to read a bitmap
Definition: BeagleWksBMParser.cxx:359
MWAWEntry::id
int id() const
returns the id
Definition: MWAWEntry.hxx:164
MWAWPageSpan::setMarginBottom
void setMarginBottom(const double marginBottom)
set the page bottom margin
Definition: MWAWPageSpan.hxx:208
BeagleWksBMParser::sendPicture
bool sendPicture(int pId, MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
try to send a picture
Definition: BeagleWksBMParser.cxx:784
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:192
MWAWEmbeddedObject
small class use to define a embedded object
Definition: libmwaw_internal.hxx:467
MWAWEntry::type
std::string const & type() const
returns the type of the entry
Definition: MWAWEntry.hxx:137
BeagleWksStructManager::Frame::m_origin
MWAWVec2f m_origin
the origin ( for a page frame )
Definition: BeagleWksStructManager.hxx:137
MWAWPrinter.hxx
BeagleWksBMParser::~BeagleWksBMParser
~BeagleWksBMParser() final
destructor
Definition: BeagleWksBMParser.cxx:121
BeagleWksBMParserInternal::State::m_numPages
int m_numPages
the number of page of the final document
Definition: BeagleWksBMParser.cxx:101
BeagleWksStructManager::Frame::m_page
int m_page
the page ( for a page frame )
Definition: BeagleWksStructManager.hxx:141
MWAWPageSpan::setMarginLeft
void setMarginLeft(const double marginLeft)
set the page left margin
Definition: MWAWPageSpan.hxx:193
MWAWPosition::WDynamic
@ WDynamic
Definition: MWAWPosition.hxx:53
libmwaw::PrinterInfo
the AppleŠ printer information : TPrint
Definition: MWAWPrinter.hxx:82
BeagleWksBMParserInternal::Bitmap::m_colorList
std::vector< MWAWColor > m_colorList
the color list
Definition: BeagleWksBMParser.cxx:73
BeagleWksBMParser::BeagleWksBMParser
BeagleWksBMParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition: BeagleWksBMParser.cxx:113
MWAWPageSpan::getPageWidth
double getPageWidth() const
returns the page width (form width without margin )
Definition: MWAWPageSpan.hxx:157
libmwaw::DebugFile::addNote
void addNote(char const *note)
adds a note in the file, in actual position
Definition: MWAWDebug.cxx:59
MWAWGraphicStyle
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:48
MWAWPageSpan::getMarginLeft
double getMarginLeft() const
returns the left margin
Definition: MWAWPageSpan.hxx:132
BeagleWksBMParserInternal::State::State
State()
constructor
Definition: BeagleWksBMParser.cxx:80
MWAWParser::ascii
libmwaw::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: MWAWParser.hxx:195
BeagleWksBMParser::m_structureManager
std::shared_ptr< BeagleWksStructManager > m_structureManager
the structure manager
Definition: BeagleWksBMParser.hxx:136
BeagleWksBMParserInternal::State::m_graphicBegin
long m_graphicBegin
the graphic begin position
Definition: BeagleWksBMParser.cxx:93
MWAWCell.hxx
Defines MWAWCell (cell content and format)
MWAWParser::asciiName
std::string const & asciiName() const
return the ascii file name
Definition: MWAWParser.hxx:232
MWAWSubDocument.hxx
BeagleWksBMParser::readRSRCZones
bool readRSRCZones()
read the resource fork zone
Definition: BeagleWksBMParser.cxx:321
MWAWPageSpan::setFormLength
void setFormLength(const double formLength)
set the total page length
Definition: MWAWPageSpan.hxx:178
BeagleWksStructManager
the main class to read the structure shared between different BeagleWorks files
Definition: BeagleWksStructManager.hxx:57
BeagleWksBMParser::createZones
bool createZones()
finds the different objects zones
Definition: BeagleWksBMParser.cxx:236
libmwaw::DebugFile::reset
void reset()
writes the current file and reset to zero
Definition: MWAWDebug.hxx:93
BeagleWksStructManager::Frame
Internal: a structure use to store a frame in a BeagleWorks files.
Definition: BeagleWksStructManager.hxx:102
MWAWPageSpan::getMarginRight
double getMarginRight() const
returns the right margin
Definition: MWAWPageSpan.hxx:137
BeagleWksStructManager.hxx
MWAWGraphicStyle::emptyStyle
static MWAWGraphicStyle emptyStyle()
returns an empty style.
Definition: MWAWGraphicStyle.hxx:401
BeagleWksBMParser::rsrcAscii
libmwaw::DebugFile & rsrcAscii()
a DebugFile used to write what we recognize when we parse the document in rsrc
Definition: BeagleWksBMParser.cxx:142
MWAWEntry::setType
void setType(std::string const &newType)
sets the type of the entry: BTEP,FDPP, BTEC, FDPC, PLC , TEXT, ...
Definition: MWAWEntry.hxx:132
MWAWParser::setAsciiName
void setAsciiName(char const *name)
Debugging: change the default ascii file.
Definition: MWAWParser.hxx:227
MWAWRSRCParser.hxx
BeagleWksBMParser::readPrefColorMap
bool readPrefColorMap()
read the preference color map
Definition: BeagleWksBMParser.cxx:565
MWAWVec2::y
T y() const
second element
Definition: libmwaw_internal.hxx:673
MWAWParser::getRSRCParser
MWAWRSRCParserPtr & getRSRCParser()
returns the rsrc parser
Definition: MWAWParser.hxx:190
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
BeagleWksBMParserInternal::State::m_typeEntryMap
std::multimap< std::string, MWAWEntry > m_typeEntryMap
the type entry map
Definition: BeagleWksBMParser.cxx:99
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document.
Definition: MWAWPosition.hxx:48
MWAWDocument::MWAW_T_BEAGLEWORKS
@ MWAW_T_BEAGLEWORKS
BeagleWorks (v1.0)/WordPerfect Works (v1.2): export database(as spreadsheet), draw,...
Definition: MWAWDocument.hxx:103
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
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
MWAWPageSpan::getPageLength
double getPageLength() const
returns the page length (form width without margin )
Definition: MWAWPageSpan.hxx:152
MWAWPosition::m_wrapping
Wrapping m_wrapping
Wrapping.
Definition: MWAWPosition.hxx:278
MWAWEntry::length
long length() const
returns the length of the zone
Definition: MWAWEntry.hxx:93
MWAWGraphicStyle::setBorders
void setBorders(int wh, MWAWBorder const &border)
sets the cell border: wh=libmwaw::LeftBit|...
Definition: MWAWGraphicStyle.cxx:232
MWAWListener::PageBreak
@ PageBreak
Definition: MWAWListener.hxx:58
libmwaw::DebugFile::setStream
void setStream(MWAWInputStreamPtr const &ip)
resets the input
Definition: MWAWDebug.hxx:81
MWAWVec2< int >
BeagleWksBMParserInternal::Bitmap::Bitmap
Bitmap()
the constructor
Definition: BeagleWksBMParser.cxx:62
MWAWGraphicListener.hxx
libmwaw::ParseException
Definition: libmwaw_internal.hxx:144
MWAWDebug.hxx
BeagleWksBMParser::parse
void parse(librevenge::RVNGDrawingInterface *documentInterface) final
virtual function used to parse the input
Definition: BeagleWksBMParser.cxx:175
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:57
MWAWEntry::begin
long begin() const
returns the begin offset
Definition: MWAWEntry.hxx:83
MWAWEntry::setLength
void setLength(long l)
sets the zone size
Definition: MWAWEntry.hxx:72
BeagleWksBMParser::createDocument
void createDocument(librevenge::RVNGDrawingInterface *documentInterface)
creates the listener which will be associated to the document
Definition: BeagleWksBMParser.cxx:205
MWAWParser::getPageSpan
MWAWPageSpan const & getPageSpan() const
returns the actual page dimension
Definition: MWAWParser.hxx:160
BeagleWksStructManager::Frame::m_pictId
int m_pictId
the picture id
Definition: BeagleWksStructManager.hxx:135
BeagleWksBMParser::readColorMap
bool readColorMap()
read the bitmap color map (if colored bitmap)
Definition: BeagleWksBMParser.cxx:631
MWAWGraphicParser
virtual class which defines the ancestor of all graphic zone parser
Definition: MWAWParser.hxx:251
MWAWColor::black
static MWAWColor black()
return the back color
Definition: libmwaw_internal.hxx:245
BeagleWksBMParserInternal::Bitmap::m_colorBytes
int m_colorBytes
the number of color bytes (1: means black/white, 8: means color)
Definition: BeagleWksBMParser.cxx:69
BeagleWksBMParserInternal
Internal: the structures of a BeagleWksBMParser.
Definition: BeagleWksBMParser.cxx:57
MWAWEntry::setId
void setId(int newId)
sets the id
Definition: MWAWEntry.hxx:169
BeagleWksBMParserInternal::State
Internal: the state of a BeagleWksBMParser.
Definition: BeagleWksBMParser.cxx:78
BeagleWksBMParser::sendBitmap
bool sendBitmap()
try to send the bitmap
Definition: BeagleWksBMParser.cxx:740
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
BeagleWksBMParser::newPage
void newPage(int number)
adds a new page
Definition: BeagleWksBMParser.cxx:159
MWAWParser::getParserState
MWAWParserStatePtr getParserState()
returns the parser state
Definition: MWAWParser.hxx:113
MWAWHeader.hxx
Defines MWAWHeader (document's type, version, kind)
MWAWEntry::end
long end() const
returns the end offset
Definition: MWAWEntry.hxx:88
BeagleWksBMParser::rsrcInput
MWAWInputStreamPtr rsrcInput()
return the input input
Definition: BeagleWksBMParser.cxx:137
BeagleWksBMParserInternal::State::m_bitmap
Bitmap m_bitmap
the bitmap data
Definition: BeagleWksBMParser.cxx:95
MWAWGraphicStyle.hxx
BeagleWksBMParser::sendPageFrames
bool sendPageFrames()
try to send the page graphic
Definition: BeagleWksBMParser.cxx:760
MWAWParser::getInput
MWAWInputStreamPtr & getInput()
returns the actual input
Definition: MWAWParser.hxx:123
BeagleWksStructManager::Frame::m_wrap
int m_wrap
the wrapping: 0=none, 1=rectangle, 2=irregular
Definition: BeagleWksStructManager.hxx:143
MWAWPosition::Page
@ Page
Definition: MWAWPosition.hxx:51
libmwaw::DebugFile::addPos
void addPos(long pos)
adds a new position in the file
Definition: MWAWDebug.cxx:53
MWAWPageSpan::setMarginRight
void setMarginRight(const double marginRight)
set the page right margin
Definition: MWAWPageSpan.hxx:198
BeagleWksBMParserInternal::Bitmap
Internal: a bitmap of a BeagleWksBMParser.
Definition: BeagleWksBMParser.cxx:60
MWAWEntry::valid
bool valid() const
returns true if the zone length is positive
Definition: MWAWEntry.hxx:99
BeagleWksBMParser::getPageLeftTop
MWAWVec2f getPageLeftTop() const
returns the page left top point ( in inches)
Definition: BeagleWksBMParser.cxx:150
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:66
MWAWInputStream.hxx
BeagleWksBMParser::m_state
std::shared_ptr< BeagleWksBMParserInternal::State > m_state
the state
Definition: BeagleWksBMParser.hxx:133
MWAWHeader::reset
void reset(MWAWDocument::Type type, int vers, Kind kind=MWAWDocument::MWAW_K_TEXT)
resets the data
Definition: MWAWHeader.hxx:84
MWAWPosition::WNone
@ WNone
Definition: MWAWPosition.hxx:53
BeagleWksBMParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition: BeagleWksBMParser.cxx:818
BeagleWksBMParserInternal::State::m_actPage
int m_actPage
the actual page
Definition: BeagleWksBMParser.cxx:101
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
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
BeagleWksStructManager::Frame::m_bordersSet
int m_bordersSet
the list of border which are set in form libmwaw::LeftBit|...
Definition: BeagleWksStructManager.hxx:147
MWAWParser.hxx
MWAWParser::resetGraphicListener
void resetGraphicListener()
resets the listener
Definition: MWAWParser.cxx:130
MWAWPageSpan
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:99
BeagleWksBMParser::readPrintInfo
bool readPrintInfo()
read the print info zone
Definition: BeagleWksBMParser.cxx:684
MWAWGraphicListener
This class contains the code needed to create Graphic document.
Definition: MWAWGraphicListener.hxx:60
BeagleWksBMParser::sendFrame
bool sendFrame(BeagleWksStructManager::Frame const &frame)
try to send a frame
Definition: BeagleWksBMParser.cxx:769