widget/windows/nsDataObjCollection.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef _NSDATAOBJCOLLECTION_H_
michael@0 7 #define _NSDATAOBJCOLLECTION_H_
michael@0 8
michael@0 9 #include <oleidl.h>
michael@0 10
michael@0 11 #include "nsString.h"
michael@0 12 #include "nsTArray.h"
michael@0 13 #include "nsAutoPtr.h"
michael@0 14 #include "nsDataObj.h"
michael@0 15 #include "mozilla/Attributes.h"
michael@0 16
michael@0 17 class CEnumFormatEtc;
michael@0 18
michael@0 19 #define MULTI_MIME "Mozilla/IDataObjectCollectionFormat"
michael@0 20
michael@0 21 EXTERN_C const IID IID_IDataObjCollection;
michael@0 22
michael@0 23 // An interface to make sure we have the right kind of object for D&D
michael@0 24 // this way we can filter out collection objects that aren't ours
michael@0 25 class nsIDataObjCollection : public IUnknown {
michael@0 26 public:
michael@0 27
michael@0 28 };
michael@0 29
michael@0 30 /*
michael@0 31 * This ole registered class is used to facilitate drag-drop of objects which
michael@0 32 * can be adapted by an object derived from CfDragDrop. The CfDragDrop is
michael@0 33 * associated with instances via SetDragDrop().
michael@0 34 */
michael@0 35
michael@0 36 class nsDataObjCollection MOZ_FINAL : public nsIDataObjCollection, public nsDataObj
michael@0 37 {
michael@0 38 public:
michael@0 39 nsDataObjCollection();
michael@0 40 ~nsDataObjCollection();
michael@0 41
michael@0 42 public: // IUnknown methods - see iunknown.h for documentation
michael@0 43 STDMETHODIMP_(ULONG) AddRef ();
michael@0 44 STDMETHODIMP QueryInterface(REFIID, void**);
michael@0 45 STDMETHODIMP_(ULONG) Release ();
michael@0 46
michael@0 47 public: // DataGet and DataSet helper methods
michael@0 48 virtual HRESULT AddSetFormat(FORMATETC& FE);
michael@0 49 virtual HRESULT AddGetFormat(FORMATETC& FE);
michael@0 50
michael@0 51 virtual HRESULT GetFile(LPFORMATETC pFE, LPSTGMEDIUM pSTM);
michael@0 52 virtual HRESULT GetText(LPFORMATETC pFE, LPSTGMEDIUM pSTM);
michael@0 53 virtual HRESULT GetFileDescriptors(LPFORMATETC pFE, LPSTGMEDIUM pSTM);
michael@0 54 virtual HRESULT GetFileContents(LPFORMATETC pFE, LPSTGMEDIUM pSTM);
michael@0 55 virtual HRESULT GetFirstSupporting(LPFORMATETC pFE, LPSTGMEDIUM pSTM);
michael@0 56
michael@0 57 // support for clipboard
michael@0 58 void AddDataFlavor(const char * aDataFlavor, LPFORMATETC aFE);
michael@0 59
michael@0 60 // from nsPIDataObjCollection
michael@0 61 void AddDataObject(IDataObject * aDataObj);
michael@0 62 int32_t GetNumDataObjects() { return mDataObjects.Length(); }
michael@0 63 nsDataObj* GetDataObjectAt(uint32_t aItem)
michael@0 64 { return mDataObjects.SafeElementAt(aItem, nsRefPtr<nsDataObj>()); }
michael@0 65
michael@0 66 // Return the registered OLE class ID of this object's CfDataObj.
michael@0 67 CLSID GetClassID() const;
michael@0 68
michael@0 69 public:
michael@0 70 // Store data in pSTM according to the format specified by pFE, if the
michael@0 71 // format is supported (supported formats are specified in CfDragDrop::
michael@0 72 // GetFormats) and return NOERROR; otherwise return DATA_E_FORMATETC. It
michael@0 73 // is the callers responsibility to free pSTM if NOERROR is returned.
michael@0 74 STDMETHODIMP GetData (LPFORMATETC pFE, LPSTGMEDIUM pSTM);
michael@0 75
michael@0 76 // Similar to GetData except that the caller allocates the structure
michael@0 77 // referenced by pSTM.
michael@0 78 STDMETHODIMP GetDataHere (LPFORMATETC pFE, LPSTGMEDIUM pSTM);
michael@0 79
michael@0 80 // Returns S_TRUE if this object supports the format specified by pSTM,
michael@0 81 // S_FALSE otherwise.
michael@0 82 STDMETHODIMP QueryGetData (LPFORMATETC pFE);
michael@0 83
michael@0 84 // Set pCanonFE to the canonical format of pFE if one exists and return
michael@0 85 // NOERROR, otherwise return DATA_S_SAMEFORMATETC. A canonical format
michael@0 86 // implies an identical rendering.
michael@0 87 STDMETHODIMP GetCanonicalFormatEtc (LPFORMATETC pFE, LPFORMATETC pCanonFE);
michael@0 88
michael@0 89 // Set this objects data according to the format specified by pFE and
michael@0 90 // the storage medium specified by pSTM and return NOERROR, if the format
michael@0 91 // is supported. If release is TRUE this object must release the storage
michael@0 92 // associated with pSTM.
michael@0 93 STDMETHODIMP SetData (LPFORMATETC pFE, LPSTGMEDIUM pSTM, BOOL release);
michael@0 94
michael@0 95 // Set ppEnum to an IEnumFORMATETC object which will iterate all of the
michael@0 96 // data formats that this object supports. direction is either DATADIR_GET
michael@0 97 // or DATADIR_SET.
michael@0 98 STDMETHODIMP EnumFormatEtc (DWORD direction, LPENUMFORMATETC* ppEnum);
michael@0 99
michael@0 100 // Set up an advisory connection to this object based on the format specified
michael@0 101 // by pFE, flags, and the pAdvise. Set pConn to the established advise
michael@0 102 // connection.
michael@0 103 STDMETHODIMP DAdvise (LPFORMATETC pFE, DWORD flags, LPADVISESINK pAdvise,
michael@0 104 DWORD* pConn);
michael@0 105
michael@0 106 // Turn off advising of a previous call to DAdvise which set pConn.
michael@0 107 STDMETHODIMP DUnadvise (DWORD pConn);
michael@0 108
michael@0 109 // Set ppEnum to an IEnumSTATDATA object which will iterate over the
michael@0 110 // existing objects which have established advisory connections to this
michael@0 111 // object.
michael@0 112 STDMETHODIMP EnumDAdvise (LPENUMSTATDATA *ppEnum);
michael@0 113
michael@0 114 public:
michael@0 115 // Set the adapter to dragDrop
michael@0 116 //void SetDragDrop(CfDragDrop& dragDrop);
michael@0 117
michael@0 118 // Return the adapter
michael@0 119 //CfDragDrop& GetDragDrop() const;
michael@0 120
michael@0 121 protected:
michael@0 122 BOOL FormatsMatch(const FORMATETC& source, const FORMATETC& target) const;
michael@0 123
michael@0 124 ULONG m_cRef; // the reference count
michael@0 125
michael@0 126 // nsDataObjCollection owns and ref counts CEnumFormatEtc
michael@0 127 CEnumFormatEtc * m_enumFE;
michael@0 128
michael@0 129 nsTArray<nsRefPtr<nsDataObj> > mDataObjects;
michael@0 130
michael@0 131 BOOL mIsAsyncMode;
michael@0 132 BOOL mIsInOperation;
michael@0 133 };
michael@0 134
michael@0 135 #endif //

mercurial