Example #1
0
        /**
         * Whether the bold property shall be applied to all non-complex script
         * characters in the contents of this run.when displayed in a document
         * <p/>
         * <p/>
         * This formatting property is a toggle property, which specifies that its
         * behavior differs between its use within a style defInition and its use as
         * direct formatting. When used as part of a style defInition, Setting this
         * property shall toggle the current state of that property as specified up
         * to this point in the hierarchy (i.e. applied to not applied, and vice
         * versa). Setting it to <code>false</code> (or an equivalent) shall
         * result in the current Setting remaining unChanged. However, when used as
         * direct formatting, Setting this property to true or false shall Set the
         * absolute state of the resulting property.
         * </p>
         * <p/>
         * If this element is not present, the default value is to leave the
         * formatting applied at previous level in the style hierarchy. If this
         * element is never applied in the style hierarchy, then bold shall not be
         * applied to non-complex script characters.
         * </p>
         *
         * @param value <code>true</code> if the italic property is applied to
         *              this run
         */
        public void SetItalic(bool value)
        {
            CT_RPr   pr     = run.IsSetRPr() ? run.rPr : run.AddNewRPr();
            CT_OnOff italic = pr.IsSetI() ? pr.i : pr.AddNewI();

            italic.val = (value ? ST_OnOff.True : ST_OnOff.False);
        }
Example #2
0
        public TOC(CT_SdtBlock block)
        {
            this.block = block;
            CT_SdtPr ctSdtPr = block.AddNewSdtPr();

            ctSdtPr.AddNewId().val = "4844945";
            ctSdtPr.AddNewDocPartObj().AddNewDocPartGallery().val = "Table of contents";
            CT_RPr   ctRpr   = block.AddNewSdtEndPr().AddNewRPr();
            CT_Fonts ctFonts = ctRpr.AddNewRFonts();

            ctFonts.asciiTheme    = ST_Theme.minorHAnsi;
            ctFonts.eastAsiaTheme = ST_Theme.minorHAnsi;
            ctFonts.hAnsiTheme    = ST_Theme.minorHAnsi;
            ctFonts.cstheme       = ST_Theme.minorBidi;
            ctRpr.AddNewB().val     = ST_OnOff.off;
            ctRpr.AddNewBCs().val   = ST_OnOff.off;
            ctRpr.AddNewColor().val = "auto";
            ctRpr.AddNewSz().val    = 24UL;
            ctRpr.AddNewSzCs().val  = 24UL;
            CT_P ctP = block.AddNewSdtContent().AddNewP();

            byte[] bytes = Encoding.Unicode.GetBytes("00EF7E24");
            ctP.rsidR        = bytes;
            ctP.rsidRDefault = bytes;
            ctP.AddNewPPr().AddNewPStyle().val = "TOCHeading";
            ctP.AddNewR().AddNewT().Value      = "Table of Contents";
        }
Example #3
0
 public void SetSpellingLanguage(string strSpellingLanguage)
 {
   CT_DocDefaults ctDocDefaults = (CT_DocDefaults) null;
   CT_RPr ctRpr = (CT_RPr) null;
   CT_Language ctLanguage = (CT_Language) null;
   if (this.ctStyles.IsSetDocDefaults())
   {
     ctDocDefaults = this.ctStyles.docDefaults;
     if (ctDocDefaults.IsSetRPrDefault())
     {
       CT_RPrDefault rPrDefault = ctDocDefaults.rPrDefault;
       if (rPrDefault.IsSetRPr())
       {
         ctRpr = rPrDefault.rPr;
         if (ctRpr.IsSetLang())
           ctLanguage = ctRpr.lang;
       }
     }
   }
   if (ctDocDefaults == null)
     ctDocDefaults = this.ctStyles.AddNewDocDefaults();
   if (ctRpr == null)
     ctRpr = ctDocDefaults.AddNewRPrDefault().AddNewRPr();
   if (ctLanguage == null)
     ctLanguage = ctRpr.AddNewLang();
   ctLanguage.val = strSpellingLanguage;
   ctLanguage.bidi = strSpellingLanguage;
 }
Example #4
0
        public void SetStrike(bool value)
        {
            CT_RPr   pr     = run.IsSetRPr() ? run.rPr : run.AddNewRPr();
            CT_OnOff strike = pr.IsSetStrike() ? pr.strike : pr.AddNewStrike();

            strike.val = value;
        }
Example #5
0
        public TOC(CT_SdtBlock block)
        {
            this.block = block;
            CT_SdtPr         sdtPr = block.AddNewSdtPr();
            CT_DecimalNumber id    = sdtPr.AddNewId();

            id.val = ("4844945");
            sdtPr.AddNewDocPartObj().AddNewDocPartGallery().val = ("Table of contents");
            CT_SdtEndPr sdtEndPr = block.AddNewSdtEndPr();
            CT_RPr      rPr      = sdtEndPr.AddNewRPr();
            CT_Fonts    fonts    = rPr.AddNewRFonts();

            fonts.asciiTheme    = (ST_Theme.minorHAnsi);
            fonts.eastAsiaTheme = (ST_Theme.minorHAnsi);
            fonts.hAnsiTheme    = (ST_Theme.minorHAnsi);
            fonts.cstheme       = (ST_Theme.minorBidi);
            rPr.AddNewB().val          = false;
            rPr.AddNewBCs().val        = false;
            rPr.AddNewColor().val      = ("auto");
            rPr.AddNewSz().val         = 24;
            rPr.AddNewSzCs().val       = 24;
            CT_SdtContentBlock content = block.AddNewSdtContent();
            CT_P p = content.AddNewP();

            byte[] b = Encoding.Unicode.GetBytes("00EF7E24");
            p.rsidR        = b;
            p.rsidRDefault = b;
            p.AddNewPPr().AddNewPStyle().val = ("TOCHeading");
            p.AddNewR().AddNewT().Value      = ("Table of Contents");
        }
Example #6
0
        /**
         * Gets the font family for the specified font char range.
         * If fcr is null, the font char range "ascii" is used
         *
         * @param fcr the font char range, defaults to "ansi"
         * @return  a string representing the font famil
         */
        public String GetFontFamily(FontCharRange fcr)
        {
            CT_RPr pr = run.rPr;

            if (pr == null || !pr.IsSetRFonts())
            {
                return(null);
            }

            CT_Fonts fonts = pr.rFonts;

            switch (fcr == FontCharRange.None ? FontCharRange.Ascii : fcr)
            {
            default:
            case FontCharRange.Ascii:
                return(fonts.ascii);

            case FontCharRange.CS:
                return(fonts.cs);

            case FontCharRange.EastAsia:
                return(fonts.eastAsia);

            case FontCharRange.HAnsi:
                return(fonts.hAnsi);
            }
        }
Example #7
0
 public void SetEastAsia(string strEastAsia)
 {
   CT_DocDefaults ctDocDefaults = (CT_DocDefaults) null;
   CT_RPr ctRpr = (CT_RPr) null;
   CT_Language ctLanguage = (CT_Language) null;
   if (this.ctStyles.IsSetDocDefaults())
   {
     ctDocDefaults = this.ctStyles.docDefaults;
     if (ctDocDefaults.IsSetRPrDefault())
     {
       CT_RPrDefault rPrDefault = ctDocDefaults.rPrDefault;
       if (rPrDefault.IsSetRPr())
       {
         ctRpr = rPrDefault.rPr;
         if (ctRpr.IsSetLang())
           ctLanguage = ctRpr.lang;
       }
     }
   }
   if (ctDocDefaults == null)
     ctDocDefaults = this.ctStyles.AddNewDocDefaults();
   if (ctRpr == null)
     ctRpr = ctDocDefaults.AddNewRPrDefault().AddNewRPr();
   if (ctLanguage == null)
     ctLanguage = ctRpr.AddNewLang();
   ctLanguage.eastAsia = strEastAsia;
 }
Example #8
0
        /**
         * Whether the bold property shall be applied to all non-complex script
         * characters in the contents of this run.when displayed in a document.
         * <p>
         * This formatting property is a toggle property, which specifies that its
         * behavior differs between its use within a style defInition and its use as
         * direct formatting. When used as part of a style defInition, Setting this
         * property shall toggle the current state of that property as specified up
         * to this point in the hierarchy (i.e. applied to not applied, and vice
         * versa). Setting it to <code>false</code> (or an equivalent) shall
         * result in the current Setting remaining unChanged. However, when used as
         * direct formatting, Setting this property to true or false shall Set the
         * absolute state of the resulting property.
         * </p>
         * <p>
         * If this element is not present, the default value is to leave the
         * formatting applied at previous level in the style hierarchy. If this
         * element is never applied in the style hierarchy, then bold shall not be
         * applied to non-complex script characters.
         * </p>
         *
         * @param value <code>true</code> if the bold property is applied to
         *              this run
         */
        public void SetBold(bool value)
        {
            CT_RPr   pr   = run.IsSetRPr() ? run.rPr : run.AddNewRPr();
            CT_OnOff bold = pr.IsSetB() ? pr.b : pr.AddNewB();

            bold.val = value;
        }
Example #9
0
        /**
         * Set text color.
         * @param rgbStr - the desired color, in the hex form "RRGGBB".
         */
        public void SetColor(String rgbStr)
        {
            CT_RPr pr = run.IsSetRPr() ? run.rPr : run.AddNewRPr();

            NPOI.OpenXmlFormats.Wordprocessing.CT_Color color = pr.IsSetColor() ? pr.color : pr.AddNewColor();
            color.val = (rgbStr);
        }
Example #10
0
        /**
         * Set text color.
         * @param rgbStr - the desired color, in the hex form "RRGGBB".
         */
        public void SetColor(String rgbStr)
        {
            CT_RPr pr = GetRunProperties(true);

            NPOI.OpenXmlFormats.Wordprocessing.CT_Color color = pr.IsSetColor() ? pr.color : pr.AddNewColor();
            color.val = (rgbStr);
        }
Example #11
0
        /**
         * Sets the default font on ctStyles DocDefaults parameter
         * @param fonts
         */
        public void SetDefaultFonts(CT_Fonts fonts)
        {
            CT_DocDefaults docDefaults = null;
            CT_RPr         RunProps    = null;

            // Just making sure we use the members that have already been defined
            if (ctStyles.IsSetDocDefaults())
            {
                docDefaults = ctStyles.docDefaults;
                if (docDefaults.IsSetRPrDefault())
                {
                    CT_RPrDefault RPrDefault = docDefaults.rPrDefault;
                    if (RPrDefault.IsSetRPr())
                    {
                        RunProps = RPrDefault.rPr;
                    }
                }
            }

            if (docDefaults == null)
            {
                docDefaults = ctStyles.AddNewDocDefaults();
            }
            if (RunProps == null)
            {
                RunProps = docDefaults.AddNewRPrDefault().AddNewRPr();
            }

            RunProps.rFonts = (fonts);
        }
Example #12
0
        /**
         * Specifies the fonts which shall be used to display the text contents of
         * this run. Specifies a font which shall be used to format all characters
         * in the ASCII range (0 - 127) within the parent run
         *
         * @param fontFamily
         */
        public void SetFontFamily(String fontFamily)
        {
            CT_RPr   pr    = run.IsSetRPr() ? run.rPr : run.AddNewRPr();
            CT_Fonts fonts = pr.IsSetRFonts() ? pr.rFonts : pr.AddNewRFonts();

            fonts.ascii = (fontFamily);
        }
Example #13
0
        /**
         * Specifies the font size which shall be applied to all non complex script
         * characters in the contents of this run.when displayed.
         * <p/>
         * If this element is not present, the default value is to leave the value
         * applied at previous level in the style hierarchy. If this element is
         * never applied in the style hierarchy, then any appropriate font size may
         * be used for non complex script characters.
         * </p>
         *
         * @param size
         */
        public void SetFontSize(int size)
        {
            CT_RPr        pr     = run.IsSetRPr() ? run.rPr : run.AddNewRPr();
            CT_HpsMeasure ctSize = pr.IsSetSz() ? pr.sz : pr.AddNewSz();

            ctSize.val = (ulong)size * 2;
        }
Example #14
0
        /**
         * Specifies the alignment which shall be applied to the contents of this
         * run.in relation to the default appearance of the run.s text. This allows
         * the text to be repositioned as subscript or superscript without altering
         * the font size of the run.properties.
         * <p/>
         * If this element is not present, the default value is to leave the
         * formatting applied at previous level in the style hierarchy. If this
         * element is never applied in the style hierarchy, then the text shall not
         * be subscript or superscript relative to the default baseline location for
         * the contents of this run.
         * </p>
         *
         * @param valign
         * @see VerticalAlign
         */
        public void SetSubscript(VerticalAlign valign)
        {
            CT_RPr pr = run.IsSetRPr() ? run.rPr : run.AddNewRPr();
            CT_VerticalAlignRun ctValign = pr.IsSetVertAlign() ? pr.vertAlign : pr.AddNewVertAlign();

            ctValign.val = EnumConverter.ValueOf <ST_VerticalAlignRun, VerticalAlign>(valign);
        }
Example #15
0
        /**
         * Specifies the fonts which shall be used to display the text contents of
         * this run. Specifies a font which shall be used to format all characters
         * in the ASCII range (0 - 127) within the parent run
         *
         * @return a string representing the font family
         */
        public String GetFontFamily()
        {
            CT_RPr pr = run.rPr;

            return((pr != null && pr.IsSetRFonts()) ? pr.rFonts.ascii
                    : null);
        }
Example #16
0
        /**
         * Specifies that the contents of this run.shall be displayed with a single
         * horizontal line through the center of the line.
         * <p/>
         * This formatting property is a toggle property, which specifies that its
         * behavior differs between its use within a style defInition and its use as
         * direct formatting. When used as part of a style defInition, Setting this
         * property shall toggle the current state of that property as specified up
         * to this point in the hierarchy (i.e. applied to not applied, and vice
         * versa). Setting it to false (or an equivalent) shall result in the
         * current Setting remaining unChanged. However, when used as direct
         * formatting, Setting this property to true or false shall Set the absolute
         * state of the resulting property.
         * </p>
         * <p/>
         * If this element is not present, the default value is to leave the
         * formatting applied at previous level in the style hierarchy. If this
         * element is never applied in the style hierarchy, then strikethrough shall
         * not be applied to the contents of this run.
         * </p>
         *
         * @param value <code>true</code> if the strike property is applied to
         *              this run
         */
        public void SetStrike(bool value)
        {
            CT_RPr   pr     = run.IsSetRPr() ? run.rPr : run.AddNewRPr();
            CT_OnOff strike = pr.IsSetStrike() ? pr.strike : pr.AddNewStrike();

            strike.val = (value ? ST_OnOff.True : ST_OnOff.False);
        }
Example #17
0
        /**
         * Specifies the alignment which shall be applied to the contents of this
         * run.in relation to the default appearance of the run.s text.
         * This allows the text to be repositioned as subscript or superscript without
         * altering the font size of the run.properties.
         *
         * @return VerticalAlign
         * @see VerticalAlign all possible value that could be Applyed to this run
         */
        public VerticalAlign GetSubscript()
        {
            CT_RPr pr = run.rPr;

            return((pr != null && pr.IsSetVertAlign()) ?
                   EnumConverter.ValueOf <VerticalAlign, ST_VerticalAlignRun>(pr.vertAlign.val) : VerticalAlign.BASELINE);
        }
Example #18
0
        /**
         * Specifies that the contents of this run.should be displayed along with an
         * underline appearing directly below the character heigh
         * If this element is not present, the default value is to leave the
         * formatting applied at previous level in the style hierarchy. If this
         * element is never applied in the style hierarchy, then an underline shall
         * not be applied to the contents of this run.
         *
         * @param value -
         *              underline type
         * @see UnderlinePatterns : all possible patterns that could be applied
         */
        public void SetUnderline(UnderlinePatterns value)
        {
            CT_RPr       pr        = run.IsSetRPr() ? run.rPr : run.AddNewRPr();
            CT_Underline underline = (pr.u == null) ? pr.AddNewU() : pr.u;

            underline.val = EnumConverter.ValueOf <ST_Underline, UnderlinePatterns>(value);
        }
Example #19
0
        /**
         * Whether the bold property shall be applied to all non-complex script
         * characters in the contents of this run.when displayed in a document.
         * <p>
         * This formatting property is a toggle property, which specifies that its
         * behavior differs between its use within a style defInition and its use as
         * direct formatting. When used as part of a style defInition, Setting this
         * property shall toggle the current state of that property as specified up
         * to this point in the hierarchy (i.e. applied to not applied, and vice
         * versa). Setting it to <code>false</code> (or an equivalent) shall
         * result in the current Setting remaining unChanged. However, when used as
         * direct formatting, Setting this property to true or false shall Set the
         * absolute state of the resulting property.
         * </p>
         * <p>
         * If this element is not present, the default value is to leave the
         * formatting applied at previous level in the style hierarchy. If this
         * element is never applied in the style hierarchy, then bold shall not be
         * applied to non-complex script characters.
         * </p>
         *
         * @param value <code>true</code> if the bold property is applied to
         *              this run
         */
        public void SetBold(bool value)
        {
            CT_RPr   pr   = run.IsSetRPr() ? run.rPr : run.AddNewRPr();
            CT_OnOff bold = pr.IsSetB() ? pr.b : pr.AddNewB();

            bold.val = (value ? ST_OnOff.True : ST_OnOff.False);
        }
Example #20
0
        /**
         * This element specifies the amount by which text shall be raised or
         * lowered for this run.in relation to the default baseline of the
         * surrounding non-positioned text. This allows the text to be repositioned
         * without altering the font size of the contents.
         *
         * If the val attribute is positive, then the parent run.shall be raised
         * above the baseline of the surrounding text by the specified number of
         * half-points. If the val attribute is negative, then the parent run.shall
         * be lowered below the baseline of the surrounding text by the specified
         * number of half-points.
         *         *
         * If this element is not present, the default value is to leave the
         * formatting applied at previous level in the style hierarchy. If this
         * element is never applied in the style hierarchy, then the text shall not
         * be raised or lowered relative to the default baseline location for the
         * contents of this run.
         */
        public void SetTextPosition(int val)
        {
            CT_RPr pr = run.IsSetRPr() ? run.rPr : run.AddNewRPr();
            CT_SignedHpsMeasure position = pr.IsSetPosition() ? pr.position : pr.AddNewPosition();

            position.val = (val.ToString());
        }
Example #21
0
        /**
         * This element specifies the amount by which text shall be raised or
         * lowered for this run.in relation to the default baseline of the
         * surrounding non-positioned text. This allows the text to be repositioned
         * without altering the font size of the contents.
         *
         * @return a big integer representing the amount of text shall be "moved"
         */
        public int GetTextPosition()
        {
            CT_RPr pr = run.rPr;

            return((pr != null && pr.IsSetPosition()) ? int.Parse(pr.position.val)
                    : -1);
        }
Example #22
0
        /**
         * Sets the default font on ctStyles DocDefaults parameter
         * TODO Replace this with specific Setters for each type, possibly
         *  on XWPFDefaultRunStyle
         */
        public void SetDefaultFonts(CT_Fonts fonts)
        {
            EnsureDocDefaults();

            CT_RPr RunProps = defaultRunStyle.GetRPr();

            RunProps.rFonts = (/*setter*/ fonts);
        }
Example #23
0
 public CT_RPr AddNewRPr()
 {
     if (this.rPrField == null)
     {
         this.rPrField = new CT_RPr();
     }
     return(this.rPrField);
 }
 private void setRTL(XWPFRun run)
 {
     if (configDocx.rightToLeft)
     {
         CT_RPr rpr = run.GetCTR().AddNewRPr();
         rpr.rtl     = new CT_OnOff();
         rpr.rtl.val = configDocx.rightToLeft;
     }
 }
Example #25
0
        /// <summary>
        /// 设置字体大小
        /// </summary>
        /// <param name="run"></param>
        /// <param name="sizeType"></param>
        public static void SetFontSize(this XWPFRun run, FontSizeType sizeType)
        {
            ulong         fontSize = GetFontSize(sizeType);
            CT_R          r        = run.GetCTR();
            CT_RPr        rpr      = r.IsSetRPr() ? r.rPr : r.AddNewRPr();
            CT_HpsMeasure ctSize   = rpr.IsSetSz() ? rpr.sz : rpr.AddNewSz();

            ctSize.val = fontSize;
        }
Example #26
0
        /// <summary>
        /// 设置颜色
        /// </summary>
        /// <param name="run"></param>
        /// <param name="colorType"></param>
        public static void SetRunColor(this XWPFRun run, ColorType colorType)
        {
            Tuple <string, string> temp = GetColor(colorType);
            CT_R     r     = run.GetCTR();
            CT_RPr   rpr   = r.IsSetRPr() ? r.rPr : r.AddNewRPr();
            CT_Color color = rpr.IsSetColor() ? rpr.color : rpr.AddNewColor();

            color.val = temp.Item1;
        }
Example #27
0
        /**
         * Whether the italic property should be applied to all non-complex script
         * characters in the contents of this run.when displayed in a document.
         *
         * @return <code>true</code> if the italic property is applied
         */
        public bool IsItalic()
        {
            CT_RPr pr = run.rPr;

            if (pr == null || !pr.IsSetI())
            {
                return(false);
            }
            return(IsCTOnOff(pr.i));
        }
Example #28
0
        /**
         * Whether the bold property shall be applied to all non-complex script
         * characters in the contents of this run.when displayed in a document
         *
         * @return <code>true</code> if the bold property is applied
         */
        public bool IsBold()
        {
            CT_RPr pr = run.rPr;

            if (pr == null || !pr.IsSetB())
            {
                return(false);
            }
            return(IsCTOnOff(pr.b));
        }
Example #29
0
        /**
         * Specifies that the contents of this run.shall be displayed with a single
         * horizontal line through the center of the line.
         *
         * @return <code>true</code> if the strike property is applied
         */
        public bool IsStrike()
        {
            CT_RPr pr = run.rPr;

            if (pr == null || !pr.IsSetStrike())
            {
                return(false);
            }
            return(IsCTOnOff(pr.strike));
        }
Example #30
0
        public int GetTextPosition()
        {
            CT_RPr rPr = this.run.rPr;

            if (rPr == null || !rPr.IsSetPosition())
            {
                return(-1);
            }
            return(int.Parse(rPr.position.val));
        }
Example #31
0
 public XWPFDefaultRunStyle(CT_RPr rpr)
 {
     this.rpr = rpr;
 }
Example #32
0
 /// <summary>
 /// CT_R class constructor
 /// </summary>
 public CT_R()
 {
     this.itemsElementNameField = new ItemsChoiceType6[0];
     this.itemsField = new object[0];
     this.rPr1Field = new CT_RPr();
     this.rPrField = new CT_RPR();
 }
Example #33
0
 public CT_Lvl()
 {
     this.rPrField = new CT_RPr();
     this.pPrField = new CT_PPr();
     this.lvlJcField = new CT_Jc();
     //this.legacyField = new CT_LvlLegacy();
     //this.lvlPicBulletIdField = new CT_DecimalNumber();
     this.lvlTextField = new CT_LevelText();
     //this.suffField = new CT_LevelSuffix();
     //this.isLglField = new CT_OnOff();
     //this.pStyleField = new CT_String();
     //this.lvlRestartField = new CT_DecimalNumber();
     this.numFmtField = new CT_NumFmt();
     this.startField = new CT_DecimalNumber();
 }
Example #34
0
 public CT_RPr AddNewRPr()
 {
     this.rPrField = new CT_RPr();
     return this.rPrField;
 }
Example #35
0
 public CT_RPrDefault()
 {
     this.rPrField = new CT_RPr();
 }
Example #36
0
 public CT_Style()
 {
     this.tblStylePrField = new List<CT_TblStylePr>();
     this.tcPrField = new CT_TcPr();
     this.trPrField = new CT_TrPr();
     this.tblPrField = new CT_TblPrBase();
     this.rPrField = new CT_RPr();
     this.pPrField = new CT_PPr();
     this.rsidField = new CT_LongHexNumber();
     this.personalReplyField = new CT_OnOff();
     this.personalComposeField = new CT_OnOff();
     this.personalField = new CT_OnOff();
     this.lockedField = new CT_OnOff();
     this.qFormatField = new CT_OnOff();
     this.unhideWhenUsedField = new CT_OnOff();
     this.semiHiddenField = new CT_OnOff();
     this.uiPriorityField = new CT_DecimalNumber();
     this.hiddenField = new CT_OnOff();
     this.autoRedefineField = new CT_OnOff();
     this.linkField = new CT_String();
     this.nextField = new CT_String();
     this.basedOnField = new CT_String();
     this.aliasesField = new CT_String();
     this.nameField = new CT_String();
 }