Skip to content
This repository was archived by the owner on Apr 7, 2023. It is now read-only.

Commit 241a1c7

Browse files
committed
refreshing with latest fixes and implementations from ironfede's repo
https://github.com/ironfede/openmcdf/
1 parent d7e03dc commit 241a1c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1462
-407
lines changed

src/shared/OpenMcdf/CFException.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* This Source Code Form is subject to the terms of the Mozilla Public
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
3-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
4-
*
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
*
55
* The Original Code is OpenMCDF - Compound Document Format library.
6-
*
6+
*
77
* The Initial Developer of the Original Code is Federico Blaseotto.*/
88

99
using System;
@@ -180,8 +180,8 @@ public CFInvalidOperation(string message, Exception innerException)
180180
/// </summary>
181181
/// <remarks>
182182
/// Items are compared by name as indicated by specs.
183-
/// Two items with the same name CANNOT be added within
184-
/// the same storage or sub-storage.
183+
/// Two items with the same name CANNOT be added within
184+
/// the same storage or sub-storage.
185185
/// </remarks>
186186
[Serializable]
187187
public class CFDuplicatedItemException : CFException
@@ -212,7 +212,7 @@ public CFDuplicatedItemException(string message, Exception innerException)
212212
}
213213

214214
/// <summary>
215-
/// Raised when trying to load a Compound File with invalid, corrupted or mismatched fields (4.1 - specifications)
215+
/// Raised when trying to load a Compound File with invalid, corrupted or mismatched fields (4.1 - specifications)
216216
/// </summary>
217217
/// <remarks>
218218
/// This exception is NOT raised when Compound file has been opened with NO_VALIDATION_EXCEPTION option.

src/shared/OpenMcdf/CFItem.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

22
/* This Source Code Form is subject to the terms of the Mozilla Public
33
* License, v. 2.0. If a copy of the MPL was not distributed with this
4-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
5-
*
4+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
5+
*
66
* The Original Code is OpenMCDF - Compound Document Format library.
7-
*
7+
*
88
* The Initial Developer of the Original Code is Federico Blaseotto.*/
99

1010
using System;
@@ -16,7 +16,7 @@ namespace OpenMcdf
1616
/// </summary>
1717
/// <example>
1818
/// <code>
19-
///
19+
///
2020
/// const String STORAGE_NAME = "report.xls";
2121
/// CompoundFile cf = new CompoundFile(STORAGE_NAME);
2222
///
@@ -32,7 +32,7 @@ namespace OpenMcdf
3232
/// cf.RootStorage.VisitEntries(va, true);
3333
///
3434
/// tw.Close();
35-
///
35+
///
3636
/// </code>
3737
/// </example>
3838
public abstract class CFItem : IComparable<CFItem>
@@ -140,7 +140,7 @@ public String Name
140140
}
141141

142142
/// <summary>
143-
/// Size in bytes of the item. It has a valid value
143+
/// Size in bytes of the item. It has a valid value
144144
/// only if entity is a stream, otherwise it is setted to zero.
145145
/// </summary>
146146
public long Size

src/shared/OpenMcdf/CFStorage.cs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* This Source Code Form is subject to the terms of the Mozilla Public
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
3-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
4-
*
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
*
55
* The Original Code is OpenMCDF - Compound Document Format library.
6-
*
6+
*
77
* The Initial Developer of the Original Code is Federico Blaseotto.*/
88

99

@@ -20,7 +20,7 @@ namespace OpenMcdf
2020
/// <param name="item">Currently visited <see cref="T:OpenMcdf.CFItem">item</see></param>
2121
/// <example>
2222
/// <code>
23-
///
23+
///
2424
/// //We assume that xls file should be a valid OLE compound file
2525
/// const String STORAGE_NAME = "report.xls";
2626
/// CompoundFile cf = new CompoundFile(STORAGE_NAME);
@@ -108,7 +108,7 @@ private RBTree LoadChildren(int SID)
108108
/// <exception cref="T:OpenMcdf.CFException">Raised when adding a stream with null or empty name</exception>
109109
/// <example>
110110
/// <code>
111-
///
111+
///
112112
/// String filename = "A_NEW_COMPOUND_FILE_YOU_CAN_WRITE_TO.cfs";
113113
///
114114
/// CompoundFile cf = new CompoundFile();
@@ -119,7 +119,7 @@ private RBTree LoadChildren(int SID)
119119
/// sm.SetData(b);
120120
///
121121
/// cf.Save(filename);
122-
///
122+
///
123123
/// </code>
124124
/// </example>
125125
public CFStream AddStream(String streamName)
@@ -129,7 +129,7 @@ public CFStream AddStream(String streamName)
129129
if (String.IsNullOrEmpty(streamName))
130130
throw new CFException("Stream name cannot be null or empty");
131131

132-
132+
133133

134134
IDirectoryEntry dirEntry = DirectoryEntry.TryNew(streamName, StgType.StgStream, this.CompoundFile.GetDirectories());
135135

@@ -147,7 +147,7 @@ public CFStream AddStream(String streamName)
147147
catch (RBTreeException)
148148
{
149149
CompoundFile.ResetDirectoryEntry(dirEntry.SID);
150-
150+
151151
throw new CFDuplicatedItemException("An entry with name '" + streamName + "' is already present in storage '" + this.Name + "' ");
152152
}
153153

@@ -253,7 +253,7 @@ public CFStream TryGetStream(String streamName)
253253
/// <exception cref="T:OpenMcdf.CFItemNotFound">Raised if item to delete is not found</exception>
254254
/// <example>
255255
/// <code>
256-
///
256+
///
257257
/// String FILENAME = "MultipleStorage2.cfs";
258258
/// CompoundFile cf = new CompoundFile(FILENAME, UpdateMode.ReadOnly, false, false);
259259
///
@@ -288,7 +288,7 @@ public CFStorage GetStorage(String storageName)
288288
/// <exception cref="T:OpenMcdf.CFDisposedException">Raised if trying to delete item from a closed compound file</exception>
289289
/// <example>
290290
/// <code>
291-
///
291+
///
292292
/// String FILENAME = "MultipleStorage2.cfs";
293293
/// CompoundFile cf = new CompoundFile(FILENAME, UpdateMode.ReadOnly, false, false);
294294
///
@@ -326,7 +326,7 @@ public CFStorage TryGetStorage(String storageName)
326326
/// <exception cref="T:OpenMcdf.CFException">Raised when adding a storage with null or empty name</exception>
327327
/// <example>
328328
/// <code>
329-
///
329+
///
330330
/// String filename = "A_NEW_COMPOUND_FILE_YOU_CAN_WRITE_TO.cfs";
331331
///
332332
/// CompoundFile cf = new CompoundFile();
@@ -337,7 +337,7 @@ public CFStorage TryGetStorage(String storageName)
337337
/// sm.SetData(b);
338338
///
339339
/// cf.Save(filename);
340-
///
340+
///
341341
/// </code>
342342
/// </example>
343343
public CFStorage AddStorage(String storageName)
@@ -403,32 +403,32 @@ public void VisitEntries(Action<CFItem> action, bool recursive)
403403
return;
404404
List<IRBNode> subStorages = new List<IRBNode>();
405405

406-
Action<IRBNode> internalAction =
407-
delegate(IRBNode targetNode)
408-
{
409-
IDirectoryEntry d = targetNode as IDirectoryEntry;
410-
if (d.StgType == StgType.StgStream)
411-
action(new CFStream(this.CompoundFile, d));
412-
else
413-
action(new CFStorage(this.CompoundFile, d));
406+
Action<IRBNode> internalAction =
407+
delegate(IRBNode targetNode)
408+
{
409+
IDirectoryEntry d = targetNode as IDirectoryEntry;
410+
if (d.StgType == StgType.StgStream)
411+
action(new CFStream(this.CompoundFile, d));
412+
else
413+
action(new CFStorage(this.CompoundFile, d));
414414

415-
if (d.Child != DirectoryEntry.NOSTREAM)
416-
subStorages.Add(targetNode);
415+
if (d.Child != DirectoryEntry.NOSTREAM)
416+
subStorages.Add(targetNode);
417417

418-
return;
419-
};
418+
return;
419+
};
420420

421-
this.Children.VisitTreeNodes(internalAction);
421+
this.Children.VisitTreeNodes(internalAction);
422422

423423
if (!recursive || subStorages.Count <= 0)
424424
return;
425425

426-
foreach (IRBNode n in subStorages)
427-
{
428-
IDirectoryEntry d = n as IDirectoryEntry;
429-
(new CFStorage(this.CompoundFile, d)).VisitEntries(action, recursive);
426+
foreach (IRBNode n in subStorages)
427+
{
428+
IDirectoryEntry d = n as IDirectoryEntry;
429+
(new CFStorage(this.CompoundFile, d)).VisitEntries(action, recursive);
430+
}
430431
}
431-
}
432432

433433
/// <summary>
434434
/// Remove an entry from the current storage and compound file.
@@ -505,7 +505,7 @@ public void Delete(String entryName)
505505

506506
case StgType.StgStream:
507507

508-
// Free directory associated data stream.
508+
// Free directory associated data stream.
509509
CompoundFile.FreeAssociatedData((foundObj as IDirectoryEntry).SID);
510510

511511
// Remove item from children tree
@@ -537,7 +537,7 @@ public void Delete(String entryName)
537537
// if( ((IDirectoryEntry)target).SID>foundObj.SID )
538538
// {
539539
// ((IDirectoryEntry)target).SID--;
540-
// }
540+
// }
541541

542542

543543
// ((IDirectoryEntry)target).LeftSibling--;

src/shared/OpenMcdf/CFStream.cs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
/* This Source Code Form is subject to the terms of the Mozilla Public
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
3-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
4-
*
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
*
55
* The Original Code is OpenMCDF - Compound Document Format library.
6-
*
6+
*
77
* The Initial Developer of the Original Code is Federico Blaseotto.*/
88

99
using System;
@@ -53,25 +53,25 @@ public void SetData(Byte[] data)
5353
/// </summary>
5454
/// <param name="data">Data buffer to Write</param>
5555
/// <param name="position">Position into the stream object to start writing from</param>
56-
/// <remarks>Current stream will be extended to receive data buffer over
56+
/// <remarks>Current stream will be extended to receive data buffer over
5757
/// its current size</remarks>
5858
public void Write(byte[] data, long position)
5959
{
6060
this.Write(data, position, 0, data.Length);
6161
}
6262

6363
/// <summary>
64-
/// Write <paramref name="count">count</paramref> bytes of a data buffer to a specific position into
64+
/// Write <paramref name="count">count</paramref> bytes of a data buffer to a specific position into
6565
/// the current CFStream object starting from the specified position.
6666
/// </summary>
6767
/// <param name="data">Data buffer to copy bytes from</param>
6868
/// <param name="position">Position into the stream object to start writing from</param>
69-
/// <param name="offset">The zero-based byte offset in buffer at which to
69+
/// <param name="offset">The zero-based byte offset in buffer at which to
7070
/// begin copying bytes to the current <see cref="T:OpenMcdf.CFStream">CFStream</see>. </param>
7171
/// <param name="count">The number of bytes to be written to the current <see cref="T:OpenMcdf.CFStream">CFStream</see> </param>
72-
/// <remarks>Current stream will be extended to receive data buffer over
72+
/// <remarks>Current stream will be extended to receive data buffer over
7373
/// its current size.</remarks>
74-
public void Write(byte[] data, long position, int offset, int count)
74+
internal void Write(byte[] data, long position, int offset, int count)
7575
{
7676
CheckDisposed();
7777
this.CompoundFile.WriteData(this, data, position, offset, count);
@@ -94,7 +94,7 @@ public void Write(byte[] data, long position, int offset, int count)
9494
/// </example>
9595
/// <param name="data">Data bytes to append to this stream</param>
9696
/// <remarks>
97-
/// This method allows user to create stream with more than 2GB of data,
97+
/// This method allows user to create stream with more than 2GB of data,
9898
/// appending data to the end of existing ones.
9999
/// Large streams (>2GB) are only supported by CFS version 4.
100100
/// Append data can also be invoked on streams with no data in order
@@ -136,7 +136,7 @@ public Byte[] GetData()
136136

137137
/// <summary>
138138
/// Read <paramref name="count"/> bytes associated with the stream object, starting from
139-
/// a provided <paramref name="offset"/>. Method returns the effective count of bytes
139+
/// a provided <paramref name="offset"/>. Method returns the effective count of bytes
140140
/// read.
141141
/// </summary>
142142
/// <param name="buffer">Array of bytes that will contain stream data</param>
@@ -145,7 +145,6 @@ public Byte[] GetData()
145145
/// <param name="count">The maximum number of bytes to be read from the current stream.</param>
146146
/// <returns>The count of bytes effectively read</returns>
147147
/// <remarks>Method may read a number of bytes lesser then the requested one.</remarks>
148-
/// <example>
149148
/// <code>
150149
/// CompoundFile cf = null;
151150
/// byte[] b = Helpers.GetBuffer(1024 * 2, 0xAA); //2MB buffer
@@ -170,7 +169,7 @@ public int Read(byte[] buffer, long position, int count)
170169

171170
/// <summary>
172171
/// Read <paramref name="count"/> bytes associated with the stream object, starting from
173-
/// a provided <paramref name="position"/>. Method returns the effective count of bytes
172+
/// a provided <paramref name="position"/>. Method returns the effective count of bytes
174173
/// read.
175174
/// </summary>
176175
/// <param name="buffer">Array of bytes that will contain stream data</param>
@@ -180,7 +179,6 @@ public int Read(byte[] buffer, long position, int count)
180179
/// <param name="count">The maximum number of bytes to be read from the current stream.</param>
181180
/// <returns>The count of bytes effectively read</returns>
182181
/// <remarks>Method may read a number of bytes lesser then the requested one.</remarks>
183-
/// <example>
184182
/// <code>
185183
/// CompoundFile cf = null;
186184
/// byte[] b = Helpers.GetBuffer(1024 * 2, 0xAA); //2MB buffer
@@ -197,12 +195,13 @@ public int Read(byte[] buffer, long position, int count)
197195
/// <exception cref="T:OpenMcdf.CFDisposedException">
198196
/// Raised when the owner compound file has been closed.
199197
/// </exception>
200-
public int Read(byte[] buffer, long position, int offset, int count)
198+
internal int Read(byte[] buffer, long position, int offset, int count)
201199
{
202200
CheckDisposed();
203201
return this.CompoundFile.ReadData(this, position, buffer, offset, count);
204202
}
205203

204+
206205
/// <summary>
207206
/// Copy data from an existing stream.
208207
/// </summary>

0 commit comments

Comments
 (0)