Пример #1
0
 internal void CreatePagesFromSource()
 {
     var documentReference = new DocumentReference {Source = Source};
     ((IUriContext) documentReference).BaseUri = BaseUri;
     var fixedDocument = documentReference.GetDocument(true);
     PrivateCreatePagesFromFixedDocument(fixedDocument);
 }
 internal ChildDocumentBlock(DocumentSequenceTextContainer aggregatedContainer, DocumentReference docRef)
 {
     Debug.Assert(docRef != null);
     _aggregatedContainer = aggregatedContainer;
     _docRef = docRef;
     _SetStatus(BlockStatus.UnloadedBlock);
 }
Пример #3
0
 public DocumentItem(string documentPath, DocumentReference documentReference)
 {
     TooltipString = documentPath;
     DocumentReference = documentReference;
     FixedDocument = documentReference.GetDocument(true);
     var enumerator = FixedDocument.Pages.GetEnumerator();
     enumerator.MoveNext();
     _firstPage = enumerator.Current.GetPageRoot(true);
 }
Пример #4
0
        /// <summary>
        /// Convert a FixedDocument to an XPS file.
        /// </summary>
        /// <param name="fixedDoc">The FixedDocument to convert.</param>
        /// <param name="outputStream">The output stream.</param>
        public static void ConvertToXps(FixedDocument fixedDoc, Stream outputStream)
        {
            var package = Package.Open(outputStream, FileMode.Create);
            var xpsDoc = new XpsDocument(package, CompressionOption.Normal);
            XpsDocumentWriter xpsWriter = XpsDocument.CreateXpsDocumentWriter(xpsDoc);

            // xps documents are built using fixed document sequences
            var fixedDocSeq = new FixedDocumentSequence();
            var docRef = new DocumentReference();
            docRef.BeginInit();
            docRef.SetDocument(fixedDoc);
            docRef.EndInit();
            ((IAddChild)fixedDocSeq).AddChild(docRef);

            // write out our fixed document to xps
            xpsWriter.Write(fixedDocSeq.DocumentPaginator);

            xpsDoc.Close();
            package.Close();
        }
        //--------------------------------------------------------------------
        //
        // Internal Methods
        //
        //---------------------------------------------------------------------

        #region Internal Method

        internal DynamicDocumentPaginator GetPaginator(DocumentReference docRef)
        {
            // #966803: Source change won't be a support scenario.
            Debug.Assert(docRef != null);
            DynamicDocumentPaginator paginator = null;
            IDocumentPaginatorSource document = docRef.CurrentlyLoadedDoc;

            if (document != null)
            {
                paginator = document.DocumentPaginator as DynamicDocumentPaginator;
                Debug.Assert(paginator != null);
            }
            else
            {
                document = docRef.GetDocument(false /*forceReload*/);
                if (document != null)
                {
                    paginator = document.DocumentPaginator as DynamicDocumentPaginator;
                    Debug.Assert(paginator != null);
                    // hook up event handlers
                    paginator.PaginationCompleted += new EventHandler(_OnChildPaginationCompleted);
                    paginator.PaginationProgress += new PaginationProgressEventHandler(_OnChildPaginationProgress);
                    paginator.PagesChanged += new PagesChangedEventHandler(_OnChildPagesChanged);
                }
            }

            return paginator;
        }
 // Find a ChildBlock in the list that corresponds to the given DocumentReference 
 // Return null if cannot find
 internal ChildDocumentBlock FindChildBlock(DocumentReference docRef) 
 { 
     Debug.Assert(docRef != null);
     ChildDocumentBlock cdb = _doclistHead.NextBlock; 
     while (cdb != null)
     {
         if (cdb.DocRef == docRef)
         { 
             return cdb;
         } 
         cdb = cdb.NextBlock; 
     }
     return null; 
 }
Пример #7
0
 private void AddPages(DocumentReference documentReference, RollUpFixedDocument document)
 {
     var fixedDocument = new FixedDocument();
     documentReference.SetDocument(fixedDocument);
     foreach (var page in document.Pages)
     {
         var pageContent = new PageContent();
         if (page.BaseUri == null)
         {
             ((IAddChild) pageContent).AddChild(page.FixedPage);
         }
         else
         {
             pageContent.Source = page.Source;
             ((IUriContext) pageContent).BaseUri = page.BaseUri;
         }
         pageContent.GetPageRoot(true);
         fixedDocument.Pages.Add(pageContent);
     }
 }
Пример #8
0
 private void FillDocumentReference(DocumentReference documentReference, RollUpFixedDocument document)
 {
     if (document.BaseUri != null)
     {
         documentReference.Source = document.Source;
         (documentReference as IUriContext).BaseUri = document.BaseUri;
     }
     else if (document.FixedDocument != null)
     {
         documentReference.SetDocument(document.FixedDocument);
     }
     else
     {
         AddPages(documentReference, document);
     }
 }
Пример #9
0
 private void ReCreateFixedDocumentSequence()
 {
     _fixedDocumentSequence = new FixedDocumentSequence();
     foreach (var document in _documents)
     {
         var documentReference = new DocumentReference();
         FillDocumentReference(documentReference, document);
         var fixedDocument = documentReference.GetDocument(true);
         _fixedDocumentSequence.References.Add(documentReference);
     }
 }
Пример #10
0
        // --------------- CreatePopulatedFixedDocumentSequence ---------------
        /// <summary>
        ///   Creates a FixedDocumentSequence with content.</summary>
        /// <param name="pq">
        ///   The print queue to print to.</param>
        /// <returns>
        ///   A FixedDocumentSequence with content.</returns>
        public FixedDocumentSequence CreatePopulatedFixedDocumentSequence(
            PrintQueue pq)
        {
            // Create FixedDocumentSequence
            FixedDocumentSequence fixedDocumentSequence =
                new FixedDocumentSequence();

            // Add Documents to a Fixed Document Sequence
            DocumentReference documentRef = new DocumentReference();
            documentRef.SetDocument(CreateFixedDocumentWithPages(pq));
            fixedDocumentSequence.References.Add(documentRef);

            return fixedDocumentSequence;
        }
Пример #11
0
 private static void Add(string path, FixedDocumentSequence fixedDocumentSequence)
 {
     using (var doc = new XpsDocument(path, FileAccess.Read))
     {
         var sourceSequence = doc.GetFixedDocumentSequence();
         if (sourceSequence != null)
         {
             foreach (var dr in sourceSequence.References)
             {
                 var newDocumentReference = new DocumentReference
                                            {
                                                Source = dr.Source
                                            };
                 var baseUri = ((IUriContext)dr).BaseUri;
                 ((IUriContext)newDocumentReference).BaseUri = baseUri;
                 var fd = newDocumentReference.GetDocument(true);
                 newDocumentReference.SetDocument(fd);
                 fixedDocumentSequence.References.Add(newDocumentReference);
             }
         }
     }
 }
 // Token: 0x06002B39 RID: 11065 RVA: 0x000C5629 File Offset: 0x000C3829
 internal ChildDocumentBlock(DocumentSequenceTextContainer aggregatedContainer, DocumentReference docRef)
 {
     this._aggregatedContainer = aggregatedContainer;
     this._docRef = docRef;
     this._SetStatus(ChildDocumentBlock.BlockStatus.UnloadedBlock);
 }
        private FixedDocumentSequence CreateFixedDocumentSequence(IEnumerable<IEnumerable<string>> projects,
            Size areaExtent,
            Size areaOrigin,
            bool fixedStrokeThickness,
            DiagramTable table)
        {
            var fixedDocumentSeq = new FixedDocumentSequence() { Name = "diagrams" };

            foreach (var diagrams in projects)
            {
                var fixedDocument = CreateFixedDocument(diagrams,
                    areaExtent,
                    areaOrigin,
                    fixedStrokeThickness,
                    table);

                var documentRef = new DocumentReference();
                documentRef.BeginInit();
                documentRef.SetDocument(fixedDocument);
                documentRef.EndInit();

                (fixedDocumentSeq as IAddChild).AddChild(documentRef);
            }

            return fixedDocumentSeq;
        }
 internal ChildDocumentBlock(DocumentSequenceTextContainer aggregatedContainer, DocumentReference docRef)
 {
     Debug.Assert(docRef != null);
     _aggregatedContainer = aggregatedContainer;
     _docRef = docRef;
     _SetStatus(BlockStatus.UnloadedBlock);
 }