Exemple #1
0
 ReachTreeWalker(
     XmlWriter writer,
     PackageSerializationManager serializationManager)
 {
     _serializerXmlWriter  = writer;
     _serializationManager = serializationManager;
 }
Exemple #2
0
 VisualSerializationService(
     PackageSerializationManager serializationManager
     )
 {
     _serializationManager = serializationManager;
     _visualTreeFlattener  = null;
 }
 NgcDocumentSequenceSerializerAsync(
     PackageSerializationManager manager
     )
     :
     base(manager)
 {
 }
        IsComplexValue(
            PackageSerializationManager manager,
            out bool canConvert
            )
        {
            bool isComplex = true;

            canConvert = true;

            if (SerializerType != null)
            {
                isComplex = true;
            }
            else
            {
                TypeConverter converter = this.TypeConverter;

                canConvert = converter.CanConvertTo(null, typeof(string)) &&
                             converter.CanConvertFrom(null, typeof(string));

                if (canConvert)
                {
                    isComplex = false;
                }
            }

            return(isComplex);
        }
 DocumentPaginatorSerializerAsync(
     PackageSerializationManager manager
     )
     :
     base(manager)
 {
 }
        FixedPageSerializer(
            PackageSerializationManager manager
            ):
        base(manager)
        {

        }
 DocumentPageSerializer(
     PackageSerializationManager manager
     )
     :
     base(manager)
 {
 }
        GetBitmapSourceFromImageTable(PackageSerializationManager manager, BitmapSource bitmapSource)
        {
            Uri imageUri = null;

            //Initialize cache values
            _uriHashValue   = 0;
            _crc32HashValue = 0;

            BitmapFrame bitmapFrame = bitmapSource as BitmapFrame;

            //Use the Uri hash table if we have a bitmap with a Uri
            if (bitmapFrame != null &&
                bitmapFrame.Decoder != null)
            {
                String sourceUri = bitmapFrame.Decoder.ToString();
                if (sourceUri != null)
                {
                    _uriHashValue = sourceUri.GetHashCode();

                    Dictionary <int, Uri> imageUriHashTable = manager.ResourcePolicy.ImageUriHashTable;
                    if (imageUriHashTable.ContainsKey(_uriHashValue))
                    {
                        imageUri = imageUriHashTable[_uriHashValue];
                    }
                }
            }

            //Checking the UriHash for zero tells us if the uri of the bitmap was checked and if it returned a valid Uri
            if (_uriHashValue == 0)
            {
                //
                // Calculate the image Crc32 value.  This is used as a key
                // into the image cache.
                //
                _crc32HashValue = CalculateImageCrc32(bitmapSource);

                //
                // Get the current image cache
                //
                Dictionary <UInt32, Uri> imageCrcTable = manager.ResourcePolicy.ImageCrcTable;

                //
                // The image has already been cached (and therefore serialized).
                // No need to serialize it again so we just return the Uri in the
                // package where the original was serialized. For that Uri returned
                // a relationship is only created if this has not been included on
                // the current page before.
                //
                if (imageCrcTable.ContainsKey(_crc32HashValue))
                {
                    imageUri = imageCrcTable[_crc32HashValue];
                }
            }

            return(imageUri);
        }
 XpsOMFixedPageSerializer(
     PackageSerializationManager manager
     ) :
     base(manager)
 {
     ///
     /// Fail if manager is not XpsOMSerializationManager
     ///
     _xpsOMSerializationManager = (XpsOMSerializationManager)manager;
 }
 NgcDocumentPageSerializerAsync(
     PackageSerializationManager manager
     ) :
     base(manager)
 {
     if (manager == null)
     {
         throw new ArgumentNullException("manager");
     }
 }
Exemple #11
0
 XpsOMDocumentSequenceSerializer(
     PackageSerializationManager manager
     ) :
     base(manager)
 {
     ///
     /// Fail if manager is not XpsOMSerializationManager
     ///
     _xpsOMSerializationManager = (XpsOMSerializationManager)manager;
 }
Exemple #12
0
 NgcFixedDocumentSerializer(
     PackageSerializationManager manager
     ) :
     base(manager)
 {
     if (manager == null)
     {
         throw new ArgumentNullException("manager");
     }
 }
Exemple #13
0
 NgcReachVisualSerializer(
     PackageSerializationManager manager
     ) :
     base(manager)
 {
     if (manager == null)
     {
         throw new ArgumentNullException("manager");
     }
 }
        ConvertTo(
            ITypeDescriptorContext context,
            System.Globalization.CultureInfo culture,
            object value,
            Type destinationType
            )
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            Toolbox.EmitEvent(EventTrace.Event.WClientDRXConvertFontBegin);

            if (!IsSupportedType(destinationType))
            {
                throw new NotSupportedException(SR.Get(SRID.Converter_ConvertToNotSupported));
            }

            PackageSerializationManager manager = (PackageSerializationManager)context.GetService(typeof(XpsSerializationManager));
            //
            // Ensure that we have a valid GlyphRun instance
            //
            GlyphRun fontGlyphRun = (GlyphRun)value;

            if (fontGlyphRun == null)
            {
                throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "GlyphRun"));
            }

            //
            // Obtain the font serialization service from the serlialization manager.
            //
            IServiceProvider            resourceServiceProvider = manager.ResourcePolicy;
            XpsFontSerializationService fontService             = (XpsFontSerializationService)resourceServiceProvider.GetService(typeof(XpsFontSerializationService));

            if (fontService == null)
            {
                throw new XpsSerializationException(SR.Get(SRID.ReachSerialization_NoFontService));
            }

            //
            // Retrieve the current font subsetter
            //
            XpsFontSubsetter fontSubsetter = fontService.FontSubsetter;

            //
            // Add the font subset to the font subsetter and retrieve a Uri
            // to the font within the Xps package.
            //
            Uri resourceUri = fontSubsetter.ComputeFontSubset(fontGlyphRun);

            Toolbox.EmitEvent(EventTrace.Event.WClientDRXConvertFontEnd);

            return(resourceUri);
        }
Exemple #15
0
 ReachSerializer(
     PackageSerializationManager manager
     )
 {
     if (manager == null)
     {
         throw new ArgumentNullException("manager");
     }
     _serializationManager = manager;
     _xmlWriter            = null;
 }
        IsComplexProperty(
            PackageSerializationManager serializationManager
            )
        {
            bool isComplex = false;

            //
            // Null property value is always serialized
            // in simple attribute="*null" notation
            //
            if (Value != null)
            {
                //
                // If the property has a DesignerSerializationOptions.SerializeAsAttribute
                // then obviously we do not use complex notation
                //
                if (!(DesignerSerializationOptionsAttribute != null &&
                      (DesignerSerializationOptionsAttribute.DesignerSerializationOptions ==
                       DesignerSerializationOptions.SerializeAsAttribute)))

                {
                    //
                    // String space preservation is honored by System.Xml only for contents of a tag not within
                    // an attribute value. Hence we always emit strings as content within a tag
                    //
                    Type valueType = Value.GetType();

                    if (valueType == typeof(string) &&
                        ((string)Value) != string.Empty)
                    {
                        isComplex = true;
                    }
                    else
                    {
                        bool canConvert;
                        isComplex = IsComplexValue(serializationManager,
                                                   out canConvert);

                        if (!canConvert)
                        {
                            Expression expr = this.Value as Expression;

                            if (expr != null)
                            {
                                this.Value = ((DependencyObject)this.TargetObject).GetValue((DependencyProperty)this.DependencyProperty);
                                isComplex  = this.IsComplexProperty(serializationManager);
                            }
                        }
                    }
                }
            }

            return(isComplex);
        }
 XpsOMFixedPageSerializerAsync(
     PackageSerializationManager manager
     ) :
     base(manager)
 {
     ///
     /// Fail if manager is not XpsOMSerializationManagerAsync
     ///
     _xpsOMSerializationManagerAsync = (XpsOMSerializationManagerAsync)manager;
     _syncSerializer = new XpsOMFixedPageSerializer(manager);
 }
Exemple #18
0
 XpsOMDocumentSequenceSerializerAsync(
     PackageSerializationManager manager
     ) :
     base(manager)
 {
     ///
     /// Fail if manager is not XpsOMSerializationManagerAsync
     ///
     _xpsOMSerializationManagerAsync = (XpsOMSerializationManagerAsync)manager;
     _syncSerializer = new XpsOMDocumentSequenceSerializer(manager);
 }
Exemple #19
0
 SerializersCacheManager(
     PackageSerializationManager serializationManager
     )
 {
     this._serializationManager = serializationManager;
     //
     // Allocate all necessary hashtables for storing
     // the cache information
     //
     _typesCacheTable  = new Hashtable(20);
     _serializersTable = new Hashtable(20);
     _typesDependencyPropertiesCacheTable = new Hashtable(20);
 }
Exemple #20
0
 XpsTokenContext(
     PackageSerializationManager serializationManager,
     Object targetObject,
     Object objectValue
     )
 {
     //
     // Make necessary checks and throw necessary exceptions
     //
     this.serializationManager = serializationManager;
     this.targetObject         = targetObject;
     this.objectValue          = objectValue;
     this.propertyInfo         = null;
     this.dependencyProperty   = null;
 }
        AddBitmapSourceToImageTables(PackageSerializationManager manager, Uri imageUri)
        {
            if (_uriHashValue != 0)
            {
                manager.ResourcePolicy.ImageUriHashTable.Add(_uriHashValue, imageUri);
                _uriHashValue = 0;
            }
            else
            {
                manager.ResourcePolicy.ImageCrcTable.Add(_crc32HashValue, imageUri);
                _crc32HashValue = 0;
            }

            manager.ResourcePolicy.CurrentPageImageTable.Add(imageUri.GetHashCode(), imageUri);
        }
Exemple #22
0
 XpsTokenContext(
     PackageSerializationManager serializationManager,
     SerializablePropertyContext propertyContext
     )
 {
     //
     // Make necessary checks and throw necessary exceptions
     //
     this.serializationManager = serializationManager;
     this.targetObject         = propertyContext.TargetObject;
     this.objectValue          = propertyContext.Value;
     this.propertyInfo         = propertyContext.PropertyInfo;
     this.dependencyProperty   = (propertyContext is SerializableDependencyPropertyContext) ?
                                 (DependencyProperty)((SerializableDependencyPropertyContext)propertyContext).DependencyProperty :
                                 null;
 }
        SerializablePropertyCollection(
            PackageSerializationManager manager,
            object targetObject
            )
        {
            this._simplePropertyCollection  = null;
            this._complexPropertyCollection = null;
            this._simplePropertiesIndex     = -1;
            this._complexPropertiesIndex    = -1;
            this._queueEnumerator           = null;
            this._serializationManager      = manager;
            this._target       = targetObject;
            this._isSimpleMode = true;

            Initialize(manager, _target);
        }
        NGCSerializerAsync(
            PackageSerializationManager manager
            )
        {
            if (manager == null)
            {
                throw new ArgumentNullException("manager");
            }

            _serializationManager = manager as NgcSerializationManagerAsync;

            if (_serializationManager == null)
            {
                throw new XpsSerializationException(SR.Get(SRID.ReachSerializationAsync_NoNgcType));
            }
        }
        Initialize(
            PackageSerializationManager serializationManager,
            object targetObject
            )
        {
            this._serializationManager = serializationManager;
            this._target = targetObject;

            //
            // Collect all serializable properties on the
            // current object instance. Those could be
            // o clr properties
            // o dependency properties
            //
            if (_simplePropertyCollection == null)
            {
                _simplePropertyCollection = new Queue();
            }

            if (_complexPropertyCollection == null)
            {
                _complexPropertyCollection = new Queue();
            }

            //
            // Collecting information about the CLR properties
            //
            InitializeSerializableClrProperties();

            //
            // Now that we are done with the clr serializable properties we need to
            // iterate through locally set dependency properties on this instance
            // that have not been serialized already.
            // Note: Dependency Properties can only be set on Dependency Objects
            //
            InitializeSerializableDependencyProperties();

            //
            // Reset the enumerator
            // to begin enumerating
            // from the start of the
            // properties collection
            //
            Reset();
        }
Exemple #26
0
        ReachSerializerAsync(
            PackageSerializationManager manager
            )
        {
            if (manager == null)
            {
                throw new ArgumentNullException("manager");
            }

            _serializationManager = manager as IXpsSerializationManagerAsync;

            if (_serializationManager == null)
            {
                throw new XpsSerializationException(SR.Get(SRID.ReachSerialization_NotXpsSerializationManagerAsync));
            }

            _xmlWriter = null;
        }
Exemple #27
0
        ReachHierarchySimulator(
            PackageSerializationManager manager,
            Object serializedObject
            )
        {
            if (manager == null)
            {
                throw new ArgumentNullException("manager");
            }
            if (serializedObject == null)
            {
                throw new ArgumentNullException("manager");
            }

            this._serializationManager      = manager;
            this._serializedObject          = serializedObject;
            this._documentSequenceXmlWriter = null;
            this._documentXmlWriter         = null;
            this._pageXmlWriter             = null;
        }
 PrintTicketSerializerAsync(
     PackageSerializationManager manager
     ) :
     base(manager)
 {
 }
Exemple #29
0
 ReachDocumentReferenceCollectionSerializer(
     PackageSerializationManager manager
     ) :
     base(manager)
 {
 }
 FixedDocumentSerializerAsync(
     PackageSerializationManager manager
     ) :
     base(manager)
 {
 }