Esempio n. 1
0
        AddPageToDocument(
            Uri partUri,
            IList <String> linkTargetStream
            )
        {
            _partEditor.PrepareXmlWriter(XpsS0Markup.FixedDocument, XpsS0Markup.FixedDocumentNamespace);
            XmlTextWriter xmlWriter = _partEditor.XmlWriter;
            //
            // Write <PageContent Target="partUri"/>
            //
            String relativePath = XpsManager.MakeRelativePath(Uri, partUri);

            xmlWriter.WriteStartElement(XpsS0Markup.PageContent);
            xmlWriter.WriteAttributeString(XmlTags.Source, relativePath);

            //
            // Write out link targets if necessary
            //
            if (linkTargetStream.Count != 0)
            {
                xmlWriter.WriteRaw("<PageContent.LinkTargets>");
                foreach (String nameElement in linkTargetStream)
                {
                    xmlWriter.WriteRaw(String.Format(
                                           System.Globalization.CultureInfo.InvariantCulture,
                                           "<LinkTarget Name=\"{0}\" />",
                                           nameElement)
                                       );
                }
                xmlWriter.WriteRaw("</PageContent.LinkTargets>");
            }

            xmlWriter.WriteEndElement();
        }
Esempio n. 2
0
        AddRelationship(
            Uri targetUri,
            string relationshipName
            )
        {
            //
            // We can not read from the file to do validation
            // when streaming
            //
            if (!CurrentXpsManager.Streaming)
            {
                foreach (PackageRelationship rel in _metroPart.GetRelationships())
                {
                    if (rel.TargetUri.Equals(targetUri))
                    {
                        //
                        // Relationship already exists
                        //
                        return;
                    }
                }
            }

            //
            // Add the relationship using a relative path to this page.
            //
            string relativePath = XpsManager.MakeRelativePath(this.Uri, targetUri);

            _metroPart.CreateRelationship(new Uri(relativePath, UriKind.Relative),
                                          TargetMode.Internal,
                                          relationshipName);
        }
Esempio n. 3
0
        AddDocumentStructure(
            )
        {
            if (this.DocumentStructure != null)
            {
                // Document structure already available for this FixedDocument
                throw new XpsPackagingException(SR.Get(SRID.ReachPackaging_MoreThanOneDocStructure));
            }

            Uri pageUri = this.CurrentXpsManager.CreateStructureUri();
            //
            // Create the part and writer
            //
            PackagePart metroPart = this.CurrentXpsManager.GeneratePart(
                XpsS0Markup.DocumentStructureContentType,
                pageUri);

            _documentStructure = new XpsStructure(CurrentXpsManager, this, metroPart);

            //
            // Create the relationship between the document and the document-structure
            // Not in INode.Flush because IXpsFixedDocumentReader has no commit.
            //

            string structurePath = XpsManager.MakeRelativePath(this.Uri, _documentStructure.Uri);

            _metroPart.CreateRelationship(new Uri(structurePath, UriKind.Relative),
                                          TargetMode.Internal,
                                          XpsS0Markup.StructureRelationshipName
                                          );

            return(_documentStructure);
        }
 RelativeUri(
     Uri inUri
     )
 {
     if (inUri == null)
     {
         throw new ArgumentNullException("inUri");
     }
     return(new Uri(XpsManager.MakeRelativePath(this.Uri, inUri), UriKind.Relative));
 }
        AddDocumentToSequence(
            Uri partUri
            )
        {
            _partEditor.PrepareXmlWriter(XpsS0Markup.FixedDocumentSequence, XpsS0Markup.DocumentSequenceNamespace);
            XmlTextWriter xmlWriter = _partEditor.XmlWriter;
            //
            // Write <Item Target="partUri"/>
            //
            String relativePath = XpsManager.MakeRelativePath(Uri, partUri);

            xmlWriter.WriteStartElement(XpsS0Markup.DocumentReference);
            xmlWriter.WriteAttributeString(XmlTags.Source, relativePath);
            xmlWriter.WriteEndElement();
        }