Ejemplo n.º 1
0
        internal void Read(Stream is1)
        {
            StreamReader sr   = new StreamReader(is1);
            string       data = sr.ReadToEnd().Replace("<br>", "");
            XDocument    doc  = XDocument.Load(new StringReader(data));

            //InflaterInputStream iis = (InflaterInputStream)is1;

            //Stream vmlsm = new EvilUnclosedBRFixingInputStream(is1); --TODO:: add later

            XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable());

            nsmgr.AddNamespace("o", "urn:schemas-microsoft-com:office:office");
            nsmgr.AddNamespace("x", "urn:schemas-microsoft-com:office:excel");
            nsmgr.AddNamespace("v", "urn:schemas-microsoft-com:vml");
            _items = new ArrayList();
            var nodes = doc.XPathSelectElements("/xml/*", nsmgr);

            foreach (XElement nd in nodes)
            {
                string xmltext = nd.OuterXml();
                if (nd.Name.LocalName == QNAME_SHAPE_LAYOUT.Name)
                {
                    CT_ShapeLayout sl = CT_ShapeLayout.Parse(nd, nsmgr);
                    _items.Add(sl);
                }
                else if (nd.Name.LocalName == QNAME_SHAPE_TYPE.Name)
                {
                    CT_Shapetype st     = CT_Shapetype.Parse(nd, nsmgr);
                    String       typeid = st.id;
                    if (typeid != null)
                    {
                        MatchCollection m = ptrn_shapeTypeId.Matches(typeid);
                        if (m.Count > 0)
                        {
                            _shapeTypeId = Math.Max(_shapeTypeId, int.Parse(m[0].Groups[1].Value));
                        }
                    }
                    _items.Add(st);
                }
                else if (nd.Name.LocalName == QNAME_SHAPE.Name)
                {
                    CT_Shape shape = CT_Shape.Parse(nd, nsmgr);
                    String   id    = shape.id;
                    if (id != null)
                    {
                        MatchCollection m = ptrn_shapeId.Matches(id);
                        if (m.Count > 0)
                        {
                            _shapeId = Math.Max(_shapeId, int.Parse(m[0].Groups[1].Value));
                        }
                    }
                    _items.Add(shape);
                }
                else
                {
                    _items.Add(nd);
                }
            }
        }
Ejemplo n.º 2
0
        internal void Read(Stream is1)
        {
            XmlDocument xmlDocument = new XmlDocument();
            string      end         = new StreamReader(is1).ReadToEnd();

            xmlDocument.LoadXml(end.Replace("<br>", ""));
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDocument.NameTable);

            nsmgr.AddNamespace("o", "urn:schemas-microsoft-com:office:office");
            nsmgr.AddNamespace("x", "urn:schemas-microsoft-com:office:excel");
            nsmgr.AddNamespace("v", "urn:schemas-microsoft-com:vml");
            this._items = new ArrayList();
            foreach (XmlNode selectNode in xmlDocument.SelectNodes("/xml/*", nsmgr))
            {
                string outerXml = selectNode.OuterXml;
                if (selectNode.LocalName == XSSFVMLDrawing.QNAME_SHAPE_LAYOUT.Name)
                {
                    this._items.Add((object)CT_ShapeLayout.Parse(outerXml));
                }
                else if (selectNode.LocalName == XSSFVMLDrawing.QNAME_SHAPE_TYPE.Name)
                {
                    CT_Shapetype ctShapetype = CT_Shapetype.Parse(outerXml);
                    this._shapeTypeId = ctShapetype.id;
                    this._items.Add((object)ctShapetype);
                }
                else if (selectNode.LocalName == XSSFVMLDrawing.QNAME_SHAPE.Name)
                {
                    CT_Shape ctShape = CT_Shape.Parse(outerXml);
                    string   id      = ctShape.id;
                    if (id != null)
                    {
                        MatchCollection matchCollection = XSSFVMLDrawing.ptrn_shapeId.Matches(id);
                        if (matchCollection.Count > 0)
                        {
                            this._shapeId = Math.Max(this._shapeId, int.Parse(matchCollection[0].Groups[1].Value));
                        }
                    }
                    this._items.Add((object)ctShape);
                }
                else
                {
                    this._items.Add((object)selectNode);
                }
            }
        }
Ejemplo n.º 3
0
        internal void Read(Stream is1)
        {
            XmlDocument doc = new XmlDocument();

            //InflaterInputStream iis = (InflaterInputStream)is1;
            StreamReader sr   = new StreamReader(is1);
            string       data = sr.ReadToEnd();

            //Stream vmlsm = new EvilUnclosedBRFixingInputStream(is1); --TODO:: add later

            doc.LoadXml(
                data.Replace("<br>", "")
                );

            XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);

            nsmgr.AddNamespace("o", "urn:schemas-microsoft-com:office:office");
            nsmgr.AddNamespace("x", "urn:schemas-microsoft-com:office:excel");
            nsmgr.AddNamespace("v", "urn:schemas-microsoft-com:vml");
            _items = new ArrayList();
            XmlNodeList nodes = doc.SelectNodes("/xml/*", nsmgr);

            foreach (XmlNode nd in nodes)
            {
                string xmltext = nd.OuterXml;
                if (nd.LocalName == QNAME_SHAPE_LAYOUT.Name)
                {
                    CT_ShapeLayout sl = CT_ShapeLayout.Parse(nd, nsmgr);
                    _items.Add(sl);
                }
                else if (nd.LocalName == QNAME_SHAPE_TYPE.Name)
                {
                    CT_Shapetype st = CT_Shapetype.Parse(nd, nsmgr);
                    _items.Add(st);
                    _shapeTypeId = st.id;
                }
                else if (nd.LocalName == QNAME_SHAPE.Name)
                {
                    CT_Shape shape = CT_Shape.Parse(nd, nsmgr);
                    String   id    = shape.id;
                    if (id != null)
                    {
                        MatchCollection m = ptrn_shapeId.Matches(id);
                        if (m.Count > 0)
                        {
                            _shapeId = Math.Max(_shapeId, int.Parse(m[0].Groups[1].Value));
                        }
                    }
                    _items.Add(shape);
                }
                else
                {
                    /// How to port following java code??
                    //Document doc2;
                    //try
                    //{
                    //    InputSource is2 = new InputSource(new StringReader(obj.xmlText()));
                    //    doc2 = DocumentHelper.readDocument(is2);
                    //}
                    //catch (SAXException e)
                    //{
                    //    throw new XmlException(e.getMessage(), e);
                    //}

                    _items.Add(nd);
                }
            }
        }