protected internal override void Commit() { if (ctStyles == null) { throw new InvalidOperationException("Unable to write out styles that were never read in!"); } /*XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.SaveSyntheticDocumentElement=(new QName(CTStyles.type.Name.NamespaceURI, "styles")); Dictionary<String,String> map = new Dictionary<String,String>(); map.Put("http://schemas.Openxmlformats.org/officeDocument/2006/relationships", "r"); map.Put("http://schemas.Openxmlformats.org/wordProcessingml/2006/main", "w"); xmlOptions.SaveSuggestedPrefixes=(map);*/ PackagePart part = GetPackagePart(); using (Stream out1 = part.GetOutputStream()) { StylesDocument doc = new StylesDocument(ctStyles); doc.Save(out1); } }
protected override void Commit() { if (ctStyles == null) { throw new InvalidOperationException("Unable to write out styles that were never read in!"); } /*XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.SaveSyntheticDocumentElement=(new QName(CTStyles.type.Name.NamespaceURI, "styles")); Dictionary<String,String> map = new Dictionary<String,String>(); map.Put("http://schemas.Openxmlformats.org/officeDocument/2006/relationships", "r"); map.Put("http://schemas.Openxmlformats.org/wordProcessingml/2006/main", "w"); xmlOptions.SaveSuggestedPrefixes=(map);*/ PackagePart part = GetPackagePart(); Stream out1 = part.GetOutputStream(); StylesDocument doc = new StylesDocument(ctStyles); XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces(new[] { new XmlQualifiedName("ve", "http://schemas.openxmlformats.org/markup-compatibility/2006"), new XmlQualifiedName("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"), new XmlQualifiedName("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"), new XmlQualifiedName("v", "urn:schemas-microsoft-com:vml"), new XmlQualifiedName("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"), new XmlQualifiedName("w10", "urn:schemas-microsoft-com:office:word"), new XmlQualifiedName("wne", "http://schemas.microsoft.com/office/word/2006/wordml"), new XmlQualifiedName("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main") }); doc.Save(out1, namespaces); out1.Close(); }
/** * Creates an empty styles for the document if one does not already exist * @return styles */ public XWPFStyles CreateStyles() { if (styles == null) { StylesDocument stylesDoc = new StylesDocument(); XWPFRelation relation = XWPFRelation.STYLES; int i = GetRelationIndex(relation); XWPFStyles wrapper = (XWPFStyles)CreateRelationship(relation, XWPFFactory.GetInstance(), i); wrapper.SetStyles(stylesDoc.Styles); styles = wrapper; } return styles; }