# Struct ipworkszip::OfficeDoc

The OfficeDoc struct implements support for the Open XML Packaging Format used in Office 2007 documents.

## Syntax

```text
ipworkszip::OfficeDoc
```

## Remarks

The struct provides a way to extract information and content from an Open XML packaged document, examine the package properties and basic read/update facilities.

### Object Lifetime

 The *new()* method returns a mutable reference to a struct instance. The object itself is kept in the global list maintained by IPWorksZip. Due to this, the OfficeDoc struct cannot be disposed of automatically. Please, call the *dispose(&mut; self)* method of OfficeDoc when you have finished using the instance.

## Property List

*The following is the full list of the properties of the struct with short descriptions. Click on the links for further details.*

|  |  |
| --- | --- |
| [content_type_count](#content_type_count-property-officedoc-struct) | The number of records in the ContentType arrays. |
| [content_type_is_override](#content_type_is_override-property-officedoc-struct) | Specifies if this is a default content type or an override. |
| [content_type_media_type](#content_type_media_type-property-officedoc-struct) | The media type for this entry, as defined by RFC2616. |
| [content_type_target](#content_type_target-property-officedoc-struct) | If it's a default content type, this will be the file extension it applies to. |
| [namespace_count](#namespace_count-property-officedoc-struct) | The number of records in the Namespace arrays. |
| [namespace_prefix](#namespace_prefix-property-officedoc-struct) | This property contains the Prefix for the namespace. |
| [namespace_uri](#namespace_uri-property-officedoc-struct) | This property contains the namespace URI associated with the corresponding Prefix . |
| [package_path](#package_path-property-officedoc-struct) | The path to the Open XML package file. |
| [package_property_count](#package_property_count-property-officedoc-struct) | The number of records in the PackageProperty arrays. |
| [package_property_data_type](#package_property_data_type-property-officedoc-struct) | The data type associated with this property, if the information is available. |
| [package_property_name](#package_property_name-property-officedoc-struct) | The name of this property. |
| [package_property_namespace](#package_property_namespace-property-officedoc-struct) | The XML Namespace URI associated with this property. |
| [package_property_prop_id](#package_property_prop_id-property-officedoc-struct) | If this is a custom property, this will be the pid assigned to it. |
| [package_property_prop_set](#package_property_prop_set-property-officedoc-struct) | If this is a custom property, this will be the GUID of the property set it belongs to. |
| [package_property_value](#package_property_value-property-officedoc-struct) | The value of this property. |
| [part_data](#part_data-property-officedoc-struct) | The contents of the currently selected part. |
| [part_name](#part_name-property-officedoc-struct) | The name of the currently selected part. |
| [relationship_count](#relationship_count-property-officedoc-struct) | The number of records in the Relationship arrays. |
| [relationship_content_type](#relationship_content_type-property-officedoc-struct) | The content type for the part referenced by this relationship, resolved from [Content_Types]. |
| [relationship_id](#relationship_id-property-officedoc-struct) | The unique ID of this relationship within this . |
| [relationship_part_name](#relationship_part_name-property-officedoc-struct) | The name of the part this relationship entry applies to. |
| [relationship_type_uri](#relationship_type_uri-property-officedoc-struct) | The XML namespace URI that specifies the meaning of this relationship. |
| [validate](#validate-property-officedoc-struct) | This property controls whether documents are validated during parsing. |
| [attr_count](#attr_count-property-officedoc-struct) | The number of records in the Attr arrays. |
| [attr_name](#attr_name-property-officedoc-struct) | The Name provides the local name (without prefix) of the attribute. |
| [attr_namespace](#attr_namespace-property-officedoc-struct) | This property contains the attribute namespace. |
| [attr_prefix](#attr_prefix-property-officedoc-struct) | This property contains the attribute prefix (if any). |
| [attr_value](#attr_value-property-officedoc-struct) | This property contains the attribute value. |
| [xchild_count](#xchild_count-property-officedoc-struct) | The number of records in the XChild arrays. |
| [xchild_name](#xchild_name-property-officedoc-struct) | The Name property provides the local name (without a prefix) of the element. |
| [xchild_namespace](#xchild_namespace-property-officedoc-struct) | This property contains the namespace of the element. |
| [xchild_prefix](#xchild_prefix-property-officedoc-struct) | This property contains the prefix of the element (if any). |
| [xchild_x_text](#xchild_x_text-property-officedoc-struct) | This property contains the inner text of the element. |
| [xelement](#xelement-property-officedoc-struct) | The name of the current element. |
| [xnamespace](#xnamespace-property-officedoc-struct) | The namespace of the current element. |
| [xparent](#xparent-property-officedoc-struct) | This property includes the parent of the current element. |
| [xpath](#xpath-property-officedoc-struct) | This property provides a way to point to a specific element in the document. |
| [xprefix](#xprefix-property-officedoc-struct) | The prefix of the current element. |
| [xsub_tree](#xsub_tree-property-officedoc-struct) | This property includes a snapshot of the current element in the document. |
| [xtext](#xtext-property-officedoc-struct) | The text of the current element. |

## Method List

*The following is the full list of the methods of the struct with short descriptions. Click on the links for further details.*

|  |  |
| --- | --- |
| [close](#close-method-officedoc-struct) | Closes the Open XML package archive. |
| [config](#config-method-officedoc-struct) | Sets or retrieves a configuration setting. |
| [extract_part](#extract_part-method-officedoc-struct) | Reads the contents of the currently selected part. |
| [find_part_by_type](#find_part_by_type-method-officedoc-struct) | Looks up a part in the current relationships file by it's type namespace URI. |
| [get_property_value](#get_property_value-method-officedoc-struct) | Returns the value of the specified package property. |
| [list_parts](#list_parts-method-officedoc-struct) | List all the parts contained in the document and their relationships. |
| [open](#open-method-officedoc-struct) | Opens the Open XML package archive. |
| [parse_part](#parse_part-method-officedoc-struct) | Parses the specified part as XML. |
| [read_relationships](#read_relationships-method-officedoc-struct) | Reads the relationships file in the archive associated with the specified part. |
| [replace_part](#replace_part-method-officedoc-struct) | Replaces the contents of the specified part in the package. |
| [reset](#reset-method-officedoc-struct) | Resets the struct. |
| [resolve_content_type](#resolve_content_type-method-officedoc-struct) | Returns the content type of the specified part. |

## Event List

*The following is the full list of the events fired by the struct with short descriptions. Click on the links for further details.*

|  |  |
| --- | --- |
| [on_begin_file](#on_begin_file-event-officedoc-struct) | Fired before each file is processed. |
| [on_characters](#on_characters-event-officedoc-struct) | This event is fired for plaintext segments of the input stream. |
| [on_comment](#on_comment-event-officedoc-struct) | This event is fired when a comment section is encountered. |
| [on_end_element](#on_end_element-event-officedoc-struct) | This event is fired when an end-element tag is encountered. |
| [on_end_file](#on_end_file-event-officedoc-struct) | Fired after each file is processed. |
| [on_end_prefix_mapping](#on_end_prefix_mapping-event-officedoc-struct) | This event is fired when leaving the scope of a namespace declaration. |
| [on_error](#on_error-event-officedoc-struct) | Fired when information is available about errors during data delivery. |
| [on_eval_entity](#on_eval_entity-event-officedoc-struct) | This event is fired every time an entity needs to be evaluated. |
| [on_ignorable_whitespace](#on_ignorable_whitespace-event-officedoc-struct) | This event is fired when a section of ignorable whitespace is encountered. |
| [on_meta](#on_meta-event-officedoc-struct) | This event fires when a meta section is encountered. |
| [on_overwrite](#on_overwrite-event-officedoc-struct) | Fired whenever a file exists and may be overwritten. |
| [on_pi](#on_pi-event-officedoc-struct) | This event is fired when a processing instruction section is encountered. |
| [on_progress](#on_progress-event-officedoc-struct) | Fired as progress is made. |
| [on_special_section](#on_special_section-event-officedoc-struct) | This event is fired when a special section is encountered. |
| [on_start_element](#on_start_element-event-officedoc-struct) | This event is fired when a begin-element tag is encountered in the document. |
| [on_start_prefix_mapping](#on_start_prefix_mapping-event-officedoc-struct) | This event is fired when entering the scope of a namespace declaration. |

## Config Settings

*The following is a list of config settings for the struct with short descriptions. Click on the links for further details.*

|  |  |
| --- | --- |
| [NormalizePartName](#NormalizePartName) | Whether to normalize Part Names. |
| [RelationshipIsExternal\[x\]](#RelationshipIsExternal[x]) | Whether the relationship part is internal or external. |
| [BuildInfo](#BuildInfo) | Information about the product's build. |
| [CodePage](#CodePage) | The system code page used for Unicode to Multibyte translations. |
| [LicenseInfo](#LicenseInfo) | Information about the current license. |
| [MaskSensitiveData](#MaskSensitiveData) | Whether sensitive data is masked in log messages. |
| [UseInternalSecurityAPI](#UseInternalSecurityAPI) | Whether or not to use the system security libraries or an internal implementation. |

# content_type_count property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The number of records in the ContentType arrays.

## Syntax

*Rust Syntax*

```text
fn content_type_count(&self ) -> Result<i32, IPWorksZipError>
```

## Default Value

0

## Remarks

This property controls the size of the following arrays:

- [content_type_is_override](#content_type_is_override-property-officedoc-struct)
- [content_type_media_type](#content_type_media_type-property-officedoc-struct)
- [content_type_target](#content_type_target-property-officedoc-struct)

The array indices start at *0* and end at *content_type_count - 1*.

This property is read-only.

## Data Type

i32

# content_type_is_override property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

Specifies if this is a default content type or an override.

## Syntax

*Rust Syntax*

```text
fn content_type_is_override(&self , ContentTypeIndex : i32) -> Result<bool, IPWorksZipError>
```

## Default Value

true

## Remarks

Specifies if this is a default content type or an override.

The *ContentTypeIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [ContentTypeCount](#content_type_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

bool

# content_type_media_type property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The media type for this entry, as defined by RFC2616.

## Syntax

*Rust Syntax*

```text
fn content_type_media_type(&self , ContentTypeIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

The media type for this entry, as defined by RFC2616.

The *ContentTypeIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [ContentTypeCount](#content_type_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# content_type_target property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

If it's a default content type, this will be the file extension it applies to.

## Syntax

*Rust Syntax*

```text
fn content_type_target(&self , ContentTypeIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

If it's a default content type, this will be the file extension it applies to. Otherwise, it will be the part name.

The *ContentTypeIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [ContentTypeCount](#content_type_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# namespace_count property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The number of records in the Namespace arrays.

## Syntax

*Rust Syntax*

```text
fn namespace_count(&self ) -> Result<i32, IPWorksZipError>
```

## Default Value

0

## Remarks

This property controls the size of the following arrays:

- [namespace_prefix](#namespace_prefix-property-officedoc-struct)
- [namespace_uri](#namespace_uri-property-officedoc-struct)

The array indices start at *0* and end at *namespace_count - 1*.

This property is read-only.

## Data Type

i32

# namespace_prefix property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This property contains the Prefix for the namespace.

## Syntax

*Rust Syntax*

```text
fn namespace_prefix(&self , NamespaceIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

This property contains the [namespace_prefix](#namespace_prefix-property-officedoc-struct) for the namespace.

The *NamespaceIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [NamespaceCount](#namespace_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# namespace_uri property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This property contains the namespace URI associated with the corresponding Prefix .

## Syntax

*Rust Syntax*

```text
fn namespace_uri(&self , NamespaceIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

This property contains the namespace URI associated with the corresponding [namespace_prefix](#namespace_prefix-property-officedoc-struct). This URL is usually pointing to the XML schema for the namespace.

The *NamespaceIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [NamespaceCount](#namespace_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# package_path property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The path to the Open XML package file.

## Syntax

*Rust Syntax*

```text
fn package_path(&self ) -> Result<String, IPWorksZipError> fn set_package_path(&self, value : &str) ->  Option<IPWorksZipError>
fn set_package_path_ref(&self, value : &String) ->  Option<IPWorksZipError>
```

## Default Value

""

## Remarks

This property specifies the path and filename of the Open XML package to work on.

## Data Type

String

# package_property_count property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The number of records in the PackageProperty arrays.

## Syntax

*Rust Syntax*

```text
fn package_property_count(&self ) -> Result<i32, IPWorksZipError>
```

## Default Value

0

## Remarks

This property controls the size of the following arrays:

- [package_property_data_type](#package_property_data_type-property-officedoc-struct)
- [package_property_name](#package_property_name-property-officedoc-struct)
- [package_property_namespace](#package_property_namespace-property-officedoc-struct)
- [package_property_prop_id](#package_property_prop_id-property-officedoc-struct)
- [package_property_prop_set](#package_property_prop_set-property-officedoc-struct)
- [package_property_value](#package_property_value-property-officedoc-struct)

The array indices start at *0* and end at *package_property_count - 1*.

This property is read-only.

## Data Type

i32

# package_property_data_type property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The data type associated with this property, if the information is available.

## Syntax

*Rust Syntax*

```text
fn package_property_data_type(&self , PackagePropertyIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

The data type associated with this property, if the information is available.

The *PackagePropertyIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [PackagePropertyCount](#package_property_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# package_property_name property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The name of this property.

## Syntax

*Rust Syntax*

```text
fn package_property_name(&self , PackagePropertyIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

The name of this property

The *PackagePropertyIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [PackagePropertyCount](#package_property_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# package_property_namespace property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The XML Namespace URI associated with this property.

## Syntax

*Rust Syntax*

```text
fn package_property_namespace(&self , PackagePropertyIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

The XML Namespace URI associated with this property. For custom properties, this will be an empty string.

The *PackagePropertyIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [PackagePropertyCount](#package_property_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# package_property_prop_id property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

If this is a custom property, this will be the pid assigned to it.

## Syntax

*Rust Syntax*

```text
fn package_property_prop_id(&self , PackagePropertyIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

If this is a custom property, this will be the pid assigned to it.

The *PackagePropertyIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [PackagePropertyCount](#package_property_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# package_property_prop_set property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

If this is a custom property, this will be the GUID of the property set it belongs to.

## Syntax

*Rust Syntax*

```text
fn package_property_prop_set(&self , PackagePropertyIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

If this is a custom property, this will be the GUID of the property set it belongs to.

The *PackagePropertyIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [PackagePropertyCount](#package_property_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# package_property_value property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The value of this property.

## Syntax

*Rust Syntax*

```text
fn package_property_value(&self , PackagePropertyIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

The value of this property

The *PackagePropertyIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [PackagePropertyCount](#package_property_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# part_data property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The contents of the currently selected part.

## Syntax

*Rust Syntax*

```text
fn part_data(&self ) -> Result<Vec<u8>, IPWorksZipError> fn set_part_data(&self, value : Vec<u8>) ->  Option<IPWorksZipError>
fn set_part_data_ref(&self, value : &[u8]) ->  Option<IPWorksZipError>
```

## Default Value

""

## Remarks

This property will hold the contents of the part selected by [part_name](#part_name-property-officedoc-struct) after calling the [extract_part](#extract_part-method-officedoc-struct) method. It can also be set before calling [replace_part](#replace_part-method-officedoc-struct).

## Data Type

Vec

# part_name property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The name of the currently selected part.

## Syntax

*Rust Syntax*

```text
fn part_name(&self ) -> Result<String, IPWorksZipError> fn set_part_name(&self, value : &str) ->  Option<IPWorksZipError>
fn set_part_name_ref(&self, value : &String) ->  Option<IPWorksZipError>
```

## Default Value

""

## Remarks

This property specifies the name of the currently selected part in the document. If null or empty, no part is currently selected.

## Data Type

String

# relationship_count property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The number of records in the Relationship arrays.

## Syntax

*Rust Syntax*

```text
fn relationship_count(&self ) -> Result<i32, IPWorksZipError>
```

## Default Value

0

## Remarks

This property controls the size of the following arrays:

- [relationship_content_type](#relationship_content_type-property-officedoc-struct)
- [relationship_id](#relationship_id-property-officedoc-struct)
- [relationship_part_name](#relationship_part_name-property-officedoc-struct)
- [relationship_type_uri](#relationship_type_uri-property-officedoc-struct)

The array indices start at *0* and end at *relationship_count - 1*.

This property is read-only.

## Data Type

i32

# relationship_content_type property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The content type for the part referenced by this relationship, resolved from [Content_Types].

## Syntax

*Rust Syntax*

```text
fn relationship_content_type(&self , RelationshipIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

The content type for the part referenced by this relationship, resolved from [Content_Types].xml according to the Open XML packaging specification rules.

The *RelationshipIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [RelationshipCount](#relationship_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# relationship_id property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The unique ID of this relationship within this .

## Syntax

*Rust Syntax*

```text
fn relationship_id(&self , RelationshipIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

The unique ID of this relationship within this .rels file

The *RelationshipIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [RelationshipCount](#relationship_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# relationship_part_name property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The name of the part this relationship entry applies to.

## Syntax

*Rust Syntax*

```text
fn relationship_part_name(&self , RelationshipIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

The name of the part this relationship entry applies to.

The *RelationshipIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [RelationshipCount](#relationship_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# relationship_type_uri property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The XML namespace URI that specifies the meaning of this relationship.

## Syntax

*Rust Syntax*

```text
fn relationship_type_uri(&self , RelationshipIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

The XML namespace URI that specifies the meaning of this relationship.

The *RelationshipIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [RelationshipCount](#relationship_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# validate property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This property controls whether documents are validated during parsing.

## Syntax

*Rust Syntax*

```text
fn validate(&self ) -> Result<bool, IPWorksZipError> fn set_validate(&self, value : bool) ->  Option<IPWorksZipError>
```

## Default Value

true

## Remarks

When *true* (default), the document will be validated during parsing. To disable validation set validate to *false*. Disabling validation may be useful in cases in which data can still be parsed even if the document is not well formed.

## Data Type

bool

# attr_count property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The number of records in the Attr arrays.

## Syntax

*Rust Syntax*

```text
fn attr_count(&self ) -> Result<i32, IPWorksZipError>
```

## Default Value

0

## Remarks

This property controls the size of the following arrays:

- [attr_name](#attr_name-property-officedoc-struct)
- [attr_namespace](#attr_namespace-property-officedoc-struct)
- [attr_prefix](#attr_prefix-property-officedoc-struct)
- [attr_value](#attr_value-property-officedoc-struct)

The array indices start at *0* and end at *attr_count - 1*.

This property is read-only.

## Data Type

i32

# attr_name property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The Name provides the local name (without prefix) of the attribute.

## Syntax

*Rust Syntax*

```text
fn attr_name(&self , AttrIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

The [attr_name](#attr_name-property-officedoc-struct) provides the local name (without prefix) of the attribute.

The *AttrIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [AttrCount](#attr_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# attr_namespace property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This property contains the attribute namespace.

## Syntax

*Rust Syntax*

```text
fn attr_namespace(&self , AttrIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

This property contains the attribute namespace.

The *AttrIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [AttrCount](#attr_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# attr_prefix property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This property contains the attribute prefix (if any).

## Syntax

*Rust Syntax*

```text
fn attr_prefix(&self , AttrIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

This property contains the attribute prefix (if any). If the attribute does not have a prefix, this property is empty.

The *AttrIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [AttrCount](#attr_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# attr_value property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This property contains the attribute value.

## Syntax

*Rust Syntax*

```text
fn attr_value(&self , AttrIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

This property contains the attribute value.

The *AttrIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [AttrCount](#attr_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# xchild_count property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The number of records in the XChild arrays.

## Syntax

*Rust Syntax*

```text
fn xchild_count(&self ) -> Result<i32, IPWorksZipError>
```

## Default Value

0

## Remarks

This property controls the size of the following arrays:

- [xchild_name](#xchild_name-property-officedoc-struct)
- [xchild_namespace](#xchild_namespace-property-officedoc-struct)
- [xchild_prefix](#xchild_prefix-property-officedoc-struct)
- [xchild_x_text](#xchild_x_text-property-officedoc-struct)

The array indices start at *0* and end at *xchild_count - 1*.

This property is read-only.

## Data Type

i32

# xchild_name property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The Name property provides the local name (without a prefix) of the element.

## Syntax

*Rust Syntax*

```text
fn xchild_name(&self , XChildIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

The [xchild_name](#xchild_name-property-officedoc-struct) property provides the local name (without a prefix) of the element.

The *XChildIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [XChildCount](#xchild_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# xchild_namespace property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This property contains the namespace of the element.

## Syntax

*Rust Syntax*

```text
fn xchild_namespace(&self , XChildIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

This property contains the namespace of the element.

The *XChildIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [XChildCount](#xchild_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# xchild_prefix property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This property contains the prefix of the element (if any).

## Syntax

*Rust Syntax*

```text
fn xchild_prefix(&self , XChildIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

This property contains the prefix of the element (if any). If the element does not have a prefix, this property is empty.

The *XChildIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [XChildCount](#xchild_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# xchild_x_text property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This property contains the inner text of the element.

## Syntax

*Rust Syntax*

```text
fn xchild_x_text(&self , XChildIndex : i32) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

This property contains the inner text of the element.

The *XChildIndex* parameter specifies the index of the item in the array. The size of the array is controlled by the [XChildCount](#xchild_count-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# xelement property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The name of the current element.

## Syntax

*Rust Syntax*

```text
fn xelement(&self ) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

The current element is specified via the [xpath](#xpath-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# xnamespace property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The namespace of the current element.

## Syntax

*Rust Syntax*

```text
fn xnamespace(&self ) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

The current element is specified via the [xpath](#xpath-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# xparent property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This property includes the parent of the current element.

## Syntax

*Rust Syntax*

```text
fn xparent(&self ) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

The current element is specified through the [xpath](#xpath-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# xpath property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This property provides a way to point to a specific element in the document.

## Syntax

*Rust Syntax*

```text
fn xpath(&self ) -> Result<String, IPWorksZipError> fn set_xpath(&self, value : &str) ->  Option<IPWorksZipError>
fn set_xpath_ref(&self, value : &String) ->  Option<IPWorksZipError>
```

## Default Value

""

## Remarks

xpath implements a subset of the XML XPath specification, allowing you to point to specific elements in the XML document.

The path is a series of one or more element accessors separated by */*. The path can be absolute (starting with */*) or relative to the current xpath location.

 The following are possible values for an element accessor:

|  |  |
| --- | --- |
| 'name' | A particular element name |
| name[i] | The i-th subelement of the current element with the given name |
| [i] | The i-th subelement of the current element |
| [last()] | The last subelement of the current element |
| [last()-i] | The subelement located at the last location minus i in the current element |
| name[@attrname="attrvalue"] | The subelement containing a particular value for a given attribute (supports single AND double quotes) |
| .. | The parent of the current element |

 When xpath is set to a valid path, [xelement](#xelement-property-officedoc-struct) points to the name of the element, with [xparent](#xparent-property-officedoc-struct), [xnamespace](#xnamespace-property-officedoc-struct), [xprefix](#xprefix-property-officedoc-struct), [xchild_name](#xchild_name-property-officedoc-struct), [xchild_namespace](#xchild_namespace-property-officedoc-struct), [xchild_prefix](#xchild_prefix-property-officedoc-struct), [xchild_x_text](#xchild_x_text-property-officedoc-struct), and [xtext](#xtext-property-officedoc-struct) providing other properties of the element. The attributes of the current element are provided in the [attr_name](#attr_name-property-officedoc-struct), [attr_namespace](#attr_namespace-property-officedoc-struct), [attr_prefix](#attr_prefix-property-officedoc-struct), and [attr_value](#attr_value-property-officedoc-struct) properties.

build_dom must be set to *true* before parsing the document for the xpath functionality to be available.

**Example. Setting XPath:**

|  |  |
| --- | --- |
| Document root | XML.XPath = "/" |
| Specific Element | XML.XPath = "/root/SubElement1/SubElement2/" |
| i-th Child | XML.XPath = "/root/SubElement1[i]" |

## Data Type

String

# xprefix property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The prefix of the current element.

## Syntax

*Rust Syntax*

```text
fn xprefix(&self ) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

The current element is specified via the [xpath](#xpath-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# xsub_tree property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This property includes a snapshot of the current element in the document.

## Syntax

*Rust Syntax*

```text
fn xsub_tree(&self ) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

The current element is specified through the [xpath](#xpath-property-officedoc-struct) property. For this property to work, you must set [CacheContent](#CacheContent) to *true*.

This property is read-only.

## Data Type

String

# xtext property ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

The text of the current element.

## Syntax

*Rust Syntax*

```text
fn xtext(&self ) -> Result<String, IPWorksZipError>
```

## Default Value

""

## Remarks

The current element is specified via the [xpath](#xpath-property-officedoc-struct) property.

This property is read-only.

## Data Type

String

# close method ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

Closes the Open XML package archive.

## Syntax

*Rust Syntax*

```text
fn close(&self) -> Result<(), IPWorksZipError>
```

## Remarks

When this method is called, the struct will close the current archive and release all resources.

# config method ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

Sets or retrieves a configuration setting.

## Syntax

*Rust Syntax*

```text
fn config(&self, configuration_string : &str) ->  Result<String, IPWorksZipError>
```

## Remarks

config is a generic method available in every struct. It is used to set and retrieve [configuration settings](#config-settings-officedoc-struct) for the struct.

These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the struct, access to these *internal properties* is provided through the config method.

To set a configuration setting named *PROPERTY*, you must call *Config("PROPERTY=VALUE")*, where *VALUE* is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).

To read (query) the value of a [configuration setting](#config-settings-officedoc-struct), you must call *Config("PROPERTY")*. The value will be returned as a string.

# extract_part method ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

Reads the contents of the currently selected part.

## Syntax

*Rust Syntax*

```text
fn extract_part(&self) -> Result<(), IPWorksZipError>
```

## Remarks

If the part specified by the [part_name](#part_name-property-officedoc-struct) property exists, the corresponding physical file will be extracted from the archive and will be available through the [part_data](#part_data-property-officedoc-struct) property.

If the part doesn't exists, or it's stored in interleaved format, an error will be raised.

# find_part_by_type method ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

Looks up a part in the current relationships file by it's type namespace URI.

## Syntax

*Rust Syntax*

```text
fn find_part_by_type(&self, type_uri : &str) ->  Result<String, IPWorksZipError>
```

## Remarks

If a matching part can be found, it's part name is returned. Otherwise, an empty string is returned.

# get_property_value method ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

Returns the value of the specified package property.

## Syntax

*Rust Syntax*

```text
fn get_property_value(&self, prop_name : &str, prop_namespace : &str) ->  Result<String, IPWorksZipError>
```

## Remarks

Looks up a package property named *prop_name* in namespace *prop_namespace* in the core and app properties tables and returns it's value, if found.

If the property doesn't exists, an empty string is returned.

For custom properties. use an empty string ("") as the value of the *prop_namespace* parameter.

# list_parts method ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

List all the parts contained in the document and their relationships.

## Syntax

*Rust Syntax*

```text
fn list_parts(&self) -> Result<(), IPWorksZipError>
```

## Remarks

When this method is called, the struct will read all the relationships in the document, recursively, and populate the relationships collection.

# open method ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

Opens the Open XML package archive.

## Syntax

*Rust Syntax*

```text
fn open(&self) -> Result<(), IPWorksZipError>
```

## Remarks

When this method is called, the struct will attempt to open the archive specified in [package_path](#package_path-property-officedoc-struct) and extract package properties, content types and parse the master relationships file in the archive.

# parse_part method ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

Parses the specified part as XML.

## Syntax

*Rust Syntax*

```text
fn parse_part(&self) -> Result<(), IPWorksZipError>
```

## Remarks

If the part specified by [part_name](#part_name-property-officedoc-struct) exists, the corresponding physical file will be extracted from the archive and parsed as XML. If build_dom is enabled, the DOM will be built internally and you can use XPath to query the resulting document, using the [xpath](#xpath-property-officedoc-struct) property. If build_dom is disabled, only the XML parser-related events will be fired.

# read_relationships method ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

Reads the relationships file in the archive associated with the specified part.

## Syntax

*Rust Syntax*

```text
fn read_relationships(&self) -> Result<(), IPWorksZipError>
```

## Remarks

When this method is called, the struct will look for a .rels file associated with the part specified by the [part_name](#part_name-property-officedoc-struct) property. If found, the relationships collection will now expose the contents of the relationships for that part.

# replace_part method ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

Replaces the contents of the specified part in the package.

## Syntax

*Rust Syntax*

```text
fn replace_part(&self) -> Result<(), IPWorksZipError>
```

## Remarks

If the part specified by the [part_name](#part_name-property-officedoc-struct) property exists, the corresponding physical file will be replaced with the contents of the [part_data](#part_data-property-officedoc-struct) property. The package file will be modified in place right away.

If the part doesn't exists, it's stored in interleaved format, or [part_data](#part_data-property-officedoc-struct) is null or empty, an error will be raised.

# reset method ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

Resets the struct.

## Syntax

*Rust Syntax*

```text
fn reset(&self) -> Result<(), IPWorksZipError>
```

## Remarks

reset resets the state of the struct. All properties will be set to their default values, and any files open will be closed.

# resolve_content_type method ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

Returns the content type of the specified part.

## Syntax

*Rust Syntax*

```text
fn resolve_content_type(&self) ->  Result<String, IPWorksZipError>
```

## Remarks

Applies the content type resolution rules specified in the Open XML packaging specification and returns the content type associated with [part_name](#part_name-property-officedoc-struct) in the archive.

If there's no content type mapped for the part or for the extension, an empty string is returned.

# on_begin_file event ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

Fired before each file is processed.

## Syntax

*Rust Syntax*

```text
// OfficeDocBeginFileEventArgs carries the OfficeDoc BeginFile event's parameters.
pub struct OfficeDocBeginFileEventArgs {
  fn index(&self) -> i32
  fn skip(&self) -> bool
  fn set_skip(&self, value : bool)
}

// OfficeDocBeginFileEvent defines the signature of the OfficeDoc BeginFile event's handler function.
pub trait OfficeDocBeginFileEvent {
  fn on_begin_file(&self, sender : OfficeDoc, e : &mut OfficeDocBeginFileEventArgs);
}

impl <'a> OfficeDoc<'a> {
  pub fn on_begin_file(&self) -> &'a dyn OfficeDocBeginFileEvent;
  pub fn set_on_begin_file(&mut self, value : &'a dyn OfficeDocBeginFileEvent);
  ...
}
```

## Remarks

on_begin_file is fired before each file is processed by the compressor or decompressor, as appropriate. *index* contains the array index of the file about to be processed, and the [file_compressed_name](#OfficeDoc_p_FileCompressedName), [file_decompressed_name](#OfficeDoc_p_FileDecompressedName), [file_compressed_size](#OfficeDoc_p_FileCompressedSize) (decompression only), and [file_decompressed_size](#OfficeDoc_p_FileDecompressedSize) fields of the files collection for this index contain more detailed information about the file about to be processed.

When extracting, an alternate location may be specified by trapping the event, and modifying [file_decompressed_name](#OfficeDoc_p_FileDecompressedName) and/or extract_to_path. If [file_decompressed_name](#OfficeDoc_p_FileDecompressedName) is set to an empty string, the file will not be written to disk. If [WriteToProgressEvent](#WriteToProgressEvent) is true, the file will still be decompressed, and the data may be extracted through the [on_progress](#on_progress-event-officedoc-struct) event.

This event may also be trapped while compressing. [file_compressed_name](#OfficeDoc_p_FileCompressedName) and [file_decompressed_name](#OfficeDoc_p_FileDecompressedName) may be changed.

 You may set the *skip* parameter to true in order to skip the file completely while compressing or extracting.

# on_characters event ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This event is fired for plaintext segments of the input stream.

## Syntax

*Rust Syntax*

```text
// OfficeDocCharactersEventArgs carries the OfficeDoc Characters event's parameters.
pub struct OfficeDocCharactersEventArgs {
  fn text(&self) -> &String
}

// OfficeDocCharactersEvent defines the signature of the OfficeDoc Characters event's handler function.
pub trait OfficeDocCharactersEvent {
  fn on_characters(&self, sender : OfficeDoc, e : &mut OfficeDocCharactersEventArgs);
}

impl <'a> OfficeDoc<'a> {
  pub fn on_characters(&self) -> &'a dyn OfficeDocCharactersEvent;
  pub fn set_on_characters(&mut self, value : &'a dyn OfficeDocCharactersEvent);
  ...
}
```

## Remarks

The on_characters event provides the plaintext content of the XML document (i.e., the text inside the tags). The text is provided through the *text* parameter.

The text includes whitespace as well as end-of-line characters, except for ignorable whitespace, which is fired through the [on_ignorable_whitespace](#on_ignorable_whitespace-event-officedoc-struct) event.

# on_comment event ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This event is fired when a comment section is encountered.

## Syntax

*Rust Syntax*

```text
// OfficeDocCommentEventArgs carries the OfficeDoc Comment event's parameters.
pub struct OfficeDocCommentEventArgs {
  fn text(&self) -> &String
}

// OfficeDocCommentEvent defines the signature of the OfficeDoc Comment event's handler function.
pub trait OfficeDocCommentEvent {
  fn on_comment(&self, sender : OfficeDoc, e : &mut OfficeDocCommentEventArgs);
}

impl <'a> OfficeDoc<'a> {
  pub fn on_comment(&self) -> &'a dyn OfficeDocCommentEvent;
  pub fn set_on_comment(&mut self, value : &'a dyn OfficeDocCommentEvent);
  ...
}
```

## Remarks

The on_comment event is fired whenever a comment section (*<!-- ...text... -->*) is found in the document.

The full text of the comment is provided by the *text* parameter.

# on_end_element event ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This event is fired when an end-element tag is encountered.

## Syntax

*Rust Syntax*

```text
// OfficeDocEndElementEventArgs carries the OfficeDoc EndElement event's parameters.
pub struct OfficeDocEndElementEventArgs {
  fn namespace(&self) -> &String
  fn element(&self) -> &String
  fn q_name(&self) -> &String
  fn is_empty(&self) -> bool
}

// OfficeDocEndElementEvent defines the signature of the OfficeDoc EndElement event's handler function.
pub trait OfficeDocEndElementEvent {
  fn on_end_element(&self, sender : OfficeDoc, e : &mut OfficeDocEndElementEventArgs);
}

impl <'a> OfficeDoc<'a> {
  pub fn on_end_element(&self) -> &'a dyn OfficeDocEndElementEvent;
  pub fn set_on_end_element(&mut self, value : &'a dyn OfficeDocEndElementEvent);
  ...
}
```

## Remarks

The on_end_element event is fired when an end-element tag is found in the document.

The element name is provided by the *element* parameter.

The *is_empty* parameter is *true* when the event corresponds to an empty element declaration.

# on_end_file event ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

Fired after each file is processed.

## Syntax

*Rust Syntax*

```text
// OfficeDocEndFileEventArgs carries the OfficeDoc EndFile event's parameters.
pub struct OfficeDocEndFileEventArgs {
  fn index(&self) -> i32
}

// OfficeDocEndFileEvent defines the signature of the OfficeDoc EndFile event's handler function.
pub trait OfficeDocEndFileEvent {
  fn on_end_file(&self, sender : OfficeDoc, e : &mut OfficeDocEndFileEventArgs);
}

impl <'a> OfficeDoc<'a> {
  pub fn on_end_file(&self) -> &'a dyn OfficeDocEndFileEvent;
  pub fn set_on_end_file(&mut self, value : &'a dyn OfficeDocEndFileEvent);
  ...
}
```

## Remarks

on_end_file is fired after each file is processed by the compressor or decompressor, as appropriate. *index* contains the array index of the file processed, and the [file_compressed_name](#OfficeDoc_p_FileCompressedName), [file_decompressed_name](#OfficeDoc_p_FileDecompressedName), [file_compressed_size](#OfficeDoc_p_FileCompressedSize), and [file_decompressed_size](#OfficeDoc_p_FileDecompressedSize) fields in the files collection for this index contain more detailed information about the file processed.

# on_end_prefix_mapping event ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This event is fired when leaving the scope of a namespace declaration.

## Syntax

*Rust Syntax*

```text
// OfficeDocEndPrefixMappingEventArgs carries the OfficeDoc EndPrefixMapping event's parameters.
pub struct OfficeDocEndPrefixMappingEventArgs {
  fn prefix(&self) -> &String
}

// OfficeDocEndPrefixMappingEvent defines the signature of the OfficeDoc EndPrefixMapping event's handler function.
pub trait OfficeDocEndPrefixMappingEvent {
  fn on_end_prefix_mapping(&self, sender : OfficeDoc, e : &mut OfficeDocEndPrefixMappingEventArgs);
}

impl <'a> OfficeDoc<'a> {
  pub fn on_end_prefix_mapping(&self) -> &'a dyn OfficeDocEndPrefixMappingEvent;
  pub fn set_on_end_prefix_mapping(&mut self, value : &'a dyn OfficeDocEndPrefixMappingEvent);
  ...
}
```

## Remarks

The [on_start_prefix_mapping](#on_start_prefix_mapping-event-officedoc-struct) event is fired when entering the scope of a namespace declaration.

# on_error event ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

Fired when information is available about errors during data delivery.

## Syntax

*Rust Syntax*

```text
// OfficeDocErrorEventArgs carries the OfficeDoc Error event's parameters.
pub struct OfficeDocErrorEventArgs {
  fn error_code(&self) -> i32
  fn description(&self) -> &String
}

// OfficeDocErrorEvent defines the signature of the OfficeDoc Error event's handler function.
pub trait OfficeDocErrorEvent {
  fn on_error(&self, sender : OfficeDoc, e : &mut OfficeDocErrorEventArgs);
}

impl <'a> OfficeDoc<'a> {
  pub fn on_error(&self) -> &'a dyn OfficeDocErrorEvent;
  pub fn set_on_error(&mut self, value : &'a dyn OfficeDocErrorEvent);
  ...
}
```

## Remarks

The on_error event is fired in case of exceptional conditions during message processing. Normally the struct fails with an error.

The *error_code* parameter contains an error code, and the *description* parameter contains a textual description of the error. For a list of valid error codes and their descriptions, please refer to the [Error Codes](#trappable-errors-officedoc-struct) section.

# on_eval_entity event ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This event is fired every time an entity needs to be evaluated.

## Syntax

*Rust Syntax*

```text
// OfficeDocEvalEntityEventArgs carries the OfficeDoc EvalEntity event's parameters.
pub struct OfficeDocEvalEntityEventArgs {
  fn entity(&self) -> &String
  fn value(&self) -> &String
  fn set_value(&self, value : &str)
  fn set_value_ref(&self, value : &String)
}

// OfficeDocEvalEntityEvent defines the signature of the OfficeDoc EvalEntity event's handler function.
pub trait OfficeDocEvalEntityEvent {
  fn on_eval_entity(&self, sender : OfficeDoc, e : &mut OfficeDocEvalEntityEventArgs);
}

impl <'a> OfficeDoc<'a> {
  pub fn on_eval_entity(&self) -> &'a dyn OfficeDocEvalEntityEvent;
  pub fn set_on_eval_entity(&mut self, value : &'a dyn OfficeDocEvalEntityEvent);
  ...
}
```

## Remarks

The *value* parameter contains a suggested value for the entity (normally the entity name itself). You may set *value* to a value of your choice, which will later be passed into the text stream.

# on_ignorable_whitespace event ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This event is fired when a section of ignorable whitespace is encountered.

## Syntax

*Rust Syntax*

```text
// OfficeDocIgnorableWhitespaceEventArgs carries the OfficeDoc IgnorableWhitespace event's parameters.
pub struct OfficeDocIgnorableWhitespaceEventArgs {
  fn text(&self) -> &String
}

// OfficeDocIgnorableWhitespaceEvent defines the signature of the OfficeDoc IgnorableWhitespace event's handler function.
pub trait OfficeDocIgnorableWhitespaceEvent {
  fn on_ignorable_whitespace(&self, sender : OfficeDoc, e : &mut OfficeDocIgnorableWhitespaceEventArgs);
}

impl <'a> OfficeDoc<'a> {
  pub fn on_ignorable_whitespace(&self) -> &'a dyn OfficeDocIgnorableWhitespaceEvent;
  pub fn set_on_ignorable_whitespace(&mut self, value : &'a dyn OfficeDocIgnorableWhitespaceEvent);
  ...
}
```

## Remarks

The ignorable whitespace section is provided by the *text* parameter.

# on_meta event ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This event fires when a meta section is encountered.

## Syntax

*Rust Syntax*

```text
// OfficeDocMetaEventArgs carries the OfficeDoc Meta event's parameters.
pub struct OfficeDocMetaEventArgs {
  fn text(&self) -> &String
}

// OfficeDocMetaEvent defines the signature of the OfficeDoc Meta event's handler function.
pub trait OfficeDocMetaEvent {
  fn on_meta(&self, sender : OfficeDoc, e : &mut OfficeDocMetaEventArgs);
}

impl <'a> OfficeDoc<'a> {
  pub fn on_meta(&self) -> &'a dyn OfficeDocMetaEvent;
  pub fn set_on_meta(&mut self, value : &'a dyn OfficeDocMetaEvent);
  ...
}
```

## Remarks

The on_meta event is fired whenever a meta information section (*<! ...text... >*) is found in the document.

The full text of the meta section is provided by the *text* parameter.

# on_overwrite event ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

Fired whenever a file exists and may be overwritten.

## Syntax

*Rust Syntax*

```text
// OfficeDocOverwriteEventArgs carries the OfficeDoc Overwrite event's parameters.
pub struct OfficeDocOverwriteEventArgs {
  fn file_name(&self) -> &String
  fn set_file_name(&self, value : &str)
  fn set_file_name_ref(&self, value : &String)
  fn overwrite(&self) -> bool
  fn set_overwrite(&self, value : bool)
}

// OfficeDocOverwriteEvent defines the signature of the OfficeDoc Overwrite event's handler function.
pub trait OfficeDocOverwriteEvent {
  fn on_overwrite(&self, sender : OfficeDoc, e : &mut OfficeDocOverwriteEventArgs);
}

impl <'a> OfficeDoc<'a> {
  pub fn on_overwrite(&self) -> &'a dyn OfficeDocOverwriteEvent;
  pub fn set_on_overwrite(&mut self, value : &'a dyn OfficeDocOverwriteEvent);
  ...
}
```

## Remarks

on_overwrite is fired when a file is about to be overwritten, and would overwrite an existing file. The event is fired during decompression.

*file_name* contains the full name of the file, specified with its pathname.

*overwrite* specifies whether or not the file will be overwritten. For Zip, Jar, and Tar, this is equal by default to the value of the overwrite_files property. For Gzip, this value defaults to true.

Either of the parameters may be changed when the event is fired. Changing the value of *overwrite* will override the default behavior of the struct, and cause the file to be overwritten or not overwritten, depending on the value set. If *file_name* is changed, the value of *overwrite* will be ignored, and the file will be written with the specified name. If a file of the new name also exists this file will be silently overwritten.

# on_pi event ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This event is fired when a processing instruction section is encountered.

## Syntax

*Rust Syntax*

```text
// OfficeDocPIEventArgs carries the OfficeDoc PI event's parameters.
pub struct OfficeDocPIEventArgs {
  fn text(&self) -> &String
}

// OfficeDocPIEvent defines the signature of the OfficeDoc PI event's handler function.
pub trait OfficeDocPIEvent {
  fn on_pi(&self, sender : OfficeDoc, e : &mut OfficeDocPIEventArgs);
}

impl <'a> OfficeDoc<'a> {
  pub fn on_pi(&self) -> &'a dyn OfficeDocPIEvent;
  pub fn set_on_pi(&mut self, value : &'a dyn OfficeDocPIEvent);
  ...
}
```

## Remarks

The on_pi event is fired whenever a processing instruction section (*<? ...text... ?>*) is found in the document.

The full text of the processing instruction is provided by the *text* parameter.

# on_progress event ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

Fired as progress is made.

## Syntax

*Rust Syntax*

```text
// OfficeDocProgressEventArgs carries the OfficeDoc Progress event's parameters.
pub struct OfficeDocProgressEventArgs {
  fn data(&self) -> &[u8]
  fn file_name(&self) -> &String
  fn bytes_processed(&self) -> i64
  fn percent_processed(&self) -> i32
}

// OfficeDocProgressEvent defines the signature of the OfficeDoc Progress event's handler function.
pub trait OfficeDocProgressEvent {
  fn on_progress(&self, sender : OfficeDoc, e : &mut OfficeDocProgressEventArgs);
}

impl <'a> OfficeDoc<'a> {
  pub fn on_progress(&self) -> &'a dyn OfficeDocProgressEvent;
  pub fn set_on_progress(&mut self, value : &'a dyn OfficeDocProgressEvent);
  ...
}
```

## Remarks

The on_progress event is automatically fired as compression or decompression is performed. When [WriteToProgressEvent](#WriteToProgressEvent) is true, the output data is provided through the *data* parameter, allowing for it to be streamed out.

*file_name* contains the name of the file being written. If no file is being written, *file_name* will contain an empty string, and the output data will be provided exclusively through this event.

*bytes_processed* contains the total number of uncompressed bytes processed. *percent_processed* contains the percent of uncompressed bytes processed, corresponding roughly to the running time of the operation.

For **Gzip** extraction only, *bytes_processed* and *percent_processed* will reflect the number of compressed bytes extracted, as it is generally impossible to predetermine the total uncompressed size.

If [WriteToProgressEvent](#WriteToProgressEvent) is false, *data* will contain null.

# on_special_section event ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This event is fired when a special section is encountered.

## Syntax

*Rust Syntax*

```text
// OfficeDocSpecialSectionEventArgs carries the OfficeDoc SpecialSection event's parameters.
pub struct OfficeDocSpecialSectionEventArgs {
  fn section_id(&self) -> &String
  fn text(&self) -> &String
}

// OfficeDocSpecialSectionEvent defines the signature of the OfficeDoc SpecialSection event's handler function.
pub trait OfficeDocSpecialSectionEvent {
  fn on_special_section(&self, sender : OfficeDoc, e : &mut OfficeDocSpecialSectionEventArgs);
}

impl <'a> OfficeDoc<'a> {
  pub fn on_special_section(&self) -> &'a dyn OfficeDocSpecialSectionEvent;
  pub fn set_on_special_section(&mut self, value : &'a dyn OfficeDocSpecialSectionEvent);
  ...
}
```

## Remarks

The on_special_section event is fired whenever a special section (such as *<![ CDATA [ ...text... ]]>*) is found in the document.

The full text of the special section is provided by the *text* parameter, and the *section_id* parameter provides the section identifier (e.g., *CDATA*).

# on_start_element event ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This event is fired when a begin-element tag is encountered in the document.

## Syntax

*Rust Syntax*

```text
// OfficeDocStartElementEventArgs carries the OfficeDoc StartElement event's parameters.
pub struct OfficeDocStartElementEventArgs {
  fn namespace(&self) -> &String
  fn element(&self) -> &String
  fn q_name(&self) -> &String
  fn is_empty(&self) -> bool
}

// OfficeDocStartElementEvent defines the signature of the OfficeDoc StartElement event's handler function.
pub trait OfficeDocStartElementEvent {
  fn on_start_element(&self, sender : OfficeDoc, e : &mut OfficeDocStartElementEventArgs);
}

impl <'a> OfficeDoc<'a> {
  pub fn on_start_element(&self) -> &'a dyn OfficeDocStartElementEvent;
  pub fn set_on_start_element(&mut self, value : &'a dyn OfficeDocStartElementEvent);
  ...
}
```

## Remarks

The on_start_element event is fired when a begin-element tag is found in the document.

The element name is provided through the *element* parameter. The attribute names and values (if any) are provided through the [attr_name](#attr_name-property-officedoc-struct), [attr_namespace](#attr_namespace-property-officedoc-struct), [attr_prefix](#attr_prefix-property-officedoc-struct), and [attr_value](#attr_value-property-officedoc-struct) properties.

The *is_empty* parameter is *true* when the event corresponds to an empty element declaration.

# on_start_prefix_mapping event ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

This event is fired when entering the scope of a namespace declaration.

## Syntax

*Rust Syntax*

```text
// OfficeDocStartPrefixMappingEventArgs carries the OfficeDoc StartPrefixMapping event's parameters.
pub struct OfficeDocStartPrefixMappingEventArgs {
  fn prefix(&self) -> &String
  fn uri(&self) -> &String
}

// OfficeDocStartPrefixMappingEvent defines the signature of the OfficeDoc StartPrefixMapping event's handler function.
pub trait OfficeDocStartPrefixMappingEvent {
  fn on_start_prefix_mapping(&self, sender : OfficeDoc, e : &mut OfficeDocStartPrefixMappingEventArgs);
}

impl <'a> OfficeDoc<'a> {
  pub fn on_start_prefix_mapping(&self) -> &'a dyn OfficeDocStartPrefixMappingEvent;
  pub fn set_on_start_prefix_mapping(&mut self, value : &'a dyn OfficeDocStartPrefixMappingEvent);
  ...
}
```

## Remarks

The [on_end_prefix_mapping](#on_end_prefix_mapping-event-officedoc-struct) event is fired when leaving the scope of a namespace declaration.

# Config Settings ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

 The struct accepts one or more of the following *configuration settings*. Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the struct, access to these *internal properties* is provided through the [config](#config-method-officedoc-struct) method.

### OfficeDoc Config Settings

**NormalizePartName**: Whether to normalize Part Names.Sometimes the Part Names retrieved from a document will be of a format that is not directly usable in the [part_name](#part_name-property-officedoc-struct) property when retrieving the part. For example:

```text
/ppt/slides/../media/image1.jpeg
```

When this option is set to True the component will automatically normalize these Part Names so that they can be directly used in the [part_name](#part_name-property-officedoc-struct) property for retrieving the part. For example, the above would become:

```text
/ppt/media/image1.jpeg
```

The default is True.

**RelationshipIsExternal[x]**: Whether the relationship part is internal or external.Some relationships in an Office document may be external items, such as URLs and files on disk. These relationships are not directly accessible via [extract_part](#extract_part-method-officedoc-struct). This configuration option will return "1" if the relationship at index "x" of relationships is an external part. Otherwise it will return "0"

### Base Config Settings

**BuildInfo**: Information about the product's build.When queried, this setting will return a string containing information about the product's build.

**CodePage**: The system code page used for Unicode to Multibyte translations.The default code page is Unicode UTF-8 (65001).

The following is a list of valid code page identifiers:

|  |  |
| --- | --- |
| Identifier | Name |
| 037 | IBM EBCDIC - U.S./Canada |
| 437 | OEM - United States |
| 500 | IBM EBCDIC - International |
| 708 | Arabic - ASMO 708 |
| 709 | Arabic - ASMO 449+, BCON V4 |
| 710 | Arabic - Transparent Arabic |
| 720 | Arabic - Transparent ASMO |
| 737 | OEM - Greek (formerly 437G) |
| 775 | OEM - Baltic |
| 850 | OEM - Multilingual Latin I |
| 852 | OEM - Latin II |
| 855 | OEM - Cyrillic (primarily Russian) |
| 857 | OEM - Turkish |
| 858 | OEM - Multilingual Latin I + Euro symbol |
| 860 | OEM - Portuguese |
| 861 | OEM - Icelandic |
| 862 | OEM - Hebrew |
| 863 | OEM - Canadian-French |
| 864 | OEM - Arabic |
| 865 | OEM - Nordic |
| 866 | OEM - Russian |
| 869 | OEM - Modern Greek |
| 870 | IBM EBCDIC - Multilingual/ROECE (Latin-2) |
| 874 | ANSI/OEM - Thai (same as 28605, ISO 8859-15) |
| 875 | IBM EBCDIC - Modern Greek |
| 932 | ANSI/OEM - Japanese, Shift-JIS |
| 936 | ANSI/OEM - Simplified Chinese (PRC, Singapore) |
| 949 | ANSI/OEM - Korean (Unified Hangul Code) |
| 950 | ANSI/OEM - Traditional Chinese (Taiwan; Hong Kong SAR, PRC) |
| 1026 | IBM EBCDIC - Turkish (Latin-5) |
| 1047 | IBM EBCDIC - Latin 1/Open System |
| 1140 | IBM EBCDIC - U.S./Canada (037 + Euro symbol) |
| 1141 | IBM EBCDIC - Germany (20273 + Euro symbol) |
| 1142 | IBM EBCDIC - Denmark/Norway (20277 + Euro symbol) |
| 1143 | IBM EBCDIC - Finland/Sweden (20278 + Euro symbol) |
| 1144 | IBM EBCDIC - Italy (20280 + Euro symbol) |
| 1145 | IBM EBCDIC - Latin America/Spain (20284 + Euro symbol) |
| 1146 | IBM EBCDIC - United Kingdom (20285 + Euro symbol) |
| 1147 | IBM EBCDIC - France (20297 + Euro symbol) |
| 1148 | IBM EBCDIC - International (500 + Euro symbol) |
| 1149 | IBM EBCDIC - Icelandic (20871 + Euro symbol) |
| 1200 | Unicode UCS-2 Little-Endian (BMP of ISO 10646) |
| 1201 | Unicode UCS-2 Big-Endian |
| 1250 | ANSI - Central European |
| 1251 | ANSI - Cyrillic |
| 1252 | ANSI - Latin I |
| 1253 | ANSI - Greek |
| 1254 | ANSI - Turkish |
| 1255 | ANSI - Hebrew |
| 1256 | ANSI - Arabic |
| 1257 | ANSI - Baltic |
| 1258 | ANSI/OEM - Vietnamese |
| 1361 | Korean (Johab) |
| 10000 | MAC - Roman |
| 10001 | MAC - Japanese |
| 10002 | MAC - Traditional Chinese (Big5) |
| 10003 | MAC - Korean |
| 10004 | MAC - Arabic |
| 10005 | MAC - Hebrew |
| 10006 | MAC - Greek I |
| 10007 | MAC - Cyrillic |
| 10008 | MAC - Simplified Chinese (GB 2312) |
| 10010 | MAC - Romania |
| 10017 | MAC - Ukraine |
| 10021 | MAC - Thai |
| 10029 | MAC - Latin II |
| 10079 | MAC - Icelandic |
| 10081 | MAC - Turkish |
| 10082 | MAC - Croatia |
| 12000 | Unicode UCS-4 Little-Endian |
| 12001 | Unicode UCS-4 Big-Endian |
| 20000 | CNS - Taiwan |
| 20001 | TCA - Taiwan |
| 20002 | Eten - Taiwan |
| 20003 | IBM5550 - Taiwan |
| 20004 | TeleText - Taiwan |
| 20005 | Wang - Taiwan |
| 20105 | IA5 IRV International Alphabet No. 5 (7-bit) |
| 20106 | IA5 German (7-bit) |
| 20107 | IA5 Swedish (7-bit) |
| 20108 | IA5 Norwegian (7-bit) |
| 20127 | US-ASCII (7-bit) |
| 20261 | T.61 |
| 20269 | ISO 6937 Non-Spacing Accent |
| 20273 | IBM EBCDIC - Germany |
| 20277 | IBM EBCDIC - Denmark/Norway |
| 20278 | IBM EBCDIC - Finland/Sweden |
| 20280 | IBM EBCDIC - Italy |
| 20284 | IBM EBCDIC - Latin America/Spain |
| 20285 | IBM EBCDIC - United Kingdom |
| 20290 | IBM EBCDIC - Japanese Katakana Extended |
| 20297 | IBM EBCDIC - France |
| 20420 | IBM EBCDIC - Arabic |
| 20423 | IBM EBCDIC - Greek |
| 20424 | IBM EBCDIC - Hebrew |
| 20833 | IBM EBCDIC - Korean Extended |
| 20838 | IBM EBCDIC - Thai |
| 20866 | Russian - KOI8-R |
| 20871 | IBM EBCDIC - Icelandic |
| 20880 | IBM EBCDIC - Cyrillic (Russian) |
| 20905 | IBM EBCDIC - Turkish |
| 20924 | IBM EBCDIC - Latin-1/Open System (1047 + Euro symbol) |
| 20932 | JIS X 0208-1990 & 0121-1990 |
| 20936 | Simplified Chinese (GB2312) |
| 21025 | IBM EBCDIC - Cyrillic (Serbian, Bulgarian) |
| 21027 | Extended Alpha Lowercase |
| 21866 | Ukrainian (KOI8-U) |
| 28591 | ISO 8859-1 Latin I |
| 28592 | ISO 8859-2 Central Europe |
| 28593 | ISO 8859-3 Latin 3 |
| 28594 | ISO 8859-4 Baltic |
| 28595 | ISO 8859-5 Cyrillic |
| 28596 | ISO 8859-6 Arabic |
| 28597 | ISO 8859-7 Greek |
| 28598 | ISO 8859-8 Hebrew |
| 28599 | ISO 8859-9 Latin 5 |
| 28605 | ISO 8859-15 Latin 9 |
| 29001 | Europa 3 |
| 38598 | ISO 8859-8 Hebrew |
| 50220 | ISO 2022 Japanese with no halfwidth Katakana |
| 50221 | ISO 2022 Japanese with halfwidth Katakana |
| 50222 | ISO 2022 Japanese JIS X 0201-1989 |
| 50225 | ISO 2022 Korean |
| 50227 | ISO 2022 Simplified Chinese |
| 50229 | ISO 2022 Traditional Chinese |
| 50930 | Japanese (Katakana) Extended |
| 50931 | US/Canada and Japanese |
| 50933 | Korean Extended and Korean |
| 50935 | Simplified Chinese Extended and Simplified Chinese |
| 50936 | Simplified Chinese |
| 50937 | US/Canada and Traditional Chinese |
| 50939 | Japanese (Latin) Extended and Japanese |
| 51932 | EUC - Japanese |
| 51936 | EUC - Simplified Chinese |
| 51949 | EUC - Korean |
| 51950 | EUC - Traditional Chinese |
| 52936 | HZ-GB2312 Simplified Chinese |
| 54936 | Windows XP: GB18030 Simplified Chinese (4 Byte) |
| 57002 | ISCII Devanagari |
| 57003 | ISCII Bengali |
| 57004 | ISCII Tamil |
| 57005 | ISCII Telugu |
| 57006 | ISCII Assamese |
| 57007 | ISCII Oriya |
| 57008 | ISCII Kannada |
| 57009 | ISCII Malayalam |
| 57010 | ISCII Gujarati |
| 57011 | ISCII Punjabi |
| 65000 | Unicode UTF-7 |
| 65001 | Unicode UTF-8 |

 The following is a list of valid code page identifiers for Mac OS only:

|  |  |
| --- | --- |
| Identifier | Name |
| 1 | ASCII |
| 2 | NEXTSTEP |
| 3 | JapaneseEUC |
| 4 | UTF8 |
| 5 | ISOLatin1 |
| 6 | Symbol |
| 7 | NonLossyASCII |
| 8 | ShiftJIS |
| 9 | ISOLatin2 |
| 10 | Unicode |
| 11 | WindowsCP1251 |
| 12 | WindowsCP1252 |
| 13 | WindowsCP1253 |
| 14 | WindowsCP1254 |
| 15 | WindowsCP1250 |
| 21 | ISO2022JP |
| 30 | MacOSRoman |
| 10 | UTF16String |
| 0x90000100 | UTF16BigEndian |
| 0x94000100 | UTF16LittleEndian |
| 0x8c000100 | UTF32String |
| 0x98000100 | UTF32BigEndian |
| 0x9c000100 | UTF32LittleEndian |
| 65536 | Proprietary |

**LicenseInfo**: Information about the current license.When queried, this setting will return a string containing information about the license this instance of a struct is using. It will return the following information:

- Product: The product the license is for.
- Product Key: The key the license was generated from.
- License Source: Where the license was found (e.g., RuntimeLicense, License File).
- License Type: The type of license installed (e.g., Royalty Free, Single Server).
- Last Valid Build: The last valid build number for which the license will work.

**MaskSensitiveData**: Whether sensitive data is masked in log messages.In certain circumstances it may be beneficial to mask sensitive data, like passwords, in log messages. Set this to *true* to mask sensitive data. The default is *true*.

**UseInternalSecurityAPI**: Whether or not to use the system security libraries or an internal implementation. When set to *false*, the struct will use the system security libraries by default to perform cryptographic functions where applicable.

Setting this configuration setting to *true* tells the struct to use the internal implementation instead of using the system security libraries.

 On Windows, this setting is set to *false* by default. On Linux/macOS, this setting is set to *true* by default.

 To use the system security libraries for Linux, OpenSSL support must be enabled. For more information on how to enable OpenSSL, please refer to the [OpenSSL Notes](platforms.md) section.

# Trappable Errors ([OfficeDoc](#struct-ipworkszipofficedoc) Struct)

 **Errors**

The following errors may be generated by the struct. Note that frequently the error message will contain more specific information than what is listed here.

Note that some non-fatal errors may be trapped and explicitly ignored in the [on_error](#on_error-event-officedoc-struct) event. This will allow the struct to continue operation even in case of error.

### OfficeDoc Errors

|  |  |
| --- | --- |
| 268 | The specified part name could not be found on the package, or the part is stored in interleaved format. |
