Ejemplo n.º 1
0
        public OpenXmlDocumentModel(Stream output, WordOpenXmlWriter.CreateXmlStream createXmlStream, ScalabilityCache scalabilityCache)
        {
            this._createXmlStream  = createXmlStream;
            this._zipPackage       = Package.Open(output, FileMode.Create);
            this._documentPart     = (this._currentPart = new PartInfo());
            this._currentPart.Part = new DocumentPart();
            this._manager          = new PartManager(this.ZipPackage);
            Relationship relationship = this._manager.AddStreamingRootPartToTree("application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", "word/document.xml");

            this.WriteStylesheet();
            this.WriteSettings();
            this._currentPart.PartName          = relationship.RelatedPart;
            this._currentPart.Stream            = this._createXmlStream("document");
            this._currentPart.Writer            = new InterleavingWriter(this._currentPart.Stream, scalabilityCache);
            this._currentHeaderFooterReferences = default(TemporaryHeaderFooterReferences);
            this._tags = new Stack <OoxmlComplexType>();
            this._currentPart.Writer.TextWriter.Write(OoxmlPart.XmlDeclaration);
            CT_Document cT_Document = new CT_Document();

            cT_Document.WriteOpenTag(this._currentPart.Writer.TextWriter, this._currentPart.Part.Tag, this._currentPart.Part.Namespaces);
            this._tags.Push(cT_Document);
            CT_Body ctObject = new CT_Body();

            this.WriteStartTag(ctObject, CT_Document.BodyElementName);
            this._currentPart.TableContext = new TableContext(this._currentPart.Writer, false);
            this._listManager       = new OpenXmlListNumberingManager();
            this._sectionProperties = new OpenXmlSectionPropertiesModel();
        }
Ejemplo n.º 2
0
        public void Save()
        {
            this._sectionProperties.WriteToBody(this._currentPart.Writer.TextWriter, (OpenXmlSectionPropertiesModel.IHeaderFooterReferences)(object) this._currentHeaderFooterReferences);
            this._firstSection = true;
            this._sectionProperties.Continuous = false;
            this.WriteCloseTag(CT_Document.BodyElementName);
            this.WriteCloseTag(this._currentPart.Part.Tag);
            Package     zipPackage = this.ZipPackage;
            PackagePart part       = zipPackage.GetPart(new Uri(PartManager.CleanName(this._currentPart.PartName), UriKind.Relative));
            Stream      stream     = part.GetStream();

            this._currentPart.Writer.Interleave(stream, this.WriteInterleaverToDocument);
            this.WriteNumberingPart();
            this._manager.Write();
        }
Ejemplo n.º 3
0
        private void FinishHeaderOrFooter()
        {
            if (this._currentPart.Writer.Location == this._currentPart.StartingLocation)
            {
                OpenXmlParagraphModel.WriteInvisibleParagraph(this._currentPart.Writer.TextWriter);
            }
            this.WriteCloseTag(this._currentPart.Part.Tag);
            Package     zipPackage = this.ZipPackage;
            PackagePart part       = zipPackage.GetPart(new Uri(PartManager.CleanName(this._currentPart.PartName), UriKind.Relative));
            Stream      stream     = part.GetStream();

            this._currentPart.Writer.Interleave(stream, this.WriteInterleaverToHeaderOrFooter);
            this._currentPart.Stream.Dispose();
            this._currentPart = this._documentPart;
        }