1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/windows/nsDataObjCollection.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,135 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef _NSDATAOBJCOLLECTION_H_ 1.10 +#define _NSDATAOBJCOLLECTION_H_ 1.11 + 1.12 +#include <oleidl.h> 1.13 + 1.14 +#include "nsString.h" 1.15 +#include "nsTArray.h" 1.16 +#include "nsAutoPtr.h" 1.17 +#include "nsDataObj.h" 1.18 +#include "mozilla/Attributes.h" 1.19 + 1.20 +class CEnumFormatEtc; 1.21 + 1.22 +#define MULTI_MIME "Mozilla/IDataObjectCollectionFormat" 1.23 + 1.24 +EXTERN_C const IID IID_IDataObjCollection; 1.25 + 1.26 +// An interface to make sure we have the right kind of object for D&D 1.27 +// this way we can filter out collection objects that aren't ours 1.28 +class nsIDataObjCollection : public IUnknown { 1.29 +public: 1.30 + 1.31 +}; 1.32 + 1.33 +/* 1.34 + * This ole registered class is used to facilitate drag-drop of objects which 1.35 + * can be adapted by an object derived from CfDragDrop. The CfDragDrop is 1.36 + * associated with instances via SetDragDrop(). 1.37 + */ 1.38 + 1.39 +class nsDataObjCollection MOZ_FINAL : public nsIDataObjCollection, public nsDataObj 1.40 +{ 1.41 + public: 1.42 + nsDataObjCollection(); 1.43 + ~nsDataObjCollection(); 1.44 + 1.45 + public: // IUnknown methods - see iunknown.h for documentation 1.46 + STDMETHODIMP_(ULONG) AddRef (); 1.47 + STDMETHODIMP QueryInterface(REFIID, void**); 1.48 + STDMETHODIMP_(ULONG) Release (); 1.49 + 1.50 + public: // DataGet and DataSet helper methods 1.51 + virtual HRESULT AddSetFormat(FORMATETC& FE); 1.52 + virtual HRESULT AddGetFormat(FORMATETC& FE); 1.53 + 1.54 + virtual HRESULT GetFile(LPFORMATETC pFE, LPSTGMEDIUM pSTM); 1.55 + virtual HRESULT GetText(LPFORMATETC pFE, LPSTGMEDIUM pSTM); 1.56 + virtual HRESULT GetFileDescriptors(LPFORMATETC pFE, LPSTGMEDIUM pSTM); 1.57 + virtual HRESULT GetFileContents(LPFORMATETC pFE, LPSTGMEDIUM pSTM); 1.58 + virtual HRESULT GetFirstSupporting(LPFORMATETC pFE, LPSTGMEDIUM pSTM); 1.59 + 1.60 + // support for clipboard 1.61 + void AddDataFlavor(const char * aDataFlavor, LPFORMATETC aFE); 1.62 + 1.63 + // from nsPIDataObjCollection 1.64 + void AddDataObject(IDataObject * aDataObj); 1.65 + int32_t GetNumDataObjects() { return mDataObjects.Length(); } 1.66 + nsDataObj* GetDataObjectAt(uint32_t aItem) 1.67 + { return mDataObjects.SafeElementAt(aItem, nsRefPtr<nsDataObj>()); } 1.68 + 1.69 + // Return the registered OLE class ID of this object's CfDataObj. 1.70 + CLSID GetClassID() const; 1.71 + 1.72 + public: 1.73 + // Store data in pSTM according to the format specified by pFE, if the 1.74 + // format is supported (supported formats are specified in CfDragDrop:: 1.75 + // GetFormats) and return NOERROR; otherwise return DATA_E_FORMATETC. It 1.76 + // is the callers responsibility to free pSTM if NOERROR is returned. 1.77 + STDMETHODIMP GetData (LPFORMATETC pFE, LPSTGMEDIUM pSTM); 1.78 + 1.79 + // Similar to GetData except that the caller allocates the structure 1.80 + // referenced by pSTM. 1.81 + STDMETHODIMP GetDataHere (LPFORMATETC pFE, LPSTGMEDIUM pSTM); 1.82 + 1.83 + // Returns S_TRUE if this object supports the format specified by pSTM, 1.84 + // S_FALSE otherwise. 1.85 + STDMETHODIMP QueryGetData (LPFORMATETC pFE); 1.86 + 1.87 + // Set pCanonFE to the canonical format of pFE if one exists and return 1.88 + // NOERROR, otherwise return DATA_S_SAMEFORMATETC. A canonical format 1.89 + // implies an identical rendering. 1.90 + STDMETHODIMP GetCanonicalFormatEtc (LPFORMATETC pFE, LPFORMATETC pCanonFE); 1.91 + 1.92 + // Set this objects data according to the format specified by pFE and 1.93 + // the storage medium specified by pSTM and return NOERROR, if the format 1.94 + // is supported. If release is TRUE this object must release the storage 1.95 + // associated with pSTM. 1.96 + STDMETHODIMP SetData (LPFORMATETC pFE, LPSTGMEDIUM pSTM, BOOL release); 1.97 + 1.98 + // Set ppEnum to an IEnumFORMATETC object which will iterate all of the 1.99 + // data formats that this object supports. direction is either DATADIR_GET 1.100 + // or DATADIR_SET. 1.101 + STDMETHODIMP EnumFormatEtc (DWORD direction, LPENUMFORMATETC* ppEnum); 1.102 + 1.103 + // Set up an advisory connection to this object based on the format specified 1.104 + // by pFE, flags, and the pAdvise. Set pConn to the established advise 1.105 + // connection. 1.106 + STDMETHODIMP DAdvise (LPFORMATETC pFE, DWORD flags, LPADVISESINK pAdvise, 1.107 + DWORD* pConn); 1.108 + 1.109 + // Turn off advising of a previous call to DAdvise which set pConn. 1.110 + STDMETHODIMP DUnadvise (DWORD pConn); 1.111 + 1.112 + // Set ppEnum to an IEnumSTATDATA object which will iterate over the 1.113 + // existing objects which have established advisory connections to this 1.114 + // object. 1.115 + STDMETHODIMP EnumDAdvise (LPENUMSTATDATA *ppEnum); 1.116 + 1.117 + public: 1.118 + // Set the adapter to dragDrop 1.119 + //void SetDragDrop(CfDragDrop& dragDrop); 1.120 + 1.121 + // Return the adapter 1.122 + //CfDragDrop& GetDragDrop() const; 1.123 + 1.124 + protected: 1.125 + BOOL FormatsMatch(const FORMATETC& source, const FORMATETC& target) const; 1.126 + 1.127 + ULONG m_cRef; // the reference count 1.128 + 1.129 + // nsDataObjCollection owns and ref counts CEnumFormatEtc 1.130 + CEnumFormatEtc * m_enumFE; 1.131 + 1.132 + nsTArray<nsRefPtr<nsDataObj> > mDataObjects; 1.133 + 1.134 + BOOL mIsAsyncMode; 1.135 + BOOL mIsInOperation; 1.136 +}; 1.137 + 1.138 +#endif //