Exemplo n.º 1
0
        protected ExcelControl(ExcelDrawings drawings, XmlNode drawingNode, string name, ExcelGroupShape parent = null) :
            base(drawings, drawingNode, "xdr:sp", "xdr:nvSpPr/xdr:cNvPr", parent)
        {
            var ws = drawings.Worksheet;

            //Drawing Xml
            XmlElement spElement = CreateShapeNode();

            spElement.InnerXml = ControlStartDrawingXml();
            CreateClientData();

            ControlPropertiesXml = new XmlDocument();
            ControlPropertiesXml.LoadXml(ControlStartControlPrXml());
            int id = ws.SheetId;

            ControlPropertiesUri  = GetNewUri(ws._package.ZipPackage, "/xl/ctrlProps/ctrlProp{0}.xml", ref id);
            ControlPropertiesPart = ws._package.ZipPackage.CreatePart(ControlPropertiesUri, ContentTypes.contentTypeControlProperties);
            var rel = ws.Part.CreateRelationship(ControlPropertiesUri, TargetMode.Internal, ExcelPackage.schemaRelationships + "/ctrlProp");

            //Vml
            _vml     = drawings.Worksheet.VmlDrawings.AddControl(this, name);
            _vmlProp = XmlHelperFactory.Create(_vml.NameSpaceManager, _vml.GetNode("x:ClientData"));

            //Control in worksheet xml
            XmlNode ctrlNode = ws.CreateControlContainerNode();

            ((XmlElement)ws.TopNode).SetAttribute("xmlns:xdr", ExcelPackage.schemaSheetDrawings);      //Make sure the namespace exists
            ((XmlElement)ws.TopNode).SetAttribute("xmlns:x14", ExcelPackage.schemaMainX14);            //Make sure the namespace exists
            ((XmlElement)ws.TopNode).SetAttribute("xmlns:mc", ExcelPackage.schemaMarkupCompatibility); //Make sure the namespace exists
            ctrlNode.InnerXml = GetControlStartWorksheetXml(rel.Id);
            _control          = new ControlInternal(NameSpaceManager, ctrlNode.FirstChild);
            _ctrlProp         = XmlHelperFactory.Create(NameSpaceManager, ControlPropertiesXml.DocumentElement);
        }
Exemplo n.º 2
0
 internal ExcelControl(ExcelDrawings drawings, XmlNode drawingNode, ControlInternal control, ZipPackagePart ctrlPropPart, XmlDocument ctrlPropXml, ExcelGroupShape parent = null) :
     base(drawings, drawingNode, "xdr:sp", "xdr:nvSpPr/xdr:cNvPr", parent)
 {
     _control              = control;
     _vml                  = (ExcelVmlDrawingControl)drawings.Worksheet.VmlDrawings[LegacySpId];
     _vmlProp              = XmlHelperFactory.Create(_vml.NameSpaceManager, _vml.GetNode("x:ClientData"));
     ControlPropertiesXml  = ctrlPropXml;
     ControlPropertiesPart = ctrlPropPart;
     ControlPropertiesUri  = ctrlPropPart.Uri;
     _ctrlProp             = XmlHelperFactory.Create(NameSpaceManager, ctrlPropXml.DocumentElement);
 }