Exemple #1
0
        /**
         * Construct a SpreadsheetML Drawing from a namespace part
         *
         * @param part the namespace part holding the Drawing data,
         * the content type must be <code>application/vnd.openxmlformats-officedocument.Drawing+xml</code>
         * @param rel  the namespace relationship holding this Drawing,
         * the relationship type must be http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing
         */
        internal XSSFDrawing(PackagePart part)
            : base(part)
        {
            XmlDocument xmldoc = ConvertStreamToXml(part.GetInputStream());

            drawing = CT_Drawing.Parse(xmldoc, NamespaceManager);
        }
Exemple #2
0
        private List <NPOI.OpenXmlFormats.Dml.Picture.CT_Picture> GetCTPictures(object o)
        {
            List <NPOI.OpenXmlFormats.Dml.Picture.CT_Picture> pictures = new List <NPOI.OpenXmlFormats.Dml.Picture.CT_Picture>();

            //XmlObject[] picts = o.SelectPath("declare namespace pic='"+CT_Picture.type.Name.NamespaceURI+"' .//pic:pic");
            //XmlElement[] picts = o.Any;
            //foreach (XmlElement pict in picts)
            //{
            //if(pict is XmlAnyTypeImpl) {
            //    // Pesky XmlBeans bug - see Bugzilla #49934
            //    try {
            //        pict = CT_Picture.Factory.Parse( pict.ToString() );
            //    } catch(XmlException e) {
            //        throw new POIXMLException(e);
            //    }
            //}
            //if (pict is NPOI.OpenXmlFormats.Dml.CT_Picture)
            //{
            //    pictures.Add((NPOI.OpenXmlFormats.Dml.CT_Picture)pict);
            //}
            //}
            if (o is CT_Drawing)
            {
                CT_Drawing drawing = o as CT_Drawing;
                if (drawing.inline != null)
                {
                    foreach (CT_Inline inline in drawing.inline)
                    {
                        GetPictures(inline.graphic.graphicData, pictures);
                    }
                }
            }
            else if (o is CT_GraphicalObjectData)
            {
                GetPictures(o as CT_GraphicalObjectData, pictures);
            }
            return(pictures);
        }
Exemple #3
0
        public static XWPFPicture AddPicture(XWPFRun run, Stream pictureData, int pictureType, string filename, int width, int height)
        {
            width  *= 9525;
            height *= 9525;
            pictureData.Seek(0, SeekOrigin.Begin);

            run.SetText("");
            //run = run.Paragraph.CreateRun();
            XWPFPicture pic = run.AddPicture(pictureData, pictureType, filename, width, height);

            ArrayList  runItems = run.GetCTR().Items;
            CT_Drawing drawing  = runItems[runItems.Count - 1] as CT_Drawing;
            CT_Inline  inline   = drawing.inline[0];

            inline.docPr.id = (uint)run.Document.GetNextPicNameNumber((int)PictureType.PNG);

            inline.effectExtent   = new CT_EffectExtent();
            inline.effectExtent.l = 0;
            inline.effectExtent.t = 0;
            inline.effectExtent.r = 0;
            inline.effectExtent.b = 0;

            return(pic);
        }
Exemple #4
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);
            }
        }
Exemple #5
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);
        }
Exemple #6
0
        public void TestNew()
        {
            XSSFWorkbook wb1   = new XSSFWorkbook();
            XSSFSheet    sheet = (XSSFSheet)wb1.CreateSheet();
            //multiple calls of CreateDrawingPatriarch should return the same instance of XSSFDrawing
            XSSFDrawing dr1 = (XSSFDrawing)sheet.CreateDrawingPatriarch();
            XSSFDrawing dr2 = (XSSFDrawing)sheet.CreateDrawingPatriarch();

            Assert.AreSame(dr1, dr2);

            List <POIXMLDocumentPart.RelationPart> rels = sheet.RelationParts;

            Assert.AreEqual(1, rels.Count);
            POIXMLDocumentPart.RelationPart rp = rels[0];
            Assert.IsTrue(rp.DocumentPart is XSSFDrawing);

            XSSFDrawing drawing   = (XSSFDrawing)rp.DocumentPart;
            String      drawingId = rp.Relationship.Id;

            //there should be a relation to this Drawing in the worksheet
            Assert.IsTrue(sheet.GetCTWorksheet().IsSetDrawing());
            Assert.AreEqual(drawingId, sheet.GetCTWorksheet().drawing.id);

            //XSSFClientAnchor anchor = new XSSFClientAnchor();

            XSSFConnector c1 = drawing.CreateConnector(new XSSFClientAnchor(0, 0, 0, 0, 0, 0, 2, 2));

            c1.LineWidth = 2.5;
            c1.LineStyle = LineStyle.DashDotSys;

            XSSFShapeGroup c2 = drawing.CreateGroup(new XSSFClientAnchor(0, 0, 0, 0, 0, 0, 5, 5));

            Assert.IsNotNull(c2);

            XSSFSimpleShape c3 = drawing.CreateSimpleShape(new XSSFClientAnchor(0, 0, 0, 0, 2, 2, 3, 4));

            c3.SetText(new XSSFRichTextString("Test String"));
            c3.SetFillColor(128, 128, 128);

            XSSFTextBox        c4 = (XSSFTextBox)drawing.CreateTextbox(new XSSFClientAnchor(0, 0, 0, 0, 4, 4, 5, 6));
            XSSFRichTextString rt = new XSSFRichTextString("Test String");

            rt.ApplyFont(0, 5, wb1.CreateFont());
            rt.ApplyFont(5, 6, wb1.CreateFont());
            c4.SetText(rt);

            c4.IsNoFill = (true);

            Assert.AreEqual(4, drawing.GetCTDrawing().SizeOfTwoCellAnchorArray());

            List <XSSFShape> shapes = drawing.GetShapes();

            Assert.AreEqual(4, shapes.Count);
            Assert.IsTrue(shapes[(0)] is XSSFConnector);
            Assert.IsTrue(shapes[(1)] is XSSFShapeGroup);
            Assert.IsTrue(shapes[(2)] is XSSFSimpleShape);
            Assert.IsTrue(shapes[(3)] is XSSFSimpleShape);

            // Save and re-load it
            XSSFWorkbook wb2 = XSSFTestDataSamples.WriteOutAndReadBack(wb1) as XSSFWorkbook;

            wb1.Close();

            sheet = wb2.GetSheetAt(0) as XSSFSheet;

            // Check
            dr1 = sheet.CreateDrawingPatriarch() as XSSFDrawing;
            CT_Drawing ctDrawing = dr1.GetCTDrawing();

            // Connector, shapes and text boxes are all two cell anchors
            Assert.AreEqual(0, ctDrawing.SizeOfAbsoluteAnchorArray());
            Assert.AreEqual(0, ctDrawing.SizeOfOneCellAnchorArray());
            Assert.AreEqual(4, ctDrawing.SizeOfTwoCellAnchorArray());

            shapes = dr1.GetShapes();
            Assert.AreEqual(4, shapes.Count);
            Assert.IsTrue(shapes[0] is XSSFConnector);
            Assert.IsTrue(shapes[1] is XSSFShapeGroup);
            Assert.IsTrue(shapes[2] is XSSFSimpleShape);
            Assert.IsTrue(shapes[3] is XSSFSimpleShape); //

            // Ensure it got the right namespaces
            //String xml = ctDrawing.ToString();
            //Assert.IsTrue(xml.Contains("xmlns:xdr=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\""));
            //Assert.IsTrue(xml.Contains("xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\""));

            checkRewrite(wb2);
            wb2.Close();
        }
Exemple #7
0
 public void UnsetDrawing()
 {
     this.drawingField = null;
 }
Exemple #8
0
 public CT_Drawing AddNewDrawing()
 {
     this.drawingField = new CT_Drawing();
     return(drawingField);
 }
Exemple #9
0
        public static CT_Worksheet Parse(XmlNode node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_Worksheet ctObj = new CT_Worksheet();

            ctObj.cols = new List <CT_Cols>();
            ctObj.conditionalFormatting = new List <CT_ConditionalFormatting>();
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.LocalName == "sheetPr")
                {
                    ctObj.sheetPr = CT_SheetPr.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "dimension")
                {
                    ctObj.dimension = CT_SheetDimension.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "sheetViews")
                {
                    ctObj.sheetViews = CT_SheetViews.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "sheetFormatPr")
                {
                    ctObj.sheetFormatPr = CT_SheetFormatPr.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "sheetData")
                {
                    ctObj.sheetData = CT_SheetData.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "sheetCalcPr")
                {
                    ctObj.sheetCalcPr = CT_SheetCalcPr.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "sheetProtection")
                {
                    ctObj.sheetProtection = CT_SheetProtection.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "protectedRanges")
                {
                    ctObj.protectedRanges = CT_ProtectedRanges.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "scenarios")
                {
                    ctObj.scenarios = CT_Scenarios.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "autoFilter")
                {
                    ctObj.autoFilter = CT_AutoFilter.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "sortState")
                {
                    ctObj.sortState = CT_SortState.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "dataConsolidate")
                {
                    ctObj.dataConsolidate = CT_DataConsolidate.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "customSheetViews")
                {
                    ctObj.customSheetViews = CT_CustomSheetViews.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "mergeCells")
                {
                    ctObj.mergeCells = CT_MergeCells.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "phoneticPr")
                {
                    ctObj.phoneticPr = CT_PhoneticPr.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "dataValidations")
                {
                    ctObj.dataValidations = CT_DataValidations.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "hyperlinks")
                {
                    ctObj.hyperlinks = CT_Hyperlinks.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "printOptions")
                {
                    ctObj.printOptions = CT_PrintOptions.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "pageMargins")
                {
                    ctObj.pageMargins = CT_PageMargins.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "pageSetup")
                {
                    ctObj.pageSetup = CT_PageSetup.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "headerFooter")
                {
                    ctObj.headerFooter = CT_HeaderFooter.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "rowBreaks")
                {
                    ctObj.rowBreaks = CT_PageBreak.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "colBreaks")
                {
                    ctObj.colBreaks = CT_PageBreak.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "customProperties")
                {
                    ctObj.customProperties = CT_CustomProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "cellWatches")
                {
                    ctObj.cellWatches = CT_CellWatches.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "ignoredErrors")
                {
                    ctObj.ignoredErrors = CT_IgnoredErrors.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "smartTags")
                {
                    ctObj.smartTags = CT_CellSmartTags.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "drawing")
                {
                    ctObj.drawing = CT_Drawing.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "legacyDrawing")
                {
                    ctObj.legacyDrawing = CT_LegacyDrawing.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "legacyDrawingHF")
                {
                    ctObj.legacyDrawingHF = CT_LegacyDrawing.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "picture")
                {
                    ctObj.picture = CT_SheetBackgroundPicture.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "oleObjects")
                {
                    ctObj.oleObjects = CT_OleObjects.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "controls")
                {
                    ctObj.controls = CT_Controls.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "webPublishItems")
                {
                    ctObj.webPublishItems = CT_WebPublishItems.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "tableParts")
                {
                    ctObj.tableParts = CT_TableParts.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "extLst")
                {
                    ctObj.extLst = CT_ExtensionList.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "cols")
                {
                    ctObj.cols.Add(CT_Cols.Parse(childNode, namespaceManager));
                }
                else if (childNode.LocalName == "conditionalFormatting")
                {
                    ctObj.conditionalFormatting.Add(CT_ConditionalFormatting.Parse(childNode, namespaceManager));
                }
            }
            return(ctObj);
        }
Exemple #10
0
 public void WriteDrawing(CT_Drawing drawing)
 {
     this.WriteStandaloneTag(drawing, StreamSheetSection.Drawing, CT_Worksheet.DrawingElementName);
 }
Exemple #11
0
 public OpenXmlPictureModel(Size size, Size desiredSize, bool clip, uint inlineId, uint picId, string relationshipId, string name)
 {
     this._drawing = new CT_Drawing
     {
         Choice_0 = CT_Drawing.ChoiceBucket_0.inline,
         Inline   = new CT_Inline
         {
             Extent = new AspNetCore.ReportingServices.Rendering.WordRenderer.WordOpenXmlRenderer.Parser.drawingml.x2006.wordprocessingDrawing.CT_PositiveSize2D
             {
                 Cx_Attr = desiredSize.Width,
                 Cy_Attr = desiredSize.Height
             },
             DocPr = new AspNetCore.ReportingServices.Rendering.WordRenderer.WordOpenXmlRenderer.Parser.drawingml.x2006.wordprocessingDrawing.CT_NonVisualDrawingProps
             {
                 Id_Attr   = inlineId,
                 Name_Attr = name
             },
             Graphic = new CT_GraphicalObject
             {
                 GraphicData = new CT_GraphicalObjectData
                 {
                     Uri_Attr = "http://schemas.openxmlformats.org/drawingml/2006/picture",
                     Pic      = new CT_Picture
                     {
                         NvPicPr = new CT_PictureNonVisual
                         {
                             CNvPr = new AspNetCore.ReportingServices.Rendering.WordRenderer.WordOpenXmlRenderer.Parser.drawingml.x2006.picture.CT_NonVisualDrawingProps
                             {
                                 Id_Attr   = picId,
                                 Name_Attr = name
                             },
                             CNvPicPr = new CT_NonVisualPictureProperties()
                         },
                         BlipFill = new CT_BlipFillProperties
                         {
                             Blip = new CT_Blip
                             {
                                 Embed_Attr  = relationshipId,
                                 Cstate_Attr = "print"
                             },
                             Choice_0 = CT_BlipFillProperties.ChoiceBucket_0.stretch,
                             Stretch  = new CT_StretchInfoProperties
                             {
                                 FillRect = new CT_RelativeRect
                                 {
                                     B_Attr = WordOpenXmlUtils.ThousandthsOfAPercentInverse((double)size.Height, (double)desiredSize.Height),
                                     R_Attr = WordOpenXmlUtils.ThousandthsOfAPercentInverse((double)size.Width, (double)desiredSize.Width)
                                 }
                             }
                         },
                         SpPr = new CT_ShapeProperties
                         {
                             Xfrm = new CT_Transform2D
                             {
                                 Off = new CT_Point2D
                                 {
                                     X_Attr = 0L,
                                     Y_Attr = 0L
                                 },
                                 Ext = new AspNetCore.ReportingServices.Rendering.WordRenderer.WordOpenXmlRenderer.Parser.drawingml.x2006.main.CT_PositiveSize2D
                                 {
                                     Cx_Attr = desiredSize.Width,
                                     Cy_Attr = desiredSize.Height
                                 }
                             },
                             Choice_0 = CT_ShapeProperties.ChoiceBucket_0.prstGeom,
                             PrstGeom = new CT_PresetGeometry2D
                             {
                                 Prst_Attr = "rect",
                                 AvLst     = new CT_GeomGuideList()
                             }
                         }
                     }
                 }
             }
         }
     };
 }
Exemple #12
0
 public CT_Macrosheet()
 {
     this.extLstField = new CT_ExtensionList();
     this.oleObjectsField = new List<CT_OleObject>();
     this.pictureField = new CT_SheetBackgroundPicture();
     this.legacyDrawingHFField = new CT_LegacyDrawing();
     this.legacyDrawingField = new CT_LegacyDrawing();
     this.drawingField = new CT_Drawing();
     this.customPropertiesField = new List<CT_CustomProperty>();
     this.colBreaksField = new CT_PageBreak();
     this.rowBreaksField = new CT_PageBreak();
     this.headerFooterField = new CT_HeaderFooter();
     this.pageSetupField = new CT_PageSetup();
     this.pageMarginsField = new CT_PageMargins();
     this.printOptionsField = new CT_PrintOptions();
     this.conditionalFormattingField = new List<CT_ConditionalFormatting>();
     this.phoneticPrField = new CT_PhoneticPr();
     this.customSheetViewsField = new List<CT_CustomSheetView>();
     this.dataConsolidateField = new CT_DataConsolidate();
     this.sortStateField = new CT_SortState();
     this.autoFilterField = new CT_AutoFilter();
     this.sheetProtectionField = new CT_SheetProtection();
     this.sheetDataField = new List<CT_Row>();
     this.colsField = new List<CT_Col>();
     this.sheetFormatPrField = new CT_SheetFormatPr();
     this.sheetViewsField = new CT_SheetViews();
     this.dimensionField = new CT_SheetDimension();
     this.sheetPrField = new CT_SheetPr();
 }
Exemple #13
0
 public static CT_Drawing Parse(XmlNode node, XmlNamespaceManager namespaceManager)
 {
     if (node == null)
         return null;
     CT_Drawing ctObj = new CT_Drawing();
     ctObj.id = XmlHelper.ReadString(node.Attributes["id", PackageNamespaces.SCHEMA_RELATIONSHIPS]);
     return ctObj;
 }
Exemple #14
0
 internal XSSFDrawing(PackagePart part, PackageRelationship rel)
     : base(part, rel)
 {
     this.drawing = CT_Drawing.Parse(part.GetInputStream());
 }
Exemple #15
0
 public XSSFDrawing()
 {
     this.drawing = XSSFDrawing.NewDrawing();
 }