Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added on transform action #3

Open
wants to merge 1 commit into
base: vNext
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions OpenXmlPowerTools/HtmlToWmlConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class HtmlToWmlConverterSettings
public Emu PageWidthEmus { get { return Emu.TwipsToEmus(PageWidthTwips); } }
public Emu PageMarginLeftEmus { get { return Emu.TwipsToEmus(PageMarginLeftTwips); } }
public Emu PageMarginRightEmus { get { return Emu.TwipsToEmus(PageMarginRightTwips); } }

public Action<XNode, object> OnTransform { get; set; }
}

public class HtmlToWmlConverter
Expand Down
7 changes: 7 additions & 0 deletions OpenXmlPowerTools/HtmlToWmlConverterCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,13 @@ private enum NextExpected

private static object Transform(XNode node, HtmlToWmlConverterSettings settings, WordprocessingDocument wDoc, NextExpected nextExpected, bool preserveWhiteSpace)
{
var result = TransformInner(node, settings, wDoc, nextExpected, preserveWhiteSpace);
settings?.OnTransform?.Invoke(node, result);
return result;
}

private static object TransformInner(XNode node, HtmlToWmlConverterSettings settings, WordprocessingDocument wDoc, NextExpected nextExpected, bool preserveWhiteSpace)
{
XElement element = node as XElement;
if (element != null)
{
Expand Down