STDMETHODIMP CDocProvider::GetErrorDescription(LONG lError, VARIANT varStringInsert, BSTR *pszErrorText) { COM_METHOD_TRY CResourceSwapper rs(_Module.m_hInstResource); HRESULT hRes = S_OK; *pszErrorText = NULL; if (HRESULT_FACILITY(lError) != WSDOC) hRes = E_NOTIMPL; else { CStdString sError =CErrorTranslator::GetWSDocProvErrorDescription(lError); if(sError.IsEmpty()) { hRes = E_FAIL; } else *pszErrorText = sError.AllocSysString(); } if (hRes == E_NOTIMPL) { if (FAILED(VerifyConnection(_T(""), false, false))) return E_FAIL; CStdString sError = CErrorTranslator::GetErrorDescriptionFromDocProvider(lError, m_mapProviders, m_pCurrentDocumentProvider); *pszErrorText = sError.AllocSysString(); hRes = S_OK; } return hRes; COM_METHOD_CATCH }
void TestCOMLayer::TestRelateSynergyDocument() { CStdString csDocumentID = _T("Bug of the Century"); BSTR bsDocumentId = csDocumentID.AllocSysString(); WSDocNonCom wsdDocIn; wsdDocIn.SetAuthor(CStdString(_T("Alfie"))); wsdDocIn.SetClass(CStdString(_T("PreSchool"))); wsdDocIn.SetDescription(CStdString(_T("Short and fluffy"))); wsdDocIn.SetDocId(CStdString(_T("afnb"))); wsdDocIn.SetExtension(CStdString(_T("Dummy"))); wsdDocIn.SetFileSizehigh(24); wsdDocIn.SetFileSizeLow(2); wsdDocIn.SetFlags(0x54407); wsdDocIn.SetLocalFile(CStdString(_T("Tractor"))); wsdDocIn.SetModifiedTime(20011127.080230); wsdDocIn.SetOperator(CStdString(_T("Keith"))); wsdDocIn.SetType(CStdString(_T("Boy"))); LOCALFILESTORELib::tagWSDOCUMENT wsDoc; wsdDocIn.InitializeWSDOCUMENT((WSDOCUMENT*)&wsDoc); WSDOCUMENTPROVIDERLib::ISynergyDocumentRelatorPtr pRel = m_pLFS; HRESULT hr = pRel->raw_RelateSynergyDocument((WSDOCUMENTPROVIDERLib::tagWSDOCUMENT*)&wsDoc, bsDocumentId); assertTest(hr == S_TEST); assertTest(m_pWorker->m_sLastMethodCalled == _T("RelateSynergyDocument")); assertTest(wsdDocIn == m_pWorker->m_wsd); assertTest(m_pWorker->m_sDocumentID == csDocumentID); SysFreeString(bsDocumentId); }
HRESULT DocProvHelper::CanPromote(CStdString sDocID) { if (m_pCurrentDocumentProvider==NULL) return E_NO_PROVIDER_SELECTED; else { CComPtr<IWSDocumentProvider3> pDocProvider3; long lLockStatus; BSTR szUser = NULL; _bstr_t sDocument = sDocID.AllocSysString(); HRESULT hRes = m_pCurrentDocumentProvider->QueryInterface(IID_IWSDocumentProvider3, (void**)&pDocProvider3); if(FAILED(hRes)) return hRes; HRESULT hr = pDocProvider3->GetDocumentLockStatus(sDocument,&lLockStatus,&szUser); if(szUser != NULL) ::SysFreeString(szUser); if(FAILED(hr)) return hr; return GetReturnResultFromLockStatus(lLockStatus); } return E_FAIL; }
void TestCOMLayer::TestSelectDocumentEx() { CStdString sFormatString = _T("Weebles wobble but they don't fall down"); BSTR bsFormat = sFormatString.AllocSysString(); CStdString csCurrentDocumentID = _T("This document has a name. It's not just a number."); BSTR bsCurrentDocumentID = csCurrentDocumentID.AllocSysString(); BSTR bsDocumentID = NULL; HRESULT hr = m_pLFS->raw_SelectDocumentEx(4816100, bsFormat, bsCurrentDocumentID, &bsDocumentID); assertTest(hr == S_TEST); assertTest(m_pWorker->m_sLastMethodCalled == _T("SelectDocumentEx")); assertTest(CStdString(bsDocumentID) == m_pWorker->m_sDocumentIDToReturn); assertTest(csCurrentDocumentID == m_pWorker->m_sDocumentID); assertTest(m_pWorker->m_sFormatString == sFormatString); assertTest(m_pWorker->m_hwnd == (HWND)4816100); SysFreeString(bsFormat); SysFreeString(bsDocumentID); SysFreeString(bsCurrentDocumentID); }
void TestCOMLayer::TestVersionDocument() { CStdString csDocumentID = _T("Weebles wobble but they don't fall down"); BSTR bsDocumentID = csDocumentID.AllocSysString(); CStdString csComment = _T("What am I supposed to say?"); BSTR bsComment = csComment.AllocSysString(); HRESULT hr = m_pLFS->raw_VersionDocument(&bsDocumentID, bsComment); assertTest(hr == S_TEST); assertTest(m_pWorker->m_sLastMethodCalled == _T("VersionDocument")); assertTest(m_pWorker->m_sDocumentID == csDocumentID); assertTest(CStdString(bsDocumentID) == m_pWorker->m_sDocumentIDToReturn); assertTest(m_pWorker->m_sComment == csComment); SysFreeString(bsDocumentID); SysFreeString(bsComment); }
void TestCOMLayer::TestDeleteDocument() { CStdString csDocumentID = _T("Weebles wobble but they don't fall down"); BSTR bsDocumentID = csDocumentID.AllocSysString(); HRESULT hr = m_pLFS->raw_DeleteDocument(bsDocumentID); assertTest(hr == S_TEST); assertTest(m_pWorker->m_sLastMethodCalled == _T("DeleteDocument")); assertTest(m_pWorker->m_sDocumentID == csDocumentID); SysFreeString(bsDocumentID); }
void TestCOMLayer::TestSetCallingApplication() { CStdString csApplicationName = _T("Lego"); BSTR bsApplicationName = csApplicationName.AllocSysString(); HRESULT hr = m_pLFS->raw_SetCallingApplication(bsApplicationName); assertTest(hr == S_TEST); assertTest(m_pWorker->m_sLastMethodCalled == _T("SetCallingApplication")); assertTest(m_pWorker->m_sApplication == csApplicationName); SysFreeString(bsApplicationName); }
void TestCOMLayer::TestLockDocumentAsOtherUser() { CStdString csDocumentID = _T("Noggin the Nog"); CStdString csUserName = _T("Nogbad the Bad"); CStdString csPassword = _T("Zebedee"); BSTR bsDocumentID = csDocumentID.AllocSysString(); BSTR bsUserName = csUserName.AllocSysString(); BSTR bsPassword = csPassword.AllocSysString(); HRESULT hr = m_pLFS->raw_LockDocumentAsOtherUserForTesting(bsDocumentID, bsUserName, bsPassword, 666); assertTest(hr == S_TEST); assertTest(m_pWorker->m_sLastMethodCalled == _T("LockDocumentAsOtherUser")); assertTest(m_pWorker->m_sDocumentID == csDocumentID); assertTest(m_pWorker->m_sUserName == csUserName); assertTest(m_pWorker->m_sPassword == csPassword); assertTest(m_pWorker->m_lFlags == 666); SysFreeString(bsDocumentID); SysFreeString(bsUserName); SysFreeString(bsPassword); }
void PrintManager::PopulateBSTRWithPageInfo(BSTR* pBSTR, int* pages, int nSize) { std::vector<int> vecNoOfPages; for(int i = 0; i<nSize; i++) { vecNoOfPages.push_back(pages[i]); } CStdString sPages = PrintManagerHelper::FormatPageNumbers(vecNoOfPages); (*pBSTR) = sPages.AllocSysString(); }
void TestCOMLayer::TestDisplayProfile() { CStdString csDocumentID = _T("Weebles wobble but they don't fall down"); BSTR bsDocumentID = csDocumentID.AllocSysString(); HRESULT hr = m_pLFS->raw_DisplayProfile(bsDocumentID, 329); assertTest(hr == S_TEST); assertTest(m_pWorker->m_sLastMethodCalled == _T("DisplayProfile")); assertTest(m_pWorker->m_sDocumentID == csDocumentID); assertTest(m_pWorker->m_lFlags == 329); SysFreeString(bsDocumentID); }
CStdString DMTests_Helper::VersionTestDoc(CStdString sTestDocID) { BSTR bsDocID = sTestDocID.AllocSysString(); HRESULT hr = GetDocProvider2()->VersionDocument(&bsDocID, _T("Test comment")); if(FAILED(hr)) { throw std::exception("Failed to version the test document in the DMS"); } return bsDocID; }
void TestCOMLayer::TestGetLatestVersion() { CStdString csDocumentID = _T("Weebles wobble but they don't fall down"); BSTR bsDocumentID = csDocumentID.AllocSysString(); HRESULT hr = m_pLFS->raw_GetLatestVersion(&bsDocumentID); assertTest(hr == S_TEST); assertTest(m_pWorker->m_sLastMethodCalled == _T("GetLatestVersion")); assertTest(m_pWorker->m_sDocumentID == csDocumentID); assertTest(CStdString(bsDocumentID) == m_pWorker->m_sDocumentIDToReturn); SysFreeString(bsDocumentID); }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TESTS void TestCOMLayer::TestSelectDocument() { CStdString sFormatString = _T("Weebles wobble but they don't fall down"); BSTR bsFormat = sFormatString.AllocSysString(); BSTR bsDocumentID = NULL; HRESULT hr = m_pLFS->raw_SelectDocument(23, bsFormat, &bsDocumentID); assertTest(hr == S_TEST); assertTest(m_pWorker->m_sLastMethodCalled == _T("SelectDocument")); assertTest(CStdString(bsDocumentID) == m_pWorker->m_sDocumentIDToReturn); assertTest(m_pWorker->m_sFormatString == sFormatString); assertTest(m_pWorker->m_hwnd == (HWND)23); SysFreeString(bsFormat); SysFreeString(bsDocumentID); }
void TestCOMLayer::TestAddHistoryEvent() { CStdString csApplicationName = _T("Lego"); BSTR bsApplicationName = csApplicationName.AllocSysString(); CStdString csDocumentID = _T("Weebles wobble but they don't fall down"); BSTR bsDocumentID = csDocumentID.AllocSysString(); CStdString csComment = _T("What am I supposed to say?"); BSTR bsComment = csComment.AllocSysString(); HRESULT hr = m_pLFS->raw_AddHistoryEvent(bsDocumentID, 11, 22, 33, bsApplicationName, bsComment); assertTest(hr == S_TEST); assertTest(m_pWorker->m_sLastMethodCalled == _T("AddHistoryEvent")); assertTest(m_pWorker->m_sApplication == csApplicationName); assertTest(m_pWorker->m_sDocumentID == csDocumentID); assertTest(m_pWorker->m_sComment == csComment); assertTest(m_pWorker->m_lAcitivity == 11); assertTest(m_pWorker->m_lDuration == 22); assertTest(m_pWorker->m_lPagesPrinted == 33); SysFreeString(bsApplicationName); SysFreeString(bsDocumentID); SysFreeString(bsComment); }
void TestCOMLayer::TestGetDocumentLockStatus() { CStdString csDocumentID = _T("Weebles wobble but they don't fall down"); BSTR bsDocumentID = csDocumentID.AllocSysString(); long lLockStatus = 0; BSTR bsUser = NULL; HRESULT hr = m_pLFS->raw_GetDocumentLockStatus(bsDocumentID, &lLockStatus, &bsUser); assertTest(hr == S_TEST); assertTest(m_pWorker->m_sLastMethodCalled == _T("GetDocumentLockStatus")); assertTest(lLockStatus == m_pWorker->m_lLockStatusToReturn); assertTest(CStdString(bsUser) == m_pWorker->m_sUserToReturn); SysFreeString(bsDocumentID); SysFreeString(bsUser); }
void TestCOMLayer::TestGetDocument() { CStdString csDocumentID = _T("Weebles wobble but they don't fall down"); BSTR bsDocumentID = csDocumentID.AllocSysString(); LOCALFILESTORELib::tagWSDOCUMENT wsDoc; ZeroMemory(&wsDoc, sizeof(wsDoc)); HRESULT hr = m_pLFS->raw_GetDocument(bsDocumentID, 28, &wsDoc); assertTest(hr == S_TEST); assertTest(m_pWorker->m_sLastMethodCalled == _T("GetDocument")); assertTest(WSDocNonCom((WSDOCUMENT*)(&wsDoc)) == m_pWorker->m_wsdToReturn); assertTest(m_pWorker->m_sDocumentID == csDocumentID); assertTest(m_pWorker->m_lFlags == 28); SysFreeString(bsDocumentID); }
void TestCOMLayer::TestGetRelatedSynergyDocuments() { CStdString csDocumentID = _T("Bug of the Century"); BSTR bsDocumentId = csDocumentID.AllocSysString(); long lSize = 0; LOCALFILESTORELib::tagWSDOCUMENT *ppwsDocument=NULL; WSDOCUMENTPROVIDERLib::ISynergyDocumentRelatorPtr pRel = m_pLFS; HRESULT hr = pRel->raw_GetSynergyRelatedDocuments(bsDocumentId, &lSize, (WSDOCUMENTPROVIDERLib::tagWSDOCUMENT**)&ppwsDocument); assertTest(hr == S_TEST); assertTest(m_pWorker->m_sLastMethodCalled == _T("GetSynergyRelatedDocuments")); assertTest(m_pWorker->m_sDocumentID == csDocumentID); assertTest(lSize == 1); assertTest(ppwsDocument != NULL) ; FreeWSDocumentStrings(ppwsDocument[0]); CoTaskMemFree(ppwsDocument); SysFreeString(bsDocumentId); }
void TestCOMLayer::TestGetSaveInfo() { LOCALFILESTORELib::tagWSDOCUMENT wsDoc; ZeroMemory(&wsDoc, sizeof(wsDoc)); CStdString csFormatString = _T("blah blah | .blah |"); BSTR bsFormat = csFormatString.AllocSysString(); long lFormatIndex = 3; HRESULT hr = m_pLFS->raw_GetSaveInfo(543, bsFormat, 4, &lFormatIndex, &wsDoc); assertTest(hr == S_TEST); assertTest(m_pWorker->m_sLastMethodCalled == _T("GetSaveInfo")); assertTest(WSDocNonCom((WSDOCUMENT*)(&wsDoc)) == m_pWorker->m_wsdToReturn); assertTest(m_pWorker->m_hwnd == (HWND)543); assertTest(m_pWorker->m_sFormatString == csFormatString); assertTest(m_pWorker->m_lFlags == 4); assertTest(m_pWorker->m_lBrand == WsDefault); assertTest(lFormatIndex == m_pWorker->m_lIndexToReturn); SysFreeString(bsFormat); }
void TestCOMLayer::TestGetVersions() { CStdString csDocumentID = _T("Bug of the Century"); BSTR bsDocumentId = csDocumentID.AllocSysString(); long lSize = 0; LOCALFILESTORELib::tagWSDOCUMENTVERSION *ppwsDocument=NULL; HRESULT hr = m_pLFS->raw_GetVersions(bsDocumentId, &lSize, &ppwsDocument); assertTest(hr == S_TEST); assertTest(m_pWorker->m_sLastMethodCalled == _T("GetVersions")); assertTest(m_pWorker->m_sDocumentID == csDocumentID); assertTest(lSize == 1); assertTest(ppwsDocument != NULL) ; SysFreeString(ppwsDocument[0].szVersionLabel); FreeWSDocumentStrings(ppwsDocument[0].wsdDocumentDetails); CoTaskMemFree(ppwsDocument); SysFreeString(bsDocumentId); }
BSTR ComConvertUtils::CStdStringtoBSTR(const CStdString& cs) { return cs.AllocSysString(); }