1 ' extensions: ods;odt;sxw
3 ' TortoiseSVN Merge script for Open Office Calc files
5 ' Copyright (C) 2004-2009, 2012-2014 the TortoiseSVN team
6 ' This file is distributed under the same license as TortoiseSVN
14 ' Jonathan Ashley, 2007
15 ' Stefan Küng, 2006, 2009
17 dim objArgs
, num
, sBaseDoc
, sMergedDoc
, sTheirDoc
, sMyDoc
, objScript
19 Set objArgs
= WScript
.Arguments
22 MsgBox
"Usage: [CScript | WScript] merge-ods.vbs %merged %theirs %mine %base", vbExclamation
, "Invalid arguments"
26 sMergedDoc
= objArgs(0)
27 sTheirDoc
= objArgs(1)
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"
36 If objScript
.FileExists(sTheirDoc
) = False Then
37 MsgBox
"File " + sTheirDoc
+ " does not exist. Cannot compare the documents.", vbExclamation
, "File not found"
40 'remove the file write protection
41 objScript
.GetFile(sMyDoc
).Attributes
= objScript
.GetFile(sMyDoc
).Attributes
And Not 1
42 objScript
.GetFile(sTheirDoc
).Attributes
= objScript
.GetFile(sTheirDoc
).Attributes
And Not 1
44 Set objScript
= Nothing
47 'The service manager is always the starting point
48 'If there is no office running then an office is started
49 Set objServiceManager
= Wscript
.CreateObject("com.sun.star.ServiceManager")
50 If Err
.Number
<> 0 Then
51 Wscript
.Echo
"You must have OpenOffice installed to perform this operation."
56 'Create the DesktopSet
57 Set objDesktop
= objServiceManager
.createInstance("com.sun.star.frame.Desktop")
58 'Adjust the paths for OO
59 sMyDoc
= Replace(sMyDoc
, "\", "/")
60 sMyDoc
= Replace(sMyDoc
, ":", "|")
61 sMyDoc
= Replace(sMyDoc
, "%", "%25")
62 sMyDoc
= Replace(sMyDoc
, " ", "%20")
63 sMyDoc
= Replace(sMyDoc
, "#", "%23")
64 sMyDoc
= "file:///"&sMyDoc
65 sTheirDoc
= Replace(sTheirDoc
, "\", "/")
66 sTheirDoc
= Replace(sTheirDoc
, ":", "|")
67 sTheirDoc
= Replace(sTheirDoc
, "%", "%25")
68 sTheirDoc
= Replace(sTheirDoc
, " ", "%20")
69 sTheirDoc
= Replace(sTheirDoc
, "#", "%23")
70 sTheirDoc
= "file:///"&sTheirDoc
72 'Open the %mine document
74 Set oPropertyValue(0) = objServiceManager
.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
75 oPropertyValue(0).Name
= "ShowTrackedChanges"
76 oPropertyValue(0).Value
= true
77 Set objDocument
= objDesktop
.loadComponentFromURL(sMyDoc
, "_blank", 0, oPropertyValue
)
80 Set Frame
= objDesktop
.getCurrentFrame
82 Set dispatcher
= objServiceManager
.CreateInstance("com.sun.star.frame.DispatchHelper")
84 'Execute the comparison
85 Dispatcher
.executeDispatch Frame
, ".uno:ShowTrackedChanges", "", 0, oPropertyValue
86 oPropertyValue(0).Name
= "URL"
87 oPropertyValue(0).Value
= sTheirDoc
88 Dispatcher
.executeDispatch Frame
, ".uno:CompareDocuments", "", 0, oPropertyValue