ImportMapping Class
Represents a mapping of styles (and other referenced objects) from source document to destination document when importing elements between two different DocumentModel instances.
- Inheritance:
- System.ObjectImportMapping
Remarks
Same ImportMapping instance can be used for multiple imports. This improves performances because matching styles (mapping from source document style to destination document style) do not have to be identified in subsequent imports if they where matched in previous imports. It also reduces memory usage and provides more consistent behavior in some particular scenarios which involve importing list paragraphs, list styles and paragraph styles which contain list formatting.
Constructors
ImportMapping(DocumentModel, DocumentModel, Boolean)
Initializes a new instance of the ImportMapping class.
public ImportMapping(DocumentModel sourceDocument, DocumentModel destinationDocument, bool useDestinationStyles)
Public Sub New(sourceDocument As DocumentModel, destinationDocument As DocumentModel, useDestinationStyles As Boolean)
Parameters
sourceDocument
- DocumentModel
The source document.
destinationDocument
- DocumentModel
The destination document.
useDestinationStyles
- System.Boolean
true to use destination document styles if it has the same name as source style (but doesn't have the same formatting); otherwise false to use source document styles.
Exceptions
- System.ArgumentNullException
sourceDocument
or destinationDocument
is null.
ImportMapping(DocumentModel, DocumentModel, Boolean, Boolean)
Initializes a new instance of the ImportMapping class.
public ImportMapping(DocumentModel sourceDocument, DocumentModel destinationDocument, bool useDestinationStyles, bool resolveFormatting)
Public Sub New(sourceDocument As DocumentModel, destinationDocument As DocumentModel, useDestinationStyles As Boolean, resolveFormatting As Boolean)
Parameters
sourceDocument
- DocumentModel
The source document.
destinationDocument
- DocumentModel
The destination document.
useDestinationStyles
- System.Boolean
true to use destination document styles if it has the same name as source style (but doesn't have the same formatting); otherwise false to use source document styles.
resolveFormatting
- System.Boolean
true to fully resolve formatting on elements from styles and document default formats; otherwise false.
Exceptions
- System.ArgumentNullException
sourceDocument
or destinationDocument
is null.
Properties
DestinationDocument
Gets the destination document.
public DocumentModel DestinationDocument { get; }
Public ReadOnly Property DestinationDocument As DocumentModel
Property Value
The destination document.
ResolveFormatting
Gets a value indicating whether to fully resolve formatting on elements.
Property Value
- System.Boolean
true to fully resolve formatting; otherwise, false.
Remarks
If this property is set to true, even if a formatting property wasn't explicitly set in the source document, it will be resolved from the style or the document's default formats. This is useful when merging multiple documents with different default formats. Default value is false.
SourceDocument
Gets the source document.
public DocumentModel SourceDocument { get; }
Public ReadOnly Property SourceDocument As DocumentModel
Property Value
The source document.
UseDestinationStyles
Gets a value indicating whether to use destination document styles if they have the same name as source document styles, even though they do not have the same formatting.
public bool UseDestinationStyles { get; }
Public ReadOnly Property UseDestinationStyles As Boolean
Property Value
- System.Boolean
true to use destination document styles; otherwise, false.
Remarks
Destination document ListStyle and ParagraphStyle with ListFormat.IsList equal to true are never used, because that would continue numbering of imported paragraphs in destination document and thus imported paragraphs would influence on the numbering of the rest of the paragraphs in destination document. If imported paragraphs with specific ListStyle should continue numbering in destination document, then set explicit mapping from source ListStyle (of these imported paragraphs) to destination ListStyle onto which numbering should continue.
Methods
GetDestinationStyle(Style)
Gets the destination Style that matches the specified source style.
public Style GetDestinationStyle(Style sourceStyle)
Public Function GetDestinationStyle(sourceStyle As Style) As Style
Parameters
sourceStyle
- Style
The source style.
Returns
The destination Style that matches the specified source style or null if source style was not yet matched to any destination style.
GetOrAddDestinationStyle(Style)
Gets existing or new destination Style that matches the specified source style.
public Style GetOrAddDestinationStyle(Style sourceStyle)
Public Function GetOrAddDestinationStyle(sourceStyle As Style) As Style
Parameters
sourceStyle
- Style
The source style.
Returns
SetDestinationStyle(Style, Style)
Sets the destination Style that matches the specified source style.
public void SetDestinationStyle(Style sourceStyle, Style destinationStyle)
Public Sub SetDestinationStyle(sourceStyle As Style, destinationStyle As Style)
Parameters
sourceStyle
- Style
The source style.
Exceptions
- System.ArgumentNullException
sourceStyle
is null.
- System.ArgumentException
Source and destination style are not of the same type.