void WP5ContentListener::insertCharacter(unsigned character) { unsigned tmpCharacter = _mapNonUnicodeCharacter(character); if (!m_ps->m_isSpanOpened) _openSpan(); appendUCS4(m_parseState->m_textBuffer, tmpCharacter); }
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; } }
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; } }
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; } }
void WP5ContentListener::insertTab(unsigned char tabType, double tabPosition) { bool tmpHasTabPositionInformation = true; if (tabPosition >= (double)((double)0xFFFE/(double)WPX_NUM_WPUS_PER_INCH) || tabPosition == 0.0) tmpHasTabPositionInformation = false; if (!isUndoOn()) { switch ((tabType & 0xE8) >> 3) { case WP5_TAB_GROUP_CENTER_TAB: case WP5_TAB_GROUP_RIGHT_TAB: case WP5_TAB_GROUP_DECIMAL_TAB: if (!m_ps->m_isParagraphOpened && !m_ps->m_isListElementOpened) { if (m_ps->m_currentListLevel == 0) _openParagraph(); else _openListElement(); } break; default: break; } // Following tabs are converted as formating if the paragraph is not opened if (!m_ps->m_isParagraphOpened && !m_ps->m_isListElementOpened) { switch ((tabType & 0xE8) >> 3) { case WP5_TAB_GROUP_CENTER_ON_MARGINS: case WP5_TAB_GROUP_CENTER_ON_CURRENT_POSITION: m_ps->m_tempParagraphJustification = WPX_PARAGRAPH_JUSTIFICATION_CENTER; break; case WP5_TAB_GROUP_FLUSH_RIGHT: m_ps->m_tempParagraphJustification = WPX_PARAGRAPH_JUSTIFICATION_RIGHT; break; case WP5_TAB_GROUP_LEFT_TAB: // converted as first line indent if (!tmpHasTabPositionInformation) m_ps->m_textIndentByTabs += 0.5f; else m_ps->m_textIndentByTabs = tabPosition - m_ps->m_paragraphMarginLeft - m_ps->m_pageMarginLeft - m_ps->m_sectionMarginLeft - m_ps->m_textIndentByParagraphIndentChange; break; case WP5_TAB_GROUP_BACK_TAB: // converted as hanging indent if (!tmpHasTabPositionInformation) m_ps->m_textIndentByTabs -= 0.5f; else m_ps->m_textIndentByTabs = tabPosition - m_ps->m_paragraphMarginLeft - m_ps->m_pageMarginLeft - m_ps->m_sectionMarginLeft - m_ps->m_textIndentByParagraphIndentChange; break; default: break; } m_ps->m_paragraphTextIndent = m_ps->m_textIndentByParagraphIndentChange + m_ps->m_textIndentByTabs; m_ps->m_paragraphMarginLeft = m_ps->m_leftMarginByPageMarginChange + m_ps->m_leftMarginByParagraphMarginChange + m_ps->m_leftMarginByTabs; m_ps->m_paragraphMarginRight = m_ps->m_rightMarginByPageMarginChange + m_ps->m_rightMarginByParagraphMarginChange + m_ps->m_rightMarginByTabs; m_ps->m_listReferencePosition = m_ps->m_paragraphMarginLeft + m_ps->m_paragraphTextIndent; } else { if (!m_ps->m_isSpanOpened) _openSpan(); else _flushText(); switch ((tabType & 0xF8) >> 3) { case WP5_TAB_GROUP_LEFT_TAB: case WP5_TAB_GROUP_CENTER_ON_MARGINS: case WP5_TAB_GROUP_CENTER_ON_CURRENT_POSITION: case WP5_TAB_GROUP_CENTER_TAB: case WP5_TAB_GROUP_FLUSH_RIGHT: case WP5_TAB_GROUP_RIGHT_TAB: case WP5_TAB_GROUP_DECIMAL_TAB: m_documentInterface->insertTab(); break; default: break; } } }
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; }
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(); }