本文整理汇总了C++中UT_UTF8String::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ UT_UTF8String::clear方法的具体用法?C++ UT_UTF8String::clear怎么用?C++ UT_UTF8String::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UT_UTF8String
的用法示例。
在下文中一共展示了UT_UTF8String::clear方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyStyles
/*!
* Append all styles from the Psion Word Styles Section.
*/
UT_Error IE_Imp_Psion::applyStyles(const psiconv_word_styles_section style_sec)
{
UT_UTF8String props;
int i;
gchar *stylename;
psiconv_word_style style;
UT_Error res;
// Iterate through all defined styles.
// Index -1 is misused to represent the default "Normal" style.
for (i = -1; i < (int) psiconv_list_length(style_sec->styles); i++) {
if (i == -1)
style = style_sec->normal;
else if (!(style = (psiconv_word_style)
psiconv_list_get(style_sec->styles,i)))
return UT_IE_IMPORTERROR;
// Get the style paragraph and character attributes.
props.clear();
if ((res = getParagraphAttributes(style->paragraph,props)))
return res;
if ((res = getCharacterAttributes(style->character,props)))
return res;
// Not yet implemented: hotkey
// Not yet implemented: built_in
// Not yet implemented: outline_level
// The three unimplemented features above are not yet available
// within AbiWord.
// Get the style name.
if (i == -1)
stylename = (gchar *) strdup("Normal");
else
stylename = prepare_style_name(style->name);
if (!stylename)
return UT_IE_NOMEMORY;
UT_DEBUGMSG(("PSION: Importing style %s\n",stylename));
UT_DEBUGMSG(("PSION: Style attributes: %s\n",props.utf8_str()));
const PP_PropertyVector propsArray = {
"props", props.utf8_str(),
"name", stylename,
// All Psion styles are based upon the Normal style
"basedon", "Normal"
};
if (!(getDoc()->appendStyle(propsArray))) {
UT_DEBUGMSG(("PSION: AppendStyle failed...\n"));
free(stylename);
return UT_IE_IMPORTERROR;
}
free(stylename);
}
return UT_OK;
}
示例2: getDocDefaultLangCheckboxLabel
/*!
Fills s with the string to be used as a label for the the default language checkbox
*/
void XAP_Dialog_Language::getDocDefaultLangCheckboxLabel(UT_UTF8String &s)
{
s.clear();
const XAP_StringSet * pSS = XAP_App::getApp()->getStringSet();
UT_return_if_fail(pSS);
pSS->getValueUTF8(XAP_STRING_ID_DLG_ULANG_DefaultLangChkbox, s);
}
示例3: getDocDefaultLangDescription
/*!
Fills s with the string to be displayed in the default language static control
*/
void XAP_Dialog_Language::getDocDefaultLangDescription(UT_UTF8String & s)
{
s.clear();
const XAP_StringSet * pSS = XAP_App::getApp()->getStringSet();
UT_return_if_fail(pSS);
pSS->getValueUTF8(XAP_STRING_ID_DLG_ULANG_DefaultLangLabel, s);
s += m_docLang;
}
示例4: _handlePageSize
void s_XSL_FO_Listener::_handlePageSize(PT_AttrPropIndex api)
{
//
// Code to write out the PageSize Definitions to disk
//
const PP_AttrProp * pAP = NULL;
bool bHaveProp = m_pDocument->getAttrProp(api,&pAP);
UT_LocaleTransactor t(LC_NUMERIC, "C");
UT_UTF8String master = "simple-page-master";
_tagOpen(TT_LAYOUT_MASTER_SET, "layout-master-set");
// query and output properties
// todo - validate these and make sure they all make sense
if (bHaveProp && pAP)
{
const gchar * szValue = NULL;
szValue = PP_evalProperty("page-margin-top",
NULL, NULL, pAP, m_pDocument, true);
if(szValue)
{
master += " margin-top=\"";
master += szValue;
master += "\"";
}
szValue = PP_evalProperty("page-margin-bottom",
NULL, NULL, pAP, m_pDocument, true);
if(szValue)
{
master += " margin-bottom=\"";
master += szValue;
master += "\"";
}
szValue = PP_evalProperty("page-margin-left",
NULL, NULL, pAP, m_pDocument, true);
if(szValue)
{
master += " margin-left=\"";
master += szValue;
master += "\"";
}
szValue = PP_evalProperty("page-margin-right",
NULL, NULL, pAP, m_pDocument, true);
if(szValue)
{
master += " margin-right=\"";
master += szValue;
master += "\"";
}
UT_Dimension docUnit = m_pDocument->m_docPageSize.getDims();
UT_UTF8String buf;
// page-width, page-height
UT_UTF8String_sprintf(buf, " page-width=\"%f%s\"", m_pDocument->m_docPageSize.Width(docUnit), UT_dimensionName(docUnit));
master += buf;
buf.clear();
UT_UTF8String_sprintf(buf, " page-height=\"%f%s\"", m_pDocument->m_docPageSize.Height(docUnit), UT_dimensionName(docUnit));
master += buf;
}
master += " master-name=\"first\"";
_tagOpen(TT_SIMPLE_PAGE_MASTER, master);
m_pie->write("\t");
_tagOpenClose("region-body");
_tagClose(TT_SIMPLE_PAGE_MASTER, "simple-page-master");
_tagClose(TT_LAYOUT_MASTER_SET, "layout-master-set");
m_pie->write("\n");
m_bFirstWrite = false;
}
示例5: 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;
}
示例6: _drawTextBox
/**
* @param ppAtts The attributes of a <draw:text-box> element.
* @param rAction Any action to be taken, regarding state change.
*/
void ODi_Frame_ListenerState::_drawTextBox (const gchar** ppAtts,
ODi_ListenerStateAction& rAction) {
const gchar* attribs[3];
const gchar* pStyleName = NULL;
const ODi_Style_Style* pGraphicStyle = NULL;
UT_UTF8String props;
UT_UTF8String sThickness;
props = "frame-type:textbox";
if (!_getFrameProperties(props, ppAtts)) {
// Abort mission!
// <draw:frame> - 0
// <draw:text-box> - -1
//
// We want to ignore the whole frame.
rAction.ignoreElement(0);
return;
}
if (!props.empty()) {
props += "; ";
}
if (m_rElementStack.getStartTag(0)) {
pStyleName = m_rElementStack.getStartTag(0)->getAttributeValue("draw:style-name");
}
if (pStyleName) {
pGraphicStyle = m_pStyles->getGraphicStyle(pStyleName, m_bOnContentStream);
}
if (pGraphicStyle) {
// For now, we'll assume HAVE_BORDER_UNSPECIFIED == HAVE_BORDER_YES
if (pGraphicStyle->hasBottomBorder() != ODi_Style_Style::HAVE_BORDER_NO) {
props += "bot-style:1";
if(pGraphicStyle->getBorderBottom_color() && !pGraphicStyle->getBorderBottom_color()->empty()) {
props += "; bot-color:";
props += *(pGraphicStyle->getBorderBottom_color());
}
} else {
props += "bot-style:0";
}
if (pGraphicStyle->hasLeftBorder() != ODi_Style_Style::HAVE_BORDER_NO) {
props += "; left-style:1";
if(pGraphicStyle->getBorderLeft_color() && !pGraphicStyle->getBorderLeft_color()->empty()) {
props += "; left-color:";
props += *(pGraphicStyle->getBorderLeft_color());
}
} else {
props += "; left-style:0";
}
if (pGraphicStyle->hasRightBorder() != ODi_Style_Style::HAVE_BORDER_NO) {
props += "; right-style:1";
if(pGraphicStyle->getBorderRight_color() && !pGraphicStyle->getBorderRight_color()->empty()) {
props += "; right-color:";
props += *(pGraphicStyle->getBorderRight_color());
}
} else {
props += "; right-style:0";
}
if (pGraphicStyle->hasTopBorder() != ODi_Style_Style::HAVE_BORDER_NO) {
props += "; top-style:1";
if(pGraphicStyle->getBorderTop_color() && !pGraphicStyle->getBorderTop_color()->empty()) {
props += "; top-color:";
props += *(pGraphicStyle->getBorderTop_color());
}
} else {
props += "; top-style:0";
}
if(pGraphicStyle->getBorderBottom_thickness() && !pGraphicStyle->getBorderBottom_thickness()->empty()) {
sThickness.clear();
bool bRet = _convertBorderThickness(pGraphicStyle->getBorderBottom_thickness()->utf8_str(), sThickness);
if(bRet) {
props += "; bot-thickness:";
props += sThickness.utf8_str();
}
}
if(pGraphicStyle->getBorderLeft_thickness() && !pGraphicStyle->getBorderLeft_thickness()->empty()) {
sThickness.clear();
bool bRet = _convertBorderThickness(pGraphicStyle->getBorderLeft_thickness()->utf8_str(), sThickness);
if(bRet) {
props += "; left-thickness:";
props += sThickness.utf8_str();
}
}
//.........这里部分代码省略.........
示例7: _openODTextbox
//.........这里部分代码省略.........
output += "<draw:frame";
UT_UTF8String_sprintf(str, "Frame%u", m_rAuxiliaryData.m_frameCount+1);
ODe_writeAttribute(output, "draw:name", str);
m_rAuxiliaryData.m_frameCount++;
ODe_writeAttribute(output, "draw:style-name", pStyle->getName());
UT_UTF8String_sprintf(str, "%u", m_zIndex);
ODe_writeAttribute(output, "draw:z-index", str);
ok = rAP.getProperty("position-to", pValue);
if (pValue && !strcmp(pValue, "block-above-text")) {
ODe_writeAttribute(output, "text:anchor-type", "paragraph");
ok = rAP.getProperty("xpos", pValue);
UT_ASSERT(ok && pValue != NULL);
ODe_writeAttribute(output, "svg:x", pValue);
ok = rAP.getProperty("ypos", pValue);
UT_ASSERT(ok && pValue != NULL);
ODe_writeAttribute(output, "svg:y", pValue);
} else {
// Everything else (column and page) will be treated as page
// anchored.
ODe_writeAttribute(output, "text:anchor-type", "page");
if(pValue && !strcmp(pValue, "column-above-text"))
{
//
// Get the most recent page style so we can do the arithmetic
// Won't work for x in multi-columned docs
//
UT_uint32 numPStyles = m_rAutomatiStyles.getSectionStylesCount();
UT_UTF8String stylePName;
UT_UTF8String_sprintf(stylePName, "PLayout%d", numPStyles + 1);
ODe_Style_PageLayout * pPageL = m_rAutomatiStyles.getPageLayout(stylePName.utf8_str());
ok = rAP.getProperty("frame-col-xpos", pValue);
UT_ASSERT(ok && pValue != NULL);
double xCol = UT_convertToInches(pValue);
const gchar* pSVal= pPageL->getPageMarginLeft();
double xPageL = UT_convertToInches(pSVal);
double xTot = xPageL + xCol;
pValue = UT_convertInchesToDimensionString(DIM_IN,xTot,"4");
ODe_writeAttribute(output, "svg:x", pValue);
ok = rAP.getProperty("frame-col-ypos", pValue);
UT_ASSERT(ok && pValue != NULL);
double yCol = UT_convertToInches(pValue);
pSVal= pPageL->getPageMarginTop();
double yPageL = UT_convertToInches(pSVal);
double yTot = yPageL + yCol;
pValue = UT_convertInchesToDimensionString(DIM_IN,yTot,"4");
ODe_writeAttribute(output, "svg:y", pValue);
}
else
{
ok = rAP.getProperty("frame-page-xpos", pValue);
UT_ASSERT(ok && pValue != NULL);
ODe_writeAttribute(output, "svg:x", pValue);
ok = rAP.getProperty("frame-page-ypos", pValue);
UT_ASSERT(ok && pValue != NULL);
ODe_writeAttribute(output, "svg:y", pValue);
}
}
ok = rAP.getProperty("frame-width", pValue);
if (ok && pValue != NULL) {
ODe_writeAttribute(output, "svg:width", pValue);
}
output += ">\n";
ODe_writeUTF8String(m_pTextOutput, output);
m_spacesOffset++;
////
// Write <draw:text-box>
output.clear();
_printSpacesOffset(output);
output += "<draw:text-box";
ok = rAP.getProperty("frame-height", pValue);
if (ok && pValue != NULL) {
ODe_writeAttribute(output, "fo:min-height", pValue);
}
output += ">\n";
ODe_writeUTF8String(m_pTextOutput, output);
m_spacesOffset++;
}
示例8: UT_UTF8String_removeProperty
/*!
* Assuming a string of standard abiword properties eg. "fred:nerk; table-width:1.0in; table-height:10.in"
* Remove the property sProp and it's value from the string of properties.
*/
void UT_UTF8String_removeProperty(UT_UTF8String & sPropertyString, const UT_UTF8String & sProp)
{
//
// Warning, warning!!! lots of brutal const casts and assignments into
// strings to handle utf8 encoding.
//
UT_UTF8String sWork ( sProp );
sWork += ":";
const char * szWork = sWork.utf8_str();
const char * szProps = sPropertyString.utf8_str();
const char * szLoc = strstr(szProps,szWork);
if(szLoc == NULL)
{
//
// Not here, do nothing
return ;
}
//
// Found it, Get left part.
//
UT_sint32 locLeft = static_cast<UT_sint32>(reinterpret_cast<size_t>(szLoc) - reinterpret_cast<size_t>(szProps));
UT_UTF8String sLeft;
if(locLeft == 0)
{
sLeft.clear();
}
else
{
UT_UTF8String sTmp = sPropertyString;
char * szTmp = const_cast<char *>(sTmp.utf8_str());
szTmp[locLeft] = 0;
sLeft = szTmp;
}
char * szLeft = const_cast<char *>(sLeft.utf8_str());
locLeft--;
if(locLeft > 0)
{
//
// If this element is the last item in the properties there is no "; ".
//
// Remove trailing ';' and ' '
//
while(locLeft >= 0 && (szLeft[locLeft] == ';' || szLeft[locLeft] == ' '))
{
locLeft--;
}
}
UT_UTF8String sNew;
if(locLeft > 0)
{
szLeft[locLeft+1] = 0;
sNew = szLeft;
}
else
{
sNew.clear();
}
//
// Look for ";" to get right part
//
const char * szDelim = strchr(szLoc,';');
if(szDelim == NULL)
{
//
// No properties after this, just assign and return
//
sPropertyString = sNew;
}
else
{
//
// Just slice off the properties and tack them onto the pre-existing sNew
//
while(*szDelim == ';' || *szDelim == ' ')
{
szDelim++;
}
UT_UTF8String sRight = szDelim;
if(sNew.size() > 0)
{
sNew += "; ";
}
sNew += sRight;
sPropertyString = sNew;
}
}
示例9: calculateValue
bool fp_FieldTableSumCols::calculateValue(void)
{
FV_View * pView = _getView();
pf_Frag_Strux* tableSDH= NULL;
UT_sint32 numRows =0;
UT_sint32 numCols = 0;
bUseCurrency = false;
cCurrency = '$';
pf_Frag_Strux* sdh = getBlock()->getStruxDocHandle();
PD_Document * pDoc = getBlock()->getDocument();
if(pDoc->isPieceTableChanging())
{
return false;
}
if(getLine() == NULL)
{
return false;
}
fp_Container * pCol = getLine()->getColumn();
if(pCol == NULL)
{
return false;
}
fp_ShadowContainer * pShad =NULL;
fl_HdrFtrShadow * pShadL = NULL;
if(pCol->getContainerType() == FP_CONTAINER_COLUMN_SHADOW)
{
pShad = static_cast<fp_ShadowContainer *>(pCol);
pShadL = pShad->getShadow();
}
PT_DocPosition pos = pDoc->getStruxPosition(sdh)+1;
pDoc->getStruxOfTypeFromPosition(pos,PTX_SectionTable,&tableSDH);
pDoc-> getRowsColsFromTableSDH(tableSDH, pView->isShowRevisions(), pView->getRevisionLevel(), &numRows, &numCols);
UT_UTF8String sValF;
if(!pView->isInTable(pos))
{
sValF = "???";
return _setValue(sValF.ucs4_str().ucs4_str());
}
fl_CellLayout * pCell = NULL;
UT_sint32 myLeft,myRight,myTop,myBot;
pView->getCellParams(pos,&myLeft,&myRight,&myTop,&myBot);
UT_sint32 col = 0;
UT_sint32 row = myTop;
UT_sint32 lastCol = -1;
double dSum = 0.0;
for(col = 0; col < numCols; col++)
{
pf_Frag_Strux* sdhCell = pDoc->getCellSDHFromRowCol(tableSDH,true,99999,row,col);
UT_sint32 i = getBlock()->getDocLayout()->getLID();
fl_ContainerLayout* fmtCell = pDoc->getNthFmtHandle(sdhCell,i);
pCell = static_cast<fl_CellLayout *>(fmtCell);
if(pCell->getLeftAttach() == lastCol)
{
continue;
}
if((pCell->getTopAttach() == myTop) && (pCell->getLeftAttach() == myLeft))
{
continue;
}
UT_GrowBuf grText;
pCell->appendTextToBuf(grText);
if(grText.getLength() == 0)
{
fl_ContainerLayout * pC = pCell->getFirstLayout();
while(pC)
{
if(pC->getContainerType() == FL_CONTAINER_BLOCK)
{
fl_BlockLayout * pBL = static_cast<fl_BlockLayout *>(pC);
if(pShadL)
{
pBL = static_cast<fl_BlockLayout *>(pShadL->findMatchingContainer(pBL));
}
if(pBL == NULL)
{
continue;
}
fp_Run * pRun = pBL->getFirstRun();
while(pRun)
{
if(pRun->getType() == FPRUN_FIELD)
{
fp_FieldRun * pFRun = static_cast<fp_FieldRun *>(pRun);
const UT_UCS4Char * szVal = pFRun->getValue();
sValF.clear();
sValF.appendUCS4(szVal);
dSum += dGetVal(sValF.utf8_str());
pRun = NULL;
pC = NULL;
break;
}
pRun = pRun->getNextRun();
}
}
if(pC)
{
pC = pC->getNext();
//.........这里部分代码省略.........
示例10: _outputData
void ODe_AbiDocListener::_outputData(const UT_UCSChar* pData, UT_uint32 length) {
UT_UTF8String sBuf;
const UT_UCSChar* p;
UT_uint32 nSpaces = 0;
UT_ASSERT(sizeof(UT_Byte) == sizeof(char));
sBuf.reserve(length);
for (p=pData; (p<pData+length); /**/)
{
switch (*p)
{
case '<':
if(nSpaces > 1)
_appendSpaces(&sBuf, nSpaces);
nSpaces = 0;
sBuf += "<";
p++;
break;
case '>':
if(nSpaces > 1)
_appendSpaces(&sBuf, nSpaces);
nSpaces = 0;
sBuf += ">";
p++;
break;
case '&':
if(nSpaces > 1)
_appendSpaces(&sBuf, nSpaces);
nSpaces = 0;
sBuf += "&";
p++;
break;
case ' ':
nSpaces++;
if(nSpaces == 1)
sBuf.appendUCS4 (p, 1);
p++;
break;
case UCS_LF: // LF -- representing a Forced-Line-Break
if(nSpaces > 1)
_appendSpaces(&sBuf, nSpaces);
nSpaces = 0;
m_pCurrentImpl->insertText(sBuf);
m_pCurrentImpl->insertLineBreak();
sBuf.clear();
p++;
break;
case UCS_VTAB: // VTAB -- representing a Forced-Column-Break
if(nSpaces > 1)
_appendSpaces(&sBuf, nSpaces);
nSpaces = 0;
m_pCurrentImpl->insertText(sBuf);
m_pCurrentImpl->insertColumnBreak();
sBuf.clear();
p++;
break;
case UCS_TAB:
if(nSpaces > 1)
_appendSpaces(&sBuf, nSpaces);
nSpaces = 0;
m_pCurrentImpl->insertText(sBuf);
m_pCurrentImpl->insertTabChar();
sBuf.clear();
p++;
break;
case UCS_FF: // FF -- representing a Forced-Page-Break
if(nSpaces > 1)
_appendSpaces(&sBuf, nSpaces);
nSpaces = 0;
m_pCurrentImpl->insertText(sBuf);
m_pCurrentImpl->insertPageBreak();
sBuf.clear();
p++;
break;
default:
if (*p < 0x20) // Silently eat these characters.
{
if(nSpaces > 1)
_appendSpaces(&sBuf, nSpaces);
nSpaces = 0;
p++;
}
//.........这里部分代码省略.........
示例11: _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();
}