Ejemplo n.º 1
0
 internal static CT_Picture Prototype()
 {
     if (XSSFPicture.prototype == null)
     {
         CT_Picture               ctPicture          = new CT_Picture();
         CT_PictureNonVisual      pictureNonVisual   = ctPicture.AddNewNvPicPr();
         CT_NonVisualDrawingProps visualDrawingProps = pictureNonVisual.AddNewCNvPr();
         visualDrawingProps.id    = 1U;
         visualDrawingProps.name  = "Picture 1";
         visualDrawingProps.descr = "Picture";
         pictureNonVisual.AddNewCNvPicPr().AddNewPicLocks().noChangeAspect = true;
         CT_BlipFillProperties blipFillProperties = ctPicture.AddNewBlipFill();
         blipFillProperties.AddNewBlip().embed    = "";
         blipFillProperties.AddNewStretch().AddNewFillRect();
         CT_ShapeProperties ctShapeProperties = ctPicture.AddNewSpPr();
         CT_Transform2D     ctTransform2D     = ctShapeProperties.AddNewXfrm();
         CT_PositiveSize2D  ctPositiveSize2D  = ctTransform2D.AddNewExt();
         ctPositiveSize2D.cx = 0L;
         ctPositiveSize2D.cy = 0L;
         CT_Point2D ctPoint2D = ctTransform2D.AddNewOff();
         ctPoint2D.x = 0L;
         ctPoint2D.y = 0L;
         CT_PresetGeometry2D presetGeometry2D = ctShapeProperties.AddNewPrstGeom();
         presetGeometry2D.prst = ST_ShapeType.rect;
         presetGeometry2D.AddNewAvLst();
         XSSFPicture.prototype = ctPicture;
     }
     return(XSSFPicture.prototype);
 }
Ejemplo n.º 2
0
        public XSSFPicture CreatePicture(XSSFClientAnchor anchor, int pictureIndex)
        {
            PackageRelationship rel       = this.GetDrawing().AddPictureReference(pictureIndex);
            CT_Picture          ctPicture = this.ctGroup.AddNewPic();

            ctPicture.Set(XSSFPicture.Prototype());
            XSSFPicture xssfPicture = new XSSFPicture(this.GetDrawing(), ctPicture);

            xssfPicture.parent = this;
            xssfPicture.anchor = (XSSFAnchor)anchor;
            xssfPicture.SetPictureReference(rel);
            return(xssfPicture);
        }
Ejemplo n.º 3
0
        public IPicture CreatePicture(XSSFClientAnchor anchor, int pictureIndex)
        {
            PackageRelationship rel = this.AddPictureReference(pictureIndex);
            long       num          = this.newShapeId();
            CT_Picture ctPicture    = this.CreateTwoCellAnchor((IClientAnchor)anchor).AddNewPic();

            ctPicture.Set(XSSFPicture.Prototype());
            ctPicture.nvPicPr.cNvPr.id = (uint)num;
            XSSFPicture xssfPicture = new XSSFPicture(this, ctPicture);

            xssfPicture.anchor = (XSSFAnchor)anchor;
            xssfPicture.SetPictureReference(rel);
            return((IPicture)xssfPicture);
        }
Ejemplo n.º 4
0
        /**
         * Creates a picture.
         *
         * @param anchor       the client anchor describes how this picture is attached to the sheet.
         * @param pictureIndex the index of the picture in the workbook collection of pictures,
         *                     {@link XSSFWorkbook#getAllPictures()} .
         * @return the newly Created picture shape.
         */
        public XSSFPicture CreatePicture(XSSFClientAnchor anchor, int pictureIndex)
        {
            PackageRelationship rel = GetDrawing().AddPictureReference(pictureIndex);

            CT_Picture ctShape = ctGroup.AddNewPic();

            ctShape.Set(XSSFPicture.Prototype());

            XSSFPicture shape = new XSSFPicture(GetDrawing(), ctShape);

            shape.parent = this;
            shape.anchor = anchor;
            shape.SetPictureReference(rel);
            return(shape);
        }
Ejemplo n.º 5
0
        /**
         * Creates a picture.
         *
         * @param anchor    the client anchor describes how this picture is attached to the sheet.
         * @param pictureIndex the index of the picture in the workbook collection of pictures,
         *   {@link NPOI.xssf.usermodel.XSSFWorkbook#getAllPictures()} .
         *
         * @return  the newly Created picture shape.
         */
        public IPicture CreatePicture(XSSFClientAnchor anchor, int pictureIndex)
        {
            PackageRelationship rel = AddPictureReference(pictureIndex);

            long             shapeId  = newShapeId();
            CT_TwoCellAnchor ctAnchor = CreateTwoCellAnchor(anchor);
            CT_Picture       ctShape  = ctAnchor.AddNewPic();

            ctShape.Set(XSSFPicture.Prototype());

            ctShape.nvPicPr.cNvPr.id = (uint)shapeId;

            XSSFPicture shape = new XSSFPicture(this, ctShape);

            shape.anchor = anchor;
            shape.SetPictureReference(rel);
            return(shape);
        }
Ejemplo n.º 6
0
        internal static CT_Picture Prototype()
        {
            CT_Picture          pic  = new CT_Picture();
            CT_PictureNonVisual nvpr = pic.AddNewNvPicPr();

            NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_NonVisualDrawingProps nvProps = nvpr.AddNewCNvPr();
            nvProps.id    = (1);
            nvProps.name  = ("Picture 1");
            nvProps.descr = ("Picture");
            NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_NonVisualPictureProperties nvPicProps = nvpr.AddNewCNvPicPr();
            nvPicProps.AddNewPicLocks().noChangeAspect = true;



            NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_BlipFillProperties blip = pic.AddNewBlipFill();
            blip.AddNewBlip().embed = "";
            blip.AddNewStretch().AddNewFillRect();

            NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_ShapeProperties sppr = pic.AddNewSpPr();
            CT_Transform2D    t2d = sppr.AddNewXfrm();
            CT_PositiveSize2D ext = t2d.AddNewExt();

            //should be original picture width and height expressed in EMUs
            ext.cx = (0);
            ext.cy = (0);

            CT_Point2D off = t2d.AddNewOff();

            off.x = (0);
            off.y = (0);

            CT_PresetGeometry2D prstGeom = sppr.AddNewPrstGeom();

            prstGeom.prst = (ST_ShapeType.rect);
            prstGeom.AddNewAvLst();

            prototype = pic;
            return(prototype);
        }
Ejemplo n.º 7
0
 public XWPFPicture(CT_Picture ctPic, XWPFRun Run)
 {
     this.run    = Run;
     this.ctPic  = ctPic;
     description = ctPic.nvPicPr.cNvPr.descr;
 }
Ejemplo n.º 8
0
        /*
         * This is the default Watermark paragraph; the only variable is the text message
         * TODO: manage all the other variables
         */
        private XWPFParagraph GetWatermarkParagraph(String text, int idx)
        {
            CT_P p = new CT_P();

            byte[] rsidr        = doc.Document.body.GetPArray(0).rsidR;
            byte[] rsidrdefault = doc.Document.body.GetPArray(0).rsidRDefault;
            p.rsidP        = (rsidr);
            p.rsidRDefault = (rsidrdefault);
            CT_PPr pPr = p.AddNewPPr();

            pPr.AddNewPStyle().val = ("Header");
            // start watermark paragraph
            Npoi.Core.OpenXmlFormats.Wordprocessing.CT_R r = p.AddNewR();
            CT_RPr rPr = r.AddNewRPr();

            rPr.AddNewNoProof();
            CT_Picture pict = r.AddNewPict();

            CT_Group     group     = new CT_Group();
            CT_Shapetype shapetype = group.AddNewShapetype();

            shapetype.id        = ("_x0000_t136");
            shapetype.coordsize = ("1600,21600");
            shapetype.spt       = (136);
            shapetype.adj       = ("10800");
            shapetype.path2     = ("m@7,0l@8,0m@5,21600l@6,21600e");
            CT_Formulas formulas = shapetype.AddNewFormulas();

            formulas.AddNewF().eqn = ("sum #0 0 10800");
            formulas.AddNewF().eqn = ("prod #0 2 1");
            formulas.AddNewF().eqn = ("sum 21600 0 @1");
            formulas.AddNewF().eqn = ("sum 0 0 @2");
            formulas.AddNewF().eqn = ("sum 21600 0 @3");
            formulas.AddNewF().eqn = ("if @0 @3 0");
            formulas.AddNewF().eqn = ("if @0 21600 @1");
            formulas.AddNewF().eqn = ("if @0 0 @2");
            formulas.AddNewF().eqn = ("if @0 @4 21600");
            formulas.AddNewF().eqn = ("mid @5 @6");
            formulas.AddNewF().eqn = ("mid @8 @5");
            formulas.AddNewF().eqn = ("mid @7 @8");
            formulas.AddNewF().eqn = ("mid @6 @7");
            formulas.AddNewF().eqn = ("sum @6 0 @5");
            CT_Path path           = shapetype.AddNewPath();

            path.textpathok    = (Npoi.Core.OpenXmlFormats.Vml.ST_TrueFalse.t);
            path.connecttype   = (ST_ConnectType.custom);
            path.connectlocs   = ("@9,0;@10,10800;@11,21600;@12,10800");
            path.connectangles = ("270,180,90,0");
            CT_TextPath shapeTypeTextPath = shapetype.AddNewTextpath();

            shapeTypeTextPath.on       = (Npoi.Core.OpenXmlFormats.Vml.ST_TrueFalse.t);
            shapeTypeTextPath.fitshape = (Npoi.Core.OpenXmlFormats.Vml.ST_TrueFalse.t);
            CT_Handles handles = shapetype.AddNewHandles();
            CT_H       h       = handles.AddNewH();

            h.position = ("#0,bottomRight");
            h.xrange   = ("6629,14971");
            Npoi.Core.OpenXmlFormats.Vml.Office.CT_Lock lock1 = shapetype.AddNewLock();
            lock1.ext = (ST_Ext.edit);
            CT_Shape shape = group.AddNewShape();

            shape.id         = ("PowerPlusWaterMarkObject" + idx);
            shape.spid       = ("_x0000_s102" + (4 + idx));
            shape.type       = ("#_x0000_t136");
            shape.style      = ("position:absolute;margin-left:0;margin-top:0;width:415pt;height:207.5pt;z-index:-251654144;mso-wrap-edited:f;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin");
            shape.wrapcoords = ("616 5068 390 16297 39 16921 -39 17155 7265 17545 7186 17467 -39 17467 18904 17467 10507 17467 8710 17545 18904 17077 18787 16843 18358 16297 18279 12554 19178 12476 20701 11774 20779 11228 21131 10059 21248 8811 21248 7563 20975 6316 20935 5380 19490 5146 14022 5068 2616 5068");
            shape.fillcolor  = ("black");
            shape.stroked    = (Npoi.Core.OpenXmlFormats.Vml.ST_TrueFalse.@false);
            CT_TextPath shapeTextPath = shape.AddNewTextpath();

            shapeTextPath.style   = ("font-family:"Cambria";font-size:1pt");
            shapeTextPath.@string = (text);
            pict.Set(group);
            // end watermark paragraph
            return(new XWPFParagraph(p, doc));
        }
Ejemplo n.º 9
0
 public XSSFPicture(XSSFDrawing drawing, CT_Picture ctPicture)
 {
     this.drawing   = drawing;
     this.ctPicture = ctPicture;
 }
Ejemplo n.º 10
0
        /**
         * Returns a prototype that is used to construct new shapes
         *
         * @return a prototype that is used to construct new shapes
         */

        public XSSFPicture(XSSFDrawing drawing, XElement ctPicture)
        {
            this.drawing   = drawing;
            this.ctPicture = CT_Picture.Parse(ctPicture, POIXMLDocumentPart.NamespaceManager);
        }
 protected override void InitElements()
 {
     _pic = new CT_Picture();
 }
Ejemplo n.º 12
0
        private XWPFParagraph GetWatermarkParagraph(string text, int idx)
        {
            CT_P prgrph = new CT_P();

            byte[] rsidR        = this.doc.Document.body.GetPArray(0).rsidR;
            byte[] rsidRdefault = this.doc.Document.body.GetPArray(0).rsidRDefault;
            prgrph.rsidP        = rsidR;
            prgrph.rsidRDefault = rsidRdefault;
            prgrph.AddNewPPr().AddNewPStyle().val       = "Header";
            NPOI.OpenXmlFormats.Wordprocessing.CT_R ctR = prgrph.AddNewR();
            ctR.AddNewRPr().AddNewNoProof();
            CT_Picture   ctPicture   = ctR.AddNewPict();
            CT_Group     ctGroup     = new CT_Group();
            CT_Shapetype ctShapetype = ctGroup.AddNewShapetype();

            ctShapetype.id        = "_x0000_t136";
            ctShapetype.coordsize = "1600,21600";
            ctShapetype.spt       = 136f;
            ctShapetype.adj       = "10800";
            ctShapetype.path2     = "m@7,0l@8,0m@5,21600l@6,21600e";
            CT_Formulas ctFormulas = ctShapetype.AddNewFormulas();

            ctFormulas.AddNewF().eqn = "sum #0 0 10800";
            ctFormulas.AddNewF().eqn = "prod #0 2 1";
            ctFormulas.AddNewF().eqn = "sum 21600 0 @1";
            ctFormulas.AddNewF().eqn = "sum 0 0 @2";
            ctFormulas.AddNewF().eqn = "sum 21600 0 @3";
            ctFormulas.AddNewF().eqn = "if @0 @3 0";
            ctFormulas.AddNewF().eqn = "if @0 21600 @1";
            ctFormulas.AddNewF().eqn = "if @0 0 @2";
            ctFormulas.AddNewF().eqn = "if @0 @4 21600";
            ctFormulas.AddNewF().eqn = "mid @5 @6";
            ctFormulas.AddNewF().eqn = "mid @8 @5";
            ctFormulas.AddNewF().eqn = "mid @7 @8";
            ctFormulas.AddNewF().eqn = "mid @6 @7";
            ctFormulas.AddNewF().eqn = "sum @6 0 @5";
            CT_Path ctPath           = ctShapetype.AddNewPath();

            ctPath.textpathok    = ST_TrueFalse.t;
            ctPath.connecttype   = ST_ConnectType.custom;
            ctPath.connectlocs   = "@9,0;@10,10800;@11,21600;@12,10800";
            ctPath.connectangles = "270,180,90,0";
            CT_TextPath ctTextPath1 = ctShapetype.AddNewTextpath();

            ctTextPath1.on       = ST_TrueFalse.t;
            ctTextPath1.fitshape = ST_TrueFalse.t;
            CT_H ctH = ctShapetype.AddNewHandles().AddNewH();

            ctH.position = "#0,bottomRight";
            ctH.xrange   = "6629,14971";
            ctShapetype.AddNewLock().ext = ST_Ext.edit;
            CT_Shape ctShape             = ctGroup.AddNewShape();

            ctShape.id         = "PowerPlusWaterMarkObject" + (object)idx;
            ctShape.spid       = "_x0000_s102" + (object)(4 + idx);
            ctShape.type       = "#_x0000_t136";
            ctShape.style      = "position:absolute;margin-left:0;margin-top:0;width:415pt;height:207.5pt;z-index:-251654144;mso-wrap-edited:f;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin";
            ctShape.wrapcoords = "616 5068 390 16297 39 16921 -39 17155 7265 17545 7186 17467 -39 17467 18904 17467 10507 17467 8710 17545 18904 17077 18787 16843 18358 16297 18279 12554 19178 12476 20701 11774 20779 11228 21131 10059 21248 8811 21248 7563 20975 6316 20935 5380 19490 5146 14022 5068 2616 5068";
            ctShape.fillcolor  = "black";
            ctShape.stroked    = ST_TrueFalse.@false;
            CT_TextPath ctTextPath2 = ctShape.AddNewTextpath();

            ctTextPath2.style   = "font-family:"Cambria";font-size:1pt";
            ctTextPath2.@string = text;
            ctPicture.Set((object)ctGroup);
            return(new XWPFParagraph(prgrph, (IBody)this.doc));
        }