• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ODi_TextContent_ListenerState.h

Go to the documentation of this file.
00001 /* AbiSource
00002  *
00003  * Copyright (C) 2002 Dom Lachowicz <cinamod@hotmail.com>
00004  * Copyright (C) 2004 Robert Staudinger <robsta@stereolyzer.net>
00005  * Copyright (C) 2005 Daniel d'Andrada T. de Carvalho
00006  * <daniel.carvalho@indt.org.br>
00007  * Copyright (C) 2011-2012 Ben Martin
00008  *
00009  * This program is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU General Public License
00011  * as published by the Free Software Foundation; either version 2
00012  * of the License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00022  * 02111-1307, USA.
00023  */
00024 
00025 #ifndef _ODI_TEXTCONTENT_LISTENERSTATE_H_
00026 #define _ODI_TEXTCONTENT_LISTENERSTATE_H_
00027 
00028 #include <string>
00029 #include <map>
00030 #include <set>
00031 
00032 // Internal includes
00033 #include "../../common/xp/ODc_util.h"
00034 #include "ODi_ListenerState.h"
00035 
00036 // AbiWord includes
00037 #include <ut_types.h>
00038 #include <ut_stack.h>
00039 
00040 // External includes
00041 #include <gsf/gsf.h>
00042 
00043 // Internal classes
00044 class ODi_Office_Styles;
00045 class ODi_Style_List;
00046 class ODi_TableOfContent_ListenerState;
00047 class ODi_Abi_Data;
00048 
00049 // AbiWord classes
00050 class PD_Document;
00051 class pf_Frag_Strux;
00052 
00053 #include <list>
00054 
00077 class ODi_TextContent_ListenerState : public ODi_ListenerState {
00078 
00079 public:
00080 
00081     ODi_TextContent_ListenerState (
00082         PD_Document* pDocument,
00083         ODi_Office_Styles* pStyles,
00084         ODi_ElementStack& rElementStack,
00085     ODi_Abi_Data & rAbiData);
00086 
00087     virtual ~ODi_TextContent_ListenerState();
00088 
00089     void startElement (const gchar* pName, const gchar** ppAtts,
00090                        ODi_ListenerStateAction& rAction);
00091 
00092     void endElement (const gchar* pName, ODi_ListenerStateAction& rAction);
00093 
00094     void charData (const gchar* pBuffer, int length);
00095 
00096 private:
00097 
00098     void _insertBookmark (const gchar * name, const gchar * type, const gchar* xmlid = 0 );
00099     void _flush ();
00100     void _startParagraphElement (const gchar* pName,
00101                                  const gchar** ppParagraphAtts,
00102                                  ODi_ListenerStateAction& rAction);
00103     void _endParagraphElement (const gchar* pName,
00104                                ODi_ListenerStateAction& rAction);
00105     bool _pushInlineFmt(const gchar** ppAtts);
00106     void _popInlineFmt(void);
00107     void _insureInBlock(const gchar ** atts);
00108     void _insureInSection(const UT_UTF8String* pMasterPageName = NULL);
00109     void _openAbiSection(const UT_UTF8String& rProps,
00110                          const UT_UTF8String* pMasterPageName = NULL);
00111     void _defineAbiTOCHeadingStyles();
00112     void _flushPendingParagraphBreak();
00113     void _insertAnnotation(void);
00114 
00115     PD_Document* m_pAbiDocument;
00116     ODi_Office_Styles* m_pStyles;
00117 
00118     bool m_bAcceptingText;
00119     bool m_bOpenedBlock;
00120 
00121     bool m_inAbiSection;
00122     bool m_openedFirstAbiSection;
00123     bool m_bPendingSection;
00124     UT_UTF8String m_currentPageMarginLeft;
00125     UT_UTF8String m_currentPageMarginRight;
00126 
00127     // For some reason AbiWord can't have a page break right before a new section.
00128     // In AbiWord, if you want to do that you have to first open the new section
00129     // and then, inside this new section, do the page break.
00130     //
00131     // That's the only reason for the existence of *pending* paragraph
00132     // (column or page) breaks.
00133     UT_UTF8String m_pendingParagraphBreak;
00134 
00135     enum ODi_CurrentODSection {
00136         // We're not inside any OpenDocument section.
00137         ODI_SECTION_NONE,
00138 
00139         // The current OpenDocument section has been mapped into the current
00140         // AbiWord section.
00141         ODI_SECTION_MAPPED,
00142 
00143         // The current OpenDocument section *wasn't* mapped into the current
00144         // AbiWord section.
00145         ODI_SECTION_IGNORED,
00146 
00147         // It's simply undefined. Have to find out the current situation.
00148         ODI_SECTION_UNDEFINED
00149     } m_currentODSection;
00150 
00151     UT_GenericVector<const gchar*> m_vecInlineFmt;
00152     UT_NumberStack m_stackFmtStartIndex;
00153 
00154     UT_sint8 m_elementParsingLevel;
00155 
00156     // Buffer that stores character data defined between start and end element
00157     // tags. e.g.: <bla>some char data</bla>
00158     UT_UCS4String m_charData;
00159 
00166     // It's weird, but a document may actually have several TOCs.
00167     UT_GenericVector<pf_Frag_Strux*> m_tablesOfContent;
00168     UT_GenericVector<UT_UTF8String*> m_tablesOfContentProps;
00169     // Maps a heading level with its style name
00170     // e.g.: "1" -> "Heading_20_1"
00171     std::map<std::string, std::string> m_headingStyles;
00172     ODi_TableOfContent_ListenerState* m_pCurrentTOCParser;
00173 
00174     // Valued as "true" if it is parsing XML content inside a
00175     // <office:document-content> tag.
00176     bool m_bOnContentStream;
00177 
00178     // List info
00179     ODi_Style_List* m_pCurrentListStyle;
00180     UT_uint8 m_listLevel;
00181     bool m_alreadyDefinedAbiParagraphForList;
00182 
00183     // Stuff for footnotes and endnotes.
00184     bool m_pendingNoteAnchorInsertion;
00185     UT_UTF8String m_currentNoteId;
00186 
00187     // Annotations
00188     bool m_bPendingAnnotation;
00189     bool m_bPendingAnnotationAuthor;
00190     bool m_bPendingAnnotationDate;
00191     UT_uint32 m_iAnnotation;
00192     std::string m_sAnnotationAuthor;
00193     std::string m_sAnnotationDate;
00194     std::string m_sAnnotationName;
00195     std::string m_sAnnotationXMLID;
00196     std::set< std::string > m_openAnnotationNames;
00197 
00198     // RDF
00199     std::list< std::string > xmlidStackForTextMeta;
00200     std::map< std::string, std::string > xmlidMapForBookmarks;
00201 
00202     // Page referenced stuff
00203     bool m_bPageReferencePending;
00204     UT_sint32 m_iPageNum;
00205     double    m_dXpos;
00206     double    m_dYpos;
00207     UT_UTF8String m_sProps;
00208     ODi_Abi_Data& m_rAbiData;
00209     bool m_bPendingTextbox;
00210     bool m_bHeadingList;
00211     UT_sint32 m_prevLevel;
00212     bool m_bContentWritten;
00213 };
00214 
00215 #endif //_ODI_TEXTCONTENT_LISTENERSTATE_H_

Generated on Sun May 27 2012 for AbiWord by  doxygen 1.7.1