public DocumentFill(DocumentDeserializationContext context, PropertyDictionary framedObjectDictionary) { if (framedObjectDictionary.HasDictionaryFor("color")) { _color = PropertyBuilders.ToColor(framedObjectDictionary.DictionaryFor("color")); } }
public RectangularDocumentFrame(DocumentDeserializationContext context, PropertyDictionary frameDictionary) : base(context, frameDictionary) { if (!frameDictionary.HasDictionaryFor("clipBounds")) { throw new DocumentReadingException("A label frame is missing the required \"clipBounds\" field."); } if (!frameDictionary.HasDictionaryFor("framedObject")) { throw new DocumentReadingException("A label frame is missing the required \"framedObject\" field."); } _clipBounds = PropertyBuilders.ToRectangle(frameDictionary.DictionaryFor("clipBounds")); PropertyDictionary framedObjectDictionary = frameDictionary.DictionaryFor("framedObject"); string framedObjectType = framedObjectDictionary.StringFor("type", "missing"); switch (framedObjectType) { case "image": _framedObject = new DocumentImage(context, framedObjectDictionary); break; case "fill": _framedObject = new DocumentFill(context, framedObjectDictionary); break; default: throw new DocumentReadingException(string.Format("The document object type \"{0}\" is not supported in this version.", framedObjectType)); } }
public DocumentFrame(DocumentDeserializationContext context, PropertyDictionary frameProperties) { if (!frameProperties.HasDictionaryFor("offsetInDocument")) { throw new DocumentReadingException("A frame is missing the required \"offsetInDocument\" field."); } _offsetInDocument = PropertyBuilders.ToPoint(frameProperties.DictionaryFor("offsetInDocument")); }
public LabelDocumentFrame(DocumentDeserializationContext context, PropertyDictionary frameProperties) : base(context, frameProperties) { if (!frameProperties.HasDictionaryFor("callOutOffsetInDocument")) { throw new DocumentReadingException("A label frame is missing the required \"callOutOffsetInDocument\" field."); } _callOutOffsetInDocument = PropertyBuilders.ToSize(frameProperties.DictionaryFor("callOutOffsetInDocument")); _label = frameProperties.StringFor("label", ""); _caption = frameProperties.StringFor("caption", ""); }
public DocumentImage(DocumentDeserializationContext context, PropertyDictionary framedObjectDictionary) { int imageLinkIndex = framedObjectDictionary.IntegerFor("imageLinkIndex").Value; if (!context.ImageLinksByKey.ContainsKey(imageLinkIndex)) { throw new DocumentReadingException(string.Format( "The image link index \"{0}\" was not found in the image link manager dictionary.", imageLinkIndex)); } _imageLink = context.ImageLinksByKey[imageLinkIndex]; }
internal ImageLinkManager(DocumentDeserializationContext context, PropertyDictionary managerDictionary) { PropertyDictionary imageLinks = managerDictionary.DictionaryFor("imageLinks"); if (imageLinks == null) throw new InvalidOperationException("The image manager dictionary is missing the \"imageLinks\" key."); foreach (object key in imageLinks.Keys) { if (!(key is int)) throw new InvalidOperationException("The image links dictionary contains a non-integer key, which is not permitted."); int linkIndex = (int)key; PropertyDictionary imageDictionary = imageLinks.DictionaryFor(key); ImageLink link = new ImageLink(context, imageDictionary); _referenceCountByLink[link] = 0; context.ImageLinksByKey[linkIndex] = link; } }
public ImageLink(DocumentDeserializationContext context, PropertyDictionary dictionary) { _fileName = Path.Combine(context.AbsolutePath, dictionary.StringFor("fileName")); _physicalDimension = PropertyBuilders.ToSize(dictionary.DictionaryFor("physicalDimension")); }
static DocumentFrame DeserializeFrame(DocumentDeserializationContext context, PropertyDictionary frameProperties) { string type = frameProperties.StringFor("type", "missing"); switch (type) { case "label": return new LabelDocumentFrame(context, frameProperties); case "rectangular": return new RectangularDocumentFrame(context, frameProperties); default: throw new DocumentReadingException(string.Format("The frame type \"{0}\" is not recognised by this version.", type)); } }
public static Document Deserialize(PropertyDictionary container, string absolutePath) { PropertyDictionary documentProperties = container.DictionaryFor("pasteUp"); if (documentProperties == null) return null; if (!documentProperties.HasIntegerFor("majorVersion", "majorVersion")) { throw new DocumentReadingException("The document lacks the required major and minor version numbers."); } if (documentProperties.IntegerFor("majorVersion") > MajorVersion) { throw new DocumentReadingException("The document version is not supported by this reader."); } Document document = new Document(); if (documentProperties.IntegerFor("majorVersion") == MajorVersion && documentProperties.IntegerFor("minorVersion") > MinorVersion) { document._wasDownConverted = true; } DocumentDeserializationContext context = new DocumentDeserializationContext( documentProperties.IntegerFor("majorVersion").Value, documentProperties.IntegerFor("minorVersion").Value, absolutePath); PropertyDictionary imageLinkManagerProperties = documentProperties.DictionaryFor("imageLinkManager"); if (imageLinkManagerProperties == null) throw new DocumentReadingException( "The image link manager dictionary is missing from the document."); document._imageLinkManager = new ImageLinkManager(context, imageLinkManagerProperties); PropertyArray framesArray = documentProperties.ArrayFor("frames"); if (framesArray == null) throw new DocumentReadingException("The frames array is missing from the document."); for (int i = 0; i < framesArray.Count; i++) { PropertyDictionary frameProperties = framesArray.DictionaryAt(i); if (frameProperties == null) throw new DocumentReadingException( "The document frame array contains an invalid non-dictionary object."); document._frames.Add(DeserializeFrame(context, frameProperties)); } return document; }