示例#1
0
        internal void TranslateStyleIdsToStyles(ref SLStyle style)
        {
            int index;

            if (style.NumberFormatId != null)
            {
                index = (int)style.NumberFormatId.Value;
                style.nfFormatCode = new SLNumberingFormat();
                style.nfFormatCode.NumberFormatId = (uint)index;

                if (dictStyleNumberingFormat.ContainsKey(index))
                {
                    style.nfFormatCode.FromHash(dictStyleNumberingFormat[index]);
                }
                else if (dictBuiltInNumberingFormat.ContainsKey(index))
                {
                    style.nfFormatCode.FormatCode = dictBuiltInNumberingFormat[index];
                }
                else
                {
                    // don't know the format code, but *something* has to be written.
                    //style.nfFormatCode.FormatCode = string.Format("Built-in format code {0}", index);
                    style.nfFormatCode.FormatCode = SLConstants.NumberFormatGeneral;
                }
                style.HasNumberingFormat = true;
            }
            else
            {
                style.RemoveFormatCode();
            }

            if (style.FontId != null)
            {
                style.HasFont = true;
                index = (int)style.FontId.Value;
                if (index >= 0 && index < listStyleFont.Count)
                {
                    style.fontReal = new SLFont(SimpleTheme.MajorLatinFont, SimpleTheme.MinorLatinFont, SimpleTheme.listThemeColors, SimpleTheme.listIndexedColors);
                    style.fontReal.FromHash(listStyleFont[index]);
                }
                else
                {
                    style.RemoveFont();
                }
            }
            else
            {
                style.RemoveFont();
            }

            if (style.FillId != null)
            {
                style.HasFill = true;
                index = (int)style.FillId.Value;
                if (index >= 0 && index < listStyleFill.Count)
                {
                    style.fillReal = new SLFill(SimpleTheme.listThemeColors, SimpleTheme.listIndexedColors);
                    style.fillReal.FromHash(listStyleFill[index]);
                }
                else
                {
                    style.RemoveFill();
                }
            }
            else
            {
                style.RemoveFill();
            }

            if (style.BorderId != null)
            {
                style.HasBorder = true;
                index = (int)style.BorderId.Value;
                if (index >= 0 && index < listStyleBorder.Count)
                {
                    style.borderReal = new SLBorder(SimpleTheme.listThemeColors, SimpleTheme.listIndexedColors);
                    style.borderReal.FromHash(listStyleBorder[index]);
                }
                else
                {
                    style.RemoveBorder();
                }
            }
            else
            {
                style.RemoveBorder();
            }

            style.Sync();
        }