diff --git a/OpenXmlFormats/Drawing/BaseTypes.cs b/OpenXmlFormats/Drawing/BaseTypes.cs index 3ffbbc246e..5ffe8b673b 100644 --- a/OpenXmlFormats/Drawing/BaseTypes.cs +++ b/OpenXmlFormats/Drawing/BaseTypes.cs @@ -2749,8 +2749,7 @@ internal void Write(StreamWriter sw, string nodeName) XmlHelper.WriteAttribute(sw, "lat", this.lat, true); XmlHelper.WriteAttribute(sw, "lon", this.lon, true); XmlHelper.WriteAttribute(sw, "rev", this.rev, true); - sw.Write('>'); - sw.WriteEndElement("a", nodeName); + sw.Write("/>"); } [XmlAttribute] diff --git a/OpenXmlFormats/Drawing/Shape3DStyles.cs b/OpenXmlFormats/Drawing/Shape3DStyles.cs index 9b8c288d43..2d3ee51e5a 100644 --- a/OpenXmlFormats/Drawing/Shape3DStyles.cs +++ b/OpenXmlFormats/Drawing/Shape3DStyles.cs @@ -51,8 +51,7 @@ internal void Write(StreamWriter sw, string nodeName) XmlHelper.WriteAttribute(sw, "h", this.h, true); if(this.prst != ST_BevelPresetType.circle) XmlHelper.WriteAttribute(sw, "prst", this.prst.ToString()); - sw.Write('>'); - sw.WriteEndElement("a", nodeName); + sw.Write("/>");; } public CT_Bevel() { @@ -196,7 +195,8 @@ internal void Write(StreamWriter sw, string nodeName) XmlHelper.WriteAttribute(sw, "z", this.z); XmlHelper.WriteAttribute(sw, "extrusionH", this.extrusionH); XmlHelper.WriteAttribute(sw, "contourW", this.contourW); - XmlHelper.WriteAttribute(sw, "prstMaterial", this.prstMaterial.ToString()); + if(this.prstMaterialField!= ST_PresetMaterialType.warmMatte) + XmlHelper.WriteAttribute(sw, "prstMaterial", this.prstMaterial.ToString()); sw.Write('>'); if (this.bevelT != null) this.bevelT.Write(sw, "bevelT"); diff --git a/OpenXmlFormats/Drawing/ShapeLineProperties.cs b/OpenXmlFormats/Drawing/ShapeLineProperties.cs index 271c5e4ec1..f4f57a05cd 100644 --- a/OpenXmlFormats/Drawing/ShapeLineProperties.cs +++ b/OpenXmlFormats/Drawing/ShapeLineProperties.cs @@ -547,7 +547,6 @@ public static CT_LineProperties Parse(XmlNode node, XmlNamespaceManager namespac ctObj.algnFieldSpecified = node.Attributes["algn"] != null; if (ctObj.algnFieldSpecified) ctObj.algn = (ST_PenAlignment)Enum.Parse(typeof(ST_PenAlignment), node.Attributes["algn"].Value); - ctObj.custDash = new CT_DashStopList(); foreach (XmlNode childNode in node.ChildNodes) { if (childNode.LocalName == "noFill") @@ -604,10 +603,6 @@ internal void Write(StreamWriter sw, string nodeName) if (this.custDash != null) { this.custDash.Write(sw, "custDash"); - //foreach (CT_DashStop x in this.custDash) - //{ - // x.Write(sw, "custDash"); - //} } if (this.round != null) sw.Write(""); diff --git a/OpenXmlFormats/Drawing/StyleSheet.cs b/OpenXmlFormats/Drawing/StyleSheet.cs index 972642b5b3..d2fed45ecd 100644 --- a/OpenXmlFormats/Drawing/StyleSheet.cs +++ b/OpenXmlFormats/Drawing/StyleSheet.cs @@ -481,6 +481,7 @@ public static CT_OfficeStyleSheet Parse(XmlNode node, XmlNamespaceManager namesp public void Write(StreamWriter sw) { + sw.WriteLine(""); sw.Write("'); diff --git a/OpenXmlFormats/Wordprocessing/Numbering.cs b/OpenXmlFormats/Wordprocessing/Numbering.cs index aa6df6029d..cc8b8c7e74 100644 --- a/OpenXmlFormats/Wordprocessing/Numbering.cs +++ b/OpenXmlFormats/Wordprocessing/Numbering.cs @@ -1289,7 +1289,7 @@ public class CT_Lvl public CT_Lvl() { - this.rPrField = new CT_RPr(); + //this.rPrField = new CT_RPr(); this.pPrField = new CT_PPr(); this.lvlJcField = new CT_Jc(); //this.legacyField = new CT_LvlLegacy(); @@ -1352,8 +1352,8 @@ internal void Write(StreamWriter sw, string nodeName) sw.WriteStartW(nodeName); XmlHelper.WriteAttribute(sw, "w:ilvl", this.ilvl); XmlHelper.WriteAttribute(sw, "w:tplc", this.tplc); - if(this.tentative!= ST_OnOff.off|| this.tentativeFieldSpecified) - XmlHelper.WriteAttribute(sw, "w:tentative", this.tentative.ToString()); + if(Util.XmlHelper.ConvertSTOnOffToBoolean(this.tentative) || this.tentativeFieldSpecified) + XmlHelper.WriteAttribute(sw, "w:tentative", Util.XmlHelper.ConvertSTOnOffToBoolean(this.tentative)?1:0); sw.Write('>'); if (this.start != null) this.start.Write(sw, "start"); diff --git a/OpenXmlFormats/Wordprocessing/Settings.cs b/OpenXmlFormats/Wordprocessing/Settings.cs index fac61c79d7..8ea0bc1d9d 100644 --- a/OpenXmlFormats/Wordprocessing/Settings.cs +++ b/OpenXmlFormats/Wordprocessing/Settings.cs @@ -234,8 +234,10 @@ public static CT_Settings Parse(XmlNode node, XmlNamespaceManager namespaceManag internal void Write(StreamWriter sw) { sw.WriteLine(""); - sw.Write(""); + sw.Write(""); + if (this.writeProtection != null) this.writeProtection.Write(sw, "writeProtection"); if (this.view != null) @@ -2792,8 +2794,7 @@ internal void Write(StreamWriter sw, string nodeName) sw.WriteStartW(nodeName); XmlHelper.WriteAttribute(sw, "w:spelling", this.spelling.ToString()); XmlHelper.WriteAttribute(sw, "w:grammar", this.grammar.ToString()); - sw.Write('>'); - sw.WriteEndW(nodeName); + sw.Write("/>"); } [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)] diff --git a/OpenXmlFormats/XmlHelper.cs b/OpenXmlFormats/XmlHelper.cs index 79cbd0ac03..08d749a039 100644 --- a/OpenXmlFormats/XmlHelper.cs +++ b/OpenXmlFormats/XmlHelper.cs @@ -1,5 +1,6 @@ using NPOI.OpenXmlFormats.Vml.Spreadsheet; using NPOI.OpenXmlFormats.Vml.Wordprocessing; +using NPOI.OpenXmlFormats.Wordprocessing; using System; using System.Collections.Generic; using System.IO; @@ -10,6 +11,19 @@ namespace NPOI.OpenXmlFormats.Util { public static class XmlHelper { + public static bool ConvertSTOnOffToBoolean(ST_OnOff value) + { + if (value == ST_OnOff.True || value == ST_OnOff.on/* || value == ST_OnOff.X_1*/) + { + return true; + } + return false; + } + + public static ST_OnOff ConvertBooleanToSTOnOff(bool value) + { + return (value ? ST_OnOff.True : ST_OnOff.False); + } public static ST_TrueFalseBlank ReadTrueFalseBlank(string attrValue) { if (string.IsNullOrEmpty(attrValue)) diff --git a/ooxml/XWPF/Model/WMLHelper.cs b/ooxml/XWPF/Model/WMLHelper.cs deleted file mode 100644 index 07e924929e..0000000000 --- a/ooxml/XWPF/Model/WMLHelper.cs +++ /dev/null @@ -1,38 +0,0 @@ -/* ==================================================================== - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -==================================================================== */ - -namespace NPOI.XWPF.Model -{ - using NPOI.OpenXmlFormats.Wordprocessing; - - public sealed class WMLHelper - { - public static bool ConvertSTOnOffToBoolean(ST_OnOff value) - { - if (value == ST_OnOff.True || value == ST_OnOff.on/* || value == ST_OnOff.X_1*/) - { - return true; - } - return false; - } - - public static ST_OnOff ConvertBooleanToSTOnOff(bool value) - { - return (value ? ST_OnOff.True : ST_OnOff.False); - } - } -}