|
@@ -9,6 +9,7 @@ using DocumentFormat.OpenXml;
|
|
|
using DocumentFormat.OpenXml.Drawing;
|
|
|
using DocumentFormat.OpenXml.Packaging;
|
|
|
using DocumentFormat.OpenXml.Presentation;
|
|
|
+using HTEXLib.Helpers.ShapeHelpers;
|
|
|
|
|
|
namespace HTEXLib.Models.Inner
|
|
|
{
|
|
@@ -52,40 +53,40 @@ namespace HTEXLib.Models.Inner
|
|
|
}
|
|
|
|
|
|
|
|
|
- public int getLineSpacingInPointsFromFont(int fontHeight)
|
|
|
+ public double getLineSpacingInPointsFromFont(double fontHeight)
|
|
|
{
|
|
|
if (lineSpacing == null)
|
|
|
return fontHeight;
|
|
|
if (lineSpacing.SpacingPoints != null)
|
|
|
return lineSpacing.SpacingPoints.Val;
|
|
|
if (lineSpacing.SpacingPercent != null)
|
|
|
- return lineSpacing.SpacingPercent.Val * fontHeight / Globals.PercentageConstant;
|
|
|
+ return lineSpacing.SpacingPercent.Val * fontHeight*1.0 / Globals.PercentageConstant;
|
|
|
return fontHeight;
|
|
|
}
|
|
|
- public int getSpaceBeforePoints()
|
|
|
+ public double getSpaceBeforePoints()
|
|
|
{
|
|
|
return getSpacingInPoints(spaceBefore, 0);
|
|
|
}
|
|
|
- public int getSpaceBeforePoints(int height)
|
|
|
+ public double getSpaceBeforePoints(double height)
|
|
|
{
|
|
|
return getSpacingInPoints(spaceBefore, height);
|
|
|
}
|
|
|
|
|
|
- public int getSpaceAfterPoints()
|
|
|
+ public double getSpaceAfterPoints()
|
|
|
{
|
|
|
return getSpacingInPoints(spaceAfter, 0);
|
|
|
}
|
|
|
- public int getSpaceAfterPoints(int height)
|
|
|
+ public double getSpaceAfterPoints(double height)
|
|
|
{
|
|
|
return getSpacingInPoints(spaceAfter, height);
|
|
|
}
|
|
|
|
|
|
- private int getSpacingInPoints(DocumentFormat.OpenXml.Drawing.TextSpacingType spacing, int height)
|
|
|
+ private double getSpacingInPoints(DocumentFormat.OpenXml.Drawing.TextSpacingType spacing, double height)
|
|
|
{
|
|
|
if (spacing == null)
|
|
|
return 0;
|
|
|
if (spacing.SpacingPoints != null)
|
|
|
- return spacing.SpacingPoints.Val / Globals.FontPoint;
|
|
|
+ return spacing.SpacingPoints.Val *1.0 / Globals.FontPoint;
|
|
|
if (spacing.SpacingPercent.Val != null && height != 0)
|
|
|
return spacing.SpacingPercent.Val * height / Globals.PercentageConstant;
|
|
|
return 0;
|
|
@@ -185,6 +186,12 @@ namespace HTEXLib.Models.Inner
|
|
|
|
|
|
private void FillParagraphProperties(TextParagraphPropertiesType baseProperties, OpenXmlPart slidePart)
|
|
|
{
|
|
|
+ ///行距该元素指定段落中要使用的垂直行间距。可以用两种不同的方式来指定,百分比间距和字体点间距。如果省略此元素,则两行文本之间的间距应由一行中最大文本的点大小确定。
|
|
|
+ ///<a:lnSpc>
|
|
|
+ // < a:spcPct val = "200%" />
|
|
|
+ // a: spcPct.
|
|
|
+ //a:spcPts.
|
|
|
+ //</ a:lnSpc >
|
|
|
if (baseProperties.LineSpacing != null)
|
|
|
{
|
|
|
lineSpacing = baseProperties.LineSpacing;
|
|
@@ -203,9 +210,30 @@ namespace HTEXLib.Models.Inner
|
|
|
}
|
|
|
if (baseProperties.FontAlignment != null)
|
|
|
{
|
|
|
+ /*
|
|
|
+ * <a:txtBody>
|
|
|
+ …
|
|
|
+ <a:pPr fontAlgn="b" …/>
|
|
|
+ …
|
|
|
+ <a:r>
|
|
|
+ <a:rPr …/>
|
|
|
+ <a:t>H </a:t>
|
|
|
+ </a:r>
|
|
|
+ <a:r>
|
|
|
+ <a:rPr sz="1200" …/>
|
|
|
+ <a:t>2</a:t>
|
|
|
+ </a:r>
|
|
|
+ <a:r>
|
|
|
+ <a:rPr …/>
|
|
|
+ <a:t>O</a:t>
|
|
|
+ </a:r>
|
|
|
+ …
|
|
|
+</p:txBody>
|
|
|
+ H2O 文字居底 ,将2 字号变小 化学公式
|
|
|
+ * */
|
|
|
FontAlign = baseProperties.FontAlignment.Value.ToString();
|
|
|
}
|
|
|
-
|
|
|
+https://docs.microsoft.com/zh-cn/dotnet/api/documentformat.openxml.drawing.textparagraphpropertiestype?view=openxml-2.8.1
|
|
|
if (baseProperties.LeftMargin != null)
|
|
|
{
|
|
|
marginLeft = baseProperties.LeftMargin.Value*1.0 / Globals.px12700;
|
|
@@ -214,7 +242,7 @@ namespace HTEXLib.Models.Inner
|
|
|
{
|
|
|
marginRight = baseProperties.RightMargin.Value *1.0/ Globals.px12700;
|
|
|
}
|
|
|
-
|
|
|
+ //缩进
|
|
|
if (baseProperties.Indent != null)
|
|
|
{
|
|
|
Indent = baseProperties.Indent.Value / Globals.px12700;
|
|
@@ -227,7 +255,14 @@ namespace HTEXLib.Models.Inner
|
|
|
{
|
|
|
bullet = null;
|
|
|
}
|
|
|
-
|
|
|
+ /// 指定标点符号是被强制地放置在一行文本上,还是放置在另一行文本上。
|
|
|
+ /// 也就是说,如果在应该携带的一系列文本的末尾有标点符号 转到另一行,它实际上会被结转吗。
|
|
|
+ /// 真值允许挂起标点符号,迫使标点符号不被结转,假值允许标点符号被结转 带到下一个文本行。
|
|
|
+ /// 如果省略此属性,则隐含值为0或false。
|
|
|
+ /// baseProperties.Height
|
|
|
+ ///baseProperties.LatinLineBreak ,EastAsianLineBreak
|
|
|
+ /// baseProperties.RightToLeft;
|
|
|
+ ///baseProperties.DefaultTabSize;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -246,9 +281,13 @@ namespace HTEXLib.Models.Inner
|
|
|
{
|
|
|
this.ReadPictureBullets(baseProperties, bulletProp, slidePart);
|
|
|
}
|
|
|
+ else if (baseProperties.GetFirstChild<AutoNumberedBullet>() != null) {
|
|
|
+ this.ReadAutoNumberedBullet(baseProperties, bulletProp);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private void ReadPictureBullets(TextParagraphPropertiesType baseProperties, PPTRunProperties bulletProp, OpenXmlPart slidePart)
|
|
|
{ //TODO 获取段落的Bullet 大纲 提纲符号
|
|
|
this.SetBulletProperties(baseProperties, bulletProp);
|
|
@@ -283,9 +322,164 @@ namespace HTEXLib.Models.Inner
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ public void ReadAutoNumberedBullet(TextParagraphPropertiesType baseProperties, PPTRunProperties bulletProp)
|
|
|
+ {
|
|
|
+
|
|
|
+ string text ="";
|
|
|
+ AutoNumberedBullet autoNumberedBullet = baseProperties.GetFirstChild<AutoNumberedBullet>();
|
|
|
+ int num = Paragraph + 1;
|
|
|
+ if (autoNumberedBullet.StartAt != null)
|
|
|
+ {
|
|
|
+ num = autoNumberedBullet.StartAt.Value + (Paragraph+1 - 1);
|
|
|
+ }
|
|
|
+ switch (autoNumberedBullet.Type.Value) {
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.AlphaLowerCharacterParenBoth:
|
|
|
+ //(a), (b), (c), …
|
|
|
+ text = "(" + BulletAutonumberHelper.IntToChar(num, false) + ")";
|
|
|
+ break;
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.AlphaLowerCharacterParenR:
|
|
|
+ //a), b), c), …
|
|
|
+ text = BulletAutonumberHelper.IntToChar(num, false) + ")";
|
|
|
+ break;
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.AlphaLowerCharacterPeriod:
|
|
|
+ //a., b., c., …
|
|
|
+ text = BulletAutonumberHelper.IntToChar(num, false) + ".";
|
|
|
+ break;
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.AlphaUpperCharacterParenBoth:
|
|
|
+ //(A), (B), (C), …
|
|
|
+ text = "(" +BulletAutonumberHelper.IntToChar(num, true) + ")";
|
|
|
+ break;
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.AlphaUpperCharacterParenR:
|
|
|
+ //A), B), C), …
|
|
|
+ text = BulletAutonumberHelper.IntToChar(num, true) + ")";
|
|
|
+ break;
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.AlphaUpperCharacterPeriod:
|
|
|
+ text = "(" + BulletAutonumberHelper.IntToChar(num, true) + ".";
|
|
|
+ //A., B., C., …
|
|
|
+ break;
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.ArabicParenBoth:
|
|
|
+ text = "(" + num + ")";
|
|
|
+ //(1), (2), (3), …
|
|
|
+ break;
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.ArabicParenR:
|
|
|
+ //1), 2), 3), …
|
|
|
+ text = num + ")";
|
|
|
+ break;
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.ArabicPeriod:
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.ArabicDoubleBytePeriod:
|
|
|
+ //1., 2., 3., …
|
|
|
+ text = num + ".";
|
|
|
+ break;
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.ArabicPlain:
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.ArabicDoubleBytePlain:
|
|
|
+ //1, 2, 3, …
|
|
|
+ text= num+"";
|
|
|
+ break;
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.RomanLowerCharacterParenBoth:
|
|
|
+ text = "(" + BulletAutonumberHelper.IntToRoman(num, false) + ")";
|
|
|
+ //(i), (ii), (iii), …
|
|
|
+ break;
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.RomanLowerCharacterParenR:
|
|
|
+ text = BulletAutonumberHelper.IntToRoman(num, false) + ")";
|
|
|
+ //i), ii), iii), …
|
|
|
+ break;
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.RomanLowerCharacterPeriod:
|
|
|
+ text = "(" + BulletAutonumberHelper.IntToRoman(num, false) + ".";
|
|
|
+ //i., ii., iii., …
|
|
|
+ break;
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.RomanUpperCharacterParenBoth:
|
|
|
+ text = "(" + BulletAutonumberHelper.IntToRoman(num, true) + ")";
|
|
|
+ //(I), (II), (III), …
|
|
|
+ break;
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.RomanUpperCharacterParenR:
|
|
|
+ text = BulletAutonumberHelper.IntToRoman(num, true) + ")";
|
|
|
+ //I), II), III), …
|
|
|
+ break;
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.RomanUpperCharacterPeriod:
|
|
|
+ text = BulletAutonumberHelper.IntToRoman(num, true) + ".";
|
|
|
+ //I., II., III., …
|
|
|
+ break;
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.EastAsianJapaneseKoreanPlain:
|
|
|
+ //一,二,三 …,一〇 … 二〇,三〇
|
|
|
+ text = BulletAutonumberHelper.IntToJp(num) ;
|
|
|
+ break;
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.EastAsianJapaneseDoubleBytePeriod:
|
|
|
+ case
|
|
|
+ TextAutoNumberSchemeValues.EastAsianJapaneseKoreanPeriod:
|
|
|
+ text = BulletAutonumberHelper.IntToJp(num)+".";
|
|
|
+ //一.,二.,三. …,一〇. …二〇.,三〇.
|
|
|
+ break;
|
|
|
+ case TextAutoNumberSchemeValues.EastAsianSimplifiedChinesePeriod:
|
|
|
+ //一.,二.,三. …,十.,十一. …,二十.,二十一.
|
|
|
+ text = BulletAutonumberHelper.LongToCh(num) + ".";
|
|
|
+ break;
|
|
|
+ case TextAutoNumberSchemeValues.EastAsianSimplifiedChinesePlain:
|
|
|
+ //一,二,三 …,十,十一 …,二十,二十一
|
|
|
+ text = BulletAutonumberHelper.LongToCh(num);
|
|
|
+ break;
|
|
|
+ case TextAutoNumberSchemeValues.EastAsianTraditionalChinesePeriod:
|
|
|
+ //一.,二.,三. …,十.,十一. …,二〇.,二一.
|
|
|
+ text = BulletAutonumberHelper.LongToCh(num)+".";
|
|
|
+ break;
|
|
|
+ case TextAutoNumberSchemeValues.EastAsianTraditionalChinesePlain:
|
|
|
+ //一,二,三 …,十,十一…,二〇,二一
|
|
|
+ text = BulletAutonumberHelper.LongToCh(num);
|
|
|
+ break;
|
|
|
+ case TextAutoNumberSchemeValues.CircleNumberDoubleBytePlain:
|
|
|
+ case TextAutoNumberSchemeValues.CircleNumberWingdingsWhitePlain:
|
|
|
+ // "①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳";
|
|
|
+ text = BulletAutonumberHelper.IntToCircle(num,false);
|
|
|
+ break;
|
|
|
+ case TextAutoNumberSchemeValues.CircleNumberWingdingsBlackPlain:
|
|
|
+ text = BulletAutonumberHelper.IntToCircle(num, true);
|
|
|
+ // "❶❷❸❹❺❻❼❽❾❿⓫⓬⓭⓮⓯⓰⓱⓲⓳⓴";
|
|
|
+ break;
|
|
|
+ /// 阿拉伯文 数字
|
|
|
+ /// TextAutoNumberSchemeValues.Arabic1Minus
|
|
|
+ /// TextAutoNumberSchemeValues.Arabic2Minus
|
|
|
+ /// 希伯来语 数字
|
|
|
+ /// TextAutoNumberSchemeValues.Hebrew2Minus
|
|
|
+ /// 古印度语 数字
|
|
|
+ /// TextAutoNumberSchemeValues.hindiAlpha1Period hindiAlphaPeriod hindiNumParenR hindiNumPeriod
|
|
|
+ /// 泰语 数字
|
|
|
+ /// TextAutoNumberSchemeValues.thaiAlphaParenBoth thaiAlphaParenR thaiAlphaPeriod thaiNumParenBoth thaiNumParenR thaiNumPeriod
|
|
|
+ }
|
|
|
+ //大纲符号 自动编号类型
|
|
|
+ bulletProp.BulletType = "AutoNum";
|
|
|
+ bulletProp.Text = text;
|
|
|
+ var bufont = baseProperties.GetFirstChild<BulletFont>();
|
|
|
+ if (baseProperties.GetFirstChild<BulletFont>() != null)
|
|
|
+ {
|
|
|
+ bulletProp.bulletSize = bufont.PitchFamily;
|
|
|
+ bulletProp.FontFamily = bufont.Typeface;
|
|
|
+ }
|
|
|
+ this.SetBulletProperties(baseProperties, bulletProp);
|
|
|
+ }
|
|
|
|
|
|
private void ReadCharacterBullets(TextParagraphPropertiesType baseProperties, PPTRunProperties bulletProp)
|
|
|
{
|
|
|
+ bulletProp.BulletType = "Character";
|
|
|
+ // BulletFontText 此元素指定段落的符号的字体应与包含每个符号的文本相同。
|
|
|
//<a:buFont typeface="Arial" panose="020B0604020202020204" pitchFamily="34" charset="0" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" />
|
|
|
bulletProp.Text = "" + baseProperties.GetFirstChild<CharacterBullet>().Char;
|
|
|
var bufont = baseProperties.GetFirstChild<BulletFont>();
|
|
@@ -298,31 +492,34 @@ namespace HTEXLib.Models.Inner
|
|
|
|
|
|
private void SetBulletProperties(TextParagraphPropertiesType baseProperties, PPTRunProperties bulletProp)
|
|
|
{
|
|
|
+ // BulletSizeText 可忽略 此元素指定段落的符号大小应与包含每个符号的文本相同。
|
|
|
this.ReadBulletFont(baseProperties, bulletProp);
|
|
|
this.ReadBulletColor(baseProperties, bulletProp);
|
|
|
this.ReadBulletSizePercentage(baseProperties, bulletProp);
|
|
|
bulletProp.Left = marginLeft;
|
|
|
- bulletProp.BulletType = "Character";
|
|
|
bullet = bulletProp;
|
|
|
|
|
|
}
|
|
|
|
|
|
private void ReadBulletColor(TextParagraphPropertiesType baseProperties, PPTRunProperties bulletProp)
|
|
|
{
|
|
|
+ //BulletColorText 指定Bullet的文本颜色与正文的颜色相同 可忽略不处理
|
|
|
BulletColor buCol = baseProperties.GetFirstChild<BulletColor>();
|
|
|
if (buCol != null)
|
|
|
{
|
|
|
- if (buCol.RgbColorModelHex != null)
|
|
|
- {
|
|
|
- bulletProp.FontColor = "#" + buCol.RgbColorModelHex.Val.Value;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (buCol.GetFirstChild<SchemeColor>() != null)
|
|
|
- {
|
|
|
- bulletProp.ReadThemeSchemeColor(buCol.GetFirstChild<SchemeColor>());
|
|
|
- }
|
|
|
- }
|
|
|
+ bulletProp.FontColor= PPTXHelper. ColorTypeColors(buCol, slide);
|
|
|
+
|
|
|
+ //if (buCol.RgbColorModelHex != null)
|
|
|
+ //{
|
|
|
+ // bulletProp.FontColor = "#" + buCol.RgbColorModelHex.Val.Value;
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // if (buCol.GetFirstChild<SchemeColor>() != null)
|
|
|
+ // {
|
|
|
+ // bulletProp.ReadThemeSchemeColor(buCol.GetFirstChild<SchemeColor>());
|
|
|
+ // }
|
|
|
+ //}
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -368,12 +565,18 @@ namespace HTEXLib.Models.Inner
|
|
|
BulletSizePercentage pct = baseProperties.GetFirstChild<BulletSizePercentage>();
|
|
|
if (bulletProp.bulletSize != 0)
|
|
|
{
|
|
|
- bulletProp.bulletSize = bulletProp.bulletSize * pct.Val / Globals.PercentageConstant;
|
|
|
+ bulletProp.bulletSize = bulletProp.bulletSize * pct.Val *1.0/ Globals.PercentageConstant;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
bulletProp.bulletSize = Globals.DefaultBulletSize;
|
|
|
- bulletProp.bulletSize = bulletProp.bulletSize * pct.Val / Globals.PercentageConstant;
|
|
|
+ bulletProp.bulletSize = bulletProp.bulletSize * pct.Val * 1.0 / Globals.PercentageConstant;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (baseProperties.GetFirstChild<BulletSizePoints>() != null) {
|
|
|
+ BulletSizePoints bulletSizePoints= baseProperties.GetFirstChild<BulletSizePoints>();
|
|
|
+ if (bulletSizePoints.Val != null) {
|
|
|
+ bulletProp.bulletSize = bulletSizePoints.Val * 1.0 / 100;
|
|
|
}
|
|
|
}
|
|
|
}
|