void AP_Dialog_EpubExportOptions::saveDefaults() { UT_ASSERT(m_app); if (m_app == NULL) return; XAP_Prefs * pPrefs = m_app->getPrefs(); if (pPrefs == NULL) return; XAP_PrefsScheme * pPScheme = pPrefs->getCurrentScheme(); if (pPScheme == NULL) return; UT_UTF8String pref; if (m_exp_opt->bEpub2) { if (pref.byteLength()) pref += ","; pref += "EPUB2"; } if (m_exp_opt->bSplitDocument) { if (pref.byteLength()) pref += ","; pref += "split-document"; } if (m_exp_opt->bRenderMathMLToPNG) { if (pref.byteLength()) pref += ","; pref += "mathml-to-png"; } const gchar * szValue = (const gchar *) pref.utf8_str(); pPScheme->setValue(EPUB_EXPORT_SCHEME_NAME, szValue); }
virtual bool notify(AV_View * pAView, const AV_ChangeMask mask, void * pPrivateData) { if(mask != AV_CHG_BLOCKCHECK) { return true; } // printf("I've been notified!! View = %x hint mask %d \n",pAView,mask); m_pView = static_cast<FV_View *>(pAView); m_pBlock = reinterpret_cast<fl_BlockLayout *>(pPrivateData); m_pDoc = m_pView->getDocument(); UT_UTF8String sText; m_pBlock->appendUTF8String(sText); if (sText.byteLength() == 0) { return true; } m_GrammarCheck.CheckBlock(m_pBlock); return true; }
void s_XSL_FO_Listener::_outputData(const UT_UCSChar * data, UT_uint32 length) { UT_UTF8String sBuf; const UT_UCSChar * pData; UT_ASSERT(sizeof(UT_Byte) == sizeof(char)); sBuf.reserve(length); for (pData=data; (pData<data+length); /**/) { switch (*pData) { case '<': { sBuf += "<"; pData++; break; } case '>': { sBuf += ">"; pData++; break; } case '&': { sBuf += "&"; pData++; break; } case UCS_LF: // LF -- representing a Forced-Line-Break { UT_ASSERT(UT_TODO); pData++; break; } case UCS_VTAB: // VTAB -- representing a Forced-Column-Break { UT_ASSERT(UT_TODO); pData++; break; } case UCS_FF: // FF -- representing a Forced-Page-Break { UT_ASSERT(UT_TODO); pData++; break; } default: { if(*pData < 0x20) //invalid xml chars { pData++; } else { sBuf.appendUCS4(pData, 1); pData++; } break; } } } m_pie->write(sBuf.utf8_str(), sBuf.byteLength()); }
/* replaces <str1> with <str2> in the current string */ void UT_UTF8Stringbuf::escape (const UT_UTF8String & utf8_str1, const UT_UTF8String & utf8_str2) { size_t diff = 0; size_t len1 = utf8_str1.byteLength (); size_t len2 = utf8_str2.byteLength (); const char * str1 = utf8_str1.utf8_str (); const char * str2 = utf8_str2.utf8_str (); if (len2 > len1) { diff = len2 - len1; size_t incr = 0; char * ptr = m_psz; while (ptr + len1 <= m_pEnd) { if (memcmp (ptr, str1, len1) == 0) { incr += diff; ptr += len1; } else { ++ptr; } } if (!grow (incr)) return; } else { diff = len1 - len2; } char * ptr = m_psz; while (ptr + len1 <= m_pEnd) { if (memcmp (ptr, str1, len1) == 0) { if (diff) { if (len2 > len1) { memmove (ptr + diff, ptr, m_pEnd - ptr + 1); m_pEnd += diff; } else { memmove (ptr, ptr + diff, m_pEnd - (ptr + diff) + 1); m_pEnd -= diff; } } memcpy (ptr, str2, len2); ptr += len2; m_strlen += utf8_str2.length () - utf8_str1.length (); } else { ++ptr; } } }