Пример #1
0
        /**
         * add a style to the document
         * @param style
         * @throws IOException
         */
        public void AddStyle(XWPFStyle style)
        {
            listStyle.Add(style);
            ctStyles.AddNewStyle();
            int pos = (ctStyles.GetStyleList().Count) - 1;

            ctStyles.SetStyleArray(pos, style.GetCTStyle());
        }
Пример #2
0
 /**
  * Sets the ctStyles
  * @param styles
  */
 public void SetStyles(CT_Styles styles)
 {
     ctStyles = styles;
     // Build up all the style objects
     foreach (CT_Style style in ctStyles.GetStyleList())
     {
         listStyle.Add(new XWPFStyle(style, this));
     }
 }
Пример #3
0
        /**
         * Read document
         */

        internal override void OnDocumentRead()
        {
            StylesDocument stylesDoc;

            try
            {
                Stream is1 = GetPackagePart().GetInputStream();
                stylesDoc    = StylesDocument.Parse(is1);
                ctStyles     = stylesDoc.Styles;
                latentStyles = new XWPFLatentStyles(ctStyles.latentStyles, this);
            }
            catch (XmlException e)
            {
                throw new POIXMLException("Unable to read styles", e);
            }
            // Build up all the style objects
            foreach (CT_Style style in ctStyles.GetStyleList())
            {
                listStyle.Add(new XWPFStyle(style, this));
            }
        }
Пример #4
0
        /**
         * Sets the ctStyles
         * @param styles
         */
        public void SetStyles(CT_Styles styles)
        {
            ctStyles = styles;
            // Build up all the style objects
            foreach (CT_Style style in ctStyles.GetStyleList())
            {
                listStyle.Add(new XWPFStyle(style, this));
            }

            if (ctStyles.IsSetDocDefaults())
            {
                CT_DocDefaults docDefaults = ctStyles.docDefaults;
                if (docDefaults.IsSetRPrDefault() && docDefaults.rPrDefault.IsSetRPr())
                {
                    defaultRunStyle = new XWPFDefaultRunStyle(
                        docDefaults.rPrDefault.rPr);
                }
                if (docDefaults.IsSetPPrDefault() && docDefaults.pPrDefault.IsSetPPr())
                {
                    defaultParaStyle = new XWPFDefaultParagraphStyle(
                        docDefaults.pPrDefault.pPr);
                }
            }
        }