Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

WPXHLListener.h

Go to the documentation of this file.
00001 /* libwpd
00002  * Copyright (C) 2002 William Lachance (william.lachance@sympatico.ca)
00003  * Copyright (C) 2002 Marc Maurer (j.m.maurer@student.utwente.nl)
00004  * Copyright (C) 2005 Fridrich Strba (fridrich.strba@bluewin.ch)
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019  *
00020  * For further information visit http://libwpd.sourceforge.net
00021  */
00022 
00023 /* "This product is not manufactured, approved, or supported by
00024  * Corel Corporation or Corel Corporation Limited."
00025  */
00026 
00027 #ifndef WPXHLLISTENER_H
00028 #define WPXHLLISTENER_H
00029 
00030 #include "WPXLLListener.h"
00031 #include "WPXHLListenerImpl.h"
00032 #include "WPXTable.h"
00033 #include "WPXPropertyListVector.h"
00034 #include <set>
00035 
00036 class WPXPageSpan;
00037 
00038 typedef struct _WPXDocumentMetaData WPXDocumentMetaData;
00039 struct _WPXDocumentMetaData
00040 {
00041         WPXString m_author;
00042         WPXString m_subject;
00043         WPXString m_publisher;
00044         WPXString m_category;
00045         WPXString m_keywords;
00046         WPXString m_language;
00047         WPXString m_abstract;
00048         WPXString m_descriptiveName;
00049         WPXString m_descriptiveType;
00050 };
00051 
00052 typedef struct _WPXTableDefinition WPXTableDefinition;
00053 struct _WPXTableDefinition
00054 {
00055         uint8_t m_positionBits;
00056         float m_leftOffset;
00057         std::vector < WPXColumnDefinition > columns;
00058 };
00059 
00060 typedef struct _WPXParsingState WPXParsingState;
00061 struct _WPXParsingState
00062 {
00063         _WPXParsingState();
00064         ~_WPXParsingState();
00065 
00066 #if 0
00067         WPXString m_bodyText;
00068         WPXString m_textBeforeNumber;
00069         WPXString m_textBeforeDisplayReference;
00070         WPXString m_numberText;
00071         WPXString m_textAfterDisplayReference;
00072         WPXString m_textAfterNumber;
00073 #endif
00074         uint32_t m_textAttributeBits;
00075         float m_fontSize;
00076         WPXString *m_fontName;
00077         RGBSColor *m_fontColor;
00078         RGBSColor *m_highlightColor;
00079 
00080         bool m_isParagraphColumnBreak;
00081         bool m_isParagraphPageBreak;
00082         uint8_t m_paragraphJustification;
00083         uint8_t m_tempParagraphJustification; // TODO: remove this one after the tabs are properly implemented
00084         float m_paragraphLineSpacing;
00085 
00086         bool m_isDocumentStarted;
00087         bool m_isPageSpanOpened;
00088         bool m_isSectionOpened;
00089         bool m_isPageSpanBreakDeferred;
00090 
00091         bool m_isSpanOpened;
00092         bool m_isParagraphOpened;
00093         bool m_isListElementOpened;
00094 
00095         WPXTableDefinition m_tableDefinition;
00096         int m_currentTableCol;
00097         int m_currentTableRow;
00098         bool m_isTableOpened;
00099         bool m_isTableRowOpened;
00100         bool m_isTableColumnOpened;
00101         bool m_isTableCellOpened;
00102         bool m_wasHeaderRow;
00103         bool m_isCellWithoutParagraph;
00104         uint32_t m_cellAttributeBits;
00105         uint8_t m_paragraphJustificationBeforeTable;
00106         
00107         int m_nextPageSpanIndice;
00108         int m_numPagesRemainingInSpan;
00109 
00110         bool m_sectionAttributesChanged;
00111         int m_numColumns;
00112         std::vector < WPXColumnDefinition > m_textColumns;
00113         bool m_isTextColumnWithoutParagraph;
00114 
00115         float m_pageFormLength;
00116         float m_pageFormWidth;
00117         WPXFormOrientation m_pageFormOrientation;
00118 
00119         float m_pageMarginLeft;
00120         float m_pageMarginRight;
00121         float m_paragraphMarginLeft;  // resulting paragraph margin that is one of the paragraph
00122         float m_paragraphMarginRight; // properties
00123         float m_paragraphMarginTop;
00124         float m_paragraphMarginBottom;
00125         float m_leftMarginByPageMarginChange;  // part of the margin due to the PAGE margin change
00126         float m_rightMarginByPageMarginChange; // inside a page that already has content.
00127         float m_leftMarginByParagraphMarginChange;  // part of the margin due to the PARAGRAPH
00128         float m_rightMarginByParagraphMarginChange; // margin change (in WP6)
00129         float m_leftMarginByTabs;  // part of the margin due to the LEFT or LEFT/RIGHT Indent; the
00130         float m_rightMarginByTabs; // only part of the margin that is reset at the end of a paragraph
00131 
00132         float m_listReferencePosition; // position from the left page margin of the list number/bullet
00133         float m_listBeginPosition; // position from the left page margin of the beginning of the list
00134 
00135         float m_paragraphTextIndent; // resulting first line indent that is one of the paragraph properties
00136         float m_textIndentByParagraphIndentChange; // part of the indent due to the PARAGRAPH indent (WP6???)
00137         float m_textIndentByTabs; // part of the indent due to the "Back Tab" or "Left Tab"
00138 
00139         uint8_t m_currentListLevel;
00140         
00141 #if 0
00142         stack<int> m_listLevelStack;
00143         uint16_t m_currentOutlineHash; // probably should replace Hash with Key in these sorts of cases
00144         uint8_t m_oldListLevel;
00145         WP6StyleStateSequence m_styleStateSequence;
00146         bool m_putativeListElementHasParagraphNumber;
00147         bool m_putativeListElementHasDisplayReferenceNumber;
00148 
00149         int m_noteTextPID;
00150 #endif
00151         uint16_t m_alignmentCharacter;
00152         std::vector<WPXTabStop> m_tabStops;
00153         bool m_isTabPositionRelative;
00154 
00155         std::set <int> m_subDocumentTextPIDs;
00156 
00157         bool m_inSubDocument;
00158         bool m_isNote;
00159 };
00160 
00161 class WPXHLListener : public WPXLLListener
00162 {
00163 public:
00164         WPXHLListener(std::vector<WPXPageSpan *> *pageList, WPXHLListenerImpl *listenerImpl);
00165         WPXHLListener::~WPXHLListener();
00166 
00167         void startDocument();
00168         void handleSubDocument(uint16_t textPID, const bool isHeaderFooter, WPXTableList tableList, int nextTableIndice);
00169         virtual void insertBreak(const uint8_t breakType);
00170         virtual void lineSpacingChange(const float lineSpacing);
00171         virtual void justificationChange(const uint8_t justification);
00172 
00173         WPXParsingState *m_ps; // parse state
00174         WPXHLListenerImpl * m_listenerImpl;
00175         WPXPropertyList m_metaData;
00176         std::vector <WPXPageSpan *> *m_pageList;
00177 
00178 protected:
00179         virtual void _handleSubDocument(uint16_t textPID, const bool isHeaderFooter, WPXTableList tableList, int nextTableIndice) = 0;
00180         virtual void _flushText() = 0;
00181         virtual void _changeList() = 0;
00182 
00183         void _openSection();
00184         void _closeSection();
00185 
00186         void _openPageSpan();
00187         void _closePageSpan();
00188 
00189         void _appendParagraphProperties(WPXPropertyList &propList, const bool isListElement=false);
00190         void _getTabStops(WPXPropertyListVector &tabStops);
00191         void _appendJustification(WPXPropertyList &propList, int justification);
00192         virtual void _openParagraph();
00193         virtual void _resetParagraphState(const bool isListElement=false);
00194         void _closeParagraph();
00195 
00196         void _openListElement();
00197         void _closeListElement();
00198 
00199         void _openSpan();
00200         void _closeSpan();
00201 
00202         void _openTable();
00203         void _closeTable();
00204         void _openTableRow(const float height, const bool isMinimumHeight, const bool isHeaderRow);
00205         void _closeTableRow();
00206         void _openTableCell(const uint8_t colSpan, const uint8_t rowSpan, const bool boundFromLeft, const bool boundFromAbove,
00207                                 const uint8_t borderBits, const RGBSColor * cellFgColor, const RGBSColor * cellBgColor,
00208                                 const RGBSColor * cellBorderColor,
00209                                 const WPXVerticalAlignment cellVerticalAlignment);
00210         void _closeTableCell();
00211 
00212         bool isUndoOn() { return m_isUndoOn; }
00213         bool m_isUndoOn;
00214         
00215 private:
00216         WPXString _colorToString(const RGBSColor * color);
00217         WPXString _mergeColorsToString(const RGBSColor *fgColor, const RGBSColor *bgColor);
00218 };
00219 
00220 #endif /* WPXHLLISTENER_H */

Generated on Sat Oct 8 17:31:12 2005 for libwpd by doxygen 1.4.2