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
9 ' $Date: 2008-06-17 03:36:28 +0800 (Tue, 17 Jun 2008) $
13 ' Jonathan Ashley, 2007
17 dim objArgs
,num
,sBaseDoc
,sMergedDoc
,sTheirDoc
,sMyDoc
,objScript
,word
,destination
19 Set objArgs
= WScript
.Arguments
22 MsgBox
"Usage: [CScript | WScript] merge-sxw.vbs %merged %theirs %mine %base", vbExclamation
, "Invalid arguments"
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"
41 Set objScript
= Nothing
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."
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
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
)
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