WPSContentListener.h

Go to the documentation of this file.
00001 /* libwps
00002  * Copyright (C) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
00017  *
00018  * For further information visit http://libwps.sourceforge.net
00019  */
00020 
00021 /*
00022  * This file is in sync with CVS
00023  * /libwpd2/src/lib/WPXContentListener.h 1.9
00024  */
00025 
00026 
00027 #ifndef WPSCONTENTLISTENER_H
00028 #define WPSCONTENTLISTENER_H
00029 
00030 #include "libwps_internal.h"
00031 #include "WPSPageSpan.h"
00032 #include "WPSListener.h"
00033 #include <libwpd/WPXPropertyListVector.h>
00034 #include <libwpd/WPXHLListenerImpl.h>
00035 #include <vector>
00036 #include <list>
00037 #include <set>
00038 
00039 typedef struct _WPSContentParsingState WPSContentParsingState;
00040 struct _WPSContentParsingState
00041 {
00042         _WPSContentParsingState();
00043         ~_WPSContentParsingState();
00044 
00045         uint32_t m_textAttributeBits;
00046         float m_fontSize;
00047         WPXString *m_fontName;
00048         RGBSColor *m_fontColor;
00049         RGBSColor *m_highlightColor;
00050 
00051         bool m_isParagraphColumnBreak;
00052         bool m_isParagraphPageBreak;
00053         uint8_t m_paragraphJustification;
00054         uint8_t m_tempParagraphJustification; // TODO: remove this one after the tabs are properly implemented
00055         float m_paragraphLineSpacing;
00056 
00057         bool m_isDocumentStarted;
00058         bool m_isPageSpanOpened;
00059         bool m_isSectionOpened;
00060         bool m_isPageSpanBreakDeferred;
00061         bool m_isHeaderFooterWithoutParagraph;
00062 
00063         bool m_isSpanOpened;
00064         bool m_isParagraphOpened;
00065         bool m_isListElementOpened;
00066 
00067         std::vector<unsigned int> m_numRowsToSkip;
00068         bool m_wasHeaderRow;
00069         bool m_isCellWithoutParagraph;
00070         uint32_t m_cellAttributeBits;
00071         uint8_t m_paragraphJustificationBeforeColumns;
00072         
00073         std::list<WPSPageSpan>::iterator m_nextPageSpanIter;
00074         int m_numPagesRemainingInSpan;
00075 
00076         bool m_sectionAttributesChanged;
00077         int m_numColumns;
00078         std::vector < WPSColumnDefinition > m_textColumns;
00079         bool m_isTextColumnWithoutParagraph;
00080 
00081         float m_pageFormLength;
00082         float m_pageFormWidth;
00083         WPSFormOrientation m_pageFormOrientation;
00084 
00085         float m_pageMarginLeft;
00086         float m_pageMarginRight;
00087         float m_paragraphMarginLeft;  // resulting paragraph margin that is one of the paragraph
00088         float m_paragraphMarginRight; // properties
00089         float m_paragraphMarginTop;
00090         float m_paragraphMarginBottom;
00091         float m_leftMarginByPageMarginChange;  // part of the margin due to the PAGE margin change
00092         float m_rightMarginByPageMarginChange; // inside a page that already has content.
00093         float m_sectionMarginLeft;  // In multicolumn sections, the above two will be rather interpreted
00094         float m_sectionMarginRight; // as section margin change 
00095         float m_leftMarginByParagraphMarginChange;  // part of the margin due to the PARAGRAPH
00096         float m_rightMarginByParagraphMarginChange; // margin change (in WP6)
00097         float m_leftMarginByTabs;  // part of the margin due to the LEFT or LEFT/RIGHT Indent; the
00098         float m_rightMarginByTabs; // only part of the margin that is reset at the end of a paragraph
00099 
00100         float m_listReferencePosition; // position from the left page margin of the list number/bullet
00101         float m_listBeginPosition; // position from the left page margin of the beginning of the list
00102 
00103         float m_paragraphTextIndent; // resulting first line indent that is one of the paragraph properties
00104         float m_textIndentByParagraphIndentChange; // part of the indent due to the PARAGRAPH indent (WP6???)
00105         float m_textIndentByTabs; // part of the indent due to the "Back Tab" or "Left Tab"
00106 
00107         uint8_t m_currentListLevel;
00108         
00109         uint16_t m_alignmentCharacter;
00110         std::vector<WPSTabStop> m_tabStops;
00111         bool m_isTabPositionRelative;
00112 
00113         bool m_isNote;
00114 };
00115 
00116 class WPSContentListener : public WPSListener
00117 {
00118 protected:
00119         WPSContentListener(std::list<WPSPageSpan> &pageList, WPXHLListenerImpl *listenerImpl);
00120         virtual ~WPSContentListener();
00121 
00122         void startDocument();
00123         void endDocument();
00124         void insertBreak(const uint8_t breakType);
00125         void lineSpacingChange(const float lineSpacing);
00126         void justificationChange(const uint8_t justification);
00127 
00128         WPSContentParsingState *m_ps; // parse state
00129         WPXHLListenerImpl * m_listenerImpl;
00130         WPXPropertyList m_metaData;
00131 
00132         virtual void _flushText() = 0;
00133         virtual void _changeList() = 0;
00134 
00135         void _openSection();
00136         void _closeSection();
00137 
00138         void _openPageSpan();
00139         void _closePageSpan();
00140 
00141         void _appendParagraphProperties(WPXPropertyList &propList, const bool isListElement=false);
00142         void _getTabStops(WPXPropertyListVector &tabStops);
00143         void _appendJustification(WPXPropertyList &propList, int justification);
00144         void _resetParagraphState(const bool isListElement=false);
00145         virtual void _openParagraph();
00146         void _closeParagraph();
00147 
00148         void _openListElement();
00149         void _closeListElement();
00150 
00151         void _openSpan();
00152         void _closeSpan();
00153 
00154         float _movePositionToFirstColumn(float position);
00155 
00156 private:
00157         WPXString _colorToString(const RGBSColor * color);
00158         WPXString _mergeColorsToString(const RGBSColor *fgColor, const RGBSColor *bgColor);
00159 };
00160 
00161 #endif /* WPSCONTENTLISTENER_H */

Generated on Mon Aug 6 09:43:36 2007 for libwps by doxygen 1.5.3