예제 #1
1
// @pymethod int|PyIDropTarget|DragEnter|Called when an object is initially dragged into a window
// @rdesc Your implementation of this function should return a shellcon.DROPEFFECT_* value indicating if the object can be accepted
PyObject *PyIDropTarget::DragEnter(PyObject *self, PyObject *args)
{
	IDropTarget *pIDT = GetI(self);
	if ( pIDT == NULL )
		return NULL;
	// @pyparm <o PyIDataObject>|pDataObj||IDataObject interface that contains the object being dragged
	// @pyparm int|grfKeyState||Combination of win32con.MK_* flags containing keyboard modifier state
	POINTL pt;
	PyObject *obpt;
	// @pyparm (int, int)|pt||(x,y) Screen coordinates of cursor
	PyObject *obpDataObj;
	IDataObject *pDataObj;
	DWORD grfKeyState;
        DWORD dwEffect;
	// @pyparm int|pdwEffect||shellcon.DROPEFFECT_* value
	if ( !PyArg_ParseTuple(args, "OlOl:DragEnter", &obpDataObj, &grfKeyState, &obpt, &dwEffect) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obpDataObj, IID_IDataObject, (void **)&pDataObj, TRUE /* bNoneOK */))
		 bPythonIsHappy = FALSE;
	if (bPythonIsHappy && !PyObject_AsPOINTL( obpt, &pt )) bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIDT->DragEnter( pDataObj, grfKeyState, pt, &dwEffect );
	if (pDataObj) pDataObj->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIDT, IID_IDropTarget );
	return PyInt_FromLong(dwEffect);
}
예제 #2
0
//-------------------------------------------------------------------------
NS_IMETHODIMP nsClipboard::SetNativeClipboardData ( PRInt32 aWhichClipboard )
{
  if ( aWhichClipboard != kGlobalClipboard )
    return NS_ERROR_FAILURE;

  mIgnoreEmptyNotification = true;

  // make sure we have a good transferable
  if (nullptr == mTransferable) {
    return NS_ERROR_FAILURE;
  }

  IDataObject * dataObj;
  if ( NS_SUCCEEDED(CreateNativeDataObject(mTransferable, &dataObj, NULL)) ) { // this add refs dataObj
    ::OleSetClipboard(dataObj);
    dataObj->Release();
  } else {
    // Clear the native clipboard
    ::OleSetClipboard(NULL);
  }

  mIgnoreEmptyNotification = false;

  return NS_OK;
}
예제 #3
0
// @pymethod |PyIOleObject|InitFromData|Description of InitFromData.
PyObject *PyIOleObject::InitFromData(PyObject *self, PyObject *args)
{
	IOleObject *pIOO = GetI(self);
	if ( pIOO == NULL )
		return NULL;
	// @pyparm <o PyIDataObject>|pDataObject||Description for pDataObject
	// @pyparm int|fCreation||Description for fCreation
	// @pyparm int|dwReserved||Description for dwReserved
	PyObject *obpDataObject;
	IDataObject * pDataObject;
	BOOL fCreation;
	DWORD dwReserved;
	if ( !PyArg_ParseTuple(args, "Oii:InitFromData", &obpDataObject, &fCreation, &dwReserved) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (!PyCom_InterfaceFromPyInstanceOrObject(obpDataObject, IID_IDataObject, (void **)&pDataObject, TRUE /* bNoneOK */))
		 bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIOO->InitFromData( pDataObject, fCreation, dwReserved );
	if (pDataObject) pDataObject->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return OleSetOleError(hr);
	Py_INCREF(Py_None);
	return Py_None;

}
예제 #4
0
// @pymethod <o PySTGMEDIUM>|PyIDataObject|GetData|Retrieves data from the object in specified format
PyObject *PyIDataObject::GetData(PyObject *self, PyObject *args)
{
	IDataObject *pIDO = GetI(self);
	if ( pIDO == NULL )
		return NULL;
	FORMATETC formatetcIn;
	PyObject *obpformatetcIn;
	// @pyparm <o PyFORMATETC>|pformatetcIn||Tuple representing a FORMATETC struct describing how the data should be returned
	if ( !PyArg_ParseTuple(args, "O:GetData", &obpformatetcIn) )
		return NULL;

	PySTGMEDIUM *pymedium = PyObject_FromSTGMEDIUM();
	BOOL bPythonIsHappy = TRUE;
	if (bPythonIsHappy && !PyObject_AsFORMATETC( obpformatetcIn, &formatetcIn )) bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIDO->GetData( &formatetcIn, &pymedium->medium);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) ) {
		Py_DECREF(pymedium);
		return PyCom_BuildPyException(hr, pIDO, IID_IDataObject );
	}
	return pymedium;
}
예제 #5
0
// @pymethod |PyIDataObject|SetData|Sets the data that the object will return.
PyObject *PyIDataObject::SetData(PyObject *self, PyObject *args)
{
	IDataObject *pIDO = GetI(self);
	if ( pIDO == NULL )
		return NULL;
	FORMATETC formatetc;
	PyObject *obpformatetc;
	// @pyparm <o PyFORMATETC>|pformatetc||Tuple representing a FORMATETC struct describing the type of data to be set
	PyObject *obmedium;
	PySTGMEDIUM *pymedium;
	// @pyparm <o PySTGMEDIUM>|pmedium||The data to be placed in the object
	// @pyparm boolean|fRelease||If True, transfers ownership of the data to the object.  If False, caller is responsible for releasing the STGMEDIUM.
	BOOL fRelease;
	if ( !PyArg_ParseTuple(args, "OOi:SetData", &obpformatetc, &obmedium, &fRelease) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (bPythonIsHappy && !PyObject_AsFORMATETC( obpformatetc, &formatetc )) bPythonIsHappy = FALSE;
	if (bPythonIsHappy && !PyObject_AsPySTGMEDIUM( obmedium, &pymedium )) bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIDO->SetData( &formatetc, &pymedium->medium, fRelease );
	PY_INTERFACE_POSTCALL;
	if (fRelease)
		pymedium->DropOwnership();
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIDO, IID_IDataObject );
	Py_INCREF(Py_None);
	return Py_None;
}
예제 #6
0
HRESULT CDataObjectViewer::OnView(HWND hwndParent, REFIID riid, LPUNKNOWN punk)
{
	SCODE sc = NOERROR ;

	ASSERT(hwndParent);
	ENSURE(punk);

	if (riid != IID_IDataObject)
	{
		AfxMessageBox( _T("IDataObject interface viewer only supports IID_IDataObject") ) ;
		return E_INVALIDARG ;
	}

	IDataObject* pdataobj = NULL ;
	sc = punk->QueryInterface( riid, (void**)&pdataobj ) ;
	if (FAILED(sc))
	{
		AfxMessageBox( _T("Object does not support IDataObject") ) ;
		return E_UNEXPECTED ;
	}

	CIDataObjectDlg* pdlg ;
	pdlg = new CIDataObjectDlg( hwndParent, pdataobj, riid, _T("") ) ;

	if (pdlg)
	{
		pdlg->DoModal() ;
		delete pdlg ;
	}

	pdataobj->Release() ;

	return sc ;
}
예제 #7
0
// @pymethod int|PyIDataObject|DAdvise|Connects the object to an interface that will receive notifications when its data changes
// @rdesc Returns a unique number that is used to identify the connection
PyObject *PyIDataObject::DAdvise(PyObject *self, PyObject *args)
{
	IDataObject *pIDO = GetI(self);
	if ( pIDO == NULL )
		return NULL;
	FORMATETC formatetc;
	PyObject *obpformatetc;
	// @pyparm <o PyFORMATETC>|pformatetc||Defines the type of data for which the sink will receive notifications.
	// @pyparm int|advf||Combination of values from ADVF enum. (which currently do not appear in any of the constants modules!)
	// @pyparm <o PyIAdviseSink>|pAdvSink||Currently this interface is not wrapped.
	PyObject *obpAdvSink;
	DWORD advf;
	IAdviseSink *pAdvSink;
	if ( !PyArg_ParseTuple(args, "OlO:DAdvise", &obpformatetc, &advf, &obpAdvSink) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (bPythonIsHappy && !PyObject_AsFORMATETC( obpformatetc, &formatetc )) bPythonIsHappy = FALSE;
	if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obpAdvSink, IID_IAdviseSink, (void **)&pAdvSink, TRUE /* bNoneOK */))
		 bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	DWORD dwConnection;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIDO->DAdvise( &formatetc, advf, pAdvSink, &dwConnection );
	PY_INTERFACE_POSTCALL;
	if (pAdvSink) pAdvSink->Release();
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIDO, IID_IDataObject );
	return PyInt_FromLong(dwConnection);
}
예제 #8
0
void ShellDirectory::fill_w32fdata_shell(LPCITEMIDLIST pidl, SFGAOF attribs, WIN32_FIND_DATA* pw32fdata, bool do_access)
{
	CONTEXT("ShellDirectory::fill_w32fdata_shell()");

	if (do_access && !( (attribs&SFGAO_FILESYSTEM) && SUCCEEDED(
				SHGetDataFromIDList(_folder, pidl, SHGDFIL_FINDDATA, pw32fdata, sizeof(WIN32_FIND_DATA))) )) {
		WIN32_FILE_ATTRIBUTE_DATA fad;
		IDataObject* pDataObj;

		STGMEDIUM medium = {0, {0}, 0};
		FORMATETC fmt = {g_Globals._cfStrFName, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};

		HRESULT hr = _folder->GetUIObjectOf(0, 1, &pidl, IID_IDataObject, 0, (LPVOID*)&pDataObj);

		if (SUCCEEDED(hr)) {
			hr = pDataObj->GetData(&fmt, &medium);

			pDataObj->Release();

			if (SUCCEEDED(hr)) {
				LPCTSTR path = (LPCTSTR)GlobalLock(medium.hGlobal);

				 // fill with drive names "C:", ...
				assert(_tcslen(path) < GlobalSize(medium.hGlobal));
				_tcscpy(pw32fdata->cFileName, path);

				UINT sem_org = SetErrorMode(SEM_FAILCRITICALERRORS);

				if (GetFileAttributesEx(path, GetFileExInfoStandard, &fad)) {
					pw32fdata->dwFileAttributes = fad.dwFileAttributes;
					pw32fdata->ftCreationTime = fad.ftCreationTime;
					pw32fdata->ftLastAccessTime = fad.ftLastAccessTime;
					pw32fdata->ftLastWriteTime = fad.ftLastWriteTime;

					if (!(fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
						pw32fdata->nFileSizeLow = fad.nFileSizeLow;
						pw32fdata->nFileSizeHigh = fad.nFileSizeHigh;
					}
				}

				SetErrorMode(sem_org);

				GlobalUnlock(medium.hGlobal);
				GlobalFree(medium.hGlobal);
			}
		}
	}

	if (!do_access || !(attribs&SFGAO_FILESYSTEM))	// Archiv files should not be displayed as folders in explorer view.
		if (attribs & (SFGAO_FOLDER|SFGAO_HASSUBFOLDER))
			pw32fdata->dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;

	if (attribs & SFGAO_READONLY)
		pw32fdata->dwFileAttributes |= FILE_ATTRIBUTE_READONLY;

	if (attribs & SFGAO_COMPRESSED)
		pw32fdata->dwFileAttributes |= FILE_ATTRIBUTE_COMPRESSED;
}
예제 #9
0
	bool ng_playlist_view_t::do_drag_drop(WPARAM wp)
	{
		metadb_handle_list_t<pfc::alloc_fast_aggressive> data;
		m_playlist_api->activeplaylist_get_selected_items(data);
		if (data.get_count() > 0)
		{
			static_api_ptr_t<playlist_incoming_item_filter> incoming_api;
			IDataObject * pDataObject = incoming_api->create_dataobject(data);
			if (pDataObject)
			{
				//IDataObject * pDataObjectFixed = new CDataObject;
#if 0
				mmh::comptr_t<IEnumFORMATETC> pEnumFORMATETC;
				pDataObject->EnumFormatEtc(DATADIR_GET, pEnumFORMATETC.get_pp());

				FORMATETC fe;
				memset(&fe,0,sizeof(fe));
				while (S_OK == pEnumFORMATETC->Next(1, &fe, NULL))
				{
					STGMEDIUM stgm;
					memset(&stgm, 0, sizeof(0));
					if (SUCCEEDED(pDataObject->GetData(&fe, &stgm)))
					{
						//if (stgm.tymed != TYMED_ISTREAM)
						//	pDataObjectFixed->SetData(&fe, &stgm, FALSE);
						ReleaseStgMedium(&stgm);
					}
					memset(&fe,0,sizeof(fe));
				}

				pEnumFORMATETC.release();
#endif
				//pfc::com_ptr_t<IAsyncOperation> pAsyncOperation;
				//HRESULT hr = pDataObject->QueryInterface(IID_IAsyncOperation, (void**)pAsyncOperation.receive_ptr());
				DWORD blah = DROPEFFECT_NONE;
				{
					m_dragging = true;
					m_DataObject = pDataObject;
					m_dragging_initial_playlist = m_playlist_api->get_active_playlist();
					pfc::com_ptr_t<mmh::ole::IDropSource_Generic> p_IDropSource_playlist = new mmh::ole::IDropSource_Generic(get_wnd(), pDataObject, wp);
					HRESULT hr = DoDragDrop(pDataObject,p_IDropSource_playlist.get_ptr(),DROPEFFECT_COPY|DROPEFFECT_MOVE,&blah);
						//SHDoDragDrop(get_wnd(), pDataObject,NULL,DROPEFFECT_COPY|DROPEFFECT_MOVE,&blah);

					m_dragging=false;
					m_DataObject.release();
					m_dragging_initial_playlist = pfc_infinite;

					/*if (DRAGDROP_S_DROP == hr && blah == DROPEFFECT_MOVE)
					m_playlist_api->playlist_remove_selection(playlist);*/
				}
				//pDataObjectFixed->Release();
				pDataObject->Release();
			}
		}
		return true;
	}
예제 #10
0
HRESULT CTextObject::GetClipboard()
{
	IDataObject* pDataObject;
	HRESULT hRes = OleGetClipboard(&pDataObject);
	if (SUCCEEDED(hRes))
	{
		if (! SetObjectText(pDataObject))
			hRes = E_FAIL;
		pDataObject->Release();
	}
	return hRes;
}
예제 #11
0
bool QClipboardWatcher::hasFormat_sys(const QString &mime) const
{
    IDataObject * pDataObj = 0;

    if (OleGetClipboard(&pDataObj) != S_OK && !pDataObj) // Sanity
        return false;

    bool has = QWindowsMime::converterToMime(mime, pDataObj) != 0;

    pDataObj->Release();

    return has;
}
예제 #12
0
QStringList QClipboardWatcher::formats_sys() const
{
    QStringList fmts;
    IDataObject * pDataObj = 0;

    if (OleGetClipboard(&pDataObj) != S_OK && !pDataObj) // Sanity
        return QStringList();

    fmts = QWindowsMime::allMimesForFormats(pDataObj);

    pDataObj->Release();

    return fmts;
}
예제 #13
0
TEST_F(iDataObjectTest, QueryInterface)
{
	IUnknown *pUnknownOut = NULL;
	HRESULT hr = m_pDataObject->QueryInterface(IID_PPV_ARGS(&pUnknownOut));
	EXPECT_EQ(S_OK, hr);

	pUnknownOut->Release();

	IDataObject *pDataObjectOut = NULL;
	hr = m_pDataObject->QueryInterface(IID_PPV_ARGS(&pDataObjectOut));
	EXPECT_EQ(S_OK, hr);

	pDataObjectOut->Release();
}
예제 #14
0
// @pymethod <o PyIEnumSTATDATA>|PyIDataObject|EnumDAdvise|Creates an enumerator to list connected notification sinks.
PyObject *PyIDataObject::EnumDAdvise(PyObject *self, PyObject *args)
{
	IDataObject *pIDO = GetI(self);
	if ( pIDO == NULL )
		return NULL;
	IEnumSTATDATA *ppenumAdvise;
	if ( !PyArg_ParseTuple(args, ":EnumDAdvise") )
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIDO->EnumDAdvise( &ppenumAdvise );
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIDO, IID_IDataObject );
	return PyCom_PyObjectFromIUnknown(ppenumAdvise, IID_IEnumSTATDATA, FALSE);
}
예제 #15
0
파일: pyshellext.cpp 프로젝트: 1st1/cpython
    STDMETHODIMP Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect) {
        LPCWSTR args;

        OutputDebugString(L"PyShellExt::Drop");
        *pdwEffect = DROPEFFECT_NONE;

        if (pDataObj != data_obj) {
            OutputDebugString(L"PyShellExt::Drop - unexpected data object");
            return E_FAIL;
        }

        data_obj->Release();
        data_obj = NULL;

        if (SUCCEEDED(GetArguments(pDataObj, &args))) {
            OutputDebugString(args);
            ShellExecute(NULL, NULL, target, args, target_dir, SW_NORMAL);

            CoTaskMemFree((LPVOID)args);
        } else {
            OutputDebugString(L"PyShellExt::Drop - failed to get launch arguments");
        }

        return S_OK;
    }
예제 #16
0
// Name    : wxIDropTarget::DragEnter
// Purpose : Called when the mouse enters the window (dragging something)
// Returns : S_OK
// Params  : [in]    IDataObject *pIDataSource : source data
//           [in]    DWORD        grfKeyState  : kbd & mouse state
//           [in]    POINTL       pt           : mouse coordinates
//           [in/out]DWORD       *pdwEffect    : effect flag
//                                               In:  Supported effects
//                                               Out: Resulting effect
// Notes   :
STDMETHODIMP wxIDropTarget::DragEnter(IDataObject *pIDataSource,
                                      DWORD        grfKeyState,
                                      POINTL       pt,
                                      DWORD       *pdwEffect)
{
    wxLogTrace(wxTRACE_OleCalls, wxT("IDropTarget::DragEnter"));

    wxASSERT_MSG( m_pIDataObject == NULL,
                  wxT("drop target must have data object") );

    // show the list of formats supported by the source data object for the
    // debugging purposes, this is quite useful sometimes - please don't remove
#if 0
    IEnumFORMATETC *penumFmt;
    if ( SUCCEEDED(pIDataSource->EnumFormatEtc(DATADIR_GET, &penumFmt)) )
    {
        FORMATETC fmt;
        while ( penumFmt->Next(1, &fmt, NULL) == S_OK )
        {
            wxLogDebug(wxT("Drop source supports format %s"),
                       wxDataObject::GetFormatName(fmt.cfFormat));
        }

        penumFmt->Release();
    }
    else
    {
        wxLogLastError(wxT("IDataObject::EnumFormatEtc"));
    }
#endif // 0

    if ( !m_pTarget->MSWIsAcceptedData(pIDataSource) ) {
        // we don't accept this kind of data
        *pdwEffect = DROPEFFECT_NONE;

        return S_OK;
    }

    // for use in OnEnter and OnDrag calls
    m_pTarget->MSWSetDataSource(pIDataSource);

    // get hold of the data object
    m_pIDataObject = pIDataSource;
    m_pIDataObject->AddRef();

    // we need client coordinates to pass to wxWin functions
    if ( !ScreenToClient(m_hwnd, (POINT *)&pt) )
    {
        wxLogLastError(wxT("ScreenToClient"));
    }

    // give some visual feedback
    *pdwEffect = ConvertDragResultToEffect(
        m_pTarget->OnEnter(pt.x, pt.y, ConvertDragEffectToResult(
            GetDropEffect(grfKeyState, m_pTarget->GetDefaultAction(), *pdwEffect))
                    )
                 );

    return S_OK;
}
예제 #17
0
파일: pidl_win.cpp 프로젝트: 3rdexp/fxfile
// IShellFolder + PIDL -> full qualified PIDL
LPITEMIDLIST Pidl::getFullPidl(LPSHELLFOLDER aShellFolder, LPCITEMIDLIST aSimplePidl)
{
    if (XPR_IS_NULL(aShellFolder) || XPR_IS_NULL(aSimplePidl))
    {
        return XPR_NULL;
    }

    LPITEMIDLIST  sFullPidl   = XPR_NULL;
    IDataObject  *sDataObject = XPR_NULL;
    HRESULT       sComResult;

    sComResult = aShellFolder->GetUIObjectOf(0, 1, &aSimplePidl, IID_IDataObject, 0, (LPVOID *)&sDataObject);
    if (SUCCEEDED(sComResult))
    {
        FORMATETC sFormatEtc = {0};
        sFormatEtc.cfFormat = RegisterClipboardFormat(CFSTR_SHELLIDLIST);
        sFormatEtc.ptd      = XPR_NULL;
        sFormatEtc.dwAspect = DVASPECT_CONTENT;
        sFormatEtc.lindex   = -1;
        sFormatEtc.tymed    = TYMED_HGLOBAL;

        STGMEDIUM sStgMedium = {0,};
        sComResult = sDataObject->GetData(&sFormatEtc, &sStgMedium);

        if (SUCCEEDED(sComResult))
        {
            LPIDA sPida = (LPIDA)::GlobalLock(sStgMedium.hGlobal);

            LPCITEMIDLIST sFolderPidl = (LPCITEMIDLIST)((xpr_byte_t *)sPida + sPida->aoffset[0]);
            LPCITEMIDLIST sChildPidl  = (LPCITEMIDLIST)((xpr_byte_t *)sPida + sPida->aoffset[1]);

            sFullPidl = concat(sFolderPidl, sChildPidl);

            ::GlobalUnlock(sStgMedium.hGlobal);

            if (XPR_IS_NOT_NULL(sStgMedium.pUnkForRelease))
            {
                ::ReleaseStgMedium(&sStgMedium);
            }
        }

        COM_RELEASE(sDataObject);
    }

    return sFullPidl;
}
// Other objects querying to see if we support a particular format
STDMETHODIMP nsDataObjCollection::QueryGetData(LPFORMATETC pFE)
{
  UINT format = nsClipboard::GetFormat(MULTI_MIME);

  if (format == pFE->cfFormat) {
    return S_OK;
  }

  for (PRUint32 i = 0; i < mDataObjects.Length(); ++i) {
    IDataObject * dataObj = mDataObjects.ElementAt(i);
    if (S_OK == dataObj->QueryGetData(pFE)) {
      return S_OK;
    }
  }

  return DV_E_FORMATETC;
}
예제 #19
0
static void* sWin32_Get_Callback(void* iParam)
	{
	ZTuple* result = static_cast<ZTuple*>(iParam);

	IDataObject* theIDataObject;
	HRESULT theHRESULT = ::OleGetClipboard(&theIDataObject);
	if (SUCCEEDED(theHRESULT))
		{
		*result = ZDragClip_Win_DataObject::sAsTuple(theIDataObject);
		theIDataObject->Release();
		}
	else
		{
		result->Clear();
		}
	return nil;
	}
예제 #20
0
QVariant QClipboardWatcher::retrieveData_sys(const QString &mimeType, QVariant::Type type) const
{
    QVariant result;
    IDataObject * pDataObj = 0;

    if (OleGetClipboard(&pDataObj) != S_OK && !pDataObj) // Sanity
        return result;

    QWindowsMime *converter = QWindowsMime::converterToMime(mimeType, pDataObj);

    if (converter)
        result = converter->convertToMime(mimeType, pDataObj, type);

    pDataObj->Release();

    return result;
}
예제 #21
0
TEST(iDataObjectTest,Simple)
{
	IDataObject *pDataObject = NULL;
	CreateDataObject(NULL,NULL,&pDataObject,0);

	FORMATETC ftc;
	ftc.cfFormat	= CF_TEXT;
	ftc.dwAspect	= DVASPECT_CONTENT;
	ftc.lindex		= -1;
	ftc.ptd			= NULL;
	ftc.tymed		= TYMED_HGLOBAL;
	EXPECT_EQ(DV_E_FORMATETC,pDataObject->QueryGetData(&ftc));

	EXPECT_EQ(E_NOTIMPL,pDataObject->DAdvise(NULL,ADVF_NODATA,NULL,NULL));
	EXPECT_EQ(OLE_E_ADVISENOTSUPPORTED,pDataObject->DUnadvise(0));
	EXPECT_EQ(OLE_E_ADVISENOTSUPPORTED,pDataObject->EnumDAdvise(NULL));
}
예제 #22
0
// @pymethod |PyIDataObject|DUnadvise|Disconnects a notification sink.
PyObject *PyIDataObject::DUnadvise(PyObject *self, PyObject *args)
{
	IDataObject *pIDO = GetI(self);
	if ( pIDO == NULL )
		return NULL;
	// @pyparm int|dwConnection||Identifier of the connection as returned by DAdvise.
	DWORD dwConnection;
	if ( !PyArg_ParseTuple(args, "l:DUnadvise", &dwConnection) )
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIDO->DUnadvise( dwConnection );
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIDO, IID_IDataObject );
	Py_INCREF(Py_None);
	return Py_None;
}
예제 #23
0
// @pymethod <o PyIEnumFORMATETC>|PyIDataObject|EnumFormatEtc|Returns an enumerator to list the data formats that the object supports.
PyObject *PyIDataObject::EnumFormatEtc(PyObject *self, PyObject *args)
{
	IDataObject *pIDO = GetI(self);
	if ( pIDO == NULL )
		return NULL;
	// @pyparm int|dwDirection|DATADIR_GET|Indicates whether to return formats that can be queried or set (pythoncom.DATADIR_GET or DATADIR_SET)
	DWORD dwDirection = DATADIR_GET;
	IEnumFORMATETC * ppenumFormatEtc;
	if ( !PyArg_ParseTuple(args, "|l:EnumFormatEtc", &dwDirection) )
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIDO->EnumFormatEtc( dwDirection, &ppenumFormatEtc );
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIDO, IID_IDataObject );
	return PyCom_PyObjectFromIUnknown(ppenumFormatEtc, IID_IEnumFORMATETC, FALSE);
}
예제 #24
0
파일: pyshellext.cpp 프로젝트: 1st1/cpython
 ~PyShellExt() {
     if (target) {
         CoTaskMemFree(target);
     }
     if (target_dir) {
         CoTaskMemFree(target_dir);
     }
     if (data_obj) {
         data_obj->Release();
     }
 }
예제 #25
0
//TODO: Review and clean code
void CProjectHierarchyWnd::DoDrag()
{
	if(m_pTarget)
	{
		m_bDrag = true;
		BaseTreeItem<loadngo::data::Entity> *pTreeItem = reinterpret_cast<BaseTreeItem<loadngo::data::Entity> *>(m_pTarget);
		IDataObject *pDataObject = pTreeItem->GetDataObject();

		if(pDataObject)
		{
			pDataObject->AddRef();
			DWORD outEffect = 0;
			DWORD dropEffect = DROPEFFECT_LINK | DROPEFFECT_COPY | DROPEFFECT_MOVE;
			DoDragDrop(pDataObject, this, dropEffect, &outEffect);
			delete pDataObject;
		}
		m_bDrag = false;
	}
	m_pTarget = NULL;
}
예제 #26
0
bool DesktopShellView::DoContextMenu(int x, int y)
{
	IDataObject* selection;

	HRESULT hr = _pShellView->GetItemObject(SVGIO_SELECTION, IID_IDataObject, (void**)&selection);
	if (FAILED(hr))
		return false;

	PIDList pidList;

	hr = pidList.GetData(selection);
	if (FAILED(hr)) {
		selection->Release();
		//CHECKERROR(hr);
		return false;
	}

	LPIDA pida = pidList;
	if (!pida->cidl) {
		selection->Release();
		return false;
	}

	LPCITEMIDLIST parent_pidl = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[0]);

	LPCITEMIDLIST* apidl = (LPCITEMIDLIST*) alloca(pida->cidl*sizeof(LPCITEMIDLIST));

	for(int i=pida->cidl; i>0; --i)
		apidl[i-1] = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[i]);

	hr = ShellFolderContextMenu(ShellFolder(parent_pidl), _hwnd, pida->cidl, apidl, x, y, _cm_ifs);

	selection->Release();

	if (SUCCEEDED(hr))
		refresh();
	else
		CHECKERROR(hr);

	return true;
}
예제 #27
0
static void* sWin32_Set_Callback(void* iParam)
	{
	const ZTuple& theTuple = *static_cast<ZTuple*>(iParam);
	if (theTuple.Empty())
		{
		::OleFlushClipboard();
		}
	else
		{
		ZDragClip_Win_DataObject* theDataObject = new ZDragClip_Win_DataObject(theTuple);
		theDataObject->AddRef();
		IDataObject* theIDataObject;
		if (SUCCEEDED(theDataObject->QueryInterface(IID_IDataObject, (void**)&theIDataObject)) && theIDataObject)
			{
			HRESULT theHRESULT = ::OleSetClipboard(theIDataObject);
			theIDataObject->Release();
			}
		theDataObject->Release();
		}
	return nil;
	}
예제 #28
0
// @pymethod <o PyFORMATETC>|PyIDataObject|GetCanonicalFormatEtc|Transforms a FORMATECT data description into a general format that the object supports
PyObject *PyIDataObject::GetCanonicalFormatEtc(PyObject *self, PyObject *args)
{
	IDataObject *pIDO = GetI(self);
	if ( pIDO == NULL )
		return NULL;
	FORMATETC formatectIn;
	PyObject *obpformatectIn;
	// @pyparm <o PyFORMATETC>|pformatectIn||Tuple representing a FORMATETC struct describing how the data should be returned
	if ( !PyArg_ParseTuple(args, "O:GetCanonicalFormatEtc", &obpformatectIn) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (bPythonIsHappy && !PyObject_AsFORMATETC( obpformatectIn, &formatectIn )) bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	FORMATETC formatetcOut;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIDO->GetCanonicalFormatEtc( &formatectIn, &formatetcOut );
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIDO, IID_IDataObject );
	return PyObject_FromFORMATETC(&formatetcOut);
}
예제 #29
0
STDMETHODIMP CGFXProperty::SetObjects (ULONG nObjects, IUnknown **ppUnk)
{
    IDataObject *pDataObject;
    FORMATETC   DataFormat;
    STGMEDIUM   GFXObject;

    // Check paramters. We expect one IUnknown.
    if (ppUnk == NULL)
    {
        ATLTRACE(_T("[CGFXProperty::SetObjects] IUnknown is NULL\n"));
        return E_POINTER;
    }

    if (nObjects != 1)
    {
        ATLTRACE(_T("[CGFXProperty::SetObjects] Not one object passed but %d\n"), nObjects);
        return E_INVALIDARG;
    }

    // Query for IDataObject interface.
    if (ppUnk[0]->QueryInterface (IID_IDataObject, (PVOID *)&pDataObject) != S_OK)
    {
        ATLTRACE(_T("[CGFXProperty::SetObjects] QueryInterface failed!\n"));
        return E_FAIL;
    }

    // Get the handle
    memset ((PVOID)&DataFormat, 0, sizeof (DataFormat));
    DataFormat.tymed = TYMED_HGLOBAL;
    if (pDataObject->GetData (&DataFormat, &GFXObject) != S_OK)
    {
        ATLTRACE(_T("[CGFXProperty::SetObjects] GetData failed!\n"));
        return E_FAIL;
    }

    // Store the handle of the GFX filter.
    m_hGFXFilter = GFXObject.hGlobal;
    return S_OK;
}
예제 #30
0
 // process default command: look for folders and traverse into them
HRESULT IShellBrowserImpl::OnDefaultCommand(IShellView* ppshv)
{
	IDataObject* selection;

	HRESULT hr = ppshv->GetItemObject(SVGIO_SELECTION, IID_IDataObject, (void**)&selection);
	if (FAILED(hr))
		return hr;

	PIDList pidList;

	hr = pidList.GetData(selection);
	if (FAILED(hr)) {
		selection->Release();
		return hr;
	}

	hr = OnDefaultCommand(pidList);

	selection->Release();

	return hr;
}