/// <summary> /// Creates this object and sets all its properties /// </summary> /// <param name="storage">The OLE version 2.0 object as a <see cref="CFStorage" /></param> internal Ole10Native(CFStorage storage) { if (storage == null) throw new ArgumentNullException("storage"); var ole10Native = storage.GetStream("\x0001Ole10Native"); var compObj = storage.GetStream("\x0001CompObj"); var compObjStream = new CompObjStream(compObj); AnsiUserType = compObjStream.AnsiUserType; StringFormat = compObjStream.StringFormat; ClipboardFormat = compObjStream.ClipboardFormat; switch (compObjStream.AnsiUserType) { case "OLE Package": var ole10NativeSize = (int) ole10Native.Size - 4; var data = ole10Native.GetData(4, ref ole10NativeSize); var package = new Package(data); Format = package.Format; FileName = Path.GetFileName(package.FileName); FilePath = package.FilePath; NativeData = package.Data; break; case "PBrush": case "Pakket": // Ignore break; default: throw new OEObjectTypeNotSupported("Unsupported OleNative AnsiUserType '" + compObjStream.AnsiUserType + "' found"); } }
/// <summary> /// Creates this object and sets all its properties /// </summary> /// <param name="storage">The OLE version 2.0 object as a <see cref="CFStorage" /></param> internal Ole10Native(CFStorage storage) { if (storage == null) { throw new ArgumentNullException("storage"); } var ole10Native = storage.GetStream("\x0001Ole10Native"); var compObj = storage.GetStream("\x0001CompObj"); var compObjStream = new CompObjStream(compObj); AnsiUserType = compObjStream.AnsiUserType; StringFormat = compObjStream.StringFormat; ClipboardFormat = compObjStream.ClipboardFormat; switch (compObjStream.AnsiUserType) { case "OLE Package": var olePackageSize = (int)ole10Native.Size - 4; var olePackageData = new byte[olePackageSize]; ole10Native.Read(olePackageData, 4, olePackageSize); var package = new Package(olePackageData); Format = package.Format; FileName = Path.GetFileName(package.FileName); FilePath = package.FilePath; NativeData = package.Data; break; case "PBrush": var pbBrushSize = (int)ole10Native.Size - 4; var pbBrushData = new byte[pbBrushSize]; ole10Native.Read(pbBrushData, 4, pbBrushSize); FileName = "Embedded PBrush image.bmp"; Format = OleFormat.File; NativeData = pbBrushData; break; case "Pakket": // Ignore break; default: throw new OEObjectTypeNotSupported("Unsupported OleNative AnsiUserType '" + compObjStream.AnsiUserType + "' found"); } }
/// <summary> /// Creates this object and sets all its properties /// </summary> /// <param name="storage">The OLE version 2.0 object as a <see cref="CFStorage" /></param> internal Ole10Native(CFStorage storage) { if (storage == null) { throw new ArgumentNullException(nameof(storage)); } var ole10Native = storage.GetStream("\x0001Ole10Native"); var compObj = storage.GetStream("\x0001CompObj"); var compObjStream = new CompObjStream(compObj); AnsiUserType = compObjStream.AnsiUserType; StringFormat = compObjStream.StringFormat; ClipboardFormat = compObjStream.ClipboardFormat; switch (compObjStream.AnsiUserType) { case "OLE Package": var olePackageSize = (int)ole10Native.Size - 4; if (olePackageSize <= 0) { break; } var olePackageData = new byte[olePackageSize]; ole10Native.Read(olePackageData, 4, olePackageSize); var package = new Package(olePackageData); Format = package.Format; FileName = Path.GetFileName(package.FileName); FilePath = package.FilePath; NativeData = package.Data; break; case "PBrush": case "Paintbrush-afbeelding": var pbBrushSize = (int)ole10Native.Size - 4; if (pbBrushSize <= 0) { break; } var pbBrushData = new byte[pbBrushSize]; ole10Native.Read(pbBrushData, 4, pbBrushSize); FileName = "Embedded PBrush image.bmp"; Format = OleFormat.File; NativeData = pbBrushData; break; case "Pakket": // Ignore break; // MathType (http://docs.wiris.com/en/mathtype/start) is a equations editor // The data is stored in the MTEF format within image file formats (PICT, WMF, EPS, GIF) or Office documents // as kind of pickaback data. (http://docs.wiris.com/en/mathtype/mathtype_desktop/mathtype-sdk/mtefstorage). // Within Office, a placeholder image shows the created equation. // Because MathType does not support storing equations in a separate MTEF file, a export of the data is not // directly possible and would require a conversion into the mentioned file formats. // Due that facts, it make no sense try to export the data. case "MathType 5.0 Equation": break; // Used by the depreciated Microsoft Office ClipArt Gallery // supposedly to store some metadata case "MS_ClipArt_Gallery": case "Microsoft ClipArt Gallery": break; default: throw new OEObjectTypeNotSupported("Unsupported OleNative AnsiUserType '" + compObjStream.AnsiUserType + "' found"); } }