本文整理汇总了C++中FV_View::cmdInsertGraphic方法的典型用法代码示例。如果您正苦于以下问题:C++ FV_View::cmdInsertGraphic方法的具体用法?C++ FV_View::cmdInsertGraphic怎么用?C++ FV_View::cmdInsertGraphic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FV_View
的用法示例。
在下文中一共展示了FV_View::cmdInsertGraphic方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDesktopWindow
bool AP_Win32App::_pasteFormatFromClipboard(PD_DocumentRange * pDocRange, const char * szFormat,
const char * szType, bool bWide)
{
HANDLE hData;
bool bSuccess = false;
if (!(hData = m_pClipboard->getHandleInFormat(szFormat)))
return bSuccess;
// It's a bitmap
if (g_ascii_strcasecmp(szFormat, AP_CLIPBOARD_BMP)==0)
{
HBITMAP hBitmap;
PBITMAPINFO bi;
HWND hWnd;
HDC hdc;
IE_ImpGraphic* pIEG = NULL;
FG_Graphic* pFG = NULL;
UT_Error errorCode;
UT_ByteBuf byteBuf;
IEGraphicFileType iegft = IEGFT_BMP;
XAP_Frame* pFrame;
AP_FrameData* pFrameData;
FL_DocLayout* pDocLy;
FV_View* pView;
UT_ByteBuf* bBufBMP = new UT_ByteBuf;
hBitmap = (HBITMAP)hData;
hWnd = GetDesktopWindow();
hdc = GetDC(hWnd);
// Create a BMP file from a BITMAP
bi = CreateBitmapInfoStruct(hBitmap);
CreateBMP(hWnd, *bBufBMP, bi, hBitmap,hdc);
// Since we are providing the file type, there is not need to pass the bytebuff filled up
errorCode = IE_ImpGraphic::constructImporter(*bBufBMP, iegft, &pIEG);
if(errorCode != UT_OK)
return false;
errorCode = pIEG->importGraphic(bBufBMP, &pFG);
if(errorCode != UT_OK || !pFG)
{
DELETEP(bBufBMP);
DELETEP(pIEG);
return false;
}
// sunk in importGraphic
bBufBMP = NULL;
// Insert graphic in the view
pFrame = getLastFocussedFrame();
pFrameData = (AP_FrameData*) pFrame->getFrameData();
pDocLy = pFrameData->m_pDocLayout;
pView = pDocLy->getView();
errorCode = pView->cmdInsertGraphic(pFG);
DELETEP(pIEG);
//DELETEP(pFG);
bSuccess = true;
}
else
{
unsigned char * pData = static_cast<unsigned char *>(GlobalLock(hData));
UT_DEBUGMSG(("Paste: [fmt %s %s][hdata 0x%08lx][pData 0x%08lx]\n",
szFormat, szType, hData, pData));
UT_uint32 iSize = GlobalSize(hData);
UT_uint32 iStrLen = bWide
? wcslen(reinterpret_cast<const wchar_t *>(pData)) * 2
: strlen(reinterpret_cast<const char *>(pData));
UT_uint32 iLen = UT_MIN(iSize,iStrLen);
IE_Imp * pImp = 0;
IE_Imp::constructImporter(pDocRange->m_pDoc, IE_Imp::fileTypeForSuffix(szType), &pImp, 0);
if (pImp)
{
const char * szEncoding = 0;
if (bWide)
szEncoding = XAP_EncodingManager::get_instance()->getUCS2LEName();
else
; // TODO Get code page using CF_LOCALE
pImp->pasteFromBuffer(pDocRange,pData,iLen,szEncoding);
delete pImp;
}
GlobalUnlock(hData);
bSuccess = true;
}
return bSuccess;
}
示例2: pasteFromClipboard
//.........这里部分代码省略.........
if (AP_UnixClipboard::isDynamicTag (szFormatFound))
{
UT_DEBUGMSG(("Dynamic Format Found = %s \n",szFormatFound));
}
if (AP_UnixClipboard::isRichTextTag(szFormatFound))
{
IE_Imp_RTF * pImpRTF = new IE_Imp_RTF(pDocRange->m_pDoc);
bSuccess = pImpRTF->pasteFromBuffer(pDocRange,pData,iLen);
DELETEP(pImpRTF);
}
else if (AP_UnixClipboard::isHTMLTag (szFormatFound))
{
IE_Imp_Text_Sniffer SniffBuf;
const char * szRes = SniffBuf.recognizeContentsType(reinterpret_cast<const char *>(pData),iLen);
if(szRes && strcmp(szRes,"none") != 0)
{
UT_uint32 iread,iwritten = 0;
const char * szutf8= static_cast<const char *>(UT_convert(reinterpret_cast<const char *>(pData),iLen,szRes,"UTF-8",&iread,&iwritten));
IE_Imp_XHTML * pImpHTML = new IE_Imp_XHTML(pDocRange->m_pDoc);
bSuccess = pImpHTML->pasteFromBuffer(pDocRange,reinterpret_cast<const unsigned char *>(szutf8),iwritten,"UTF-8");
g_free(const_cast<char *>(szutf8));
DELETEP(pImpHTML);
}
else
{
IE_Imp_XHTML * pImpHTML = new IE_Imp_XHTML(pDocRange->m_pDoc);
bSuccess = pImpHTML->pasteFromBuffer(pDocRange,reinterpret_cast<const unsigned char *>(pData),iLen);
DELETEP(pImpHTML);
}
}
else if (AP_UnixClipboard::isDynamicTag (szFormatFound))
{
UT_DEBUGMSG(("Format Found = %s \n",szFormatFound));
IE_Imp * pImp = NULL;
IEFileType ieft = IE_Imp::fileTypeForMimetype(szFormatFound);
UT_DEBUGMSG(("found file type %d\n",ieft));
IE_Imp::constructImporter(pDocRange->m_pDoc,ieft,&pImp);
if(pImp == NULL)
goto retry_text;
bSuccess = pImp->pasteFromBuffer(pDocRange,pData,iLen);
DELETEP(pImp);
}
else if (AP_UnixClipboard::isImageTag(szFormatFound))
{
UT_DEBUGMSG(("Format Found = %s \n",szFormatFound));
if(strncmp(szFormatFound,"application",11) == 0) // embedded object
{
IE_Imp * pImp = NULL;
IEGraphicFileType iegft = IE_Imp::fileTypeForMimetype(szFormatFound);
IE_Imp::constructImporter(pDocRange->m_pDoc,iegft,&pImp);
if(pImp == NULL)
{
goto retry_text;
}
/*bool b = */ pImp->pasteFromBuffer(pDocRange,pData,iLen);
DELETEP(pImp);
return;
}
FG_Graphic * pFG = NULL;
IEGraphicFileType iegft = IEGFT_Unknown;
UT_Error error = UT_OK;
UT_ByteBuf bytes( iLen );
bytes.append (pData, iLen);
error = IE_ImpGraphic::loadGraphic(bytes, iegft, &pFG);
if(!pFG || error)
{
UT_DEBUGMSG(("DOM: could not import graphic (%d)\n", error));
goto retry_text;
}
// at this point, 'bytes' is owned by pFG
FV_View * pView = static_cast<FV_View*>(getLastFocussedFrame ()->getCurrentView());
error = pView->cmdInsertGraphic(pFG);
DELETEP(pFG);
if (!error)
bSuccess = true;
}
else // ( AP_UnixClipboard::isTextTag(szFormatFound) )
{
IE_Imp_Text * pImpText = new IE_Imp_Text(pDocRange->m_pDoc,"UTF-8");
bSuccess = pImpText->pasteFromBuffer(pDocRange,pData,iLen);
DELETEP(pImpText);
}
retry_text:
// we failed to paste *anything.* try plaintext as a last-ditch effort
if(!bSuccess && m_pClipboard->getTextData(tFrom,reinterpret_cast<const void **>(&pData),&iLen, &szFormatFound)) {
UT_DEBUGMSG(("DOM: pasting text as an absolute fallback (bug 7666)\n"));
IE_Imp_Text * pImpText = new IE_Imp_Text(pDocRange->m_pDoc,"UTF-8");
bSuccess = pImpText->pasteFromBuffer(pDocRange,pData,iLen);
DELETEP(pImpText);
}
}
示例3: DECLARE_ABI_PLUGIN_METHOD
//.........这里部分代码省略.........
off_t size = myFileStat.st_size;
UT_usleep(100000); // wait 100 milliseconds (so program may have time to write something)
ok = stat(szTmp.c_str(),&myFileStat);
while((mod_time != myFileStat.st_mtime) || !size || (size > 0 && size != myFileStat.st_size))
{
mod_time = myFileStat.st_mtime;
size = myFileStat.st_size;
ok = stat(szTmp.c_str(),&myFileStat);
UT_usleep(500000); // wait a while, let program write its data
// just make sure the program is still running, otherwise we could get stuck in a loop
if (!isProcessStillAlive(procInfo))
{
pFrame->showMessageBox("External image editor appears to have been terminated unexpectedly.",
XAP_Dialog_MessageBox::b_O,XAP_Dialog_MessageBox::a_OK);
//procInfo.hProcess = 0;
goto Cleanup;
}
}
mod_time = myFileStat.st_mtime;
UT_usleep(100000); // wait a while just to make sure program is done with file
//
// OK replace the current image with this.
//
IEGraphicFileType iegft = IEGFT_Unknown;
FG_Graphic* pFG;
UT_Error errorCode;
#ifdef ENABLE_BMP
//
// Convert bmp back to png (as we can not assume AbiWord has builtin BMP support [as its now an optional plugin])
// NOTE: probably looses detail/information though!!! so if possible use only PNG
//
if (!bLeaveImageAsPNG)
{
if (convertBMP2PNG(szTmp.c_str(), szTmpPng.c_str()))
{
pFrame->showMessageBox("Unable to convert BMP image data back to PNG for AbiWord to import!", XAP_Dialog_MessageBox::b_O,XAP_Dialog_MessageBox::a_OK);
UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
goto Cleanup;
}
}
#endif
errorCode = IE_ImpGraphic::loadGraphic(szTmpPng.c_str(), iegft, &pFG);
if(errorCode)
{
UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
pFrame->showMessageBox("Error making pFG. Could not put image back into Abiword", XAP_Dialog_MessageBox::b_O,XAP_Dialog_MessageBox::a_OK);
goto Cleanup;
}
unlockGUI(d);
pView->cmdUnselectSelection();
pView->setPoint(pos);
pView->extSelHorizontal(true, 1); // move point forward one
errorCode = pView->cmdInsertGraphic(pFG);
if (errorCode)
{
pFrame->showMessageBox("Could not put image back into Abiword", XAP_Dialog_MessageBox::b_O,XAP_Dialog_MessageBox::a_OK);
UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
DELETEP(pFG);
goto Cleanup;
}
DELETEP(pFG);
//
// Reselect the image
//
pView->setPoint(pos);
pView->extSelHorizontal(true, 1); // move point forward one
lockGUI(d);
}
}
}
//
// Normal exit, delete the tempfile and return success
//
remove(szTmpPng.c_str());
remove(szTmp.c_str()); // should silently fail if exporting as PNG file
unlockGUI(d);
return true;
//
// Something went wrong.
//
Cleanup:
remove(szTmpPng.c_str());
remove(szTmp.c_str()); // should silently fail if exporting as PNG file
unlockGUI(d);
//
// Kill the image editor.
//
endProcess(procInfo);
return false;
}