Cleanup
[TortoiseGit.git] / contrib / other / diff-scripts / merge-sxw.vbs
blobe80631e041b2f593cf523b12e4f9b6722ef1a879
2 ' TortoiseSVN Merge script for Open Office Writer files
4 ' Copyright (C) 2004-2008 the TortoiseSVN team
5 ' This file is distributed under the same license as TortoiseSVN
7 ' Last commit by:
8 ' $Author: steveking $
9 ' $Date: 2008-06-17 03:36:28 +0800 (Tue, 17 Jun 2008) $
10 ' $Rev: 13285 $
12 ' Authors:
13 ' Jonathan Ashley, 2007
14 ' Stefan Küng, 2006
17 dim objArgs,num,sBaseDoc,sMergedDoc,sTheirDoc,sMyDoc,objScript,word,destination
19 Set objArgs = WScript.Arguments
20 num = objArgs.Count
21 if num < 4 then
22 MsgBox "Usage: [CScript | WScript] merge-sxw.vbs %merged %theirs %mine %base", vbExclamation, "Invalid arguments"
23 WScript.Quit 1
24 end if
26 sMergedDoc=objArgs(0)
27 sTheirDoc=objArgs(1)
28 sMyDoc=objArgs(2)
29 sBaseDoc=objArgs(3)
31 Set objScript = CreateObject("Scripting.FileSystemObject")
32 If objScript.FileExists(sMyDoc) = False Then
33 MsgBox "File " + sMyDoc +" does not exist. Cannot compare the documents.", vbExclamation, "File not found"
34 Wscript.Quit 1
35 End If
36 If objScript.FileExists(sTheirDoc) = False Then
37 MsgBox "File " + sTheirDoc +" does not exist. Cannot compare the documents.", vbExclamation, "File not found"
38 Wscript.Quit 1
39 End If
41 Set objScript = Nothing
43 On Error Resume Next
44 'The service manager is always the starting point
45 'If there is no office running then an office is started
46 Set objServiceManager= Wscript.CreateObject("com.sun.star.ServiceManager")
47 If Err.Number <> 0 Then
48 Wscript.Echo "You must have OpenOffice installed to perform this operation."
49 Wscript.Quit 1
50 End If
52 On Error Goto 0
53 'Create the DesktopSet
54 Set objDesktop = objServiceManager.createInstance("com.sun.star.frame.Desktop")
55 'Adjust the paths for OO
56 sMyDoc=Replace(sMyDoc, "\", "/")
57 sMyDoc=Replace(sMyDoc, ":", "|")
58 sMyDoc=Replace(sMyDoc, "%", "%25")
59 sMyDoc=Replace(sMyDoc, " ", "%20")
60 sMyDoc="file:///"&sMyDoc
61 sTheirDoc=Replace(sTheirDoc, "\", "/")
62 sTheirDoc=Replace(sTheirDoc, ":", "|")
63 sTheirDoc=Replace(sTheirDoc, "%", "%25")
64 sTheirDoc=Replace(sTheirDoc, " ", "%20")
65 sTheirDoc="file:///"&sTheirDoc
67 'Open the %mine document
68 Dim oPropertyValue(0)
69 Set oPropertyValue(0) = objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
70 oPropertyValue(0).Name = "ShowTrackedChanges"
71 oPropertyValue(0).Value = true
72 Set objDocument=objDesktop.loadComponentFromURL(sMyDoc,"_blank", 0, oPropertyValue)
74 'Set the frame
75 Set Frame = objDesktop.getCurrentFrame
77 Set dispatcher=objServiceManager.CreateInstance("com.sun.star.frame.DispatchHelper")
79 'Execute the comparison
80 Dispatcher.executeDispatch Frame, ".uno:ShowTrackedChanges", "", 0, oPropertyValue
81 oPropertyValue(0).Name = "URL"
82 oPropertyValue(0).Value = sTheirDoc
83 Dispatcher.executeDispatch Frame, ".uno:CompareDocuments", "", 0, oPropertyValue