#include <ie_exp_Psion.h>
Public Member Functions | |
PL_Psion_Listener (PD_Document *pDocument) | |
virtual | ~PL_Psion_Listener (void) |
virtual bool | populate (fl_ContainerLayout *sfh, const PX_ChangeRecord *pcr) |
virtual bool | populateStrux (pf_Frag_Strux *sdh, const PX_ChangeRecord *pcr, fl_ContainerLayout **psfh) |
bool | startDocument (void) |
bool | finishDocument (void) |
virtual psiconv_file | createPsionFile (void)=0 |
virtual bool | change (fl_ContainerLayout *, const PX_ChangeRecord *) |
virtual bool | insertStrux (fl_ContainerLayout *, const PX_ChangeRecord *, pf_Frag_Strux *, PL_ListenerId, void(*)(pf_Frag_Strux *sdhNew, PL_ListenerId lid, fl_ContainerLayout *sfhNew)) |
virtual bool | signal (UT_uint32) |
Protected Attributes | |
PD_Document * | m_pDocument |
psiconv_text_and_layout | m_paragraphs |
psiconv_word_styles_section | m_styles |
psiconv_page_header | m_header |
psiconv_page_header | m_footer |
Private Types | |
enum | sectionType { section_none, section_header, section_footer, section_main } |
Private Member Functions | |
bool | _writeText (const UT_UCSChar *p, UT_uint32 inlength, UT_uint32 &outlength) |
bool | _openParagraph (const PT_AttrPropIndex api) |
bool | _closeParagraph (void) |
bool | _addInLine (const PT_AttrPropIndex api, UT_uint32 textlen) |
bool | _processStyles (void) |
bool | _setStyleLayout (PD_Style *style, psiconv_paragraph_layout para_layout, psiconv_character_layout char_layout) |
bool | _insertImage (const PT_AttrPropIndex api) |
Private Attributes | |
bool | m_inParagraph |
sectionType | m_sectionType |
psiconv_list | m_currentParagraphText |
psiconv_paragraph_layout | m_currentParagraphPLayout |
psiconv_character_layout | m_currentParagraphCLayout |
psiconv_in_line_layouts | m_currentParagraphInLines |
psiconv_s16 | m_currentParagraphStyle |
Abstract listener class for Psion files.
The actual Word and TextEd listeners are derived from this class. Listener classes are used to traverse the AbiWord document, using the defined callbacks whenever something interesting is found. This specific class builds a psiconv representation of the AbiWord document internally. The abstract createPsionFile method will need to be defined to return this psiconv document, currently in Word or TextEd form.
enum PL_Psion_Listener::sectionType [private] |
PL_Psion_Listener::PL_Psion_Listener | ( | PD_Document * | pDocument | ) |
Constructor
The listener uses several psiconv_file fragments while building paragraphs (and perhaps other things). We can't allocate them here, because we can't fail in a constructor. At all places, we use NULL to indicate an unallocated structure.
PL_Psion_Listener::~PL_Psion_Listener | ( | void | ) | [virtual] |
Destructor
Deallocate those psiconv_file fragments that are currently allocated. NULL is used to indicate an unallocated structure.
References m_currentParagraphCLayout, m_currentParagraphInLines, m_currentParagraphPLayout, m_currentParagraphText, m_footer, m_header, and m_paragraphs.
bool PL_Psion_Listener::_addInLine | ( | const PT_AttrPropIndex | api, | |
UT_uint32 | textlen | |||
) | [private] |
Parse the current in-line formatting
References PD_Document::getAttrProp(), m_currentParagraphCLayout, m_currentParagraphInLines, m_inParagraph, m_pDocument, updateCharacterLayout(), UT_ASSERT, and UT_DEBUGMSG.
Referenced by populate().
bool PL_Psion_Listener::_closeParagraph | ( | void | ) | [private] |
Close the paragraph
The current paragraph stuff is added to the paragraph list. It is safe to call this function if no paragraph is opened.
References m_currentParagraphCLayout, m_currentParagraphInLines, m_currentParagraphPLayout, m_currentParagraphStyle, m_currentParagraphText, m_footer, m_header, m_inParagraph, m_paragraphs, m_sectionType, section_footer, section_header, section_main, section_none, and UT_DEBUGMSG.
Referenced by _openParagraph(), finishDocument(), and populateStrux().
bool PL_Psion_Listener::_insertImage | ( | const PT_AttrPropIndex | api | ) | [private] |
Handle images
Images can be in several flavours in the AbiWord source. Here, we just handle PNG ones.
References gchar, PP_AttrProp::getAttribute(), PD_Document::getAttrProp(), PD_Document::getDataItemDataByName(), _bb::iCurPos, m_currentParagraphCLayout, m_currentParagraphInLines, m_currentParagraphText, m_pDocument, _bb::pBB, read_png_data(), UT_DEBUGMSG, and utf8_to_ucs2().
Referenced by populate().
bool PL_Psion_Listener::_openParagraph | ( | const PT_AttrPropIndex | api | ) | [private] |
Open a new paragraph, and set paragraph-level layout.
References _closeParagraph(), gchar, PP_AttrProp::getAttribute(), PD_Document::getAttrProp(), m_currentParagraphCLayout, m_currentParagraphInLines, m_currentParagraphPLayout, m_currentParagraphStyle, m_currentParagraphText, m_inParagraph, m_pDocument, m_styles, style, updateCharacterLayout(), updateParagraphLayout(), UT_DEBUGMSG, and utf8_to_ucs2().
Referenced by populateStrux().
bool PL_Psion_Listener::_processStyles | ( | void | ) | [private] |
Translate all styles.
References _setStyleLayout(), PD_Document::getAllUsedStyles(), UT_GenericVector< T >::getItemCount(), PD_Style::getName(), UT_GenericVector< T >::getNthItem(), PD_Style::isCharStyle(), m_pDocument, m_styles, style, UT_DEBUGMSG, and utf8_to_ucs2().
Referenced by startDocument().
bool PL_Psion_Listener::_setStyleLayout | ( | PD_Style * | style, | |
psiconv_paragraph_layout | para_layout, | |||
psiconv_character_layout | char_layout | |||
) | [private] |
Determine the layout of this style, considering the styles it is based on.
A paragraph style is associated with a certain layout. That layout is partly defined in the style itself, and partly because it inherits layout from its parent style. This method gathers all that information, translates it to Psiconv format and puts it in para_layout and char_layout. Note that we call ourselves recursively; if we ever encounter a situation in which is style is based on itself, or is in some other circular relationship, we will crash and burn. So don't do that :-)
References PD_Document::getAttrProp(), PD_Style::getBasedOn(), PD_Style::getIndexAP(), m_pDocument, updateCharacterLayout(), and updateParagraphLayout().
Referenced by _processStyles().
bool PL_Psion_Listener::_writeText | ( | const UT_UCSChar * | p, | |
UT_uint32 | inLength, | |||
UT_uint32 & | outLength | |||
) | [private] |
Add some AbiWord document text to the current paragraph
Add some text to the current paragraph. Returns the length of the written text in outLength; this may be more or less than inLength, because some input characters may need to be represented by more than one output character, and because we may ignore some input characters.
References UT_UTF8Stringbuf::appendUCS4(), UT_UTF8Stringbuf::data(), m_currentParagraphText, UCS_ABI_OBJECT, UCS_CR, UCS_EM_DASH, UCS_EM_SPACE, UCS_EN_DASH, UCS_EN_SPACE, UCS_FF, UCS_LF, UCS_TAB, and UT_DEBUGMSG.
Referenced by populate().
virtual bool PL_Psion_Listener::change | ( | fl_ContainerLayout * | , | |
const PX_ChangeRecord * | ||||
) | [inline, virtual] |
Implements PL_Listener.
References UT_ASSERT, and UT_SHOULD_NOT_HAPPEN.
virtual psiconv_file PL_Psion_Listener::createPsionFile | ( | void | ) | [pure virtual] |
Implemented in PL_Psion_Word_Listener, and PL_Psion_TextEd_Listener.
Referenced by IE_Exp_Psion::_writeDocument().
bool PL_Psion_Listener::finishDocument | ( | void | ) |
Finish the traversing of the document by the Listener.
Call this after calling tellListener to traverse the document. Closes remaining paragraphs and sections.
References _closeParagraph().
Referenced by IE_Exp_Psion::_writeDocument().
virtual bool PL_Psion_Listener::insertStrux | ( | fl_ContainerLayout * | , | |
const PX_ChangeRecord * | , | |||
pf_Frag_Strux * | , | |||
PL_ListenerId | , | |||
void(*)(pf_Frag_Strux *sdhNew,PL_ListenerId lid,fl_ContainerLayout *sfhNew) | ||||
) | [inline, virtual] |
Implements PL_Listener.
References UT_ASSERT, and UT_SHOULD_NOT_HAPPEN.
bool PL_Psion_Listener::populate | ( | fl_ContainerLayout * | sfh, | |
const PX_ChangeRecord * | pcr | |||
) | [virtual] |
Standard listener callback for in-block data
This method is called when a span, object or format mark is found in the document while traversing it.
Implements PL_Listener.
References _addInLine(), _insertImage(), _writeText(), PX_ChangeRecord_Span::getBufIndex(), PX_ChangeRecord_Object::getField(), fd_Field::getFieldType(), PX_ChangeRecord::getIndexAP(), PX_ChangeRecord_Span::getLength(), PX_ChangeRecord_Object::getObjectType(), PD_Document::getPointer(), PX_ChangeRecord::getType(), m_currentParagraphPLayout, m_inParagraph, m_pDocument, PTO_Bookmark, PTO_Field, PTO_Hyperlink, PTO_Image, PX_ChangeRecord::PXT_InsertFmtMark, PX_ChangeRecord::PXT_InsertObject, PX_ChangeRecord::PXT_InsertSpan, UT_ASSERT, and UT_DEBUGMSG.
bool PL_Psion_Listener::populateStrux | ( | pf_Frag_Strux * | sdh, | |
const PX_ChangeRecord * | pcr, | |||
fl_ContainerLayout ** | psfh | |||
) | [virtual] |
Standard listener callback for block and section data
This method is called whenever a block (paragraph) or section is found in the document while traversing it.
Implements PL_Listener.
References _closeParagraph(), _openParagraph(), gchar, PP_AttrProp::getAttribute(), PD_Document::getAttrProp(), PX_ChangeRecord::getIndexAP(), PX_ChangeRecord::getType(), m_pDocument, m_sectionType, PTX_Block, PTX_EndCell, PTX_EndEndnote, PTX_EndFootnote, PTX_EndFrame, PTX_EndMarginnote, PTX_EndTable, PTX_Section, PTX_SectionCell, PTX_SectionFootnote, PTX_SectionFrame, PTX_SectionHdrFtr, PTX_SectionMarginnote, PTX_SectionTable, UT_ASSERT, UT_ASSERT_NOT_REACHED, and UT_DEBUGMSG.
virtual bool PL_Psion_Listener::signal | ( | UT_uint32 | ) | [inline, virtual] |
Implements PL_Listener.
References UT_ASSERT, and UT_SHOULD_NOT_HAPPEN.
bool PL_Psion_Listener::startDocument | ( | void | ) |
Initialize a new Psion Listener.
Call this right after the constructor. We can't call it from the constructor, because our constructor may not fail. We initialize all kinds of private variables. Some juggling is done with NULL values to make sure everything can be safely deallocated at any time by our destructor. We also parse all styles here. This is needed further on, and listeners do not traverse styles.
References _processStyles(), m_currentParagraphText, m_footer, m_header, and m_paragraphs.
Referenced by IE_Exp_Psion::_writeDocument().
psiconv_character_layout PL_Psion_Listener::m_currentParagraphCLayout [private] |
Referenced by _addInLine(), _closeParagraph(), _insertImage(), _openParagraph(), and ~PL_Psion_Listener().
psiconv_in_line_layouts PL_Psion_Listener::m_currentParagraphInLines [private] |
Referenced by _addInLine(), _closeParagraph(), _insertImage(), _openParagraph(), and ~PL_Psion_Listener().
psiconv_paragraph_layout PL_Psion_Listener::m_currentParagraphPLayout [private] |
Referenced by _closeParagraph(), _openParagraph(), populate(), and ~PL_Psion_Listener().
psiconv_s16 PL_Psion_Listener::m_currentParagraphStyle [private] |
Referenced by _closeParagraph(), and _openParagraph().
psiconv_list PL_Psion_Listener::m_currentParagraphText [private] |
Referenced by _closeParagraph(), _insertImage(), _openParagraph(), _writeText(), startDocument(), and ~PL_Psion_Listener().
psiconv_page_header PL_Psion_Listener::m_footer [protected] |
psiconv_page_header PL_Psion_Listener::m_header [protected] |
bool PL_Psion_Listener::m_inParagraph [private] |
Referenced by _addInLine(), _closeParagraph(), _openParagraph(), and populate().
psiconv_text_and_layout PL_Psion_Listener::m_paragraphs [protected] |
PD_Document* PL_Psion_Listener::m_pDocument [protected] |
Referenced by _addInLine(), _insertImage(), _openParagraph(), _processStyles(), _setStyleLayout(), populate(), and populateStrux().
sectionType PL_Psion_Listener::m_sectionType [private] |
Referenced by _closeParagraph(), and populateStrux().
psiconv_word_styles_section PL_Psion_Listener::m_styles [protected] |
Referenced by _openParagraph(), _processStyles(), and PL_Psion_Word_Listener::createPsionFile().