Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        EnsureDoucmentStructure()
        {
            // if _xpsSignaturs is not null we have already initialized this
            //
            if (null != _documentStructure)
            {
                return;
            }
            PackageRelationship documentStructureRelationship = null;
            PackagePart         documentStructurePart         = null;

            foreach (PackageRelationship rel in _metroPart.GetRelationshipsByType(XpsS0Markup.StructureRelationshipName))
            {
                if (documentStructureRelationship != null)
                {
                    throw new InvalidDataException(SR.Get(SRID.ReachPackaging_MoreThanOneDocStructure));
                }

                documentStructureRelationship = rel;
            }

            if (documentStructureRelationship != null)
            {
                Uri documentStructureUri = PackUriHelper.ResolvePartUri(documentStructureRelationship.SourceUri,
                                                                        documentStructureRelationship.TargetUri);

                if (CurrentXpsManager.MetroPackage.PartExists(documentStructureUri))
                {
                    documentStructurePart = CurrentXpsManager.MetroPackage.GetPart(documentStructureUri);
                    _documentStructure    = new XpsStructure(CurrentXpsManager, this, documentStructurePart);
                }
            }
        }