Esempio n. 1
0
        /**
         * Get the styles which are related to the parameter style and their relatives
         * this method can be used to copy all styles from one document to another document
         * @param style
         * @return a list of all styles which were used by this method
         */
        public List <XWPFStyle> GetUsedStyleList(XWPFStyle style)
        {
            List <XWPFStyle> usedStyleList = new List <XWPFStyle>();

            usedStyleList.Add(style);
            return(GetUsedStyleList(style, usedStyleList));
        }
Esempio n. 2
0
        /**
         * Get the styles which are related to parameter style
         * @param style
         * @return all Styles of the parameterList
         */
        private List <XWPFStyle> GetUsedStyleList(XWPFStyle style, List <XWPFStyle> usedStyleList)
        {
            String    basisStyleID = style.GetBasisStyleID();
            XWPFStyle basisStyle   = GetStyle(basisStyleID);

            if ((basisStyle != null) && (!usedStyleList.Contains(basisStyle)))
            {
                usedStyleList.Add(basisStyle);
                GetUsedStyleList(basisStyle, usedStyleList);
            }
            String    linkStyleID = style.GetLinkStyleID();
            XWPFStyle linkStyle   = GetStyle(linkStyleID);

            if ((linkStyle != null) && (!usedStyleList.Contains(linkStyle)))
            {
                usedStyleList.Add(linkStyle);
                GetUsedStyleList(linkStyle, usedStyleList);
            }

            String    nextStyleID = style.GetNextStyleID();
            XWPFStyle nextStyle   = GetStyle(nextStyleID);

            if ((nextStyle != null) && (!usedStyleList.Contains(nextStyle)))
            {
                usedStyleList.Add(linkStyle);
                GetUsedStyleList(linkStyle, usedStyleList);
            }
            return(usedStyleList);
        }
Esempio n. 3
0
        /**
         * Compares the names of the Styles
         * @param compStyle
         */
        public bool HasSameName(XWPFStyle compStyle)
        {
            CT_Style ctCompStyle = compStyle.GetCTStyle();
            String   name        = ctCompStyle.name.val;

            return(name.Equals(ctStyle.name.val));
        }
Esempio n. 4
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());
        }
Esempio n. 5
0
        public void TestType()
        {
            CT_Style  ctStyle = new CT_Style();
            XWPFStyle style   = new XWPFStyle(ctStyle);

            style.StyleType = ST_StyleType.paragraph;
            Assert.AreEqual(ST_StyleType.paragraph, style.StyleType);
        }
Esempio n. 6
0
 public XWPFStyle GetStyleWithSameName(XWPFStyle style)
 {
   foreach (XWPFStyle xwpfStyle in this.listStyle)
   {
     if (xwpfStyle.HasSameName(style))
       return xwpfStyle;
   }
   return (XWPFStyle) null;
 }
Esempio n. 7
0
 /**
  * Get the style with the same name
  * if this style is not existing, return null
  */
 public XWPFStyle GetStyleWithSameName(XWPFStyle style)
 {
     foreach (XWPFStyle ownStyle in listStyle)
     {
         if (ownStyle.HasSameName(style))
         {
             return(ownStyle);
         }
     }
     return(null);
 }
Esempio n. 8
0
        public void TestAddStylesToDocument()
        {
            XWPFDocument docOut = new XWPFDocument();
            XWPFStyles   styles = docOut.CreateStyles();

            String   strStyleName = "headline1";
            CT_Style ctStyle      = new CT_Style();

            ctStyle.styleId = (strStyleName);
            XWPFStyle s = new XWPFStyle(ctStyle);

            styles.AddStyle(s);

            XWPFDocument docIn = XWPFTestDataSamples.WriteOutAndReadBack(docOut);

            styles = docIn.GetStyles();
            Assert.IsTrue(styles.StyleExist(strStyleName));
        }
Esempio n. 9
0
        public void TestGetUsedStyles()
        {
            XWPFDocument     sampleDoc         = XWPFTestDataSamples.OpenSampleDocument("Styles.docx");
            List <XWPFStyle> testUsedStyleList = new List <XWPFStyle>();
            XWPFStyles       styles            = sampleDoc.GetStyles();
            XWPFStyle        style             = styles.GetStyle("berschrift1");

            testUsedStyleList.Add(style);
            testUsedStyleList.Add(styles.GetStyle("Standard"));
            testUsedStyleList.Add(styles.GetStyle("berschrift1Zchn"));
            testUsedStyleList.Add(styles.GetStyle("Absatz-Standardschriftart"));
            style.HasSameName(style);

            List <XWPFStyle> usedStyleList = styles.GetUsedStyleList(style);

            //Assert.AreEqual(usedStyleList, testUsedStyleList);
            Assert.AreEqual(usedStyleList.Count, testUsedStyleList.Count);
            for (int i = 0; i < usedStyleList.Count; i++)
            {
                Assert.AreEqual(usedStyleList[i], testUsedStyleList[i]);
            }
        }
Esempio n. 10
0
 private List<XWPFStyle> GetUsedStyleList(XWPFStyle style, List<XWPFStyle> usedStyleList)
 {
   XWPFStyle style1 = this.GetStyle(style.GetBasisStyleID());
   if (style1 != null && !usedStyleList.Contains(style1))
   {
     usedStyleList.Add(style1);
     this.GetUsedStyleList(style1, usedStyleList);
   }
   XWPFStyle style2 = this.GetStyle(style.GetLinkStyleID());
   if (style2 != null && !usedStyleList.Contains(style2))
   {
     usedStyleList.Add(style2);
     this.GetUsedStyleList(style2, usedStyleList);
   }
   XWPFStyle style3 = this.GetStyle(style.GetNextStyleID());
   if (style3 != null && !usedStyleList.Contains(style3))
   {
     usedStyleList.Add(style2);
     this.GetUsedStyleList(style2, usedStyleList);
   }
   return usedStyleList;
 }
Esempio n. 11
0
        /** 
         * Get the styles which are related to parameter style
         * @param style
         * @return all Styles of the parameterList
         */
        private List<XWPFStyle> GetUsedStyleList(XWPFStyle style, List<XWPFStyle> usedStyleList)
        {
            String basisStyleID = style.GetBasisStyleID();
            XWPFStyle basisStyle = GetStyle(basisStyleID);
            if ((basisStyle != null) && (!usedStyleList.Contains(basisStyle)))
            {
                usedStyleList.Add(basisStyle);
                GetUsedStyleList(basisStyle, usedStyleList);
            }
            String linkStyleID = style.GetLinkStyleID();
            XWPFStyle linkStyle = GetStyle(linkStyleID);
            if ((linkStyle != null) && (!usedStyleList.Contains(linkStyle)))
            {
                usedStyleList.Add(linkStyle);
                GetUsedStyleList(linkStyle, usedStyleList);
            }

            String nextStyleID = style.GetNextStyleID();
            XWPFStyle nextStyle = GetStyle(nextStyleID);
            if ((nextStyle != null) && (!usedStyleList.Contains(nextStyle)))
            {
                usedStyleList.Add(linkStyle);
                GetUsedStyleList(linkStyle, usedStyleList);
            }
            return usedStyleList;
        }
Esempio n. 12
0
 /**
  * Compares the names of the Styles 
  * @param compStyle
  */
 public bool HasSameName(XWPFStyle compStyle)
 {
     CT_Style ctCompStyle = compStyle.GetCTStyle();
     String name = ctCompStyle.name.val;
     return name.Equals(ctStyle.name.val);
 }
Esempio n. 13
0
 public void AddStyle(XWPFStyle style)
 {
   this.listStyle.Add(style);
   this.ctStyles.AddNewStyle();
   this.ctStyles.SetStyleArray(this.ctStyles.GetStyleList().Count - 1, style.GetCTStyle());
 }
Esempio n. 14
0
 public List<XWPFStyle> GetUsedStyleList(XWPFStyle style)
 {
   return this.GetUsedStyleList(style, new List<XWPFStyle>() { style });
 }
Esempio n. 15
0
 public bool HasSameName(XWPFStyle compStyle)
 {
     return(compStyle.GetCTStyle().name.val.Equals(this.ctStyle.name.val));
 }
Esempio n. 16
0
        /**
         * Get the style with the same name
         * if this style is not existing, return null
         */
        public XWPFStyle GetStyleWithSameName(XWPFStyle style)
        {
            foreach (XWPFStyle ownStyle in listStyle)
            {
                if (ownStyle.HasSameName(style))
                {
                    return ownStyle;
                }
            }
            return null;

        }
Esempio n. 17
0
        public void TestType()
        {
            CT_Style ctStyle = new CT_Style();
            XWPFStyle style = new XWPFStyle(ctStyle);

			style.StyleType = ST_StyleType.paragraph;
            Assert.AreEqual(ST_StyleType.paragraph, style.StyleType);
        }
Esempio n. 18
0
 /**
  * Get the styles which are related to the parameter style and their relatives
  * this method can be used to copy all styles from one document to another document 
  * @param style
  * @return a list of all styles which were used by this method 
  */
 public List<XWPFStyle> GetUsedStyleList(XWPFStyle style)
 {
     List<XWPFStyle> usedStyleList = new List<XWPFStyle>();
     usedStyleList.Add(style);
     return GetUsedStyleList(style, usedStyleList);
 }
Esempio n. 19
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());
 }
Esempio n. 20
-1
        public void TestAddStylesToDocument()
        {
            XWPFDocument docOut = new XWPFDocument();
            XWPFStyles styles = docOut.CreateStyles();

            String strStyleName = "headline1";
            CT_Style ctStyle = new CT_Style();

            ctStyle.styleId = (strStyleName);
            XWPFStyle s = new XWPFStyle(ctStyle);
            styles.AddStyle(s);

            XWPFDocument docIn = XWPFTestDataSamples.WriteOutAndReadBack(docOut);

            styles = docIn.GetStyles();
            Assert.IsTrue(styles.StyleExist(strStyleName));
        }