Skip to content

Commit

Permalink
Fixed table handling (assert failing for colgroups and NullPointerExc…
Browse files Browse the repository at this point in the history
…eption in htmlfromxamlcontext
  • Loading branch information
t00 committed Aug 7, 2017
1 parent 6c58aa2 commit 64c4ceb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions MarkupConverter/htmlfromxamlcontext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public HtmlFromXamlContext(HtmlFromXamlDocumentOptions options)
Options = options;
}

public IReadOnlyList<HtmlFromXamlTableInfo> Tables => (tables ?? (tables = new List<HtmlFromXamlTableInfo>())).AsReadOnly();
public IReadOnlyList<HtmlFromXamlTableInfo> Tables => tables.AsReadOnly();

public HtmlFromXamlTableInfo CurrentTable => (tableIndex >= 0 && tableIndex < Tables.Count) ? Tables[tableIndex] : null;

Expand All @@ -48,7 +48,7 @@ internal HtmlFromXamlTableInfo TableMove()
return CurrentTable;
}

private List<HtmlFromXamlTableInfo> tables;
private List<HtmlFromXamlTableInfo> tables = new List<HtmlFromXamlTableInfo>();
private int tableIndex;
}
}
13 changes: 11 additions & 2 deletions MarkupConverter/htmltoxamlconverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,8 @@ private static void AddColumnInformation(XElement htmlTableElement, XElement xam
/// <param name="context">Conversion context</param>
private static void AddTableColumnGroup(XElement xamlTableElement, XElement htmlColgroupElement, IDictionary<string, string> inheritedProperties, HtmlToXamlContext context)
{
context.SourceContext.Add(htmlColgroupElement);

IDictionary<string, string> localProperties;
IDictionary<string, string> currentProperties = GetElementProperties(htmlColgroupElement, inheritedProperties, out localProperties, context);

Expand All @@ -1284,6 +1286,7 @@ private static void AddTableColumnGroup(XElement xamlTableElement, XElement html
AddTableColumn(xamlTableElement, htmlNode, currentProperties, context);
}
}
CheckPop(context.SourceContext, htmlColgroupElement);
}

/// <summary>
Expand All @@ -1300,15 +1303,21 @@ private static void AddTableColumnGroup(XElement xamlTableElement, XElement html
/// <param name="context">Conversion context</param>
private static void AddTableColumn(XElement xamlTableElement, XElement htmlColElement, IDictionary<string, string> inheritedProperties, HtmlToXamlContext context)
{
IDictionary<string, string> localProperties;
IDictionary<string, string> currentProperties = GetElementProperties(htmlColElement, inheritedProperties, out localProperties, context);
context.SourceContext.Add(htmlColElement);

XElement xamlTableColumnElement = new XElement(XName.Get(Xaml_TableColumn, XamlNamespace));
context.DestinationContext.Add(xamlTableColumnElement);

IDictionary<string, string> localProperties;
IDictionary<string, string> currentProperties = GetElementProperties(htmlColElement, inheritedProperties, out localProperties, context);

// TODO: process local properties for TableColumn element

// Col is an empty element, with no subtree
xamlTableElement.Add(xamlTableColumnElement);

CheckPop(context.DestinationContext, xamlTableColumnElement);
CheckPop(context.SourceContext, htmlColElement);
}

/// <summary>
Expand Down

0 comments on commit 64c4ceb

Please sign in to comment.