Fixed issue #1220: ext/CrashServer/CommonLibs/Zlib/Zlib.vcproj immediate dir Win32...
[TortoiseGit.git] / contrib / other / diff-scripts / diff-odt.vbs
blob0d2c4eabb4f542130fcb6368df31c4e867014b9d
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
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
16 dim objArgs,num,sBaseDoc,sNewDoc,objScript,word,destination
18 Set objArgs = WScript.Arguments
19 num = objArgs.Count
20 if num < 2 then
21 MsgBox "Usage: [CScript | WScript] diff-odt.vbs base.odt new.odt", vbExclamation, "Invalid arguments"
22 WScript.Quit 1
23 end if
25 sBaseDoc=objArgs(0)
26 sNewDoc=objArgs(1)
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"
31 Wscript.Quit 1
32 End If
33 If objScript.FileExists(sNewDoc) = False Then
34 MsgBox "File " + sNewDoc +" does not exist. Cannot compare the documents.", vbExclamation, "File not found"
35 Wscript.Quit 1
36 End If
38 Set objScript = Nothing
40 On Error Resume Next
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."
46 Wscript.Quit 1
47 End If
49 On Error Goto 0
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
58 End If
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
78 Dim oPropertyValue(0)
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)
84 'Set the frame
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