コード例 #1
0
        IEnumFORMATETC IDataObject.EnumFormatEtc(DATADIR direction)
        {
            if (direction == DATADIR.DATADIR_GET)
            {
                if (0 == _dataObjects.Count)
                {
                    // Note: SHCreateStdEnumFmtEtc fails for a count of 0; throw helpful exception
                    throw new InvalidOperationException(
                              "VirtualFileDataObject requires at least one data object to enumerate.");
                }

                // Create enumerator and return it
                IEnumFORMATETC   enumerator;
                List <FORMATETC> l = new List <FORMATETC>();
                foreach (DataObject o in _dataObjects)
                {
                    l.Add(o.FORMATETC);
                }
                if (
                    NativeMethods.SUCCEEDED(NativeMethods.SHCreateStdEnumFmtEtc((uint)(_dataObjects.Count), l.ToArray(),
                                                                                out enumerator)))
                {
                    return(enumerator);
                }

                // Returning null here can cause an AV in the caller; throw instead
                Marshal.ThrowExceptionForHR(NativeMethods.E_FAIL);
            }
            throw new NotImplementedException();
        }
コード例 #2
0
 IEnumFORMATETC IComDataObject.EnumFormatEtc(DATADIR direction)
 {
     if (direction == DATADIR.DATADIR_GET)
     {
         return(new FormatEnumrator(this));
     }
     throw HRESULT.E_NOTIMPL.GetException();
 }
コード例 #3
0
 /// <summary>
 /// Creates an object for enumerating the <see cref="T:System.Runtime.InteropServices.ComTypes.FORMATETC"/>
 /// structures for a data object. These structures are used in calls to GetData() or SetData().</summary>
 /// <returns>This method supports the standard return values E_INVALIDARG and E_OUTOFMEMORY, as well as the following:
 /// S_OK -- The enumerator object was successfully created.
 /// E_NOTIMPL -- The direction specified by the <paramref name="direction"/> parameter is not supported.
 /// OLE_S_USEREG -- Requests that OLE enumerate the formats from the registry.</returns>
 /// <param name="direction">Specifies the direction of the data.</param>
 public IEnumFORMATETC EnumFormatEtc(DATADIR direction)
 {
     if (direction == DATADIR.DATADIR_GET)
     {
         var list = m_oleStorage.Select(data => data.Format).ToArray();
         return(new FormatEnumerator(list));
     }
     throw new NotImplementedException("OLE_S_USEREG");
 }
コード例 #4
0
        public EnumFORMATETC(DATADIR dir, IEnumerable cache)
        {
            if (cache == null)
                throw new ArgumentNullException("cache");

            this.cache = cache;
            this.dir = dir;
            e = cache.GetEnumerator();
        }
コード例 #5
0
ファイル: DataObject.cs プロジェクト: metaseed/Metakey
        IEnumFORMATETC IDataObject.EnumFormatEtc(DATADIR direction)
        {
            if (direction == DATADIR.DATADIR_GET)
            {
                return(new FormatEnumerator(this));
            }

            throw new ExternalException(direction.ToString(), Consts.E_NOTIMPL);
        }
コード例 #6
0
        public IEnumFORMATETC EnumFormatEtc(DATADIR direction)
        {
            // We only support GET.
            if (DATADIR.DATADIR_GET == direction)
            {
                return(new EnumFORMATETC(storage));
            }

            throw new NotImplementedException("DataObject: only \"get\" data direction supported in EnumFormatEtc");
        }
コード例 #7
0
ファイル: DataObject.cs プロジェクト: bundie1990/MygodLibrary
        /// <summary>
        /// Gets an enumerator for the formats contained in this DataObject.
        /// </summary>
        /// <param name="direction">The direction of the data.</param>
        /// <returns>An instance of the IEnumFORMATETC interface.</returns>
        public IEnumFORMATETC EnumFormatEtc(DATADIR direction)
        {
            // We only support GET
            if (DATADIR.DATADIR_GET == direction)
            {
                return(new EnumFORMATETC(storage));
            }

            throw new NotImplementedException("OLE_S_USEREG");
        }
コード例 #8
0
 public IEnumFORMATETC EnumFormatEtc(DATADIR direction)
 {
     if (DATADIR.DATADIR_GET == direction)
     {
         return((IEnumFORMATETC) new Advent.Common.Interop.DataObject.EnumFORMATETC(this.storage));
     }
     else
     {
         throw new NotImplementedException("OLE_S_USEREG");
     }
 }
コード例 #9
0
        public IEnumFORMATETC EnumFormatEtc(DATADIR direction)
        {
            int a = SHCreateStdEnumFmtEtc((uint)supportedFormats.Count, supportedFormats.ToArray(), out IEnumFORMATETC enumer);

            if (a != 0)
            {
                throw new Win32Exception();
            }

            return(enumer);
        }
コード例 #10
0
        public EnumFORMATETC(DATADIR dir, IEnumerable cache)
        {
            if (cache == null)
            {
                throw new ArgumentNullException("cache");
            }

            this.cache = cache;
            this.dir   = dir;
            e          = cache.GetEnumerator();
        }
コード例 #11
0
 IEnumFORMATETC IOleDataObject.EnumFormatEtc(DATADIR direction)
 {
     if (_wrapped is IOleDataObject ole)
     {
         return(ole.EnumFormatEtc(direction));
     }
     if (direction == DATADIR.DATADIR_GET)
     {
         return(new FormatEnumerator(_wrapped));
     }
     throw new NotSupportedException();
 }
コード例 #12
0
ファイル: DataObject.cs プロジェクト: Jessie-Zhang01/origin
        IEnumFORMATETC IComDataObject.EnumFormatEtc(DATADIR dwDirection)
        {
            Debug.WriteLineIf(CompModSwitches.DataObject.TraceVerbose, "EnumFormatEtc: " + dwDirection.ToString());
            if (innerData is OleConverter innerDataOleConverter)
            {
                return(innerDataOleConverter.OleDataObject.EnumFormatEtc(dwDirection));
            }
            if (dwDirection == DATADIR.DATADIR_GET)
            {
                return(new FormatEnumerator(this));
            }

            throw new ExternalException(SR.ExternalException, (int)HRESULT.E_NOTIMPL);
        }
コード例 #13
0
        /// <summary>
        /// Creates and returns a pointer to an object to enumerate the FORMATETC
        /// supported by the data object
        /// </summary>
        /// <param name="dwDirection">Direction of the data through a value from
        /// the enumeration DATADIR</param>
        /// <param name="ppEnumFormatEtc">Address of IEnumFORMATETC* pointer variable
        /// that receives the interface pointer to the new enumerator object</param>
        public int EnumFormatEtc(DATADIR dwDirection, out IEnumFORMATETC ppEnumFormatEtc)
        {
            // don't support enumeration of set formats
            if (dwDirection == DATADIR.SET)
            {
                ppEnumFormatEtc = null;
                return(HRESULT.E_NOTIMPL);
            }

            // return a new enumerator for our data entries
            IEnumFORMATETC enumerator = new EnumFORMATETC(oleDataEntries);

            enumerators.Add(enumerator);
            ppEnumFormatEtc = enumerator;
            return(HRESULT.S_OK);
        }
コード例 #14
0
ファイル: ClipboardBroker.cs プロジェクト: zha0/exploit-1
        public IEnumFORMATETC EnumFormatEtc(DATADIR direction)
        {
            Console.WriteLine("EnumFormatEtc");
            FORMATETC fmt = new FORMATETC();

            fmt.tymed    = TYMED.TYMED_ISTORAGE;
            fmt.cfFormat = 1;
            fmt.dwAspect = DVASPECT.DVASPECT_CONTENT;
            fmt.lindex   = -1;
            FORMATETC[]    fmts = new FORMATETC[] { fmt };
            IEnumFORMATETC e;
            int            hr = SHCreateStdEnumFmtEtc(1, fmts, out e);

            if (hr != 0)
            {
                Marshal.ThrowExceptionForHR(hr);
            }
            return(e);
        }
コード例 #15
0
        public IEnumFORMATETC EnumFormatEtc(DATADIR direction)
        {
            ComDebug.ReportInfo("{0}.IDataObject.EnumFormatEtc", GetType().Name);
            try
            {
                // We only support GET
                if (DATADIR.DATADIR_GET == direction)
                {
                    return(new EnumFormatEtc(new List <FORMATETC>(Renderings.Select(x => x.format))));
                }
            }
            catch (Exception e)
            {
                ComDebug.ReportError("{0}.IDataObject.EnumFormatEtc exception: {1}", GetType().Name, e);
                throw;
            }

            throw new NotImplementedException("Can not use registry here because a return value is not supported");
        }
コード例 #16
0
            private static HRESULT EnumFormatEtc(IntPtr thisPtr, DATADIR direction, IntPtr *pEnumFormatC)
            {
                var instance = ComInterfaceDispatch.GetInstance <IDataObject>((ComInterfaceDispatch *)thisPtr);

                try
                {
                    var formatEtc = instance.EnumFormatEtc(direction);
                    var result    = WinFormsComWrappers.Instance.TryGetComPointer(formatEtc, IID.IEnumFORMATETC, out var formatEtcPtr);
                    if (result.Failed())
                    {
                        return(result);
                    }

                    *pEnumFormatC = formatEtcPtr;
                    return(HRESULT.S_OK);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                    return((HRESULT)ex.HResult);
                }
            }
コード例 #17
0
ファイル: DataObject.cs プロジェクト: renmin/DesignHelper
        /// <summary>
        /// Gets an enumerator for the formats contained in this DataObject.
        /// </summary>
        /// <param name="direction">The direction of the data.</param>
        /// <returns>An instance of the IEnumFORMATETC interface.</returns>
        public IEnumFORMATETC EnumFormatEtc(DATADIR direction)
        {
            // We only support GET
            if (DATADIR.DATADIR_GET == direction)
                return new EnumFORMATETC(storage);

            throw new NotImplementedException("OLE_S_USEREG");
        }
コード例 #18
0
ファイル: DataCacheEntry.cs プロジェクト: yangfan79/MPFProj10
 /// <summary>
 /// The IntPtr is data allocated that should be removed. It is allocated by the ProcessSelectionData method.
 /// </summary>
 public DataCacheEntry(FORMATETC fmt, SafeGlobalAllocHandle data, DATADIR dir)
 {
     this.format  = fmt;
     this.data    = data;
     this.dataDir = dir;
 }
コード例 #19
0
ファイル: DragDrop.cs プロジェクト: abibell/mysql-workbench
        public IEnumFORMATETC EnumFormatEtc(DATADIR direction)
        {
            // We only support GET.
              if (DATADIR.DATADIR_GET == direction)
            return new EnumFORMATETC(storage);

              throw new NotImplementedException("DataObject: only \"get\" data direction supported in EnumFormatEtc");
        }
コード例 #20
0
 IEnumFORMATETC System.Runtime.InteropServices.ComTypes.IDataObject.EnumFormatEtc(DATADIR dwDirection)
 {
     throw null;
 }
コード例 #21
0
ファイル: DataObject.cs プロジェクト: theimowski/visualfsharp
 /// <summary>
 /// The IntPtr is data allocated that should be removed. It is allocated by the ProcessSelectionData method.
 /// </summary>
 /*internal, but public for FSharp.Project.dll*/ public DataCacheEntry(FORMATETC fmt, IntPtr data, DATADIR dir)
 {
     this.format  = fmt;
     this.data    = (long)data;
     this.dataDir = dir;
 }
コード例 #22
0
 public IEnumFORMATETC EnumFormatEtc(DATADIR direction)
 {
     return(CreateFormatEnumerator(formatetc.Length, formatetc));
 }
コード例 #23
0
        IEnumFORMATETC System.Runtime.InteropServices.ComTypes.IDataObject.EnumFormatEtc(DATADIR direction)
        {
            if (direction == DATADIR.DATADIR_GET)
            {
                if (0 == _dataObjects.Count)
                {
                    // Note: SHCreateStdEnumFmtEtc fails for a count of 0; throw helpful exception
                    throw new InvalidOperationException("VirtualFileDataObject requires at least one data object to enumerate.");
                }

                // Create enumerator and return it
                IEnumFORMATETC enumerator;
                if (NativeMethods.SUCCEEDED(NativeMethods.SHCreateStdEnumFmtEtc((uint)(_dataObjects.Count), _dataObjects.Select(d => d.FORMATETC).ToArray(), out enumerator)))
                {
                    return(enumerator);
                }

                // Returning null here can cause an AV in the caller; throw instead
                Marshal.ThrowExceptionForHR(NativeMethods.E_FAIL);
            }
            throw new NotImplementedException();
        }
コード例 #24
0
 public IEnumFORMATETC EnumFormatEtc(DATADIR direction)
 {
     throw new NotImplementedException();
 }
コード例 #25
0
 public EnumFORMATETC(DATADIR dir, IEnumerable cache) {
     this.cache = cache;
     this.dir = dir;
     e = cache.GetEnumerator();
 }
コード例 #26
0
 public Class940(DATADIR A_0, Struct33 A_1, Struct34 A_2)
 {
     this.struct33_0 = A_1;
     this.struct34_0 = A_2;
     this.datadir_0  = A_0;
 }
コード例 #27
0
ファイル: DataObject.cs プロジェクト: svick/visualfsharp
 /// <summary>
 /// The IntPtr is data allocated that should be removed. It is allocated by the ProcessSelectionData method.
 /// </summary>
 /*internal, but public for FSharp.Project.dll*/ public DataCacheEntry(FORMATETC fmt, IntPtr data, DATADIR dir)
 {
         this.format = fmt;
         this.data = (long)data;
         this.dataDir = dir;
 }
コード例 #28
0
ファイル: DataObject.cs プロジェクト: hesam/SketchSharp
 public DataCacheEntry(FORMATETC fmt, IntPtr data, DATADIR dir) {
     this.format = fmt;
     this.data = data;
     this.dataDir = dir;
 }
コード例 #29
0
 public IEnumFORMATETC EnumFormatEtc(DATADIR direction)
 {
     throw new NotImplementedException();
 }
コード例 #30
0
ファイル: DataObject.cs プロジェクト: Plankankul/SpecSharp
 public EnumFORMATETC(DATADIR dir, IEnumerable cache)
 {
     this.cache = cache;
     this.dir   = dir;
     e          = cache.GetEnumerator();
 }
コード例 #31
0
ファイル: DataObjectBase.cs プロジェクト: Altaxo/Altaxo
		public IEnumFORMATETC EnumFormatEtc(DATADIR direction)
		{
			ComDebug.ReportInfo("{0}.IDataObject.EnumFormatEtc", this.GetType().Name);
			try
			{
				// We only support GET
				if (DATADIR.DATADIR_GET == direction)
					return new EnumFormatEtc(new List<FORMATETC>(Renderings.Select(x => x.format)));
			}
			catch (Exception e)
			{
				ComDebug.ReportError("{0}.IDataObject.EnumFormatEtc exception: {1}", this.GetType().Name, e);
				throw;
			}

			throw new NotImplementedException("Can not use registry here because a return value is not supported");
		}
コード例 #32
0
        public int EnumFormatEtc(DATADIR direction, out IEnumFORMATETC ppenumFormatEtc)
        {
            IEnumFORMATETC origEnum = null;

            try
            {
                log.DebugFormat("IDataObject.EnumFormatEtc called -- direction {0}", direction);
                switch (direction)
                {
                case DATADIR.DATADIR_GET:
                    //Get original enumerator
                    int result = innerData.EnumFormatEtc(direction, out origEnum);
                    if (result != NativeMethods.S_OK)
                    {
                        ppenumFormatEtc = null;
                        return(result);
                    }

                    //Enumerate original formats
                    List <FORMATETC> formats = new List <FORMATETC>();
                    FORMATETC[]      buffer  = new FORMATETC[] { new FORMATETC() };
                    while (origEnum.Next(1, buffer, null) == NativeMethods.S_OK)
                    {
                        //Convert format from short to unsigned short
                        ushort cfFormat = (ushort)buffer[0].cfFormat;

                        //Do not return text formats -- some applications try to get text before files
                        if (cfFormat != NativeMethods.CF_TEXT && cfFormat != NativeMethods.CF_UNICODETEXT && cfFormat != (ushort)DataObjectHelper.GetClipboardFormat("Csv"))
                        {
                            formats.Add(buffer[0]);
                        }
                    }

                    //Add CF_HDROP format
                    FORMATETC format = new FORMATETC();
                    format.cfFormat = NativeMethods.CF_HDROP;
                    format.dwAspect = DVASPECT.DVASPECT_CONTENT;
                    format.lindex   = -1;
                    format.ptd      = IntPtr.Zero;
                    format.tymed    = TYMED.TYMED_HGLOBAL;
                    formats.Add(format);

                    //Return new enumerator for available formats
                    ppenumFormatEtc = new FormatEtcEnumerator(formats.ToArray());
                    return(NativeMethods.S_OK);

                case DATADIR.DATADIR_SET:
                    //Return original enumerator
                    return(innerData.EnumFormatEtc(direction, out ppenumFormatEtc));

                default:
                    //Invalid direction
                    ppenumFormatEtc = null;
                    return(NativeMethods.E_INVALIDARG);
                }
            }
            catch (Exception ex)
            {
                log.Error("Exception in IDataObject.EnumFormatEtc", ex);
                ppenumFormatEtc = null;
                return(NativeMethods.E_UNEXPECTED);
            }
            finally
            {
                //Release all unmanaged objects
                if (origEnum != null)
                {
                    Marshal.ReleaseComObject(origEnum);
                }
            }
        }
コード例 #33
0
ファイル: DataObject.cs プロジェクト: JianwenSun/cc
 IEnumFORMATETC IComDataObject.EnumFormatEtc(DATADIR dwDirection) {
     Debug.WriteLineIf(CompModSwitches.DataObject.TraceVerbose, "EnumFormatEtc: " + dwDirection.ToString());
     if (innerData is OleConverter) {
         return ((OleConverter)innerData).OleDataObject.EnumFormatEtc(dwDirection);
     }
     if (dwDirection == DATADIR.DATADIR_GET) {
         return new FormatEnumerator(this);
     }
     else {
         throw new ExternalException(SR.GetString(SR.ExternalException), NativeMethods.E_NOTIMPL);
     }
 }
コード例 #34
0
 /// <summary>
 /// The IntPtr is data allocated that should be removed. It is allocated by the ProcessSelectionData method.
 /// </summary>
 public DataCacheEntry(FORMATETC fmt, SafeGlobalAllocHandle data, DATADIR dir)
 {
     this.format = fmt;
     this.data = data;
     this.dataDir = dir;
 }
コード例 #35
0
ファイル: DataObject.cs プロジェクト: Plankankul/SpecSharp
 public DataCacheEntry(FORMATETC fmt, IntPtr data, DATADIR dir)
 {
     this.format  = fmt;
     this.data    = (long)data;
     this.dataDir = dir;
 }
コード例 #36
0
ファイル: dataobject.cs プロジェクト: JianwenSun/cc
            private IEnumFORMATETC EnumFormatEtcInner(DATADIR dwDirection)
            {
                IEnumFORMATETC enumFORMATETC;

                new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert(); // BlessedAssert

                try
                {
                    enumFORMATETC = _innerData.EnumFormatEtc(dwDirection);
                }
                finally
                {
                    SecurityPermission.RevertAssert();
                }

                return enumFORMATETC;

            }
コード例 #37
0
            IEnumFORMATETC System.Runtime.InteropServices.ComTypes.IDataObject.EnumFormatEtc(DATADIR direction)
            {
                var innerEnumerator = _innerComDataObject.EnumFormatEtc(direction);

                if (direction != DATADIR.DATADIR_GET)
                {
                    return(innerEnumerator);
                }

                var formats = new List <FORMATETC>(5 + _fileContents.Count);
                var tmp     = new FORMATETC[5];
                var fetched = new int[2];
                int result;

                do
                {
                    result = innerEnumerator.Next(5, tmp, fetched);
                    for (var i = 0; i < fetched[0]; ++i)
                    {
                        formats.Add(tmp[i]);
                    }
                } while (result == 0);

                formats.AddRange(_fileContents.Select(c => c.Format));
                return(new FormatEnumerator(formats));
            }
コード例 #38
0
ファイル: dataobject.cs プロジェクト: JianwenSun/cc
 IEnumFORMATETC IComDataObject.EnumFormatEtc(DATADIR dwDirection)
 {
     if (_innerData is OleConverter)
     {
         return ((OleConverter)_innerData).OleDataObject.EnumFormatEtc(dwDirection);
     }
     if (dwDirection == DATADIR.DATADIR_GET)
     {
         return new FormatEnumerator(this);
     }
     else
     {
         throw new ExternalException(SR.Get(SRID.DataObject_NotImplementedEnumFormatEtc, dwDirection), NativeMethods.E_NOTIMPL);
     }
 }
コード例 #39
0
 /// <summary>
 /// Creates an object for enumerating the <see cref="T:System.Runtime.InteropServices.ComTypes.FORMATETC"/>
 /// structures for a data object. These structures are used in calls to GetData() or SetData().</summary>
 /// <returns>This method supports the standard return values E_INVALIDARG and E_OUTOFMEMORY, as well as the following:
 /// S_OK -- The enumerator object was successfully created.
 /// E_NOTIMPL -- The direction specified by the <paramref name="direction"/> parameter is not supported.
 /// OLE_S_USEREG -- Requests that OLE enumerate the formats from the registry.</returns>
 /// <param name="direction">Specifies the direction of the data.</param>
 public IEnumFORMATETC EnumFormatEtc(DATADIR direction)
 {
     if (direction == DATADIR.DATADIR_GET)
     {
         var list = m_oleStorage.Select(data => data.Format).ToArray();
         return new FormatEnumerator(list);
     }
     throw new NotImplementedException("OLE_S_USEREG");
 }
コード例 #40
0
 /// <summary>
 /// The IntPtr is data allocated that should be removed. It is allocated by the ProcessSelectionData method.
 /// </summary>
 internal DataCacheEntry(FORMATETC fmt, IntPtr data, DATADIR dir)
 {
     this.Format  = fmt;
     this.Data    = (long)data;
     this.DataDir = dir;
 }
コード例 #41
0
		IEnumFORMATETC IDataObject.EnumFormatEtc(DATADIR direction) {
			if (direction == DATADIR.DATADIR_GET) {
				if (0 == _dataObjects.Count) {
					// Note: SHCreateStdEnumFmtEtc fails for a count of 0; throw helpful exception
					throw new InvalidOperationException("VirtualFileDataObject requires at least one data object to enumerate.");
				}

				// Create enumerator and return it
				IEnumFORMATETC enumerator;
				if (
					NativeMethods.Succeeded(NativeMethods.SHCreateStdEnumFmtEtc((uint)(_dataObjects.Count),
																				_dataObjects.Select(d => d.FORMATETC).ToArray(),
																				out enumerator))) {
					return enumerator;
				}

				// Returning null here can cause an AV in the caller; throw instead
				Marshal.ThrowExceptionForHR(NativeMethods.E_FAIL);
			}
			throw new NotImplementedException();
		}
コード例 #42
0
ファイル: DataObject.cs プロジェクト: kingpin2k/MCS
 public IEnumFORMATETC EnumFormatEtc(DATADIR direction)
 {
     if (DATADIR.DATADIR_GET == direction)
         return (IEnumFORMATETC)new Advent.Common.Interop.DataObject.EnumFORMATETC(this.storage);
     else
         throw new NotImplementedException("OLE_S_USEREG");
 }
コード例 #43
0
 /// <summary>
 /// The IntPtr is data allocated that should be removed. It is allocated by the ProcessSelectionData method.
 /// </summary>
 internal DataCacheEntry(FORMATETC fmt, IntPtr data, DATADIR dir) {
     this.format = fmt;
     this.data = (long)data;
     this.dataDir = dir;
 }
コード例 #44
0
        /// <summary>
        /// Creates and returns a pointer to an object to enumerate the FORMATETC
        /// supported by the data object
        /// </summary>
        /// <param name="dwDirection">Direction of the data through a value from
        /// the enumeration DATADIR</param>
        /// <param name="ppEnumFormatEtc">Address of IEnumFORMATETC* pointer variable
        /// that receives the interface pointer to the new enumerator object</param>
        public int EnumFormatEtc(DATADIR dwDirection, out IEnumFORMATETC ppEnumFormatEtc)
        {
            // don't support enumeration of set formats
            if (dwDirection == DATADIR.SET)
            {
                ppEnumFormatEtc = null;
                return HRESULT.E_NOTIMPL;
            }

            // return a new enumerator for our data entries
            IEnumFORMATETC enumerator = new EnumFORMATETC(oleDataEntries);
            enumerators.Add(enumerator);
            ppEnumFormatEtc = enumerator;
            return HRESULT.S_OK;
        }