// // high-resolution timers for profiling // int32_t win_inittimer(void) { int64_t t; if (win_timerfreq) return 0; // already installed // OpenWatcom seems to want us to query the value into a local variable // instead of the global 'win_timerfreq' or else it gets pissed with an // access violation if (!QueryPerformanceFrequency((LARGE_INTEGER *)&t)) { ShowErrorBox("Failed fetching timer frequency"); return -1; } win_timerfreq = t; return 0; }
/*! * Import graphic for cell background. */ void AP_Dialog_FormatFrame::askForGraphicPathName(void) { UT_return_if_fail(m_pApp); XAP_Frame * pFrame = m_pApp->getLastFocussedFrame(); UT_return_if_fail(pFrame); XAP_DialogFactory * pDialogFactory = static_cast<XAP_DialogFactory *>(pFrame->getDialogFactory()); UT_return_if_fail(pDialogFactory); XAP_Dialog_FileOpenSaveAs * pDialog = static_cast<XAP_Dialog_FileOpenSaveAs *>(pDialogFactory->requestDialog(XAP_DIALOG_ID_INSERT_PICTURE)); UT_return_if_fail (pDialog); pDialog->setCurrentPathname(NULL); pDialog->setSuggestFilename(false); // to fill the file types popup list, we need to convert AP-level // ImpGraphic descriptions, suffixes, and types into strings. UT_uint32 filterCount = IE_ImpGraphic::getImporterCount(); const char ** szDescList = static_cast<const char **>(UT_calloc(filterCount + 1, sizeof(char *))); const char ** szSuffixList = static_cast<const char **>(UT_calloc(filterCount + 1, sizeof(char *))); IEGraphicFileType * nTypeList = (IEGraphicFileType *) UT_calloc(filterCount + 1, sizeof(IEGraphicFileType)); UT_uint32 k = 0; while (IE_ImpGraphic::enumerateDlgLabels(k, &szDescList[k], &szSuffixList[k], &nTypeList[k])) k++; pDialog->setFileTypeList(szDescList, szSuffixList, static_cast<const UT_sint32 *>(nTypeList)); pDialog->runModal(pFrame); XAP_Dialog_FileOpenSaveAs::tAnswer ans = pDialog->getAnswer(); bool bOK = (ans == XAP_Dialog_FileOpenSaveAs::a_OK); if (bOK) { m_sImagePath = pDialog->getPathname(); UT_sint32 type = pDialog->getFileType(); // If the number is negative, it's a special type. // Some operating systems which depend solely on filename // suffixes to identify type (like Windows) will always // want auto-detection. if (type < 0) switch (type) { case XAP_DIALOG_FILEOPENSAVEAS_FILE_TYPE_AUTO: // do some automagical detecting m_iGraphicType = IEGFT_Unknown; break; default: // it returned a type we don't know how to handle UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); } else m_iGraphicType = static_cast<IEGraphicFileType>(pDialog->getFileType()); } FREEP(szDescList); FREEP(szSuffixList); FREEP(nTypeList); pDialogFactory->releaseDialog(pDialog); if(m_sImagePath.size() == 0) { return; } FG_Graphic* pFG = NULL; UT_Error errorCode; errorCode = IE_ImpGraphic::loadGraphic(m_sImagePath.c_str(), m_iGraphicType, &pFG); if(errorCode != UT_OK || !pFG) { ShowErrorBox(m_sImagePath, errorCode); return; } DELETEP(m_pGraphic); DELETEP(m_pImage); m_pGraphic = pFG->clone(); GR_Graphics * pG = m_pFormatFramePreview->getGraphics(); FV_View * pView = static_cast<FV_View *>(pFrame->getCurrentView()); UT_return_if_fail(pView && pView->getDocument()); UT_uint32 uid = pView->getDocument()->getUID(UT_UniqueId::Image); //see Bug 10851 m_sImagePath.clear(); m_sImagePath = UT_std_string_sprintf("%d",uid); m_pImage = _makeImageForRaster(m_sImagePath, pG, m_pGraphic); // draw the preview with the changed properties if(m_pFormatFramePreview) m_pFormatFramePreview->draw(); }