1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
23 // Peter Bartok (pbartok@novell.com)
30 using System.Collections;
33 namespace System.Windows.Forms
35 public class DataFormats
39 static readonly object lockobj = new object ();
41 private static Format formats;
45 internal bool is_serializable;
47 public Format (string name, int id)
57 while (f.next != null)
64 #region Public Instance Properties
77 internal Format Next {
82 #endregion // Public Instance Properties
84 #region Private Methods
85 internal static Format Add (string name)
93 cliphandle = XplatUI.ClipboardOpen (false);
94 f = new Format (name, XplatUI.ClipboardGetID (cliphandle, name));
95 XplatUI.ClipboardClose (cliphandle);
100 internal static Format Add (int id) {
105 f = new Format("Format" + id.ToString(), id);
109 internal static Format Find (int id) {
113 while ((f != null) && (f.Id != id))
118 internal static Format Find (string name) {
122 while ((f != null) && (!f.Name.Equals(name)))
127 internal static Format List {
132 #endregion // Private Methods
135 private DataFormats ()
139 #region Public Static Fields
140 public static readonly string Bitmap = "Bitmap";
141 public static readonly string CommaSeparatedValue = "Csv";
142 public static readonly string Dib = "DeviceIndependentBitmap";
143 public static readonly string Dif = "DataInterchangeFormat";
144 public static readonly string EnhancedMetafile = "EnhancedMetafile";
145 public static readonly string FileDrop = "FileDrop";
146 public static readonly string Html = "HTML Format";
147 public static readonly string Locale = "Locale";
148 public static readonly string MetafilePict = "MetaFilePict";
149 public static readonly string OemText = "OEMText";
150 public static readonly string Palette = "Palette";
151 public static readonly string PenData = "PenData";
152 public static readonly string Riff = "RiffAudio";
153 public static readonly string Rtf = "Rich Text Format";
154 public static readonly string Serializable = "WindowsForms10PersistentObject";
155 public static readonly string StringFormat = "System.String";
156 public static readonly string SymbolicLink = "SymbolicLink";
157 public static readonly string Text = "Text";
158 public static readonly string Tiff = "Tiff";
159 public static readonly string UnicodeText = "UnicodeText";
160 public static readonly string WaveAudio = "WaveAudio";
161 #endregion // Public Static Fields
163 private static object lock_object = new object ();
164 private static bool initialized;
166 // we don't want to force the creation of a new format
167 internal static bool ContainsFormat (int id)
173 return Format.Find (id) != null;
177 public static Format GetFormat (int id)
182 return Format.Find (id);
186 public static Format GetFormat (string format)
191 return Format.Add (format);
195 // Assumes we are locked on the lock_object when it is called
196 private static void Init ()
200 IntPtr cliphandle = XplatUI.ClipboardOpen(false);
202 new Format (Text, XplatUI.ClipboardGetID (cliphandle, Text));
203 new Format (Bitmap, XplatUI.ClipboardGetID (cliphandle, Bitmap));
204 new Format (MetafilePict, XplatUI.ClipboardGetID (cliphandle, MetafilePict));
205 new Format (SymbolicLink, XplatUI.ClipboardGetID (cliphandle, SymbolicLink));
206 new Format (Dif, XplatUI.ClipboardGetID (cliphandle, Dif)) ;
207 new Format (Tiff, XplatUI.ClipboardGetID (cliphandle, Tiff));
208 new Format (OemText, XplatUI.ClipboardGetID (cliphandle, OemText));
209 new Format (Dib, XplatUI.ClipboardGetID (cliphandle, Dib));
210 new Format (Palette, XplatUI.ClipboardGetID (cliphandle, Palette));
211 new Format (PenData, XplatUI.ClipboardGetID (cliphandle, PenData));
212 new Format (Riff, XplatUI.ClipboardGetID (cliphandle, Riff));
213 new Format (WaveAudio, XplatUI.ClipboardGetID (cliphandle, WaveAudio));
214 new Format (UnicodeText, XplatUI.ClipboardGetID (cliphandle, UnicodeText));
215 new Format (EnhancedMetafile, XplatUI.ClipboardGetID (cliphandle, EnhancedMetafile));
216 new Format (FileDrop, XplatUI.ClipboardGetID (cliphandle, FileDrop));
217 new Format (Locale, XplatUI.ClipboardGetID (cliphandle, Locale));
218 new Format (CommaSeparatedValue, XplatUI.ClipboardGetID (cliphandle, CommaSeparatedValue));
219 new Format (Html, XplatUI.ClipboardGetID (cliphandle, Html));
220 new Format (Rtf, XplatUI.ClipboardGetID (cliphandle, Rtf));
221 new Format (Serializable, XplatUI.ClipboardGetID (cliphandle, Serializable));
222 new Format (StringFormat, XplatUI.ClipboardGetID (cliphandle, StringFormat));
224 XplatUI.ClipboardClose (cliphandle);