MWAWContentListener.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 MWAW_CONTENT_LISTENER_H
#define MWAW_CONTENT_LISTENER_H
#include <vector>
#include <libwpd/libwpd.h>
#include "libmwaw_internal.hxx"
class MWAWCell;
class MWAWTable;
namespace MWAWContentListenerInternal
{
struct DocumentState;
struct State;
}
class MWAWContentListener
{
public:
enum BreakType { PageBreak=0, SoftPageBreak, ColumnBreak };
MWAWContentListener(MWAWParserState &parserState, std::vector<MWAWPageSpan> const &pageList, WPXDocumentInterface *documentInterface);
virtual ~MWAWContentListener();
void setDocumentLanguage(std::string locale);
void startDocument();
void endDocument(bool sendDelayedSubDoc=true);
void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType);
bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const;
// ------ page --------
bool isPageSpanOpened() const;
MWAWPageSpan const &getPageSpan();
// ------ header/footer --------
bool insertHeader(MWAWSubDocumentPtr subDocument, WPXPropertyList const &extras);
bool insertFooter(MWAWSubDocumentPtr subDocument, WPXPropertyList const &extras);
bool isHeaderFooterOpened() const;
// ------ text data -----------
void insertChar(uint8_t character);
void insertCharacter(unsigned char c);
int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1);
void insertUnicode(uint32_t character);
void insertUnicodeString(WPXString const &str);
void insertTab();
void insertEOL(bool softBreak=false);
void insertBreak(BreakType breakType);
// ------ text format -----------
void setFont(MWAWFont const &font);
MWAWFont const &getFont() const;
// ------ paragraph format -----------
bool isParagraphOpened() const;
void setParagraph(MWAWParagraph const &paragraph);
MWAWParagraph const &getParagraph() const;
// ------- fields ----------------
void insertField(MWAWField const&field);
// ------- subdocument -----------------
void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument);
void insertComment(MWAWSubDocumentPtr &subDocument);
void insertPicture(MWAWPosition const &pos, const WPXBinaryData &binaryData,
std::string type="image/pict",
WPXPropertyList frameExtras=WPXPropertyList());
void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument,
WPXPropertyList frameExtras=WPXPropertyList(),
WPXPropertyList textboxExtras=WPXPropertyList());
// ------- table -----------------
void openTable(MWAWTable const &table);
void closeTable();
void openTableRow(float h, WPXUnit unit, bool headerRow=false);
void closeTableRow();
void openTableCell(MWAWCell const &cell);
void closeTableCell();
void addEmptyTableCell(Vec2i const &pos, Vec2i span=Vec2i(1,1));
// ------- section ---------------
bool isSectionOpened() const;
MWAWSection const &getSection() const;
bool openSection(MWAWSection const &section);
bool closeSection();
protected:
void _openSection();
void _closeSection();
void _openPageSpan(bool sendHeaderFooters=true);
void _closePageSpan();
void _startSubDocument();
void _endSubDocument();
void _handleFrameParameters( WPXPropertyList &propList, MWAWPosition const &pos);
bool openFrame(MWAWPosition const &pos, WPXPropertyList extras=WPXPropertyList());
void closeFrame();
void _openParagraph();
void _closeParagraph();
void _appendParagraphProperties(WPXPropertyList &propList, const bool isListElement=false);
void _resetParagraphState(const bool isListElement=false);
void _openListElement();
void _closeListElement();
void _changeList();
int _getListId() const;
void _openSpan();
void _closeSpan();
void _flushText();
void _flushDeferredTabs();
void _insertBreakIfNecessary(WPXPropertyList &propList);
shared_ptr<MWAWContentListenerInternal::State> _pushParsingState();
void _popParsingState();
protected:
shared_ptr<MWAWContentListenerInternal::DocumentState> m_ds;
shared_ptr<MWAWContentListenerInternal::State> m_ps;
std::vector<shared_ptr<MWAWContentListenerInternal::State> > m_psStack;
MWAWParserState &m_parserState;
WPXDocumentInterface *m_documentInterface;
private:
MWAWContentListener(const MWAWContentListener &);
MWAWContentListener &operator=(const MWAWContentListener &);
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWContentListener::_openParagraph
void _openParagraph()
Definition: MWAWContentListener.cxx:698
MWAWContentListener::isHeaderFooterOpened
bool isHeaderFooterOpened() const
returns true if the header/footer is open
Definition: MWAWContentListener.cxx:582
MWAWContentListener::isParagraphOpened
bool isParagraphOpened() const
returns true if a paragraph or a list is opened
Definition: MWAWContentListener.cxx:381
MWAWContentListener::closeTable
void closeTable()
closes this table
Definition: MWAWContentListener.cxx:1481
MWAWContentListener::_closeListElement
void _closeListElement()
close a list level
Definition: MWAWContentListener.cxx:801
MWAWContentListener::m_ds
shared_ptr< MWAWContentListenerInternal::DocumentState > m_ds
the main parse state
Definition: MWAWContentListener.hxx:226
MWAWContentListener::insertCharacter
void insertCharacter(unsigned char c)
insert a character using the font converter to find the utf8 character
Definition: MWAWContentListener.cxx:210
MWAWContentListener::getParagraph
MWAWParagraph const & getParagraph() const
returns the actual paragraph
Definition: MWAWContentListener.cxx:393
MWAWContentListener::getPageSpan
MWAWPageSpan const & getPageSpan()
returns the current page span
Definition: MWAWContentListener.cxx:516
MWAWContentListener::insertField
void insertField(MWAWField const &field)
adds a field type
Definition: MWAWContentListener.cxx:401
MWAWPageSpan
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:95
MWAWContentListener::isSectionOpened
bool isSectionOpened() const
returns true if a section is opened
Definition: MWAWContentListener.cxx:616
libmwaw_internal.hxx
MWAWContentListener::closeSection
bool closeSection()
close a section
Definition: MWAWContentListener.cxx:642
MWAWContentListener::openSection
bool openSection(MWAWSection const &section)
open a section if possible
Definition: MWAWContentListener.cxx:626
MWAWContentListener::handleSubDocument
void handleSubDocument(MWAWSubDocumentPtr subDocument, libmwaw::SubDocumentType subDocumentType)
function called to add a subdocument
Definition: MWAWContentListener.cxx:1359
MWAWContentListener::insertHeader
bool insertHeader(MWAWSubDocumentPtr subDocument, WPXPropertyList const &extras)
insert a header
Definition: MWAWContentListener.cxx:587
MWAWContentListener::_openSection
void _openSection()
Definition: MWAWContentListener.cxx:657
MWAWContentListener::openTableRow
void openTableRow(float h, WPXUnit unit, bool headerRow=false)
open a row with given height ( if h < 0.0, set min-row-height = -h )
Definition: MWAWContentListener.cxx:1495
MWAWContentListener::insertUnicode
void insertUnicode(uint32_t character)
adds an unicode character.
Definition: MWAWContentListener.cxx:252
MWAWContentListener::insertEOL
void insertEOL(bool softBreak=false)
adds an end of line ( by default an hard one)
Definition: MWAWContentListener.cxx:269
MWAWContentListener::_flushText
void _flushText()
Definition: MWAWContentListener.cxx:944
libmwaw::SubDocumentType
SubDocumentType
Definition: libmwaw_internal.hxx:157
MWAWContentListener::insertComment
void insertComment(MWAWSubDocumentPtr &subDocument)
adds comment
Definition: MWAWContentListener.cxx:1029
MWAWTable
a class used to recreate the table structure using cell informations, ....
Definition: MWAWTable.hxx:53
MWAWContentListener::_insertBreakIfNecessary
void _insertBreakIfNecessary(WPXPropertyList &propList)
Definition: MWAWContentListener.cxx:341
MWAWContentListener::startDocument
void startDocument()
starts the document
Definition: MWAWContentListener.cxx:465
MWAWContentListener::_getListId
int _getListId() const
low level: find a list id which corresponds to actual list and a change of level. ...
Definition: MWAWContentListener.cxx:817
MWAWContentListener::insertTab
void insertTab()
adds a tab
Definition: MWAWContentListener.cxx:286
MWAWContentListener::~MWAWContentListener
virtual ~MWAWContentListener()
destructor
Definition: MWAWContentListener.cxx:191
MWAWContentListener::_appendParagraphProperties
void _appendParagraphProperties(WPXPropertyList &propList, const bool isListElement=false)
Definition: MWAWContentListener.cxx:756
MWAWCell
a structure used to define a cell and its format
Definition: MWAWCell.hxx:50
Vec2i
Vec2< int > Vec2i
Vec2 of int.
Definition: libmwaw_internal.hxx:578
MWAWSubDocumentPtr
shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:344
MWAWContentListener::m_documentInterface
WPXDocumentInterface * m_documentInterface
the document interface
Definition: MWAWContentListener.hxx:234
MWAWContentListener::_handleFrameParameters
void _handleFrameParameters(WPXPropertyList &propList, MWAWPosition const &pos)
Definition: MWAWContentListener.cxx:1159
MWAWContentListener::m_ps
shared_ptr< MWAWContentListenerInternal::State > m_ps
the actual local parse state
Definition: MWAWContentListener.hxx:228
MWAWContentListener::closeTableRow
void closeTableRow()
closes this row
Definition: MWAWContentListener.cxx:1516
MWAWContentListener::addEmptyTableCell
void addEmptyTableCell(Vec2i const &pos, Vec2i span=Vec2i(1, 1))
add empty cell
Definition: MWAWContentListener.cxx:1526
MWAWContentListener::isPageSpanOpened
bool isPageSpanOpened() const
returns true if a page is opened
Definition: MWAWContentListener.cxx:511
MWAWParserState
a class to define the parser state
Definition: MWAWParser.hxx:51
MWAWContentListener::insertUnicodeString
void insertUnicodeString(WPXString const &str)
adds a unicode string
Definition: MWAWContentListener.cxx:262
MWAWContentListener::endDocument
void endDocument(bool sendDelayedSubDoc=true)
ends the document
Definition: MWAWContentListener.cxx:480
MWAWContentListener::_openPageSpan
void _openPageSpan(bool sendHeaderFooters=true)
Definition: MWAWContentListener.cxx:524
MWAWContentListener::insertBreak
void insertBreak(BreakType breakType)
inserts a break type: ColumBreak, PageBreak, ..
Definition: MWAWContentListener.cxx:297
MWAWContentListener::insertFooter
bool insertFooter(MWAWSubDocumentPtr subDocument, WPXPropertyList const &extras)
insert a footer
Definition: MWAWContentListener.cxx:600
MWAWContentListener::_resetParagraphState
void _resetParagraphState(const bool isListElement=false)
Definition: MWAWContentListener.cxx:748
MWAWContentListener::openTableCell
void openTableCell(MWAWCell const &cell)
open a cell
Definition: MWAWContentListener.cxx:1545
MWAWContentListener::_closeSection
void _closeSection()
Definition: MWAWContentListener.cxx:678
MWAWContentListener::openTable
void openTable(MWAWTable const &table)
open a table
Definition: MWAWContentListener.cxx:1456
MWAWContentListener::_closeParagraph
void _closeParagraph()
Definition: MWAWContentListener.cxx:727
MWAWContentListener::_openSpan
void _openSpan()
Definition: MWAWContentListener.cxx:888
MWAWContentListener::_closeSpan
void _closeSpan()
Definition: MWAWContentListener.cxx:912
MWAWContentListener::_flushDeferredTabs
void _flushDeferredTabs()
Definition: MWAWContentListener.cxx:925
MWAWContentListener::BreakType
BreakType
Definition: MWAWContentListener.hxx:55
MWAWContentListener::_openListElement
void _openListElement()
open a list level
Definition: MWAWContentListener.cxx:769
MWAWContentListener::setParagraph
void setParagraph(MWAWParagraph const &paragraph)
sets the paragraph
Definition: MWAWContentListener.cxx:386
MWAWSection
a class which stores section properties
Definition: MWAWSection.hxx:45
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:336
MWAWContentListener::setFont
void setFont(MWAWFont const &font)
sets the font
Definition: MWAWContentListener.cxx:360
MWAWContentListener::_changeList
void _changeList()
update the list so that it corresponds to the actual level
Definition: MWAWContentListener.cxx:834
MWAWContentListener::insertTextBox
void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr subDocument, WPXPropertyList frameExtras=WPXPropertyList(), WPXPropertyList textboxExtras=WPXPropertyList())
adds a textbox in given position
Definition: MWAWContentListener.cxx:1054
MWAWContentListener::getFont
MWAWFont const & getFont() const
returns the actual font
Definition: MWAWContentListener.cxx:376
MWAWParagraph
class to store the paragraph properties
Definition: MWAWParagraph.hxx:83
MWAWContentListener::_endSubDocument
void _endSubDocument()
Definition: MWAWContentListener.cxx:1442
MWAWContentListener::insertChar
void insertChar(uint8_t character)
adds a basic character, ..
Definition: MWAWContentListener.cxx:199
MWAWContentListener::openFrame
bool openFrame(MWAWPosition const &pos, WPXPropertyList extras=WPXPropertyList())
Definition: MWAWContentListener.cxx:1092
MWAWField
a field
Definition: libmwaw_internal.hxx:281
MWAWContentListener::insertNote
void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument)
insert a note
Definition: MWAWContentListener.cxx:974
MWAWContentListener::_popParsingState
void _popParsingState()
resets the previous parsing state
Definition: MWAWContentListener.cxx:1596
MWAWContentListener::isSubDocumentOpened
bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const
returns try if a subdocument is open
Definition: MWAWContentListener.cxx:1428
MWAWContentListener::m_parserState
MWAWParserState & m_parserState
the parser state
Definition: MWAWContentListener.hxx:232
MWAWNote
a note
Definition: libmwaw_internal.hxx:299
MWAWContentListener::ColumnBreak
Definition: MWAWContentListener.hxx:55
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: MWAWPosition.hxx:47
MWAWContentListener::operator=
MWAWContentListener & operator=(const MWAWContentListener &)
MWAWContentListener::_startSubDocument
void _startSubDocument()
Definition: MWAWContentListener.cxx:1436
Vec2< int >
MWAWContentListener
Definition: MWAWContentListener.hxx:52
MWAWContentListener::_closePageSpan
void _closePageSpan()
Definition: MWAWContentListener.cxx:567
MWAWContentListener::closeFrame
void closeFrame()
Definition: MWAWContentListener.cxx:1148
MWAWContentListener::_pushParsingState
shared_ptr< MWAWContentListenerInternal::State > _pushParsingState()
creates a new parsing state (copy of the actual state)
Definition: MWAWContentListener.cxx:1582
MWAWContentListener::SoftPageBreak
Definition: MWAWContentListener.hxx:55
MWAWContentListener::insertPicture
void insertPicture(MWAWPosition const &pos, const WPXBinaryData &binaryData, std::string type="image/pict", WPXPropertyList frameExtras=WPXPropertyList())
adds a picture in given position
Definition: MWAWContentListener.cxx:1067
MWAWContentListener::m_psStack
std::vector< shared_ptr< MWAWContentListenerInternal::State > > m_psStack
stack of local state
Definition: MWAWContentListener.hxx:230
MWAWContentListener::closeTableCell
void closeTableCell()
close a cell
Definition: MWAWContentListener.cxx:1562
MWAWContentListener::setDocumentLanguage
void setDocumentLanguage(std::string locale)
sets the documents language
Definition: MWAWContentListener.cxx:459
MWAWContentListener::getSection
MWAWSection const & getSection() const
returns the actual section
Definition: MWAWContentListener.cxx:621
MWAWContentListener::PageBreak
Definition: MWAWContentListener.hxx:55
MWAWContentListener::MWAWContentListener
MWAWContentListener(MWAWParserState &parserState, std::vector< MWAWPageSpan > const &pageList, WPXDocumentInterface *documentInterface)
constructor
Definition: MWAWContentListener.cxx:185