本文整理汇总了C++中FV_View::isSelectionEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ FV_View::isSelectionEmpty方法的具体用法?C++ FV_View::isSelectionEmpty怎么用?C++ FV_View::isSelectionEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FV_View
的用法示例。
在下文中一共展示了FV_View::isSelectionEmpty方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: url
//
// 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;
}
示例2: FreeTranslation_invoke
//
// 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;
}
示例3: url
//
// AbiGoogle_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
AbiGoogle_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.
if (pView->isSelectionEmpty()) {
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
UT_UTF8String url ("http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=");
// url escaping should be moved somewhere more generic
UT_UCS4Char *ucs4ST;
pView->getSelectionText(*&ucs4ST);
UT_UCS4String data (ucs4ST);
bool last_was_space = false;
for (size_t i = 0; i < data.length (); i++) {
UT_UCS4Char ch = data[i];
if (!UT_UCS4_isspace (ch)) {
url.appendUCS4 (&ch, 1);
last_was_space = false;
}
else if (!last_was_space) {
ch = '+';
url.appendUCS4 (&ch, 1);
last_was_space = true;
}
}
XAP_App::getApp()->openURL( url.utf8_str() );
FREEP(ucs4ST);
return true;
}
示例4:
//
// AiksaurusABI_invoke
// -------------------
// This is the function that we actually call to invoke the thesaurus.
// It should be called when the user hits the thesaurus key (shift+f7?)
// or chooses "thesaurus" from a menu.
//
bool
AiksaurusABI_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.
char* search = 0;
if (!pView->isSelectionEmpty())
{
// We need to get the Ascii version of the current word.
UT_UCS4Char * ucs4ST;
pView->getSelectionText(*&ucs4ST);
search = AiksaurusABI_ucsToAscii(
ucs4ST
);
}
// Now we will run the thesaurus dialog and get a response.
// We will automatically do a search for the selected/current word.
#ifdef _WIN32
AiksaurusApp thesaurus;
thesaurus.setInstance( (HINSTANCE)s_hModule );
#else
AiksaurusGTK thesaurus;
#endif
thesaurus.setTitle("Abiword Thesaurus");
thesaurus.setInitialMessage("Welcome to Aiksaurus");
const char* response = thesaurus.runThesaurus(search);
if (response)
{
// Now that we have our replacement, we need to convert it to UCS-2.
int length;
UT_UCSChar* replacement = AiksaurusABI_asciiToUcs(response, length);
// Now, if our replacement has length, we can go ahead and run the
// replacement. If the replacement has no length, we will do nothing.
if (length)
pView->cmdCharInsert(replacement, length);
// all done with replacement.
delete[] replacement;
}
// Finally, we need to remember to delete search and replacement strings.
// Note that "search" might be null so we only want to delete[] it if it
// was actually initialized above.
if (search)
delete[] search;
return true;
}
示例5: copyToClipboard
//.........这里部分代码省略.........
pExpHtml->set_HTML4 (false);
pExpHtml->copyToBuffer (pDocRange, &bufXHTML);
DELETEP(pExpHtml);
}
// create HTML4 buffer to put on the clipboard
pExpHtml = new IE_Exp_HTML(pDocRange->m_pDoc);
if (pExpHtml)
{
pExpHtml->set_HTML4 (true);
pExpHtml->copyToBuffer(pDocRange, &bufHTML4);
DELETEP(pExpHtml);
}
// Look to see if the ODT plugin is loaded
IEFileType ftODT = IE_Exp::fileTypeForMimetype("application/vnd.oasis.opendocument.text");
bool bExpODT = false;
if(ftODT != IEFT_Unknown)
{
// ODT plugin is present construct an exporter
//
IE_Exp * pODT = NULL;
IEFileType genIEFT = IEFT_Unknown;
GsfOutput * outBuf = gsf_output_memory_new();
UT_Error err = IE_Exp::constructExporter(pDocRange->m_pDoc,outBuf,
ftODT,&pODT,& genIEFT);
if(pODT && (genIEFT == ftODT))
{
//
// Copy to the buffer
//
err = pODT->copyToBuffer(pDocRange, &bufODT);
bExpODT = (err == UT_OK);
UT_DEBUGMSG(("Putting ODF on the clipboard...e:%d bExpODT:%d\n", err, bExpODT ));
#ifdef DUMP_CLIPBOARD_COPY
std::ofstream oss("/tmp/abiword-clipboard-copy.odt");
oss.write( (const char*)bufODT.getPointer (0), bufODT.getLength () );
oss.close();
#endif
}
}
// create UTF-8 text buffer to put on the clipboard
IE_Exp_Text * pExpText = new IE_Exp_Text(pDocRange->m_pDoc, "UTF-8");
if (pExpText)
{
pExpText->copyToBuffer(pDocRange,&bufTEXT);
DELETEP(pExpText);
}
// NOTE: this clearData() will actually release our ownership of
// NOTE: the CLIPBOARD property in addition to clearing any
// NOTE: stored buffers. I'm omitting it since we seem to get
// NOTE: clr callback after we have done some other processing
// NOTE: (like adding the new stuff).
// m_pClipboard->clearData(true,false);
// TODO: handle CLIPBOARD vs PRIMARY
XAP_UnixClipboard::T_AllowGet target = ((bUseClipboard)
? XAP_UnixClipboard::TAG_ClipboardOnly
: XAP_UnixClipboard::TAG_PrimaryOnly);
if (bufRTF.getLength () > 0)
m_pClipboard->addRichTextData (target, bufRTF.getPointer (0), bufRTF.getLength ());
if (bufXHTML.getLength () > 0)
m_pClipboard->addHtmlData (target, bufXHTML.getPointer (0), bufXHTML.getLength (), true);
if (bufHTML4.getLength () > 0)
m_pClipboard->addHtmlData (target, bufHTML4.getPointer (0), bufHTML4.getLength (), false);
if (bExpODT && bufODT.getLength () > 0)
m_pClipboard->addODTData (target, bufODT.getPointer (0), bufODT.getLength ());
if (bufTEXT.getLength () > 0)
m_pClipboard->addTextData (target, bufTEXT.getPointer (0), bufTEXT.getLength ());
{
// TODO: we have to make a good way to tell if the current selection is just an image
FV_View * pView = NULL;
if(getLastFocussedFrame())
pView = static_cast<FV_View*>(getLastFocussedFrame()->getCurrentView());
if (pView && !pView->isSelectionEmpty())
{
// don't own, don't g_free
const UT_ByteBuf * png = 0;
pView->saveSelectedImage (&png);
if (png && png->getLength() > 0)
{
m_pClipboard->addPNGData(target, static_cast<const UT_Byte*>(png->getPointer(0)), png->getLength());
}
}
}
m_pClipboard->finishedAddingData();
return;
}
示例6: getCurrentSelection
/*!
get the current contents of the selection in the
window last known to have a selection using one
of the formats in the given list.
\param formatList the list of acceptable formats
\param ppData
\param pLen a pointer to an integer representing the length
\param pszFormatFound a pointer for the data to be returned in
\return True if successful, false otherwise.
*/
bool AP_UnixApp::getCurrentSelection(const char** formatList,
void ** ppData, UT_uint32 * pLen,
const char **pszFormatFound)
{
int j;
*ppData = NULL; // assume failure
*pLen = 0;
*pszFormatFound = NULL;
if (!m_pViewSelection || !m_pFrameSelection || !m_bHasSelection)
return false; // can't do it, give up.
PD_DocumentRange dr;
if (m_cacheSelectionView == m_pViewSelection)
{
dr = m_cacheDocumentRangeOfSelection;
}
else
{
// TODO if we ever support multiple view types, we'll have to
// TODO change this.
FV_View * pFVView = static_cast<FV_View *>(m_pViewSelection);
pFVView->getDocumentRangeOfCurrentSelection(&dr);
}
m_selectionByteBuf.truncate(0);
for (j=0; (formatList[j]); j++)
{
if ( AP_UnixClipboard::isRichTextTag(formatList[j]) )
{
IE_Exp_RTF * pExpRtf = new IE_Exp_RTF(dr.m_pDoc);
if (!pExpRtf)
return false; // give up on memory errors
pExpRtf->copyToBuffer(&dr,&m_selectionByteBuf);
DELETEP(pExpRtf);
goto ReturnThisBuffer;
}
if ( AP_UnixClipboard::isHTMLTag(formatList[j]) )
{
IE_Exp_HTML * pExpHTML = new IE_Exp_HTML(dr.m_pDoc);
if (!pExpHTML)
return false;
pExpHTML->set_HTML4 (!strcmp (formatList[j], "text/html"));
pExpHTML->copyToBuffer(&dr,&m_selectionByteBuf);
DELETEP(pExpHTML);
goto ReturnThisBuffer;
}
if ( AP_UnixClipboard::isImageTag(formatList[j]) )
{
// TODO: we have to make a good way to tell if the current selection is just an image
FV_View * pView = NULL;
if(getLastFocussedFrame())
pView = static_cast<FV_View*>(getLastFocussedFrame()->getCurrentView());
if (pView && !pView->isSelectionEmpty())
{
// don't own, don't g_free
const UT_ByteBuf * png = 0;
pView->saveSelectedImage (&png);
if (png && png->getLength() > 0)
{
m_selectionByteBuf.ins (0, png->getPointer (0), png->getLength ());
goto ReturnThisBuffer;
}
}
}
if ( AP_UnixClipboard::isTextTag(formatList[j]) )
{
IE_Exp_Text * pExpText = new IE_Exp_Text(dr.m_pDoc, "UTF-8");
if (!pExpText)
return false;
pExpText->copyToBuffer(&dr,&m_selectionByteBuf);
DELETEP(pExpText);
goto ReturnThisBuffer;
}
// TODO add other formats as necessary
}
//.........这里部分代码省略.........
示例7: BabelFish_invoke
//
// BabelFish_invoke
// -------------------
// This is the function that we actually call to invoke the
// online babelfish translation
// It should be called when the user selects from the context menu
//
static bool BabelFish_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());
UT_String url ("http://babelfish.altavista.com");
if (!pView->isSelectionEmpty())
{
// TODO: generate the correct language binding via the current
// TODO: language and then the language dialog. Currently
// TODO: english->german is hardcoded
UT_String langCode;
if ( _getTranslationCode ( pView, langCode ) )
{
// Now we will figure out what words to translate
url = "http://babelfish.altavista.com/tr?doit=done&tt=urltext";
url += "&lp=";
url += langCode;
url += "&urltext=";
// We need to get the UTF-8 version of the current word.
UT_String utf8;
UT_UCS4Char *ucs4ST;
pView->getSelectionText(*&ucs4ST);
_ucsToUTF8(
utf8,
ucs4ST
);
// URL encode the string (' ' -> %20, ...)
// TODO this is not complete
UT_String srcText;
//for (char *p = utf8; p && *p; ++p)
for (UT_uint32 i = 0; i < utf8.size(); ++i)
{
if (utf8[i] == ' ' || utf8[i] == '%'
|| utf8[i] == '&' || utf8[i] == '?' || (utf8[i] & 128))
{
char temp[4] = "";
sprintf(&temp[0], "%%%x", utf8[i]);
srcText += temp;
} else
srcText += utf8[i];
}
url += srcText;
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;
}