本文整理汇总了C++中UT_XML::setListener方法的典型用法代码示例。如果您正苦于以下问题:C++ UT_XML::setListener方法的具体用法?C++ UT_XML::setListener怎么用?C++ UT_XML::setListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UT_XML
的用法示例。
在下文中一共展示了UT_XML::setListener方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pasteFromBuffer
bool IE_Imp_XML::pasteFromBuffer(PD_DocumentRange * pDocRange, const unsigned char * pData,
UT_uint32 lenData, const char * /*szEncoding*/)
{
UT_DEBUGMSG(("IE_Imp_XML::pasteFromBuffer\n"));
UT_return_val_if_fail(pDocRange && pDocRange->m_pDoc,false);
setClipboard(pDocRange->m_pos1);
UT_XML default_xml;
UT_XML * parser = &default_xml;
if (m_pParser) parser = m_pParser;
parser->setListener (this);
if (m_pReader) parser->setReader (m_pReader);
UT_Error err = parser->parse ((const char*)pData, lenData);
if ((err != UT_OK) && (err != UT_IE_SKIPINVALID))
m_error = UT_IE_BOGUSDOCUMENT;
if (m_error != UT_OK)
{
UT_DEBUGMSG(("Problem reading document\n"));
return false;
}
return true;
}
示例2: importFile
UT_Error IE_Imp_XML::importFile(const char * data, UT_uint32 length)
{
m_szFileName = 0;
UT_XML default_xml;
UT_XML * parser = &default_xml;
if (m_pParser) parser = m_pParser;
parser->setListener (this);
if (m_pReader) parser->setReader (m_pReader);
UT_Error err = parser->parse (data, length);
if ((err != UT_OK) && (err != UT_IE_SKIPINVALID))
m_error = UT_IE_BOGUSDOCUMENT;
if (m_error != UT_OK)
{
UT_DEBUGMSG(("Problem reading document\n"));
if(m_error != UT_IE_SKIPINVALID)
m_szFileName = 0;
}
return m_error;
}
示例3: _loadFile
UT_Error IE_Imp_XML::_loadFile(GsfInput * input)
{
m_szFileName = gsf_input_name (input);
UT_XML default_xml;
UT_XML * parser = &default_xml;
if (m_pParser) parser = m_pParser;
parser->setListener (this);
if (m_pReader) parser->setReader (m_pReader);
// hack!!!
size_t num_bytes = gsf_input_size(input);
char * bytes = (char *)gsf_input_read(input, num_bytes, NULL);
UT_Error err = parser->parse (bytes, num_bytes);
if ((err != UT_OK) && (err != UT_IE_SKIPINVALID))
m_error = UT_IE_BOGUSDOCUMENT;
if (m_error != UT_OK)
{
UT_DEBUGMSG(("Problem reading document\n"));
if(m_error != UT_IE_SKIPINVALID)
m_szFileName = 0;
}
return m_error;
}
示例4: readMetadata
UT_Error IE_Imp_EPUB::readMetadata()
{
GsfInput* metaInf = gsf_infile_child_by_name(m_epub, "META-INF");
if (metaInf == NULL)
{
UT_DEBUGMSG(("Can`t open container META-INF dir\n"));
return UT_ERROR;
}
GsfInput* meta = gsf_infile_child_by_name(GSF_INFILE(metaInf),
"container.xml");
if (meta == NULL)
{
UT_DEBUGMSG(("Can`t open container metadata\n"));
return UT_ERROR;
}
size_t metaSize = gsf_input_size(meta);
if (metaSize == 0)
{
UT_DEBUGMSG(("Container metadata file is empty\n"));
return UT_ERROR;
}
gchar* metaXml = (gchar*) gsf_input_read(meta, metaSize, NULL);
std::string rootfilePath;
UT_XML metaParser;
ContainerListener containerListener;
metaParser.setListener(&containerListener);
if (metaParser.sniff(metaXml, metaSize, "container"))
{
UT_DEBUGMSG(("Parsing container.xml file\n"));
metaParser.parse(metaXml, metaSize);
}
else
{
UT_DEBUGMSG(("Incorrect container.xml file\n"));
return UT_ERROR;
}
m_rootfilePath = containerListener.getRootFilePath();
g_object_unref(G_OBJECT(meta));
g_object_unref(G_OBJECT(metaInf));
return UT_OK;
}
示例5: _recognizeContent
static bool _recognizeContent(const char* buffer,UT_uint32 buflen,UT_svg* data)
{
data->m_bSVG = false;
data->m_bContinue = true;
data->m_bIsText = false;
data->m_bIsTSpan = false;
data->m_bHasTSpan = false;
UT_XML parser;
parser.setListener (data);
if (parser.parse (buffer,buflen) != UT_OK) data->m_bSVG = false;
return data->m_bSVG;
}
示例6: readPackage
UT_Error IE_Imp_EPUB::readPackage()
{
gchar **aname = g_strsplit(m_rootfilePath.c_str(), G_DIR_SEPARATOR_S, 0);
GsfInput* opf = gsf_infile_child_by_aname(m_epub, (const char**) aname);
UT_DEBUGMSG(("Getting parent\n"));
GsfInfile* opfParent = gsf_input_container(opf);
m_opsDir = std::string(gsf_input_name(GSF_INPUT(opfParent)));
UT_DEBUGMSG(("OPS dir: %s\n", m_opsDir.c_str()));
if (opf == NULL)
{
UT_DEBUGMSG(("Can`t open .opf file\n"));
return UT_ERROR;
}
size_t opfSize = gsf_input_size(opf);
gchar* opfXml = (gchar*) gsf_input_read(opf, opfSize, NULL);
UT_XML opfParser;
OpfListener opfListener;
opfParser.setListener(&opfListener);
if (opfParser.sniff(opfXml, opfSize, "package"))
{
UT_DEBUGMSG(("Parsing opf file\n"));
opfParser.parse(opfXml, opfSize);
}
else
{
UT_DEBUGMSG(("Incorrect opf file found \n"));
return UT_ERROR;
}
g_strfreev(aname);
g_object_unref(G_OBJECT(opf));
//g_object_unref(G_OBJECT(opfParent));
m_spine = opfListener.getSpine();
m_manifestItems = opfListener.getManifestItems();
return UT_OK;
}
示例7: _parseStream
UT_Error OXMLi_PackageManager::_parseStream( GsfInput * stream, OXMLi_StreamListener * pListener)
{
UT_return_val_if_fail(stream != NULL && pListener != NULL , UT_ERROR);
//First, we check if this stream has already been parsed before
std::string part_name = gsf_input_name(stream); //TODO: determine if part names are truly unique
std::map<std::string, bool>::iterator it;
it = m_parsedParts.find(part_name);
if (it != m_parsedParts.end() && it->second) {
//this stream has already been parsed successfully
return UT_OK;
}
UT_Error ret = UT_OK;
guint8 const *data = NULL;
const char * cdata = NULL;
size_t len = 0;
UT_XML reader;
reader.setListener(pListener);
if (gsf_input_size (stream) > 0) {
len = gsf_input_remaining (stream);
if (len > 0) {
data = gsf_input_read (stream, len, NULL);
if (NULL == data) {
g_object_unref (G_OBJECT (stream));
return UT_ERROR;
}
cdata = (const char *)data;
ret = reader.parse (cdata, len);
}
}
//There are two error codes to check here.
if (ret == UT_OK && pListener->getStatus() == UT_OK)
m_parsedParts[part_name] = true;
//We prioritize the one from UT_XML when returning.
return ret == UT_OK ? pListener->getStatus() : ret;
}
示例8: _handleStream
/**
* Handle the stream @stream using the listener @listener.
* Tries to abstract away how we're actually going to handle
* how we read the stream, so that the underlying implementation
* can easily adapt or change
*/
UT_Error IE_Imp_OpenDocument::_handleStream ( GsfInfile* pGsfInfile,
const char * pStream, UT_XML::Listener& rListener)
{
GsfInput* pInput = gsf_infile_child_by_name(pGsfInfile, pStream);
UT_return_val_if_fail(pInput, UT_ERROR);
// check if the stream is encrypted, and if so, decrypt it
std::map<std::string, ODc_CryptoInfo>::iterator pos = m_cryptoInfo.find(pStream);
if (pos != m_cryptoInfo.end())
{
UT_DEBUGMSG(("Running decrypt on stream %s\n", pStream));
#ifndef HAVE_GCRYPT
UT_DEBUGMSG(("Can not decrypt files because of how abiword is compiled!\n"));
return UT_ERROR;
#endif
GsfInput* pDecryptedInput = NULL;
UT_Error err = ODc_Crypto::decrypt(pInput, (*pos).second, m_sPassword.utf8_str(), &pDecryptedInput);
g_object_unref (G_OBJECT (pInput));
if (err != UT_OK) {
UT_DEBUGMSG(("Decryption failed!\n"));
return err;
}
UT_DEBUGMSG(("Stream %s decrypted\n", pStream));
pInput = pDecryptedInput;
}
// parse the XML stream
UT_XML reader;
reader.setListener ( &rListener );
UT_Error err = _parseStream (pInput, reader);
g_object_unref (G_OBJECT (pInput));
return err;
}