|
rpm-build |
6f7582 |
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
/* libmwaw
|
|
rpm-build |
6f7582 |
* Version: MPL 2.0 / LGPLv2+
|
|
rpm-build |
6f7582 |
*
|
|
rpm-build |
6f7582 |
* The contents of this file are subject to the Mozilla Public License Version
|
|
rpm-build |
6f7582 |
* 2.0 (the "License"); you may not use this file except in compliance with
|
|
rpm-build |
6f7582 |
* the License or as specified alternatively below. You may obtain a copy of
|
|
rpm-build |
6f7582 |
* the License at http://www.mozilla.org/MPL/
|
|
rpm-build |
6f7582 |
*
|
|
rpm-build |
6f7582 |
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
rpm-build |
6f7582 |
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
rpm-build |
6f7582 |
* for the specific language governing rights and limitations under the
|
|
rpm-build |
6f7582 |
* License.
|
|
rpm-build |
6f7582 |
*
|
|
rpm-build |
6f7582 |
* Major Contributor(s):
|
|
rpm-build |
6f7582 |
* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
|
|
rpm-build |
6f7582 |
* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
|
|
rpm-build |
6f7582 |
* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
|
|
rpm-build |
6f7582 |
* Copyright (C) 2006, 2007 Andrew Ziem
|
|
rpm-build |
6f7582 |
* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
|
|
rpm-build |
6f7582 |
*
|
|
rpm-build |
6f7582 |
*
|
|
rpm-build |
6f7582 |
* All Rights Reserved.
|
|
rpm-build |
6f7582 |
*
|
|
rpm-build |
6f7582 |
* For minor contributions see the git repository.
|
|
rpm-build |
6f7582 |
*
|
|
rpm-build |
6f7582 |
* Alternatively, the contents of this file may be used under the terms of
|
|
rpm-build |
6f7582 |
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
|
|
rpm-build |
6f7582 |
* in which case the provisions of the LGPLv2+ are applicable
|
|
rpm-build |
6f7582 |
* instead of those above.
|
|
rpm-build |
6f7582 |
*/
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
#ifndef MAC_WRT_PRO_PARSER
|
|
rpm-build |
6f7582 |
# define MAC_WRT_PRO_PARSER
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
#include <list>
|
|
rpm-build |
6f7582 |
#include <string>
|
|
rpm-build |
6f7582 |
#include <vector>
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
#include "MWAWDebug.hxx"
|
|
rpm-build |
6f7582 |
#include "MWAWEntry.hxx"
|
|
rpm-build |
6f7582 |
#include "MWAWGraphicStyle.hxx"
|
|
rpm-build |
6f7582 |
#include "MWAWInputStream.hxx"
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
#include "MWAWParser.hxx"
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
namespace MacWrtProParserInternal
|
|
rpm-build |
6f7582 |
{
|
|
rpm-build |
6f7582 |
struct State;
|
|
rpm-build |
6f7582 |
struct TextZoneData;
|
|
rpm-build |
6f7582 |
struct TextZone;
|
|
rpm-build |
6f7582 |
struct Token;
|
|
rpm-build |
6f7582 |
struct Zone;
|
|
rpm-build |
6f7582 |
class SubDocument;
|
|
rpm-build |
6f7582 |
}
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
class MacWrtProStructures;
|
|
rpm-build |
6f7582 |
class MacWrtProStructuresListenerState;
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
/** \brief the main class to read a MacWrite II and MacWrite Pro file
|
|
rpm-build |
6f7582 |
*
|
|
rpm-build |
6f7582 |
*
|
|
rpm-build |
6f7582 |
*
|
|
rpm-build |
6f7582 |
*/
|
|
rpm-build |
6f7582 |
class MacWrtProParser final : public MWAWTextParser
|
|
rpm-build |
6f7582 |
{
|
|
rpm-build |
6f7582 |
friend class MacWrtProStructures;
|
|
rpm-build |
6f7582 |
friend class MacWrtProStructuresListenerState;
|
|
rpm-build |
6f7582 |
friend class MacWrtProParserInternal::SubDocument;
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
public:
|
|
rpm-build |
6f7582 |
//! constructor
|
|
rpm-build |
6f7582 |
MacWrtProParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
|
|
rpm-build |
6f7582 |
//! destructor
|
|
rpm-build |
6f7582 |
~MacWrtProParser() final;
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
//! checks if the document header is correct (or not)
|
|
rpm-build |
6f7582 |
bool checkHeader(MWAWHeader *header, bool strict=false) final;
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
// the main parse function
|
|
rpm-build |
6f7582 |
void parse(librevenge::RVNGTextInterface *documentInterface) final;
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
protected:
|
|
rpm-build |
6f7582 |
//! inits all internal variables
|
|
rpm-build |
6f7582 |
void init();
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
//! creates the listener which will be associated to the document
|
|
rpm-build |
6f7582 |
void createDocument(librevenge::RVNGTextInterface *documentInterface);
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
//! finds the different objects zones
|
|
rpm-build |
6f7582 |
bool createZones();
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
//! retrieve the data which corresponds to a zone
|
|
rpm-build |
6f7582 |
bool getZoneData(librevenge::RVNGBinaryData &data, int blockId);
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
//! return the chain list of block ( used to get free blocks)
|
|
rpm-build |
6f7582 |
bool getFreeZoneList(int blockId, std::vector<int> &blockLists);
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
/** parse a data zone
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
\note type=0 ( text entry), type = 1 ( graphic entry ), other unknown
|
|
rpm-build |
6f7582 |
*/
|
|
rpm-build |
6f7582 |
bool parseDataZone(int blockId, int type);
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
/** parse a text zone */
|
|
rpm-build |
6f7582 |
bool parseTextZone(std::shared_ptr<MacWrtProParserInternal::Zone> zone);
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
/** try to read the text block entries */
|
|
rpm-build |
6f7582 |
bool readTextEntries(std::shared_ptr<MacWrtProParserInternal::Zone> zone,
|
|
rpm-build |
6f7582 |
std::vector<MWAWEntry> &res, int textLength);
|
|
rpm-build |
6f7582 |
/** try to read the text id entries */
|
|
rpm-build |
6f7582 |
bool readTextIds(std::shared_ptr<MacWrtProParserInternal::Zone> zone,
|
|
rpm-build |
6f7582 |
std::vector<MacWrtProParserInternal::TextZoneData> &res,
|
|
rpm-build |
6f7582 |
int textLength, int type);
|
|
rpm-build |
6f7582 |
/** try to read the text token entries */
|
|
rpm-build |
6f7582 |
bool readTextTokens(std::shared_ptr<MacWrtProParserInternal::Zone> zone,
|
|
rpm-build |
6f7582 |
std::vector<MacWrtProParserInternal::Token> &res,
|
|
rpm-build |
6f7582 |
int textLength);
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
/** return the list of blockid called by token. A hack to help
|
|
rpm-build |
6f7582 |
structures to retrieve the page attachment */
|
|
rpm-build |
6f7582 |
std::vector<int> const &getBlocksCalledByToken() const;
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
//! returns the page height, ie. paper size less margin (in inches)
|
|
rpm-build |
6f7582 |
float pageHeight() const;
|
|
rpm-build |
6f7582 |
//! returns the document number of columns ( filed in MWII)
|
|
rpm-build |
6f7582 |
int numColumns() const;
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
//! adds a new page
|
|
rpm-build |
6f7582 |
void newPage(int number, bool softBreak=false);
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
//
|
|
rpm-build |
6f7582 |
// interface with MacWrtProParserStructures
|
|
rpm-build |
6f7582 |
//
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
//! send a text box
|
|
rpm-build |
6f7582 |
bool sendTextZone(int blockId, bool mainZone = false);
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
//! compute the number of hard page break
|
|
rpm-build |
6f7582 |
int findNumHardBreaks(int blockId);
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
//! try to send a picture
|
|
rpm-build |
6f7582 |
bool sendPictureZone(int blockId, MWAWPosition const &pictPos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
//! send a textbox zone
|
|
rpm-build |
6f7582 |
bool sendTextBoxZone(int blockId, MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
|
|
rpm-build |
6f7582 |
//! try to send an empty zone (can exist in MacWrtPro1.5)
|
|
rpm-build |
6f7582 |
bool sendEmptyFrameZone(MWAWPosition const &pos, MWAWGraphicStyle const &style);
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
//
|
|
rpm-build |
6f7582 |
// low level
|
|
rpm-build |
6f7582 |
//
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
//! read the print info zone
|
|
rpm-build |
6f7582 |
bool readPrintInfo();
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
//! try to read the doc header zone
|
|
rpm-build |
6f7582 |
bool readDocHeader();
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
#ifdef DEBUG
|
|
rpm-build |
6f7582 |
//! a debug function which can be used to check the block retrieving
|
|
rpm-build |
6f7582 |
void saveOriginal(MWAWInputStreamPtr input);
|
|
rpm-build |
6f7582 |
#endif
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
//! try to send a picture
|
|
rpm-build |
6f7582 |
bool sendPicture(std::shared_ptr<MacWrtProParserInternal::Zone> zone, MWAWPosition pictPos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
//! try to send a text
|
|
rpm-build |
6f7582 |
bool sendText(std::shared_ptr<MacWrtProParserInternal::TextZone> zone, bool mainZone = false);
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
//! compute the number of hard page break
|
|
rpm-build |
6f7582 |
int findNumHardBreaks(std::shared_ptr<MacWrtProParserInternal::TextZone> zone);
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
//! a debug function which can be used to save the unparsed block
|
|
rpm-build |
6f7582 |
void checkUnparsed();
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
protected:
|
|
rpm-build |
6f7582 |
//
|
|
rpm-build |
6f7582 |
// data
|
|
rpm-build |
6f7582 |
//
|
|
rpm-build |
6f7582 |
//! the state
|
|
rpm-build |
6f7582 |
std::shared_ptr<MacWrtProParserInternal::State> m_state;
|
|
rpm-build |
6f7582 |
|
|
rpm-build |
6f7582 |
//! the structures parser
|
|
rpm-build |
6f7582 |
std::shared_ptr<MacWrtProStructures> m_structures;
|
|
rpm-build |
6f7582 |
};
|
|
rpm-build |
6f7582 |
#endif
|
|
rpm-build |
6f7582 |
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
|