Example #1
0
        /**
         * Creates a CharacterProperties object from a chpx stored in the
         * StyleDescription at the index istd in the StyleDescription array. The
         * CharacterProperties object is placed in the StyleDescription at istd after
         * its been Created. Not every StyleDescription will contain a chpx. In these
         * cases this function does nothing.
         *
         * @param istd The index of the StyleDescription to create the
         *        CharacterProperties object from.
         */
        private void CreateChp(int istd)
        {
            StyleDescription    sd  = _styleDescriptions[istd];
            CharacterProperties chp = sd.GetCHP();

            byte[] chpx      = sd.GetCHPX();
            int    baseIndex = sd.GetBaseStyle();

            if (baseIndex == istd)
            {
                // Oh dear, this isn't allowed...
                // The word file seems to be corrupted
                // Switch to using the nil style so that
                //  there's a chance we can read it
                baseIndex = NIL_STYLE;
            }

            // Build and decompress the Chp if required
            if (chp == null && chpx != null)
            {
                CharacterProperties parentCHP = new CharacterProperties();
                if (baseIndex != NIL_STYLE)
                {
                    parentCHP = _styleDescriptions[baseIndex].GetCHP();
                    if (parentCHP == null)
                    {
                        CreateChp(baseIndex);
                        parentCHP = _styleDescriptions[baseIndex].GetCHP();
                    }
                }

                chp = CharacterSprmUncompressor.UncompressCHP(parentCHP, chpx, 0);
                sd.SetCHP(chp);
            }
        }
Example #2
0
        public CharacterProperties GetCharacterProperties(StyleSheet ss, short istd)
        {
            if (ss == null)
            {
                // TODO Fix up for Word 6/95
                return(new CharacterProperties());
            }

            CharacterProperties baseStyle = ss.GetCharacterStyle(istd);

            if (baseStyle == null)
            {
                baseStyle = new CharacterProperties();
            }

            CharacterProperties props =
                CharacterSprmUncompressor.UncompressCHP(baseStyle, GetGrpprl(), 0);

            return(props);
        }