This tool is a copy/paste functionality that enables to copy text from one document into another where all formatting except hard formatting (color, bold, italic, etc.) is removed, and then apply relevant formatting (styles) before pasting into the final document. This feature is related to our reuse functionality, but with this tool we are able to remap styles when content is being reused.
We can do the remapping in two different ways. The first method is to define a style for each outline or bullet level, while the second method is rather custom as we must define a source style and a destination style, meaning that it will map the source style to be the destination style when the text is pasted. The configuration of both methods is described below.
Configuration
Make sure to get the latest plugin for this tool by right-clicking the particular SDUP and then select Update ReuseDocument in OfficeExtensions.
CMD for copy
This command saves the currently selected range to the clipboard.
<Cmd case="SkabelonDesign.ReuseDoc:CopyForStyleRemap"/>
CMD for remap and paste
This command gets the range from the clipboard, remaps the styles and will then paste it into the current selection. The command has a <CmdData>
child element where we define how the styles should be remapped. Examples of configuration can be seen later in this article.
<Cmd case="SkabelonDesign.ReuseDoc:RemapStylesAndPaste"></Cmd>
Parameters
SelectContent
This parameter is optional. Define whether the command should select the pasted content using true
or false
.
This parameter is necessary for after burners to selection (see later in this article).
reapplyStyles
This parameter is optional. Define whether the command should respect the reapply logic using true
or false
.
SectionBreaksPreserved
This parameter is optional. Define whether it should preserve all section breaks in copied/pasted range using true
or false
. If this parameter is defined to be true
the section breaks will be preserved. This means that all the properties of the source sections are applied to the target document. This includes margins, distances from headers and footers, and wether the section was linked to previous or not.
RemoveAllBreaks
This parameter is optional. Define whether the command should remove all kinds of breaks in the copied range before pasting using true
or false
.
numberingPreserved
This parameter is optional. Define whether it should preserve the numbering as it is in the source document using true
or false
. This will restart the list time same places as in the source document.
Configuration of style mapping - method #1
This method is especially suitable for pasting content from external documents as we do not specify the particular styles that should be mapped but instead we keep it at outline/bullet level.
Inside the command that will remap and paste, we must define a child element that contains a definition of how the mapping should take place. We must define a level
and then a style
which is the id of the style to add to the particular paragraph. The id of a style is the name of a style without any spaces.
In this method, there are three types of mappings:
Outline
Changes the style of a paragraph with an outline level of level, i.e. Heading 1 is level 1, Heading 2 is level 2, etc. Text that is "Normal" or "Body text" outline will always be mapped to "Normal".
BulletList
Changes the style of a paragraph in a bullet list with an indent level of level. No indent is level 1, one indent is level 2, etc.
NumberedList
Changes the style of a paragraph in a non-bullet list. Here, level is the same as in BulletList.
Example of usage
Below example is from a clients solution:
<Cmd case="SkabelonDesign.ReuseDoc:RemapStylesAndPaste" SelectContent="true">
<CmdData>
<Outline Level="1" Style="Heading1"/>
<Outline Level="2" Style="Heading2"/>
<Outline Level="3" Style="Heading3"/>
<BulletList Level="1" Style="Bullet1"/>
<BulletList Level="2" Style="Bullet2"/>
<BulletList Level="3" Style="Bullet3"/>
<NumberedList Level="1" Style="NumBullet1"/>
<NumberedList Level="2" Style="NumBullet2"/>
<NumberedList Level="3" Style="NumBullet3"/>
</CmdData>
</Cmd>
Configuration of style mapping - method #2
This method is especially suitable for pasting content from internal documents as we have to define a source style and a destination style.
Just like in method #1, we have a child element in the command where we define our remapping. Here, we support both StyleMapping
and TableStyleMapping
, which supports the following parameters:
Source
This parameter is required. Define the id of the style that should be mapped. The id of a style is the style name with no space in between.
Destination
This parameter is required. Define the id of the style that the source style should be mapped to. The id of a style is the style name with no space in between.
AllCaps
This parameter is optional. It will either set the text in destination to have all letters capitals (if defined to true
) or only the first one to be capital (if defined to false
). If this parameter is omitted, it does not do any formatting.
RemoveHardcodeNumbering
This parameter is optional. Define whether it should remove hardcoded numbering using true
or false
, e.g. "1.2.3. My heading" will result in "My heading". Then use the Reapply
parameter to get the right numbering.
Reapply
This parameter is optional. Define whether it should reapply style after it has been pasted using true
or false
. This is useful for headings.
Example of usage
Below is an example:
<Cmd case="SkabelonDesign.ReuseDoc:RemapStylesAndPaste" selectContent="true" reapplyStyles="true" SectionBreaksPreserved="true">
<CmdData>
<StyleMapping Source="Normal" Destination="Normal" Reapply="true"/>
<StyleMapping Source="Vedrørende" Destination="Regarding" Reapply="true"/>
<StyleMapping Source="Heading5" Destination="Heading1" Reapply="true"/>
<StyleMapping Source="Heading6" Destination="Heading2A" Reapply="true"/>
<StyleMapping Source="Heading7" Destination="Heading2" Reapply="true"/>
<StyleMapping Source="Heading8" Destination="Heading3" Reapply="true"/>
<StyleMapping Source="BodyText" Destination="Normal" Reapply="true"/>
<StyleMapping Source="ListParagraph" Destination="RecitalNumbering2" Reapply="true"/>
</CmdData>
</Cmd>
Afterburners (actions after pasting)
In some cases it can be handy to add extra commands to the configuration which involve actions that should take place after content has been remapped and pasted. Examples include:
Comments
0 comments
Article is closed for comments.