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

Generated on Tue Jul 26 11:52:46 2005 for libwpd by doxygen 1.4.3-20050530