MWAWTextListener.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_TEXT_LISTENER_H
#define MWAW_TEXT_LISTENER_H
#include <vector>
#include <librevenge/librevenge.h>
#include "libmwaw_internal.hxx"
#include "MWAWGraphicStyle.hxx"
#include "MWAWListener.hxx"
class MWAWCell;
class MWAWGraphicStyle;
class MWAWGraphicShape;
class MWAWTable;
namespace MWAWTextListenerInternal
{
struct DocumentState;
struct State;
}
class MWAWTextListener final : public MWAWListener
{
public:
MWAWTextListener(MWAWParserState &parserState, std::vector<MWAWPageSpan> const &pageList, librevenge::RVNGTextInterface *documentInterface);
~MWAWTextListener() final;
Type getType() const final
{
return Text;
}
void setDocumentMetaData(librevenge::RVNGPropertyList const &metadata) final;
void setDocumentLanguage(std::string const &locale) final;
void startDocument() final;
void endDocument(bool sendDelayedSubDoc=true) final;
bool isDocumentStarted() const final;
void handleSubDocument(MWAWSubDocumentPtr const &subDocument, libmwaw::SubDocumentType subDocumentType) final;
bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const final;
bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle()) final;
void closeFrame() final;
bool openGroup(MWAWPosition const &pos) final;
void closeGroup() final;
bool canWriteText() const final
{
return MWAWTextListener::isDocumentStarted();
}
// ------ page --------
bool isPageSpanOpened() const final;
MWAWPageSpan const &getPageSpan() final;
// ------ header/footer --------
bool insertHeader(MWAWSubDocumentPtr const &subDocument, librevenge::RVNGPropertyList const &extras) final;
bool insertFooter(MWAWSubDocumentPtr const &subDocument, librevenge::RVNGPropertyList const &extras) final;
bool isHeaderFooterOpened() const final;
// ------ text data -----------
void insertChar(uint8_t character) final;
void insertCharacter(unsigned char c) final;
int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1) final;
void insertUnicode(uint32_t character) final;
void insertUnicodeString(librevenge::RVNGString const &str) final;
void insertTab() final;
void insertEOL(bool softBreak=false) final;
// ------ text format -----------
void setFont(MWAWFont const &font) final;
MWAWFont const &getFont() const final;
// ------ paragraph format -----------
bool isParagraphOpened() const final;
void setParagraph(MWAWParagraph const &paragraph) final;
MWAWParagraph const &getParagraph() const final;
// ------- fields ----------------
void insertField(MWAWField const &field) final;
// ------- link ----------------
void openLink(MWAWLink const &link) final;
void closeLink() final;
// ------- subdocument -----------------
void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument) final;
void insertComment(MWAWSubDocumentPtr &subDocument) final;
void insertPicture(MWAWPosition const &pos, MWAWEmbeddedObject const &picture,
MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle()) final;
void insertShape(MWAWPosition const &pos, MWAWGraphicShape const &shape,
MWAWGraphicStyle const &style) final;
void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr const &subDocument,
MWAWGraphicStyle const &frameStyle=MWAWGraphicStyle::emptyStyle()) final;
// ------- table -----------------
void openTable(MWAWTable const &table) final;
void closeTable() final;
void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false) final;
void closeTableRow() final;
void openTableCell(MWAWCell const &cell) final;
void closeTableCell() final;
void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1,1)) final;
// ------- section ---------------
bool canOpenSectionAddBreak() const final;
bool isSectionOpened() const final;
MWAWSection const &getSection() const final;
bool openSection(MWAWSection const &section) final;
bool closeSection() final;
void insertBreak(BreakType breakType) final;
protected:
void _openSection();
void _closeSection();
void _openPageSpan(bool sendHeaderFooters=true);
void _closePageSpan();
void _startSubDocument();
void _endSubDocument();
void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos);
void _openParagraph();
void _closeParagraph();
void _appendParagraphProperties(librevenge::RVNGPropertyList &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(librevenge::RVNGPropertyList &propList);
std::shared_ptr<MWAWTextListenerInternal::State> _pushParsingState();
void _popParsingState();
protected:
std::shared_ptr<MWAWTextListenerInternal::DocumentState> m_ds;
std::shared_ptr<MWAWTextListenerInternal::State> m_ps;
std::vector<std::shared_ptr<MWAWTextListenerInternal::State> > m_psStack;
MWAWParserState &m_parserState;
librevenge::RVNGTextInterface *m_documentInterface;
private:
MWAWTextListener(const MWAWTextListener &) = delete;
MWAWTextListener &operator=(const MWAWTextListener &) = delete;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWGraphicStyle.hxx
MWAWListener.hxx
MWAWCell
a structure used to define a cell and its format
Definition MWAWCell.hxx:53
MWAWFont
Class to store font.
Definition MWAWFont.hxx:44
MWAWGraphicShape
a structure used to define a picture shape
Definition MWAWGraphicShape.hxx:46
MWAWGraphicStyle
a structure used to define a picture style
Definition MWAWGraphicStyle.hxx:48
MWAWListener
This class contains a virtual interface to all listener.
Definition MWAWListener.hxx:50
MWAWListener::Type
Type
the listener type
Definition MWAWListener.hxx:56
MWAWListener::Text
@ Text
Definition MWAWListener.hxx:56
MWAWListener::BreakType
BreakType
the different break type
Definition MWAWListener.hxx:58
MWAWPageSpan
A class which defines the page properties.
Definition MWAWPageSpan.hxx:99
MWAWParagraph
class to store the paragraph properties
Definition MWAWParagraph.hxx:85
MWAWParserState
a class to define the parser state
Definition MWAWParser.hxx:50
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document.
Definition MWAWPosition.hxx:48
MWAWSection
a class which stores section properties
Definition MWAWSection.hxx:46
MWAWTable
a class used to recreate the table structure using cell informations, ....
Definition MWAWTable.hxx:52
MWAWTextListener::isParagraphOpened
bool isParagraphOpened() const final
returns true if a paragraph or a list is opened
Definition MWAWTextListener.cxx:431
MWAWTextListener::isPageSpanOpened
bool isPageSpanOpened() const final
returns true if a page is opened
Definition MWAWTextListener.cxx:561
MWAWTextListener::closeTableRow
void closeTableRow() final
closes this row
Definition MWAWTextListener.cxx:1814
MWAWTextListener::canWriteText
bool canWriteText() const final
returns true if we can add text data
Definition MWAWTextListener.hxx:104
MWAWTextListener::m_ds
std::shared_ptr< MWAWTextListenerInternal::DocumentState > m_ds
the main parse state
Definition MWAWTextListener.hxx:273
MWAWTextListener::m_ps
std::shared_ptr< MWAWTextListenerInternal::State > m_ps
the actual local parse state
Definition MWAWTextListener.hxx:275
MWAWTextListener::insertChar
void insertChar(uint8_t character) final
adds a basic character, ..
Definition MWAWTextListener.cxx:238
MWAWTextListener::insertTab
void insertTab() final
adds a tab
Definition MWAWTextListener.cxx:330
MWAWTextListener::startDocument
void startDocument() final
starts the document
Definition MWAWTextListener.cxx:517
MWAWTextListener::_pushParsingState
std::shared_ptr< MWAWTextListenerInternal::State > _pushParsingState()
creates a new parsing state (copy of the actual state)
Definition MWAWTextListener.cxx:1880
MWAWTextListener::_changeList
void _changeList()
update the list so that it corresponds to the actual level
Definition MWAWTextListener.cxx:891
MWAWTextListener::_openSpan
void _openSpan()
low level: the function which opens a new span property
Definition MWAWTextListener.cxx:950
MWAWTextListener::insertHeader
bool insertHeader(MWAWSubDocumentPtr const &subDocument, librevenge::RVNGPropertyList const &extras) final
insert a header
Definition MWAWTextListener.cxx:639
MWAWTextListener::setParagraph
void setParagraph(MWAWParagraph const &paragraph) final
sets the paragraph
Definition MWAWTextListener.cxx:436
MWAWTextListener::m_psStack
std::vector< std::shared_ptr< MWAWTextListenerInternal::State > > m_psStack
stack of local state
Definition MWAWTextListener.hxx:277
MWAWTextListener::_openListElement
void _openListElement()
open a list level
Definition MWAWTextListener.cxx:829
MWAWTextListener::handleSubDocument
void handleSubDocument(MWAWSubDocumentPtr const &subDocument, libmwaw::SubDocumentType subDocumentType) final
function called to add a subdocument
Definition MWAWTextListener.cxx:1643
MWAWTextListener::addEmptyTableCell
void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1, 1)) final
add empty cell
Definition MWAWTextListener.cxx:1824
MWAWTextListener::isHeaderFooterOpened
bool isHeaderFooterOpened() const final
returns true if the header/footer is open
Definition MWAWTextListener.cxx:634
MWAWTextListener::_openParagraph
void _openParagraph()
Definition MWAWTextListener.cxx:758
MWAWTextListener::insertField
void insertField(MWAWField const &field) final
adds a field type
Definition MWAWTextListener.cxx:451
MWAWTextListener::m_documentInterface
librevenge::RVNGTextInterface * m_documentInterface
the document interface
Definition MWAWTextListener.hxx:281
MWAWTextListener::insertShape
void insertShape(MWAWPosition const &pos, MWAWGraphicShape const &shape, MWAWGraphicStyle const &style) final
adds a shape picture in given position
Definition MWAWTextListener.cxx:1136
MWAWTextListener::insertComment
void insertComment(MWAWSubDocumentPtr &subDocument) final
adds comment
Definition MWAWTextListener.cxx:1095
MWAWTextListener::_closeListElement
void _closeListElement()
close a list level
Definition MWAWTextListener.cxx:859
MWAWTextListener::openTable
void openTable(MWAWTable const &table) final
open a table
Definition MWAWTextListener.cxx:1756
MWAWTextListener::isSectionOpened
bool isSectionOpened() const final
returns true if a section is opened
Definition MWAWTextListener.cxx:668
MWAWTextListener::openLink
void openLink(MWAWLink const &link) final
open a link
Definition MWAWTextListener.cxx:469
MWAWTextListener::_closeSection
void _closeSection()
does close a section (low level)
Definition MWAWTextListener.cxx:738
MWAWTextListener::_resetParagraphState
void _resetParagraphState(const bool isListElement=false)
Definition MWAWTextListener.cxx:808
MWAWTextListener::_popParsingState
void _popParsingState()
resets the previous parsing state
Definition MWAWTextListener.cxx:1891
MWAWTextListener::_closeSpan
void _closeSpan()
low level: the function which closes the last opened span property
Definition MWAWTextListener.cxx:974
MWAWTextListener::getPageSpan
MWAWPageSpan const & getPageSpan() final
returns the current page span
Definition MWAWTextListener.cxx:566
MWAWTextListener::_handleFrameParameters
void _handleFrameParameters(librevenge::RVNGPropertyList &propList, MWAWPosition const &pos)
Definition MWAWTextListener.cxx:1401
MWAWTextListener::closeLink
void closeLink() final
close a link
Definition MWAWTextListener.cxx:485
MWAWTextListener::_closePageSpan
void _closePageSpan()
does close a page (low level)
Definition MWAWTextListener.cxx:619
MWAWTextListener::m_parserState
MWAWParserState & m_parserState
the parser state
Definition MWAWTextListener.hxx:279
MWAWTextListener::insertTextBox
void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr const &subDocument, MWAWGraphicStyle const &frameStyle=MWAWGraphicStyle::emptyStyle()) final
adds a textbox in given position
Definition MWAWTextListener.cxx:1120
MWAWTextListener::insertUnicodeString
void insertUnicodeString(librevenge::RVNGString const &str) final
adds a unicode string
Definition MWAWTextListener.cxx:305
MWAWTextListener::openTableCell
void openTableCell(MWAWCell const &cell) final
open a cell
Definition MWAWTextListener.cxx:1843
MWAWTextListener::isSubDocumentOpened
bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const final
returns try if a subdocument is open
Definition MWAWTextListener.cxx:1728
MWAWTextListener::closeGroup
void closeGroup() final
close a group
Definition MWAWTextListener.cxx:1389
MWAWTextListener::openFrame
bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle()) final
tries to open a frame
Definition MWAWTextListener.cxx:1258
MWAWTextListener::getParagraph
MWAWParagraph const & getParagraph() const final
returns the actual paragraph
Definition MWAWTextListener.cxx:443
MWAWTextListener::endDocument
void endDocument(bool sendDelayedSubDoc=true) final
ends the document
Definition MWAWTextListener.cxx:530
MWAWTextListener::closeTable
void closeTable() final
closes this table
Definition MWAWTextListener.cxx:1779
MWAWTextListener::setFont
void setFont(MWAWFont const &font) final
sets the font
Definition MWAWTextListener.cxx:410
MWAWTextListener::MWAWTextListener
MWAWTextListener(MWAWParserState &parserState, std::vector< MWAWPageSpan > const &pageList, librevenge::RVNGTextInterface *documentInterface)
constructor
Definition MWAWTextListener.cxx:222
MWAWTextListener::insertEOL
void insertEOL(bool softBreak=false) final
adds an end of line ( by default an hard one)
Definition MWAWTextListener.cxx:312
MWAWTextListener::_openPageSpan
void _openPageSpan(bool sendHeaderFooters=true)
does open a new page (low level)
Definition MWAWTextListener.cxx:574
MWAWTextListener::_flushText
void _flushText()
low level: flush the deferred text
Definition MWAWTextListener.cxx:1007
MWAWTextListener::getFont
MWAWFont const & getFont() const final
returns the actual font
Definition MWAWTextListener.cxx:426
MWAWTextListener::_openSection
void _openSection()
does open a section (low level)
Definition MWAWTextListener.cxx:715
MWAWTextListener::_closeParagraph
void _closeParagraph()
Definition MWAWTextListener.cxx:784
MWAWTextListener::insertUnicode
void insertUnicode(uint32_t character) final
adds an unicode character.
Definition MWAWTextListener.cxx:295
MWAWTextListener::getSection
MWAWSection const & getSection() const final
returns the actual section
Definition MWAWTextListener.cxx:673
MWAWTextListener::_startSubDocument
void _startSubDocument()
Definition MWAWTextListener.cxx:1736
MWAWTextListener::insertNote
void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument) final
insert a note
Definition MWAWTextListener.cxx:1038
MWAWTextListener::_insertBreakIfNecessary
void _insertBreakIfNecessary(librevenge::RVNGPropertyList &propList)
Definition MWAWTextListener.cxx:389
MWAWTextListener::closeSection
bool closeSection() final
close a section
Definition MWAWTextListener.cxx:700
MWAWTextListener::insertBreak
void insertBreak(BreakType breakType) final
inserts a break type: ColumBreak, PageBreak, ..
Definition MWAWTextListener.cxx:341
MWAWTextListener::_flushDeferredTabs
void _flushDeferredTabs()
low level: flush the deferred tabs
Definition MWAWTextListener.cxx:988
MWAWTextListener::_appendParagraphProperties
void _appendParagraphProperties(librevenge::RVNGPropertyList &propList, const bool isListElement=false)
Definition MWAWTextListener.cxx:816
MWAWTextListener::closeFrame
void closeFrame() final
tries to close the last open frame
Definition MWAWTextListener.cxx:1328
MWAWTextListener::insertPicture
void insertPicture(MWAWPosition const &pos, MWAWEmbeddedObject const &picture, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle()) final
adds a picture with potential various representationin given position
Definition MWAWTextListener.cxx:1234
MWAWTextListener::getType
Type getType() const final
returns the listener type
Definition MWAWTextListener.hxx:73
MWAWTextListener::openGroup
bool openGroup(MWAWPosition const &pos) final
open a group
Definition MWAWTextListener.cxx:1338
MWAWTextListener::openSection
bool openSection(MWAWSection const &section) final
open a section if possible
Definition MWAWTextListener.cxx:683
MWAWTextListener::closeTableCell
void closeTableCell() final
close a cell
Definition MWAWTextListener.cxx:1860
MWAWTextListener::isDocumentStarted
bool isDocumentStarted() const final
returns true if a document is opened
Definition MWAWTextListener.cxx:512
MWAWTextListener::insertCharacter
void insertCharacter(unsigned char c) final
insert a character using the font converter to find the utf8 character
Definition MWAWTextListener.cxx:249
MWAWTextListener::setDocumentMetaData
void setDocumentMetaData(librevenge::RVNGPropertyList const &metadata) final
sets the documents metadata
Definition MWAWTextListener.cxx:499
MWAWTextListener::openTableRow
void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false) final
open a row with given height ( if h < 0.0, set min-row-height = -h )
Definition MWAWTextListener.cxx:1793
MWAWTextListener::_getListId
int _getListId() const
low level: find a list id which corresponds to actual list and a change of level.
Definition MWAWTextListener.cxx:875
MWAWTextListener::insertFooter
bool insertFooter(MWAWSubDocumentPtr const &subDocument, librevenge::RVNGPropertyList const &extras) final
insert a footer
Definition MWAWTextListener.cxx:652
MWAWTextListener::_endSubDocument
void _endSubDocument()
Definition MWAWTextListener.cxx:1742
MWAWTextListener::setDocumentLanguage
void setDocumentLanguage(std::string const &locale) final
sets the documents language
Definition MWAWTextListener.cxx:506
MWAWTextListener::~MWAWTextListener
~MWAWTextListener() final
destructor
Definition MWAWTextListener.cxx:231
MWAWTextListener::canOpenSectionAddBreak
bool canOpenSectionAddBreak() const final
returns true if we can add open a section, add page break, ...
Definition MWAWTextListener.cxx:678
libmwaw_internal.hxx
MWAWVec2i
MWAWVec2< int > MWAWVec2i
MWAWVec2 of int.
Definition libmwaw_internal.hxx:838
MWAWSubDocumentPtr
std::shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition libmwaw_internal.hxx:565
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition libmwaw_internal.hxx:551
MWAWTextListenerInternal
Internal and low level namespace to define the states of MWAWTextListener.
Definition MWAWTextListener.cxx:71
libmwaw
namespace used to regroup all libwpd functions, enumerations which we have redefined for internal usa...
Definition libmwaw_internal.cxx:51
librevenge
Definition MWAWDocument.hxx:57
MWAWEmbeddedObject
small class use to define a embedded object
Definition libmwaw_internal.hxx:467
MWAWField
a field
Definition libmwaw_internal.hxx:399
MWAWLink
a link
Definition libmwaw_internal.hxx:430
MWAWNote
a note
Definition libmwaw_internal.hxx:445
MWAWTextListenerInternal::DocumentState
a class to store the document state of a MWAWTextListener
Definition MWAWTextListener.cxx:75
MWAWTextListenerInternal::State
the state of a MWAWTextListener
Definition MWAWTextListener.cxx:116