Skip to content

Commit

Permalink
fixed issues critical for cpp porter and unsupportable by simplifier
Browse files Browse the repository at this point in the history
  • Loading branch information
stdstring committed Nov 10, 2024
1 parent f93f34a commit c2fe5b9
Show file tree
Hide file tree
Showing 11 changed files with 183 additions and 158 deletions.
4 changes: 2 additions & 2 deletions Examples/ApiExamples/ApiExamples/ExBookmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ public void TableColumnBookmarks()
Console.WriteLine($"Bookmark: {bookmark.Name}{(bookmark.IsColumn ? " (Column)" : "")}");
if (bookmark.IsColumn)
{
if (bookmark.BookmarkStart.GetAncestor(NodeType.Row) is Row row &&
bookmark.FirstColumn < row.Cells.Count)
Row row = bookmark.BookmarkStart.GetAncestor(NodeType.Row) as Row;
if (row != null && bookmark.FirstColumn < row.Cells.Count)
{
// Print the contents of the first and last columns enclosed by the bookmark.
Console.WriteLine(row.Cells[bookmark.FirstColumn].GetText().TrimEnd(ControlChar.CellChar));
Expand Down
2 changes: 1 addition & 1 deletion Examples/ApiExamples/ApiExamples/ExCharts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,7 @@ public void DataArraysWrongSize(double[] seriesValue, Type exception = null)
seriesColl.Clear();

string[] categories = { "Word", null, "Excel", "GoogleDocs", "Note", null };
if (exception is null)
if (exception == null)
seriesColl.Add("AW Series", categories, seriesValue);
else
Assert.Throws(exception, () => seriesColl.Add("AW Series", categories, seriesValue));
Expand Down
7 changes: 4 additions & 3 deletions Examples/ApiExamples/ApiExamples/ExDocumentBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2670,6 +2670,7 @@ public FieldResultFormatter(string numberFormat, string dateFormat, string gener
mNumberFormat = numberFormat;
mDateFormat = dateFormat;
mGeneralFormat = generalFormat;
FormatInvocations = new List<FormatInvocation>();
}

public string FormatNumeric(double value, string format)
Expand Down Expand Up @@ -2730,9 +2731,9 @@ public void PrintFormatInvocations()

private readonly string mNumberFormat;
private readonly string mDateFormat;
private readonly string mGeneralFormat;
private List<FormatInvocation> FormatInvocations { get; } = new List<FormatInvocation>();
private readonly string mGeneralFormat;
private List<FormatInvocation> FormatInvocations { get; }

private class FormatInvocation
{
public FormatInvocationType FormatInvocationType { get; }
Expand Down
95 changes: 61 additions & 34 deletions Examples/ApiExamples/ApiExamples/ExFont.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1289,42 +1289,69 @@ private void TestRemoveHiddenContent(Document doc)

foreach (Node node in doc.GetChildNodes(NodeType.Any, true))
{
switch (node)
FieldStart fieldStart = node as FieldStart;
if (fieldStart != null)
{
case FieldStart fieldStart:
Assert.False(fieldStart.Font.Hidden);
break;
case FieldEnd fieldEnd:
Assert.False(fieldEnd.Font.Hidden);
break;
case FieldSeparator fieldSeparator:
Assert.False(fieldSeparator.Font.Hidden);
break;
case Run run:
Assert.False(run.Font.Hidden);
break;
case Paragraph paragraph:
Assert.False(paragraph.ParagraphBreakFont.Hidden);
break;
case FormField formField:
Assert.False(formField.Font.Hidden);
break;
case GroupShape groupShape:
Assert.False(groupShape.Font.Hidden);
break;
case Shape shape:
Assert.False(shape.Font.Hidden);
break;
case Comment comment:
Assert.False(comment.Font.Hidden);
break;
case Footnote footnote:
Assert.False(footnote.Font.Hidden);
break;
case SpecialChar specialChar:
Assert.False(specialChar.Font.Hidden);
break;
Assert.False(fieldStart.Font.Hidden);
continue;
}
FieldEnd fieldEnd = node as FieldEnd;
if (fieldEnd != null)
{
Assert.False(fieldEnd.Font.Hidden);
continue;
}
FieldSeparator fieldSeparator = node as FieldSeparator;
if (fieldSeparator != null)
{
Assert.False(fieldSeparator.Font.Hidden);
continue;
}
Run run = node as Run;
if (run != null)
{
Assert.False(run.Font.Hidden);
continue;
}
Paragraph paragraph = node as Paragraph;
if (paragraph != null)
{
Assert.False(paragraph.ParagraphBreakFont.Hidden);
continue;
}
FormField formField = node as FormField;
if (formField != null)
{
Assert.False(formField.Font.Hidden);
continue;
}
GroupShape groupShape = node as GroupShape;
if (groupShape != null)
{
Assert.False(groupShape.Font.Hidden);
continue;
}
Shape shape = node as Shape;
if (shape != null)
{
Assert.False(shape.Font.Hidden);
continue;
}
Comment comment = node as Comment;
if (comment != null)
{
Assert.False(comment.Font.Hidden);
continue;
}
Footnote footnote = node as Footnote;
if (footnote != null)
{
Assert.False(footnote.Font.Hidden);
continue;
}
SpecialChar specialChar = node as SpecialChar;
if (specialChar != null)
Assert.False(specialChar.Font.Hidden);
}
}

Expand Down
5 changes: 4 additions & 1 deletion Examples/ApiExamples/ApiExamples/ExHeaderFooter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,10 @@ public ReplaceAction Replacing(ReplacingArgs args)
return ReplaceAction.Skip;
}

internal string Text => mTextBuilder.ToString();
internal string Text
{
get { return mTextBuilder.ToString(); }
}

private readonly StringBuilder mTextBuilder = new StringBuilder();
}
Expand Down
2 changes: 2 additions & 0 deletions Examples/ApiExamples/ApiExamples/ExHtmlSaveOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1744,11 +1744,13 @@ public void ScaleImageToShapeSize(bool scaleImageToShapeSize)
var testedImageLength = new FileInfo(ArtifactsDir + "HtmlSaveOptions.ScaleImageToShapeSize.001.png").Length;

if (scaleImageToShapeSize)
{
#if NET461_OR_GREATER || JAVA
Assert.IsTrue(testedImageLength < 3000);
#elif NET5_0_OR_GREATER
Assert.IsTrue(testedImageLength < 6000);
#endif
}
else
Assert.IsTrue(testedImageLength < 16000);

Expand Down
10 changes: 8 additions & 2 deletions Examples/ApiExamples/ApiExamples/ExPdfSaveOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2121,7 +2121,10 @@ public void Warning(WarningInfo info)
mWarnings.Add(info);
}

public WarningInfo this[int i] => mWarnings[i];
public WarningInfo this[int i]
{
get { return mWarnings[i]; }
}

/// <summary>
/// Clears warning collection.
Expand All @@ -2131,7 +2134,10 @@ public void Clear()
mWarnings.Clear();
}

public int Count => mWarnings.Count;
public int Count
{
get { return mWarnings.Count; }
}

/// <summary>
/// Returns true if a warning with the specified properties has been generated.
Expand Down
14 changes: 12 additions & 2 deletions Examples/ApiExamples/ApiExamples/ExRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -616,13 +616,18 @@ public void UseLegacyOrder(bool useLegacyOrder)
/// </summary>
private class TextReplacementTracker : IReplacingCallback
{
public TextReplacementTracker()
{
Matches = new List<string>();
}

ReplaceAction IReplacingCallback.Replacing(ReplacingArgs e)
{
Matches.Add(e.Match.Value);
return ReplaceAction.Replace;
}

public List<string> Matches { get; } = new List<string>();
public List<string> Matches { get; }
}
//ExEnd

Expand Down Expand Up @@ -794,13 +799,18 @@ public void Direction(FindReplaceDirection findReplaceDirection)
/// </summary>
private class TextReplacementRecorder : IReplacingCallback
{
public TextReplacementRecorder()
{
Matches = new List<string>();
}

ReplaceAction IReplacingCallback.Replacing(ReplacingArgs e)
{
Matches.Add(e.Match.Value);
return ReplaceAction.Replace;
}

public List<string> Matches { get; } = new List<string>();
public List<string> Matches { get; }
}
//ExEnd
}
Expand Down
5 changes: 4 additions & 1 deletion Examples/ApiExamples/ApiExamples/ExTableColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ public class Column
{
private Column(Table table, int columnIndex)
{
mTable = table ?? throw new ArgumentException("table");
if (table == null)
throw new ArgumentException("table");
mTable = table;

mColumnIndex = columnIndex;
}

Expand Down
Loading

0 comments on commit c2fe5b9

Please sign in to comment.