From 8b973e3749f9a8a0d5e4f787a9c1cb9c38c40885 Mon Sep 17 00:00:00 2001 From: Sup Yut Sum Date: Wed, 18 Jun 2014 19:50:36 +0800 Subject: [PATCH] VBS diff scripts: fix a few inconsistencies and remove unused variables Based on TortoiseSVN revision 25592 Signed-off-by: Sup Yut Sum --- contrib/diff-scripts/diff-dll.vbs | 34 +++++++++++++-------------- contrib/diff-scripts/diff-nb.vbs | 24 +++++++++---------- contrib/diff-scripts/diff-odt.vbs | 48 +++++++++++++++++++------------------- contrib/diff-scripts/diff-sxw.vbs | 34 +++++++++++++-------------- contrib/diff-scripts/merge-ods.vbs | 46 ++++++++++++++++++------------------ 5 files changed, 93 insertions(+), 93 deletions(-) diff --git a/contrib/diff-scripts/diff-dll.vbs b/contrib/diff-scripts/diff-dll.vbs index ae5f2e20a..67f33b290 100644 --- a/contrib/diff-scripts/diff-dll.vbs +++ b/contrib/diff-scripts/diff-dll.vbs @@ -2,7 +2,7 @@ ' ' TortoiseSVN Diff script for binary files ' -' Copyright (C) 2010 the TortoiseSVN team +' Copyright (C) 2010-2014 the TortoiseSVN team ' This file is distributed under the same license as TortoiseSVN ' ' Last commit by: @@ -21,27 +21,27 @@ bDiffers = False Set objArgs = WScript.Arguments num = objArgs.Count if num < 2 then - MsgBox "Usage: [CScript | WScript] compare.vbs base.doc new.doc", vbCritical, "Invalid arguments" + MsgBox "Usage: [CScript | WScript] diff-dll.vbs base.[dll|exe] new.[dll|exe]", vbCritical, "Invalid arguments" WScript.Quit 1 end if -sBaseDoc = objArgs(0) -sNewDoc = objArgs(1) +sBaseFile = objArgs(0) +sNewFile = objArgs(1) Set objFileSystem = CreateObject("Scripting.FileSystemObject") -If objFileSystem.FileExists(sBaseDoc) = False Then - MsgBox "File " + sBaseDoc +" does not exist. Cannot compare the files.", vbCritical, "File not found" +If objFileSystem.FileExists(sBaseFile) = False Then + MsgBox "File " + sBaseFile + " does not exist. Cannot compare the files.", vbCritical, "File not found" Wscript.Quit 1 End If -If objFileSystem.FileExists(sNewDoc) = False Then - MsgBox "File " + sNewDoc +" does not exist. Cannot compare the files.", vbCritical, "File not found" +If objFileSystem.FileExists(sNewFile) = False Then + MsgBox "File " + sNewFile + " does not exist. Cannot compare the files.", vbCritical, "File not found" Wscript.Quit 1 End If ' Compare file size dim fBaseFile, fNewFile -Set fBaseFile = objFileSystem.GetFile(sBaseDoc) -Set fNewFile = objFileSystem.GetFile(sNewDoc) +Set fBaseFile = objFileSystem.GetFile(sBaseFile) +Set fNewFile = objFileSystem.GetFile(sNewFile) If fBaseFile.size <> fNewFile.size Then bDiffers = True @@ -54,7 +54,7 @@ End If ' Compare files using fc.exe If bDiffers = False Then Set WshShell = WScript.CreateObject("WScript.Shell") - exitStatus = WshShell.Run("fc.exe """+sBaseDoc+""" """+sNewDoc+"""", 0, True) + exitStatus = WshShell.Run("fc.exe """ + sBaseFile + """ """ + sNewFile + """", 0, True) If exitStatus = 1 Then bDiffers = True sMessage = sMessage + "File content differs!" + vbCrLf @@ -64,12 +64,12 @@ If bDiffers = False Then End If ' Only compare versions if we are comparing exe:s or dll:s -If LCase(Right(sBaseDoc, 3)) = "exe" or LCase(Right(sNewDoc, 3)) = "exe" or _ - LCase(Right(sBaseDoc, 3)) = "dll" or LCase(Right(sNewDoc, 3)) = "dll" Then +If LCase(Right(sBaseFile, 3)) = "exe" or LCase(Right(sNewFile, 3)) = "exe" or _ + LCase(Right(sBaseFile, 3)) = "dll" or LCase(Right(sNewFile, 3)) = "dll" Then ' Compare version - sBaseVer = objFileSystem.GetFileVersion(sBaseDoc) - sNewVer = objFileSystem.GetFileVersion(sNewDoc) + sBaseVer = objFileSystem.GetFileVersion(sBaseFile) + sNewVer = objFileSystem.GetFileVersion(sNewFile) If Len(sBaseVer) = 0 and Len(sNewVer) = 0 Then sMessage = sMessage + "No version information available." @@ -83,10 +83,10 @@ End If ' Generate result message sBaseMessage = "Base" + vbCrLf _ - + " File: " + sBaseDoc + vbCrLf _ + + " File: " + sBaseFile + vbCrLf _ + sBaseMessage sNewMessage = + "New" + vbCrLf _ - + " File: " + sNewDoc + vbCrLf _ + + " File: " + sNewFile + vbCrLf _ + sNewMessage If bDiffers = True Then diff --git a/contrib/diff-scripts/diff-nb.vbs b/contrib/diff-scripts/diff-nb.vbs index 2a295404a..097b49407 100644 --- a/contrib/diff-scripts/diff-nb.vbs +++ b/contrib/diff-scripts/diff-nb.vbs @@ -17,31 +17,31 @@ dim objArgs, objScript, objDiffNotebook Set objArgs = WScript.Arguments num = objArgs.Count if num < 2 then - MsgBox "Usage: [CScript | WScript] compare.vbs base.nb new.nb", vbExclamation, "Invalid arguments" + MsgBox "Usage: [CScript | WScript] diff-nb.vbs base.nb new.nb", vbExclamation, "Invalid arguments" WScript.Quit 1 end if -sBaseDoc = objArgs(0) -sNewDoc = objArgs(1) +sBaseFile = objArgs(0) +sNewFile = objArgs(1) Set objScript = CreateObject("Scripting.FileSystemObject") -If objScript.FileExists(sBaseDoc) = False Then - MsgBox "File " + sBaseDoc +" does not exist. Cannot compare the notebooks.", vbExclamation, "File not found" +If objScript.FileExists(sBaseFile) = False Then + MsgBox "File " + sBaseFile + " does not exist. Cannot compare the notebooks.", vbExclamation, "File not found" Wscript.Quit 1 Else - sBaseDoc = objScript.GetAbsolutePathName(sBaseDoc) + sBaseFile = objScript.GetAbsolutePathName(sBaseFile) End If -If objScript.FileExists(sNewDoc) = False Then - MsgBox "File " + sNewDoc +" does not exist. Cannot compare the notebooks.", vbExclamation, "File not found" +If objScript.FileExists(sNewFile) = False Then + MsgBox "File " + sNewFile + " does not exist. Cannot compare the notebooks.", vbExclamation, "File not found" Wscript.Quit 1 Else - sNewDoc = objScript.GetAbsolutePathName(sNewDoc) + sNewFile = objScript.GetAbsolutePathName(sNewFile) End If On Error Resume Next -Dim tfolder, tname, tfile +Dim tfolder, tname Const TemporaryFolder = 2 Set tfolder = objScript.GetSpecialFolder(TemporaryFolder) @@ -55,8 +55,8 @@ objDiffNotebook.WriteLine "Notebook[{" + vbCrLf + _ "ButtonFrame->""DialogBox"", Active->True, ButtonEvaluator->Automatic," + vbCrLf + _ "ButtonFunction:>(Needs[""AuthorTools`""];" + vbCrLf + _ "NotebookPut[Symbol[""NotebookDiff""][" + vbCrLf + _ -"""" + Replace(sBaseDoc,"\","\\") + """," + vbCrLf + _ -"""" + Replace(sNewDoc,"\","\\") + """" + vbCrLf + _ +"""" + Replace(sBaseFile, "\", "\\") + """," + vbCrLf + _ +"""" + Replace(sNewFile, "\", "\\") + """" + vbCrLf + _ "]])]], NotebookDefault]" + vbCrLf + _ "}, Saveable->False, Editable->False, Selectable->False, WindowToolbars->{}, WindowFrame->ModelessDialog, WindowElements->{}, WindowFrameElements->CloseBox, WindowTitle->""Diff"", ShowCellBracket->False, WindowSize->{Fit,Fit}]" diff --git a/contrib/diff-scripts/diff-odt.vbs b/contrib/diff-scripts/diff-odt.vbs index 0330a1df0..8e94095b9 100644 --- a/contrib/diff-scripts/diff-odt.vbs +++ b/contrib/diff-scripts/diff-odt.vbs @@ -2,7 +2,7 @@ ' ' TortoiseSVN Diff script for Open Office Text files ' -' Copyright (C) 2004-2009 the TortoiseSVN team +' Copyright (C) 2004-2009, 2012-2014 the TortoiseSVN team ' This file is distributed under the same license as TortoiseSVN ' ' Last commit by: @@ -14,7 +14,7 @@ ' Jonathan Ashley, 2007 ' Stefan Küng, 2006, 2009 ' -dim objArgs,num,sBaseDoc,sNewDoc,objScript,word,destination +dim objArgs, num, sBaseDoc, sNewDoc, objScript Set objArgs = WScript.Arguments num = objArgs.Count @@ -23,16 +23,16 @@ if num < 2 then WScript.Quit 1 end if -sBaseDoc=objArgs(0) -sNewDoc=objArgs(1) +sBaseDoc = objArgs(0) +sNewDoc = objArgs(1) Set objScript = CreateObject("Scripting.FileSystemObject") If objScript.FileExists(sBaseDoc) = False Then - MsgBox "File " + sBaseDoc +" does not exist. Cannot compare the documents.", vbExclamation, "File not found" + MsgBox "File " + sBaseDoc + " does not exist. Cannot compare the documents.", vbExclamation, "File not found" Wscript.Quit 1 End If If objScript.FileExists(sNewDoc) = False Then - MsgBox "File " + sNewDoc +" does not exist. Cannot compare the documents.", vbExclamation, "File not found" + MsgBox "File " + sNewDoc + " does not exist. Cannot compare the documents.", vbExclamation, "File not found" Wscript.Quit 1 End If 'remove the file write protection @@ -44,7 +44,7 @@ Set objScript = Nothing On Error Resume Next 'The service manager is always the starting point 'If there is no office running then an office is started -Set objServiceManager= Wscript.CreateObject("com.sun.star.ServiceManager") +Set objServiceManager = Wscript.CreateObject("com.sun.star.ServiceManager") If Err.Number <> 0 Then Wscript.Echo "You must have OpenOffice installed to perform this operation." Wscript.Quit 1 @@ -57,7 +57,7 @@ On Error Goto 0 'Make sure we un-set that flag. Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.GetFile(sNewDoc) -If (objFile.Attributes AND 1)=1 Then +If (objFile.Attributes AND 1) = 1 Then objFile.Attributes = objFile.Attributes XOR 1 End If @@ -65,32 +65,32 @@ End If Set objDesktop = objServiceManager.createInstance("com.sun.star.frame.Desktop") Set objUriTranslator = objServiceManager.createInstance("com.sun.star.uri.ExternalUriReferenceTranslator") 'Adjust the paths for OO -sBaseDoc=Replace(sBaseDoc, "\", "/") -sBaseDoc=Replace(sBaseDoc, ":", "|") -sBaseDoc=Replace(sBaseDoc, "%", "%25") -sBaseDoc=Replace(sBaseDoc, " ", "%20") -sBaseDoc=Replace(sBaseDoc, "#", "%23") -sBaseDoc="file:///"&sBaseDoc -sBaseDoc=objUriTranslator.translateToInternal(sBaseDoc) -sNewDoc=Replace(sNewDoc, "\", "/") -sNewDoc=Replace(sNewDoc, ":", "|") -sNewDoc=Replace(sNewDoc, "%", "%25") -sNewDoc=Replace(sNewDoc, " ", "%20") -sNewDoc=Replace(sNewDoc, "#", "%23") -sNewDoc="file:///"&sNewDoc -sNewDoc=objUriTranslator.translateToInternal(sNewDoc) +sBaseDoc = Replace(sBaseDoc, "\", "/") +sBaseDoc = Replace(sBaseDoc, ":", "|") +sBaseDoc = Replace(sBaseDoc, "%", "%25") +sBaseDoc = Replace(sBaseDoc, " ", "%20") +sBaseDoc = Replace(sBaseDoc, "#", "%23") +sBaseDoc = "file:///"&sBaseDoc +sBaseDoc = objUriTranslator.translateToInternal(sBaseDoc) +sNewDoc = Replace(sNewDoc, "\", "/") +sNewDoc = Replace(sNewDoc, ":", "|") +sNewDoc = Replace(sNewDoc, "%", "%25") +sNewDoc = Replace(sNewDoc, " ", "%20") +sNewDoc = Replace(sNewDoc, "#", "%23") +sNewDoc = "file:///"&sNewDoc +sNewDoc = objUriTranslator.translateToInternal(sNewDoc) 'Open the %base document Dim oPropertyValue(0) Set oPropertyValue(0) = objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue") oPropertyValue(0).Name = "ShowTrackedChanges" oPropertyValue(0).Value = true -Set objDocument=objDesktop.loadComponentFromURL(sNewDoc,"_blank", 0, oPropertyValue) +Set objDocument = objDesktop.loadComponentFromURL(sNewDoc, "_blank", 0, oPropertyValue) 'Set the frame Set Frame = objDesktop.getCurrentFrame -Set dispatcher=objServiceManager.CreateInstance("com.sun.star.frame.DispatchHelper") +Set dispatcher = objServiceManager.CreateInstance("com.sun.star.frame.DispatchHelper") 'Execute the comparison dispatcher.executeDispatch Frame, ".uno:ShowTrackedChanges", "", 0, oPropertyValue diff --git a/contrib/diff-scripts/diff-sxw.vbs b/contrib/diff-scripts/diff-sxw.vbs index 87da9442d..c7dbd1198 100644 --- a/contrib/diff-scripts/diff-sxw.vbs +++ b/contrib/diff-scripts/diff-sxw.vbs @@ -1,7 +1,7 @@ ' ' TortoiseSVN Diff script for Open Office Calc files ' -' Copyright (C) 2004-2008 the TortoiseSVN team +' Copyright (C) 2004-2009, 2012-2014 the TortoiseSVN team ' This file is distributed under the same license as TortoiseSVN ' ' Last commit by: @@ -13,7 +13,7 @@ ' Jonathan Ashley, 2007 ' Stefan Küng, 2006 ' -dim objArgs,num,sBaseDoc,sNewDoc,objScript,word,destination +dim objArgs, num, sBaseDoc, sNewDoc, objScript Set objArgs = WScript.Arguments num = objArgs.Count @@ -22,8 +22,8 @@ if num < 2 then WScript.Quit 1 end if -sBaseDoc=objArgs(0) -sNewDoc=objArgs(1) +sBaseDoc = objArgs(0) +sNewDoc = objArgs(1) Set objScript = CreateObject("Scripting.FileSystemObject") If objScript.FileExists(sBaseDoc) = False Then @@ -40,7 +40,7 @@ Set objScript = Nothing On Error Resume Next 'The service manager is always the starting point 'If there is no office running then an office is started -Set objServiceManager= Wscript.CreateObject("com.sun.star.ServiceManager") +Set objServiceManager = Wscript.CreateObject("com.sun.star.ServiceManager") If Err.Number <> 0 Then Wscript.Echo "You must have OpenOffice installed to perform this operation." Wscript.Quit 1 @@ -50,21 +50,21 @@ On Error Goto 0 'Create the DesktopSet Set objDesktop = objServiceManager.createInstance("com.sun.star.frame.Desktop") 'Adjust the paths for OO -sBaseDoc=Replace(sBaseDoc, "\", "/") -sBaseDoc=Replace(sBaseDoc, ":", "|") -sBaseDoc=Replace(sBaseDoc, "%", "%25") -sBaseDoc=Replace(sBaseDoc, " ", "%20") -sBaseDoc="file:///"&sBaseDoc -sNewDoc=Replace(sNewDoc, "\", "/") -sNewDoc=Replace(sNewDoc, ":", "|") -sNewDoc=Replace(sNewDoc, "%", "%25") -sNewDoc=Replace(sNewDoc, " ", "%20") -sNewDoc="file:///"&sNewDoc +sBaseDoc = Replace(sBaseDoc, "\", "/") +sBaseDoc = Replace(sBaseDoc, ":", "|") +sBaseDoc = Replace(sBaseDoc, "%", "%25") +sBaseDoc = Replace(sBaseDoc, " ", "%20") +sBaseDoc = "file:///"&sBaseDoc +sNewDoc = Replace(sNewDoc, "\", "/") +sNewDoc = Replace(sNewDoc, ":", "|") +sNewDoc = Replace(sNewDoc, "%", "%25") +sNewDoc = Replace(sNewDoc, " ", "%20") +sNewDoc = "file:///"&sNewDoc 'Open the %base document Dim oPropertyValue(0) Set oPropertyValue(0) = objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue") oPropertyValue(0).Name = "ShowTrackedChanges" oPropertyValue(0).Value = true -Set objDocument=objDesktop.loadComponentFromURL(sNewDoc,"_blank", 0, oPropertyValue) -Set objDocument2=objDesktop.loadComponentFromURL(sBaseDoc,"_blank",0, oPropertyValue) +Set objDocument = objDesktop.loadComponentFromURL(sNewDoc, "_blank", 0, oPropertyValue) +Set objDocument2 = objDesktop.loadComponentFromURL(sBaseDoc, "_blank", 0, oPropertyValue) diff --git a/contrib/diff-scripts/merge-ods.vbs b/contrib/diff-scripts/merge-ods.vbs index 887805516..e19cb7305 100644 --- a/contrib/diff-scripts/merge-ods.vbs +++ b/contrib/diff-scripts/merge-ods.vbs @@ -2,7 +2,7 @@ ' ' TortoiseSVN Merge script for Open Office Calc files ' -' Copyright (C) 2004-2009 the TortoiseSVN team +' Copyright (C) 2004-2009, 2012-2014 the TortoiseSVN team ' This file is distributed under the same license as TortoiseSVN ' ' Last commit by: @@ -14,7 +14,7 @@ ' Jonathan Ashley, 2007 ' Stefan Küng, 2006, 2009 ' -dim objArgs,num,sBaseDoc,sMergedDoc,sTheirDoc,sMyDoc,objScript,word,destination +dim objArgs, num, sBaseDoc, sMergedDoc, sTheirDoc, sMyDoc, objScript Set objArgs = WScript.Arguments num = objArgs.Count @@ -23,18 +23,18 @@ if num < 4 then WScript.Quit 1 end if -sMergedDoc=objArgs(0) -sTheirDoc=objArgs(1) -sMyDoc=objArgs(2) -sBaseDoc=objArgs(3) +sMergedDoc = objArgs(0) +sTheirDoc = objArgs(1) +sMyDoc = objArgs(2) +sBaseDoc = objArgs(3) Set objScript = CreateObject("Scripting.FileSystemObject") If objScript.FileExists(sMyDoc) = False Then - MsgBox "File " + sMyDoc +" does not exist. Cannot compare the documents.", vbExclamation, "File not found" + MsgBox "File " + sMyDoc + " does not exist. Cannot compare the documents.", vbExclamation, "File not found" Wscript.Quit 1 End If If objScript.FileExists(sTheirDoc) = False Then - MsgBox "File " + sTheirDoc +" does not exist. Cannot compare the documents.", vbExclamation, "File not found" + MsgBox "File " + sTheirDoc + " does not exist. Cannot compare the documents.", vbExclamation, "File not found" Wscript.Quit 1 End If 'remove the file write protection @@ -46,7 +46,7 @@ Set objScript = Nothing On Error Resume Next 'The service manager is always the starting point 'If there is no office running then an office is started -Set objServiceManager= Wscript.CreateObject("com.sun.star.ServiceManager") +Set objServiceManager = Wscript.CreateObject("com.sun.star.ServiceManager") If Err.Number <> 0 Then Wscript.Echo "You must have OpenOffice installed to perform this operation." Wscript.Quit 1 @@ -56,30 +56,30 @@ On Error Goto 0 'Create the DesktopSet Set objDesktop = objServiceManager.createInstance("com.sun.star.frame.Desktop") 'Adjust the paths for OO -sMyDoc=Replace(sMyDoc, "\", "/") -sMyDoc=Replace(sMyDoc, ":", "|") -sMyDoc=Replace(sMyDoc, "%", "%25") -sMyDoc=Replace(sMyDoc, " ", "%20") -sMyDoc=Replace(sMyDoc, "#", "%23") -sMyDoc="file:///"&sMyDoc -sTheirDoc=Replace(sTheirDoc, "\", "/") -sTheirDoc=Replace(sTheirDoc, ":", "|") -sTheirDoc=Replace(sTheirDoc, "%", "%25") -sTheirDoc=Replace(sTheirDoc, " ", "%20") -sTheirDoc=Replace(sTheirDoc, "#", "%23") -sTheirDoc="file:///"&sTheirDoc +sMyDoc = Replace(sMyDoc, "\", "/") +sMyDoc = Replace(sMyDoc, ":", "|") +sMyDoc = Replace(sMyDoc, "%", "%25") +sMyDoc = Replace(sMyDoc, " ", "%20") +sMyDoc = Replace(sMyDoc, "#", "%23") +sMyDoc = "file:///"&sMyDoc +sTheirDoc = Replace(sTheirDoc, "\", "/") +sTheirDoc = Replace(sTheirDoc, ":", "|") +sTheirDoc = Replace(sTheirDoc, "%", "%25") +sTheirDoc = Replace(sTheirDoc, " ", "%20") +sTheirDoc = Replace(sTheirDoc, "#", "%23") +sTheirDoc = "file:///"&sTheirDoc 'Open the %mine document Dim oPropertyValue(0) Set oPropertyValue(0) = objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue") oPropertyValue(0).Name = "ShowTrackedChanges" oPropertyValue(0).Value = true -Set objDocument=objDesktop.loadComponentFromURL(sMyDoc,"_blank", 0, oPropertyValue) +Set objDocument = objDesktop.loadComponentFromURL(sMyDoc, "_blank", 0, oPropertyValue) 'Set the frame Set Frame = objDesktop.getCurrentFrame -Set dispatcher=objServiceManager.CreateInstance("com.sun.star.frame.DispatchHelper") +Set dispatcher = objServiceManager.CreateInstance("com.sun.star.frame.DispatchHelper") 'Execute the comparison Dispatcher.executeDispatch Frame, ".uno:ShowTrackedChanges", "", 0, oPropertyValue -- 2.11.4.GIT