Beispiel #1
0
        public void TestSetGetMargins()
        {
            // instantiate the following class so it'll Get picked up by
            // the XmlBean process and Added to the jar file. it's required
            // for the following XWPFTable methods.
            CT_TblCellMar ctm = new CT_TblCellMar();

            Assert.IsNotNull(ctm);
            // create a table
            XWPFDocument doc     = new XWPFDocument();
            CT_Tbl       ctTable = new CT_Tbl();
            XWPFTable    table   = new XWPFTable(ctTable, doc);

            // Set margins
            table.SetCellMargins(50, 50, 250, 450);
            // Get margin components
            int t = table.GetCellMarginTop();

            Assert.AreEqual(50, t);
            int l = table.GetCellMarginLeft();

            Assert.AreEqual(50, l);
            int b = table.GetCellMarginBottom();

            Assert.AreEqual(250, b);
            int r = table.GetCellMarginRight();

            Assert.AreEqual(450, r);
        }
Beispiel #2
0
        public int GetCellMarginRight()
        {
            int           result     = 0;
            CT_TblCellMar tblCellMar = this.GetTrPr().tblCellMar;

            if (tblCellMar != null)
            {
                CT_TblWidth right = tblCellMar.right;
                if (right != null)
                {
                    int.TryParse(right.w, out result);
                }
            }
            return(result);
        }
Beispiel #3
0
        public int GetCellMarginBottom()
        {
            int           result     = 0;
            CT_TblCellMar tblCellMar = this.GetTrPr().tblCellMar;

            if (tblCellMar != null)
            {
                CT_TblWidth bottom = tblCellMar.bottom;
                if (bottom != null)
                {
                    int.TryParse(bottom.w, out result);
                }
            }
            return(result);
        }
Beispiel #4
0
        public int GetCellMarginLeft()
        {
            int           result     = 0;
            CT_TblCellMar tblCellMar = this.GetTrPr().tblCellMar;

            if (tblCellMar != null)
            {
                CT_TblWidth left = tblCellMar.left;
                if (left != null)
                {
                    int.TryParse(left.w, out result);
                }
            }
            return(result);
        }
Beispiel #5
0
        public int GetCellMarginTop()
        {
            int           result     = 0;
            CT_TblCellMar tblCellMar = this.GetTrPr().tblCellMar;

            if (tblCellMar != null)
            {
                CT_TblWidth top = tblCellMar.top;
                if (top != null)
                {
                    int.TryParse(top.w, out result);
                }
            }
            return(result);
        }
Beispiel #6
0
        public int GetCellMarginRight()
        {
            int           margin = 0;
            CT_TblPr      tblPr  = GetTrPr();
            CT_TblCellMar tcm    = tblPr.tblCellMar;

            if (tcm != null)
            {
                CT_TblWidth tw = tcm.right;
                if (tw != null)
                {
                    int.TryParse(tw.w, out margin);
                }
            }
            return(margin);
        }
Beispiel #7
0
        public void SetCellMargins(int top, int left, int bottom, int right)
        {
            CT_TblPr      trPr         = this.GetTrPr();
            CT_TblCellMar ctTblCellMar = trPr.IsSetTblCellMar() ? trPr.tblCellMar : trPr.AddNewTblCellMar();
            CT_TblWidth   ctTblWidth1  = ctTblCellMar.IsSetLeft() ? ctTblCellMar.left : ctTblCellMar.AddNewLeft();

            ctTblWidth1.type = ST_TblWidth.dxa;
            ctTblWidth1.w    = left.ToString();
            CT_TblWidth ctTblWidth2 = ctTblCellMar.IsSetTop() ? ctTblCellMar.top : ctTblCellMar.AddNewTop();

            ctTblWidth2.type = ST_TblWidth.dxa;
            ctTblWidth2.w    = top.ToString();
            CT_TblWidth ctTblWidth3 = ctTblCellMar.IsSetBottom() ? ctTblCellMar.bottom : ctTblCellMar.AddNewBottom();

            ctTblWidth3.type = ST_TblWidth.dxa;
            ctTblWidth3.w    = bottom.ToString();
            CT_TblWidth ctTblWidth4 = ctTblCellMar.IsSetRight() ? ctTblCellMar.right : ctTblCellMar.AddNewRight();

            ctTblWidth4.type = ST_TblWidth.dxa;
            ctTblWidth4.w    = right.ToString();
        }
Beispiel #8
0
        public void SetCellMargins(int top, int left, int bottom, int right)
        {
            CT_TblPr      tblPr = GetTrPr();
            CT_TblCellMar tcm   = tblPr.IsSetTblCellMar() ? tblPr.tblCellMar : tblPr.AddNewTblCellMar();

            CT_TblWidth tw = tcm.IsSetLeft() ? tcm.left : tcm.AddNewLeft();

            tw.type = (ST_TblWidth.dxa);
            tw.w    = left.ToString();

            tw      = tcm.IsSetTop() ? tcm.top : tcm.AddNewTop();
            tw.type = (ST_TblWidth.dxa);
            tw.w    = top.ToString();

            tw      = tcm.IsSetBottom() ? tcm.bottom : tcm.AddNewBottom();
            tw.type = (ST_TblWidth.dxa);
            tw.w    = bottom.ToString();

            tw      = tcm.IsSetRight() ? tcm.right : tcm.AddNewRight();
            tw.type = (ST_TblWidth.dxa);
            tw.w    = right.ToString();
        }
Beispiel #9
0
 public void TestSetGetMargins()
 {
     // instantiate the following class so it'll Get picked up by
     // the XmlBean process and Added to the jar file. it's required
     // for the following XWPFTable methods.
     CT_TblCellMar ctm = new CT_TblCellMar();
     Assert.IsNotNull(ctm);
     // create a table
     XWPFDocument doc = new XWPFDocument();
     CT_Tbl ctTable = new CT_Tbl();
     XWPFTable table = new XWPFTable(ctTable, doc);
     // Set margins
     table.SetCellMargins(50, 50, 250, 450);
     // Get margin components
     int t = table.CellMarginTop;
     Assert.AreEqual(50, t);
     int l = table.CellMarginLeft;
     Assert.AreEqual(50, l);
     int b = table.CellMarginBottom;
     Assert.AreEqual(250, b);
     int r = table.CellMarginRight;
     Assert.AreEqual(450, r);
 }