Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2915-AbsoluteSymbol/HeuristicLab.ExtLibs/HeuristicLab.EPPlus/4.0.3/EPPlus-4.0.3/Utils/EncryptedPackageHandler.cs @ 16300

Last change on this file since 16300 was 12074, checked in by sraggl, 10 years ago

#2341: Added EPPlus-4.0.3 to ExtLibs

File size: 7.5 KB
Line 
1/*******************************************************************************
2 * You may amend and distribute as you like, but don't remove this header!
3 *
4 * EPPlus provides server-side generation of Excel 2007/2010 spreadsheets.
5 * See http://www.codeplex.com/EPPlus for details.
6 *
7 * Copyright (C) 2011  Jan Källman
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
17 * See the GNU Lesser General Public License for more details.
18 *
19 * The GNU Lesser General Public License can be viewed at http://www.opensource.org/licenses/lgpl-license.php
20 * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
21 *
22 * All code and executables are provided "as is" with no warranty either express or implied.
23 * The author accepts no liability for any damage or loss of business that this product may cause.
24 **************************************************************************************
25 * This class is created with the help of the MS-OFFCRYPTO PDF documentation... http://msdn.microsoft.com/en-us/library/cc313071(office.12).aspx
26 * Decryption library for Office Open XML files(Lyquidity) and Sminks very nice example
27 * on "Reading compound documents in c#" on Stackoverflow. Many thanks!
28 ***************************************************************************************
29 * Code change notes:
30 *
31 * Author             Change            Date
32 *******************************************************************************
33 * Jan Källman    Added   10-AUG-2010
34 * Jan Källman    License changed GPL-->LGPL 2011-12-16
35 *******************************************************************************/
36using System;
37using System.Collections.Generic;
38using System.Text;
39using System.Runtime.InteropServices;
40using comTypes=System.Runtime.InteropServices.ComTypes;
41using System.IO;
42using System.Security.Cryptography;
43using System.Xml;
44namespace OfficeOpenXml.Utils
45{
46    [ComImport]
47    [Guid("0000000d-0000-0000-C000-000000000046")]
48    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
49    internal interface IEnumSTATSTG
50    {
51        // The user needs to allocate an STATSTG array whose size is celt.
52        [PreserveSig]
53        uint Next(
54            uint celt,
55            [MarshalAs(UnmanagedType.LPArray), Out]
56            System.Runtime.InteropServices.ComTypes.STATSTG[] rgelt,
57            out uint pceltFetched
58        );
59 
60        void Skip(uint celt);
61 
62        void Reset();
63 
64        [return: MarshalAs(UnmanagedType.Interface)]
65        IEnumSTATSTG Clone();
66    }
67 
68    [ComImport]
69    [Guid("0000000b-0000-0000-C000-000000000046")]
70    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
71    interface IStorage
72    {
73        void CreateStream(
74            /* [string][in] */ string pwcsName,
75            /* [in] */ uint grfMode,
76            /* [in] */ uint reserved1,
77            /* [in] */ uint reserved2,
78            /* [out] */ out comTypes.IStream ppstm);
79       
80        void OpenStream(
81            /* [string][in] */ string pwcsName,
82            /* [unique][in] */ IntPtr reserved1,
83            /* [in] */ uint grfMode,
84            /* [in] */ uint reserved2,
85            /* [out] */ out comTypes.IStream ppstm);
86 
87        void CreateStorage(
88            /* [string][in] */ string pwcsName,
89            /* [in] */ uint grfMode,
90            /* [in] */ uint reserved1,
91            /* [in] */ uint reserved2,
92            /* [out] */ out IStorage ppstg);
93 
94        void OpenStorage(
95            /* [string][unique][in] */ string pwcsName,
96            /* [unique][in] */ IStorage pstgPriority,
97            /* [in] */ uint grfMode,
98            /* [unique][in] */ IntPtr snbExclude,
99            /* [in] */ uint reserved,
100            /* [out] */ out IStorage ppstg);
101
102        void CopyTo(
103            [InAttribute] uint ciidExclude,
104            [InAttribute] Guid[] rgiidExclude,
105            [InAttribute] IntPtr snbExclude,
106            [InAttribute] IStorage pstgDest
107        );
108 
109        void MoveElementTo(
110            /* [string][in] */ string pwcsName,
111            /* [unique][in] */ IStorage pstgDest,
112            /* [string][in] */ string pwcsNewName,
113            /* [in] */ uint grfFlags);
114 
115        void Commit(
116            /* [in] */ uint grfCommitFlags);
117 
118        void Revert();
119 
120        void EnumElements(
121            /* [in] */ uint reserved1,
122            /* [size_is][unique][in] */ IntPtr reserved2,
123            /* [in] */ uint reserved3,
124            /* [out] */ out IEnumSTATSTG ppenum);
125 
126        void DestroyElement(
127            /* [string][in] */ string pwcsName);
128 
129        void RenameElement(
130            /* [string][in] */ string pwcsOldName,
131            /* [string][in] */ string pwcsNewName);
132 
133        void SetElementTimes(
134            /* [string][unique][in] */ string pwcsName,
135            /* [unique][in] */ System.Runtime.InteropServices.ComTypes.FILETIME pctime,
136            /* [unique][in] */ System.Runtime.InteropServices.ComTypes.FILETIME patime,
137            /* [unique][in] */ System.Runtime.InteropServices.ComTypes.FILETIME pmtime);
138 
139        void SetClass(
140            /* [in] */ Guid clsid);
141 
142        void SetStateBits(
143            /* [in] */ uint grfStateBits,
144            /* [in] */ uint grfMask);
145 
146        void Stat(
147            /* [out] */ out System.Runtime.InteropServices.ComTypes.STATSTG pstatstg,
148            /* [in] */ uint grfStatFlag);
149 
150    }
151    [ComVisible(false)]
152    [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("0000000A-0000-0000-C000-000000000046")]
153    internal interface ILockBytes
154    {
155        void ReadAt(long ulOffset, System.IntPtr pv, int cb, out UIntPtr pcbRead);
156        void WriteAt(long ulOffset, System.IntPtr pv, int cb, out UIntPtr pcbWritten);
157        void Flush();
158        void SetSize(long cb);
159        void LockRegion(long libOffset, long cb, int dwLockType);
160        void UnlockRegion(long libOffset, long cb, int dwLockType);
161        void Stat(out System.Runtime.InteropServices.ComTypes.STATSTG pstatstg, int grfStatFlag);
162    }
163    [Flags]
164    internal enum STGM : int
165    {
166        DIRECT = 0x00000000,
167        TRANSACTED = 0x00010000,
168        SIMPLE = 0x08000000,
169        READ = 0x00000000,
170        WRITE = 0x00000001,
171        READWRITE = 0x00000002,
172        SHARE_DENY_NONE = 0x00000040,
173        SHARE_DENY_READ = 0x00000030,
174        SHARE_DENY_WRITE = 0x00000020,
175        SHARE_EXCLUSIVE = 0x00000010,
176        PRIORITY = 0x00040000,
177        DELETEONRELEASE = 0x04000000,
178        NOSCRATCH = 0x00100000,
179        CREATE = 0x00001000,
180        CONVERT = 0x00020000,
181        FAILIFTHERE = 0x00000000,
182        NOSNAPSHOT = 0x00200000,
183        DIRECT_SWMR = 0x00400000,
184    }
185 
186    internal enum STATFLAG : uint
187    {
188        STATFLAG_DEFAULT = 0,
189        STATFLAG_NONAME = 1,
190        STATFLAG_NOOPEN = 2
191    }
192 
193    internal enum STGTY : int
194    {
195        STGTY_STORAGE = 1,
196        STGTY_STREAM = 2,
197        STGTY_LOCKBYTES = 3,
198        STGTY_PROPERTY = 4
199    }
200}
Note: See TracBrowser for help on using the repository browser.