当前位置: 首页>>代码示例>>C++>>正文


C++ UT_UTF8String::escapeXML方法代码示例

本文整理汇总了C++中UT_UTF8String::escapeXML方法的典型用法代码示例。如果您正苦于以下问题:C++ UT_UTF8String::escapeXML方法的具体用法?C++ UT_UTF8String::escapeXML怎么用?C++ UT_UTF8String::escapeXML使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UT_UTF8String的用法示例。


在下文中一共展示了UT_UTF8String::escapeXML方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _handleField

void s_XSL_FO_Listener::_handleField(const PX_ChangeRecord_Object * pcro, PT_AttrPropIndex api)
{
	if(!m_iBlockDepth && !m_iListBlockDepth)
		return;

	const PP_AttrProp* pAP = NULL;
	bool bHaveProp = m_pDocument->getAttrProp(api, &pAP);
	
	if (bHaveProp && pAP)
	{
		const gchar* szValue = NULL;
		if (pAP->getAttribute("type", szValue) && szValue)
		{
			fd_Field * field = pcro->getField();

			m_pie->populateFields ();

			if((_tagTop() == TT_LISTBLOCK) && !strcmp(static_cast<const char*>(szValue), "list_label"))
			{
				m_pie->write("\n");

				_tagOpen(TT_LISTITEM, "list-item");
				_tagOpen(TT_LISTITEMLABEL, "list-item-label end-indent=\"label-end()\"", false);
				_tagOpen(TT_BLOCK, "block", false);

				UT_UTF8String label = "";
				for(UT_sint32 i = 0; i < m_Lists.getItemCount(); i++)
				{
					ListHelper * lh = m_Lists[i];
					if(lh && ((*lh).retrieveID() == m_iListID))
					{
						label = (*lh).getNextLabel();
						break;
					}
				}

				if(label.length())
					m_pie->write(label.utf8_str()); //write out the list label text

				_tagClose(TT_BLOCK, "block", false);
				_tagClose(TT_LISTITEMLABEL, "list-item-label");
				_tagOpen(TT_LISTITEMBODY, "list-item-body start-indent=\"body-start()\"", false);
				_tagOpen(TT_BLOCK, "block", false);

				m_iBlockDepth++;
				m_bWroteListField = true;
			}
			else if(!strcmp(szValue, "footnote_ref"))
			{
				UT_UTF8String buf = field->getValue();
				buf.escapeXML();

				_tagOpen(TT_FOOTNOTE, "footnote", false);
				_tagOpen(TT_INLINE, "inline", false);

				if(buf.length())
					m_pie->write(buf.utf8_str());

				_tagClose(TT_INLINE, "inline", false);
			}
			else
			{
				UT_UTF8String buf = field->getValue();
				buf.escapeXML();

				if(buf.length())
					m_pie->write(buf.utf8_str());
			}
		}
	}
}
开发者ID:Distrotech,项目名称:abiword,代码行数:71,代码来源:ie_exp_XSL-FO.cpp

示例2: writeMetaData

bool ODe_MetaDataWriter::writeMetaData(PD_Document* pDoc, GsfOutfile* oo) {
    
    GsfOutput* meta = gsf_outfile_new_child (oo, "meta.xml", FALSE);

    static const UT_UTF8String preamble =
        UT_UTF8String("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
        "<office:document-meta"
            " xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\""
            " xmlns:xlink=\"http://www.w3.org/1999/xlink\""
            " xmlns:dc=\"http://purl.org/dc/elements/1.1/\""
            " xmlns:meta=\"urn:oasis:names:tc:opendocument:xmlns:meta:1.0\""
            " xmlns:ooo=\"http://openoffice.org/2004/office\""
            " office:version=\"1.1\">\n"
        "<office:meta>\n"
        "<meta:generator>AbiWord/") + PACKAGE_VERSION + " (" + PLATFORM + ", " + TOOLKIT + ")</meta:generator>\n";

    static const char * const postamble [] = {
        "</office:meta>\n",
        "</office:document-meta>\n"
    };

    ODe_writeUTF8String(meta, preamble);

    UT_UTF8String meta_val, val;
    
#define WRITE_METADATA_ELEMENT(abiwordKey, odElementName) if (pDoc->getMetaDataProp(abiwordKey, meta_val) && meta_val.size()) { \
                                                               meta_val.escapeXML(); \
                                                               val = UT_UTF8String_sprintf("<%s>%s</%s>\n", odElementName, meta_val.utf8_str(), odElementName); \
                                                               ODe_writeUTF8String (meta, val); \
                                                          }
    
    WRITE_METADATA_ELEMENT(PD_META_KEY_TITLE, "dc:title");
    WRITE_METADATA_ELEMENT(PD_META_KEY_DESCRIPTION, "dc:description");
    WRITE_METADATA_ELEMENT(PD_META_KEY_SUBJECT, "dc:subject");

    //Each keyword needs to be exported individually:

    UT_UTF8String keywords;
    if (pDoc->getMetaDataProp (PD_META_KEY_KEYWORDS, keywords) && keywords.size())
    {
        UT_UTF8String buf = "";
        UT_UCS4String keyword = keywords.utf8_str();

        for(UT_uint32 i = 0;i < keyword.length(); i++)
        {
            if(keyword[i] != ' ')
            {
                buf += keyword[i];
            }
            else
            {
                if(buf.empty())  //only blank space encountered
                    continue;

                buf.escapeXML();
                val = UT_UTF8String_sprintf("<meta:keyword>%s</meta:keyword>\n", buf.utf8_str());
                ODe_writeUTF8String(meta, val);
                buf.clear();
            }
        }

        if(buf.length())  //there may only be one keyword (i.e. no spaces encountered)
        {
            buf.escapeXML();
            val = UT_UTF8String_sprintf("<meta:keyword>%s</meta:keyword>\n", buf.utf8_str());
            ODe_writeUTF8String(meta, val);
        }
    }

    // Should have a PD_META_KEY_INITIAL_CREATOR macro for this one, but only
    // if it gets implemented on the document properties dialog.
    WRITE_METADATA_ELEMENT("meta:initial-creator", "meta:initial-creator");
    
    WRITE_METADATA_ELEMENT(PD_META_KEY_CREATOR, "dc:creator");
    
    WRITE_METADATA_ELEMENT("meta:printed-by", "meta:printed-by");
    
    // ATTENTION: I'm assuming that dc.date is used by AbiWord as
    // the document creation date & time.
    WRITE_METADATA_ELEMENT(PD_META_KEY_DATE, "meta:creation-date");
    
    // Note that, for the OpenDocument standard, dc.date
    // is the last modification date & time.
    WRITE_METADATA_ELEMENT(PD_META_KEY_DATE_LAST_CHANGED, "dc:date");
    
    WRITE_METADATA_ELEMENT("meta:print-date", "meta:print-date");
    
    WRITE_METADATA_ELEMENT(PD_META_KEY_LANGUAGE, "dc:language");
    
#undef WRITE_METADATA_ELEMENT

    ODe_writeToStream(meta, postamble, G_N_ELEMENTS(postamble));

    ODe_gsf_output_close(meta);

    return true;
}
开发者ID:Distrotech,项目名称:abiword,代码行数:97,代码来源:ODe_MetaDataWriter.cpp


注:本文中的UT_UTF8String::escapeXML方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。