STOFFListener.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 -*- */
/* libstaroffice
* 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 STOFF_LISTENER_H
#define STOFF_LISTENER_H
#include <vector>
#include <librevenge/librevenge.h>
#include "libstaroffice_internal.hxx"
#include "STOFFGraphicStyle.hxx"
#include "STOFFPosition.hxx"
class STOFFCell;
class STOFFTable;
class STOFFListener
{
public:
virtual ~STOFFListener();
enum Type { Graphic, Presentation, Spreadsheet, Text };
enum BreakType { PageBreak=0, SoftPageBreak, ColumnBreak };
//------- generic accessor ---
virtual Type getType() const = 0;
virtual bool canWriteText() const =0;
STOFFListManagerPtr getListManager() const
{
return m_listManager;
}
// ------ main document -------
virtual void setDocumentLanguage(std::string locale) = 0;
virtual void setDocumentMetaData(const librevenge::RVNGPropertyList &list) = 0;
virtual void startDocument() = 0;
virtual bool isDocumentStarted() const =0;
virtual void endDocument(bool sendDelayedSubDoc=true) = 0;
// ------ page --------
virtual bool isPageSpanOpened() const = 0;
virtual STOFFPageSpan const &getPageSpan() = 0;
// ------ header/footer --------
virtual bool openHeader(librevenge::RVNGPropertyList const &extras) = 0;
virtual bool openFooter(librevenge::RVNGPropertyList const &extras) = 0;
virtual bool closeHeader() = 0;
virtual bool closeFooter() = 0;
virtual bool insertHeaderRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which) = 0;
virtual bool insertFooterRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which) = 0;
virtual bool isHeaderFooterOpened() const = 0;
// ------ text data -----------
virtual void insertChar(uint8_t character)=0;
virtual void insertUnicode(uint32_t character)=0;
void insertUnicodeList(std::vector<uint32_t> const &list)
{
if (list.empty() || !canWriteText())
return;
for (unsigned int i : list) {
if (i==0x9) insertTab();
else if (i==0xa || i==0xc) insertEOL(); // checkme: use softBreak ?
else insertUnicode(i);
}
}
virtual void insertUnicodeString(librevenge::RVNGString const &str)=0;
virtual void insertTab()=0;
virtual void insertEOL(bool softBreak=false)=0;
// ------ text format -----------
virtual void setFont(STOFFFont const &font)=0;
virtual STOFFFont const &getFont() const=0;
// ------ paragraph format -----------
virtual bool isParagraphOpened() const=0;
virtual void setParagraph(STOFFParagraph const &paragraph)=0;
virtual STOFFParagraph const &getParagraph() const=0;
// ------ style definition -----------
virtual void defineStyle(STOFFFont const &style) = 0;
virtual bool isFontStyleDefined(librevenge::RVNGString const &name) const = 0;
virtual void defineStyle(STOFFGraphicStyle const &style) = 0;
virtual bool isGraphicStyleDefined(librevenge::RVNGString const &name) const = 0;
virtual void defineStyle(STOFFParagraph const &style) = 0;
virtual bool isParagraphStyleDefined(librevenge::RVNGString const &name) const = 0;
// ------- fields ----------------
virtual void insertField(STOFFField const &field)=0;
// ------- link ----------------
virtual void openLink(STOFFLink const &link)=0;
virtual void closeLink()=0;
// ------- table -----------------
virtual void openTable(STOFFTable const &table) = 0;
virtual void closeTable() = 0;
virtual void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false) = 0;
virtual void closeTableRow() = 0;
virtual void openTableCell(STOFFCell const &cell) = 0;
virtual void closeTableCell() = 0;
virtual void addCoveredTableCell(STOFFVec2i const &pos) = 0;
virtual void addEmptyTableCell(STOFFVec2i const &pos, STOFFVec2i span=STOFFVec2i(1,1)) = 0;
// ------- section ---------------
virtual bool canOpenSectionAddBreak() const =0;
virtual bool isSectionOpened() const=0;
virtual STOFFSection const &getSection() const=0;
virtual bool openSection(STOFFSection const &section)=0;
virtual bool closeSection()=0;
virtual void insertBreak(BreakType breakType)=0;
// ------- subdocument ---------------
virtual void insertNote(STOFFNote const &note, STOFFSubDocumentPtr &subDocument)=0;
virtual void insertComment(STOFFSubDocumentPtr &subDocument, librevenge::RVNGString const &creator="", librevenge::RVNGString const &date="") = 0;
virtual void insertEquation(STOFFFrameStyle const &frame, librevenge::RVNGString const &equation,
STOFFGraphicStyle const &style=STOFFGraphicStyle()) = 0;
virtual void insertPicture(STOFFFrameStyle const &frame, STOFFEmbeddedObject const &picture,
STOFFGraphicStyle const &style=STOFFGraphicStyle())=0;
virtual void insertShape(STOFFFrameStyle const &frame, STOFFGraphicShape const &shape, STOFFGraphicStyle const &style) = 0;
virtual void insertTextBox(STOFFFrameStyle const &frame, STOFFSubDocumentPtr subDocument,
STOFFGraphicStyle const &frameStyle=STOFFGraphicStyle()) = 0;
#if 0
virtual void insertTextBoxInShape(STOFFFrameStyle const &frame, STOFFSubDocumentPtr subDocument,
STOFFGraphicShape const &/*shape*/,
STOFFGraphicStyle const &frameStyle=STOFFGraphicStyle())
{
static bool first=true;
if (first) {
STOFF_DEBUG_MSG(("STOFFListener::insertTextBoxInShape: umimplemented, revert to basic insertTextBox\n"));
first=false;
}
insertTextBox(frame, subDocument, frameStyle);
}
#endif
virtual bool openFrame(STOFFFrameStyle const &frame, STOFFGraphicStyle const &style=STOFFGraphicStyle()) = 0;
virtual void closeFrame() = 0;
virtual bool openGroup(STOFFFrameStyle const &frame) = 0;
virtual void closeGroup() = 0;
virtual void handleSubDocument(STOFFSubDocumentPtr subDocument, libstoff::SubDocumentType subDocumentType) = 0;
virtual bool isSubDocumentOpened(libstoff::SubDocumentType &subdocType) const = 0;
protected:
explicit STOFFListener(STOFFListManagerPtr &listManager);
STOFFListManagerPtr m_listManager;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
STOFFGraphicStyle.hxx
STOFFPosition.hxx
STOFFCell
a structure used to define a cell and its format
Definition STOFFCell.hxx:54
STOFFFont
Class to store font.
Definition STOFFFont.hxx:44
STOFFFrameStyle
Class to store a frame style.
Definition STOFFFrameStyle.hxx:46
STOFFGraphicShape
a structure used to define a picture shape
Definition STOFFGraphicShape.hxx:46
STOFFGraphicStyle
Class to store a graphic style.
Definition STOFFGraphicStyle.hxx:45
STOFFListener::insertShape
virtual void insertShape(STOFFFrameStyle const &frame, STOFFGraphicShape const &shape, STOFFGraphicStyle const &style)=0
adds a shape picture in given position
STOFFListener::closeTableRow
virtual void closeTableRow()=0
closes this row
STOFFListener::isDocumentStarted
virtual bool isDocumentStarted() const =0
returns true if a document is opened
STOFFListener::STOFFListener
STOFFListener(STOFFListManagerPtr &listManager)
constructor
Definition STOFFListener.cxx:41
STOFFListener::insertEquation
virtual void insertEquation(STOFFFrameStyle const &frame, librevenge::RVNGString const &equation, STOFFGraphicStyle const &style=STOFFGraphicStyle())=0
adds a equation given a position
STOFFListener::closeLink
virtual void closeLink()=0
close a link
STOFFListener::openTableCell
virtual void openTableCell(STOFFCell const &cell)=0
open a cell
STOFFListener::insertHeaderRegion
virtual bool insertHeaderRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which)=0
insert a header
STOFFListener::openLink
virtual void openLink(STOFFLink const &link)=0
open a link
STOFFListener::addCoveredTableCell
virtual void addCoveredTableCell(STOFFVec2i const &pos)=0
add covered cell
STOFFListener::openSection
virtual bool openSection(STOFFSection const &section)=0
open a section if possible
STOFFListener::isSectionOpened
virtual bool isSectionOpened() const =0
returns true if a section is opened
STOFFListener::setFont
virtual void setFont(STOFFFont const &font)=0
sets the font
STOFFListener::handleSubDocument
virtual void handleSubDocument(STOFFSubDocumentPtr subDocument, libstoff::SubDocumentType subDocumentType)=0
low level: function called to add a subdocument
STOFFListener::Type
Type
the listener type
Definition STOFFListener.hxx:57
STOFFListener::Spreadsheet
@ Spreadsheet
Definition STOFFListener.hxx:57
STOFFListener::Text
@ Text
Definition STOFFListener.hxx:57
STOFFListener::Graphic
@ Graphic
Definition STOFFListener.hxx:57
STOFFListener::Presentation
@ Presentation
Definition STOFFListener.hxx:57
STOFFListener::closeHeader
virtual bool closeHeader()=0
close a header
STOFFListener::insertUnicodeString
virtual void insertUnicodeString(librevenge::RVNGString const &str)=0
adds a unicode string
STOFFListener::isParagraphOpened
virtual bool isParagraphOpened() const =0
returns true if a paragraph or a list is opened
STOFFListener::openTable
virtual void openTable(STOFFTable const &table)=0
open a table
STOFFListener::closeTable
virtual void closeTable()=0
closes this table
STOFFListener::setParagraph
virtual void setParagraph(STOFFParagraph const &paragraph)=0
sets the paragraph
STOFFListener::insertField
virtual void insertField(STOFFField const &field)=0
adds a field type
STOFFListener::openFooter
virtual bool openFooter(librevenge::RVNGPropertyList const &extras)=0
open a footer (interaction with STOFFPageSpan which fills the parameters for openFooter)
STOFFListener::getType
virtual Type getType() const =0
returns the listener type
STOFFListener::getParagraph
virtual STOFFParagraph const & getParagraph() const =0
returns the actual paragraph
STOFFListener::getListManager
STOFFListManagerPtr getListManager() const
return the list manager
Definition STOFFListener.hxx:67
STOFFListener::openFrame
virtual bool openFrame(STOFFFrameStyle const &frame, STOFFGraphicStyle const &style=STOFFGraphicStyle())=0
low level: tries to open a frame
STOFFListener::defineStyle
virtual void defineStyle(STOFFParagraph const &style)=0
defines a paragraph styles
STOFFListener::insertUnicodeList
void insertUnicodeList(std::vector< uint32_t > const &list)
try to insert a list of unicode character
Definition STOFFListener.hxx:114
STOFFListener::openHeader
virtual bool openHeader(librevenge::RVNGPropertyList const &extras)=0
open a header (interaction with STOFFPageSpan which fills the parameters for openHeader)
STOFFListener::insertNote
virtual void insertNote(STOFFNote const &note, STOFFSubDocumentPtr &subDocument)=0
insert a note
STOFFListener::closeSection
virtual bool closeSection()=0
close a section
STOFFListener::isGraphicStyleDefined
virtual bool isGraphicStyleDefined(librevenge::RVNGString const &name) const =0
check if a graphic style with a display name is already defined
STOFFListener::isParagraphStyleDefined
virtual bool isParagraphStyleDefined(librevenge::RVNGString const &name) const =0
check if a paragraph style with a display name is already defined
STOFFListener::endDocument
virtual void endDocument(bool sendDelayedSubDoc=true)=0
ends the document
STOFFListener::closeFrame
virtual void closeFrame()=0
low level: tries to close the last opened frame
STOFFListener::insertEOL
virtual void insertEOL(bool softBreak=false)=0
adds an end of line ( by default an hard one)
STOFFListener::BreakType
BreakType
the different break type
Definition STOFFListener.hxx:59
STOFFListener::ColumnBreak
@ ColumnBreak
Definition STOFFListener.hxx:59
STOFFListener::SoftPageBreak
@ SoftPageBreak
Definition STOFFListener.hxx:59
STOFFListener::PageBreak
@ PageBreak
Definition STOFFListener.hxx:59
STOFFListener::m_listManager
STOFFListManagerPtr m_listManager
the list manager
Definition STOFFListener.hxx:250
STOFFListener::closeTableCell
virtual void closeTableCell()=0
close a cell
STOFFListener::insertFooterRegion
virtual bool insertFooterRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which)=0
insert a footer
STOFFListener::defineStyle
virtual void defineStyle(STOFFGraphicStyle const &style)=0
defines a graphic styles
STOFFListener::startDocument
virtual void startDocument()=0
starts the document
STOFFListener::insertBreak
virtual void insertBreak(BreakType breakType)=0
inserts a break type: ColumBreak, PageBreak, ..
STOFFListener::addEmptyTableCell
virtual void addEmptyTableCell(STOFFVec2i const &pos, STOFFVec2i span=STOFFVec2i(1, 1))=0
add empty cell
STOFFListener::canWriteText
virtual bool canWriteText() const =0
returns true if we can add text data
STOFFListener::isPageSpanOpened
virtual bool isPageSpanOpened() const =0
returns true if a page is opened
STOFFListener::insertChar
virtual void insertChar(uint8_t character)=0
adds a basic character, ..
STOFFListener::~STOFFListener
virtual ~STOFFListener()
destructor
Definition STOFFListener.cxx:48
STOFFListener::closeGroup
virtual void closeGroup()=0
low level: tries to close the last opened group
STOFFListener::canOpenSectionAddBreak
virtual bool canOpenSectionAddBreak() const =0
returns true if we can add open a section, add page break, ...
STOFFListener::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 )
STOFFListener::isSubDocumentOpened
virtual bool isSubDocumentOpened(libstoff::SubDocumentType &subdocType) const =0
returns true if a subdocument is open
STOFFListener::insertUnicode
virtual void insertUnicode(uint32_t character)=0
adds an unicode character.
STOFFListener::setDocumentLanguage
virtual void setDocumentLanguage(std::string locale)=0
sets the documents language
STOFFListener::isFontStyleDefined
virtual bool isFontStyleDefined(librevenge::RVNGString const &name) const =0
check if a font style with a display name is already defined
STOFFListener::getFont
virtual STOFFFont const & getFont() const =0
returns the actual font
STOFFListener::insertTextBox
virtual void insertTextBox(STOFFFrameStyle const &frame, STOFFSubDocumentPtr subDocument, STOFFGraphicStyle const &frameStyle=STOFFGraphicStyle())=0
adds a textbox in given position
STOFFListener::insertTab
virtual void insertTab()=0
adds a tab
STOFFListener::isHeaderFooterOpened
virtual bool isHeaderFooterOpened() const =0
returns true if the header/footer is open
STOFFListener::insertPicture
virtual void insertPicture(STOFFFrameStyle const &frame, STOFFEmbeddedObject const &picture, STOFFGraphicStyle const &style=STOFFGraphicStyle())=0
adds a picture with various representationin given position.
STOFFListener::insertComment
virtual void insertComment(STOFFSubDocumentPtr &subDocument, librevenge::RVNGString const &creator="", librevenge::RVNGString const &date="")=0
adds comment
STOFFListener::getPageSpan
virtual STOFFPageSpan const & getPageSpan()=0
returns the current page span
STOFFListener::setDocumentMetaData
virtual void setDocumentMetaData(const librevenge::RVNGPropertyList &list)=0
sets the document meta data
STOFFListener::getSection
virtual STOFFSection const & getSection() const =0
returns the actual section
STOFFListener::openGroup
virtual bool openGroup(STOFFFrameStyle const &frame)=0
low level: tries to open a group
STOFFListener::closeFooter
virtual bool closeFooter()=0
close a footer
STOFFListener::defineStyle
virtual void defineStyle(STOFFFont const &style)=0
defines a font styles
STOFFPageSpan
A class which defines the page properties.
Definition STOFFPageSpan.hxx:76
STOFFParagraph
class to store the paragraph properties
Definition STOFFParagraph.hxx:48
STOFFSection
a class which stores section properties
Definition STOFFSection.hxx:46
STOFFTable
a class used to recreate the table structure using cell informations, ....
Definition STOFFTable.hxx:52
libstaroffice_internal.hxx
STOFFSubDocumentPtr
std::shared_ptr< STOFFSubDocument > STOFFSubDocumentPtr
a smart pointer of STOFFSubDocument
Definition libstaroffice_internal.hxx:499
STOFFListManagerPtr
std::shared_ptr< STOFFListManager > STOFFListManagerPtr
a smart pointer of STOFFListManager
Definition libstaroffice_internal.hxx:493
STOFFVec2i
STOFFVec2< int > STOFFVec2i
STOFFVec2 of int.
Definition libstaroffice_internal.hxx:767
STOFF_DEBUG_MSG
#define STOFF_DEBUG_MSG(M)
Definition libstaroffice_internal.hxx:129
libstoff::SubDocumentType
SubDocumentType
Definition libstaroffice_internal.hxx:185
STOFFEmbeddedObject
small class use to define a embedded object
Definition libstaroffice_internal.hxx:408
STOFFField
a field
Definition libstaroffice_internal.hxx:363
STOFFLink
a link
Definition libstaroffice_internal.hxx:375
STOFFNote
a note
Definition libstaroffice_internal.hxx:389