diff --git a/src/Filee.Engines/Hwp/Hwpx/Docx/DocxReader.Drawing.cs b/src/Filee.Engines/Hwp/Hwpx/Docx/DocxReader.Drawing.cs index 6ceb124af..9e7b4e4f8 100644 --- a/src/Filee.Engines/Hwp/Hwpx/Docx/DocxReader.Drawing.cs +++ b/src/Filee.Engines/Hwp/Hwpx/Docx/DocxReader.Drawing.cs @@ -573,6 +573,9 @@ private IEnumerable Vml(XElement container, HCharFormat format) continue; var style = VmlStyle((string?)shape.Attribute("style")); + // Word doesn't draw a hidden shape (a stamp's text kept for later, a template's spare WordArt). + if (style.GetValueOrDefault("visibility") == "hidden") + continue; var width = HwpxUnits.ParseLength(style.GetValueOrDefault("width")) ?? 0; var height = HwpxUnits.ParseLength(style.GetValueOrDefault("height")) ?? 0; var anchor = style.GetValueOrDefault("position") == "absolute" ? VmlAnchor(shape, style) : null; diff --git a/src/Filee.Engines/Hwp/Hwpx/Docx/DocxReader.Styles.cs b/src/Filee.Engines/Hwp/Hwpx/Docx/DocxReader.Styles.cs index 39c9201ea..72266c0bc 100644 --- a/src/Filee.Engines/Hwp/Hwpx/Docx/DocxReader.Styles.cs +++ b/src/Filee.Engines/Hwp/Hwpx/Docx/DocxReader.Styles.cs @@ -305,6 +305,23 @@ private sealed class NumberingLevel private (string? Latin, string? EastAsian) _minorFont, _majorFont; private string? _minorComplexFont, _majorComplexFont; + /// + /// Word draws text whose styles and document defaults name no font in Times New Roman (Latin and complex script + /// characters); East Asian text keeps the font of its language. + /// + private void DefaultFonts() + { + var run = _defaultRun; + if (run.Ascii is not null || run.AsciiTheme is not null || run.AsciiOnly is not null || run.AsciiOnlyTheme is not null + || run.HighAnsi is not null || run.HighAnsiTheme is not null) + return; + run.Ascii = run.AsciiOnly = run.HighAnsi = WordDefaultFont; + if (run.ComplexScript is null && run.ComplexScriptTheme is null) + run.ComplexScript = WordDefaultFont; + } + + private const string WordDefaultFont = "Times New Roman"; + private void LoadStyles(Part? part) { var root = part?.Xml.Root; @@ -492,7 +509,10 @@ static void ApplyLevel(NumberingLevel[] levels, XElement lvl) private RunProps RunProperties(XElement? rPr, RunProps paragraphRun) { var run = paragraphRun.Clone(); - if (Val(rPr?.Element(W + "rStyle")) is { } characterStyle && _styles.TryGetValue(characterStyle, out var style)) + // Word and LibreOffice draw the entries of a table of contents in the TOC styles' look, though Word gives each + // entry's link the Hyperlink character style (blue, underlined). + if (Val(rPr?.Element(W + "rStyle")) is { } characterStyle && _styles.TryGetValue(characterStyle, out var style) + && !(InTableOfContents && (style.Id == "Hyperlink" || string.Equals(style.Name, "Hyperlink", StringComparison.OrdinalIgnoreCase)))) { // Character styles only carry run properties; apply their chain on top of the paragraph's. var chain = new List