//+------------------------------------------------------------------------ // // Microsoft Windows // Copyright (C) Microsoft Corporation, 1993. // // File: bm_Clip.cxx // // Contents: Contains the impl of CClipbrdTest which deals with // Clipboard related apis. // // Classes: CClipbrdTest // // Functions: // // History: Doesn't work yet. The code to place data on the clipboard // uses autoamation which isn't supported in the server. // //-------------------------------------------------------------------------- #include #pragma hdrstop #include "hlp_util.hxx" #include "hlp_iocs.hxx" #include "hlp_ias.hxx" #include "hlp_app.hxx" #include "hlp_site.hxx" #include "hlp_doc.hxx" #include "bm_Clip.hxx" #include //********************************************************************** // // CClipbrd::Name, SetUp, Run, CleanUp // // Purpose: // // These routines provide the implementation for the Name, Setup, // Run and CleanUp of the class CClipbrd. For details see the doc // for driver what are these routines supposed to do. // // Parameters: // // // Return Value: // // None // // // Comments: // If STRESS is defined don't do anything with timer variable! We are // not interested in time values. // //******************************************************************** TCHAR *CClipbrdTest::Name () { return TEXT("ClipbrdTest"); } SCODE CClipbrdTest::Setup (CTestInput *pInput) { CTestBase::Setup(pInput); HRESULT sc; HRESULT hres; #ifdef STRESS //If stress condition loop number of time = STRESSCOUNT m_ulIterations = STRESSCOUNT; #else // get iteration count m_ulIterations = pInput->GetIterations(Name()); #endif // initialize timing arrays #ifndef STRESS INIT_RESULTS(m_ulOleGetClipbrd); INIT_RESULTS(m_ulOleQueryCreate); INIT_RESULTS(m_ulOleQueryLink); INIT_RESULTS(m_ulCreateFromClipOutl); INIT_RESULTS(m_ulCreateFromClipRenderDrawOutl); INIT_RESULTS(m_ulCreateFromClipRenderAsisOutl); INIT_RESULTS(m_ulCreateLinkFromClipOutl); INIT_RESULTS(m_ulCreateLinkFromClipRenderDrawOutl); INIT_RESULTS(m_ulCreateStaticFromClipRenderDrawOutl); INIT_RESULTS(m_ulCreateStaticFromClipRenderDrawBMOutl); #endif //STRESS sc = OleInitialize(NULL); if (FAILED(sc)) { Log (TEXT("Setup - OleInitialize failed."), sc); return sc; } hres = CLSIDFromString(OutlineClassName, &m_clsidOutl); Log (TEXT("CLSIDFromString returned ."), hres); assert (hres == NOERROR); //Create root Doc and STorage for Doc m_lpDoc = CSimpleDoc::Create(); //Create Individual Objects and Init the table for (ULONG iIter=0; iIterBindToObject(pbc, NULL, IID_IDispatch, (LPVOID FAR*) &pDisp); if (hres != NOERROR) goto error; //Now Make outline copy object to clipboard OLECHAR FAR* pCopy = L"COPY"; DISPID dispid; EXCEPINFO expinfo; DISPPARAMS vNullDisp = {NULL, 0, 0, NULL}; hres = pDisp->GetIDsOfNames( IID_NULL, &pCopy, 1, LOCALE_USER_DEFAULT, &dispid); if (hres == NOERROR) { //Invoke Method Copy so that SvrOutl copies data to clipboard hres = pDisp->Invoke( dispid, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &vNullDisp, NULL, &expinfo, NULL); if (hres != NOERROR) goto error; } pDisp->Release(); pDisp = NULL; } for ( iIter=0; iIterRelease(); pDO = NULL; } } retVal = TRUE; error: if (hres != NOERROR) Log (TEXT("Routine OleGetClipbrd failed with hres = "), hres); if (pmk) pmk->Release(); if (pDO) pDO->Release(); if (pbc) pbc->Release(); if (pDisp) pDisp->Release(); return retVal; } //********************************************************************** // // CallCreateFromClip // // Purpose: // This routine creates the OLE object from Clipboard data. It creates // both embedded and linked object. // // // Parameters: // // // Return Value: // // None // // Functions called: // CreateFileMoniker OLE - creates file moniker // CreateBindCtx OLE // IDispatch::GetIDsOfNames Dispatch routine which makes call into SvrOutl (yet another version!) // IDispatch::Invoke Dispatch routine asking Svroutl to copy to clipboard // OleGetClipboard OLE - called to get Data object on Clip // OleCreateFromData OLE - Is profiled here // OleCreateLinkFromData OLE - Is profiled here // OleCreateStaticFromData OLE - Is profiled here // // // Comments: // //******************************************************************** BOOL CallCreateFromClip(LPCOLESTR lpFileName, CSimpleSite * pSite[], REFIID riid, DWORD renderopt, LPFORMATETC pFormatEtc, ULONG ulIterations, ULONG uOleClipbrdtime[], CREATE_METHOD MethodID) { CStopWatch sw; HRESULT hres; ULONG iIter; BOOL retVal = FALSE; LPDATAOBJECT pDO = NULL; LPMONIKER pmk = NULL; LPBC pbc = NULL; IDispatch FAR* pDisp = NULL; hres = CreateFileMoniker(lpFileName, &pmk); if (hres != NOERROR) goto error; else { //Bind to moniker object and ask for IID_IDispatch hres = CreateBindCtx(NULL, &pbc); if (hres != NOERROR) goto error; hres = pmk->BindToObject(pbc, NULL, IID_IDispatch, (LPVOID FAR*)&pDisp); if (hres != NOERROR) goto error; //Now Make outline copy object to clipboard OLECHAR FAR* pCopy = L"COPY"; DISPID dispid; EXCEPINFO expinfo; DISPPARAMS vNullDisp = {NULL, 0, 0, NULL}; hres = pDisp->GetIDsOfNames( IID_NULL, &pCopy, 1, LOCALE_USER_DEFAULT, &dispid); if (hres == NOERROR) { hres = pDisp->Invoke( dispid, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &vNullDisp, NULL, &expinfo, NULL); if (hres != NOERROR) goto error; } pDisp->Release(); pDisp = NULL; } //Get the Clipboard data hres = OleGetClipboard(&pDO); if (hres != NOERROR) goto error; for ( iIter=0; iIterm_OleClientSite, pSite[iIter]->m_lpObjStorage, (VOID FAR* FAR*)&pSite[iIter]->m_lpOleObject); break; } case OLECREATELINK: { sw.Reset(); hres = OleCreateLinkFromData(pDO, riid, renderopt, pFormatEtc, &pSite[iIter]->m_OleClientSite, pSite[iIter]->m_lpObjStorage, (VOID FAR* FAR*)&pSite[iIter]->m_lpOleObject); break; } case OLECREATESTATIC: { sw.Reset(); hres = OleCreateStaticFromData(pDO, riid, renderopt, pFormatEtc, &pSite[iIter]->m_OleClientSite, pSite[iIter]->m_lpObjStorage, (VOID FAR* FAR*)&pSite[iIter]->m_lpOleObject); break; } default: assert(FALSE); } GetTimerVal(uOleClipbrdtime[iIter]); LOGRESULTS (TEXT("OleCreate/Link/Static "), hres); if (hres != NOERROR) { goto error; } } for (iIter=0; iIterUnloadOleObject(); } retVal = TRUE; error: if (hres != NOERROR) Log (TEXT("Routine CallCreateFromClip failed with hres = "), hres); if (pmk) pmk->Release(); if (pDO) pDO->Release(); if (pbc) pbc->Release(); if (pDisp) pDisp->Release(); return retVal; }