SimulateEndFixedDocument(
            XmlWriter xmlWriter
            )
        {
            _xpsOMSerializationManager.ReleaseXpsOMWriterForFixedDocument();

            //
            // Clear off the table from the packaging policy
            //
            _xpsOMSerializationManager.ResourcePolicy.ImageCrcTable = null;

            _xpsOMSerializationManager.ResourcePolicy.ImageUriHashTable = null;
            //
            // Clear off the table from the packaging policy
            //
            _xpsOMSerializationManager.ResourcePolicy.ColorContextTable = null;

            _xpsOMSerializationManager.RegisterDocumentEnd();

            // Inform any registered listener that the document has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            (_serializationManager as IXpsSerializationManager)?.OnXPSSerializationProgressChanged(progressEvent);
        }
        AsyncOperation(
            NGCSerializerContext context
            )
        {
            if (context == null)
            {
            }

            switch (context.Action)
            {
            case SerializerAction.endPersistObjectData:
            {
                EndPersistObjectData();

                XpsSerializationProgressChangedEventArgs e =
                    new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentSequenceWritingProgress,
                                                                 0,
                                                                 0,
                                                                 null);
                NgcSerializationManager.OnNGCSerializationProgressChanged(e);

                break;
            }

            default:
            {
                base.AsyncOperation(context);
                break;
            }
            }
        }
        EndPersistObjectData(
            )
        {
            XmlWriter.WriteEndElement();
            XmlWriter = null;
            //
            // Clear off the table from the packaging policy
            //
            ((XpsSerializationManager)SerializationManager).ResourcePolicy.ImageCrcTable = null;

            ((XpsSerializationManager)SerializationManager).ResourcePolicy.ImageUriHashTable = null;

            //
            // Signal to any registered callers that the Document has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            if (SerializationManager is XpsSerializationManager)
            {
                (SerializationManager as XpsSerializationManager).RegisterDocumentEnd();
            }
            ((IXpsSerializationManager)SerializationManager).OnXPSSerializationProgressChanged(progressEvent);
        }
        EndPersistObjectData(
            )
        {
            //
            // Clear off the table from the packaging policy
            //
            _xpsOMSerializationManager.ResourcePolicy.ImageCrcTable = null;

            _xpsOMSerializationManager.ResourcePolicy.ImageUriHashTable = null;

            _xpsOMSerializationManager.ReleaseXpsOMWriterForFixedDocument();

            //
            // Signal to any registered callers that the Document has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            _xpsOMSerializationManager.OnXPSSerializationProgressChanged(progressEvent);

            _xpsOMSerializationManager.RegisterDocumentEnd();
        }
Exemplo n.º 5
0
        EndPage()
        {
            if (_isStartPage)
            {
                try
                {
                    _device.FlushPage();
                }
                catch (PrintingCanceledException)
                {
                    _device.EndDocument();
                    throw;
                }
            }

            _isStartPage         = false;
            _isPrintTicketMerged = false;

            //
            // Inform any potential listeners that the page has been printed
            //
            XpsSerializationProgressChangedEventArgs e =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedPageWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            OnNGCSerializationProgressChagned(e);
        }
Exemplo n.º 6
0
        SimulateEndFixedDocumentSequence(
            XmlWriter xmlWriter
            )
        {
            //
            // Write the End Element
            //
            xmlWriter.WriteEndElement();
            //
            // Release the Package writer
            //
            _serializationManager.ReleaseXmlWriter(typeof(FixedDocumentSequence));
            //
            // Inform any registered listener that the document sequence has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentSequenceWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            if (_serializationManager is XpsSerializationManager)
            {
                (_serializationManager as XpsSerializationManager).RegisterDocumentSequenceEnd();
            }
            (_serializationManager as IXpsSerializationManager)?.OnXPSSerializationProgressChanged(progressEvent);
        }
Exemplo n.º 7
0
        EndPersistObjectData(bool needEndVisual, ReachTreeWalker treeWalker)
        {
            if (needEndVisual)
            {
                XmlWriter pageWriter = SerializationManager.
                                       PackagingPolicy.AcquireXmlWriterForPage();

                XmlWriter resWriter = SerializationManager.
                                      PackagingPolicy.AcquireXmlWriterForResourceDictionary();

                Size fixedPageSize            = _xpsOMSerializationManager.FixedPageSize;
                VisualTreeFlattener flattener = _xpsOMSerializationManager.
                                                VisualSerializationService.AcquireVisualTreeFlattener(resWriter,
                                                                                                      pageWriter,
                                                                                                      fixedPageSize);

                flattener.EndVisual();
            }

            SerializationManager.PackagingPolicy.PreCommitCurrentPage();

            //
            // Copy hyperlinks into stream
            //
            treeWalker.CommitHyperlinks();

            XmlWriter.WriteEndElement();
            //
            //Release used resources
            //
            XmlWriter = null;
            //
            // Free the image table in use for this page
            //
            _xpsOMSerializationManager.ResourcePolicy.CurrentPageImageTable = null;
            //
            // Free the colorContext table in use for this page
            //
            _xpsOMSerializationManager.ResourcePolicy.CurrentPageColorContextTable = null;
            //
            // Free the resourceDictionary table in use for this page
            //
            _xpsOMSerializationManager.ResourcePolicy.CurrentPageResourceDictionaryTable = null;

            _xpsOMSerializationManager.VisualSerializationService.ReleaseVisualTreeFlattener();

            _xpsOMSerializationManager.RegisterPageEnd();

            //
            // Signal to any registered callers that the Page has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedPageWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            _xpsOMSerializationManager.OnXPSSerializationProgressChanged(progressEvent);
        }
Exemplo n.º 8
0
        OnNGCSerializationProgressChagned(
            object operationState
            )
        {
            XpsSerializationProgressChangedEventArgs e = operationState as XpsSerializationProgressChangedEventArgs;

            if (XpsSerializationProgressChanged != null)
            {
                XpsSerializationProgressChanged(this, e);
            }
        }
Exemplo n.º 9
0
        IXpsSerializationManager.OnXPSSerializationProgressChanged(
            object operationState
            )
        {
            XpsSerializationProgressChangedEventArgs e = operationState as XpsSerializationProgressChangedEventArgs;

            if (XpsSerializationProgressChanged != null)
            {
                XpsSerializationProgressChanged(this, e);
            }
        }
        EndPage()
        {
            _device.FlushPage();
            _isStartPage         = false;
            _isPrintTicketMerged = false;

            //
            // Inform the listener that the page has been printed
            //
            XpsSerializationProgressChangedEventArgs e =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedPageWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            OnNGCSerializationProgressChanged(e);
        }
Exemplo n.º 11
0
        SerializeObject(
            Object serializedObject
            )
        {
            if (serializedObject == null)
            {
                throw new ArgumentNullException("serializedObject");
            }
            FixedDocumentSequence fds = serializedObject as FixedDocumentSequence;

            if (fds == null)
            {
                throw new ArgumentException(SR.Get(SRID.ReachSerialization_ExpectedFixedDocumentSequence));
            }

            NgcSerializationManager ngcManager = SerializationManager as NgcSerializationManager;

            if (!ngcManager.IsPrintTicketEventHandlerEnabled)
            {
                //ngcManager.FdsPrintTicket = fds.PrintTicket as PrintTicket;
            }
            else
            {
                XpsSerializationPrintTicketRequiredEventArgs printTicketEvent =
                    new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedDocumentSequencePrintTicket,
                                                                     0);
                ngcManager.OnNGCSerializationPrintTicketRequired(printTicketEvent);
            }

            ngcManager.StartDocument(fds, false);

            ReachSerializer serializer = ngcManager.GetSerializer(fds.References);

            serializer.SerializeObject(fds.References);

            ngcManager.EndDocument();

            XpsSerializationProgressChangedEventArgs e =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentSequenceWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            ngcManager.OnNGCSerializationProgressChagned(e);
        }
Exemplo n.º 12
0
        EndPersistObjectData(
            )
        {
            _xpsOMSerializationManager.ReleaseXpsOMWriterForFixedDocumentSequence();

            //
            // Signal to any registered callers that the Sequence has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentSequenceWritingProgress,
                                                             0,
                                                             0,
                                                             null);


            _xpsOMSerializationManager.RegisterDocumentSequenceEnd();
            _xpsOMSerializationManager.OnXPSSerializationProgressChanged(progressEvent);
        }
Exemplo n.º 13
0
        EndDocument()
        {
            if (_startDocCnt == 1)
            {
                _device.EndDocument();

                //
                // Inform any potential listeners that the doucment has been printed
                //
                XpsSerializationProgressChangedEventArgs e =
                    new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentWritingProgress,
                                                                 0,
                                                                 0,
                                                                 null);
                OnNGCSerializationProgressChagned(e);
            }
            _startDocCnt--;
        }
        EndDocument(bool abort)
        {
            if (_startDocCnt == 1 || abort)
            {
                _device.EndDocument(abort);

                //
                // Inform the listener that the doucment has been printed
                //
                XpsSerializationProgressChangedEventArgs e =
                    new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentWritingProgress,
                                                                 0,
                                                                 0,
                                                                 null);
                OnNGCSerializationProgressChanged(e);
            }
            _startDocCnt--;
        }
        EndSerializeDocumentPage(
            ReachSerializerContext context
            )
        {
            ReachFixedPageSerializerContext thisContext = context as ReachFixedPageSerializerContext;

            if(thisContext != null)
            {
                ((XpsSerializationManager)SerializationManager).PackagingPolicy.PreCommitCurrentPage();

                //copy hyperlinks into stream
                thisContext.TreeWalker.CommitHyperlinks();

                XmlWriter.WriteEndElement();
                XmlWriter = null;
                //
                // Free the image table in use for this page
                //
                ((XpsSerializationManagerAsync)SerializationManager).ResourcePolicy.CurrentPageImageTable = null;
                //
                // Free the colorContext table in use for this page
                //
                ((XpsSerializationManager)SerializationManager).ResourcePolicy.CurrentPageColorContextTable = null;

                ((IXpsSerializationManager)SerializationManager).VisualSerializationService.ReleaseVisualTreeFlattener();

                if( SerializationManager is IXpsSerializationManager)
                {
                    (SerializationManager as IXpsSerializationManager).RegisterPageEnd();
                }
                //
                // Signal to any registered callers that the Page has been serialized
                //
                XpsSerializationProgressChangedEventArgs progressEvent = 
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedPageWritingProgress,
                                                             0,
                                                             0,
                                                             null);

                ((IXpsSerializationManager)SerializationManager).OnXPSSerializationProgressChanged(progressEvent);
            }

        }
Exemplo n.º 16
0
        EndPersistObjectData(
            )
        {
            XmlWriter.WriteEndElement();
            XmlWriter = null;

            //
            // Signal to any registered callers that the Sequence has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentSequenceWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            if (SerializationManager is XpsSerializationManager)
            {
                (SerializationManager as XpsSerializationManager).RegisterDocumentSequenceEnd();
            }
            ((IXpsSerializationManager)SerializationManager).OnXPSSerializationProgressChanged(progressEvent);
        }
        SimulateEndFixedDocumentSequence(
            XmlWriter xmlWriter
            )
        {
            //
            // Release the Package writer
            //
            _xpsOMSerializationManager.ReleaseXpsOMWriterForFixedDocumentSequence();

            _xpsOMSerializationManager.RegisterDocumentSequenceEnd();

            //
            // Inform any registered listener that the document sequence has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentSequenceWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            (_serializationManager as IXpsSerializationManager)?.OnXPSSerializationProgressChanged(progressEvent);
        }
Exemplo n.º 18
0
        SimulateEndFixedDocument(
            XmlWriter xmlWriter
            )
        {
            //
            // Write the End Element
            //
            xmlWriter.WriteEndElement();
            //
            // Release the Package writer
            //
            _serializationManager.ReleaseXmlWriter(typeof(FixedDocument));
            //
            // Clear off the table from the packaging policy
            //
            _serializationManager.ResourcePolicy.ImageCrcTable = null;

            _serializationManager.ResourcePolicy.ImageUriHashTable = null;
            //
            // Clear off the table from the packaging policy
            //
            _serializationManager.ResourcePolicy.ColorContextTable = null;
            //
            // Inform any registered listener that the document has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            if (_serializationManager is XpsSerializationManager)
            {
                (_serializationManager as XpsSerializationManager).RegisterDocumentEnd();
            }
            (_serializationManager as IXpsSerializationManager)?.OnXPSSerializationProgressChanged(progressEvent);
        }
Exemplo n.º 19
0
        EndSerializeDocumentPage(
            ReachTreeWalker treeWalker
            )
        {
            _xpsOMSerializationManager.PackagingPolicy.PreCommitCurrentPage();

            //copy hyperlinks into stream
            treeWalker.CommitHyperlinks();

            XmlWriter.WriteEndElement();
            XmlWriter = null;
            //
            // Free the image table in use for this page
            //
            _xpsOMSerializationManager.ResourcePolicy.CurrentPageImageTable = null;
            //
            // Free the colorContext table in use for this page
            //
            _xpsOMSerializationManager.ResourcePolicy.CurrentPageColorContextTable = null;

            IXpsSerializationManager xpsSerializationManager = ((IXpsSerializationManager)SerializationManager);

            xpsSerializationManager.VisualSerializationService.ReleaseVisualTreeFlattener();

            xpsSerializationManager.RegisterPageEnd();

            //
            // Signal to any registered callers that the Page has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedPageWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            xpsSerializationManager.OnXPSSerializationProgressChanged(progressEvent);
        }
Exemplo n.º 20
0
        SimulateEndFixedPage(
            XmlWriter xmlWriter
            )
        {
            _serializationManager.PackagingPolicy.PreCommitCurrentPage();

            if (_treeWalker != null)
            {
                _treeWalker.CommitHyperlinks();
                _treeWalker = null;
            }

            xmlWriter.WriteEndElement();

            _serializationManager.ReleaseXmlWriter(typeof(FixedPage));
            //
            // Clear off the table from the packaging policy
            //
            _serializationManager.ResourcePolicy.CurrentPageImageTable = null;
            //
            // Clear off the table from the packaging policy
            //
            _serializationManager.ResourcePolicy.CurrentPageColorContextTable = null;
            (_serializationManager as IXpsSerializationManager)?.VisualSerializationService.ReleaseVisualTreeFlattener();
            //
            // Inform any registered listener that the page has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedPageWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            (_serializationManager as IXpsSerializationManager)?.OnXPSSerializationProgressChanged(progressEvent);
            (_serializationManager as IXpsSerializationManager)?.RegisterPageEnd();
        }
Exemplo n.º 21
0
        PersistObjectData(
            SerializableObjectContext serializableObjectContext
            )
        {
            if (SerializationManager is IXpsSerializationManager)
            {
                (SerializationManager as IXpsSerializationManager).RegisterPageStart();
            }

            //
            // A DocumentPage is persisted as a FixedPage
            //
            DocumentPage dp = (DocumentPage)serializableObjectContext.TargetObject;

            ReachTreeWalker treeWalker = new ReachTreeWalker(this);

            treeWalker.SerializeLinksInDocumentPage(dp);

            XmlWriter.WriteStartElement(XpsS0Markup.FixedPage);

            String xmlnsForType = SerializationManager.GetXmlNSForType(typeof(FixedPage));

            if (xmlnsForType != null)
            {
                XmlWriter.WriteAttributeString(XpsS0Markup.Xmlns, xmlnsForType);
                XmlWriter.WriteAttributeString(XpsS0Markup.XmlnsX, XpsS0Markup.XmlnsXSchema);

                if (SerializationManager.Language != null)
                {
                    XmlWriter.WriteAttributeString(XpsS0Markup.XmlLang, SerializationManager.Language.ToString());
                }
                else
                {
                    XmlWriter.WriteAttributeString(XpsS0Markup.XmlLang, XpsS0Markup.XmlLangValue);
                }
            }

            XpsSerializationPrintTicketRequiredEventArgs e =
                new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedPagePrintTicket,
                                                                 0);

            ((IXpsSerializationManager)SerializationManager).OnXPSSerializationPrintTicketRequired(e);

            PrintTicket printTicket = null;

            if (e.Modified)
            {
                printTicket = e.PrintTicket;
            }

            Size size = Toolbox.ValidateDocumentSize(dp.Size, printTicket);

            ((IXpsSerializationManager)SerializationManager).FixedPageSize = size;

            //
            //write length and width elements
            //
            WriteAttribute(XmlWriter, XpsS0Markup.PageWidth, size.Width);
            WriteAttribute(XmlWriter, XpsS0Markup.PageHeight, size.Height);

            //
            // Serialize the data for the PrintTicket
            //
            if (printTicket != null)
            {
                PrintTicketSerializer serializer = new PrintTicketSerializer(SerializationManager);
                serializer.SerializeObject(printTicket);
            }

            SerializeChild(dp.Visual, serializableObjectContext);

            ((XpsSerializationManager)SerializationManager).PackagingPolicy.PreCommitCurrentPage();

            //copy hyperlinks into stream
            treeWalker.CommitHyperlinks();

            XmlWriter.WriteEndElement();
            XmlWriter = null;
            //
            // Free the image table in use for this page
            //
            ((XpsSerializationManager)SerializationManager).ResourcePolicy.CurrentPageImageTable = null;
            //
            // Free the colorContext table in use for this page
            //
            ((XpsSerializationManager)SerializationManager).ResourcePolicy.CurrentPageColorContextTable = null;

            ((IXpsSerializationManager)SerializationManager).VisualSerializationService.ReleaseVisualTreeFlattener();

            if (SerializationManager is IXpsSerializationManager)
            {
                (SerializationManager as IXpsSerializationManager).RegisterPageEnd();
            }
            //
            // Signal to any registered callers that the Page has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedPageWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            ((IXpsSerializationManager)SerializationManager).OnXPSSerializationProgressChanged(progressEvent);
        }
Exemplo n.º 22
0
        PersistObjectData(
            SerializableObjectContext serializableObjectContext
            )
        {
            if (serializableObjectContext == null)
            {
                throw new ArgumentNullException("serializableObjectContext");
            }

            String xmlnsForType = SerializationManager.GetXmlNSForType(typeof(FixedDocument));

            if (SerializationManager is XpsSerializationManager)
            {
                (SerializationManager as XpsSerializationManager).RegisterDocumentStart();
            }

            if (xmlnsForType == null)
            {
                XmlWriter.WriteStartElement(serializableObjectContext.Name);
            }
            else
            {
                XmlWriter.WriteStartElement(serializableObjectContext.Name,
                                            xmlnsForType);
            }

            {
                if (serializableObjectContext.IsComplexValue)
                {
                    XpsSerializationPrintTicketRequiredEventArgs e =
                        new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedDocumentPrintTicket,
                                                                         0);

                    ((IXpsSerializationManager)SerializationManager).OnXPSSerializationPrintTicketRequired(e);

                    //
                    // Serialize the data for the PrintTicket
                    //
                    if (e.Modified)
                    {
                        if (e.PrintTicket != null)
                        {
                            PrintTicketSerializer serializer = new PrintTicketSerializer(SerializationManager);
                            serializer.SerializeObject(e.PrintTicket);
                        }
                    }

                    SerializeObjectCore(serializableObjectContext);
                }
                else
                {
                    throw new XpsSerializationException(SR.Get(SRID.ReachSerialization_WrongPropertyTypeForFixedDocument));
                }
            }

            //
            // Clear off the table from the packaging policy
            //
            ((XpsSerializationManager)SerializationManager).ResourcePolicy.ImageCrcTable = null;

            ((XpsSerializationManager)SerializationManager).ResourcePolicy.ImageUriHashTable = null;

            XmlWriter.WriteEndElement();
            XmlWriter = null;

            //
            // Signal to any registered callers that the Document has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            ((IXpsSerializationManager)SerializationManager).OnXPSSerializationProgressChanged(progressEvent);

            if (SerializationManager is XpsSerializationManager)
            {
                (SerializationManager as XpsSerializationManager).RegisterDocumentEnd();
            }
        }
        EndSerializeReachFixedPage(
            ReachFixedPageSerializerContext context
            )
        {
            ReachFixedPageSerializerContext thisContext = context as ReachFixedPageSerializerContext;

            if (thisContext != null)
            {
                if (thisContext.EndVisual)
                {
                    XmlWriter pageWriter = ((XpsSerializationManagerAsync)SerializationManager).
                                           PackagingPolicy.AcquireXmlWriterForPage();

                    XmlWriter resWriter = ((XpsSerializationManagerAsync)SerializationManager).
                                          PackagingPolicy.AcquireXmlWriterForResourceDictionary();


                    Size fixedPageSize            = ((IXpsSerializationManager)SerializationManager).FixedPageSize;
                    VisualTreeFlattener flattener = ((IXpsSerializationManager)SerializationManager).
                                                    VisualSerializationService.AcquireVisualTreeFlattener(resWriter,
                                                                                                          pageWriter,
                                                                                                          fixedPageSize);

                    flattener.EndVisual();
                }


                ((XpsSerializationManagerAsync)SerializationManager).PackagingPolicy.PreCommitCurrentPage();

                //
                // Copy hyperlinks into stream
                //
                thisContext.TreeWalker.CommitHyperlinks();

                XmlWriter.WriteEndElement();
                //
                //Release used resources
                //
                XmlWriter = null;
                //
                // Free the image table in use for this page
                //
                ((XpsSerializationManagerAsync)SerializationManager).ResourcePolicy.CurrentPageImageTable = null;
                //
                // Free the colorContext table in use for this page
                //
                ((XpsSerializationManagerAsync)SerializationManager).ResourcePolicy.CurrentPageColorContextTable = null;

                //
                // Signal to any registered callers that the Page has been serialized
                //
                XpsSerializationProgressChangedEventArgs progressEvent =
                    new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedPageWritingProgress,
                                                                 0,
                                                                 0,
                                                                 null);

                ((IXpsSerializationManager)SerializationManager).OnXPSSerializationProgressChanged(progressEvent);
                ((IXpsSerializationManager)SerializationManager).VisualSerializationService.ReleaseVisualTreeFlattener();
                if (SerializationManager is IXpsSerializationManager)
                {
                    (SerializationManager as IXpsSerializationManager).RegisterPageEnd();
                }
            }
        }
        PersistObjectData(
            SerializableObjectContext serializableObjectContext
            )
        {
            String xmlnsForType = SerializationManager.GetXmlNSForType(typeof(FixedDocumentSequence));

            if (SerializationManager is XpsSerializationManager)
            {
                (SerializationManager as XpsSerializationManager).RegisterDocumentSequenceStart();
            }

            if (xmlnsForType == null)
            {
                XmlWriter.WriteStartElement(serializableObjectContext.Name);
            }
            else
            {
                XmlWriter.WriteStartElement(serializableObjectContext.Name,
                                            xmlnsForType);
            }

            {
                if (serializableObjectContext.IsComplexValue)
                {
                    //
                    // Pick the data for the PrintTicket if it existed
                    //
                    XpsSerializationPrintTicketRequiredEventArgs e =
                        new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedDocumentSequencePrintTicket,
                                                                         0);

                    ((IXpsSerializationManager)SerializationManager).OnXPSSerializationPrintTicketRequired(e);

                    //
                    // Serialize the data for the PrintTicket
                    //
                    if (e.Modified)
                    {
                        if (e.PrintTicket != null)
                        {
                            PrintTicketSerializer serializer = new PrintTicketSerializer(SerializationManager);
                            serializer.SerializeObject(e.PrintTicket);
                        }
                    }

                    SerializeObjectCore(serializableObjectContext);
                }
                else
                {
                }
            }

            XmlWriter.WriteEndElement();
            XmlWriter = null;

            //
            // Signal to any registered callers that the Sequence has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentSequenceWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            if (SerializationManager is XpsSerializationManager)
            {
                (SerializationManager as XpsSerializationManager).RegisterDocumentSequenceEnd();
            }
            ((IXpsSerializationManager)SerializationManager).OnXPSSerializationProgressChanged(progressEvent);
        }
Exemplo n.º 25
0
        PersistObjectData(
            SerializableObjectContext serializableObjectContext
            )
        {
            String xmlnsForType = SerializationManager.GetXmlNSForType(typeof(FixedDocument));
            String nameForType  = XpsS0Markup.FixedDocument;

            if (SerializationManager is XpsSerializationManager)
            {
                (SerializationManager as XpsSerializationManager).RegisterDocumentStart();
            }

            if (xmlnsForType == null)
            {
                XmlWriter.WriteStartElement(nameForType);
            }
            else
            {
                XmlWriter.WriteStartElement(nameForType,
                                            xmlnsForType);
            }

            {
                XpsSerializationPrintTicketRequiredEventArgs e =
                    new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedDocumentPrintTicket,
                                                                     0);

                ((IXpsSerializationManager)SerializationManager).OnXPSSerializationPrintTicketRequired(e);

                //
                // Serialize the data for the PrintTicket
                //
                if (e.Modified)
                {
                    if (e.PrintTicket != null)
                    {
                        PrintTicketSerializer serializer = new PrintTicketSerializer(SerializationManager);
                        serializer.SerializeObject(e.PrintTicket);
                    }
                }

                DocumentPaginator paginator = (DocumentPaginator)serializableObjectContext.TargetObject;

                XmlLanguage language = null;

                DependencyObject dependencyObject = paginator.Source as DependencyObject;
                if (dependencyObject != null)
                {
                    language = (XmlLanguage)dependencyObject.GetValue(FrameworkContentElement.LanguageProperty);
                }

                if (language == null)
                {
                    //If the language property is null, assign the language to the default
                    language = XmlLanguage.GetLanguage(XpsS0Markup.XmlLangValue);
                }

                SerializationManager.Language = language;

                for (int i = 0; !paginator.IsPageCountValid || (i < paginator.PageCount); i++)
                {
                    DocumentPage page = Toolbox.GetPage(paginator, i);

                    ReachSerializer serializer = SerializationManager.GetSerializer(page);

                    if (serializer != null)
                    {
                        serializer.SerializeObject(page);
                    }
                }
            }

            XmlWriter.WriteEndElement();
            XmlWriter = null;
            //
            // Clear off the table from the resource policy
            //
            ((XpsSerializationManager)SerializationManager).ResourcePolicy.ImageCrcTable = null;

            ((XpsSerializationManager)SerializationManager).ResourcePolicy.ImageUriHashTable = null;
            //
            // Clear off the table from the resource policy
            //
            ((XpsSerializationManager)SerializationManager).ResourcePolicy.ColorContextTable = null;
            //
            // Signal to any registered callers that the Document has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            if (SerializationManager is XpsSerializationManager)
            {
                (SerializationManager as XpsSerializationManager).RegisterDocumentEnd();
            }
            ((IXpsSerializationManager)SerializationManager).OnXPSSerializationProgressChanged(progressEvent);
        }
        PersistObjectData(
            SerializableObjectContext serializableObjectContext
            )
        {
            Toolbox.EmitEvent(EventTrace.Event.WClientDRXSerializationBegin);

            if (serializableObjectContext == null)
            {
                throw new ArgumentNullException("serializableObjectContext");
            }

            if (SerializationManager is IXpsSerializationManager)
            {
                (SerializationManager as IXpsSerializationManager).RegisterPageStart();
            }

            FixedPage fixedPage = serializableObjectContext.TargetObject as FixedPage;

            ReachTreeWalker treeWalker = new ReachTreeWalker(this);

            treeWalker.SerializeLinksInFixedPage((FixedPage)serializableObjectContext.TargetObject);

            String xmlnsForType = SerializationManager.GetXmlNSForType(serializableObjectContext.TargetObject.GetType());

            if (xmlnsForType == null)
            {
                XmlWriter.WriteStartElement(serializableObjectContext.Name);
            }
            else
            {
                XmlWriter.WriteStartElement(serializableObjectContext.Name);

                XmlWriter.WriteAttributeString(XpsS0Markup.Xmlns, xmlnsForType);
                XmlWriter.WriteAttributeString(XpsS0Markup.XmlnsX, XpsS0Markup.XmlnsXSchema);

                XmlLanguage language = fixedPage.Language;
                if (language == null)
                {
                    //If the language property is null, assign the language to the default
                    language = XmlLanguage.GetLanguage(XpsS0Markup.XmlLangValue);
                }

                SerializationManager.Language = language;

                XmlWriter.WriteAttributeString(XpsS0Markup.XmlLang, language.ToString());
            }
            {
                Size fixedPageSize = new Size(fixedPage.Width, fixedPage.Height);
                ((IXpsSerializationManager)SerializationManager).FixedPageSize = fixedPageSize;

                //
                // Before we serialize any properties on the FixedPage, we need to
                // serialize the FixedPage as a Visual
                //
                Visual fixedPageAsVisual = serializableObjectContext.TargetObject as Visual;

                bool needEndVisual = false;

                if (fixedPageAsVisual != null)
                {
                    needEndVisual = SerializePageAsVisual(fixedPageAsVisual);
                }

                if (serializableObjectContext.IsComplexValue)
                {
                    PrintTicket printTicket = ((IXpsSerializationManager)SerializationManager).FixedPagePrintTicket;

                    if (printTicket != null)
                    {
                        PrintTicketSerializer serializer = new PrintTicketSerializer(SerializationManager);
                        serializer.SerializeObject(printTicket);
                        ((IXpsSerializationManager)SerializationManager).FixedPagePrintTicket = null;
                    }

                    SerializeObjectCore(serializableObjectContext);
                }
                else
                {
                    throw new XpsSerializationException(SR.Get(SRID.ReachSerialization_WrongPropertyTypeForFixedPage));
                }

                if (needEndVisual)
                {
                    XmlWriter pageWriter = ((XpsSerializationManager)SerializationManager).
                                           PackagingPolicy.AcquireXmlWriterForPage();

                    XmlWriter resWriter = ((XpsSerializationManager)SerializationManager).
                                          PackagingPolicy.AcquireXmlWriterForResourceDictionary();


                    VisualTreeFlattener flattener = ((IXpsSerializationManager)SerializationManager).
                                                    VisualSerializationService.AcquireVisualTreeFlattener(resWriter,
                                                                                                          pageWriter,
                                                                                                          fixedPageSize);

                    flattener.EndVisual();
                }
            }

            ((XpsSerializationManager)SerializationManager).PackagingPolicy.PreCommitCurrentPage();

            //
            // Copy hyperlinks into stream
            //
            treeWalker.CommitHyperlinks();

            XmlWriter.WriteEndElement();
            //
            //Release used resources
            //
            XmlWriter = null;
            //
            // Free the image table in use for this page
            //
            ((XpsSerializationManager)SerializationManager).ResourcePolicy.CurrentPageImageTable = null;
            //
            // Free the colorContext table in use for this page
            //
            ((XpsSerializationManager)SerializationManager).ResourcePolicy.CurrentPageColorContextTable = null;
            //
            // Free the resourceDictionary table in use for this page
            //
            ((XpsSerializationManager)SerializationManager).ResourcePolicy.CurrentPageResourceDictionaryTable = null;

            ((IXpsSerializationManager)SerializationManager).VisualSerializationService.ReleaseVisualTreeFlattener();

            if (SerializationManager is IXpsSerializationManager)
            {
                (SerializationManager as IXpsSerializationManager).RegisterPageEnd();
            }

            //
            // Signal to any registered callers that the Page has been serialized
            //
            XpsSerializationProgressChangedEventArgs progressEvent =
                new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedPageWritingProgress,
                                                             0,
                                                             0,
                                                             null);

            ((IXpsSerializationManager)SerializationManager).OnXPSSerializationProgressChanged(progressEvent);

            Toolbox.EmitEvent(EventTrace.Event.WClientDRXSerializationEnd);
        }