Exemplo n.º 1
0
        }// end:ReleaseXmlWriterForFixedDocument

        // ------------------- AcquireXmlWriterForFixedPage -------------------
        /// <Summary>
        ///   Acquires an XmlWriter for a FixedPage.</Summary>
        public override XmlWriter AcquireXmlWriterForFixedPage()
        {
            XmlWriter xmlWriter = null;

            if (_currentFixedPageHelper == null)
            {
                String fileName = FileHelper.GenerateFileName(XpsFileType.FixedPage, _path);
                _currentFixedPageHelper = new XmlWriterHelper(_path, fileName);

                //Need to allocate helper streams and writers for FixedPage
                _linkTargetStream            = new List <String>();
                _resourceDictionaryStream    = new StringWriter(CultureInfo.InvariantCulture);
                _resourceDictionaryXmlWriter = new XmlTextWriter(_resourceDictionaryStream);
                _pageStream    = new StringWriter(CultureInfo.InvariantCulture);
                _pageXmlWriter = new XmlTextWriter(_pageStream);

                //Need to figure out name for the relationship file for this FixedPage
                String path = _path + "/Pages/_rels/" + Path.GetFileName(fileName) + ".rels";
                _fixedPageRelationshipStream = new RelationshipStream(path);

                //Add FixedPage type to Content Type file
                _contentTypeFile.AddType(XpsFileType.FixedPage,
                                         FileHelper.GetExtension(XpsFileType.FixedPage));
            }

            xmlWriter = _currentFixedPageHelper.AcquireXmlWriter();

            return(xmlWriter);
        }
Exemplo n.º 2
0
        }// end:ReleaseXmlWriterForFixedDocumentSequence

        // ----------------- AcquireXmlWriterForFixedDocument -----------------
        /// <Summary>
        ///   Acquires an XmlWriter for a FixedDocument.</Summary>
        public override XmlWriter AcquireXmlWriterForFixedDocument()
        {
            XmlWriter xmlWriter = null;

            //Create a FixedDocumentHelper if one isn't already created.
            if (_currentFixedDocumentHelper == null)
            {
                String fileName = FileHelper.GenerateFileName(XpsFileType.FixedDocument, _path);
                _currentFixedDocumentHelper = new XmlWriterHelper(_path, fileName);

                //Add FixedDocument content type to ConentTypes file
                _contentTypeFile.AddType(XpsFileType.FixedDocument,
                                         FileHelper.GetExtension(XpsFileType.FixedDocument));

                //Need to figure out name for the relationship file for this FixedPage
                String path = _path + "/Documents/_rels/" + Path.GetFileName(fileName) + ".rels";
                _fixedDocumentRelationshipStream = new RelationshipStream(path);

                //Need to write DocumentReference markup to FixedDocument
                _currentDocumentSequenceHelper.WriteStartElement("DocumentReference");
                String relativePath = _currentFixedDocumentHelper.FileName;
                _currentDocumentSequenceHelper.WriteAttributeString("Source", relativePath);
                _currentDocumentSequenceHelper.WriteEndElement();
            }

            xmlWriter = _currentFixedDocumentHelper.AcquireXmlWriter();

            return(xmlWriter);
        }
Exemplo n.º 3
0
        // ------------- AcquireXmlWriterForFixedDocumentSequence -------------
        /// <Summary>
        ///   Acquires an XmlWriter for a FixedDocumentSequence.</Summary>
        public override XmlWriter AcquireXmlWriterForFixedDocumentSequence()
        {
            XmlWriter xmlWriter = null;

            // Check to make sure that there is not already a Document Sequence writer created
            if (_currentDocumentSequenceHelper == null)
            {
                String filename = FileHelper.GenerateFileName(XpsFileType.FixedDocumentSequence, _path);
                _currentDocumentSequenceHelper = new XmlWriterHelper(_path, filename);
            }

            xmlWriter = _currentDocumentSequenceHelper.AcquireXmlWriter();

            //Adds file type for FixedDocumentSequence to Content Types
            _contentTypeFile.AddType(XpsFileType.FixedDocumentSequence,
                                     FileHelper.GetExtension(XpsFileType.FixedDocumentSequence));

            //Adds file type for Relationships to Content Types
            _contentTypeFile.AddType(XpsFileType.Relationship,
                                     FileHelper.GetExtension(XpsFileType.Relationship));

            return(xmlWriter);
        }