Ignore /doc/source/en/TortoiseGit/git_doc/git-doc.xml
[TortoiseGit.git] / contrib / diff-scripts / diff-ppt.js
blob2a327ab3ac41f61a42fffa7dd51ad702fd40cb16
1 // extensions: ppt;pptx;pptm\r
2 //\r
3 // TortoiseSVN Diff script for Powerpoint files\r
4 //\r
5 // Copyright (C) 2004-2009, 2019 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     // disable macros\r
81     powerpoint.AutomationSecurity = 3; //msoAutomationSecurityForceDisable\r
82 }\r
83 catch (e)\r
84 {\r
85     WScript.Echo("You must have Microsoft Powerpoint installed to perform this operation.");\r
86     WScript.Quit(1);\r
87 }\r
89 if (PptAppMajorVersion(powerpoint) === 12)\r
90 {\r
91     WScript.Echo("Microsoft Powerpoint 2007 doesn't provide the DIFF features any more. Sorry!");\r
92     WScript.Quit(1);\r
93 }\r
94 else\r
95 {\r
96     powerpoint.visible = true;\r
98     // Open the original (base) document\r
99     source = powerpoint.Presentations.Open(sBasePpt);\r
101     // Merge the new document, to show the changes\r
102     source.Merge(sNewPpt);\r
104     // Mark the comparison presentation as saved to prevent the annoying\r
105     // "Save as" dialog from appearing.\r
106     powerpoint.ActivePresentation.Saved = 1;\r