Beispiel #1
0
        public OLEPropertiesContainer(int codePage, ContainerType containerType)
        {
            Context = new PropertyContext
            {
                CodePage = codePage,
                Behavior = Behavior.CaseInsensitive
            };

            ContainerType = containerType;
        }
Beispiel #2
0
        public ITypedPropertyValue NewProperty(VtPropertyType vType, PropertyContext ctx)
        {
            ITypedPropertyValue pr;

            switch (vType)
            {
            case VtPropertyType.VtI2:
                pr = new VtI2Property(vType);
                break;

            case VtPropertyType.VtI4:
                pr = new VtI4Property(vType);
                break;

            case VtPropertyType.VtR4:
                pr = new VtR4Property(vType);
                break;

            case VtPropertyType.VtLpstr:
                pr = new VtLpstrProperty(vType, ctx.CodePage);
                break;

            case VtPropertyType.VtFiletime:
                pr = new VtFiletimeProperty(vType);
                break;

            case VtPropertyType.VtDecimal:
                pr = new VtDecimalProperty(vType);
                break;

            case VtPropertyType.VtBool:
                pr = new VtBoolProperty(vType);
                break;

            case VtPropertyType.VtVectorHeader:
                pr = new VtVectorHeader(vType);
                break;

            case VtPropertyType.VtEmpty:
                pr = new VtEmptyProperty(vType);
                break;

            default:
                throw new Exception("Unrecognized property type");
            }

            return(pr);
        }
Beispiel #3
0
        public ITypedPropertyValue NewProperty(VTPropertyType vType, PropertyContext ctx)
        {
            ITypedPropertyValue pr = null;

            switch (vType)
            {
            case VTPropertyType.VT_I2:
                pr = new VT_I2_Property(vType);
                break;

            case VTPropertyType.VT_I4:
                pr = new VT_I4_Property(vType);
                break;

            case VTPropertyType.VT_R4:
                pr = new VT_R4_Property(vType);
                break;

            case VTPropertyType.VT_LPSTR:
                pr = new VT_LPSTR_Property(vType, ctx.CodePage);
                break;

            case VTPropertyType.VT_FILETIME:
                pr = new VT_FILETIME_Property(vType);
                break;

            case VTPropertyType.VT_DECIMAL:
                pr = new VT_DECIMAL_Property(vType);
                break;

            case VTPropertyType.VT_BOOL:
                pr = new VT_BOOL_Property(vType);
                break;

            case VTPropertyType.VT_VECTOR_HEADER:
                pr = new VT_VectorHeader(vType);
                break;

            case VTPropertyType.VT_EMPTY:
                pr = new VT_EMPTY_Property(vType);
                break;

            default:
                throw new Exception("Unrecognized property type");
            }

            return(pr);
        }
Beispiel #4
0
        public void LoadContext(int propertySetOffset, BinaryReader br)
        {
            var currPos = br.BaseStream.Position;

            PropertyContext = new PropertyContext();
            var codePageOffset = (int)(propertySetOffset + PropertyIdentifierAndOffsets.Where(pio => pio.PropertyIdentifier == 1).First().Offset);

            br.BaseStream.Seek(codePageOffset, SeekOrigin.Begin);

            VTPropertyType vType = (VTPropertyType)br.ReadUInt16();

            br.ReadUInt16(); // Ushort Padding
            PropertyContext.CodePage = (int)(ushort)br.ReadInt16();

            br.BaseStream.Position = currPos;
        }
Beispiel #5
0
        internal OLEPropertiesContainer(CFStream cfStream)
        {
            var pStream = new PropertySetStream();

            this.cfStream = cfStream;
            pStream       = new PropertySetStream();
            pStream.Read(new BinaryReader(new StreamDecorator(cfStream)));

            switch (pStream.FMTID0.ToString("B").ToUpperInvariant())
            {
            case "{F29F85E0-4FF9-1068-AB91-08002B27B3D9}":
                ContainerType = ContainerType.SummaryInfo;
                break;

            case "{D5CDD502-2E9C-101B-9397-08002B2CF9AE}":
                ContainerType = ContainerType.DocumentSummaryInfo;
                break;

            default:
                ContainerType = ContainerType.AppSpecific;
                break;
            }


            PropertyNames = (Dictionary <uint, string>)pStream.PropertySet0.Properties
                            .FirstOrDefault(p => p.PropertyType == PropertyType.DictionaryProperty);

            Context = new PropertyContext
            {
                CodePage = pStream.PropertySet0.PropertyContext.CodePage
            };

            for (var i = 0; i < pStream.PropertySet0.Properties.Count; i++)
            {
                if (pStream.PropertySet0.PropertyIdentifierAndOffsets[i].PropertyIdentifier == 0)
                {
                    continue;
                }
                //if (pStream.PropertySet0.PropertyIdentifierAndOffsets[i].PropertyIdentifier == 1) continue;
                //if (pStream.PropertySet0.PropertyIdentifierAndOffsets[i].PropertyIdentifier == 0x80000000) continue;

                var p   = (ITypedPropertyValue)pStream.PropertySet0.Properties[i];
                var poi = pStream.PropertySet0.PropertyIdentifierAndOffsets[i];

                var op = new OLEProperty(this);

                op.VTType             = p.VTType;
                op.PropertyIdentifier = pStream.PropertySet0.PropertyIdentifierAndOffsets[i].PropertyIdentifier;
                op.Value = p.Value;


                properties.Add(op);
            }

            if (pStream.NumPropertySets == 2)
            {
                UserDefinedProperties =
                    new OLEPropertiesContainer(Context.CodePage, ContainerType.UserDefinedProperties);
                HasUserDefinedProperties = true;

                UserDefinedProperties.ContainerType = ContainerType.UserDefinedProperties;

                for (var i = 0; i < pStream.PropertySet1.Properties.Count; i++)
                {
                    if (pStream.PropertySet1.PropertyIdentifierAndOffsets[i].PropertyIdentifier == 0)
                    {
                        continue;
                    }
                    //if (pStream.PropertySet1.PropertyIdentifierAndOffsets[i].PropertyIdentifier == 1) continue;
                    if (pStream.PropertySet1.PropertyIdentifierAndOffsets[i].PropertyIdentifier == 0x80000000)
                    {
                        continue;
                    }

                    var p   = (ITypedPropertyValue)pStream.PropertySet1.Properties[i];
                    var poi = pStream.PropertySet1.PropertyIdentifierAndOffsets[i];

                    var op = new OLEProperty(UserDefinedProperties);

                    op.VTType             = p.VTType;
                    op.PropertyIdentifier = pStream.PropertySet1.PropertyIdentifierAndOffsets[i].PropertyIdentifier;
                    op.Value = p.Value;

                    UserDefinedProperties.properties.Add(op);
                }

                UserDefinedProperties.PropertyNames = (Dictionary <uint, string>)pStream.PropertySet1.Properties
                                                      .Where(p => p.PropertyType == PropertyType.DictionaryProperty).FirstOrDefault()?.Value;
            }
        }
Beispiel #6
0
 public PropertyFactory(PropertyContext ctx)
 {
     this.ctx = ctx;
 }