michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef _NSDATAOBJCOLLECTION_H_ michael@0: #define _NSDATAOBJCOLLECTION_H_ michael@0: michael@0: #include michael@0: michael@0: #include "nsString.h" michael@0: #include "nsTArray.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsDataObj.h" michael@0: #include "mozilla/Attributes.h" michael@0: michael@0: class CEnumFormatEtc; michael@0: michael@0: #define MULTI_MIME "Mozilla/IDataObjectCollectionFormat" michael@0: michael@0: EXTERN_C const IID IID_IDataObjCollection; michael@0: michael@0: // An interface to make sure we have the right kind of object for D&D michael@0: // this way we can filter out collection objects that aren't ours michael@0: class nsIDataObjCollection : public IUnknown { michael@0: public: michael@0: michael@0: }; michael@0: michael@0: /* michael@0: * This ole registered class is used to facilitate drag-drop of objects which michael@0: * can be adapted by an object derived from CfDragDrop. The CfDragDrop is michael@0: * associated with instances via SetDragDrop(). michael@0: */ michael@0: michael@0: class nsDataObjCollection MOZ_FINAL : public nsIDataObjCollection, public nsDataObj michael@0: { michael@0: public: michael@0: nsDataObjCollection(); michael@0: ~nsDataObjCollection(); michael@0: michael@0: public: // IUnknown methods - see iunknown.h for documentation michael@0: STDMETHODIMP_(ULONG) AddRef (); michael@0: STDMETHODIMP QueryInterface(REFIID, void**); michael@0: STDMETHODIMP_(ULONG) Release (); michael@0: michael@0: public: // DataGet and DataSet helper methods michael@0: virtual HRESULT AddSetFormat(FORMATETC& FE); michael@0: virtual HRESULT AddGetFormat(FORMATETC& FE); michael@0: michael@0: virtual HRESULT GetFile(LPFORMATETC pFE, LPSTGMEDIUM pSTM); michael@0: virtual HRESULT GetText(LPFORMATETC pFE, LPSTGMEDIUM pSTM); michael@0: virtual HRESULT GetFileDescriptors(LPFORMATETC pFE, LPSTGMEDIUM pSTM); michael@0: virtual HRESULT GetFileContents(LPFORMATETC pFE, LPSTGMEDIUM pSTM); michael@0: virtual HRESULT GetFirstSupporting(LPFORMATETC pFE, LPSTGMEDIUM pSTM); michael@0: michael@0: // support for clipboard michael@0: void AddDataFlavor(const char * aDataFlavor, LPFORMATETC aFE); michael@0: michael@0: // from nsPIDataObjCollection michael@0: void AddDataObject(IDataObject * aDataObj); michael@0: int32_t GetNumDataObjects() { return mDataObjects.Length(); } michael@0: nsDataObj* GetDataObjectAt(uint32_t aItem) michael@0: { return mDataObjects.SafeElementAt(aItem, nsRefPtr()); } michael@0: michael@0: // Return the registered OLE class ID of this object's CfDataObj. michael@0: CLSID GetClassID() const; michael@0: michael@0: public: michael@0: // Store data in pSTM according to the format specified by pFE, if the michael@0: // format is supported (supported formats are specified in CfDragDrop:: michael@0: // GetFormats) and return NOERROR; otherwise return DATA_E_FORMATETC. It michael@0: // is the callers responsibility to free pSTM if NOERROR is returned. michael@0: STDMETHODIMP GetData (LPFORMATETC pFE, LPSTGMEDIUM pSTM); michael@0: michael@0: // Similar to GetData except that the caller allocates the structure michael@0: // referenced by pSTM. michael@0: STDMETHODIMP GetDataHere (LPFORMATETC pFE, LPSTGMEDIUM pSTM); michael@0: michael@0: // Returns S_TRUE if this object supports the format specified by pSTM, michael@0: // S_FALSE otherwise. michael@0: STDMETHODIMP QueryGetData (LPFORMATETC pFE); michael@0: michael@0: // Set pCanonFE to the canonical format of pFE if one exists and return michael@0: // NOERROR, otherwise return DATA_S_SAMEFORMATETC. A canonical format michael@0: // implies an identical rendering. michael@0: STDMETHODIMP GetCanonicalFormatEtc (LPFORMATETC pFE, LPFORMATETC pCanonFE); michael@0: michael@0: // Set this objects data according to the format specified by pFE and michael@0: // the storage medium specified by pSTM and return NOERROR, if the format michael@0: // is supported. If release is TRUE this object must release the storage michael@0: // associated with pSTM. michael@0: STDMETHODIMP SetData (LPFORMATETC pFE, LPSTGMEDIUM pSTM, BOOL release); michael@0: michael@0: // Set ppEnum to an IEnumFORMATETC object which will iterate all of the michael@0: // data formats that this object supports. direction is either DATADIR_GET michael@0: // or DATADIR_SET. michael@0: STDMETHODIMP EnumFormatEtc (DWORD direction, LPENUMFORMATETC* ppEnum); michael@0: michael@0: // Set up an advisory connection to this object based on the format specified michael@0: // by pFE, flags, and the pAdvise. Set pConn to the established advise michael@0: // connection. michael@0: STDMETHODIMP DAdvise (LPFORMATETC pFE, DWORD flags, LPADVISESINK pAdvise, michael@0: DWORD* pConn); michael@0: michael@0: // Turn off advising of a previous call to DAdvise which set pConn. michael@0: STDMETHODIMP DUnadvise (DWORD pConn); michael@0: michael@0: // Set ppEnum to an IEnumSTATDATA object which will iterate over the michael@0: // existing objects which have established advisory connections to this michael@0: // object. michael@0: STDMETHODIMP EnumDAdvise (LPENUMSTATDATA *ppEnum); michael@0: michael@0: public: michael@0: // Set the adapter to dragDrop michael@0: //void SetDragDrop(CfDragDrop& dragDrop); michael@0: michael@0: // Return the adapter michael@0: //CfDragDrop& GetDragDrop() const; michael@0: michael@0: protected: michael@0: BOOL FormatsMatch(const FORMATETC& source, const FORMATETC& target) const; michael@0: michael@0: ULONG m_cRef; // the reference count michael@0: michael@0: // nsDataObjCollection owns and ref counts CEnumFormatEtc michael@0: CEnumFormatEtc * m_enumFE; michael@0: michael@0: nsTArray > mDataObjects; michael@0: michael@0: BOOL mIsAsyncMode; michael@0: BOOL mIsInOperation; michael@0: }; michael@0: michael@0: #endif //