Exemplo n.º 1
0
 public CT_Picture()
 {
     this.blipFillField   = new CT_BlipFillProperties();
     this.nvPicPrField    = new CT_PictureNonVisual();
     this.macroField      = "";
     this.fPublishedField = false;
 }
Exemplo n.º 2
0
        /**
         * Get the PictureData of the Picture, if present.
         * Note - not all kinds of picture have data
         */
        public XWPFPictureData GetPictureData()
        {
            //String blipId = ctPic.blipFill.blip.embed;
            CT_BlipFillProperties blipProps = ctPic.blipFill;

            if (blipProps == null || !blipProps.IsSetBlip())
            {
                // return null if Blip data is missing
                return(null);
            }

            String blipId = blipProps.blip.embed;


            POIXMLDocumentPart part = run.Parent.Part;

            if (part != null)
            {
                POIXMLDocumentPart relatedPart = part.GetRelationById(blipId);
                if (relatedPart is XWPFPictureData)
                {
                    return((XWPFPictureData)relatedPart);
                }
            }
            return(null);
        }
Exemplo n.º 3
0
 public CT_TextCharacterProperties()
 {
     this.extLstField         = new CT_OfficeArtExtensionList();
     this.hlinkMouseOverField = new CT_Hyperlink();
     this.hlinkClickField     = new CT_Hyperlink();
     this.symField            = new CT_TextFont();
     this.csField             = new CT_TextFont();
     this.eaField             = new CT_TextFont();
     this.latinField          = new CT_TextFont();
     this.uFillField          = new CT_TextUnderlineFillGroupWrapper();
     this.uFillTxField        = new CT_TextUnderlineFillFollowText();
     this.uLnField            = new CT_LineProperties();
     this.uLnTxField          = new CT_TextUnderlineLineFollowText();
     this.highlightField      = new CT_Color();
     this.effectDagField      = new CT_EffectContainer();
     this.effectLstField      = new CT_EffectList();
     this.grpFillField        = new CT_GroupFillProperties();
     this.pattFillField       = new CT_PatternFillProperties();
     this.blipFillField       = new CT_BlipFillProperties();
     this.gradFillField       = new CT_GradientFillProperties();
     this.solidFillField      = new CT_SolidColorFillProperties();
     this.noFillField         = new CT_NoFillProperties();
     this.lnField             = new CT_LineProperties();
     this.dirtyField          = true;
     this.errField            = false;
     this.smtCleanField       = true;
     this.smtIdField          = ((uint)(0));
 }
Exemplo n.º 4
0
 public CT_TableCellProperties()
 {
     this.extLstField       = new CT_OfficeArtExtensionList();
     this.grpFillField      = new CT_GroupFillProperties();
     this.pattFillField     = new CT_PatternFillProperties();
     this.blipFillField     = new CT_BlipFillProperties();
     this.gradFillField     = new CT_GradientFillProperties();
     this.solidFillField    = new CT_SolidColorFillProperties();
     this.noFillField       = new CT_NoFillProperties();
     this.cell3DField       = new CT_Cell3D();
     this.lnBlToTrField     = new CT_LineProperties();
     this.lnTlToBrField     = new CT_LineProperties();
     this.lnBField          = new CT_LineProperties();
     this.lnTField          = new CT_LineProperties();
     this.lnRField          = new CT_LineProperties();
     this.lnLField          = new CT_LineProperties();
     this.marLField         = 91440;
     this.marRField         = 91440;
     this.marTField         = 45720;
     this.marBField         = 45720;
     this.vertField         = ST_TextVerticalType.horz;
     this.anchorField       = ST_TextAnchoringType.t;
     this.anchorCtrField    = false;
     this.horzOverflowField = ST_TextHorzOverflowType.clip;
 }
Exemplo n.º 5
0
        public static CT_Picture Parse(XmlNode node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_Picture ctObj = new CT_Picture();

            ctObj.macro      = XmlHelper.ReadString(node.Attributes["macro"]);
            ctObj.fPublished = XmlHelper.ReadBool(node.Attributes["fPublished"]);
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.LocalName == "nvPicPr")
                {
                    ctObj.nvPicPr = CT_PictureNonVisual.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "blipFill")
                {
                    ctObj.blipFill = CT_BlipFillProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "spPr")
                {
                    ctObj.spPr = CT_ShapeProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "style")
                {
                    ctObj.style = CT_ShapeStyle.Parse(childNode, namespaceManager);
                }
            }
            return(ctObj);
        }
Exemplo n.º 6
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);
 }
Exemplo n.º 7
0
        public XWPFPicture AddPicture(Stream pictureData, int pictureType, string filename, int width, int height)
        {
            XWPFDocument    document     = this.paragraph.GetDocument();
            string          id           = document.AddPictureData(pictureData, pictureType);
            XWPFPictureData relationById = (XWPFPictureData)document.GetRelationById(id);

            try
            {
                CT_Inline  ctInline = this.run.AddNewDrawing().AddNewInline();
                XmlElement element  = new XmlDocument().CreateElement("pic", "pic", "http://schemas.openxmlformats.org/drawingml/2006/picture");
                ctInline.graphic             = new CT_GraphicalObject();
                ctInline.graphic.graphicData = new CT_GraphicalObjectData();
                ctInline.graphic.graphicData.AddPicElement((XmlElement)element.Clone());
                ctInline.distT = 0U;
                ctInline.distR = 0U;
                ctInline.distB = 0U;
                ctInline.distL = 0U;
                CT_NonVisualDrawingProps visualDrawingProps1 = ctInline.AddNewDocPr();
                long num = this.GetParagraph().GetDocument().GetDrawingIdManager().ReserveNew();
                visualDrawingProps1.id    = (uint)num;
                visualDrawingProps1.name  = "Drawing " + (object)num;
                visualDrawingProps1.descr = filename;
                CT_PositiveSize2D ctPositiveSize2D1 = ctInline.AddNewExtent();
                ctPositiveSize2D1.cx = (long)width;
                ctPositiveSize2D1.cy = (long)height;
                NPOI.OpenXmlFormats.Dml.Picture.CT_Picture ctPicture = this.GetCTPictures((object)ctInline.graphic.graphicData)[0];
                CT_PictureNonVisual      pictureNonVisual            = ctPicture.AddNewNvPicPr();
                CT_NonVisualDrawingProps visualDrawingProps2         = pictureNonVisual.AddNewCNvPr();
                visualDrawingProps2.id    = 0U;
                visualDrawingProps2.name  = "Picture " + (object)num;
                visualDrawingProps2.descr = filename;
                pictureNonVisual.AddNewCNvPicPr().AddNewPicLocks().noChangeAspect = true;
                CT_BlipFillProperties blipFillProperties = ctPicture.AddNewBlipFill();
                blipFillProperties.AddNewBlip().embed    = relationById.GetPackageRelationship().Id;
                blipFillProperties.AddNewStretch().AddNewFillRect();
                CT_ShapeProperties ctShapeProperties = ctPicture.AddNewSpPr();
                CT_Transform2D     ctTransform2D     = ctShapeProperties.AddNewXfrm();
                CT_Point2D         ctPoint2D         = ctTransform2D.AddNewOff();
                ctPoint2D.x = 0L;
                ctPoint2D.y = 0L;
                CT_PositiveSize2D ctPositiveSize2D2 = ctTransform2D.AddNewExt();
                ctPositiveSize2D2.cx = (long)width;
                ctPositiveSize2D2.cy = (long)height;
                CT_PresetGeometry2D presetGeometry2D = ctShapeProperties.AddNewPrstGeom();
                presetGeometry2D.prst = ST_ShapeType.rect;
                presetGeometry2D.AddNewAvLst();
                XWPFPicture xwpfPicture = new XWPFPicture(ctPicture, this);
                this.pictures.Add(xwpfPicture);
                return(xwpfPicture);
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("", ex);
            }
        }
Exemplo n.º 8
0
 public CT_BackgroundFormatting()
 {
     this.effectDagField = new CT_EffectContainer();
     this.effectLstField = new CT_EffectList();
     this.grpFillField   = new CT_GroupFillProperties();
     this.pattFillField  = new CT_PatternFillProperties();
     this.blipFillField  = new CT_BlipFillProperties();
     this.gradFillField  = new CT_GradientFillProperties();
     this.solidFillField = new CT_SolidColorFillProperties();
     this.noFillField    = new CT_NoFillProperties();
 }
Exemplo n.º 9
0
 public CT_GroupShapeProperties()
 {
     this.extLstField    = new CT_OfficeArtExtensionList();
     this.scene3dField   = new CT_Scene3D();
     this.effectDagField = new CT_EffectContainer();
     this.effectLstField = new CT_EffectList();
     this.grpFillField   = new CT_GroupFillProperties();
     this.pattFillField  = new CT_PatternFillProperties();
     this.blipFillField  = new CT_BlipFillProperties();
     this.gradFillField  = new CT_GradientFillProperties();
     this.solidFillField = new CT_SolidColorFillProperties();
     this.noFillField    = new CT_NoFillProperties();
     //this.xfrmField = new CT_GroupTransform2D();
 }
Exemplo n.º 10
0
 public CT_TableProperties()
 {
     this.extLstField    = new CT_OfficeArtExtensionList();
     this.effectDagField = new CT_EffectContainer();
     this.effectLstField = new CT_EffectList();
     this.grpFillField   = new CT_GroupFillProperties();
     this.pattFillField  = new CT_PatternFillProperties();
     this.blipFillField  = new CT_BlipFillProperties();
     this.gradFillField  = new CT_GradientFillProperties();
     this.solidFillField = new CT_SolidColorFillProperties();
     this.noFillField    = new CT_NoFillProperties();
     this.rtlField       = false;
     this.firstRowField  = false;
     this.firstColField  = false;
     this.lastRowField   = false;
     this.lastColField   = false;
     this.bandRowField   = false;
     this.bandColField   = false;
 }
Exemplo n.º 11
0
        public XWPFPictureData GetPictureData()
        {
            CT_BlipFillProperties blipFill = this.ctPic.blipFill;

            if (blipFill == null || !blipFill.IsSetBlip())
            {
                return((XWPFPictureData)null);
            }
            string             embed = blipFill.blip.embed;
            POIXMLDocumentPart part  = this.run.GetParagraph().GetPart();

            if (part != null)
            {
                POIXMLDocumentPart relationById = part.GetRelationById(embed);
                if (relationById is XWPFPictureData)
                {
                    return((XWPFPictureData)relationById);
                }
            }
            return((XWPFPictureData)null);
        }
Exemplo n.º 12
0
 public XMLPictureShapeModel(PartManager manager, WsDrPart part, XmlPart parent, AnchorModel startAnchor, AnchorModel endAnchor, uint uniqueId)
     : base(manager, part, startAnchor, endAnchor)
 {
     this._parent = parent;
     base.TwoCellAnchor.Choice_0            = CT_TwoCellAnchor.ChoiceBucket_0.pic;
     base.TwoCellAnchor.ClientData          = new CT_AnchorClientData();
     this.Picture.NvPicPr                   = new CT_PictureNonVisual();
     this.Picture.NvPicPr.CNvPicPr          = new CT_NonVisualPictureProperties();
     this.Picture.NvPicPr.CNvPr             = new CT_NonVisualDrawingProps();
     this.Picture.NvPicPr.CNvPr.Id_Attr     = uniqueId;
     this.Picture.NvPicPr.CNvPr.Name_Attr   = "Picture " + uniqueId;
     this.Picture.BlipFill                  = new CT_BlipFillProperties();
     this.Picture.BlipFill.Blip             = new CT_Blip();
     this.Picture.BlipFill.Blip.Cstate_Attr = ST_BlipCompression.print;
     this.Picture.BlipFill.Choice_0         = CT_BlipFillProperties.ChoiceBucket_0.stretch;
     this.Picture.BlipFill.Stretch          = new CT_StretchInfoProperties();
     this.Picture.BlipFill.Stretch.FillRect = new CT_RelativeRect();
     this.Picture.SpPr.Choice_0             = CT_ShapeProperties.ChoiceBucket_0.prstGeom;
     this.Picture.SpPr.PrstGeom             = new CT_PresetGeometry2D();
     this.Picture.SpPr.PrstGeom.Prst_Attr   = ST_ShapeType.rect;
     this.Picture.SpPr.PrstGeom.AvLst       = new CT_GeomGuideList();
 }
Exemplo n.º 13
0
        /**
         * Returns a prototype that is used to construct new shapes
         *
         * @return a prototype that is used to construct new shapes
         */


        internal static CT_Picture Prototype()
        {
            if (prototype == null)
            {
                CT_Picture               pic     = new CT_Picture();
                CT_PictureNonVisual      nvpr    = pic.AddNewNvPicPr();
                CT_NonVisualDrawingProps nvProps = nvpr.AddNewCNvPr();
                nvProps.id    = (1);
                nvProps.name  = ("Picture 1");
                nvProps.descr = ("Picture");
                CT_NonVisualPictureProperties nvPicProps   = nvpr.AddNewCNvPicPr();
                nvPicProps.AddNewPicLocks().noChangeAspect = true;



                CT_BlipFillProperties blip = pic.AddNewBlipFill();
                blip.AddNewBlip().embed    = "";
                blip.AddNewStretch().AddNewFillRect();

                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);
        }
Exemplo n.º 14
0
        public static CT_TextUnderlineFillGroupWrapper Parse(XmlNode node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_TextUnderlineFillGroupWrapper ctObj = new CT_TextUnderlineFillGroupWrapper();

            foreach (XmlNode childNode in node.ChildNodes)
            {
                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();
                }
            }
            return(ctObj);
        }
Exemplo n.º 15
0
        XWPFPicture AddPicture(Stream pictureData, int pictureType, String filename, int width, int height, Action <XWPFDocument, CT_Blip> extAct)
        {
            // Add the picture + relationship
            String          relationId;
            XWPFPictureData picData;
            XWPFDocument    doc = null;

            // Work out what to add the picture to, then add both the
            //  picture and the relationship for it
            // TODO Should we have an interface for this sort of thing?
            if (parent.Part is XWPFHeaderFooter)
            {
                XWPFHeaderFooter headerFooter = (XWPFHeaderFooter)parent.Part;
                relationId = headerFooter.AddPictureData(pictureData, pictureType);
                picData    = (XWPFPictureData)headerFooter.GetRelationById(relationId);
            }
            else
            {
                doc        = parent.Document;
                relationId = doc.AddPictureData(pictureData, pictureType);
                picData    = (XWPFPictureData)doc.GetRelationById(relationId);
            }

            try
            {
                // Create the Drawing entry for it
                CT_Drawing Drawing = run.AddNewDrawing();
                CT_Inline  inline  = Drawing.AddNewInline();

                // Do the fiddly namespace bits on the inline
                // (We need full control of what goes where and as what)
                //CT_GraphicalObject tmp = new CT_GraphicalObject();
                //String xml =
                //    "<a:graphic xmlns:a=\"" + "http://schemas.openxmlformats.org/drawingml/2006/main" + "\">" +
                //    "<a:graphicData uri=\"" + "http://schemas.openxmlformats.org/drawingml/2006/picture" + "\">" +
                //    "<pic:pic xmlns:pic=\"" + "http://schemas.openxmlformats.org/drawingml/2006/picture" + "\" />" +
                //    "</a:graphicData>" +
                //    "</a:graphic>";
                //InputSource is = new InputSource(new StringReader(xml));
                //org.w3c.dom.Document doc = DocumentHelper.readDocument(is);
                //inline.set(XmlToken.Factory.parse(doc.getDocumentElement(), DEFAULT_XML_OPTIONS));

                inline.graphic                 = new CT_GraphicalObject();
                inline.graphic.graphicData     = new CT_GraphicalObjectData();
                inline.graphic.graphicData.uri = "http://schemas.openxmlformats.org/drawingml/2006/picture";


                // Setup the inline
                inline.distT = (0);
                inline.distR = (0);
                inline.distB = (0);
                inline.distL = (0);

                NPOI.OpenXmlFormats.Dml.WordProcessing.CT_NonVisualDrawingProps docPr = inline.AddNewDocPr();
                long id = parent.Document.DrawingIdManager.ReserveNew();
                docPr.id = (uint)(id);
                /* This name is not visible in Word 2010 anywhere. */
                docPr.name  = ("Drawing " + id);
                docPr.descr = (filename);

                NPOI.OpenXmlFormats.Dml.WordProcessing.CT_PositiveSize2D extent = inline.AddNewExtent();
                extent.cx = (width);
                extent.cy = (height);

                // Grab the picture object
                NPOI.OpenXmlFormats.Dml.Picture.CT_Picture pic = new OpenXmlFormats.Dml.Picture.CT_Picture();

                // Set it up
                NPOI.OpenXmlFormats.Dml.Picture.CT_PictureNonVisual nvPicPr = pic.AddNewNvPicPr();

                NPOI.OpenXmlFormats.Dml.CT_NonVisualDrawingProps cNvPr = nvPicPr.AddNewCNvPr();
                /* use "0" for the id. See ECM-576, 20.2.2.3 */
                cNvPr.id = (0);
                /* This name is not visible in Word 2010 anywhere */
                cNvPr.name  = ("Picture " + id);
                cNvPr.descr = (filename);

                CT_NonVisualPictureProperties cNvPicPr   = nvPicPr.AddNewCNvPicPr();
                cNvPicPr.AddNewPicLocks().noChangeAspect = true;

                CT_BlipFillProperties blipFill = pic.AddNewBlipFill();
                CT_Blip blip = blipFill.AddNewBlip();
                blip.embed = (picData.GetPackageRelationship().Id);
                if (doc != null)
                {
                    extAct(doc, blip);
                }
                blipFill.AddNewStretch().AddNewFillRect();

                CT_ShapeProperties spPr = pic.AddNewSpPr();
                CT_Transform2D     xfrm = spPr.AddNewXfrm();

                CT_Point2D off = xfrm.AddNewOff();
                off.x = (0);
                off.y = (0);

                NPOI.OpenXmlFormats.Dml.CT_PositiveSize2D ext = xfrm.AddNewExt();
                ext.cx = (width);
                ext.cy = (height);

                CT_PresetGeometry2D prstGeom = spPr.AddNewPrstGeom();
                prstGeom.prst = (ST_ShapeType.rect);
                prstGeom.AddNewAvLst();

                using (var ms = new MemoryStream())
                {
                    StreamWriter sw = new StreamWriter(ms);
                    pic.Write(sw, "pic:pic");
                    sw.Flush();
                    ms.Position = 0;
                    var sr     = new StreamReader(ms);
                    var picXml = sr.ReadToEnd();
                    inline.graphic.graphicData.AddPicElement(picXml);
                }
                // Finish up
                XWPFPicture xwpfPicture = new XWPFPicture(pic, this);
                pictures.Add(xwpfPicture);
                return(xwpfPicture);
            }
            catch (XmlException e)
            {
                throw new InvalidOperationException("XWPFRun.Addpicture error", e);
            }
        }
Exemplo n.º 16
0
        /**
         * Adds a picture to the run. This method handles
         *  attaching the picture data to the overall file.
         *
         * @see NPOI.XWPF.UserModel.Document#PICTURE_TYPE_EMF
         * @see NPOI.XWPF.UserModel.Document#PICTURE_TYPE_WMF
         * @see NPOI.XWPF.UserModel.Document#PICTURE_TYPE_PICT
         * @see NPOI.XWPF.UserModel.Document#PICTURE_TYPE_JPEG
         * @see NPOI.XWPF.UserModel.Document#PICTURE_TYPE_PNG
         * @see NPOI.XWPF.UserModel.Document#PICTURE_TYPE_DIB
         *
         * @param pictureData The raw picture data
         * @param pictureType The type of the picture, eg {@link Document#PICTURE_TYPE_JPEG}
         * @param width width in EMUs. To convert to / from points use {@link org.apache.poi.util.Units}
         * @param height height in EMUs. To convert to / from points use {@link org.apache.poi.util.Units}
         * @throws NPOI.Openxml4j.exceptions.InvalidFormatException
         * @throws IOException
         */
        public XWPFPicture AddPicture(Stream pictureData, int pictureType, String filename, int width, int height)
        {
            XWPFDocument doc = parent.Document;

            // Add the picture + relationship
            String          relationId = doc.AddPictureData(pictureData, pictureType);
            XWPFPictureData picData    = (XWPFPictureData)doc.GetRelationById(relationId);

            // Create the Drawing entry for it
            CT_Drawing Drawing = run.AddNewDrawing();
            CT_Inline  inline  = Drawing.AddNewInline();

            // Do the fiddly namespace bits on the inline
            // (We need full control of what goes where and as what)
            //CT_GraphicalObject tmp = new CT_GraphicalObject();
            //String xml =
            //    "<a:graphic xmlns:a=\"" + "http://schemas.openxmlformats.org/drawingml/2006/main" + "\">" +
            //    "<a:graphicData uri=\"" + "http://schemas.openxmlformats.org/drawingml/2006/picture" + "\">" +
            //    "<pic:pic xmlns:pic=\"" + "http://schemas.openxmlformats.org/drawingml/2006/picture" + "\" />" +
            //    "</a:graphicData>" +
            //    "</a:graphic>";
            //inline.Set((xml));

            XmlDocument xmlDoc = new XmlDocument();

            //XmlElement el = xmlDoc.CreateElement("pic", "pic", "http://schemas.openxmlformats.org/drawingml/2006/picture");

            inline.graphic                 = new CT_GraphicalObject();
            inline.graphic.graphicData     = new CT_GraphicalObjectData();
            inline.graphic.graphicData.uri = "http://schemas.openxmlformats.org/drawingml/2006/picture";


            // Setup the inline
            inline.distT = (0);
            inline.distR = (0);
            inline.distB = (0);
            inline.distL = (0);

            NPOI.OpenXmlFormats.Dml.WordProcessing.CT_NonVisualDrawingProps docPr = inline.AddNewDocPr();
            long id = parent.Document.DrawingIdManager.ReserveNew();

            docPr.id = (uint)(id);
            /* This name is not visible in Word 2010 anywhere. */
            docPr.name  = ("Drawing " + id);
            docPr.descr = (filename);

            NPOI.OpenXmlFormats.Dml.WordProcessing.CT_PositiveSize2D extent = inline.AddNewExtent();
            extent.cx = (width);
            extent.cy = (height);

            // Grab the picture object
            NPOI.OpenXmlFormats.Dml.Picture.CT_Picture pic = new OpenXmlFormats.Dml.Picture.CT_Picture();

            // Set it up
            NPOI.OpenXmlFormats.Dml.Picture.CT_PictureNonVisual nvPicPr = pic.AddNewNvPicPr();

            NPOI.OpenXmlFormats.Dml.CT_NonVisualDrawingProps cNvPr = nvPicPr.AddNewCNvPr();
            /* use "0" for the id. See ECM-576, 20.2.2.3 */
            cNvPr.id = (0);
            /* This name is not visible in Word 2010 anywhere */
            cNvPr.name  = ("Picture " + id);
            cNvPr.descr = (filename);

            CT_NonVisualPictureProperties cNvPicPr = nvPicPr.AddNewCNvPicPr();

            cNvPicPr.AddNewPicLocks().noChangeAspect = true;

            CT_BlipFillProperties blipFill = pic.AddNewBlipFill();
            CT_Blip blip = blipFill.AddNewBlip();

            blip.embed = (picData.GetPackageRelationship().Id);
            blipFill.AddNewStretch().AddNewFillRect();

            CT_ShapeProperties spPr = pic.AddNewSpPr();
            CT_Transform2D     xfrm = spPr.AddNewXfrm();

            CT_Point2D off = xfrm.AddNewOff();

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

            NPOI.OpenXmlFormats.Dml.CT_PositiveSize2D ext = xfrm.AddNewExt();
            ext.cx = (width);
            ext.cy = (height);

            CT_PresetGeometry2D prstGeom = spPr.AddNewPrstGeom();

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

            using (var ms = new MemoryStream())
            {
                StreamWriter sw = new StreamWriter(ms);
                pic.Write(sw, "pic:pic");
                sw.Flush();
                ms.Position = 0;
                var sr     = new StreamReader(ms);
                var picXml = sr.ReadToEnd();
                inline.graphic.graphicData.AddPicElement(picXml);
            }
            // Finish up
            XWPFPicture xwpfPicture = new XWPFPicture(pic, this);

            pictures.Add(xwpfPicture);
            return(xwpfPicture);
        }
Exemplo n.º 17
0
        public static CT_TextCharacterProperties Parse(XmlNode node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_TextCharacterProperties ctObj = new CT_TextCharacterProperties();

            ctObj.kumimoji = XmlHelper.ReadBool(node.Attributes["kumimoji"]);
            ctObj.lang     = XmlHelper.ReadString(node.Attributes["lang"]);
            ctObj.altLang  = XmlHelper.ReadString(node.Attributes["altLang"]);
            ctObj.sz       = XmlHelper.ReadInt(node.Attributes["sz"]);
            if (node.Attributes["b"] != null)
            {
                ctObj.b = XmlHelper.ReadBool(node.Attributes["b"]);
            }
            if (node.Attributes["i"] != null)
            {
                ctObj.i = XmlHelper.ReadBool(node.Attributes["i"]);
            }
            if (node.Attributes["u"] != null)
            {
                ctObj.u = (ST_TextUnderlineType)Enum.Parse(typeof(ST_TextUnderlineType), node.Attributes["u"].Value);
            }
            if (node.Attributes["strike"] != null)
            {
                ctObj.strike = (ST_TextStrikeType)Enum.Parse(typeof(ST_TextStrikeType), node.Attributes["strike"].Value);
            }
            ctObj.kern = XmlHelper.ReadInt(node.Attributes["kern"]);
            if (node.Attributes["cap"] != null)
            {
                ctObj.cap = (ST_TextCapsType)Enum.Parse(typeof(ST_TextCapsType), node.Attributes["cap"].Value);
            }
            ctObj.spc        = XmlHelper.ReadInt(node.Attributes["spc"]);
            ctObj.normalizeH = XmlHelper.ReadBool(node.Attributes["normalizeH"]);
            ctObj.baseline   = XmlHelper.ReadInt(node.Attributes["baseline"]);
            ctObj.noProof    = XmlHelper.ReadBool(node.Attributes["noProof"]);
            if (node.Attributes["dirty"] != null)
            {
                ctObj.dirty = XmlHelper.ReadBool(node.Attributes["dirty"]);
            }
            ctObj.err = XmlHelper.ReadBool(node.Attributes["err"]);
            if (node.Attributes["smtClean"] != null)
            {
                ctObj.smtClean = XmlHelper.ReadBool(node.Attributes["smtClean"]);
            }
            ctObj.smtId = XmlHelper.ReadUInt(node.Attributes["smtId"]);
            ctObj.bmk   = XmlHelper.ReadString(node.Attributes["bmk"]);
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.LocalName == "ln")
                {
                    ctObj.ln = CT_LineProperties.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 == "effectLst")
                {
                    ctObj.effectLst = CT_EffectList.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "effectDag")
                {
                    ctObj.effectDag = CT_EffectContainer.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "highlight")
                {
                    ctObj.highlight = CT_Color.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "uLnTx")
                {
                    ctObj.uLnTx = new CT_TextUnderlineLineFollowText();
                }
                else if (childNode.LocalName == "uLn")
                {
                    ctObj.uLn = CT_LineProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "uFillTx")
                {
                    ctObj.uFillTx = new CT_TextUnderlineFillFollowText();
                }
                else if (childNode.LocalName == "uFill")
                {
                    ctObj.uFill = CT_TextUnderlineFillGroupWrapper.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "latin")
                {
                    ctObj.latin = CT_TextFont.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "ea")
                {
                    ctObj.ea = CT_TextFont.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "cs")
                {
                    ctObj.cs = CT_TextFont.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "sym")
                {
                    ctObj.sym = CT_TextFont.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "hlinkClick")
                {
                    ctObj.hlinkClick = CT_Hyperlink.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "hlinkMouseOver")
                {
                    ctObj.hlinkMouseOver = CT_Hyperlink.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "extLst")
                {
                    ctObj.extLst = CT_OfficeArtExtensionList.Parse(childNode, namespaceManager);
                }
            }
            return(ctObj);
        }
Exemplo n.º 18
0
 public CT_BlipFillProperties AddNewBlipFill()
 {
     blipFillField = new CT_BlipFillProperties();
     return(this.blipFillField);
 }
Exemplo n.º 19
0
 public CT_Picture()
 {
     this.blipFillField = new CT_BlipFillProperties();
     this.nvPicPrField = new CT_PictureNonVisual();
     this.macroField = "";
     this.fPublishedField = false;
 }
Exemplo n.º 20
0
 public CT_BlipFillProperties AddNewBlipFill()
 {
     blipFillField = new CT_BlipFillProperties();
     return this.blipFillField;
 }