2 ' TortoiseSVN Diff script for Open Office Text 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
16 dim objArgs
,num
,sBaseDoc
,sNewDoc
,objScript
,word
,destination
18 Set objArgs
= WScript
.Arguments
21 MsgBox
"Usage: [CScript | WScript] diff-odt.vbs base.odt new.odt", vbExclamation
, "Invalid arguments"
28 Set objScript
= CreateObject("Scripting.FileSystemObject")
29 If objScript
.FileExists(sBaseDoc
) = False Then
30 MsgBox
"File " + sBaseDoc
+" does not exist. Cannot compare the documents.", vbExclamation
, "File not found"
33 If objScript
.FileExists(sNewDoc
) = False Then
34 MsgBox
"File " + sNewDoc
+" does not exist. Cannot compare the documents.", vbExclamation
, "File not found"
38 Set objScript
= Nothing
41 'The service manager is always the starting point
42 'If there is no office running then an office is started
43 Set objServiceManager
= Wscript
.CreateObject("com.sun.star.ServiceManager")
44 If Err
.Number
<> 0 Then
45 Wscript
.Echo
"You must have OpenOffice installed to perform this operation."
51 'Because this is a diff, TortoiseSVN marks the files as read-only.
52 'However, OpenOffice will not compare any file with that flag set.
53 'Make sure we un-set that flag.
54 Set objFSO
= CreateObject("Scripting.FileSystemObject")
55 Set objFile
= objFSO
.GetFile(sNewDoc
)
56 If (objFile
.Attributes
AND 1)=1 Then
57 objFile
.Attributes
= objFile
.Attributes XOR
1
60 'Create the DesktopSet
61 Set objDesktop
= objServiceManager
.createInstance("com.sun.star.frame.Desktop")
62 Set objUriTranslator
= objServiceManager
.createInstance("com.sun.star.uri.ExternalUriReferenceTranslator")
63 'Adjust the paths for OO
64 sBaseDoc
=Replace(sBaseDoc
, "\", "/")
65 sBaseDoc
=Replace(sBaseDoc
, ":", "|")
66 sBaseDoc
=Replace(sBaseDoc
, "%", "%25")
67 sBaseDoc
=Replace(sBaseDoc
, " ", "%20")
68 sBaseDoc
="file:///"&sBaseDoc
69 sBaseDoc
=objUriTranslator
.translateToInternal(sBaseDoc
)
70 sNewDoc
=Replace(sNewDoc
, "\", "/")
71 sNewDoc
=Replace(sNewDoc
, ":", "|")
72 sNewDoc
=Replace(sNewDoc
, "%", "%25")
73 sNewDoc
=Replace(sNewDoc
, " ", "%20")
74 sNewDoc
="file:///"&sNewDoc
75 sNewDoc
=objUriTranslator
.translateToInternal(sNewDoc
)
77 'Open the %base document
79 Set oPropertyValue(0) = objServiceManager
.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
80 oPropertyValue(0).Name
= "ShowTrackedChanges"
81 oPropertyValue(0).Value
= true
82 Set objDocument
=objDesktop
.loadComponentFromURL(sNewDoc
,"_blank", 0, oPropertyValue
)
85 Set Frame
= objDesktop
.getCurrentFrame
87 Set dispatcher
=objServiceManager
.CreateInstance("com.sun.star.frame.DispatchHelper")
89 'Execute the comparison
90 dispatcher
.executeDispatch Frame
, ".uno:ShowTrackedChanges", "", 0, oPropertyValue
91 oPropertyValue(0).Name
= "URL"
92 oPropertyValue(0).Value
= sBaseDoc
93 dispatcher
.executeDispatch Frame
, ".uno:CompareDocuments", "", 0, oPropertyValue