/*! * 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; }
/*! 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); }
/*! 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; }
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; }
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; }
/** * @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(); } } if(pGraphicStyle->getBorderRight_thickness() && !pGraphicStyle->getBorderRight_thickness()->empty()) { sThickness.clear(); bool bRet = _convertBorderThickness(pGraphicStyle->getBorderRight_thickness()->utf8_str(), sThickness); if(bRet) { props += "; right-thickness:"; props += sThickness.utf8_str(); } } if(pGraphicStyle->getBorderTop_thickness() && !pGraphicStyle->getBorderTop_thickness()->empty()) { sThickness.clear(); bool bRet = _convertBorderThickness(pGraphicStyle->getBorderTop_thickness()->utf8_str(), sThickness); if(bRet) { props += "; top-thickness:"; props += sThickness.utf8_str(); } } if(pGraphicStyle->getHorizPos(true) && !pGraphicStyle->getHorizPos(true)->empty()) { props += "; frame-horiz-align:"; props += pGraphicStyle->getHorizPos(true)->utf8_str(); } } else { //just hard-code some defaults props += "bot-style:1; left-style:1; right-style:1; top-style:1"; } attribs[0] = "props"; attribs[1] = props.utf8_str(); attribs[2] = 0; if(!m_pAbiDocument->appendStrux(PTX_SectionFrame, attribs)) { UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); } else { m_iFrameDepth++; } // We are going to receive text content. rAction.pushState("TextContent"); }
void ODe_Frame_Listener::_openODTextbox(const PP_AttrProp& rAP, ODe_ListenerAction& /*rAction*/) { UT_UTF8String output; UT_UTF8String str; bool ok; const gchar* pValue = NULL; ODe_Style_Style* pStyle; pStyle = new ODe_Style_Style(); pStyle->setFamily("graphic"); pStyle->fetchAttributesFromAbiFrame(rAP); // Abi frames have no padding // (no margin between frame borders and its content) pStyle->setPadding("0cm"); // Abi frames are aways positioned from its top-left corner. pStyle->setHorizontalPos("from-left"); pStyle->setVerticalPos("from-top"); // For OOo to recognize a textbox as being a textbox, it will // need to have the parent style name "Frame". I can't find it // in the ODF spec, but without it OOo considers the textbox to // be a generic drawing object (check the Navigator window in OOo). pStyle->setParentStyleName("Frame"); // Make sure an (empty) Frame style exists, for completeness sake // (OOo doesn't seem to care if it exists or not). if (!m_rStyles.getGraphicsStyle("Frame")) { ODe_Style_Style* pFrameStyle = new ODe_Style_Style(); pFrameStyle->setStyleName("Frame"); pFrameStyle->setFamily("graphic"); m_rStyles.addGraphicsStyle(pFrameStyle); } m_rAutomatiStyles.storeGraphicStyle(pStyle); //// // Write <draw:frame> _printSpacesOffset(output); 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++; }
bool pt_PieceTable::_realInsertObject(PT_DocPosition dpos, PTObjectType pto, const gchar ** attributes, const gchar ** properties ) { // dpos == 1 seems to be generally bad. - plam // I'm curious about how often it happens. Please mail me if it does! UT_ASSERT_HARMLESS(dpos > 1); // TODO currently we force the caller to pass in the attr/prop. // TODO this is probably a good thing for Images, but might be // TODO bogus for things like Fields. UT_return_val_if_fail (m_pts==PTS_Editing,false); // store the attributes and properties and get an index to them. UT_UTF8String sProps; UT_sint32 i = 0; sProps.clear(); if(properties != NULL) { for(i=0;(properties[i] != NULL);i+=2) { UT_DEBUGMSG(("Object: szProps = |%s| \n",properties[i])); sProps +=properties[i]; sProps += ":"; sProps += properties[i+1]; if(properties[i+2] != NULL) { sProps += ";"; } } } UT_GenericVector<const gchar*> Atts; Atts.clear(); if(attributes) { for(i=0; attributes[i] != 0; i++) { Atts.addItem(attributes[i]); } } if(sProps.size() > 0) { Atts.addItem("props"); Atts.addItem(sProps.utf8_str()); } PT_AttrPropIndex indexAP; if (!m_varset.storeAP(&Atts,&indexAP)) return false; // get the fragment at the given document position. pf_Frag * pf = NULL; PT_BlockOffset fragOffset = 0; bool bFound = getFragFromPosition(dpos,&pf,&fragOffset); UT_return_val_if_fail (bFound,false); pf_Frag_Strux * pfs = NULL; bool bFoundStrux = _getStruxFromFrag(pf,&pfs); UT_return_val_if_fail (bFoundStrux,false); if(isEndFootnote((pf_Frag *) pfs)) { bFoundStrux = _getStruxFromFragSkip((pf_Frag *)pfs,&pfs); } UT_return_val_if_fail (bFoundStrux,false); PT_BlockOffset blockOffset = _computeBlockOffset(pfs,pf) + fragOffset; pf_Frag_Object * pfo = NULL; if (!_insertObject(pf,fragOffset,pto,indexAP,pfo)) return false; // create a change record, add it to the history, and notify // anyone listening. PX_ChangeRecord_Object * pcr = new PX_ChangeRecord_Object(PX_ChangeRecord::PXT_InsertObject, dpos,indexAP,pfo->getXID(),pto,blockOffset, pfo->getField(),reinterpret_cast<PL_ObjectHandle>(pfo)); UT_return_val_if_fail (pcr,false); m_history.addChangeRecord(pcr); m_pDocument->notifyListeners(pfs,pcr); return true; }
/*! * 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; } }
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(); } } } else { sValF.clear(); sValF.appendUCS4(reinterpret_cast<const UT_UCS4Char *>(grText.getPointer(0)),grText.getLength()); dSum += dGetVal(sValF.utf8_str()); } lastCol = col; } sFormatDouble(sValF,dSum); return _setValue(sValF.ucs4_str().ucs4_str()); }
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++; } else { if(nSpaces > 1) _appendSpaces(&sBuf, nSpaces); nSpaces = 0; sBuf.appendUCS4 (p, 1); p++; } } } if (!sBuf.empty()) { if(nSpaces > 1) _appendSpaces(&sBuf, nSpaces); nSpaces = 0; m_pCurrentImpl->insertText(sBuf); } }
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(); }