Esempio n. 1
0
        /// <summary>
        /// Searches all OptionEntry in the ShapeContainer and puts them into a list.
        /// </summary>
        /// <param name="shapeContainer">The ShapeContainer</param>
        /// <returns>A List containing all OptionEntry of the ShapeContainer</returns>
        public List <ShapeOptions.OptionEntry> ExtractOptions()
        {
            List <ShapeOptions.OptionEntry> ret = new List <ShapeOptions.OptionEntry>();

            //build the list of all option entries of this shape
            foreach (Record rec in this.Children)
            {
                if (rec.GetType() == typeof(ShapeOptions))
                {
                    ShapeOptions opt = (ShapeOptions)rec;
                    ret.AddRange(opt.Options);
                }
            }

            return(ret);
        }
Esempio n. 2
0
        public static string getRGBColorFromOfficeArtCOLORREF(uint value, RegularContainer slide, DIaLOGIKa.b2xtranslator.OfficeDrawing.ShapeOptions so, ref string SchemeType)
        {
            byte[] bytes         = BitConverter.GetBytes(value);
            bool   fPaletteIndex = (bytes[3] & 1) != 0;
            bool   fPaletteRGB   = (bytes[3] & (1 << 1)) != 0;
            bool   fSystemRGB    = (bytes[3] & (1 << 2)) != 0;
            bool   fSchemeIndex  = (bytes[3] & (1 << 3)) != 0;
            bool   fSysIndex     = (bytes[3] & (1 << 4)) != 0;

            List <ColorSchemeAtom> colors       = slide.AllChildrenWithType <ColorSchemeAtom>();
            ColorSchemeAtom        MasterScheme = null;

            foreach (ColorSchemeAtom color in colors)
            {
                if (color.Instance == 1)
                {
                    MasterScheme = color;
                }
            }

            if (fSysIndex)
            {
                UInt16 val    = BitConverter.ToUInt16(bytes, 0);
                string result = "";
                switch (val & 0x00ff)
                {
                case 0xF0:     //shape fill color
                    if (so.OptionsByID.ContainsKey(DIaLOGIKa.b2xtranslator.OfficeDrawing.ShapeOptions.PropertyId.fillColor))
                    {
                        result = getRGBColorFromOfficeArtCOLORREF(so.OptionsByID[DIaLOGIKa.b2xtranslator.OfficeDrawing.ShapeOptions.PropertyId.fillColor].op, slide, so);
                    }
                    else
                    {
                        result = new RGBColor(MasterScheme.Fills, RGBColor.ByteOrder.RedFirst).SixDigitHexCode;      //TODO: find out which color to use in this case
                    }
                    break;

                case 0xF1:     //shape line color if it is a line else shape fill color TODO!!
                    if (so.FirstAncestorWithType <OfficeDrawing.ShapeContainer>().FirstChildWithType <OfficeDrawing.Shape>().Instance == 1)
                    {
                        if (so.OptionsByID.ContainsKey(DIaLOGIKa.b2xtranslator.OfficeDrawing.ShapeOptions.PropertyId.fillColor))
                        {
                            result = getRGBColorFromOfficeArtCOLORREF(so.OptionsByID[DIaLOGIKa.b2xtranslator.OfficeDrawing.ShapeOptions.PropertyId.fillColor].op, slide, so);
                        }
                        else
                        {
                            result = new RGBColor(MasterScheme.Fills, RGBColor.ByteOrder.RedFirst).SixDigitHexCode;      //TODO: find out which color to use in this case
                        }
                    }
                    else
                    {
                        if (so.OptionsByID.ContainsKey(DIaLOGIKa.b2xtranslator.OfficeDrawing.ShapeOptions.PropertyId.lineColor))
                        {
                            result = getRGBColorFromOfficeArtCOLORREF(so.OptionsByID[DIaLOGIKa.b2xtranslator.OfficeDrawing.ShapeOptions.PropertyId.lineColor].op, slide, so);
                        }
                        else
                        {
                            result = new RGBColor(MasterScheme.TextAndLines, RGBColor.ByteOrder.RedFirst).SixDigitHexCode;     //TODO: find out which color to use in this case
                        }
                    }
                    break;

                case 0xF2:     //shape line color
                    if (so.OptionsByID.ContainsKey(DIaLOGIKa.b2xtranslator.OfficeDrawing.ShapeOptions.PropertyId.lineColor))
                    {
                        result = getRGBColorFromOfficeArtCOLORREF(so.OptionsByID[DIaLOGIKa.b2xtranslator.OfficeDrawing.ShapeOptions.PropertyId.lineColor].op, slide, so);
                    }
                    else
                    {
                        result = new RGBColor(MasterScheme.TextAndLines, RGBColor.ByteOrder.RedFirst).SixDigitHexCode;     //TODO: find out which color to use in this case
                    }
                    break;

                case 0xF3:     //shape shadow color
                    result = getRGBColorFromOfficeArtCOLORREF(so.OptionsByID[DIaLOGIKa.b2xtranslator.OfficeDrawing.ShapeOptions.PropertyId.shadowColor].op, slide, so);
                    break;

                case 0xF4:     //current or last used color
                case 0xF5:     //shape fill background color
                    result = getRGBColorFromOfficeArtCOLORREF(so.OptionsByID[DIaLOGIKa.b2xtranslator.OfficeDrawing.ShapeOptions.PropertyId.fillBackColor].op, slide, so);
                    break;

                case 0xF6:     //shape line background color
                    result = getRGBColorFromOfficeArtCOLORREF(so.OptionsByID[DIaLOGIKa.b2xtranslator.OfficeDrawing.ShapeOptions.PropertyId.lineBackColor].op, slide, so);
                    break;

                case 0xF7:     //shape fill color if shape contains a fill else line color
                    result = getRGBColorFromOfficeArtCOLORREF(so.OptionsByID[DIaLOGIKa.b2xtranslator.OfficeDrawing.ShapeOptions.PropertyId.fillColor].op, slide, so);
                    break;

                case 0xFF:     //undefined
                    return("");
                }

                if (result.Length == 0)
                {
                    return("");
                }

                int red   = int.Parse(result.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
                int green = int.Parse(result.Substring(2, 2), System.Globalization.NumberStyles.HexNumber);
                int blue  = int.Parse(result.Substring(4, 2), System.Globalization.NumberStyles.HexNumber);
                int v     = (int)bytes[2];
                int res;
                return(result);
                //switch (val & 0xff00)
                //{
                //    case 0x100:
                //        if (blue == 0xff) return result;
                //        if (blue == 0x00) return "000000";

                //        res = int.Parse(result, System.Globalization.NumberStyles.HexNumber);
                //        if (!so.OptionsByID.ContainsKey(DIaLOGIKa.b2xtranslator.OfficeDrawing.ShapeOptions.PropertyId.ShadowStyleBooleanProperties))
                //        res -= v; //this is wrong for shadow17
                //        if (res < 0) res = 0;
                //        return res.ToString("X").PadLeft(6, '0');
                //    case 0x200:
                //        if (blue == 0xff) return result;
                //        if (blue == 0x00) return "FFFFFF";

                //        res = int.Parse(result, System.Globalization.NumberStyles.HexNumber);
                //        res += v;
                //        return res.ToString("X").PadLeft(6, '0');
                //    case 0x300:
                //        red += v;
                //        green += v;
                //        blue += v;
                //        if (red > 0xff) red = 0xff;
                //        if (green > 0xff) green = 0xff;
                //        if (blue > 0xff) blue = 0xff;
                //        return red.ToString("X").PadLeft(2, '0') + green.ToString("X").PadLeft(2, '0') + blue.ToString("X").PadLeft(2, '0');
                //    case 0x400:
                //        red -= v;
                //        green -= v;
                //        blue -= v;
                //        if (red < 0) red = 0x0;
                //        if (green < 0) green = 0x0;
                //        if (blue < 0) blue = 0x0;
                //        return red.ToString("X").PadLeft(2, '0') + green.ToString("X").PadLeft(2, '0') + blue.ToString("X").PadLeft(2, '0');
                //    case 0x500:
                //        red = v - red;
                //        green = v - green;
                //        blue = v - blue;
                //        if (red < 0) red = 0x0;
                //        if (green < 0) green = 0x0;
                //        if (blue < 0) blue = 0x0;
                //        return red.ToString("X").PadLeft(2, '0') + green.ToString("X").PadLeft(2, '0') + blue.ToString("X").PadLeft(2, '0');
                //    default:
                //        break;
                //}
            }

            if (fSchemeIndex)
            {
                //red is the index to the color scheme
                //List<ColorSchemeAtom> colors = slide.AllChildrenWithType<ColorSchemeAtom>();
                //ColorSchemeAtom MasterScheme = null;
                //foreach (ColorSchemeAtom color in colors)
                //{
                //    if (color.Instance == 1) MasterScheme = color;
                //}

                switch (bytes[0])
                {
                case 0x00:     //background
                    SchemeType = "bg1";
                    return(new RGBColor(MasterScheme.Background, RGBColor.ByteOrder.RedFirst).SixDigitHexCode);

                case 0x01:     //text
                    SchemeType = "tx1";
                    return(new RGBColor(MasterScheme.TextAndLines, RGBColor.ByteOrder.RedFirst).SixDigitHexCode);

                case 0x02:     //shadow
                    return(new RGBColor(MasterScheme.Shadows, RGBColor.ByteOrder.RedFirst).SixDigitHexCode);

                case 0x03:     //title
                    return(new RGBColor(MasterScheme.TitleText, RGBColor.ByteOrder.RedFirst).SixDigitHexCode);

                case 0x04:     //fill
                    SchemeType = "accent1";
                    return(new RGBColor(MasterScheme.Fills, RGBColor.ByteOrder.RedFirst).SixDigitHexCode);

                case 0x05:     //accent1
                    SchemeType = "accent2";
                    return(new RGBColor(MasterScheme.Accent, RGBColor.ByteOrder.RedFirst).SixDigitHexCode);

                case 0x06:     //accent2
                    SchemeType = "hlink";
                    return(new RGBColor(MasterScheme.AccentAndHyperlink, RGBColor.ByteOrder.RedFirst).SixDigitHexCode);

                case 0x07:     //accent3
                    return(new RGBColor(MasterScheme.AccentAndFollowedHyperlink, RGBColor.ByteOrder.RedFirst).SixDigitHexCode);

                case 0xFE:     //sRGB
                    return(bytes[0].ToString("X").PadLeft(2, '0') + bytes[1].ToString("X").PadLeft(2, '0') + bytes[3].ToString("X").PadLeft(2, '0'));

                case 0xFF:     //undefined
                    break;
                }
            }
            return(bytes[0].ToString("X").PadLeft(2, '0') + bytes[1].ToString("X").PadLeft(2, '0') + bytes[2].ToString("X").PadLeft(2, '0'));
        }
Esempio n. 3
0
        public static string getRGBColorFromOfficeArtCOLORREF(uint value, RegularContainer slide, DIaLOGIKa.b2xtranslator.OfficeDrawing.ShapeOptions so)
        {
            string dummy = "";

            return(getRGBColorFromOfficeArtCOLORREF(value, slide, so, ref dummy));
        }