Synced diff-scripts with TortoiseSVN
[TortoiseGit.git] / contrib / diff-scripts / diff-ppt.js
blob49074a759d8273d12fa2773f978c095f7efd70ec
1 // extensions: ppt;pptx;pptm\r
2 //\r
3 // TortoiseSVN Diff script for Powerpoint files\r
4 //\r
5 // Copyright (C) 2004-2009 the TortoiseSVN team\r
6 // This file is distributed under the same license as TortoiseSVN\r
7 //\r
8 // Last commit by:\r
9 // $Author$\r
10 // $Date$\r
11 // $Rev$\r
12 //\r
13 // Authors:\r
14 // Arne Moor, 2006\r
15 //\r
17 /*\r
18 This script starts PowerPoint and compares the two given presentations.\r
19 To better see the changes and get the highlighting feature of PowerPoint\r
20 click on "Apply all changes to the presentation" on the reviewing toolbar.\r
21 */\r
23 function PptAppMajorVersion(PowerPoint)\r
24 {\r
25     var pptVersion;\r
26     try\r
27     {\r
28         pptVersion = PowerPoint.Version.toString();\r
29         if (pptVersion.indexOf(".") > 0)\r
30         {\r
31             pptVersion = pptVersion.substr(0, pptVersion.indexOf("."));\r
32         }\r
33         if (pptVersion === "")\r
34         {\r
35             return 0;\r
36         }\r
37         else\r
38         {\r
39             return parseInt(pptVersion, 10);\r
40         }\r
41     }\r
42     catch (e)\r
43     {\r
44         return 0;\r
45     }\r
46 }\r
48 var objArgs, num, sBasePpt, sNewPpt, objScript, powerpoint, source;\r
50 objArgs = WScript.Arguments;\r
51 num = objArgs.length;\r
52 if (num < 2)\r
53 {\r
54     WScript.Echo("Usage: [CScript | WScript] diff-ppt.js base.ppt new.ppt");\r
55     WScript.Quit(1);\r
56 }\r
58 sBasePpt = objArgs(0);\r
59 sNewPpt = objArgs(1);\r
61 objScript = new ActiveXObject("Scripting.FileSystemObject");\r
63 if (!objScript.FileExists(sBasePpt))\r
64 {\r
65     WScript.Echo("File " + sBasePpt + " does not exist.  Cannot compare the presentations.");\r
66     WScript.Quit(1);\r
67 }\r
69 if (!objScript.FileExists(sNewPpt))\r
70 {\r
71     WScript.Echo("File " + sNewPpt + " does not exist.  Cannot compare the presentations.");\r
72     WScript.Quit(1);\r
73 }\r
75 objScript = null;\r
77 try\r
78 {\r
79     powerpoint = WScript.CreateObject("Powerpoint.Application");\r
80 }\r
81 catch (e)\r
82 {\r
83     WScript.Echo("You must have Microsoft Powerpoint installed to perform this operation.");\r
84     WScript.Quit(1);\r
85 }\r
87 if (PptAppMajorVersion(powerpoint) === 12)\r
88 {\r
89     WScript.Echo("Microsoft Powerpoint 2007 doesn't provide the DIFF features any more. Sorry!");\r
90     WScript.Quit(1);\r
91 }\r
92 else\r
93 {\r
94     powerpoint.visible = true;\r
96     // Open the original (base) document\r
97     source = powerpoint.Presentations.Open(sBasePpt);\r
99     // Merge the new document, to show the changes\r
100     source.Merge(sNewPpt);\r
102     // Mark the comparison presentation as saved to prevent the annoying\r
103     // "Save as" dialog from appearing.\r
104     powerpoint.ActivePresentation.Saved = 1;\r