コード例 #1
0
ファイル: LabelControl.cs プロジェクト: PizzaShift/VBASync
        public LabelControl(byte[] b)
        {
            using (var st = new MemoryStream(b))
                using (var r = new FrxReader(st)) {
                    MinorVersion = r.ReadByte();
                    MajorVersion = r.ReadByte();

                    var cbLabel = r.ReadUInt16();
                    PropMask = new LabelPropMask(r.ReadUInt32());

                    // DataBlock
                    ForeColor           = PropMask.HasForeColor ? r.ReadOleColor() : null;
                    BackColor           = PropMask.HasBackColor ? r.ReadOleColor() : null;
                    VariousPropertyBits = PropMask.HasVariousPropertyBits ? r.ReadUInt32() : 0;
                    var captionCcb = PropMask.HasCaption ? r.ReadCcb() : Tuple.Create(0, false);
                    PicturePosition = PropMask.HasPicturePosition ? r.ReadPicturePosition() : PicturePosition.RightTop;
                    MousePointer    = PropMask.HasMousePointer ? r.ReadMousePointer() : MousePointer.Default;
                    BorderColor     = PropMask.HasBorderColor ? r.ReadOleColor() : null;
                    BorderStyle     = PropMask.HasBorderStyle ? r.ReadBorderStyle() : BorderStyle.None;
                    SpecialEffect   = PropMask.HasSpecialEffect ? r.ReadSpecialEffect() : SpecialEffect.Flat;
                    if (PropMask.HasPicture)
                    {
                        r.Skip2Bytes();
                    }
                    Accelerator = PropMask.HasAccelerator ? r.ReadWChar() : "";
                    if (PropMask.HasMouseIcon)
                    {
                        r.Skip2Bytes();
                    }

                    // ExtraDataBlock
                    Caption = r.ReadStringFromCcb(captionCcb);
                    Size    = PropMask.HasSize ? r.ReadCoords() : Tuple.Create(0, 0);

                    r.AlignTo(4);
                    if (cbLabel != r.BaseStream.Position - 4)
                    {
                        throw new ApplicationException("Error reading 'o' stream in .frx data: expected cbLabel size "
                                                       + $"{r.BaseStream.Position - 4}, but actual size was {cbLabel}.");
                    }

                    // StreamData
                    Picture   = PropMask.HasPicture ? r.ReadGuidAndPicture() : new byte[0];
                    MouseIcon = PropMask.HasMouseIcon ? r.ReadGuidAndPicture() : new byte[0];
                }
        }
コード例 #2
0
ファイル: Common.cs プロジェクト: PizzaShift/VBASync
        public TextProps(byte[] b)
        {
            using (var st = new MemoryStream(b))
                using (var r = new FrxReader(st)) {
                    MinorVersion = r.ReadByte();
                    MajorVersion = r.ReadByte();

                    var cbTextProps = r.ReadUInt16();
                    PropMask = new TextPropsPropMask(r.ReadUInt32());

                    // DataBlock
                    var fontNameCcb = PropMask.HasFontName ? r.ReadCcb() : Tuple.Create(0, false);
                    FontEffects        = PropMask.HasFontEffects ? r.ReadUInt32() : 0;
                    FontHeight         = PropMask.HasFontHeight ? r.ReadUInt32() : 0;
                    FontCharSet        = PropMask.HasFontCharSet ? r.ReadByte() : (byte)0;
                    FontPitchAndFamily = PropMask.HasFontPitchAndFamily ? r.ReadByte() : (byte)0;
                    ParagraphAlign     = PropMask.HasParagraphAlign ? r.ReadByte() : (byte)0;
                    FontWeight         = PropMask.HasFontWeight ? r.ReadUInt16() : (ushort)0;

                    // ExtraDataBlock
                    FontName = r.ReadStringFromCcb(fontNameCcb);
                }
        }
コード例 #3
0
ファイル: FormControl.cs プロジェクト: sandboxorg/VBASync
        public OleSiteConcreteControl(byte[] b)
        {
            using (var st = new MemoryStream(b))
                using (var r = new FrxReader(st)) {
                    PropMask = new SitePropMask(r.ReadUInt32());

                    // DataBlock
                    var nameCcb = PropMask.HasName ? r.ReadCcb() : Tuple.Create(0, false);
                    var tagCcb  = PropMask.HasTag ? r.ReadCcb() : Tuple.Create(0, false);
                    Id               = PropMask.HasId ? r.ReadInt32() : 0;
                    HelpContextId    = PropMask.HasHelpContextId ? r.ReadInt32() : 0;
                    BitFlags         = PropMask.HasBitFlags ? r.ReadUInt32() : 0;
                    ObjectStreamSize = PropMask.HasObjectStreamSize ? r.ReadUInt32() : 0;
                    TabIndex         = PropMask.HasTabIndex ? r.ReadInt16() : (short)0;
                    ClsidCacheIndex  = PropMask.HasClsidCacheIndex ? r.ReadInt16() : (short)0;
                    GroupId          = PropMask.HasGroupId ? r.ReadUInt16() : (ushort)0;
                    var controlTipTextCcb = PropMask.HasControlTipText ? r.ReadCcb() : Tuple.Create(0, false);
                    var runtimeLicKeyCcb  = PropMask.HasRuntimeLicKey ? r.ReadCcb() : Tuple.Create(0, false);
                    var controlSourceCcb  = PropMask.HasControlSource ? r.ReadCcb() : Tuple.Create(0, false);
                    var rowSourceCcb      = PropMask.HasRowSource ? r.ReadCcb() : Tuple.Create(0, false);

                    // ExtraDataBlock
                    Name           = r.ReadStringFromCcb(nameCcb);
                    Tag            = r.ReadStringFromCcb(tagCcb);
                    SitePosition   = PropMask.HasPosition ? r.ReadCoords() : Tuple.Create(0, 0);
                    ControlTipText = r.ReadStringFromCcb(controlTipTextCcb);
                    RuntimeLicKey  = r.ReadStringFromCcb(runtimeLicKeyCcb);
                    ControlSource  = r.ReadStringFromCcb(controlSourceCcb);
                    RowSource      = r.ReadStringFromCcb(rowSourceCcb);

                    if (st.Position < st.Length)
                    {
                        throw new ApplicationException("Expected end of OleSiteConcreteControl.");
                    }
                }
        }
コード例 #4
0
ファイル: FormControl.cs プロジェクト: sandboxorg/VBASync
        public FormControl(byte[] b)
        {
            using (var st = new MemoryStream(b))
                using (var r = new FrxReader(st)) {
                    MinorVersion = r.ReadByte();
                    MajorVersion = r.ReadByte();

                    var cbForm = r.ReadUInt16();
                    PropMask = new FormPropMask(r.ReadUInt32());

                    // DataBlock
                    BackColor         = PropMask.HasBackColor ? r.ReadOleColor() : null;
                    ForeColor         = PropMask.HasForeColor ? r.ReadOleColor() : null;
                    NextAvailableId   = PropMask.HasNextAvailableId ? r.ReadUInt32() : 0;
                    BooleanProperties = new FormFlags(PropMask.HasBooleanProperties ? r.ReadUInt32() : 0);
                    BorderStyle       = PropMask.HasBorderStyle ? r.ReadBorderStyle() : BorderStyle.None;
                    MousePointer      = PropMask.HasMousePointer ? r.ReadMousePointer() : MousePointer.Default;
                    ScrollBars        = new FormScrollBarFlags(PropMask.HasScrollBars ? r.ReadByte() : (byte)0);
                    GroupCount        = PropMask.HasGroupCount ? r.ReadInt32() : 0;
                    var captionCcb = PropMask.HasCaption ? r.ReadCcb() : Tuple.Create(0, false); // this seems to be in a different position than indicated in MS's spec?
                    if (PropMask.HasFont)
                    {
                        r.Skip2Bytes();
                    }
                    if (PropMask.HasMouseIcon)
                    {
                        r.Skip2Bytes();
                    }
                    Cycle         = PropMask.HasCycle ? r.ReadCycle() : Cycle.AllForms;
                    SpecialEffect = PropMask.HasSpecialEffect ? r.ReadSpecialEffect() : SpecialEffect.Flat;
                    BorderColor   = PropMask.HasBorderColor ? r.ReadOleColor() : null;
                    if (PropMask.HasPicture)
                    {
                        r.Skip2Bytes();
                    }
                    Zoom             = PropMask.HasZoom ? r.ReadUInt32() : 0;
                    PictureAlignment = PropMask.HasPictureAlignment ? r.ReadPictureAlignment() : PictureAlignment.TopLeft;
                    PictureSizeMode  = PropMask.HasPictureSizeMode ? r.ReadPictureSizeMode() : PictureSizeMode.Clip;
                    ShapeCookie      = PropMask.HasShapeCookie ? r.ReadUInt32() : 0;
                    DrawBuffer       = PropMask.HasDrawBuffer ? r.ReadUInt32() : 0;

                    // ExtraDataBlock
                    DisplayedSize  = PropMask.HasDisplayedSize ? r.ReadCoords() : Tuple.Create(0, 0);
                    LogicalSize    = PropMask.HasLogicalSize ? r.ReadCoords() : Tuple.Create(0, 0);
                    ScrollPosition = PropMask.HasScrollPosition ? r.ReadCoords() : Tuple.Create(0, 0);
                    Caption        = r.ReadStringFromCcb(captionCcb);

                    r.AlignTo(4);
                    if (cbForm != r.BaseStream.Position - 4)
                    {
                        throw new ApplicationException("Error reading 'f' stream in .frx data: expected cbForm size "
                                                       + $"{r.BaseStream.Position - 4}, but actual size was {cbForm}.");
                    }

                    // StreamData
                    MouseIcon = PropMask.HasMouseIcon ? r.ReadGuidAndPicture() : new byte[0];
                    if (PropMask.HasFont)
                    {
                        FontIsStdFont = r.GetFontIsStdFont();
                        if (FontIsStdFont)
                        {
                            FontStdFont = r.ReadStdFont();
                        }
                        else
                        {
                            FontTextProps = r.ReadTextProps();
                        }
                    }
                    Picture = PropMask.HasPicture ? r.ReadGuidAndPicture() : new byte[0];

                    // FormSiteData
                    SiteClassInfos = new List <byte[]>();
                    ushort siteClassInfoCount = 0;
                    if (!PropMask.HasBooleanProperties || BooleanProperties.ClassTablePersisted)
                    {
                        siteClassInfoCount = r.Unaligned.ReadUInt16();
                    }
                    for (var i = 0; i < siteClassInfoCount; i++)
                    {
                        st.Seek(2, SeekOrigin.Current); // skip Version
                        SiteClassInfos.Add(r.Unaligned.ReadBytes(r.Unaligned.ReadUInt16()));
                    }
                    var siteCount      = r.Unaligned.ReadUInt32();
                    var cbSites        = r.Unaligned.ReadUInt32();
                    var sitesStartPos  = r.BaseStream.Position;
                    var depths         = new byte[siteCount];
                    var types          = new byte[siteCount];
                    var siteDepthsLeft = siteCount;
                    while (siteDepthsLeft > 0)
                    {
                        var thisDepth = r.Unaligned.ReadByte();
                        var thisType  = r.Unaligned.ReadByte();
                        var thisCount = (byte)1;
                        if ((thisType & 0x80) == 0x80)
                        {
                            thisCount = (byte)(thisType ^ 0x80);
                            thisType  = r.Unaligned.ReadByte();
                        }
                        for (var i = 0; i < thisCount; i++)
                        {
                            var siteIdx = siteCount - siteDepthsLeft;
                            depths[siteIdx] = thisDepth;
                            types[siteIdx]  = thisType;
                            siteDepthsLeft--;
                        }
                    }
                    var rem = (r.BaseStream.Position - sitesStartPos) % 4;
                    if (rem != 0)
                    {
                        r.BaseStream.Seek(4 - rem, SeekOrigin.Current);       // add ArrayPadding
                    }
                    Sites = new OleSiteConcreteControl[siteCount];
                    for (var i = 0; i < siteCount; i++)
                    {
                        r.BaseStream.Seek(2, SeekOrigin.Current); // ignore Version
                        var cbSite = r.Unaligned.ReadUInt16();
                        Sites[i] = new OleSiteConcreteControl(r.Unaligned.ReadBytes(cbSite));
                    }
                    if (cbSites != r.BaseStream.Position - sitesStartPos)
                    {
                        throw new ApplicationException("Error reading 'f' stream in .frx data: expected cbSites size "
                                                       + $"{r.BaseStream.Position - sitesStartPos} but actual size was {cbSites}.");
                    }

                    Remainder = st.Position < st.Length ? r.Unaligned.ReadBytes((int)(st.Length - st.Position)) : new byte[0];
                }
        }
コード例 #5
0
        public MorphDataControl(byte[] b)
        {
            using (var st = new MemoryStream(b))
                using (var r = new FrxReader(st)) {
                    MinorVersion = r.ReadByte();
                    MajorVersion = r.ReadByte();

                    var cbMorphData = r.ReadUInt16();
                    PropMask = new MorphDataPropMask(r.ReadUInt64());

                    // DataBlock
                    VariousPropertyBits = PropMask.HasVariousPropertyBits ? r.ReadUInt32() : 0;
                    BackColor           = PropMask.HasBackColor ? r.ReadOleColor() : null;
                    ForeColor           = PropMask.HasForeColor ? r.ReadOleColor() : null;
                    MaxLength           = PropMask.HasMaxLength ? r.ReadUInt32() : 0;
                    BorderStyle         = PropMask.HasBorderStyle ? r.ReadBorderStyle() : BorderStyle.None;
                    ScrollBars          = new FormScrollBarFlags(PropMask.HasScrollBars ? r.ReadByte() : (byte)0);
                    DisplayStyle        = PropMask.HasDisplayStyle ? r.ReadByte() : (byte)0;
                    MousePointer        = PropMask.HasMousePointer ? r.ReadMousePointer() : MousePointer.Default;
                    PasswordChar        = PropMask.HasPasswordChar ? r.ReadWChar() : "";
                    ListWidth           = PropMask.HasListWidth ? r.ReadUInt32() : 0;
                    BoundColumn         = PropMask.HasBoundColumn ? r.ReadUInt16() : (ushort)0;
                    TextColumn          = PropMask.HasTextColumn ? r.ReadInt16() : (short)0;
                    ColumnCount         = PropMask.HasColumnCount ? r.ReadInt16() : (short)0;
                    ListRows            = PropMask.HasListRows ? r.ReadUInt16() : (ushort)0;
                    ColumnInfoCount     = PropMask.HasColumnInfoCount ? r.ReadUInt16() : (ushort)0;
                    MatchEntry          = PropMask.HasMatchEntry ? r.ReadByte() : (byte)0;
                    ListStyle           = PropMask.HasListStyle ? r.ReadByte() : (byte)0;
                    ShowDropButtonWhen  = PropMask.HasShowDropDownWhen ? r.ReadByte() : (byte)0;
                    DropButtonStyle     = PropMask.HasDropButtonStyle ? r.ReadByte() : (byte)0;
                    MultiSelect         = PropMask.HasMultiSelect ? r.ReadByte() : (byte)0;
                    var valueCcb   = PropMask.HasValue ? r.ReadCcb() : Tuple.Create(0, false);
                    var captionCcb = PropMask.HasCaption ? r.ReadCcb() : Tuple.Create(0, false);
                    PicturePosition = PropMask.HasPicturePosition ? r.ReadPicturePosition() : PicturePosition.RightTop;
                    BorderColor     = PropMask.HasBorderColor ? r.ReadOleColor() : null;
                    SpecialEffect   = PropMask.HasSpecialEffect ? r.ReadSpecialEffect() : SpecialEffect.Flat;
                    if (PropMask.HasMouseIcon)
                    {
                        r.Skip2Bytes();
                    }
                    if (PropMask.HasPicture)
                    {
                        r.Skip2Bytes();
                    }
                    Accelerator = PropMask.HasAccelerator ? r.ReadWChar() : "";
                    var groupNameCcb = PropMask.HasGroupName ? r.ReadCcb() : Tuple.Create(0, false);

                    // ExtraDataBlock
                    Size      = PropMask.HasSize ? r.ReadCoords() : Tuple.Create(0, 0);
                    Value     = r.ReadStringFromCcb(valueCcb);
                    Caption   = r.ReadStringFromCcb(captionCcb);
                    GroupName = r.ReadStringFromCcb(groupNameCcb);

                    r.AlignTo(4);
                    if (cbMorphData != r.BaseStream.Position - 4)
                    {
                        throw new ApplicationException("Error reading 'o' stream in .frx data: expected cbMorphData size "
                                                       + $"{r.BaseStream.Position - 4}, but actual size was {cbMorphData}.");
                    }

                    // StreamData
                    MouseIcon = PropMask.HasMouseIcon ? r.ReadGuidAndPicture() : new byte[0];
                    Picture   = PropMask.HasPicture ? r.ReadGuidAndPicture() : new byte[0];

                    TextProps = r.ReadTextProps();

                    Remainder = st.Position < st.Length ? r.Unaligned.ReadBytes((int)(st.Length - st.Position)) : new byte[0];
                }
        }