void ODi_StartTag::_growAttributes() { if (m_pAttributes == NULL) { m_pAttributes = new UT_UTF8Stringbuf[m_attributeGrowStep]; m_attributeMemSize = m_attributeGrowStep; } else { UT_UTF8Stringbuf* pTemp; UT_uint32 i; pTemp = m_pAttributes; m_pAttributes = new UT_UTF8Stringbuf[m_attributeMemSize + m_attributeGrowStep]; m_attributeMemSize += m_attributeGrowStep; for (i=0; i<m_attributeSize; i++) { m_pAttributes[i] = pTemp[i]; } DELETEPV(pTemp); } }
// // URLDict_invoke // ------------------- // This is the function that we actually call to invoke the on-line dictionary. // It should be called when the user selects from the context menu // static bool URLDict_invoke(AV_View* /*v*/, EV_EditMethodCallData * /*d*/) { // Get the current view that the user is in. XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame(); FV_View* pView = static_cast<FV_View*>(pFrame->getCurrentView()); // If the user is on a word, but does not have it selected, we need // to go ahead and select that word so that the search/replace goes // correctly. pView->moveInsPtTo(FV_DOCPOS_EOW_MOVE); pView->moveInsPtTo(FV_DOCPOS_BOW); pView->extSelTo(FV_DOCPOS_EOW_SELECT); // Now we will figure out what word to look up when we open our dialog. UT_String url ("http://www.dict.org/bin/Dict?Form=Dict1&Database=*&Strategy=*&Query="); if (!pView->isSelectionEmpty()) { // We need to get the Ascii version of the current word. UT_UCS4Char *ucs4ST; pView->getSelectionText(*&ucs4ST); char* search = _ucsToAscii( ucs4ST ); url += search; DELETEPV(search); FREEP(ucs4ST); } XAP_App::getApp()->openURL( url.c_str() ); return true; }
// // FreeTranslate_invoke // ------------------- // This is the function that we actually call to invoke the // online freetranslation translation // It should be called when the user selects from the context menu // static bool FreeTranslation_invoke(AV_View * /*v*/, EV_EditMethodCallData * /*d*/) { // Get the current view that the user is in. XAP_Frame * pFrame = XAP_App::getApp()->getLastFocussedFrame(); FV_View * pView = static_cast <FV_View *>(pFrame->getCurrentView()); std::string url("http://www.freetranslation.com"); if (!pView->isSelectionEmpty()) { std::string langCode; if (_getTranslationCode(pView, langCode)) { // Now we will figure out what words to translate // We need to get the Latin1 version of the current word. UT_UCS4Char *ucs4ST; pView->getSelectionText(*&ucs4ST); char * translate = _ucs4ToLatin1(ucs4ST); // URL encode the string (' ' -> %20, ...) // TODO this is not complete std::string srcText; for (char *p = translate; p && *p; ++p) { if (*p == ' ' || *p == '%' || *p == '&' || *p == '?' || (*p & 128)) // sometime char is signed. // do bitwise comparison for portability { char temp[4] = ""; sprintf(&temp[0], "%%%x", *p); srcText += temp; } else srcText += *p; } url = "http://ets.freetranslation.com/?Sequence=core"; url += "&Language="; url += langCode; url += "&SrcText="; url += srcText; DELETEPV(translate); FREEP(ucs4ST); XAP_App::getApp()->openURL(url.c_str()); } // else didn't get the translation code. don't show anything } else { XAP_App::getApp()->openURL(url.c_str()); } return true; }
fp_AnnotationRun::fp_AnnotationRun(fl_BlockLayout* pBL, UT_uint32 iOffsetFirst, UT_uint32 /*iLen*/ ) : fp_HyperlinkRun(pBL,iOffsetFirst,1),m_iPID(0),m_sValue(""),m_iRealWidth(0) { UT_ASSERT(pBL); _setLength(1); _setDirty(false); _setWidth(0); _setRecalcWidth(true); UT_ASSERT((pBL)); _setDirection(UT_BIDI_WS); const PP_AttrProp * pAP = NULL; getSpanAP(pAP); const gchar * pTarget; const gchar * pName; bool bFound = false; UT_uint32 k = 0; while(pAP->getNthAttribute(k++, pName, pTarget)) { bFound = (0 == g_ascii_strncasecmp(pName,"Annotation",10)); if(bFound) break; } // we have got to keep a local copy, since the pointer we get // is to a potentially volatile location if(bFound) { DELETEPV(m_pTarget); UT_uint32 iTargetLen = strlen(pTarget); m_pTarget = new gchar [iTargetLen + 1]; strncpy(m_pTarget, pTarget, iTargetLen + 1); m_bIsStart = true; //if this is a start of the Annotation, we set m_pHyperlink to this, //so that when a run gets inserted after this one, its m_pHyperlink is //set correctly _setHyperlink(this); m_iPID = atoi(m_pTarget); } else { m_bIsStart = false; m_pTarget = NULL; _setHyperlink(NULL); m_iPID =0; } lookupProperties(); }
const char * XAP_UnixApp::getUserPrivateDirectory() { /* return a pointer to a static buffer */ static char *buf = NULL; if (buf == NULL) { const char * szAbiDir = "abiword"; const char * szCfgDir = ".config"; const char * szXDG = getenv("XDG_CONFIG_HOME"); if (!szXDG || !*szXDG) { const char * szHome = getenv("HOME"); if (!szHome || !*szHome) szHome = "./"; buf = new char[strlen(szHome)+strlen(szCfgDir)+strlen(szAbiDir)+4]; strcpy(buf, szHome); if (buf[strlen(buf)-1] != '/') strcat(buf, "/"); strcat(buf, szCfgDir); } else { buf = new char[strlen(szXDG)+strlen(szAbiDir)+4]; strcpy(buf, szXDG); } strcat(buf, "/"); strcat(buf, szAbiDir); #ifdef PATH_MAX if (strlen(buf) >= PATH_MAX) DELETEPV(buf); #endif // migration / legacy migrate("/AbiSuite", szAbiDir, buf); } return buf; }
void GR_Graphics::getMaxCharacterDimension(const UT_UCSChar*s, UT_uint32 length, UT_uint32 &width, UT_uint32 &height) { UT_GrowBufElement *pWidths = new UT_GrowBufElement[length]; UT_uint32 maxHeight = 0; measureString(s, 0, length, pWidths, &maxHeight); UT_sint32 maxWidth = 0; for(UT_uint32 i = 0; i < length; i++) { if(pWidths[i] > maxWidth) maxWidth = pWidths[i]; } DELETEPV(pWidths); width = maxWidth; if (maxHeight > 0) { height = maxHeight; } }
AP_Dialog_Paragraph::sControlData::~sControlData () { DELETEPV(m_szData); }
fp_AnnotationRun::~fp_AnnotationRun() { DELETEPV(m_pTarget); }
/** * Destructor */ ODi_StartTag::~ODi_StartTag() { DELETEPV(m_pAttributes); }
XAP_Dialog_Language::~XAP_Dialog_Language(void) { DELETEP(m_pLangTable); DELETEPV(m_ppLanguages); DELETEPV(m_ppLanguagesCode); }