Skip to content

Commit

Permalink
Merge branch 'release/9.1' into LT-21737
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonleenaylor authored Nov 12, 2024
2 parents 271aabe + 2d05f6f commit 5d2270d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
11 changes: 9 additions & 2 deletions Src/xWorks/ConfiguredLcmGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ private static string GenerateSrcAttributeFromFilePath(ICmFile file, string subF
{
filePath = MakeSafeFilePath(file.AbsoluteInternalPath);
}
return filePath;
return (settings.UseRelativePaths || !settings.UseUri) ? filePath : new Uri(filePath).ToString();
}

private static string GenerateSrcAttributeForMediaFromFilePath(string filename, string subFolder, GeneratorSettings settings)
Expand Down Expand Up @@ -3175,6 +3175,8 @@ public class GeneratorSettings
public LcmCache Cache { get; }
public ReadOnlyPropertyTable PropertyTable { get; }
public bool UseRelativePaths { get; }

public bool UseUri { get; }
public bool CopyFiles { get; }
public string ExportPath { get; }
public bool RightToLeft { get; }
Expand All @@ -3186,8 +3188,12 @@ public GeneratorSettings(LcmCache cache, PropertyTable propertyTable, bool relat
{
}


public GeneratorSettings(LcmCache cache, ReadOnlyPropertyTable propertyTable, bool relativePaths, bool copyFiles, string exportPath, bool rightToLeft = false, bool isWebExport = false, bool isTemplate = false)
: this(cache, propertyTable == null ? null : propertyTable, relativePaths, true, copyFiles, exportPath, rightToLeft, isWebExport, isTemplate)
{
}

public GeneratorSettings(LcmCache cache, ReadOnlyPropertyTable propertyTable, bool relativePaths, bool useUri, bool copyFiles, string exportPath, bool rightToLeft = false, bool isWebExport = false, bool isTemplate = false)
{
if (cache == null || propertyTable == null)
{
Expand All @@ -3196,6 +3202,7 @@ public GeneratorSettings(LcmCache cache, ReadOnlyPropertyTable propertyTable, bo
Cache = cache;
PropertyTable = propertyTable;
UseRelativePaths = relativePaths;
UseUri = useUri;
CopyFiles = copyFiles;
ExportPath = exportPath;
RightToLeft = rightToLeft;
Expand Down
7 changes: 4 additions & 3 deletions Src/xWorks/LcmWordGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public static void SavePublishedDocx(int[] entryHvos, DictionaryPublicationDecor

generator.Init(readOnlyPropertyTable);
IsBidi = ConfiguredLcmGenerator.IsEntryStyleRtl(readOnlyPropertyTable, configuration);
var settings = new ConfiguredLcmGenerator.GeneratorSettings(cache, readOnlyPropertyTable, false, true, System.IO.Path.GetDirectoryName(filePath),
// Call GeneratorSettings with relativesPaths = false but useUri = false because that works better for Word.
var settings = new ConfiguredLcmGenerator.GeneratorSettings(cache, readOnlyPropertyTable, false, false, true, System.IO.Path.GetDirectoryName(filePath),
IsBidi, System.IO.Path.GetFileName(cssPath) == "configured.css")
{ ContentGenerator = generator, StylesGenerator = generator};
settings.StylesGenerator.AddGlobalStyles(configuration, readOnlyPropertyTable);
Expand Down Expand Up @@ -173,7 +174,7 @@ public static void SavePublishedDocx(int[] entryHvos, DictionaryPublicationDecor
Name = CompatSettingNameValues.CompatibilityMode,
// val determines the version of word we are targeting.
// 14 corresponds to Office 2010; 16 would correspond to Office 2019
Val = new StringValue("14"),
Val = new StringValue("16"),
Uri = new StringValue("http://schemas.microsoft.com/office/word")
},
new CompatibilitySetting()
Expand All @@ -183,7 +184,7 @@ public static void SavePublishedDocx(int[] entryHvos, DictionaryPublicationDecor
Val = new StringValue("0"),
Uri = new StringValue("http://schemas.microsoft.com/office/word")
}
// If in the future, if we find that certain style items are different in different version of word,
// If in the future, if we find that certain style items are different in different versions of word,
// it may help to specify more compatibility settings.
// A full list of all possible compatibility settings may be found here:
// https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.compatsettingnamevalues?view=openxml-3.0.1
Expand Down
4 changes: 4 additions & 0 deletions Src/xWorks/WordStylesGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,9 @@ private static StyleRunProperties AddFontInfoWordStyles(BaseStyleInfo projectSty
if (bold)
{
var boldFont = new Bold() { Val = true };
var boldCS = new BoldComplexScript() { Val = true };
charDefaults.Append(boldFont);
charDefaults.Append(boldCS);
}

// Check for italic
Expand All @@ -555,7 +557,9 @@ private static StyleRunProperties AddFontInfoWordStyles(BaseStyleInfo projectSty
if (ital)
{
var italFont = new Italic() { Val = true };
var italicCS = new ItalicComplexScript() { Val = true };
charDefaults.Append(italFont);
charDefaults.Append(italicCS);
}

// Check for font color
Expand Down

0 comments on commit 5d2270d

Please sign in to comment.