MWAWListener.hxx Source File documentation

MWAWListener.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 MWAW_LISTENER_H
35 #define MWAW_LISTENER_H
36
37 #include <vector>
38
39 #include <librevenge/librevenge.h>
40
41 #include "libmwaw_internal.hxx"
42
43 #include "MWAWGraphicStyle.hxx"
44
45 class MWAWCell;
46 class MWAWTable;
47
49 class MWAWListener
50 {
51 public:
53 virtual ~MWAWListener();
54
56 enum Type { Graphic, Presentation, Spreadsheet, Text };
58 enum BreakType { PageBreak=0, SoftPageBreak, ColumnBreak };
59
60 //------- generic accessor ---
62 virtual Type getType() const = 0;
64 virtual bool canWriteText() const =0;
65
66 // ------ main document -------
68 virtual void setDocumentMetaData(librevenge::RVNGPropertyList const &metadata) = 0;
70 virtual void setDocumentLanguage(std::string const &locale) = 0;
72 virtual void startDocument() = 0;
74 virtual bool isDocumentStarted() const =0;
76 virtual void endDocument(bool sendDelayedSubDoc=true) = 0;
77
78 // ------ page --------
80 virtual bool isPageSpanOpened() const = 0;
84 virtual MWAWPageSpan const &getPageSpan() = 0;
85
86 // ------ header/footer --------
88 virtual bool insertHeader(MWAWSubDocumentPtr const &subDocument, librevenge::RVNGPropertyList const &extras) = 0;
90 virtual bool insertFooter(MWAWSubDocumentPtr const &subDocument, librevenge::RVNGPropertyList const &extras) = 0;
92 virtual bool isHeaderFooterOpened() const = 0;
93
94 // ------ text data -----------
96 virtual void insertChar(uint8_t character)=0;
99 virtual void insertCharacter(unsigned char c)=0;
105 virtual int insertCharacter(unsigned char c, MWAWInputStreamPtr &input, long endPos=-1)=0;
108 virtual void insertUnicode(uint32_t character)=0;
110 virtual void insertUnicodeString(librevenge::RVNGString const &str)=0;
111
113 virtual void insertTab()=0;
115 virtual void insertEOL(bool softBreak=false)=0;
116
117 // ------ text format -----------
119 virtual void setFont(MWAWFont const &font)=0;
121 virtual MWAWFont const &getFont() const=0;
122
123 // ------ paragraph format -----------
125 virtual bool isParagraphOpened() const=0;
127 virtual void setParagraph(MWAWParagraph const &paragraph)=0;
129 virtual MWAWParagraph const &getParagraph() const=0;
130
131 // ------- fields ----------------
133 virtual void insertField(MWAWField const &field)=0;
134
135 // ------- link ----------------
136
138 virtual void openLink(MWAWLink const &link)=0;
140 virtual void closeLink()=0;
141
142 // ------- table -----------------
144 virtual void openTable(MWAWTable const &table) = 0;
146 virtual void closeTable() = 0;
148 virtual void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false) = 0;
150 virtual void closeTableRow() = 0;
152 virtual void openTableCell(MWAWCell const &cell) = 0;
154 virtual void closeTableCell() = 0;
156 virtual void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1,1)) = 0;
157
158 // ------- section ---------------
160 virtual bool canOpenSectionAddBreak() const =0;
162 virtual bool isSectionOpened() const=0;
164 virtual MWAWSection const &getSection() const=0;
166 virtual bool openSection(MWAWSection const &section)=0;
168 virtual bool closeSection()=0;
170 virtual void insertBreak(BreakType breakType)=0;
171
172 // ------- subdocument ---------------
174 virtual void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument)=0;
176 virtual void insertComment(MWAWSubDocumentPtr &subDocument) = 0;
179 virtual void insertPicture(MWAWPosition const &pos, MWAWEmbeddedObject const &picture,
180 MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())=0;
182 virtual void insertShape(MWAWPosition const &pos, MWAWGraphicShape const &shape,
183 MWAWGraphicStyle const &style) = 0;
185 virtual void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr const &subDocument,
186 MWAWGraphicStyle const &frameStyle=MWAWGraphicStyle::emptyStyle()) = 0;
188 virtual void insertTextBoxInShape(MWAWPosition const &pos, MWAWSubDocumentPtr const &subDocument,
189 MWAWGraphicShape const &/*shape*/,
190 MWAWGraphicStyle const &frameStyle=MWAWGraphicStyle::emptyStyle())
191 {
192 static bool first=true;
193 if (first) {
194 MWAW_DEBUG_MSG(("MWAWListener::insertTextBoxInShape: umimplemented, revert to basic insertTextBox\n"));
195 first=false;
196 }
197 insertTextBox(pos, subDocument, frameStyle);
198 }
200 virtual bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle()) = 0;
202 virtual void closeFrame() = 0;
204 virtual bool openGroup(MWAWPosition const &pos) = 0;
206 virtual void closeGroup() = 0;
208 virtual void handleSubDocument(MWAWSubDocumentPtr const &subDocument, libmwaw::SubDocumentType subDocumentType) = 0;
210 virtual bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const = 0;
211 };
212
213 #endif
214 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWListener::canOpenSectionAddBreak
virtual bool canOpenSectionAddBreak() const =0
returns true if we can add open a section, add page break, ...
MWAWListener::startDocument
virtual void startDocument()=0
starts the document
MWAWListener::endDocument
virtual void endDocument(bool sendDelayedSubDoc=true)=0
ends the document
MWAWListener::insertCharacter
virtual void insertCharacter(unsigned char c)=0
insert a character using the font converter to find the utf8 character
MWAWListener::openSection
virtual bool openSection(MWAWSection const &section)=0
open a section if possible
MWAWListener::isSectionOpened
virtual bool isSectionOpened() const =0
returns true if a section is opened
MWAWListener::isParagraphOpened
virtual bool isParagraphOpened() const =0
returns true if a paragraph or a list is opened
MWAWPageSpan
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:95
libmwaw_internal.hxx
MWAWListener::closeTableCell
virtual void closeTableCell()=0
close a cell
MWAWLink
a link
Definition: libmwaw_internal.hxx:430
MWAWListener::ColumnBreak
Definition: MWAWListener.hxx:58
MWAWListener::insertUnicode
virtual void insertUnicode(uint32_t character)=0
adds an unicode character.
MWAWListener::Graphic
Definition: MWAWListener.hxx:56
MWAWListener::setParagraph
virtual void setParagraph(MWAWParagraph const &paragraph)=0
sets the paragraph
MWAWListener::openLink
virtual void openLink(MWAWLink const &link)=0
open a link
MWAWListener::insertComment
virtual void insertComment(MWAWSubDocumentPtr &subDocument)=0
adds comment
MWAWListener::closeGroup
virtual void closeGroup()=0
low level: tries to close the last opened group
MWAWListener::openTable
virtual void openTable(MWAWTable const &table)=0
open a table
MWAWListener::setFont
virtual void setFont(MWAWFont const &font)=0
sets the font
MWAWGraphicStyle
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
libmwaw::SubDocumentType
SubDocumentType
Definition: libmwaw_internal.hxx:188
MWAWListener::SoftPageBreak
Definition: MWAWListener.hxx:58
MWAWTable
a class used to recreate the table structure using cell informations, ....
Definition: MWAWTable.hxx:51
MWAWListener::isHeaderFooterOpened
virtual bool isHeaderFooterOpened() const =0
returns true if the header/footer is open
MWAWVec2i
MWAWVec2< int > MWAWVec2i
MWAWVec2 of int.
Definition: libmwaw_internal.hxx:834
MWAWListener::addEmptyTableCell
virtual void addEmptyTableCell(MWAWVec2i const &pos, MWAWVec2i span=MWAWVec2i(1, 1))=0
add empty cell
MWAWListener::getFont
virtual MWAWFont const & getFont() const =0
returns the actual font
MWAWListener::isDocumentStarted
virtual bool isDocumentStarted() const =0
returns true if a document is opened
MWAWListener::insertChar
virtual void insertChar(uint8_t character)=0
adds a basic character, ..
MWAWListener::Type
Type
the listener type
Definition: MWAWListener.hxx:56
MWAWCell
a structure used to define a cell and its format
Definition: MWAWCell.hxx:52
MWAWListener::setDocumentLanguage
virtual void setDocumentLanguage(std::string const &locale)=0
sets the documents language
MWAWListener::isPageSpanOpened
virtual bool isPageSpanOpened() const =0
returns true if a page is opened
MWAWListener::insertFooter
virtual bool insertFooter(MWAWSubDocumentPtr const &subDocument, librevenge::RVNGPropertyList const &extras)=0
insert a footer (interaction with MWAWPageSpan which fills the parameters for openFooter) ...
MWAWListener::insertUnicodeString
virtual void insertUnicodeString(librevenge::RVNGString const &str)=0
adds a unicode string
MWAWListener::openGroup
virtual bool openGroup(MWAWPosition const &pos)=0
low level: tries to open a group
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:43
MWAWListener::insertBreak
virtual void insertBreak(BreakType breakType)=0
inserts a break type: ColumBreak, PageBreak, ..
MWAW_DEBUG_MSG
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:129
MWAWListener::BreakType
BreakType
the different break type
Definition: MWAWListener.hxx:58
MWAWListener::insertPicture
virtual void insertPicture(MWAWPosition const &pos, MWAWEmbeddedObject const &picture, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())=0
adds a picture with various representationin given position.
MWAWListener::canWriteText
virtual bool canWriteText() const =0
returns true if we can add text data
MWAWListener::closeLink
virtual void closeLink()=0
close a link
MWAWListener::insertTextBoxInShape
virtual void insertTextBoxInShape(MWAWPosition const &pos, MWAWSubDocumentPtr const &subDocument, MWAWGraphicShape const &, MWAWGraphicStyle const &frameStyle=MWAWGraphicStyle::emptyStyle())
adds a textbox in given position
Definition: MWAWListener.hxx:188
MWAWListener::closeFrame
virtual void closeFrame()=0
low level: tries to close the last opened frame
MWAWListener::closeTableRow
virtual void closeTableRow()=0
closes this row
MWAWListener::insertEOL
virtual void insertEOL(bool softBreak=false)=0
adds an end of line ( by default an hard one)
MWAWListener::getPageSpan
virtual MWAWPageSpan const & getPageSpan()=0
returns the current page span
MWAWListener::getSection
virtual MWAWSection const & getSection() const =0
returns the actual section
MWAWListener::insertNote
virtual void insertNote(MWAWNote const &note, MWAWSubDocumentPtr &subDocument)=0
insert a note
MWAWEmbeddedObject
small class use to define a embedded object
Definition: libmwaw_internal.hxx:467
MWAWListener::PageBreak
Definition: MWAWListener.hxx:58
MWAWListener::insertHeader
virtual bool insertHeader(MWAWSubDocumentPtr const &subDocument, librevenge::RVNGPropertyList const &extras)=0
insert a header (interaction with MWAWPageSpan which fills the parameters for openHeader) ...
MWAWListener::insertShape
virtual void insertShape(MWAWPosition const &pos, MWAWGraphicShape const &shape, MWAWGraphicStyle const &style)=0
adds a shape picture in given position
MWAWSection
a class which stores section properties
Definition: MWAWSection.hxx:45
MWAWListener::Text
Definition: MWAWListener.hxx:56
MWAWListener::Spreadsheet
Definition: MWAWListener.hxx:56
MWAWListener::openTableCell
virtual void openTableCell(MWAWCell const &cell)=0
open a cell
MWAWListener::insertField
virtual void insertField(MWAWField const &field)=0
adds a field type
MWAWListener::getParagraph
virtual MWAWParagraph const & getParagraph() const =0
returns the actual paragraph
MWAWListener::setDocumentMetaData
virtual void setDocumentMetaData(librevenge::RVNGPropertyList const &metadata)=0
sets the documents metadata
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:547
MWAWListener::~MWAWListener
virtual ~MWAWListener()
destructor
Definition: MWAWListener.cxx:36
MWAWListener::Presentation
Definition: MWAWListener.hxx:56
MWAWGraphicShape
a structure used to define a picture shape
Definition: MWAWGraphicShape.hxx:45
MWAWListener::isSubDocumentOpened
virtual bool isSubDocumentOpened(libmwaw::SubDocumentType &subdocType) const =0
returns true if a subdocument is open
MWAWParagraph
class to store the paragraph properties
Definition: MWAWParagraph.hxx:84
MWAWField
a field
Definition: libmwaw_internal.hxx:399
MWAWListener::openFrame
virtual bool openFrame(MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())=0
low level: tries to open a frame
MWAWListener::insertTab
virtual void insertTab()=0
adds a tab
MWAWListener::insertTextBox
virtual void insertTextBox(MWAWPosition const &pos, MWAWSubDocumentPtr const &subDocument, MWAWGraphicStyle const &frameStyle=MWAWGraphicStyle::emptyStyle())=0
adds a textbox in given position
MWAWNote
a note
Definition: libmwaw_internal.hxx:445
MWAWListener::closeTable
virtual void closeTable()=0
closes this table
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: MWAWPosition.hxx:47
MWAWListener
This class contains a virtual interface to all listener.
Definition: MWAWListener.hxx:49
MWAWSubDocumentPtr
std::shared_ptr< MWAWSubDocument > MWAWSubDocumentPtr
a smart pointer of MWAWSubDocument
Definition: libmwaw_internal.hxx:561
MWAWListener::getType
virtual Type getType() const =0
returns the listener type
MWAWListener::handleSubDocument
virtual void handleSubDocument(MWAWSubDocumentPtr const &subDocument, libmwaw::SubDocumentType subDocumentType)=0
low level: function called to add a subdocument
MWAWListener::openTableRow
virtual void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false)=0
open a row with given height ( if h < 0.0, set min-row-height = -h )
MWAWGraphicStyle.hxx
MWAWVec2< int >
MWAWGraphicStyle::emptyStyle
static MWAWGraphicStyle emptyStyle()
returns an empty style.
Definition: MWAWGraphicStyle.hxx:304
MWAWListener::closeSection
virtual bool closeSection()=0
close a section