bool s_RTF_ListenerGetProps::populate(PL_StruxFmtHandle /*sfh*/, const PX_ChangeRecord * pcr) { switch (pcr->getType()) { case PX_ChangeRecord::PXT_InsertSpan: { const PX_ChangeRecord_Span * pcrs = static_cast<const PX_ChangeRecord_Span *> (pcr); PT_AttrPropIndex api = pcr->getIndexAP(); _openSpan(api); PT_BufIndex bi = pcrs->getBufIndex(); _outputData(m_pDocument->getPointer(bi),pcrs->getLength()); return true; } case PX_ChangeRecord::PXT_InsertObject: { #if 0 const PX_ChangeRecord_Object * pcro = static_cast<const PX_ChangeRecord_Object *> (pcr); PT_AttrPropIndex api = pcr->getIndexAP(); switch (pcro->getObjectType()) { case PTO_Image: _closeSpan(); _openTag("image",api); return true; case PTO_Field: _closeSpan(); _openTag("field",api); return true; default: UT_ASSERT_NOT_REACHED(); return false; } #endif } case PX_ChangeRecord::PXT_InsertFmtMark: return true; default: UT_ASSERT_NOT_REACHED(); return false; } }
void s_XSL_FO_Listener::_closeBlock(void) { _closeSpan(); _closeLink(); if(!m_iBlockDepth && !m_iListBlockDepth) return; if(m_iBlockDepth) { if(_tagTop() == TT_BLOCK) { _tagClose(TT_BLOCK, "block"); m_iBlockDepth--; } } else if(m_iListBlockDepth) { if(!m_bWroteListField && (_tagTop() == TT_LISTBLOCK)) // in a list block without a list label - add some corrective markup { _openListItem(); } _popListToDepth(m_iListBlockDepth - 1); } }
void ODe_AbiDocListener::_openSpan(PT_AttrPropIndex api) { const PP_AttrProp* pAP; bool ok; if (m_bInSpan) { if (m_apiLastSpan == api) return; _closeSpan(); } if (!api) // don't write tag for empty A/P return; m_bInSpan = true; m_apiLastSpan = api; ok = m_pDocument->getAttrProp (api, &pAP); if (!ok) { pAP = NULL; } m_pCurrentImpl->openSpan(pAP); return; }
void ODe_AbiDocListener::_closeHyperlink() { if (!m_bInHyperlink) return; _closeSpan(); m_bInHyperlink = false; m_pCurrentImpl->closeHyperlink(); }
void ODe_AbiDocListener::_closeField(void) { if (!m_pCurrentField || !m_currentFieldType.length()) return; _closeSpan(); m_pCurrentImpl->closeField(m_currentFieldType); m_pCurrentField = NULL; m_currentFieldType.clear(); }
void ODe_AbiDocListener::_closeBookmark(UT_UTF8String &sBookmarkName) { if (!m_bInBookmark || sBookmarkName.empty()) return; _closeSpan(); m_pCurrentImpl->closeBookmark(sBookmarkName); m_bInBookmark = false; m_bookmarkName.clear(); }
void ODe_AbiDocListener::finished() { _closeSpan(); _closeField(); _closeBookmark(m_bookmarkName); _closeHyperlink(); _closeBlock(); _closeCell(); _closeTable(); _closeSection(); }
void ODe_AbiDocListener::_closeBookmark(PT_AttrPropIndex api) { if (!m_bInBookmark) return; _closeSpan(); const PP_AttrProp* pAP = NULL; bool ok = false; ok = m_pDocument->getAttrProp (api, &pAP); if (ok && pAP) { m_pCurrentImpl->closeBookmark(pAP); } m_bInBookmark = false; m_bookmarkName.clear(); }
bool WordPerfect_Listener::populate(fl_ContainerLayout* /*sfh*/, const PX_ChangeRecord * pcr) { switch (pcr->getType()) { case PX_ChangeRecord::PXT_InsertSpan: { const PX_ChangeRecord_Span * pcrs = static_cast<const PX_ChangeRecord_Span *>(pcr); PT_BufIndex bi = pcrs->getBufIndex(); PT_AttrPropIndex api = pcr->getIndexAP(); if (api) { _openSpan(api); } _outputData(m_pDocument->getPointer(bi),pcrs->getLength()); if (api) { _closeSpan(); } return true; } case PX_ChangeRecord::PXT_InsertObject: { } case PX_ChangeRecord::PXT_InsertFmtMark: return true; default: UT_ASSERT(0); return false; } }
void s_RTF_ListenerGetProps::_openSpan(PT_AttrPropIndex apiSpan) { if (m_bInSpan) { if (m_apiLastSpan == apiSpan) return; _closeSpan(); } const PP_AttrProp * pSpanAP = NULL; const PP_AttrProp * pBlockAP = NULL; const PP_AttrProp * pSectionAP = NULL; m_pDocument->getAttrProp(m_apiThisSection,&pSectionAP); m_pDocument->getAttrProp(m_apiThisBlock,&pBlockAP); m_pDocument->getAttrProp(apiSpan,&pSpanAP); _compute_span_properties(pSpanAP,pBlockAP,pSectionAP); m_bInSpan = true; m_apiLastSpan = apiSpan; return; }
void s_XSL_FO_Listener::_openSpan(PT_AttrPropIndex api) { if (!m_iBlockDepth && !m_iListBlockDepth) return; _closeSpan(); if(_tagTop() == TT_LISTBLOCK) { _openListItem(); } const PP_AttrProp* pAP = 0; bool bHaveProp = m_pDocument->getAttrProp(api, &pAP); UT_UTF8String buf = "inline"; // query and output properties if (bHaveProp && pAP) { const gchar * szValue = NULL; if (pAP->getProperty("bgcolor", szValue) && szValue) { buf += " background-color=\""; if ((*szValue >= '0') && (*szValue <= '9')) buf += "#"; buf += static_cast<const char *>(szValue); buf += "\""; } if (pAP->getProperty("color", szValue) && szValue) { buf += " color=\""; if ((*szValue >= '0') && (*szValue <= '9')) buf += "#"; buf += static_cast<const char *>(szValue); buf += "\""; } if (pAP->getProperty("lang", szValue) && szValue) { buf += " language=\""; buf += static_cast<const char *>(szValue); buf += "\""; } if (pAP->getProperty("font-size", szValue) && szValue) { buf += " font-size=\""; buf += purgeSpaces(static_cast<const char *>(szValue)).utf8_str(); buf += "\""; } PROPERTY("font-family"); PROPERTY("font-weight"); PROPERTY("font-style"); PROPERTY("font-stretch"); PROPERTY("keep-together"); PROPERTY("keep-with-next"); PROPERTY("text-decoration"); PROPERTY("text-transform"); } _tagOpen(TT_INLINE, buf, false); m_bInSpan = true; }
bool s_RTF_ListenerGetProps::populateStrux(PL_StruxDocHandle /*sdh*/, const PX_ChangeRecord * pcr, PL_StruxFmtHandle * psfh) { UT_return_val_if_fail(pcr->getType() == PX_ChangeRecord::PXT_InsertStrux, false); const PX_ChangeRecord_Strux * pcrx = static_cast<const PX_ChangeRecord_Strux *> (pcr); *psfh = 0; // we don't need it. switch (pcrx->getStruxType()) { case PTX_Section: { _closeSpan(); _closeBlock(); _closeSection(); m_bInSection = true; m_apiThisSection = pcr->getIndexAP(); return true; } case PTX_SectionHdrFtr: { _closeSpan(); _closeBlock(); _closeSection(); m_bInSection = true; m_apiThisSection = pcr->getIndexAP(); return true; } case PTX_SectionTable: { _closeSpan(); _searchTableAPI(pcr->getIndexAP()); return true; } case PTX_SectionFootnote: { _closeSpan(); m_apiSavedBlock = m_apiThisBlock; return true; } case PTX_EndFootnote: { _closeSpan(); _closeBlock(); m_apiThisBlock = m_apiSavedBlock; return true; } case PTX_SectionAnnotation: { _closeSpan(); m_apiSavedBlock = m_apiThisBlock; return true; } case PTX_EndAnnotation: { _closeSpan(); _closeBlock(); m_apiThisBlock = m_apiSavedBlock; return true; } case PTX_SectionEndnote: { _closeSpan(); m_apiSavedBlock = m_apiThisBlock; return true; } case PTX_SectionTOC: { _closeSpan(); return true; } case PTX_EndTOC: { _closeSpan(); return true; } case PTX_SectionFrame: { _closeSpan(); return true; } case PTX_EndFrame: { _closeSpan(); return true; } case PTX_EndEndnote: { _closeSpan(); _closeBlock(); m_apiThisBlock = m_apiSavedBlock; return true; } case PTX_SectionCell: { _closeSpan(); _searchCellAPI(pcr->getIndexAP()); return true; } case PTX_EndTable: { _closeSpan(); return true; } case PTX_EndCell: { _closeSpan(); return true; } case PTX_Block: { _closeSpan(); _closeBlock(); m_bInBlock = true; m_bHasBlock = true; m_apiThisBlock = pcr->getIndexAP(); // Find colours of the Paragraph borders and shading const PP_AttrProp * pBlockAP = NULL; m_pDocument->getAttrProp(m_apiThisBlock,&pBlockAP); const gchar * szColor = PP_evalProperty("bot-color",pBlockAP,NULL,NULL,m_pDocument,true); UT_sint32 ndxColor = 0; if (szColor) { ndxColor = m_pie->_findColor(static_cast<const char*>(szColor)); if (ndxColor == -1) m_pie->_addColor(static_cast<const char*>(szColor)); } szColor = PP_evalProperty("left-color",pBlockAP,NULL,NULL,m_pDocument,true); if (szColor) { ndxColor = m_pie->_findColor(static_cast<const char*>(szColor)); if (ndxColor == -1) m_pie->_addColor(static_cast<const char*>(szColor)); } szColor = PP_evalProperty("right-color",pBlockAP,NULL,NULL,m_pDocument,true); if (szColor) { ndxColor = m_pie->_findColor(static_cast<const char*>(szColor)); if (ndxColor == -1) m_pie->_addColor(static_cast<const char*>(szColor)); } szColor = PP_evalProperty("top-color",pBlockAP,NULL,NULL,m_pDocument,true); if (szColor) { ndxColor = m_pie->_findColor(static_cast<const char*>(szColor)); if (ndxColor == -1) m_pie->_addColor(static_cast<const char*>(szColor)); } szColor = PP_evalProperty("shading-foreground-color",pBlockAP,NULL,NULL,m_pDocument,true); if (szColor) { ndxColor = m_pie->_findColor(static_cast<const char*>(szColor)); if (ndxColor == -1) m_pie->_addColor(static_cast<const char*>(szColor)); } szColor = PP_evalProperty("shading-background-color",pBlockAP,NULL,NULL,m_pDocument,true); if (szColor) { ndxColor = m_pie->_findColor(static_cast<const char*>(szColor)); if (ndxColor == -1) m_pie->_addColor(static_cast<const char*>(szColor)); } return true; } default: UT_ASSERT_NOT_REACHED(); return false; } }
s_RTF_ListenerGetProps::~s_RTF_ListenerGetProps() { _closeSpan(); _closeBlock(); _closeSection(); }
bool ODe_AbiDocListener::populateStrux(PL_StruxDocHandle /*sdh*/, const PX_ChangeRecord* pcr, PL_StruxFmtHandle* psfh) { UT_return_val_if_fail(pcr->getType() == PX_ChangeRecord::PXT_InsertStrux, false); bool returnVal = true; const PX_ChangeRecord_Strux * pcrx = static_cast<const PX_ChangeRecord_Strux *> (pcr); *psfh = 0; // we don't need it. PT_AttrPropIndex api = pcr->getIndexAP(); //const gchar* image_name = // _getObjectKey(api, static_cast<const gchar*>(PT_STRUX_IMAGE_DATAID)); switch (pcrx->getStruxType()) { case PTX_Section: case PTX_SectionHdrFtr: { _closeSpan(); _closeField(); _closeBookmark(m_bookmarkName); _closeHyperlink(); _closeBlock(); _closeSection(); _openSection(api); } break; case PTX_SectionTable: { _closeSpan(); _closeField(); _closeBookmark(m_bookmarkName); _closeHyperlink(); _closeBlock(); _openTable(api); } break; case PTX_SectionCell: { _closeSpan(); _closeField(); _closeBookmark(m_bookmarkName); _closeHyperlink(); _closeBlock(); _openCell(api); } break; case PTX_SectionFootnote: { _closeSpan(); _closeField(); _closeBookmark(m_bookmarkName); _closeHyperlink(); _openFootnote(api); } break; case PTX_SectionEndnote: { _closeSpan(); _closeField(); _closeBookmark(m_bookmarkName); _closeHyperlink(); _openEndnote(api); } break; case PTX_SectionAnnotation: { _closeSpan(); _closeField(); _closeBookmark(m_bookmarkName); _closeHyperlink(); _openAnnotation(api); } break; case PTX_SectionTOC: { _closeSpan(); _closeField(); _closeBookmark(m_bookmarkName); _closeHyperlink(); _closeBlock(); _openTOC(api); } break; case PTX_SectionMarginnote: { _closeSpan(); _closeField(); _closeBookmark(m_bookmarkName); _closeHyperlink(); _closeBlock(); //_openTag("margin","",true,pcr->getIndexAP(),pcr->getXID()); } break; case PTX_SectionFrame: { _closeSpan(); _closeField(); _closeBookmark(m_bookmarkName); _closeHyperlink(); _closeBlock(); _openFrame(api); } break; case PTX_EndTable: { _closeSpan(); _closeField(); _closeBookmark(m_bookmarkName); _closeHyperlink(); _closeBlock(); _closeTable(); } break; case PTX_EndCell: { _closeSpan(); _closeField(); _closeBookmark(m_bookmarkName); _closeHyperlink(); _closeBlock(); _closeCell(); } break; case PTX_EndFootnote: { _closeSpan(); _closeField(); _closeBookmark(m_bookmarkName); _closeHyperlink(); _closeBlock(); _closeFootnote(); } break; case PTX_EndEndnote: { _closeSpan(); _closeField(); _closeBookmark(m_bookmarkName); _closeHyperlink(); _closeBlock(); _closeEndnote(); } break; case PTX_EndAnnotation: { _closeSpan(); _closeField(); _closeBookmark(m_bookmarkName); _closeHyperlink(); _closeBlock(); _closeAnnotation(); } break; case PTX_EndTOC: { _closeSpan(); _closeField(); _closeBookmark(m_bookmarkName); _closeHyperlink(); _closeBlock(); _closeTOC(); } break; case PTX_EndMarginnote: { _closeSpan(); _closeField(); _closeBookmark(m_bookmarkName); _closeHyperlink(); _closeBlock(); } break; case PTX_EndFrame: { _closeSpan(); _closeField(); _closeBookmark(m_bookmarkName); _closeHyperlink(); _closeBlock(); _closeFrame(); } break; case PTX_Block: { _closeSpan(); _closeField(); _closeBookmark(m_bookmarkName); _closeHyperlink(); _closeBlock(); _openBlock(api); } break; default: UT_ASSERT_HARMLESS(UT_TODO); returnVal = true; } return returnVal; }
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(); }
bool s_XSL_FO_Listener::populate(PL_StruxFmtHandle /*sfh*/, const PX_ChangeRecord * pcr) { switch (pcr->getType()) { case PX_ChangeRecord::PXT_InsertSpan: { const PX_ChangeRecord_Span * pcrs = static_cast<const PX_ChangeRecord_Span *> (pcr); PT_AttrPropIndex api = pcr->getIndexAP(); if (api) { _openSpan(api); } PT_BufIndex bi = pcrs->getBufIndex(); _outputData(m_pDocument->getPointer(bi),pcrs->getLength()); if (api) { _closeSpan(); } return true; } case PX_ChangeRecord::PXT_InsertObject: { const PX_ChangeRecord_Object * pcro = static_cast<const PX_ChangeRecord_Object *> (pcr); PT_AttrPropIndex api = pcr->getIndexAP(); switch (pcro->getObjectType()) { case PTO_Image: { _handleImage(api); return true; } case PTO_Field: { _handleField(pcro, api); return true; } case PTO_Hyperlink: { _handleHyperlink(api); return true; } case PTO_Bookmark: { _handleBookmark(api); return true; } case PTO_Math: { _handleMath(api); return true; } case PTO_Embed: { _handleEmbedded(api); return true; } default: { UT_ASSERT(UT_TODO); return true; } } } case PX_ChangeRecord::PXT_InsertFmtMark: return true; default: UT_ASSERT(0); return false; } }
bool ODe_AbiDocListener::populate(PL_StruxFmtHandle /*sfh*/, const PX_ChangeRecord * pcr) { switch (pcr->getType()) { case PX_ChangeRecord::PXT_InsertSpan: { const PX_ChangeRecord_Span * pcrs = static_cast<const PX_ChangeRecord_Span *> (pcr); if (pcrs->getField()!=m_pCurrentField) { _closeField(); } PT_AttrPropIndex api = pcr->getIndexAP(); _openSpan(api); PT_BufIndex bi = pcrs->getBufIndex(); UT_UTF8String utf8String (m_pDocument->getPointer(bi), pcrs->getLength()); _outputData(m_pDocument->getPointer(bi), pcrs->getLength()); } break; case PX_ChangeRecord::PXT_InsertObject: { const PX_ChangeRecord_Object * pcro = static_cast<const PX_ChangeRecord_Object *> (pcr); PT_AttrPropIndex api = pcr->getIndexAP(); switch (pcro->getObjectType()) { case PTO_Image: { _closeSpan(); _closeField(); _insertInlinedImage(api); return true; } case PTO_Field: { _closeSpan(); _closeField(); _openField(pcro, api); return true; } case PTO_Math: { _closeSpan(); _closeField(); _insertMath(api); return true; } case PTO_Embed: { //TODO: we may want to save the actual chart xml one day, // but saving the image will do for now _closeSpan(); _closeField(); _insertEmbeddedImage(api); return true; } case PTO_Bookmark: { _closeSpan(); _closeField(); const PP_AttrProp* pAP = NULL; m_pDocument->getAttrProp(api,&pAP); const gchar* pValue = NULL; if(pAP && pAP->getAttribute("type",pValue) && pValue && (strcmp(pValue, "start") == 0)) { _openBookmark(api); } else { _closeBookmark(api); } return true; } case PTO_Hyperlink: { _closeSpan(); _closeField(); const PP_AttrProp* pAP = NULL; m_pDocument->getAttrProp(api,&pAP); const gchar* pValue = NULL; if(pAP && pAP->getAttribute("xlink:href",pValue) && pValue) { _openHyperlink(api); } else { _closeHyperlink(); } return true; } case PTO_Annotation: { _closeSpan(); _closeField(); return true; } default: UT_ASSERT_HARMLESS(UT_TODO); return true; } } case PX_ChangeRecord::PXT_InsertFmtMark: // fmt marks are temporary placeholders for props and // attributes and should not be saved return true; default: UT_ASSERT_HARMLESS(UT_TODO); return true; } return true; }