Show / Hide Table of Contents

Class MsWordGenerator

Generator for Microsoft Word documents.

Inheritance
object
Generator
BinaryGenerator
MsWordGenerator
Inherited Members
BinaryGenerator.GenerateAsync(Stream, CancellationToken)
BinaryGenerator.OnProcessDataAsync(long, int, BinaryGenerator.State, CancellationToken)
BinaryGenerator.SetStateAsync(BinaryGenerator.State, int, CancellationToken)
BinaryGenerator.AbortTag()
BinaryGenerator.AbortTag(int)
BinaryGenerator.GeneratorState
BinaryGenerator.Reader
BinaryGenerator.Writer
Generator.OptionSkipLtGtTags
Generator.RegExTag
Generator.SetOption(string)
Generator.HasOption(string)
Generator.GetGenerator(Stream, TagContainer, GeneratorEncoding)
Generator.GetGenerator(Stream, TagContainer, GeneratorEncoding, string)
Generator.GetGenerator(string, TagContainer, GeneratorEncoding)
Generator.GetGenerator(string, TagContainer, GeneratorEncoding, string)
Generator.GetGenerator(Stream, TagContainer, string)
Generator.GetGenerator(Stream, TagContainer, string, string)
Generator.AddExtensionMapping(string, string)
Generator.GetEncoding(string)
Generator.GenerateAsync(CancellationToken)
Generator.GetDefaultTextEncoding(GeneratorEncoding)
Generator.GetTagDataAsync(string, CancellationToken)
Generator.AddTagRegex(Regex)
Generator.UiCulture
Generator.Template
Generator.Tags
Generator.Encoding
Generator.OldEncoding
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: SuperOffice.IO
Assembly: SoCore.dll
Syntax
public class MsWordGenerator : BinaryGenerator

Constructors

MsWordGenerator(Stream, TagContainer, GeneratorEncoding, byte)

Protected internal constructor for the Microsoft Word generator.

Declaration
protected MsWordGenerator(Stream template, TagContainer tags, GeneratorEncoding encoding, byte paddingCharacter)
Parameters
Type Name Description
Stream template

Stream holding a template.

TagContainer tags

Class holding values for the tags used by the generator

GeneratorEncoding encoding

Format of the document.

byte paddingCharacter

Methods

EndTag(int)

Identify a tag end.

Declaration
protected override int EndTag(int buffer)
Parameters
Type Name Description
int buffer

Last 4 bytes parsed. This method is called each time a new byte is read from the template.

Returns
Type Description
int

0 if no tag has been identified. A positive number is the number of bytes held by the end tag.

Overrides
BinaryGenerator.EndTag(int)

IsValidTagData(int)

Called for each byte in a tag, to verify that the data within the tags are valid.

Declaration
protected override bool IsValidTagData(int buffer)
Parameters
Type Name Description
int buffer
Returns
Type Description
bool

True if it is valid data.

Overrides
BinaryGenerator.IsValidTagData(int)
Remarks

The default implementation will allways return true.

OnEnd()

Called when the template has been parsed.

Declaration
protected override void OnEnd()
Overrides
BinaryGenerator.OnEnd()

OnProcessTagAsync(long, byte[], CancellationToken)

Called when a tag has been estracted from the template file.

Declaration
protected override Task<byte[]> OnProcessTagAsync(long position, byte[] tagBuffer, CancellationToken cancellationToken = default)
Parameters
Type Name Description
long position

Position in the template where the tag starts.

byte[] tagBuffer

Buffer holding the tag, including tag start and stop bytes,

CancellationToken cancellationToken
Returns
Type Description
Task<byte[]>

Buffer holding data to be written to the document instead of the tag.

Overrides
BinaryGenerator.OnProcessTagAsync(long, byte[], CancellationToken)
Remarks

Strings in word documents are either in Windows 1252 or UTF 16 Little endian encoding.
String data is held in blocks of 512 characters. There might be one, but not more than one, switch of encoding within a tag.

OnStart()

Event raised when parsing is started.

Declaration
protected override void OnStart()
Overrides
BinaryGenerator.OnStart()

StartTag(int)

Identify a tag start.

Declaration
protected override int StartTag(int buffer)
Parameters
Type Name Description
int buffer

Last 4 bytes parsed. This method is called each time a new byte is read from the template.

Returns
Type Description
int

0 if no tag has been identified. A positive number is the number of bytes held by the start tag.

Overrides
BinaryGenerator.StartTag(int)

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top