Exemple #1
0
        /**
         * Sets the color used to fill this shape using the solid fill pattern.
         */
        public void SetFillColor(int red, int green, int blue)
        {
            NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_ShapeProperties props = GetShapeProperties();
            CT_SolidColorFillProperties fill = props.IsSetSolidFill() ? props.solidFill : props.AddNewSolidFill();
            CT_SRgbColor rgb = new CT_SRgbColor();

            rgb.val      = (new byte[] { (byte)red, (byte)green, (byte)blue });
            fill.srgbClr = (rgb);
        }
Exemple #2
0
        public void Set(CT_Shape obj)
        {
            this.macroField = obj.macro;
            this.textlinkField = obj.textlink;
            this.fLocksTextField = obj.fLocksText;
            this.fPublishedField = obj.fPublished;

            this.nvSpPrField = obj.nvSpPr;
            this.spPrField = obj.spPr;
            this.styleField = obj.style;
            this.txBodyField = obj.txBody;
        }
        /**
         * Initialize default structure of a new auto-shape
         *
         */
        public static CT_Connector Prototype()
        {
            CT_Connector          shape = new CT_Connector();
            CT_ConnectorNonVisual nv    = shape.AddNewNvCxnSpPr();

            NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_NonVisualDrawingProps nvp = nv.AddNewCNvPr();
            nvp.id   = (1);
            nvp.name = ("Shape 1");
            nv.AddNewCNvCxnSpPr();

            NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_ShapeProperties sp  = shape.AddNewSpPr();
            NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_Transform2D     t2d = sp.AddNewXfrm();
            CT_PositiveSize2D p1 = t2d.AddNewExt();

            p1.cx = (0);
            p1.cy = (0);
            CT_Point2D p2 = t2d.AddNewOff();

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

            CT_PresetGeometry2D geom = sp.AddNewPrstGeom();

            geom.prst = (ST_ShapeType.line);
            geom.AddNewAvLst();

            NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_ShapeStyle style = shape.AddNewStyle();
            CT_SchemeColor scheme = style.AddNewLnRef().AddNewSchemeClr();

            scheme.val      = (ST_SchemeColorVal.accent1);
            style.lnRef.idx = (1);

            CT_StyleMatrixReference fillref = style.AddNewFillRef();

            fillref.idx = (0);
            fillref.AddNewSchemeClr().val = (ST_SchemeColorVal.accent1);

            CT_StyleMatrixReference effectRef = style.AddNewEffectRef();

            effectRef.idx = (0);
            effectRef.AddNewSchemeClr().val = (ST_SchemeColorVal.accent1);

            CT_FontReference fontRef = style.AddNewFontRef();

            fontRef.idx = (ST_FontCollectionIndex.minor);
            fontRef.AddNewSchemeClr().val = (ST_SchemeColorVal.tx1);

            prototype = shape;

            return(prototype);
        }
Exemple #4
0
        /**
         * Prototype with the default structure of a new auto-shape.
         */
        protected internal static CT_Shape Prototype()
        {
            // in poi, method XmlObject set(XmlObject srcObj) will create a copy of XmlObject
            // so this prototype object would be newly set to shape object
            // but in .net, the prototype object will be modified and keep its contents, would
            // affect next usage. so comment the following code, and create a new prototype object
            // for every calling of Prototype().
            //if (prototype == null)
            {
                CT_Shape shape = new CT_Shape();

                CT_ShapeNonVisual nv = shape.AddNewNvSpPr();
                NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_NonVisualDrawingProps nvp = nv.AddNewCNvPr();
                nvp.id   = (/*setter*/ 1);
                nvp.name = (/*setter*/ "Shape 1");
                nv.AddNewCNvSpPr();

                NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_ShapeProperties sp = shape.AddNewSpPr();
                CT_Transform2D    t2d = sp.AddNewXfrm();
                CT_PositiveSize2D p1  = t2d.AddNewExt();
                p1.cx = (/*setter*/ 0);
                p1.cy = (/*setter*/ 0);
                CT_Point2D p2 = t2d.AddNewOff();
                p2.x = (/*setter*/ 0);
                p2.y = (/*setter*/ 0);

                CT_PresetGeometry2D geom = sp.AddNewPrstGeom();
                geom.prst = (/*setter*/ ST_ShapeType.rect);
                geom.AddNewAvLst();

                NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_TextBody body = shape.AddNewTxBody();
                CT_TextBodyProperties bodypr = body.AddNewBodyPr();
                bodypr.anchor = (/*setter*/ ST_TextAnchoringType.t);
                bodypr.rtlCol = (/*setter*/ false);
                CT_TextParagraph p = body.AddNewP();
                p.AddNewPPr().algn = (/*setter*/ ST_TextAlignType.l);
                CT_TextCharacterProperties endPr = p.AddNewEndParaRPr();
                endPr.lang = (/*setter*/ "en-US");
                endPr.sz   = (/*setter*/ 1100);
                CT_SolidColorFillProperties scfpr = endPr.AddNewSolidFill();
                scfpr.AddNewSrgbClr().val         = (/*setter*/ new byte[] { 0, 0, 0 });

                body.AddNewLstStyle();

                prototype = shape;
            }
            return(prototype);
        }
Exemple #5
0
        /**
         * Prototype with the default structure of a new auto-shape.
         */
        protected internal static CT_Shape GetPrototype()
        {
            if (prototype == null)
            {
                CT_Shape shape = new CT_Shape();

                CT_ShapeNonVisual nv = shape.AddNewNvSpPr();
                NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_NonVisualDrawingProps nvp = nv.AddNewCNvPr();
                nvp.id   = (/*setter*/ 1);
                nvp.name = (/*setter*/ "Shape 1");
                nv.AddNewCNvSpPr();

                NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_ShapeProperties sp  = shape.AddNewSpPr();
                NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_Transform2D     t2d = sp.AddNewXfrm();
                CT_PositiveSize2D p1 = t2d.AddNewExt();
                p1.cx = (/*setter*/ 0);
                p1.cy = (/*setter*/ 0);
                CT_Point2D p2 = t2d.AddNewOff();
                p2.x = (/*setter*/ 0);
                p2.y = (/*setter*/ 0);

                CT_PresetGeometry2D geom = sp.AddNewPrstGeom();
                geom.prst = (/*setter*/ ST_ShapeType.rect);
                geom.AddNewAvLst();

                NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_TextBody body = shape.AddNewTxBody();
                CT_TextBodyProperties bodypr = body.AddNewBodyPr();
                bodypr.anchor = (/*setter*/ ST_TextAnchoringType.t);
                bodypr.rtlCol = (/*setter*/ false);
                CT_TextParagraph p = body.AddNewP();
                p.AddNewPPr().algn = (/*setter*/ ST_TextAlignType.l);
                CT_TextCharacterProperties endPr = p.AddNewEndParaRPr();
                endPr.lang = (/*setter*/ "en-US");
                endPr.sz   = (/*setter*/ 1100);
                CT_SolidColorFillProperties scfpr = endPr.AddNewSolidFill();
                scfpr.AddNewSrgbClr().val         = (/*setter*/ new byte[] { 0, 0, 0 });

                body.AddNewLstStyle();

                prototype = shape;
            }
            return(prototype);
        }
Exemple #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);
        }
Exemple #7
0
 public CT_ShapeProperties AddNewSpPr()
 {
     this.spPrField = new CT_ShapeProperties();
     return this.spPrField;
 }
Exemple #8
0
 public void Set(CT_Connector obj)
 {
     this.macroField = obj.macro;
     this.fPublishedField = obj.fPublished;
     this.spPrField = obj.spPr;
     this.styleField = obj.style;
     this.nvCxnSpPrField = obj.nvCxnSpPr;
 }
Exemple #9
0
 public static CT_ShapeProperties Parse(XmlNode node, XmlNamespaceManager namespaceManager)
 {
     if (node == null)
         return null;
     CT_ShapeProperties ctObj = new CT_ShapeProperties();
     if (node.Attributes["bwMode"] != null)
         ctObj.bwMode = (ST_BlackWhiteMode)Enum.Parse(typeof(ST_BlackWhiteMode), node.Attributes["bwMode"].Value);
     foreach (XmlNode childNode in node.ChildNodes)
     {
         if (childNode.LocalName == "xfrm")
             ctObj.xfrm = NPOI.OpenXmlFormats.Dml.CT_Transform2D.Parse(childNode, namespaceManager);
         else if (childNode.LocalName == "custGeom")
             ctObj.custGeom = CT_CustomGeometry2D.Parse(childNode, namespaceManager);
         else if (childNode.LocalName == "prstGeom")
             ctObj.prstGeom = CT_PresetGeometry2D.Parse(childNode, namespaceManager);
         else if (childNode.LocalName == "noFill")
             ctObj.noFill = new CT_NoFillProperties();
         else if (childNode.LocalName == "solidFill")
             ctObj.solidFill = CT_SolidColorFillProperties.Parse(childNode, namespaceManager);
         else if (childNode.LocalName == "gradFill")
             ctObj.gradFill = CT_GradientFillProperties.Parse(childNode, namespaceManager);
         else if (childNode.LocalName == "blipFill")
             ctObj.blipFill = CT_BlipFillProperties.Parse(childNode, namespaceManager);
         else if (childNode.LocalName == "pattFill")
             ctObj.pattFill = CT_PatternFillProperties.Parse(childNode, namespaceManager);
         else if (childNode.LocalName == "grpFill")
             ctObj.grpFill = new CT_GroupFillProperties();
         else if (childNode.LocalName == "ln")
             ctObj.ln = CT_LineProperties.Parse(childNode, namespaceManager);
         else if (childNode.LocalName == "effectLst")
             ctObj.effectLst = CT_EffectList.Parse(childNode, namespaceManager);
         else if (childNode.LocalName == "effectDag")
             ctObj.effectDag = CT_EffectContainer.Parse(childNode, namespaceManager);
         else if (childNode.LocalName == "scene3d")
             ctObj.scene3d = CT_Scene3D.Parse(childNode, namespaceManager);
         else if (childNode.LocalName == "sp3d")
             ctObj.sp3d = CT_Shape3D.Parse(childNode, namespaceManager);
         else if (childNode.LocalName == "extLst")
             ctObj.extLst = CT_OfficeArtExtensionList.Parse(childNode, namespaceManager);
     }
     return ctObj;
 }
Exemple #10
0
 public void Set(CT_Connector obj)
 {
     //throw new NotImplementedException();
     this.macroField = obj.macro;
     this.fPublishField = obj.fPublished;
     this.spPrField = obj.spPr;
     this.styleField = obj.style;
     this.nvCxnSpPrField = obj.nvCxnSpPr;
 }
Exemple #11
0
        /**
         * Prototype with the default structure of a new auto-shape.
         */
        internal static CT_Shape Prototype()
        {
            CT_Shape shape = new CT_Shape();


            CT_ShapeNonVisual nv = shape.AddNewNvSpPr();

            NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_NonVisualDrawingProps nvp = nv.AddNewCNvPr();
            nvp.id   = (1);
            nvp.name = ("Shape 1");
            nv.AddNewCNvSpPr();

            NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_ShapeProperties sp = shape.AddNewSpPr();
            NPOI.OpenXmlFormats.Dml.CT_Transform2D t2d = sp.AddNewXfrm();
            CT_PositiveSize2D p1 = t2d.AddNewExt();

            p1.cx = (0);
            p1.cy = (0);
            CT_Point2D p2 = t2d.AddNewOff();

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

            CT_PresetGeometry2D geom = sp.AddNewPrstGeom();

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

            NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_ShapeStyle style = shape.AddNewStyle();
            CT_SchemeColor scheme = style.AddNewLnRef().AddNewSchemeClr();

            scheme.val = (ST_SchemeColorVal.accent1);
            scheme.AddNewShade().val = 50000;
            style.lnRef.idx = (2);

            CT_StyleMatrixReference Fillref = style.AddNewFillRef();

            Fillref.idx = (1);
            Fillref.AddNewSchemeClr().val = (ST_SchemeColorVal.accent1);

            CT_StyleMatrixReference effectRef = style.AddNewEffectRef();

            effectRef.idx = (0);
            effectRef.AddNewSchemeClr().val = (ST_SchemeColorVal.accent1);

            CT_FontReference fontRef = style.AddNewFontRef();

            fontRef.idx = (ST_FontCollectionIndex.minor);
            fontRef.AddNewSchemeClr().val = (ST_SchemeColorVal.lt1);

            NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_TextBody body = shape.AddNewTxBody();
            CT_TextBodyProperties bodypr = body.AddNewBodyPr();

            bodypr.anchor = (ST_TextAnchoringType.ctr);
            bodypr.rtlCol = (false);
            CT_TextParagraph p = body.AddNewP();

            p.AddNewPPr().algn = (ST_TextAlignType.ctr);
            CT_TextCharacterProperties endPr = p.AddNewEndParaRPr();

            endPr.lang = ("en-US");
            endPr.sz   = (1100);

            body.AddNewLstStyle();

            prototype = shape;

            return(prototype);
        }