STOFFListener.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 /* libstaroffice
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 STOFF_LISTENER_H
35 #define STOFF_LISTENER_H
36 
37 #include <vector>
38 
39 #include <librevenge/librevenge.h>
40 
42 
43 #include "STOFFGraphicStyle.hxx"
44 
45 class STOFFCell;
46 class STOFFTable;
47 
50 {
51 public:
53  virtual ~STOFFListener() {}
54 
59 
60  //------- generic accessor ---
62  virtual Type getType() const = 0;
64  virtual bool canWriteText() const =0;
65 
66  // ------ main document -------
68  virtual void setDocumentLanguage(std::string locale) = 0;
70  virtual void setDocumentMetaData(const librevenge::RVNGPropertyList &list) = 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 STOFFPageSpan const &getPageSpan() = 0;
85 
86  // ------ header/footer --------
88  virtual bool openHeader(librevenge::RVNGPropertyList const &extras) = 0;
90  virtual bool openFooter(librevenge::RVNGPropertyList const &extras) = 0;
92  virtual bool closeHeader() = 0;
94  virtual bool closeFooter() = 0;
96  virtual bool insertHeaderRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which) = 0;
98  virtual bool insertFooterRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which) = 0;
100  virtual bool isHeaderFooterOpened() const = 0;
101 
102  // ------ text data -----------
104  virtual void insertChar(uint8_t character)=0;
107  virtual void insertUnicode(uint32_t character)=0;
109  virtual void insertUnicodeList(std::vector<uint32_t> const &list)
110  {
111  if (list.empty() || !canWriteText())
112  return;
113  for (size_t i=0; i<list.size(); ++i) {
114  if (list[i]==0x9) insertTab();
115  else if (list[i]==0xa || list[i]==0xc) insertEOL(); // checkme: use softBreak ?
116  else insertUnicode(list[i]);
117  }
118  }
120  virtual void insertUnicodeString(librevenge::RVNGString const &str)=0;
121 
123  virtual void insertTab()=0;
125  virtual void insertEOL(bool softBreak=false)=0;
126 
127  // ------ text format -----------
129  virtual void setFont(STOFFFont const &font)=0;
131  virtual STOFFFont const &getFont() const=0;
132 
133  // ------ paragraph format -----------
135  virtual bool isParagraphOpened() const=0;
137  virtual void setParagraph(STOFFParagraph const &paragraph)=0;
139  virtual STOFFParagraph const &getParagraph() const=0;
140 
141  // ------ style definition -----------
143  virtual void defineStyle(STOFFGraphicStyle const &style) = 0;
145  virtual bool isGraphicStyleDefined(librevenge::RVNGString const &name) const = 0;
146  // ------- fields ----------------
148  virtual void insertField(STOFFField const &field)=0;
149 
150  // ------- link ----------------
151 
153  virtual void openLink(STOFFLink const &link)=0;
155  virtual void closeLink()=0;
156 
157  // ------- table -----------------
159  virtual void openTable(STOFFTable const &table) = 0;
161  virtual void closeTable() = 0;
163  virtual void openTableRow(float h, librevenge::RVNGUnit unit, bool headerRow=false) = 0;
165  virtual void closeTableRow() = 0;
167  virtual void openTableCell(STOFFCell const &cell) = 0;
169  virtual void closeTableCell() = 0;
171  virtual void addEmptyTableCell(STOFFVec2i const &pos, STOFFVec2i span=STOFFVec2i(1,1)) = 0;
172 
173  // ------- section ---------------
175  virtual bool canOpenSectionAddBreak() const =0;
177  virtual bool isSectionOpened() const=0;
179  virtual STOFFSection const &getSection() const=0;
181  virtual bool openSection(STOFFSection const &section)=0;
183  virtual bool closeSection()=0;
185  virtual void insertBreak(BreakType breakType)=0;
186 
187  // ------- subdocument ---------------
189  virtual void insertNote(STOFFNote const &note, STOFFSubDocumentPtr &subDocument)=0;
191  virtual void insertComment(STOFFSubDocumentPtr &subDocument, librevenge::RVNGString const &creator="", librevenge::RVNGString const &date="") = 0;
194  virtual void insertPicture(STOFFPosition const &pos, STOFFEmbeddedObject const &picture,
195  STOFFGraphicStyle const &style=STOFFGraphicStyle())=0;
197  virtual void insertShape(STOFFGraphicShape const &shape, STOFFGraphicStyle const &style) = 0;
199  virtual void insertTextBox(STOFFPosition const &pos, STOFFSubDocumentPtr subDocument,
200  STOFFGraphicStyle const &frameStyle=STOFFGraphicStyle()) = 0;
201 #if 0
202 
203  virtual void insertTextBoxInShape(STOFFPosition const &pos, STOFFSubDocumentPtr subDocument,
204  STOFFGraphicShape const &/*shape*/,
205  STOFFGraphicStyle const &frameStyle=STOFFGraphicStyle())
206  {
207  static bool first=true;
208  if (first) {
209  STOFF_DEBUG_MSG(("STOFFListener::insertTextBoxInShape: umimplemented, revert to basic insertTextBox\n"));
210  first=false;
211  }
212  insertTextBox(pos, subDocument, frameStyle);
213  }
214 #endif
215 
216  virtual bool openFrame(STOFFPosition const &pos, STOFFGraphicStyle const &style=STOFFGraphicStyle()) = 0;
218  virtual void closeFrame() = 0;
220  virtual bool openGroup() = 0;
222  virtual void closeGroup() = 0;
224  virtual void handleSubDocument(STOFFSubDocumentPtr subDocument, libstoff::SubDocumentType subDocumentType) = 0;
226  virtual bool isSubDocumentOpened(libstoff::SubDocumentType &subdocType) const = 0;
227 };
228 
229 #endif
230 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
virtual void insertPicture(STOFFPosition const &pos, STOFFEmbeddedObject const &picture, STOFFGraphicStyle const &style=STOFFGraphicStyle())=0
adds a picture with various representationin given position.
virtual void startDocument()=0
starts the document
virtual void insertField(STOFFField const &field)=0
adds a field type
virtual void insertShape(STOFFGraphicShape const &shape, STOFFGraphicStyle const &style)=0
adds a shape picture in given position
virtual void openLink(STOFFLink const &link)=0
open a link
virtual void closeTable()=0
closes this table
virtual STOFFPageSpan const & getPageSpan()=0
returns the current page span
Definition: STOFFListener.hxx:56
a structure used to define a cell and its format
Definition: STOFFCell.hxx:53
virtual bool isParagraphOpened() const =0
returns true if a paragraph or a list is opened
virtual void openTable(STOFFTable const &table)=0
open a table
virtual bool openHeader(librevenge::RVNGPropertyList const &extras)=0
open a header (interaction with STOFFPageSpan which fills the parameters for openHeader) ...
virtual void closeLink()=0
close a link
Type
the listener type
Definition: STOFFListener.hxx:56
virtual void handleSubDocument(STOFFSubDocumentPtr subDocument, libstoff::SubDocumentType subDocumentType)=0
low level: function called to add a subdocument
virtual bool isSubDocumentOpened(libstoff::SubDocumentType &subdocType) const =0
returns true if a subdocument is open
virtual void addEmptyTableCell(STOFFVec2i const &pos, STOFFVec2i span=STOFFVec2i(1, 1))=0
add empty cell
virtual bool closeSection()=0
close a section
virtual void openTableCell(STOFFCell const &cell)=0
open a cell
virtual void insertUnicodeString(librevenge::RVNGString const &str)=0
adds a unicode string
virtual void insertChar(uint8_t character)=0
adds a basic character, ..
Definition: STOFFListener.hxx:58
Definition: STOFFListener.hxx:58
virtual Type getType() const =0
returns the listener type
virtual bool canOpenSectionAddBreak() const =0
returns true if we can add open a section, add page break, ...
virtual bool isGraphicStyleDefined(librevenge::RVNGString const &name) const =0
check if a graphic style with a display name is already defined
#define STOFF_DEBUG_MSG(M)
Definition: libstaroffice_internal.hxx:127
a class used to recreate the table structure using cell informations, ....
Definition: STOFFTable.hxx:51
virtual STOFFFont const & getFont() const =0
returns the actual font
virtual bool closeHeader()=0
close a header
virtual void insertTextBox(STOFFPosition const &pos, STOFFSubDocumentPtr subDocument, STOFFGraphicStyle const &frameStyle=STOFFGraphicStyle())=0
adds a textbox in given position
Definition: STOFFListener.hxx:56
a note
Definition: libstaroffice_internal.hxx:390
class to store the paragraph properties
Definition: STOFFParagraph.hxx:47
virtual void setParagraph(STOFFParagraph const &paragraph)=0
sets the paragraph
Definition: STOFFListener.hxx:56
virtual bool insertHeaderRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which)=0
insert a header
virtual void closeTableRow()=0
closes this row
Definition: STOFFListener.hxx:56
virtual void insertEOL(bool softBreak=false)=0
adds an end of line ( by default an hard one)
virtual void insertBreak(BreakType breakType)=0
inserts a break type: ColumBreak, PageBreak, ..
SubDocumentType
Definition: libstaroffice_internal.hxx:175
shared_ptr< STOFFSubDocument > STOFFSubDocumentPtr
a smart pointer of STOFFSubDocument
Definition: libstaroffice_internal.hxx:492
a class which stores section properties
Definition: STOFFSection.hxx:45
virtual bool canWriteText() const =0
returns true if we can add text data
virtual void endDocument(bool sendDelayedSubDoc=true)=0
ends the document
a field
Definition: libstaroffice_internal.hxx:353
a structure used to define a picture shape
Definition: STOFFGraphicShape.hxx:45
virtual void insertUnicode(uint32_t character)=0
adds an unicode character.
small class use to define a embedded object
Definition: libstaroffice_internal.hxx:409
virtual bool openFrame(STOFFPosition const &pos, STOFFGraphicStyle const &style=STOFFGraphicStyle())=0
low level: tries to open a frame
virtual void insertUnicodeList(std::vector< uint32_t > const &list)
try to insert a list of unicode character
Definition: STOFFListener.hxx:109
virtual bool isSectionOpened() const =0
returns true if a section is opened
STOFFVec2< int > STOFFVec2i
STOFFVec2 of int.
Definition: libstaroffice_internal.hxx:754
virtual bool insertFooterRegion(STOFFSubDocumentPtr subDocument, librevenge::RVNGString const &which)=0
insert a footer
virtual void closeGroup()=0
low level: tries to close the last opened group
virtual void closeTableCell()=0
close a cell
Definition: STOFFListener.hxx:58
Class to store font.
Definition: STOFFFont.hxx:43
virtual void setDocumentLanguage(std::string locale)=0
sets the documents language
virtual bool openGroup()=0
low level: tries to open a group
virtual bool isDocumentStarted() const =0
returns true if a document is opened
virtual void insertComment(STOFFSubDocumentPtr &subDocument, librevenge::RVNGString const &creator="", librevenge::RVNGString const &date="")=0
adds comment
virtual bool isHeaderFooterOpened() const =0
returns true if the header/footer is open
virtual void defineStyle(STOFFGraphicStyle const &style)=0
defines a graphic styles, return the graphic id
virtual void closeFrame()=0
low level: tries to close the last opened frame
virtual void insertNote(STOFFNote const &note, STOFFSubDocumentPtr &subDocument)=0
insert a note
virtual void setFont(STOFFFont const &font)=0
sets the font
virtual bool openSection(STOFFSection const &section)=0
open a section if possible
virtual STOFFSection const & getSection() const =0
returns the actual section
A class which defines the page properties.
Definition: STOFFPageSpan.hxx:74
virtual void setDocumentMetaData(const librevenge::RVNGPropertyList &list)=0
sets the document meta data
BreakType
the different break type
Definition: STOFFListener.hxx:58
virtual bool closeFooter()=0
close a footer
virtual STOFFParagraph const & getParagraph() const =0
returns the actual paragraph
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 )
virtual ~STOFFListener()
destructor
Definition: STOFFListener.hxx:53
virtual bool isPageSpanOpened() const =0
returns true if a page is opened
This class contains a virtual interface to all listener.
Definition: STOFFListener.hxx:49
Class to store a graphic style.
Definition: STOFFGraphicStyle.hxx:44
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: STOFFPosition.hxx:47
virtual void insertTab()=0
adds a tab
virtual bool openFooter(librevenge::RVNGPropertyList const &extras)=0
open a footer (interaction with STOFFPageSpan which fills the parameters for openFooter) ...

Generated on Mon Feb 22 2016 09:38:06 for libstaroffice by doxygen 1.8.11