// Decalaring a class Response function Response() { this.element = 'Response'; this.nestables = ['Speak', 'Play', 'GetDigits', 'Record', 'Dial', 'Message', 'Redirect', 'Wait', 'Hangup', 'PreAnswer', 'Conference', 'DTMF']; this.valid_attributes = []; this.elem = xmlBuilder.begin().ele(this.element); }
xmlrpcBuilder.buildMethodResponseWithAFault = function(fault, callback) { // Creates the boiler plate for the XML-RPC response var xml = xmlBuilder.begin('methodResponse', { version: '1.0' }) // Adds the fault to the XML-RPC call var faultXml = xml.ele('fault') serializeParam(fault, faultXml) // One more up() to include the <?xml ...> declaration var xmlString = xml.up().toString() callback(null, xmlString) }
return new Promise((resolve, reject) => { let xmlProlog = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'; let xmlString = ''; let wsXML = xml.begin({ 'allowSurrogateChars': true, }, (chunk) => { xmlString += chunk; }) .ele('worksheet') .att('mc:Ignorable', 'x14ac') .att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main') .att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006') .att('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships') .att('xmlns:x14ac', 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac'); // Excel complains if specific elements on not in the correct order in the XML doc as defined in §M.2.2 let promiseObj = { xml: wsXML, ws: ws }; _addSheetPr(promiseObj) .then(_addDimension) .then(_addSheetViews) .then(_addSheetFormatPr) .then(_addCols) .then(_addSheetData) .then(_addSheetProtection) .then(_addAutoFilter) .then(_addMergeCells) .then(_addConditionalFormatting) .then(_addDataValidations) .then(_addHyperlinks) .then(_addPrintOptions) .then(_addPageMargins) .then(_addLegacyDrawing) .then(_addPageSetup) .then(_addPageBreaks) .then(_addHeaderFooter) .then(_addDrawing) .then((promiseObj) => { return new Promise((resolve, reject) => { wsXML.end(); resolve(xmlString); }); }) .then((xml) => { resolve(xml); }) .catch((e) => { throw new Error(e.stack); }); });
xmlrpcBuilder.buildMethodResponse = function(value, callback) { // Creates the boiler plate for the XML-RPC response var xml = xmlBuilder.begin('methodResponse', { version: '1.0' }) // Adds the parameter to the XML-RPC call var paramXml = xml.ele('params') .ele('param') serializeParam(value, paramXml) // One more up() to include the <?xml ...> declaration var xmlString = xml.up().toString() callback(null, xmlString) }
return new Promise((resolve, reject) => { // do not add XML prolog to document const vmlXml = xml.begin().ele('xml'); vmlXml.att('xmlns:v', 'urn:schemas-microsoft-com:vml') vmlXml.att('xmlns:o', 'urn:schemas-microsoft-com:office:office'); vmlXml.att('xmlns:x', 'urn:schemas-microsoft-com:office:excel'); const sl = vmlXml.ele('o:shapelayout').att('v:ext', 'edit'); sl.ele('o:idmap').att('v:ext', 'edit').att('data', ws.sheetId); const st = vmlXml.ele('v:shapetype') .att('id', '_x0000_t202') .att('coordsize', '21600,21600') .att('o:spt', '202') .att('path', 'm,l,21600r21600,l21600,xe'); st.ele('v:stroke').att('joinstyle', 'miter'); st.ele('v:path').att('gradientshapeok', 't').att('o:connecttype', 'rect'); Object.keys(ws.comments).forEach((ref) => { const {row, col, position, marginLeft, marginTop, width, height, zIndex, visibility, fillColor} = ws.comments[ref]; const shape = vmlXml.ele('v:shape'); shape.att('id', `_${ws.sheetId}_${row}_${col}`); shape.att('type', "#_x0000_t202"); shape.att('style', `position:${position};margin-left:${marginLeft};margin-top:${marginTop};width:${width};height:${height};z-index:${zIndex};visibility:${visibility}`); shape.att('fillcolor', fillColor); shape.att('o:insetmode', 'auto'); shape.ele('v:path').att('o:connecttype', 'none'); const tb = shape.ele('v:textbox').att('style', 'mso-direction-alt:auto'); tb.ele('div').att('style', 'text-align:left'); const cd = shape.ele('x:ClientData').att('ObjectType', 'Note'); cd.ele('x:MoveWithCells'); cd.ele('x:SizeWithCells'); cd.ele('x:AutoFill').text('False'); cd.ele('x:Row').text(row - 1); cd.ele('x:Column').text(col - 1); }); let xmlString = vmlXml.doc().end(); resolve(xmlString); });