()
| 878 | var fileIndex = 0; |
| 879 | |
| 880 | function processOneFile() |
| 881 | { |
| 882 | var curFile = files[fileIndex]; |
| 883 | |
| 884 | try |
| 885 | { |
| 886 | var ext = path.extname(curFile); |
| 887 | |
| 888 | let fileContent = fs.readFileSync(curFile, ext === '.png' || ext === '.pdf' || ext === '.vsdx' ? null : 'utf-8'); |
| 889 | |
| 890 | if (ext === '.vsdx') |
| 891 | { |
| 892 | dummyWin.loadURL(`file://${codeDir}/vsdxImporter.html`); |
| 893 | |
| 894 | const contents = dummyWin.webContents; |
| 895 | |
| 896 | contents.on('did-finish-load', function() |
| 897 | { |
| 898 | contents.send('import', fileContent); |
| 899 | |
| 900 | ipcMain.once('import-success', function(e, xml) |
| 901 | { |
| 902 | if (!validateSender(e.senderFrame)) return null; |
| 903 | |
| 904 | expArgs.xml = xml; |
| 905 | startExport(); |
| 906 | }); |
| 907 | |
| 908 | ipcMain.once('import-error', function(e) |
| 909 | { |
| 910 | if (!validateSender(e.senderFrame)) return null; |
| 911 | |
| 912 | console.error('Error: cannot import VSDX file: ' + curFile); |
| 913 | next(); |
| 914 | }); |
| 915 | }); |
| 916 | } |
| 917 | else |
| 918 | { |
| 919 | if (ext === '.csv') |
| 920 | { |
| 921 | expArgs.csv = fileContent; |
| 922 | } |
| 923 | else if (ext === '.png') |
| 924 | { |
| 925 | expArgs.xmlEncoded = true; |
| 926 | expArgs.xml = Buffer.from(fileContent).toString('base64'); |
| 927 | } |
| 928 | else if (ext === '.pdf') |
| 929 | { |
| 930 | expArgs.pdfEncoded = true; |
| 931 | expArgs.xml = Buffer.from(fileContent).toString('base64'); |
| 932 | } |
| 933 | else if (ext === '.mmd' || ext === '.mermaid') |
| 934 | { |
| 935 | // Mermaid is converted to a diagram in the renderer |
| 936 | // (export3.html loads the Mermaid bundle); export.js |
| 937 | // handles the data.mermaid input. |
no test coverage detected