@copylee/dsh-office 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/helper/OfficeHelper.cs +30 -0
- package/package.json +1 -1
package/helper/OfficeHelper.cs
CHANGED
|
@@ -1018,11 +1018,40 @@ static class Program
|
|
|
1018
1018
|
return made;
|
|
1019
1019
|
}
|
|
1020
1020
|
|
|
1021
|
+
/// Equations on a line of their own built during the current operation (their ranges: these keep pointing at the
|
|
1022
|
+
/// equation while the document grows). They are set off from the text once the operation is done: a paragraph
|
|
1023
|
+
/// inserted after one takes over its look, and must not take over this.
|
|
1024
|
+
static readonly List<object> Displays = new List<object>();
|
|
1025
|
+
|
|
1026
|
+
/// As typeset papers do: some space above and below the equation, and a line that grows with the formula
|
|
1027
|
+
/// (an exact line height would cut a tall one off).
|
|
1028
|
+
static void SetOff()
|
|
1029
|
+
{
|
|
1030
|
+
foreach (dynamic equation in Displays)
|
|
1031
|
+
{
|
|
1032
|
+
try
|
|
1033
|
+
{
|
|
1034
|
+
dynamic paragraph = equation.Paragraphs[1];
|
|
1035
|
+
dynamic range = paragraph.Range;
|
|
1036
|
+
dynamic math = range.OMaths[1].Range;
|
|
1037
|
+
if ((int)range.OMaths.Count != 1) continue;
|
|
1038
|
+
if ((int)range.End - (int)range.Start > (int)math.End - (int)math.Start + 3) continue;
|
|
1039
|
+
dynamic format = paragraph.Format;
|
|
1040
|
+
if ((float)format.SpaceBefore < 6f) format.SpaceBefore = 6f;
|
|
1041
|
+
if ((float)format.SpaceAfter < 6f) format.SpaceAfter = 6f;
|
|
1042
|
+
if ((int)format.LineSpacingRule == 4) format.LineSpacingRule = 3;
|
|
1043
|
+
}
|
|
1044
|
+
catch (Exception) { }
|
|
1045
|
+
}
|
|
1046
|
+
Displays.Clear();
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1021
1049
|
/// Formulas that could not be turned into equations during the current operation (they stay as text).
|
|
1022
1050
|
static int MathFailed;
|
|
1023
1051
|
|
|
1024
1052
|
static string MathNote()
|
|
1025
1053
|
{
|
|
1054
|
+
SetOff();
|
|
1026
1055
|
if (MathFailed == 0) return "";
|
|
1027
1056
|
string note = " — NOTE " + MathFailed + " formula(s) could not be built and were left as text: check them with office_render and rewrite them more simply";
|
|
1028
1057
|
MathFailed = 0;
|
|
@@ -1050,6 +1079,7 @@ static class Program
|
|
|
1050
1079
|
dynamic math = doc.OMaths.Add(spot);
|
|
1051
1080
|
math.OMaths[1].BuildUp();
|
|
1052
1081
|
if (display) { try { math.OMaths[1].Type = 0; math.OMaths[1].Justification = 1; } catch (COMException) { } }
|
|
1082
|
+
if (display) { try { Displays.Add(math.OMaths[1].Range); } catch (Exception) { } }
|
|
1053
1083
|
return true;
|
|
1054
1084
|
}
|
|
1055
1085
|
catch (COMException) { return false; }
|
package/package.json
CHANGED