コード例 #1
0
        private CT_Rst buildCTRst(string text, SortedDictionary <int, CT_RPrElt> formats)
        {
            if (text.Length != this.GetLastKey(formats.Keys))
            {
                throw new ArgumentException("Text length was " + (object)text.Length + " but the last format index was " + (object)this.GetLastKey(formats.Keys));
            }
            CT_Rst ctRst      = new CT_Rst();
            int    startIndex = 0;

            SortedDictionary <int, CT_RPrElt> .KeyCollection.Enumerator enumerator = formats.Keys.GetEnumerator();
            while (enumerator.MoveNext())
            {
                int     current = enumerator.Current;
                CT_RElt ctRelt  = ctRst.AddNewR();
                string  str     = text.Substring(startIndex, current - startIndex);
                ctRelt.t = str;
                XSSFRichTextString.PreserveSpaces(ctRelt.t);
                CT_RPrElt format = formats[current];
                if (format != null)
                {
                    ctRelt.rPr = format;
                }
                startIndex = current;
            }
            return(ctRst);
        }
コード例 #2
0
        public void Append(string text, XSSFFont font)
        {
            if (this.st.sizeOfRArray() == 0 && this.st.IsSetT())
            {
                CT_RElt ctRelt = this.st.AddNewR();
                ctRelt.t = this.st.t;
                XSSFRichTextString.PreserveSpaces(ctRelt.t);
                this.st.unsetT();
            }
            CT_RElt ctRelt1 = this.st.AddNewR();

            ctRelt1.t = text;
            XSSFRichTextString.PreserveSpaces(ctRelt1.t);
            CT_RPrElt pr = ctRelt1.AddNewRPr();

            if (font == null)
            {
                return;
            }
            this.SetRunAttributes(font.GetCTFont(), pr);
        }
コード例 #3
0
 public XSSFRichTextString(string str)
 {
     this.st   = new CT_Rst();
     this.st.t = str;
     XSSFRichTextString.PreserveSpaces(this.st.t);
 }