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()); } } } }
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; }