• 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., 51 Franklin Street, Fifth Floor, Boston, MA
00022  * 02110-1301 USA.
00023  */
00024 
00025 #ifndef _ODI_TEXTCONTENT_LISTENERSTATE_H_
00026 #define _ODI_TEXTCONTENT_LISTENERSTATE_H_
00027 
00028 #include "ut_compiler.h"
00029 
00030 #include <string>
00031 #include <map>
00032 #include <set>
00033 
00034 // Internal includes
00035 #include "../../common/xp/ODc_util.h"
00036 #include "ODi_ListenerState.h"
00037 
00038 // AbiWord includes
00039 #include <ut_types.h>
00040 #include <ut_stack.h>
00041 
00042 // External includes
00043 ABI_W_NO_CONST_QUAL
00044 #include <gsf/gsf.h>
00045 ABI_W_POP
00046 
00047 // Internal classes
00048 class ODi_Office_Styles;
00049 class ODi_Style_List;
00050 class ODi_TableOfContent_ListenerState;
00051 class ODi_Abi_Data;
00052 
00053 // AbiWord classes
00054 class PD_Document;
00055 class pf_Frag_Strux;
00056 
00057 #include <list>
00058 
00059 #include "pp_Property.h"
00060 
00083 class ODi_TextContent_ListenerState : public ODi_ListenerState {
00084 
00085 public:
00086 
00087     ODi_TextContent_ListenerState (
00088         PD_Document* pDocument,
00089         ODi_Office_Styles* pStyles,
00090         ODi_ElementStack& rElementStack,
00091     ODi_Abi_Data & rAbiData);
00092 
00093     virtual ~ODi_TextContent_ListenerState();
00094 
00095     void startElement (const gchar* pName, const gchar** ppAtts,
00096                        ODi_ListenerStateAction& rAction);
00097 
00098     void endElement (const gchar* pName, ODi_ListenerStateAction& rAction);
00099 
00100     void charData (const gchar* pBuffer, int length);
00101 
00102 private:
00103 
00104     void _insertBookmark (const gchar * name, const gchar * type, const gchar* xmlid = 0 );
00105     void _flush ();
00106     void _startParagraphElement (const gchar* pName,
00107                                  const gchar** ppParagraphAtts,
00108                                  ODi_ListenerStateAction& rAction);
00109     void _endParagraphElement (const gchar* pName,
00110                                ODi_ListenerStateAction& rAction);
00111     bool _pushInlineFmt(const PP_PropertyVector & ppAtts);
00112     void _popInlineFmt(void);
00113     void _insureInBlock(const PP_PropertyVector & atts);
00114     void _insureInSection(const std::string* pMasterPageName = NULL);
00115     void _openAbiSection(const std::string& rProps,
00116                          const std::string* pMasterPageName = NULL);
00117     void _defineAbiTOCHeadingStyles();
00118     void _flushPendingParagraphBreak();
00119     void _insertAnnotation(void);
00120 
00121     PD_Document* m_pAbiDocument;
00122     ODi_Office_Styles* m_pStyles;
00123 
00124     bool m_bAcceptingText;
00125     bool m_bOpenedBlock;
00126 
00127     bool m_inAbiSection;
00128     bool m_openedFirstAbiSection;
00129     bool m_bPendingSection;
00130     std::string m_currentPageMarginLeft;
00131     std::string m_currentPageMarginRight;
00132 
00133     // For some reason AbiWord can't have a page break right before a new section.
00134     // In AbiWord, if you want to do that you have to first open the new section
00135     // and then, inside this new section, do the page break.
00136     //
00137     // That's the only reason for the existence of *pending* paragraph
00138     // (column or page) breaks.
00139     std::string m_pendingParagraphBreak;
00140 
00141     enum ODi_CurrentODSection {
00142         // We're not inside any OpenDocument section.
00143         ODI_SECTION_NONE,
00144 
00145         // The current OpenDocument section has been mapped into the current
00146         // AbiWord section.
00147         ODI_SECTION_MAPPED,
00148 
00149         // The current OpenDocument section *wasn't* mapped into the current
00150         // AbiWord section.
00151         ODI_SECTION_IGNORED,
00152 
00153         // It's simply undefined. Have to find out the current situation.
00154         ODI_SECTION_UNDEFINED
00155     } m_currentODSection;
00156 
00157     PP_PropertyVector m_vecInlineFmt;
00158     UT_NumberStack m_stackFmtStartIndex;
00159 
00160     UT_sint8 m_elementParsingLevel;
00161 
00162     // Buffer that stores character data defined between start and end element
00163     // tags. e.g.: <bla>some char data</bla>
00164     UT_UCS4String m_charData;
00165 
00172     // It's weird, but a document may actually have several TOCs.
00173     UT_GenericVector<pf_Frag_Strux*> m_tablesOfContent;
00174     UT_GenericVector<std::string*> m_tablesOfContentProps;
00175     // Maps a heading level with its style name
00176     // e.g.: "1" -> "Heading_20_1"
00177     std::map<std::string, std::string> m_headingStyles;
00178     ODi_TableOfContent_ListenerState* m_pCurrentTOCParser;
00179 
00180     // Valued as "true" if it is parsing XML content inside a
00181     // <office:document-content> tag.
00182     bool m_bOnContentStream;
00183 
00184     // List info
00185     ODi_Style_List* m_pCurrentListStyle;
00186     UT_uint8 m_listLevel;
00187     bool m_alreadyDefinedAbiParagraphForList;
00188 
00189     // Stuff for footnotes and endnotes
00190     bool m_bPendingNoteCitation;
00191     bool m_pendingNoteAnchorInsertion;
00192     std::string m_currentNoteId;
00193     std::string m_noteCitation;
00194 
00195     // Annotations
00196     bool m_bPendingAnnotation;
00197     bool m_bPendingAnnotationAuthor;
00198     bool m_bPendingAnnotationDate;
00199     UT_uint32 m_iAnnotation;
00200     std::string m_sAnnotationAuthor;
00201     std::string m_sAnnotationDate;
00202     std::string m_sAnnotationName;
00203     std::string m_sAnnotationXMLID;
00204     std::set< std::string > m_openAnnotationNames;
00205 
00206     // RDF
00207     std::list< std::string > xmlidStackForTextMeta;
00208     std::map< std::string, std::string > xmlidMapForBookmarks;
00209 
00210     // Page referenced stuff
00211     bool m_bPageReferencePending;
00212     UT_sint32 m_iPageNum;
00213     double    m_dXpos;
00214     double    m_dYpos;
00215     std::string m_sProps;
00216     ODi_Abi_Data& m_rAbiData;
00217     bool m_bPendingTextbox;
00218     bool m_bHeadingList;
00219     UT_sint32 m_prevLevel;
00220     bool m_bContentWritten;
00221     
00222     UT_uint32 m_columnsCount;
00223     UT_uint32 m_columnIndex;
00224 };
00225 
00226 #endif //_ODI_TEXTCONTENT_LISTENERSTATE_H_

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1