Public Member Functions | Protected Member Functions | Private Attributes

IE_Imp_Text Class Reference

#include <ie_imp_Text.h>

Inheritance diagram for IE_Imp_Text:

List of all members.

Public Member Functions

 IE_Imp_Text (PD_Document *pDocument, bool bEncoded=false)
 IE_Imp_Text (PD_Document *pDocument, const char *encoding)
virtual ~IE_Imp_Text ()
virtual bool pasteFromBuffer (PD_DocumentRange *pDocRange, const unsigned char *pData, UT_uint32 lenData, const char *szEncoding=0)

Protected Member Functions

virtual UT_Error _loadFile (GsfInput *fp)
UT_Error _recognizeEncoding (GsfInput *fp)
UT_Error _recognizeEncoding (const char *szBuf, UT_uint32 iNumbytes)
virtual UT_Error _constructStream (ImportStream *&pStream, GsfInput *fp)
UT_Error _writeHeader (GsfInput *fp)
UT_Error _parseStream (ImportStream *pStream)
bool _doEncodingDialog (const char *szEncoding)
void _setEncoding (const char *szEncoding)
bool _insertBlock ()
bool _insertSpan (UT_GrowBuf &b)

Private Attributes

const char * m_szEncoding
bool m_bExplicitlySetEncoding
bool m_bIsEncoded
bool m_bIs16Bit
bool m_bUseBOM
bool m_bBigEndian
bool m_bBlockDirectionPending
bool m_bFirstBlockData

Constructor & Destructor Documentation

IE_Imp_Text::IE_Imp_Text ( PD_Document pDocument,
const char *  encoding 
IE_Imp_Text::~IE_Imp_Text (  )  [virtual]

Member Function Documentation

UT_Error IE_Imp_Text::_constructStream ( ImportStream *&  pStream,
GsfInput *  fp 
) [protected, virtual]

Create a stream of the appropriate type

pStream Pointer to created stream
fp File to construct stream from

Override this virtual function to derive from the text importer

Reimplemented in IE_Imp_ISCII.

References UT_OK.

Referenced by _loadFile().

bool IE_Imp_Text::_insertSpan ( UT_GrowBuf b  )  [protected]

Insert a span of text into the document

b Buffer containing UCS text to insert

Uses appropriate function for clipboard or file

References IE_Imp::appendSpan(), IE_Imp::appendStruxFmt(), IE_Imp::getDoc(), IE_Imp::getDocPos(), UT_GrowBuf::getLength(), UT_GrowBuf::getPointer(), m_bBlockDirectionPending, m_bFirstBlockData, m_pBlock, PTX_Block, UT_GrowBuf::truncate(), type, UCS_LRM, UCS_RLM, UT_BIDI_IS_RTL, UT_BIDI_IS_STRONG, and UT_bidiGetCharType().

Referenced by _parseStream().

UT_Error IE_Imp_Text::_parseStream ( ImportStream pStream  )  [protected]

Parse stream contents into the document

stream Stream to import from

This code is used for both files and the clipboard

References _insertBlock(), _insertSpan(), _setEncoding(), UT_GrowBuf::append(), ImportStream::getChar(), UT_GrowBuf::getLength(), IE_Imp::getProperty(), ImportStream::init(), m_bExplicitlySetEncoding, m_szEncoding, UCS_BOM, UCS_CR, UCS_LF, UCS_LINESEP, UCS_PARASEP, UT_ERROR, UT_return_val_if_fail, and X_ReturnNoMemIfError.

Referenced by _loadFile(), and pasteFromBuffer().

UT_Error IE_Imp_Text::_recognizeEncoding ( const char *  szBuf,
UT_uint32  iNumbytes 
) [protected]

Detect encoding of text buffer

pData Buffer
lenData Length of buffer

Supports UTF-8 and UCS-2 big and little endian CJK encodings could be added

References IE_Imp_Text_Sniffer::_recognizeUCS2(), IE_Imp_Text_Sniffer::_recognizeUTF8(), _setEncoding(), XAP_EncodingManager::get_instance(), IE_Imp_Text_Sniffer::UE_BigEnd, and IE_Imp_Text_Sniffer::UE_LittleEnd.

UT_Error IE_Imp_Text::_recognizeEncoding ( GsfInput *  fp  )  [protected]

Detect encoding of text file

fp File

Supports UTF-8 and UCS-2 big and little endian CJK encodings could be added

References UT_MIN.

Referenced by _loadFile(), and pasteFromBuffer().

void IE_Imp_Text::_setEncoding ( const char *  szEncoding  )  [protected]

Set importer's encoding and related members

szEncoding Encoding to export file into

Decides endian and BOM policy based on encoding. Set to 0 to handle raw bytes. This function should be identical to the one in IE_Exp_Text.

References XAP_EncodingManager::get_instance(), XAP_EncodingManager::getUCS2BEName(), XAP_EncodingManager::getUCS2LEName(), m_bBigEndian, m_bIs16Bit, m_bUseBOM, and m_szEncoding.

Referenced by _doEncodingDialog(), _parseStream(), _recognizeEncoding(), IE_Imp_ISCII::IE_Imp_ISCII(), IE_Imp_Text(), and pasteFromBuffer().

UT_Error IE_Imp_Text::_writeHeader ( GsfInput *  fp  )  [protected]

Write header to document

Writes the minimum needed Section and Block before we begin import

References IE_Imp::appendStrux(), IE_Imp::getDoc(), pt_PieceTable::getFragments(), pf_Fragments::getLast(), PD_Document::getPieceTable(), pf_Frag::getType(), m_pBlock, PTX_Block, PTX_Section, UT_return_val_if_fail, and X_ReturnNoMemIfError.

Referenced by _loadFile().

bool IE_Imp_Text::pasteFromBuffer ( PD_DocumentRange pDocRange,
const unsigned char *  pData,
UT_uint32  lenData,
const char *  szEncoding = 0 
) [virtual]

Member Data Documentation

bool IE_Imp_Text::m_bBigEndian [private]

Referenced by _setEncoding().

Referenced by _insertBlock(), and _insertSpan().

bool IE_Imp_Text::m_bIs16Bit [private]

Referenced by _setEncoding().

bool IE_Imp_Text::m_bIsEncoded [private]

Referenced by _loadFile(), and IE_Imp_Text().

bool IE_Imp_Text::m_bUseBOM [private]

Referenced by _setEncoding().

const char* IE_Imp_Text::m_szEncoding [private]

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