Skip to content

Commit 805f013

Browse files
committed
Update WDocument
1 parent 48061af commit 805f013

1 file changed

Lines changed: 1 addition & 16 deletions

File tree

src/DocSharp.Docx/Model/WDocument.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,10 @@ internal class WDocument : IDisposable
2121
private bool _shouldDisposeStream = false;
2222
private bool _isReadOnly = false;
2323

24-
// Logic:
25-
// - When loading DOCX, use the WordprocessingDocument instance directly.
26-
// - When loading other formats (e.g. RTF) call the appropriate converter to populate a new WordprocessingDocument instance.
27-
// - When saving to DOCX, save the WordprocessingDocument instance directly.
28-
// - When saving to other formats (e.g. RTF), call the appropriate converter to convert from the WordprocessingDocument instance.
29-
//
3024
// The Open XML SDK requires different handling for saving to the same stream vs a different stream: Save() vs Clone(newStream).
3125
// The latter is wrapped in the SaveTo extension method.
3226
// Therefore, we need to track the original stream used to open the document and determine if the output stream is the same.
33-
// A public constructor from WordprocessingDocument is currently not provided, as we cannot track the original stream in that case.
34-
//
35-
// Alternatively, other libraries always create WordprocessingDocument in an isolated memory stream, so that saving is easier,
36-
// but this approach has performance implications.
37-
//
38-
// Possible future improvements:
39-
// - add methods for manipulating the document directly in this class (e.g. AddParagraph, GetSections, etc.).
40-
// - use OpenXmlReader/Writer when possible to reduce memory usage.
41-
// - rather than calling SaveTo (that always uses clone), add an AsCopy parameter in Save methods,
42-
// allowing to update the original stream if set to false.
27+
// (For this reason, a public constructor from WordprocessingDocument is currently not provided, as we cannot track the original stream in that case.)
4328
private WDocument(WordprocessingDocument document, Stream originalStream, LoadFormat? originalFormat, bool shouldDisposeStream, bool isReadOnly = false)
4429
{
4530
_document = document;

0 commit comments

Comments
 (0)