Beispiel #1
0
        /**
         * Gets a copy of the font used in a particular formatting Run.
         *
         * @param index     the index of the formatting run
         * @return  A copy of the  font used or null if no formatting is applied to the specified text Run.
         */
        public IFont GetFontOfFormattingRun(int index)
        {
            if (st.sizeOfRArray() == 0 || index >= st.sizeOfRArray())
            {
                return(null);
            }

            CT_RElt r = st.GetRArray(index);

            if (r.rPr != null)
            {
                XSSFFont fnt = new XSSFFont(ToCTFont(r.rPr));
                fnt.SetThemesTable(GetThemesTable());
                return(fnt);
            }
            return(null);
        }
Beispiel #2
0
        /**
         * Return a copy of the font in use at a particular index.
         *
         * @param index         The index.
         * @return              A copy of the  font that's currently being applied at that
         *                      index or null if no font is being applied or the
         *                      index is out of range.
         */
        public XSSFFont GetFontAtIndex(int index)
        {
            if (st.sizeOfRArray() == 0)
            {
                return(null);
            }

            int pos = 0;

            for (int i = 0; i < st.sizeOfRArray(); i++)
            {
                CT_RElt r = st.GetRArray(i);
                if (index >= pos && index < pos + r.t.Length)
                {
                    XSSFFont fnt = new XSSFFont(ToCTFont(r.rPr));
                    fnt.SetThemesTable(GetThemesTable());
                    return(fnt);
                }

                pos += r.t.Length;
            }
            return(null);
        }