本文整理汇总了C++中UT_UTF8String::appendBuf方法的典型用法代码示例。如果您正苦于以下问题:C++ UT_UTF8String::appendBuf方法的具体用法?C++ UT_UTF8String::appendBuf怎么用?C++ UT_UTF8String::appendBuf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UT_UTF8String
的用法示例。
在下文中一共展示了UT_UTF8String::appendBuf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadEmbedData
void GR_MathManager::loadEmbedData(UT_sint32 uid)
{
SmartPtr<libxml2_MathView> pMathView = m_vecMathView.getNthItem(uid);
UT_return_if_fail(pMathView);
const PP_AttrProp * pSpanAP = NULL;
GR_AbiMathItems * pItem = m_vecItems.getNthItem(uid);
UT_return_if_fail(pItem);
PT_AttrPropIndex api = pItem->m_iAPI;
m_pDoc->getAttrProp(api, &pSpanAP);
const char * pszDataID = NULL;
bool bFoundDataID = pSpanAP->getAttribute("dataid", pszDataID);
UT_DEBUGMSG(("DataID val =%s \n",pszDataID));
UT_UTF8String sMathML;
if (bFoundDataID && pszDataID)
{
const UT_ByteBuf * pByteBuf = NULL;
bFoundDataID = m_pDoc->getDataItemDataByName(pszDataID,
const_cast<const UT_ByteBuf **>(&pByteBuf),
NULL, NULL);
UT_return_if_fail(pByteBuf && bFoundDataID);
UT_UCS4_mbtowc myWC;
sMathML.appendBuf( *pByteBuf, myWC);
}
UT_return_if_fail(bFoundDataID);
UT_return_if_fail(pszDataID);
UT_DEBUGMSG(("MATH ML string is... \n %s \n",sMathML.utf8_str()));
// printf("MATH ML string is... \n %s \n",sMathML.utf8_str());
_loadMathML(uid, sMathML);
}
示例2: convert
bool GR_MathManager::convert(UT_uint32 iConType, UT_ByteBuf & From, UT_ByteBuf & To)
{
XAP_App * pApp = XAP_App::getApp();
XAP_Frame * pFrame = pApp->getLastFocussedFrame();
if (iConType != 0)
{
return false;
}
/* add a pair of enclosing brackets \[ \] */
UT_UTF8String sLatex;
UT_UCS4_mbtowc myWC;
sLatex += "\\[";
sLatex.appendBuf(From, myWC);
sLatex += "\\]";
char * mathml = itex2MML_parse(sLatex.utf8_str(), sLatex.size());
if (!mathml)
{
pFrame->showMessageBox("itex2MML failed to convert the LaTeX equation into MathML, sorry!\n", // TODO: fix message
XAP_Dialog_MessageBox::b_O,
XAP_Dialog_MessageBox::a_OK);
return false;
}
UT_UTF8String sMathML(mathml);
itex2MML_free_string(mathml);
if (sMathML.size() == 0)
{
UT_UTF8String sErrMessage = "itex2MML conversion from LaTex equation resulted in zero-length MathML!\n"; // TODO: fix message
//sErrMessage += sLatex;
sErrMessage += "\n";
// sErrMessage += FullLine;
pFrame->showMessageBox(sErrMessage.utf8_str(),
XAP_Dialog_MessageBox::b_O,
XAP_Dialog_MessageBox::a_OK);
return false;
}
UT_DEBUGMSG(("Input MathML %s \n", sMathML.utf8_str()));
return EntityTable().convert(sMathML.utf8_str(), sMathML.size(), To);
}
示例3: _insertMath
void ODe_AbiDocListener::_insertMath(PT_AttrPropIndex api) {
const gchar* szMath = NULL;
szMath = _getObjectKey(api, static_cast<const gchar*>("dataid"));
UT_return_if_fail(szMath);
const UT_ByteBuf * pByteBuf = NULL;
bool bOK = m_pDocument->getDataItemDataByName(szMath, const_cast<const UT_ByteBuf **>(&pByteBuf), NULL, NULL);
UT_return_if_fail(bOK);
UT_UCS4_mbtowc myWC;
UT_UTF8String sMathML;
sMathML.appendBuf(*pByteBuf, myWC);
UT_return_if_fail(!sMathML.empty());
UT_UCS4String buf = sMathML.utf8_str();
UT_UTF8String output = "";
const PP_AttrProp * pAP = NULL;
bool bHaveProp = m_pDocument->getAttrProp(api,&pAP);
UT_LocaleTransactor t(LC_NUMERIC, "C");
UT_UTF8String dimension;
double dInch;
UT_return_if_fail(bHaveProp && pAP);
_openSpan(api);
if(pAP->getProperty("width", szMath)) {
dInch = static_cast<double>(atoi(szMath))/UT_LAYOUT_RESOLUTION;
UT_UTF8String_sprintf(dimension,"%fin",dInch);
output += "<draw:frame svg:width=\"";
output += dimension;
output += "\" svg:height=\"";
} else {
UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN);
_closeSpan();
return;
}
if(pAP->getProperty("height", szMath)) {
dInch = static_cast<double>(atoi(szMath))/UT_LAYOUT_RESOLUTION;
dimension.clear();
UT_UTF8String_sprintf(dimension,"%fin",dInch);
output += dimension;
output += "\"><draw:object>";
} else {
UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN);
_closeSpan();
return;
}
for (UT_uint32 i = 0; i < buf.length(); i++) {
if (buf[i] == '<') {
if (((i + 1) < buf.length()) && (buf[i+1] == '/')) {
output += "</math:";
i++; // skip the '/'
} else if ((i + 1) < buf.length()) {
output += "<math:";
} else {
UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN);
}
} else {
output += buf[i];
}
}
output += "</draw:object></draw:frame>";
m_pCurrentImpl->insertText(output);
_closeSpan();
}