/** *@details EmbraceBFApplication */ EmbraceBFApplication::EmbraceBFApplication(int argc, char** argv, const QString& stream) { QCoreApplication app(argc, argv); try { // Create a PipelineApplication. PipelineApplication pApp(argc, argv); // Register the pipelines that can run. PipelineSwitcher sw; //sw.addPipeline(new BandPassPipeline(stream)); sw.addPipeline(new EmbraceBFPipeline(stream)); pApp.addPipelineSwitcher(sw); // Set the data client. pApp.setDataClient("PelicanServerClient"); // Start the pipeline driver. pApp.start(); } catch (const QString& err) { std::cerr << "Error caught in EmbraceBFApplication(" << stream.toStdString() << "):\"" << err.toStdString() << "\"" << std::endl; } }
void TestRealWordObject::setUpSuite() { try { Word::_ApplicationPtr pApp(_T("Word.Application")); if (NULL != pApp) { if (_ttoi(pApp->Version) >= 9) { m_bIManageCOMAddInLoaded = WordAddInFinder::DoesComAddInExist(pApp, _T("iManO2K.AddinForWord2000")) || WordAddInFinder::DoesComAddInExist(pApp, _T("iManO2K.AddinForWORD_2K")); } pApp->raw_Quit(); } } catch (...) { // Why would this throw? } WordWatcher wotcher; wotcher.CloseAllWordInstances(); wotcher.WaitForAllInstancesOfWordToExit(); }
CStdString CPDTestHelper::GetCurrentLibrary() { DOCSObjects::IApplicationPtr pApp( __uuidof( DOCSObjects::Application )); pApp->PutDefParentWindow( 0 ); DOCSObjects::ILibrariesPtr pLibs = pApp->GetLibraries(); DOCSObjects::ILibraryPtr pLib = pApp->GetCurrentLibrary(); return pLib->GetName(); }
int __stdcall WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int) { std::auto_ptr<core::IApplication> pApp(core::IApplication::Create(L"Track Editor", 800, 600, false, false)); pApp->addTask(core::PTask(new core::InputTask(*pApp, 0, false))); pApp->addTask(core::PTask(new core::CGameTask(*pApp, 1))); pApp->addTask(core::PTask(new core::RenderTask(*pApp, 2))); TrackEditor r; pApp->Run(); return 0; }
bool CPDTestHelper::CheckLibraryIsAvailable(const CStdString& sLibraryName) { try { DOCSObjects::IApplicationPtr pApp( __uuidof( DOCSObjects::Application )); DOCSObjects::ILibrariesPtr pLibs = pApp->GetLibraries(); DOCSObjects::ILibraryPtr pLib = pLibs->GetItem(sLibraryName.c_str()); if(pLib != NULL) return true; } catch(...) { } return false; }
void WordOutputProcessor::Open(CStdString sFile) { Word::_ApplicationPtr pApp(L"Word.Application"); m_WordApp = pApp; pApp->Visible = TRUE; m_WordDoc = pApp->Documents->Open(&_variant_t(sFile)); Word::_DocumentPtr pDoc = m_WordDoc; pDoc->ActiveWindow->View->Type = Word::wdPrintView; pDoc->ActiveWindow->WindowState = Word::wdWindowStateNormal; pDoc->ActiveWindow->Height = 400; pDoc->Activate(); Sleep(1000); Word::WindowPtr pWnd = pDoc->ActiveWindow; pWnd->LargeScroll(&vtMissing, &variant_t(100)); m_hWndEditor = GetContainerWnd(pDoc); m_hWndEditor = FindWindowEx(m_hWndEditor, NULL, _T("_WwB"), NULL); m_hWndEditor = FindWindowEx(m_hWndEditor, NULL, _T("_WwG"), NULL); }
bool CPDTestHelper::PDcanRun(std::tstring& sReason) { try { sReason = _T("PowerDOCS is not installed"); DOCSObjects::IApplicationPtr pApp( __uuidof( DOCSObjects::Application )); if(pApp) { return (CGeneral::FileExists(_T("c:\\program files\\powerdocs\\powerdocs.exe")) || CGeneral::FileExists(_T("C:\\Program Files\\Hummingbird\\PowerDOCS\\PowerDOCS.exe")) || CGeneral::FileExists(_T("C:\\Program Files\\Hummingbird\\PowerDOCS.exe")) || CGeneral::FileExists(_T("C:\\Program Files\\Hummingbird\\DM Extensions\\PowerDOCS.exe"))); } } catch(...) { } return false; }
// IOMEventHandler STDMETHODIMP CEventHandler::Init(DOCSObjects::IApplication * piApp) { CComQIPtr<DOCSObjects::IApplication> pApp( piApp ); try { VHELPERLib::IVBConnectorPtr pVBConnector; HRESULT hr = pVBConnector.CreateInstance( __uuidof( VHELPERLib::VBConnector )); if( SUCCEEDED( hr )) { IUnknown* pUnk; QueryInterface( IID_IUnknown, (void **)&pUnk ); pVBConnector->Connect( pApp, pUnk ); } } catch(...) { LOG_WS_ERROR(_T("Failed to connect to events source")); } return S_OK; }
void DMTests_Helper::SaveDocument(const CStdString& sDocumentName, const CStdString& sAppID, CStdString& sTestDocID) { USES_CONVERSION; try { DOCSObjects::IApplicationPtr pApp( __uuidof( DOCSObjects::Application )); pApp->PutDefParentWindow( 0 ); DOCSObjects::ILibrariesPtr pLibs = pApp->GetLibraries(); DOCSObjects::ILibraryPtr pLib = pApp->GetCurrentLibrary(); DOCSObjects::IDOCSFormsPtr pForms = pLib->GetForms(); DOCSObjects::IProfilePtr pBaseProf = NULL; DOCSObjects::IDOCSFormPtr pForm = NULL; int iCount = pForms->GetCount(); bool bFoundProf = FALSE; _variant_t vtIndex; vtIndex.vt = VT_I4; for (vtIndex.lVal = 1; (vtIndex.lVal <= iCount) && (!bFoundProf); vtIndex.lVal++) { pForm = pForms->GetItem(vtIndex); if (pForm->GetType() & DOCSObjects::FT_DEFAULT_PROFILE) { pBaseProf = pLib->CreateProfile(pForm->GetName()); bFoundProf = TRUE; } } if (pBaseProf == NULL) { pBaseProf = pLib->CreateProfile( _bstr_t( _T("LAWPROF") )); } DOCSObjects::IColumnsPtr pCols = pBaseProf->GetColumns(); DOCSObjects::IColumnPtr pCol = pCols->GetItem( _variant_t( _T("APP_ID") )); pCol->PutValue( _variant_t( T2CW(sAppID.c_str()) ) ); pCol = pCols->GetItem( _variant_t( _T("DOCNAME") )); pCol->PutValue( _variant_t( sDocumentName.c_str() ) ); pCol = pCols->GetItem( _variant_t( _T("TYPE_ID") )); pCol->PutValue( _variant_t( L"MEMO")); pCol = pCols->GetItem( L"AUTHOR_ID"); pCol->PutValue(L"pair"); pCol = pCols->GetItem(L"TYPIST_ID"); pCol->PutValue(L"pair"); pCol = pCols->GetItem(L"CLIENT_ID"); pCol->PutValue(L"TEST"); pCol = pCols->GetItem(L"MATTER_ID"); pCol->PutValue(L"TEST"); VARIANT_BOOL vb = pBaseProf->Save( DOCSObjects::OF_NORMAL ); if(vb == VARIANT_FALSE) { throw std::exception("Profile save document failed"); } DOCSObjects::IVersionPtr pVer = pBaseProf->GetCurrentVersion(); CStdString sDest = pVer->GetFilePath(); bool bSuccess = false; if (sAppID.CompareNoCase(_T("ACROBAT")) == 0) { bSuccess = (CopyFile(TEST_PDF_FILE,sDest.c_str(),false)!=0); } else { bSuccess = (CopyFile(TEST_DOC_FILE,sDest.c_str(),false)!=0); } if(!bSuccess) { throw std::exception("Copy of test file failed"); } m_lDocNum = pBaseProf->GetDocNumber(); BSTR bsLibName = pLib->GetName(); CStdString sLibName(bsLibName); SysFreeString(bsLibName); sTestDocID.Format(_T("PowerDocs://%s/%d/1"),sLibName.c_str(),m_lDocNum); pVer->UploadFile( NULL ); pVer->UnlockVersion( DOCSObjects::OF_NORMAL ); pBaseProf->ReleaseDoc(); m_vDocIDs.push_back(sTestDocID); } catch(_com_error& e) { CStdString sMsg; sMsg.Format(_T("Save document failed : %s"), (const TCHAR*)e.Description()); throw std::exception(CStdStringA(sMsg)); } }
void CPDTestHelper::SaveDocument(const CStdString& sDocumentName, const CStdString& sAppID, CStdString& sTestDocID) { USES_CONVERSION; DOCSObjects::IApplicationPtr pApp( __uuidof( DOCSObjects::Application )); pApp->PutDefParentWindow( 0 ); DOCSObjects::ILibrariesPtr pLibs = pApp->GetLibraries(); DOCSObjects::ILibraryPtr pLib = pApp->GetCurrentLibrary(); DOCSObjects::IDOCSFormsPtr pForms = pLib->GetForms(); DOCSObjects::IProfilePtr pBaseProf = NULL; DOCSObjects::IDOCSFormPtr pForm = NULL; int iCount = pForms->GetCount(); bool bFoundProf = FALSE; _variant_t vtIndex; vtIndex.vt = VT_I4; for (vtIndex.lVal = 1; (vtIndex.lVal <= iCount) && (!bFoundProf); vtIndex.lVal++) { pForm = pForms->GetItem(vtIndex); if (pForm->GetType() & DOCSObjects::FT_DEFAULT_PROFILE) { // ATLTRACE("Found default form,\n"); // ATLTRACE("Form %2.2d, Type = 0x%02x, Name = %s\n", vtIndex.lVal, pForm->GetType(), (LPCTSTR) pForm->GetName()); pBaseProf = pLib->CreateProfile(pForm->GetName()); bFoundProf = TRUE; } } // TT - I assume that there should always be a default profile // but lets protect ourselves anyway. if (pBaseProf == NULL) { // ATLTRACE("No default form, Default form type = 0x%02X\n", FT_DEFAULT_PROFILE); pBaseProf = pLib->CreateProfile( _bstr_t( _T("LAWPROF") )); } DOCSObjects::IColumnsPtr pCols = pBaseProf->GetColumns(); DOCSObjects::IColumnPtr pCol = pCols->GetItem( _variant_t( _T("APP_ID") )); pCol->PutValue( _variant_t( T2CW(sAppID.c_str()) ) ); pCol = pCols->GetItem( _variant_t( _T("DOCNAME") )); pCol->PutValue( _variant_t( sDocumentName.c_str() ) ); pCol = pCols->GetItem( _variant_t( _T("TYPE_ID") )); pCol->PutValue( _variant_t( L"MEMO")); pCol = pCols->GetItem( L"AUTHOR_ID"); pCol->PutValue(L"pair"); pCol = pCols->GetItem(L"TYPIST_ID"); pCol->PutValue(L"pair"); pCol = pCols->GetItem(L"CLIENT_ID"); pCol->PutValue(L"TEST"); pCol = pCols->GetItem(L"MATTER_ID"); pCol->PutValue(L"TEST"); VARIANT_BOOL vb = pBaseProf->Save( DOCSObjects::OF_NORMAL ); assertTest(vb); DOCSObjects::IVersionPtr pVer = pBaseProf->GetCurrentVersion(); BSTR sFilePath = pVer->GetFilePath(); CStdString sDest(sFilePath); SysFreeString(sFilePath); bool bSuccess = false; if (sAppID.CompareNoCase(_T("ACROBAT")) == 0) { bSuccess = (CopyFile(TEST_PDF_FILE,sDest.c_str(),false)!=0); } else { bSuccess = (CopyFile(TEST_DOC_FILE,sDest.c_str(),false)!=0); } assertTest(bSuccess); LONG lDocID = pBaseProf->GetDocNumber(); BSTR bsLibName = pLib->GetName(); CStdString sLibName(bsLibName); SysFreeString(bsLibName); sTestDocID.Format(_T("PowerDocs://%s/%d/1"),sLibName.c_str(),lDocID); pVer->UploadFile( NULL ); pVer->UnlockVersion( DOCSObjects::OF_NORMAL ); pBaseProf->ReleaseDoc(); }
HRESULT CPDTestHelper::GetDocumentProfile(const CStdString& sTestDocID, DOCSObjects::IProfilePtr& pProf) { TCHAR szDocID[ MAX_PATH ]; TCHAR szDMSId[ MAX_PATH ]; TCHAR szLibName[ MAX_PATH ]; TCHAR szVerLabel[ MAX_PATH ]; LONG nDocnum = 0; HRESULT hr = E_FAIL; if (sTestDocID.CompareNoCase(_T("")) == 0) { return(E_INVALIDARG); } try { if(sTestDocID.IsEmpty()) return E_INVALIDARG; _tcsncpy(szDocID, sTestDocID.c_str(), MAX_PATH); TCHAR szSeps[] = _T("\\/:"); TCHAR* szTok = _tcstok( szDocID, szSeps ); _tcsncpy( szDMSId, szTok, MAX_PATH ); szTok = _tcstok( NULL, szSeps ); int n = 0; while( szTok != NULL ) { switch( n++ ) { case 0: _tcsncpy( szLibName, szTok, MAX_PATH ); break; case 1: nDocnum = _ttoi( szTok ); break; case 2: _tcsncpy( szVerLabel, szTok, MAX_PATH ); break; default: break; } szTok = _tcstok( NULL, szSeps ); } DOCSObjects::IApplicationPtr pApp( __uuidof( DOCSObjects::Application )); DOCSObjects::ILibrariesPtr pLibs = NULL; hr = pApp->get_Libraries(&pLibs); RETURN_FAILED_HR(hr,_T("Unable to get libraries from application"), szDocID); DOCSObjects::ILibraryPtr pLib = NULL; _variant_t vIndex = szLibName; hr = pLibs->get_Item(vIndex, &pLib); RETURN_FAILED_HR(hr, _T("Unable to get library"), szDocID); _variant_t vDoc = nDocnum; hr = pLib->raw_GetProfile(vDoc, &pProf); RETURN_FAILED_HR(hr, _T("Unable to get profile for document"), szDocID); } catch(_com_error e) { hr = e.Error(); RETURN_FAILED_HR(hr, _T("GetVersionFromDocID threw up a com error:"), e.ErrorMessage()) } return hr; }