OSDN Git Service

Pick Ref: Prepare ref picker to be able to leave out some ref types.
[tortoisegit/TortoiseGitJp.git] / contrib / other / diff-scripts / merge-docx.js
1 //\r
2 // TortoiseSVN Merge script for Word Doc files\r
3 //\r
4 // Copyright (C) 2004-2008 the TortoiseSVN team\r
5 // This file is distributed under the same license as TortoiseSVN\r
6 //\r
7 // Last commit by:\r
8 // $Author: steveking $\r
9 // $Date: 2008-07-26 14:49:59 +0800 (Sat, 26 Jul 2008) $\r
10 // $Rev: 13557 $\r
11 //\r
12 // Authors:\r
13 // Dan Sheridan, 2008\r
14 // Davide Orlandi and Hans-Emil Skogh, 2005\r
15 //\r
16 \r
17 var objArgs,num,sTheirDoc,sMyDoc,sBaseDoc,sMergedDoc,objScript,word,baseDoc,WSHShell;\r
18 \r
19 var vbExclamation = "!"; //+pa\r
20 \r
21 objArgs = WScript.Arguments;\r
22 num = objArgs.length;\r
23 if (num < 4)\r
24 {\r
25    WScript.Echo("Usage: [CScript | WScript] merge-doc.js merged.doc theirs.doc mine.doc base.doc");\r
26    WScript.Quit(1);\r
27 }\r
28 \r
29 sMergedDoc=objArgs(0);\r
30 sTheirDoc=objArgs(1);\r
31 sMyDoc=objArgs(2);   //?? unused??\r
32 sBaseDoc=objArgs(3);\r
33 \r
34 objScript = new ActiveXObject("Scripting.FileSystemObject")\r
35 if ( ! objScript.FileExists(sTheirDoc))\r
36 {\r
37     WScript.Echo("File " + sTheirDoc +" does not exist.  Cannot compare the documents.", vbExclamation, "File not found");\r
38     WScript.Quit(1);\r
39 }\r
40 if ( ! objScript.FileExists(sMergedDoc))\r
41 {\r
42     WScript.Echo("File " + sMergedDoc +" does not exist.  Cannot compare the documents.", vbExclamation, "File not found");\r
43     WScript.Quit(1);\r
44 }\r
45 \r
46 objScript = null\r
47 \r
48 try\r
49 {\r
50         word = WScript.CreateObject("Word.Application");\r
51 }\r
52 catch(e)\r
53 {\r
54    WScript.Echo("You must have Microsoft Word installed to perform this operation.");\r
55    WScript.Quit(1);\r
56 }\r
57 \r
58 word.visible = true\r
59 \r
60 // Open the base document\r
61 baseDoc = word.Documents.Open(sTheirDoc); //?? base or their??\r
62 \r
63 // Merge into the "My" document\r
64 if (Number(word.Version) < 12)\r
65 {\r
66         baseDoc.Compare(sMergedDoc);\r
67 } else {\r
68         baseDoc.Merge(sMergedDoc);\r
69 }\r
70 \r
71 // Show the merge result\r
72 if (Number(word.Version) < 12)\r
73 {\r
74         word.ActiveDocument.Windows(1).Visible = 1;\r
75 }\r
76 \r
77 // Close the first document\r
78 if (Number(word.Version) >= 10)\r
79 {\r
80    baseDoc.Close();\r
81 }\r
82 \r
83 // Show usage hint message\r
84 WSHShell = WScript.CreateObject("WScript.Shell");\r
85 if(WSHShell.Popup("You have to accept or reject the changes before\nsaving the document to prevent future problems.\n\nWould you like to see a help page on how to do this?", 0, "TSVN Word Merge", 4 + 64) == 6)\r
86 {\r
87     WSHShell.Run("http://office.microsoft.com/en-us/assistance/HP030823691033.aspx");\r
88 }\r