87bcd0ca44e3bf265b9589c1a7cbb87feac4351b
3 ' TortoiseSVN Diff script for Open Office Text files
5 ' Copyright (C) 2004-2009 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
,sNewDoc
,objScript
,word
,destination
19 Set objArgs
= WScript
.Arguments
22 MsgBox
"Usage: [CScript | WScript] diff-odt.vbs base.odt new.odt", vbExclamation
, "Invalid arguments"
29 Set objScript
= CreateObject("Scripting.FileSystemObject")
30 If objScript
.FileExists(sBaseDoc
) = False Then
31 MsgBox
"File " + sBaseDoc
+" does not exist. Cannot compare the documents.", vbExclamation
, "File not found"
34 If objScript
.FileExists(sNewDoc
) = False Then
35 MsgBox
"File " + sNewDoc
+" does not exist. Cannot compare the documents.", vbExclamation
, "File not found"
38 'remove the file write protection
39 objScript
.GetFile(sBaseDoc
).Attributes
= objScript
.GetFile(sBaseDoc
).Attributes
And Not 1
40 objScript
.GetFile(sNewDoc
).Attributes
= objScript
.GetFile(sNewDoc
).Attributes
And Not 1
42 Set objScript
= Nothing
45 'The service manager is always the starting point
46 'If there is no office running then an office is started
47 Set objServiceManager
= Wscript
.CreateObject("com.sun.star.ServiceManager")
48 If Err
.Number
<> 0 Then
49 Wscript
.Echo
"You must have OpenOffice installed to perform this operation."
55 'Because this is a diff, TortoiseSVN marks the files as read-only.
56 'However, OpenOffice will not compare any file with that flag set.
57 'Make sure we un-set that flag.
58 Set objFSO
= CreateObject("Scripting.FileSystemObject")
59 Set objFile
= objFSO
.GetFile(sNewDoc
)
60 If (objFile
.Attributes
AND 1)=1 Then
61 objFile
.Attributes
= objFile
.Attributes XOR
1
64 'Create the DesktopSet
65 Set objDesktop
= objServiceManager
.createInstance("com.sun.star.frame.Desktop")
66 Set objUriTranslator
= objServiceManager
.createInstance("com.sun.star.uri.ExternalUriReferenceTranslator")
67 'Adjust the paths for OO
68 sBaseDoc
=Replace(sBaseDoc
, "\", "/")
69 sBaseDoc
=Replace(sBaseDoc
, ":", "|")
70 sBaseDoc
=Replace(sBaseDoc
, "%", "%25")
71 sBaseDoc
=Replace(sBaseDoc
, " ", "%20")
72 sBaseDoc
=Replace(sBaseDoc
, "#", "%23")
73 sBaseDoc
="file:///"&sBaseDoc
74 sBaseDoc
=objUriTranslator
.translateToInternal(sBaseDoc
)
75 sNewDoc
=Replace(sNewDoc
, "\", "/")
76 sNewDoc
=Replace(sNewDoc
, ":", "|")
77 sNewDoc
=Replace(sNewDoc
, "%", "%25")
78 sNewDoc
=Replace(sNewDoc
, " ", "%20")
79 sNewDoc
=Replace(sNewDoc
, "#", "%23")
80 sNewDoc
="file:///"&sNewDoc
81 sNewDoc
=objUriTranslator
.translateToInternal(sNewDoc
)
83 'Open the %base document
85 Set oPropertyValue(0) = objServiceManager
.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
86 oPropertyValue(0).Name
= "ShowTrackedChanges"
87 oPropertyValue(0).Value
= true
88 Set objDocument
=objDesktop
.loadComponentFromURL(sNewDoc
,"_blank", 0, oPropertyValue
)
91 Set Frame
= objDesktop
.getCurrentFrame
93 Set dispatcher
=objServiceManager
.CreateInstance("com.sun.star.frame.DispatchHelper")
95 'Execute the comparison
96 dispatcher
.executeDispatch Frame
, ".uno:ShowTrackedChanges", "", 0, oPropertyValue
97 oPropertyValue(0).Name
= "URL"
98 oPropertyValue(0).Value
= sBaseDoc
99 dispatcher
.executeDispatch Frame
, ".uno:CompareDocuments", "", 0, oPropertyValue