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();
        }
Exemplo n.º 2
0
 IEnumFORMATETC IComDataObject.EnumFormatEtc(DATADIR direction)
 {
     if (direction == DATADIR.DATADIR_GET)
     {
         return(new FormatEnumrator(this));
     }
     throw HRESULT.E_NOTIMPL.GetException();
 }
Exemplo n.º 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");
 }
Exemplo n.º 4
0
        public EnumFORMATETC(DATADIR dir, IEnumerable cache)
        {
            if (cache == null)
                throw new ArgumentNullException("cache");

            this.cache = cache;
            this.dir = dir;
            e = cache.GetEnumerator();
        }
Exemplo n.º 5
0
        IEnumFORMATETC IDataObject.EnumFormatEtc(DATADIR direction)
        {
            if (direction == DATADIR.DATADIR_GET)
            {
                return(new FormatEnumerator(this));
            }

            throw new ExternalException(direction.ToString(), Consts.E_NOTIMPL);
        }
Exemplo n.º 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");
        }
Exemplo n.º 7
0
        /// <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");
        }
Exemplo n.º 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");
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 10
0
        public EnumFORMATETC(DATADIR dir, IEnumerable cache)
        {
            if (cache == null)
            {
                throw new ArgumentNullException("cache");
            }

            this.cache = cache;
            this.dir   = dir;
            e          = cache.GetEnumerator();
        }
Exemplo n.º 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();
 }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 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");
        }
            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);
                }
            }
Exemplo n.º 17
0
        /// <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");
        }
Exemplo n.º 18
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;
 }
Exemplo n.º 19
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");
        }
Exemplo n.º 20
0
 IEnumFORMATETC System.Runtime.InteropServices.ComTypes.IDataObject.EnumFormatEtc(DATADIR dwDirection)
 {
     throw null;
 }
Exemplo n.º 21
0
 /// <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;
 }
Exemplo n.º 22
0
 public IEnumFORMATETC EnumFormatEtc(DATADIR direction)
 {
     return(CreateFormatEnumerator(formatetc.Length, formatetc));
 }
        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();
        }
Exemplo n.º 24
0
 public IEnumFORMATETC EnumFormatEtc(DATADIR direction)
 {
     throw new NotImplementedException();
 }
 public EnumFORMATETC(DATADIR dir, IEnumerable cache) {
     this.cache = cache;
     this.dir = dir;
     e = cache.GetEnumerator();
 }
Exemplo n.º 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;
 }
Exemplo n.º 27
0
 /// <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;
 }
Exemplo n.º 28
0
 public DataCacheEntry(FORMATETC fmt, IntPtr data, DATADIR dir) {
     this.format = fmt;
     this.data = data;
     this.dataDir = dir;
 }
Exemplo n.º 29
0
 public IEnumFORMATETC EnumFormatEtc(DATADIR direction)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 30
0
 public EnumFORMATETC(DATADIR dir, IEnumerable cache)
 {
     this.cache = cache;
     this.dir   = dir;
     e          = cache.GetEnumerator();
 }
Exemplo n.º 31
0
		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");
		}
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 33
0
 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);
     }
 }
Exemplo n.º 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;
 }
Exemplo n.º 35
0
 public DataCacheEntry(FORMATETC fmt, IntPtr data, DATADIR dir)
 {
     this.format  = fmt;
     this.data    = (long)data;
     this.dataDir = dir;
 }
Exemplo n.º 36
0
            private IEnumFORMATETC EnumFormatEtcInner(DATADIR dwDirection)
            {
                IEnumFORMATETC enumFORMATETC;

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

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

                return enumFORMATETC;

            }
Exemplo n.º 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));
            }
Exemplo n.º 38
0
 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);
     }
 }
Exemplo n.º 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");
 }
Exemplo n.º 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;
 }
Exemplo n.º 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();
		}
Exemplo n.º 42
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");
 }
 /// <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;
 }
        /// <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;
        }