本文整理汇总了C++中UT_UTF8String::length方法的典型用法代码示例。如果您正苦于以下问题:C++ UT_UTF8String::length方法的具体用法?C++ UT_UTF8String::length怎么用?C++ UT_UTF8String::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UT_UTF8String
的用法示例。
在下文中一共展示了UT_UTF8String::length方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void IE_Exp_EPUB_EPUB3Writer::insertAnnotations(
const std::vector<UT_UTF8String> &titles,
const std::vector<UT_UTF8String> &authors,
const std::vector<UT_UTF8String> &annotations)
{
m_pTagWriter->openTag("section");
m_pTagWriter->addAttribute("epub:type", "annotations");
for(size_t i = 0; i < annotations.size(); i++)
{
UT_UTF8String title = titles.at(i);
UT_UTF8String author = authors.at(i);
UT_UTF8String annotation = annotations.at(i);
m_pTagWriter->openTag("section");
// m_pTagWriter->addAttribute("class", "annotation");
m_pTagWriter->addAttribute("epub:type", "annotation");
m_pTagWriter->addAttribute("id", UT_UTF8String_sprintf("annotation-%d",
i + 1).utf8_str());
if (title.length())
{
m_pTagWriter->openTag("h4");
m_pTagWriter->writeData(title.utf8_str());
m_pTagWriter->closeTag();
}
/*if (author.length())
{
m_pTagWriter->openTag("span");
m_pTagWriter->addAttribute("class", "annotation-author");
m_pTagWriter->writeData(author.utf8_str());
m_pTagWriter->closeTag();
m_pTagWriter->openTag("br", false, true);
m_pTagWriter->closeTag();
}*/
if (annotation.length())
{
m_pTagWriter->openTag("blockquote");
// m_pTagWriter->addAttribute("class", "annotation-content");
m_pTagWriter->writeData(annotation.utf8_str());
m_pTagWriter->closeTag();
}
m_pTagWriter->closeTag();
}
m_pTagWriter->closeTag();
}
示例2: insertText
void ODe_TOC_Listener::insertText(const UT_UTF8String& rText) {
if (!m_bInTOCBlock)
return;
if (rText.length() == 0)
return;
UT_return_if_fail(m_rAuxiliaryData.m_pTOCContents);
ODe_writeUTF8String(m_rAuxiliaryData.m_pTOCContents, rText);
}
示例3: getCharacterAttributes
/*!
* Get all character-related attributes and append them to props.
*
* If props is not empty, we start with '; ', else we do not.
*/
UT_Error IE_Imp_Psion::getCharacterAttributes(const psiconv_character_layout layout,
UT_UTF8String &props)
{
UT_return_val_if_fail(layout != NULL, true /* perhaps should be false, but we want loading to proceed */);
UT_UTF8String buffer;
int fontsize;
UT_UCS4Char ucs4char;
int i;
// Append a semicolon if there is already text in the props
if (props.length())
props += "; ";
// font family
// BUG: No checking is done yet whether this family is known to AbiWord.
// We need to sanitize the font name first, or we could confuse the
// properties parser.
props += "font-family:";
for (i = 0; i < psiconv_unicode_strlen(layout->font->name); i++) {
ucs4char = layout->font->name[i];
if ((ucs4char < 0x20) || (ucs4char == ';') || (ucs4char == ':'))
ucs4char = '?';
props.appendUCS4(&ucs4char,1);
}
// font size.
// This should be moved to some general-purpose function.
// At the moment, only the following font-sizes seem to be supported
// by the GUI: 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28,
// 36, 48 and 72. Others give GTK errors. This should be changed I think.
fontsize = (int) layout->font_size;
if (fontsize < 8)
fontsize = 8;
if ((fontsize % 2) && (fontsize > 11))
fontsize -=1;
if (fontsize > 28) {
if (fontsize < 32)
fontsize = 28;
else if (fontsize < 42)
fontsize = 36;
else if (fontsize < 60)
fontsize = 48;
else
fontsize = 72;
}
UT_UTF8String_sprintf(buffer,"; font-size:%dpt",fontsize);
props += buffer;
// bold
UT_UTF8String_sprintf(buffer, "; font-weight:%s", layout->bold ? "bold" : "normal");
props += buffer;
// italic
UT_UTF8String_sprintf(buffer, "; font-style:%s",layout->italic ? "italic" : "normal");
props += buffer;
// underline and strike-through
UT_UTF8String_sprintf(buffer, "; text-decoration:%s",
layout->underline && layout->strikethrough?"underline line-through":
layout->underline && !layout->strikethrough?"underline":
!layout->underline && layout->strikethrough?"line-through":
"none");
props += buffer;
// superscript and subscript
UT_UTF8String_sprintf(buffer, "; text-position:%s",
layout->super_sub == psiconv_superscript?"superscript":
layout->super_sub == psiconv_subscript ?"subscript":
"normal");
props += buffer;
// text color
UT_UTF8String_sprintf(buffer, "; color:%02x%02x%02x", (layout->color->red),
(layout->color->green),
(layout->color->blue));
props += buffer;
// background color
UT_UTF8String_sprintf(buffer, "; bgcolor:%02x%02x%02x", layout->back_color->red,
layout->back_color->green,
layout->back_color->blue);
props += buffer;
return UT_OK;
}
示例4: getParagraphAttributes
/*!
* Get all paragraph-related attributes and append them to props.
*
* If props is not empty, we start with '; ', else we do not.
*/
UT_Error IE_Imp_Psion::getParagraphAttributes(const psiconv_paragraph_layout layout,
UT_UTF8String &props)
{
UT_return_val_if_fail(layout != NULL, true /* perhaps should be false, but we want loading to proceed */);
UT_UTF8String buffer;
psiconv_length_t indent_left,indent_first;
int i;
psiconv_tab tab;
// Compute the indent_left and indent_first settings. Note that
// indent_first is always relative to indent_left. There are a few
// special cases related to bullets; see the psiconv docs for details.
if (layout->bullet && layout->bullet->on && layout->bullet->indent &&
(layout->indent_first > 0))
indent_left = layout->indent_left + layout->indent_first;
else
indent_left = layout->indent_left;
if (layout->bullet && layout->bullet->on && (layout->indent_first > 0))
if (layout->bullet->indent)
indent_first = -layout->indent_first;
else
indent_first = 0;
else
indent_first = layout->indent_first;
// Append a semicolon if there is already text in the props
if (props.length())
props += ";";
// Left indent
UT_UTF8String_sprintf(buffer,"margin-left:%6.3fcm",indent_left);
props += buffer;
// Right indent
UT_UTF8String_sprintf(buffer,"; margin-right:%6.3fcm",layout->indent_right);
props += buffer;
// First line indent
UT_UTF8String_sprintf(buffer,"; text-indent:%6.3fcm",indent_first);
props += buffer;
// Horizontal justify
UT_UTF8String_sprintf(buffer,"; text-align:%s",
layout->justify_hor==psiconv_justify_left ? "left" :
layout->justify_hor==psiconv_justify_right ? "right":
layout->justify_hor==psiconv_justify_centre? "center":
"justify");
props += buffer;
// Vertical justify: ignored (never used in Word documents)
// Background color
UT_UTF8String_sprintf(buffer, "; bgcolor: %02x%02x%02x",
layout->back_color->red,
layout->back_color->green,
layout->back_color->blue);
props += buffer;
#if 0
// Linespacing (gives trouble at the moment, so we disable it)
UT_UTF8String_sprintf(buffer, "; line-height: %dpt",(int) layout->linespacing);
props += buffer;
if (! layout->linespacing_exact)
props += "+";
#endif
// Space above
UT_UTF8String_sprintf(buffer,"; margin-top:%dpt",(int) layout->space_above);
props += buffer;
// Space below
UT_UTF8String_sprintf(buffer,"; margin-bottom:%dpt",(int) layout->space_below);
props += buffer;
// Keep together
UT_UTF8String_sprintf(buffer,"; keep-together:%s",layout->keep_together?"yes":"no");
props += buffer;
// Keep with next
UT_UTF8String_sprintf(buffer,"; keep-with-next:%s",layout->keep_with_next?"yes":"no");
props += buffer;
// On next page
// This is not yet implemented in AbiWord. We use a hack in
// applyParagraphAttributes; styles are out of luck in this.
// Last checked 20040229: Dialog is available, but no property yet.
// Widow control
// I'm not quite sure about the difference between setting widows and
// orphans?!?
UT_UTF8String_sprintf(buffer,"; widows:%d; orphans:%d",
layout->no_widow_protection?0:2,
layout->no_widow_protection?0:2);
//.........这里部分代码省略.........
示例5: _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());
}
}
}
}
示例6: 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;
}
示例7:
/* replaces <str1> with <str2> in the current string
*/
void UT_UTF8Stringbuf::escape (const UT_UTF8String & utf8_str1,
const UT_UTF8String & utf8_str2)
{
size_t diff = 0;
size_t len1 = utf8_str1.byteLength ();
size_t len2 = utf8_str2.byteLength ();
const char * str1 = utf8_str1.utf8_str ();
const char * str2 = utf8_str2.utf8_str ();
if (len2 > len1)
{
diff = len2 - len1;
size_t incr = 0;
char * ptr = m_psz;
while (ptr + len1 <= m_pEnd)
{
if (memcmp (ptr, str1, len1) == 0)
{
incr += diff;
ptr += len1;
}
else
{
++ptr;
}
}
if (!grow (incr)) return;
}
else
{
diff = len1 - len2;
}
char * ptr = m_psz;
while (ptr + len1 <= m_pEnd)
{
if (memcmp (ptr, str1, len1) == 0)
{
if (diff)
{
if (len2 > len1)
{
memmove (ptr + diff, ptr, m_pEnd - ptr + 1);
m_pEnd += diff;
}
else
{
memmove (ptr, ptr + diff, m_pEnd - (ptr + diff) + 1);
m_pEnd -= diff;
}
}
memcpy (ptr, str2, len2);
ptr += len2;
m_strlen += utf8_str2.length () - utf8_str1.length ();
}
else
{
++ptr;
}
}
}