Class MsWordGenerator
Generator for Microsoft Word documents.
Inherited Members
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
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
Remarks
The default implementation will allways return true.
OnEnd()
Called when the template has been parsed.
Declaration
protected override void OnEnd()
Overrides
OnProcessTag(long, byte[])
Called when a tag has been estracted from the template file.
Declaration
protected override byte[] OnProcessTag(long position, byte[] tagBuffer)
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, |
Returns
Type | Description |
---|---|
byte[] | Buffer holding data to be written to the document instead of the tag. |
Overrides
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
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. |