本文整理汇总了C++中FV_View::saveSelectedImage方法的典型用法代码示例。如果您正苦于以下问题:C++ FV_View::saveSelectedImage方法的具体用法?C++ FV_View::saveSelectedImage怎么用?C++ FV_View::saveSelectedImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FV_View
的用法示例。
在下文中一共展示了FV_View::saveSelectedImage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: DECLARE_ABI_PLUGIN_METHOD
//
// AbiPaint editImage
// ------------------
// This is the function that we actually call to invoke the image editor.
//
// parameters are:
// AV_View* v
// EV_EditMethodCallData *d
//
static DECLARE_ABI_PLUGIN_METHOD(editImage)
{
UT_UNUSED(v);
// 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());
//
// get values from preference (initial plugin execution should have set sensible defaults)
//
UT_String imageApp; // holds MAXPATH\appName <space> MAXPATH\imagefilename
bool bLeaveImageAsPNG;
// read stuff from the preference value
if (!prefsScheme->getValue(ABIPAINT_PREF_KEY_szProgramName, imageApp))
{
UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
getDefaultApp(imageApp, bLeaveImageAsPNG);
}
// now that we have program name, try to get other flag (allows overriding default value)
// Note: we allow overriding, otherwise if we don't adhere to user's setting
// then the use BMP or not menu should be greyed to note it has no effect
prefsScheme->getValueBool(ABIPAINT_PREF_KEY_bLeaveImageAsPNG, &bLeaveImageAsPNG);
//
// generate a temp file name...
//
char *szTempFileName = NULL;
GError *err = NULL;
gint fp = g_file_open_tmp ("XXXXXX", &szTempFileName, &err);
if (err) {
g_warning ("%s", err->message);
g_error_free (err); err = NULL;
return FALSE;
}
close(fp);
UT_String szTmpPng = szTempFileName;
szTmpPng += ".png";
UT_String szTmp = szTmpPng; // default: our temp file is the created png file
PT_DocPosition pos = pView->saveSelectedImage((const char *)szTmpPng.c_str());
if(pos == 0)
{
remove(szTempFileName);
g_free (szTempFileName); szTempFileName = NULL;
pFrame->showMessageBox("You must select an Image before editing it", XAP_Dialog_MessageBox::b_O,XAP_Dialog_MessageBox::a_OK);
return false;
}
#ifdef ENABLE_BMP
//
// Convert png into bmp for best compatibility with Windows programs
// NOTE: probably looses detail/information though!!! so if possible use PNG
//
if (!bLeaveImageAsPNG)
{
szTmp = szTempFileName;
szTmp += ".bmp"; // our temp file is a bmp file
if (convertPNG2BMP(szTmpPng.c_str(), szTmp.c_str()))
{
pFrame->showMessageBox("Unable to convert PNG image data to BMP for external program use!", XAP_Dialog_MessageBox::b_O,XAP_Dialog_MessageBox::a_OK);
UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
remove(szTempFileName);
g_free (szTempFileName); szTempFileName = NULL;
remove(szTmpPng.c_str());
return false;
}
// remove(szTmpPng.c_str());
}
#endif
// remove the temp file (that lacks proper extension)
remove(szTempFileName);
g_free (szTempFileName); szTempFileName = NULL;
//
// Get the initial file status.
//
struct stat myFileStat;
int ok = stat(szTmp.c_str(),&myFileStat);
if(ok < 0)
{
UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
remove(szTmpPng.c_str());
remove(szTmp.c_str()); // should silently fail if exporting as PNG file
//.........这里部分代码省略.........
示例3: 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
}
//.........这里部分代码省略.........