Skip to content

Commit

Permalink
adjust Word openxml serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyqus committed Apr 16, 2024
1 parent 990e862 commit d31d5d3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
8 changes: 4 additions & 4 deletions OpenXmlFormats/Drawing/WordprocessingDrawing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,10 @@ public static CT_Inline Parse(XmlNode node, XmlNamespaceManager namespaceManager
if (node == null)
return null;
CT_Inline ctObj = new CT_Inline();
ctObj.distT = XmlHelper.ReadUInt(node.Attributes["wp:distT"]);
ctObj.distB = XmlHelper.ReadUInt(node.Attributes["wp:distB"]);
ctObj.distL = XmlHelper.ReadUInt(node.Attributes["wp:distL"]);
ctObj.distR = XmlHelper.ReadUInt(node.Attributes["wp:distR"]);
ctObj.distT = XmlHelper.ReadUInt(node.Attributes["distT"]);
ctObj.distB = XmlHelper.ReadUInt(node.Attributes["distB"]);
ctObj.distL = XmlHelper.ReadUInt(node.Attributes["distL"]);
ctObj.distR = XmlHelper.ReadUInt(node.Attributes["distR"]);
foreach (XmlNode childNode in node.ChildNodes)
{
if (childNode.LocalName == "extent")
Expand Down
13 changes: 7 additions & 6 deletions OpenXmlFormats/Wordprocessing/Font.cs
Original file line number Diff line number Diff line change
Expand Up @@ -488,16 +488,17 @@ public static CT_Fonts Parse(XmlNode node, XmlNamespaceManager namespaceManager)
internal void Write(StreamWriter sw, string nodeName)
{
sw.Write(string.Format("<w:{0}", nodeName));
if (this.hint != ST_Hint.@default || this.hintFieldSpecified)
XmlHelper.WriteAttribute(sw, "w:hint", this.hint.ToString());
XmlHelper.WriteAttribute(sw, "w:ascii", this.ascii);
XmlHelper.WriteAttribute(sw, "w:hAnsi", this.hAnsi);
if(this.eastAsiaTheme !=null)
XmlHelper.WriteAttribute(sw, "w:eastAsiaTheme", this.eastAsiaTheme.ToString());
XmlHelper.WriteAttribute(sw, "w:eastAsia", this.eastAsia);
XmlHelper.WriteAttribute(sw, "w:hAnsi", this.hAnsi);
XmlHelper.WriteAttribute(sw, "w:cs", this.cs);
if (this.asciiTheme != null)
if(this.hint != ST_Hint.@default || this.hintFieldSpecified)
XmlHelper.WriteAttribute(sw, "w:hint", this.hint.ToString());

if(this.asciiTheme != null)
XmlHelper.WriteAttribute(sw, "w:asciiTheme", this.asciiTheme.ToString());
if (this.eastAsiaTheme !=null)
XmlHelper.WriteAttribute(sw, "w:eastAsiaTheme", this.eastAsiaTheme.ToString());
if (this.hAnsiTheme != ST_Theme.majorEastAsia)
XmlHelper.WriteAttribute(sw, "w:hAnsiTheme", this.hAnsiTheme.ToString());
if (this.cstheme != null)
Expand Down
2 changes: 1 addition & 1 deletion OpenXmlFormats/Wordprocessing/Styles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2304,11 +2304,11 @@ internal void Write(StreamWriter sw, string nodeName)
{
sw.Write(string.Format("<w:{0}", nodeName));
XmlHelper.WriteAttribute(sw, "w:val", this.val.ToString());
XmlHelper.WriteAttribute(sw, "w:color", this.color);
if (this.sz != null)
XmlHelper.WriteAttribute(sw, "w:sz", (ulong)this.sz, true);
if (this.space != null)
XmlHelper.WriteAttribute(sw, "w:space", (ulong)this.space, true);
XmlHelper.WriteAttribute(sw, "w:color", this.color);
if(this.themeColor!= ST_ThemeColor.none)
XmlHelper.WriteAttribute(sw, "w:themeColor", this.themeColor.ToString());
XmlHelper.WriteAttribute(sw, "w:themeTint", this.themeTint);
Expand Down
6 changes: 3 additions & 3 deletions OpenXmlFormats/Wordprocessing/Table.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1912,9 +1912,9 @@ public static CT_Height Parse(XmlNode node, XmlNamespaceManager namespaceManager
internal void Write(StreamWriter sw, string nodeName)
{
sw.Write(string.Format("<w:{0}", nodeName));
XmlHelper.WriteAttribute(sw, "w:val", this.val);
if(this.hRule!= ST_HeightRule.auto)
XmlHelper.WriteAttribute(sw, "w:hRule", this.hRule.ToString());
XmlHelper.WriteAttribute(sw, "w:val", this.val);
sw.Write("/>");
}

Expand Down Expand Up @@ -5703,8 +5703,8 @@ internal void Write(StreamWriter sw, string nodeName)
sw.Write(string.Format("<w:{0}", nodeName));
XmlHelper.WriteAttribute(sw, "w:rsidR", this.rsidR);
XmlHelper.WriteAttribute(sw, "w:rsidRPr", this.rsidRPr);
//XmlHelper.WriteAttribute(sw, "w14:paraId", this.paraIdField);
//XmlHelper.WriteAttribute(sw, "w14:textId", this.textIdField);
XmlHelper.WriteAttribute(sw, "w14:paraId", this.paraIdField);
XmlHelper.WriteAttribute(sw, "w14:textId", this.textIdField);
XmlHelper.WriteAttribute(sw, "w:rsidDel", this.rsidDel);
XmlHelper.WriteAttribute(sw, "w:rsidTr", this.rsidTr);
sw.Write(">");
Expand Down

0 comments on commit d31d5d3

Please sign in to comment.