Public Member Functions | Private Types | Private Member Functions | Private Attributes

ODi_TextContent_ListenerState Class Reference

It parses the regular content of a text document. More...

#include <ODi_TextContent_ListenerState.h>

Inheritance diagram for ODi_TextContent_ListenerState:
ODi_ListenerState

List of all members.

Public Member Functions

 ODi_TextContent_ListenerState (PD_Document *pDocument, ODi_Office_Styles *pStyles, ODi_ElementStack &rElementStack, ODi_Abi_Data &rAbiData)
 Constructor.
virtual ~ODi_TextContent_ListenerState ()
 Destructor.
void startElement (const gchar *pName, const gchar **ppAtts, ODi_ListenerStateAction &rAction)
 Called when the XML parser finds a start element tag.
void endElement (const gchar *pName, ODi_ListenerStateAction &rAction)
 Called when an "end of element" tag is parsed (like <myElementName>).
void charData (const gchar *pBuffer, int length)

Private Types

enum  ODi_CurrentODSection { ODI_SECTION_NONE, ODI_SECTION_MAPPED, ODI_SECTION_IGNORED, ODI_SECTION_UNDEFINED }

Private Member Functions

void _insertBookmark (const gchar *name, const gchar *type, const gchar *xmlid=0)
void _flush ()
void _startParagraphElement (const gchar *pName, const gchar **ppParagraphAtts, ODi_ListenerStateAction &rAction)
 Process <text:p> and <text:h> startElement calls.
void _endParagraphElement (const gchar *pName, ODi_ListenerStateAction &rAction)
bool _pushInlineFmt (const PP_PropertyVector &ppAtts)
void _popInlineFmt (void)
void _insureInBlock (const PP_PropertyVector &atts)
void _insureInSection (const std::string *pMasterPageName=NULL)
 Makes sure that an AbiWord section have already been created.
void _openAbiSection (const std::string &rProps, const std::string *pMasterPageName=NULL)
 Tries to open an abi <section> given its properties.
void _defineAbiTOCHeadingStyles ()
 Defines all toc-source-style* propeties on Abi TOCs (<toc> struxs).
void _flushPendingParagraphBreak ()
 For some reason AbiWord can't have a page break right before a new section.
void _insertAnnotation (void)
 Inserts an <annotate> element into the document before inserting a paragraph or list item.

Private Attributes

PD_Documentm_pAbiDocument
ODi_Office_Stylesm_pStyles
bool m_bAcceptingText
bool m_bOpenedBlock
bool m_inAbiSection
bool m_openedFirstAbiSection
bool m_bPendingSection
std::string m_currentPageMarginLeft
std::string m_currentPageMarginRight
std::string m_pendingParagraphBreak
enum
ODi_TextContent_ListenerState::ODi_CurrentODSection 
m_currentODSection
PP_PropertyVector m_vecInlineFmt
UT_NumberStack m_stackFmtStartIndex
UT_sint8 m_elementParsingLevel
UT_UCS4String m_charData
UT_GenericVector< pf_Frag_Strux * > m_tablesOfContent
 In OpenDocument, <text:h> elements along the text defines the document chapter's structure.
UT_GenericVector< std::string * > m_tablesOfContentProps
std::map< std::string,
std::string > 
m_headingStyles
ODi_TableOfContent_ListenerStatem_pCurrentTOCParser
bool m_bOnContentStream
ODi_Style_Listm_pCurrentListStyle
UT_uint8 m_listLevel
bool m_alreadyDefinedAbiParagraphForList
bool m_bPendingNoteCitation
bool m_pendingNoteAnchorInsertion
std::string m_currentNoteId
std::string m_noteCitation
bool m_bPendingAnnotation
bool m_bPendingAnnotationAuthor
bool m_bPendingAnnotationDate
UT_uint32 m_iAnnotation
std::string m_sAnnotationAuthor
std::string m_sAnnotationDate
std::string m_sAnnotationName
std::string m_sAnnotationXMLID
std::set< std::string > m_openAnnotationNames
std::list< std::string > xmlidStackForTextMeta
std::map< std::string,
std::string > 
xmlidMapForBookmarks
bool m_bPageReferencePending
UT_sint32 m_iPageNum
double m_dXpos
double m_dYpos
std::string m_sProps
ODi_Abi_Datam_rAbiData
bool m_bPendingTextbox
bool m_bHeadingList
UT_sint32 m_prevLevel
bool m_bContentWritten
UT_uint32 m_columnsCount
UT_uint32 m_columnIndex

Detailed Description

It parses the regular content of a text document.

It is used to parse the document text body itself (<office:text>) and the contents of headers (<style:header>) and footers (<style:footer>).

Regular text content may have the following main elements (that is, not mentioning their child elements): <text-h> <text-p> <text-list> <table-table> <text-section> <text-table-of-content> <text-illustration-index> <text-table-index> <text-object-index> <text-user-index> <text-alphabetical-index> <text-bibliography> <text-index-title> <change-marks>


Member Enumeration Documentation

Enumerator:
ODI_SECTION_NONE 
ODI_SECTION_MAPPED 
ODI_SECTION_IGNORED 
ODI_SECTION_UNDEFINED 

Constructor & Destructor Documentation

ODi_TextContent_ListenerState::ODi_TextContent_ListenerState ( PD_Document pDocument,
ODi_Office_Styles pStyles,
ODi_ElementStack rElementStack,
ODi_Abi_Data rAbiData 
)

Constructor.

References m_pAbiDocument, m_pStyles, and UT_ASSERT_HARMLESS.

ODi_TextContent_ListenerState::~ODi_TextContent_ListenerState (  )  [virtual]

Member Function Documentation

void ODi_TextContent_ListenerState::_defineAbiTOCHeadingStyles (  )  [private]
void ODi_TextContent_ListenerState::_flushPendingParagraphBreak (  )  [private]

For some reason AbiWord can't have a page break right before a new section.

In AbiWord, if you want to do that you have to first open the new section and then, inside this new section, do the page break.

That's the only reason for the existence of *pending* paragraph (column or page) breaks.

References PD_Document::appendSpan(), PD_Document::appendStrux(), m_bContentWritten, m_bOpenedBlock, m_pAbiDocument, m_pendingParagraphBreak, and PTX_Block.

Referenced by _openAbiSection(), and startElement().

void ODi_TextContent_ListenerState::_insertAnnotation ( void   )  [private]
void ODi_TextContent_ListenerState::_insertBookmark ( const gchar *  name,
const gchar *  type,
const gchar *  xmlid = 0 
) [private]
void ODi_TextContent_ListenerState::_insureInBlock ( const PP_PropertyVector atts  )  [private]
void ODi_TextContent_ListenerState::_insureInSection ( const std::string *  pMasterPageName = NULL  )  [private]

Makes sure that an AbiWord section have already been created.

Unlike OpenDocument, AbiWord can't have paragraphs without a section to hold them.

Parameters:
pMasterPageName The name of the master page to be used. i.e.: The name of the master page which will have its properties used in this section.

References _openAbiSection(), gchar, ODi_Style_Style::getAbiPropsAttrString(), ODi_StartTag::getAttributeValue(), ODi_ElementStack::getClosestElement(), ODi_Office_Styles::getSectionStyle(), m_bOnContentStream, m_bPendingSection, m_columnIndex, m_columnsCount, m_currentODSection, m_inAbiSection, m_pStyles, ODi_ListenerState::m_rElementStack, UT_ASSERT, UT_getAttribute(), and UT_splitPropsToArray().

Referenced by _insureInBlock(), _startParagraphElement(), and startElement().

void ODi_TextContent_ListenerState::_popInlineFmt ( void   )  [private]
bool ODi_TextContent_ListenerState::_pushInlineFmt ( const PP_PropertyVector ppAtts  )  [private]
void ODi_TextContent_ListenerState::_startParagraphElement ( const gchar *  pName,
const gchar **  ppParagraphAtts,
ODi_ListenerStateAction rAction 
) [private]
void ODi_TextContent_ListenerState::endElement ( const gchar *  pName,
ODi_ListenerStateAction rAction 
) [virtual]

Called when an "end of element" tag is parsed (like <myElementName>).

Parameters:
pName The name of the element

Implements ODi_ListenerState.

References _defineAbiTOCHeadingStyles(), _endParagraphElement(), _flush(), _insertAnnotation(), _popInlineFmt(), UT_GenericVector< T >::addItem(), PD_Document::addPageReferencedTextbox(), PD_Document::appendFmt(), PD_Document::appendObject(), PD_Document::appendStrux(), ODi_ListenerStateAction::bringUpPostponedElements(), UT_GenericVector< T >::clear(), IE_Exp::copyToBuffer(), PD_Document::deleteFragNoUpdate(), DELETEP, gchar, ODi_StartTag::getAttributeValue(), PD_Document::getBounds(), PD_Document::getLastFrag(), pf_Frag::getNext(), pf_Frag::getPos(), pf_Frag::getPrev(), ODi_TableOfContent_ListenerState::getProps(), ODi_ElementStack::getStartTag(), ODi_TableOfContent_ListenerState::getTOCStrux(), m_bAcceptingText, m_bOnContentStream, m_bPageReferencePending, m_bPendingAnnotation, m_bPendingAnnotationAuthor, m_bPendingAnnotationDate, m_bPendingTextbox, m_currentNoteId, m_currentODSection, m_dXpos, m_dYpos, m_elementParsingLevel, m_iAnnotation, m_inAbiSection, m_iPageNum, m_listLevel, m_pAbiDocument, m_pCurrentListStyle, m_pCurrentTOCParser, m_pendingNoteAnchorInsertion, m_rAbiData, ODi_Abi_Data::m_rangedAnnotationNames, ODi_ListenerState::m_rElementStack, m_sAnnotationName, m_sProps, m_tablesOfContent, m_tablesOfContentProps, m_vecInlineFmt, ODI_SECTION_MAPPED, ODi_ListenerStateAction::popState(), PTO_Annotation, PTO_Hyperlink, PTO_RDFAnchor, PTX_EndAnnotation, PTX_EndEndnote, PTX_EndFootnote, UT_ASSERT, UT_ASSERT_HARMLESS, UT_DEBUGMSG, UT_SHOULD_NOT_HAPPEN, UT_std_string_sprintf(), UT_VECTOR_PURGEALL, UT_UTF8String::utf8_str(), and xmlidStackForTextMeta.

void ODi_TextContent_ListenerState::startElement ( const gchar *  pName,
const gchar **  ppAtts,
ODi_ListenerStateAction rAction 
) [virtual]

Called when the XML parser finds a start element tag.

Parameters:
pName The name of the element.
ppAtts The attributes of the parsed start tag.

Implements ODi_ListenerState.

References _flush(), _flushPendingParagraphBreak(), _insertAnnotation(), _insertBookmark(), _insureInBlock(), _insureInSection(), _popInlineFmt(), _pushInlineFmt(), _startParagraphElement(), ODi_Abi_Data::addImageDataItem(), PD_Document::addPageReferencedImage(), UT_UniqueId::Annotation, PD_Document::appendFmt(), PD_Document::appendObject(), PD_Document::appendSpan(), PD_Document::appendStrux(), UT_String::c_str(), UT_UniqueId::Endnote, UT_UniqueId::Footnote, gchar, ODi_Style_Style::getAbiPropsAttrString(), ODi_StartTag::getAttributeValue(), ODi_NotesConfiguration::getCitationStyleName(), ODi_Style_Style::getDisplayName(), ODi_Office_Styles::getGraphicStyle(), ODi_Style_List::getLevelStyle(), ODi_Office_Styles::getList(), ODi_StartTag::getName(), ODi_Office_Styles::getNotesConfiguration(), ODi_Office_Styles::getParagraphStyle(), ODi_Style_Style::getParent(), ODi_Office_Styles::getSectionStyle(), ODi_ElementStack::getStartTag(), ODi_Office_Styles::getTextStyle(), PD_Document::getUID(), ODi_Style_Style::getWrap(), id, ODi_ListenerStateAction::ignoreElement(), ODi_Style_Style::isAutomatic(), ODi_ListLevelStyle::isVisible(), m_alreadyDefinedAbiParagraphForList, m_bAcceptingText, m_bContentWritten, m_bHeadingList, m_bOnContentStream, m_bPageReferencePending, m_bPendingAnnotation, m_bPendingAnnotationAuthor, m_bPendingAnnotationDate, m_bPendingNoteCitation, m_bPendingSection, m_bPendingTextbox, m_charData, m_currentNoteId, m_currentODSection, m_dXpos, m_dYpos, m_elementParsingLevel, m_headingStyles, m_iAnnotation, m_inAbiSection, m_iPageNum, m_listLevel, m_noteCitation, m_openAnnotationNames, m_openedFirstAbiSection, m_pAbiDocument, m_pCurrentListStyle, m_pCurrentTOCParser, m_pendingNoteAnchorInsertion, m_pStyles, m_rAbiData, ODi_ListenerState::m_rElementStack, m_sAnnotationAuthor, m_sAnnotationDate, m_sAnnotationName, m_sAnnotationXMLID, m_sProps, m_vecInlineFmt, ODi_ListenerStateAction::postponeElementParsing(), PT_NAME_ATTRIBUTE_NAME, PTO_Annotation, PTO_Field, PTO_Hyperlink, PTO_RDFAnchor, PTX_SectionEndnote, PTX_SectionFootnote, ODi_ListenerStateAction::pushState(), s, size, type, UT_ASSERT, UT_ASSERT_HARMLESS, UT_convertToInches(), UT_DEBUGMSG, UT_getAttribute(), UT_SHOULD_NOT_HAPPEN, UT_std_string_setProperty(), UT_std_string_sprintf(), xmlidMapForBookmarks, xmlidStackForTextMeta, and xxx_UT_DEBUGMSG.


Member Data Documentation

Referenced by charData(), and startElement().

std::set< std::string > ODi_TextContent_ListenerState::m_openAnnotationNames [private]

Referenced by startElement().

Referenced by endElement(), and startElement().

In OpenDocument, <text:h> elements along the text defines the document chapter's structure.

So, we must get the styles used by those <text:h> for each content level in order to set AbiWord's <toc> properties correctly.

Referenced by _defineAbiTOCHeadingStyles(), and endElement().

std::map< std::string, std::string > ODi_TextContent_ListenerState::xmlidMapForBookmarks [private]

Referenced by startElement().

std::list< std::string > ODi_TextContent_ListenerState::xmlidStackForTextMeta [private]

Referenced by endElement(), and startElement().


The documentation for this class was generated from the following files: