GetXpsImageTypeFromContentType( ContentType contentType ) { if (contentType == null) { throw new ArgumentNullException(nameof(contentType)); } if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.JpgContentType)) { return(XPS_IMAGE_TYPE.XPS_IMAGE_TYPE_JPEG); } else if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.PngContentType)) { return(XPS_IMAGE_TYPE.XPS_IMAGE_TYPE_PNG); } else if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.TifContentType)) { return(XPS_IMAGE_TYPE.XPS_IMAGE_TYPE_TIFF); } else if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.WdpContentType)) { return(XPS_IMAGE_TYPE.XPS_IMAGE_TYPE_WDP); } else { throw new XpsPackagingException(SR.Get(SRID.ReachPackaging_UnsupportedImageType)); } }
//Throws an exception if the relationship part does not have the correct content type private void ThrowIfIncorrectContentType(ContentType contentType) { if (!contentType.AreTypeAndSubTypeEqual(PackagingUtilities.RelationshipPartContentType)) { throw new FileFormatException(SR.Get(SRID.RelationshipPartIncorrectContentType)); } }
// Token: 0x06002CFA RID: 11514 RVA: 0x000CAC74 File Offset: 0x000C8E74 public bool IsValidRequiredResourceMimeType(ContentType mimeType) { foreach (object obj in this._requiredResourceMimeTypes.Keys) { ContentType contentType = (ContentType)obj; if (contentType.AreTypeAndSubTypeEqual(mimeType)) { return(true); } } return(false); }
GetFixedDocumentSequence( ) { CheckDisposed(); if (CurrentXpsManager == null) { throw new InvalidOperationException(SR.Get(SRID.ReachPackaging_DocumentWasClosed)); } if (!IsReader) { throw new XpsPackagingException(SR.Get(SRID.ReachPackaging_NotOpenForReading)); } if (null == Uri) { throw new XpsPackagingException(SR.Get(SRID.ReachPackaging_PackageUriNull)); } if (CurrentXpsManager.StartingPart == null) { return(null); } ContentType startPartType = CurrentXpsManager.StartingPart.ValidatedContentType(); if (!startPartType.AreTypeAndSubTypeEqual(XpsS0Markup.DocumentSequenceContentType)) { throw new XpsPackagingException(SR.Get(SRID.ReachPackaging_InvalidStartingPart)); } ParserContext parserContext = new ParserContext(); parserContext.BaseUri = PackUriHelper.Create(Uri, CurrentXpsManager.StartingPart.Uri); object fixedObject = XamlReader.Load(CurrentXpsManager.StartingPart.GetStream(), parserContext); if (!(fixedObject is FixedDocumentSequence)) { throw new XpsPackagingException(SR.Get(SRID.ReachPackaging_NotAFixedDocumentSequence)); } return(fixedObject as FixedDocumentSequence); }
private Uri GenerateUniqueUri(ContentType contentType) { string str3; string contentCounterKey = this.GetContentCounterKey(contentType); string key = this.GetContentCounterKey(XpsS0Markup.FixedDocumentContentType); int num = this._contentTypes[contentCounterKey]; int num2 = 0; Guid guid = Guid.NewGuid(); if (this._contentTypes.ContainsKey(key)) { num2 = this._contentTypes[key] - 1; } if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.DocumentSequenceContentType)) { str3 = string.Format(CultureInfo.InvariantCulture, "{0}.fdseq", new object[] { contentCounterKey }); } else if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.FixedDocumentContentType)) { str3 = string.Format(CultureInfo.InvariantCulture, "/Documents/{0}/FixedDocument.fdoc", new object[] { num }); string str4 = this.GetContentCounterKey(XpsS0Markup.FixedPageContentType); this._contentTypes[str4] = 1; } else if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.FixedPageContentType)) { str3 = string.Format(CultureInfo.InvariantCulture, "/Documents/{0}/Pages/{1}.fpage", new object[] { num2, num }); } else if (contentCounterKey.Equals("Dictionary", StringComparison.OrdinalIgnoreCase)) { str3 = string.Format(CultureInfo.InvariantCulture, "/Resources/{0}.dict", new object[] { guid }); } else if (contentCounterKey.Equals("Font", StringComparison.OrdinalIgnoreCase)) { str3 = string.Format(CultureInfo.InvariantCulture, "/Resources/{0}.ttf", new object[] { guid }); } else if (contentCounterKey.Equals("ColorContext", StringComparison.OrdinalIgnoreCase)) { str3 = string.Format(CultureInfo.InvariantCulture, "/Resources/{0}.icc", new object[] { guid }); } else if (contentCounterKey.Equals("ResourceDictionary", StringComparison.OrdinalIgnoreCase)) { str3 = string.Format(CultureInfo.InvariantCulture, "/Resources/{0}.dict", new object[] { guid }); } else if (contentCounterKey.Equals("Image", StringComparison.OrdinalIgnoreCase)) { str3 = string.Format(CultureInfo.InvariantCulture, "/Resources/{0}.{1}", new object[] { guid, LookupImageExtension(contentType) }); } else { str3 = string.Format(CultureInfo.InvariantCulture, "/{0}s/{0}_{1}.xaml", new object[] { contentCounterKey, num }); } num++; this._contentTypes.Remove(contentCounterKey); this._contentTypes[contentCounterKey] = num; return PackUriHelper.CreatePartUri(new Uri(str3, UriKind.Relative)); }
public PackagePart GeneratePart(ContentType contentType, Uri partUri) { if (this._metroPackage == null) { throw new ObjectDisposedException("XpsManager"); } if (!this.IsWriter) { throw new XpsPackagingException(SR.Get("ReachPackaging_OnlyWriters")); } if (contentType == null) { throw new ArgumentNullException("contentType"); } if (contentType.ToString().Length == 0) { throw new ArgumentException("contentType"); } CompressionOption compressionOption = this._compressionOption; if ((contentType.AreTypeAndSubTypeEqual(XpsS0Markup.JpgContentType) || contentType.AreTypeAndSubTypeEqual(XpsS0Markup.PngContentType)) || (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.TifContentType) || contentType.AreTypeAndSubTypeEqual(XpsS0Markup.WdpContentType))) { compressionOption = CompressionOption.NotCompressed; } PackagePart part = this._metroPackage.CreatePart(partUri, contentType.ToString(), compressionOption); this._cachedParts[partUri] = part; return part; }
public static bool SupportedImageType(ContentType imageContentType) { bool flag = false; if ((!imageContentType.AreTypeAndSubTypeEqual(XpsS0Markup.JpgContentType) && !imageContentType.AreTypeAndSubTypeEqual(XpsS0Markup.PngContentType)) && (!imageContentType.AreTypeAndSubTypeEqual(XpsS0Markup.TifContentType) && !imageContentType.AreTypeAndSubTypeEqual(XpsS0Markup.WdpContentType))) { return flag; } return true; }
private static string LookupImageExtension(ContentType contentType) { string pngExtension = XpsS0Markup.PngExtension; if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.JpgContentType)) { return XpsS0Markup.JpgExtension; } if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.PngContentType)) { return XpsS0Markup.PngExtension; } if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.TifContentType)) { return XpsS0Markup.TifExtension; } if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.WdpContentType)) { pngExtension = XpsS0Markup.WdpExtension; } return pngExtension; }
private string GetContentCounterKey(ContentType contentType) { string subTypeComponent; if (ContentType.Empty.AreTypeAndSubTypeEqual(contentType)) { throw new ArgumentException("contentType"); } if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.DocumentSequenceContentType)) { subTypeComponent = "FixedDocumentSequence"; } else if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.FixedDocumentContentType)) { subTypeComponent = "FixedDocument"; } else if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.FixedPageContentType)) { subTypeComponent = "FixedPage"; } else if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.DocumentStructureContentType)) { subTypeComponent = "DocumentStructure"; } else if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.PrintTicketContentType)) { subTypeComponent = "PrintTicket"; } else if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.FontContentType)) { subTypeComponent = "Font"; } else if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.ColorContextContentType)) { subTypeComponent = "ColorContext"; } else if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.ResourceDictionaryContentType)) { subTypeComponent = "ResourceDictionary"; } else if (string.CompareOrdinal(contentType.TypeComponent.ToUpper(CultureInfo.InvariantCulture), "Image".ToUpper(CultureInfo.InvariantCulture)) == 0) { subTypeComponent = "Image"; } else { subTypeComponent = contentType.SubTypeComponent; } if (!this._contentTypes.ContainsKey(subTypeComponent)) { this._contentTypes[subTypeComponent] = 1; } return subTypeComponent; }