From: Sven Strickroth Date: Sun, 24 Mar 2013 16:51:03 +0000 (+0100) Subject: Synced diff-scripts with TortoiseSVN X-Git-Tag: REL_1.8.2.0_EXTERNAL~21 X-Git-Url: https://repo.or.cz/w/TortoiseGit.git/commitdiff_plain/824337c1c53fb2522b34bd48fa866ccaf2a2a5ea Synced diff-scripts with TortoiseSVN Based on revision #24048. Signed-off-by: Sven Strickroth --- diff --git a/contrib/diff-scripts/diff-dll.vbs b/contrib/diff-scripts/diff-dll.vbs index 11d05e5a2..3bda80926 100644 --- a/contrib/diff-scripts/diff-dll.vbs +++ b/contrib/diff-scripts/diff-dll.vbs @@ -1,108 +1,108 @@ -' extensions: dll;exe -' -' TortoiseSVN Diff script for binary files -' -' Copyright (C) 2010 the TortoiseSVN team -' This file is distributed under the same license as TortoiseSVN -' -' Last commit by: -' $Author$ -' $Date$ -' $Rev$ -' -' Authors: -' Casey Barton, 2010 -' Hans-Emil Skogh, 2011 -' -dim objArgs, objFileSystem, sBaseVer, sNewVer, sMessage, sBaseMessage, sNewMessage, bDiffers - -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" - WScript.Quit 1 -end if - -sBaseDoc = objArgs(0) -sNewDoc = 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" - 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" - Wscript.Quit 1 -End If - -' Compare file size -dim fBaseFile, fNewFile -Set fBaseFile = objFileSystem.GetFile(sBaseDoc) -Set fNewFile = objFileSystem.GetFile(sNewDoc) - -If fBaseFile.size <> fNewFile.size Then - bDiffers = True - sBaseMessage = sBaseMessage + " Size: " + CStr(fBaseFile.Size) + " bytes" + vbCrLf - sNewMessage = sNewMessage + " Size: " + CStr(fNewFile.Size) + " bytes" + vbCrLf -Else - sMessage = sMessage + "File sizes: " + CStr(fNewFile.Size) + " bytes" + vbCrLf -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) - If exitStatus = 1 Then - bDiffers = True - sMessage = sMessage + "File content differs!" + vbCrLf - ElseIf exitStatus > 1 Then - ' Todo: Handle error! - End If -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 - - ' Compare version - sBaseVer = objFileSystem.GetFileVersion(sBaseDoc) - sNewVer = objFileSystem.GetFileVersion(sNewDoc) - - If Len(sBaseVer) = 0 and Len(sNewVer) = 0 Then - sMessage = sMessage + "No version information available." - ElseIf sBaseVer = sNewVer Then - sMessage = sMessage + "Version: " + sBaseVer - Else - sBaseMessage = sBaseMessage + " Version: " + sBaseVer + vbCrLf - sNewMessage = sNewMessage + " Version: " + sNewVer + vbCrLf - End If -End If - -' Generate result message -sBaseMessage = "Base" + vbCrLf _ - + " File: " + sBaseDoc + vbCrLf _ - + sBaseMessage -sNewMessage = + "New" + vbCrLf _ - + " File: " + sNewDoc + vbCrLf _ - + sNewMessage - -If bDiffers = True Then - sMessage = "Files differ!" + vbCrLf _ - + vbCrLf _ - + sBaseMessage + vbCrLf _ - + sNewMessage + vbCrLf _ - + sMessage - - MsgBox sMessage, vbExclamation, "File Comparison - Differs" -Else - sMessage = "Files are identical" + vbCrLf _ - + vbCrLf _ - + sMessage - - MsgBox sMessage, vbInformation, "File Comparison - Identical" -End If - -Wscript.Quit +' extensions: dll;exe +' +' TortoiseSVN Diff script for binary files +' +' Copyright (C) 2010 the TortoiseSVN team +' This file is distributed under the same license as TortoiseSVN +' +' Last commit by: +' $Author$ +' $Date$ +' $Rev$ +' +' Authors: +' Casey Barton, 2010 +' Hans-Emil Skogh, 2011 +' +dim objArgs, objFileSystem, sBaseVer, sNewVer, sMessage, sBaseMessage, sNewMessage, bDiffers + +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" + WScript.Quit 1 +end if + +sBaseDoc = objArgs(0) +sNewDoc = 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" + 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" + Wscript.Quit 1 +End If + +' Compare file size +dim fBaseFile, fNewFile +Set fBaseFile = objFileSystem.GetFile(sBaseDoc) +Set fNewFile = objFileSystem.GetFile(sNewDoc) + +If fBaseFile.size <> fNewFile.size Then + bDiffers = True + sBaseMessage = sBaseMessage + " Size: " + CStr(fBaseFile.Size) + " bytes" + vbCrLf + sNewMessage = sNewMessage + " Size: " + CStr(fNewFile.Size) + " bytes" + vbCrLf +Else + sMessage = sMessage + "File sizes: " + CStr(fNewFile.Size) + " bytes" + vbCrLf +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) + If exitStatus = 1 Then + bDiffers = True + sMessage = sMessage + "File content differs!" + vbCrLf + ElseIf exitStatus > 1 Then + ' Todo: Handle error! + End If +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 + + ' Compare version + sBaseVer = objFileSystem.GetFileVersion(sBaseDoc) + sNewVer = objFileSystem.GetFileVersion(sNewDoc) + + If Len(sBaseVer) = 0 and Len(sNewVer) = 0 Then + sMessage = sMessage + "No version information available." + ElseIf sBaseVer = sNewVer Then + sMessage = sMessage + "Version: " + sBaseVer + Else + sBaseMessage = sBaseMessage + " Version: " + sBaseVer + vbCrLf + sNewMessage = sNewMessage + " Version: " + sNewVer + vbCrLf + End If +End If + +' Generate result message +sBaseMessage = "Base" + vbCrLf _ + + " File: " + sBaseDoc + vbCrLf _ + + sBaseMessage +sNewMessage = + "New" + vbCrLf _ + + " File: " + sNewDoc + vbCrLf _ + + sNewMessage + +If bDiffers = True Then + sMessage = "Files differ!" + vbCrLf _ + + vbCrLf _ + + sBaseMessage + vbCrLf _ + + sNewMessage + vbCrLf _ + + sMessage + + MsgBox sMessage, vbExclamation, "File Comparison - Differs" +Else + sMessage = "Files are identical" + vbCrLf _ + + vbCrLf _ + + sMessage + + MsgBox sMessage, vbInformation, "File Comparison - Identical" +End If + +Wscript.Quit diff --git a/contrib/diff-scripts/diff-doc.js b/contrib/diff-scripts/diff-doc.js index 48443d0a0..993970c90 100644 --- a/contrib/diff-scripts/diff-doc.js +++ b/contrib/diff-scripts/diff-doc.js @@ -1,218 +1,218 @@ -// extensions: doc;docx;docm -// -// TortoiseSVN Diff script for Word Doc files -// -// Copyright (C) 2004-2008, 2011, 2013 the TortoiseSVN team -// This file is distributed under the same license as TortoiseSVN -// -// Last commit by: -// $Author$ -// $Date$ -// $Rev$ -// -// Authors: -// Stefan Kueng, 2011, 2013 -// Jared Silva, 2008 -// Davide Orlandi and Hans-Emil Skogh, 2005 -// - -var objArgs, num, sBaseDoc, sNewDoc, sTempDoc, objScript, word, destination; -// Microsoft Office versions for Microsoft Windows OS -var vOffice2000 = 9; -var vOffice2002 = 10; -//var vOffice2003 = 11; -var vOffice2007 = 12; -var vOffice2013 = 15; -// WdCompareTarget -//var wdCompareTargetSelected = 0; -//var wdCompareTargetCurrent = 1; -var wdCompareTargetNew = 2; -// WdViewType -var wdMasterView = 5; -var wdNormalView = 1; -var wdOutlineView = 2; -// WdSaveOptions -var wdDoNotSaveChanges = 0; -//var wdPromptToSaveChanges = -2; -//var wdSaveChanges = -1; - -objArgs = WScript.Arguments; -num = objArgs.length; -if (num < 2) -{ - WScript.Echo("Usage: [CScript | WScript] diff-doc.js base.doc new.doc"); - WScript.Quit(1); -} - -sBaseDoc = objArgs(0); -sNewDoc = objArgs(1); - -objScript = new ActiveXObject("Scripting.FileSystemObject"); - -if (!objScript.FileExists(sBaseDoc)) -{ - WScript.Echo("File " + sBaseDoc + " does not exist. Cannot compare the documents."); - WScript.Quit(1); -} - -if (!objScript.FileExists(sNewDoc)) -{ - WScript.Echo("File " + sNewDoc + " does not exist. Cannot compare the documents."); - WScript.Quit(1); -} - -try -{ - word = WScript.CreateObject("Word.Application"); - - if (parseInt(word.Version) >= vOffice2013) - { - var f = objScript.GetFile(sBaseDoc); - if (f.attributes & 1) - { - f.attributes = f.attributes - 1; - } - } -} -catch (e) -{ - // before giving up, try with OpenOffice - var OO; - try - { - OO = WScript.CreateObject("com.sun.star.ServiceManager"); - } - catch (e) - { - WScript.Echo("You must have Microsoft Word or OpenOffice installed to perform this operation."); - WScript.Quit(1); - } - // yes, OO is installed - do the diff with that one instead - var objFile = objScript.GetFile(sNewDoc); - if ((objFile.Attributes & 1) === 1) - { - // reset the readonly attribute - objFile.Attributes = objFile.Attributes & (~1); - } - //Create the DesktopSet - var objDesktop = OO.createInstance("com.sun.star.frame.Desktop"); - var objUriTranslator = OO.createInstance("com.sun.star.uri.ExternalUriReferenceTranslator"); - //Adjust the paths for OO - sBaseDoc = sBaseDoc.replace(/\\/g, "/"); - sBaseDoc = sBaseDoc.replace(/:/g, "|"); - sBaseDoc = sBaseDoc.replace(/ /g, "%20"); - sBaseDoc = sBaseDoc.replace(/#/g, "%23"); - sBaseDoc = "file:///" + sBaseDoc; - sBaseDoc = objUriTranslator.translateToInternal(sBaseDoc); - sNewDoc = sNewDoc.replace(/\\/g, "/"); - sNewDoc = sNewDoc.replace(/:/g, "|"); - sNewDoc = sNewDoc.replace(/ /g, "%20"); - sNewDoc = sNewDoc.replace(/#/g, "%23"); - sNewDoc = "file:///" + sNewDoc; - sNewDoc = objUriTranslator.translateToInternal(sNewDoc); - - //Open the %base document - var oPropertyValue = new Array(); - oPropertyValue[0] = OO.Bridge_GetStruct("com.sun.star.beans.PropertyValue"); - oPropertyValue[0].Name = "ShowTrackedChanges"; - oPropertyValue[0].Value = true; - // objDocument is needed - var objDocument = objDesktop.loadComponentFromURL(sNewDoc,"_blank", 0, oPropertyValue); - - //Set the frame - var Frame = objDesktop.getCurrentFrame(); - - var dispatcher = OO.CreateInstance("com.sun.star.frame.DispatchHelper"); - - //Execute the comparison - dispatcher.executeDispatch(Frame, ".uno:ShowTrackedChanges", "", 0, oPropertyValue); - oPropertyValue[0].Name = "URL"; - oPropertyValue[0].Value = sBaseDoc; - dispatcher.executeDispatch(Frame, ".uno:CompareDocuments", "", 0, oPropertyValue); - WScript.Quit(0); -} - -if (parseInt(word.Version) >= vOffice2007) -{ - sTempDoc = sNewDoc; - sNewDoc = sBaseDoc; - sBaseDoc = sTempDoc; -} - -objScript = null; -word.visible = true; - -// Open the new document -try -{ - destination = word.Documents.Open(sNewDoc, true, (parseInt(word.Version) < vOffice2013)); -} -catch (e) -{ - try - { - // open empty document to prevent bug where first Open() call fails - word.Documents.Add(); - destination = word.Documents.Open(sNewDoc, true, (parseInt(word.Version) < vOffice2013)); - } - catch (e) - { - WScript.Echo("Error opening " + sNewDoc); - // Quit - WScript.Quit(1); - } -} - -// If the Type property returns either wdOutlineView or wdMasterView and the Count property returns zero, the current document is an outline. -if (((destination.ActiveWindow.View.Type === wdOutlineView) || (destination.ActiveWindow.View.Type === wdMasterView)) && (destination.Subdocuments.Count === 0)) -{ - // Change the Type property of the current document to normal - destination.ActiveWindow.View.Type = wdNormalView; -} - -// Compare to the base document -if (parseInt(word.Version) <= vOffice2000) -{ - // Compare for Office 2000 and earlier - try - { - destination.Compare(sBaseDoc); - } - catch (e) - { - WScript.Echo("Error comparing " + sBaseDoc + " and " + sNewDoc); - // Quit - WScript.Quit(1); - } -} -else -{ - // Compare for Office XP (2002) and later - try - { - destination.Compare(sBaseDoc, "Comparison", wdCompareTargetNew, true, true); - } - catch (e) - { - WScript.Echo("Error comparing " + sBaseDoc + " and " + sNewDoc); - // Close the first document and quit - destination.Close(wdDoNotSaveChanges); - WScript.Quit(1); - } -} - -// Show the comparison result -if (parseInt(word.Version) < vOffice2007) -{ - word.ActiveDocument.Windows(1).Visible = 1; -} - -// Mark the comparison document as saved to prevent the annoying -// "Save as" dialog from appearing. -word.ActiveDocument.Saved = 1; - -// Close the first document -if (parseInt(word.Version) >= vOffice2002) -{ - destination.Close(wdDoNotSaveChanges); -} +// extensions: doc;docx;docm +// +// TortoiseSVN Diff script for Word Doc files +// +// Copyright (C) 2004-2008, 2011, 2013 the TortoiseSVN team +// This file is distributed under the same license as TortoiseSVN +// +// Last commit by: +// $Author$ +// $Date$ +// $Rev$ +// +// Authors: +// Stefan Kueng, 2011, 2013 +// Jared Silva, 2008 +// Davide Orlandi and Hans-Emil Skogh, 2005 +// + +var objArgs, num, sBaseDoc, sNewDoc, sTempDoc, objScript, word, destination; +// Microsoft Office versions for Microsoft Windows OS +var vOffice2000 = 9; +var vOffice2002 = 10; +//var vOffice2003 = 11; +var vOffice2007 = 12; +var vOffice2013 = 15; +// WdCompareTarget +//var wdCompareTargetSelected = 0; +//var wdCompareTargetCurrent = 1; +var wdCompareTargetNew = 2; +// WdViewType +var wdMasterView = 5; +var wdNormalView = 1; +var wdOutlineView = 2; +// WdSaveOptions +var wdDoNotSaveChanges = 0; +//var wdPromptToSaveChanges = -2; +//var wdSaveChanges = -1; + +objArgs = WScript.Arguments; +num = objArgs.length; +if (num < 2) +{ + WScript.Echo("Usage: [CScript | WScript] diff-doc.js base.doc new.doc"); + WScript.Quit(1); +} + +sBaseDoc = objArgs(0); +sNewDoc = objArgs(1); + +objScript = new ActiveXObject("Scripting.FileSystemObject"); + +if (!objScript.FileExists(sBaseDoc)) +{ + WScript.Echo("File " + sBaseDoc + " does not exist. Cannot compare the documents."); + WScript.Quit(1); +} + +if (!objScript.FileExists(sNewDoc)) +{ + WScript.Echo("File " + sNewDoc + " does not exist. Cannot compare the documents."); + WScript.Quit(1); +} + +try +{ + word = WScript.CreateObject("Word.Application"); + + if (parseInt(word.Version, 10) >= vOffice2013) + { + var f = objScript.GetFile(sBaseDoc); + if (f.attributes & 1) + { + f.attributes = f.attributes - 1; + } + } +} +catch (e) +{ + // before giving up, try with OpenOffice + var OO; + try + { + OO = WScript.CreateObject("com.sun.star.ServiceManager"); + } + catch (e) + { + WScript.Echo("You must have Microsoft Word or OpenOffice installed to perform this operation."); + WScript.Quit(1); + } + // yes, OO is installed - do the diff with that one instead + var objFile = objScript.GetFile(sNewDoc); + if ((objFile.Attributes & 1) === 1) + { + // reset the readonly attribute + objFile.Attributes = objFile.Attributes & (~1); + } + //Create the DesktopSet + var objDesktop = OO.createInstance("com.sun.star.frame.Desktop"); + var objUriTranslator = OO.createInstance("com.sun.star.uri.ExternalUriReferenceTranslator"); + //Adjust the paths for OO + sBaseDoc = sBaseDoc.replace(/\\/g, "/"); + sBaseDoc = sBaseDoc.replace(/:/g, "|"); + sBaseDoc = sBaseDoc.replace(/ /g, "%20"); + sBaseDoc = sBaseDoc.replace(/#/g, "%23"); + sBaseDoc = "file:///" + sBaseDoc; + sBaseDoc = objUriTranslator.translateToInternal(sBaseDoc); + sNewDoc = sNewDoc.replace(/\\/g, "/"); + sNewDoc = sNewDoc.replace(/:/g, "|"); + sNewDoc = sNewDoc.replace(/ /g, "%20"); + sNewDoc = sNewDoc.replace(/#/g, "%23"); + sNewDoc = "file:///" + sNewDoc; + sNewDoc = objUriTranslator.translateToInternal(sNewDoc); + + //Open the %base document + var oPropertyValue = []; + oPropertyValue[0] = OO.Bridge_GetStruct("com.sun.star.beans.PropertyValue"); + oPropertyValue[0].Name = "ShowTrackedChanges"; + oPropertyValue[0].Value = true; + // objDocument is needed + var objDocument = objDesktop.loadComponentFromURL(sNewDoc,"_blank", 0, oPropertyValue); + + //Set the frame + var Frame = objDesktop.getCurrentFrame(); + + var dispatcher = OO.CreateInstance("com.sun.star.frame.DispatchHelper"); + + //Execute the comparison + dispatcher.executeDispatch(Frame, ".uno:ShowTrackedChanges", "", 0, oPropertyValue); + oPropertyValue[0].Name = "URL"; + oPropertyValue[0].Value = sBaseDoc; + dispatcher.executeDispatch(Frame, ".uno:CompareDocuments", "", 0, oPropertyValue); + WScript.Quit(0); +} + +if (parseInt(word.Version, 10) >= vOffice2007) +{ + sTempDoc = sNewDoc; + sNewDoc = sBaseDoc; + sBaseDoc = sTempDoc; +} + +objScript = null; +word.visible = true; + +// Open the new document +try +{ + destination = word.Documents.Open(sNewDoc, true, (parseInt(word.Version, 10) < vOffice2013)); +} +catch (e) +{ + try + { + // open empty document to prevent bug where first Open() call fails + word.Documents.Add(); + destination = word.Documents.Open(sNewDoc, true, (parseInt(word.Version, 10) < vOffice2013)); + } + catch (e) + { + WScript.Echo("Error opening " + sNewDoc); + // Quit + WScript.Quit(1); + } +} + +// If the Type property returns either wdOutlineView or wdMasterView and the Count property returns zero, the current document is an outline. +if (((destination.ActiveWindow.View.Type === wdOutlineView) || (destination.ActiveWindow.View.Type === wdMasterView)) && (destination.Subdocuments.Count === 0)) +{ + // Change the Type property of the current document to normal + destination.ActiveWindow.View.Type = wdNormalView; +} + +// Compare to the base document +if (parseInt(word.Version, 10) <= vOffice2000) +{ + // Compare for Office 2000 and earlier + try + { + destination.Compare(sBaseDoc); + } + catch (e) + { + WScript.Echo("Error comparing " + sBaseDoc + " and " + sNewDoc); + // Quit + WScript.Quit(1); + } +} +else +{ + // Compare for Office XP (2002) and later + try + { + destination.Compare(sBaseDoc, "Comparison", wdCompareTargetNew, true, true); + } + catch (e) + { + WScript.Echo("Error comparing " + sBaseDoc + " and " + sNewDoc); + // Close the first document and quit + destination.Close(wdDoNotSaveChanges); + WScript.Quit(1); + } +} + +// Show the comparison result +if (parseInt(word.Version, 10) < vOffice2007) +{ + word.ActiveDocument.Windows(1).Visible = 1; +} + +// Mark the comparison document as saved to prevent the annoying +// "Save as" dialog from appearing. +word.ActiveDocument.Saved = 1; + +// Close the first document +if (parseInt(word.Version, 10) >= vOffice2002) +{ + destination.Close(wdDoNotSaveChanges); +} diff --git a/contrib/diff-scripts/diff-nb.vbs b/contrib/diff-scripts/diff-nb.vbs index fe857b6cb..2a295404a 100644 --- a/contrib/diff-scripts/diff-nb.vbs +++ b/contrib/diff-scripts/diff-nb.vbs @@ -1,67 +1,67 @@ -' -' TortoiseSVN Diff script for Mathematica notebooks -' -' Last commit by: -' $Author$ -' $Date$ -' $Rev$ -' -' Authors: -' Szabolcs Horvát, 2008 -' Chris Rodgers http://rodgers.org.uk/, 2008 -' (Based on diff-xlsx.vbs) -' - -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" - WScript.Quit 1 -end if - -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 notebooks.", vbExclamation, "File not found" - Wscript.Quit 1 -Else - sBaseDoc = objScript.GetAbsolutePathName(sBaseDoc) -End If - -If objScript.FileExists(sNewDoc) = False Then - MsgBox "File " + sNewDoc +" does not exist. Cannot compare the notebooks.", vbExclamation, "File not found" - Wscript.Quit 1 -Else - sNewDoc = objScript.GetAbsolutePathName(sNewDoc) -End If - -On Error Resume Next -Dim tfolder, tname, tfile -Const TemporaryFolder = 2 - -Set tfolder = objScript.GetSpecialFolder(TemporaryFolder) - -tname = objScript.GetTempName + ".nb" -Set objDiffNotebook = tfolder.CreateTextFile(tname) - -'Output a Mathematica notebook that will do the diff for us -objDiffNotebook.WriteLine "Notebook[{" + vbCrLf + _ -"Cell[BoxData[ButtonBox[""\<\""Compare Notebooks\""\>""," + vbCrLf + _ -"ButtonFrame->""DialogBox"", Active->True, ButtonEvaluator->Automatic," + vbCrLf + _ -"ButtonFunction:>(Needs[""AuthorTools`""];" + vbCrLf + _ -"NotebookPut[Symbol[""NotebookDiff""][" + vbCrLf + _ -"""" + Replace(sBaseDoc,"\","\\") + """," + vbCrLf + _ -"""" + Replace(sNewDoc,"\","\\") + """" + vbCrLf + _ -"]])]], NotebookDefault]" + vbCrLf + _ -"}, Saveable->False, Editable->False, Selectable->False, WindowToolbars->{}, WindowFrame->ModelessDialog, WindowElements->{}, WindowFrameElements->CloseBox, WindowTitle->""Diff"", ShowCellBracket->False, WindowSize->{Fit,Fit}]" - - -objDiffNotebook.Close - -Set objShell = CreateObject("WScript.Shell") -objShell.Run tfolder + "\" + tname +' +' TortoiseSVN Diff script for Mathematica notebooks +' +' Last commit by: +' $Author$ +' $Date$ +' $Rev$ +' +' Authors: +' Szabolcs Horvát, 2008 +' Chris Rodgers http://rodgers.org.uk/, 2008 +' (Based on diff-xlsx.vbs) +' + +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" + WScript.Quit 1 +end if + +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 notebooks.", vbExclamation, "File not found" + Wscript.Quit 1 +Else + sBaseDoc = objScript.GetAbsolutePathName(sBaseDoc) +End If + +If objScript.FileExists(sNewDoc) = False Then + MsgBox "File " + sNewDoc +" does not exist. Cannot compare the notebooks.", vbExclamation, "File not found" + Wscript.Quit 1 +Else + sNewDoc = objScript.GetAbsolutePathName(sNewDoc) +End If + +On Error Resume Next +Dim tfolder, tname, tfile +Const TemporaryFolder = 2 + +Set tfolder = objScript.GetSpecialFolder(TemporaryFolder) + +tname = objScript.GetTempName + ".nb" +Set objDiffNotebook = tfolder.CreateTextFile(tname) + +'Output a Mathematica notebook that will do the diff for us +objDiffNotebook.WriteLine "Notebook[{" + vbCrLf + _ +"Cell[BoxData[ButtonBox[""\<\""Compare Notebooks\""\>""," + vbCrLf + _ +"ButtonFrame->""DialogBox"", Active->True, ButtonEvaluator->Automatic," + vbCrLf + _ +"ButtonFunction:>(Needs[""AuthorTools`""];" + vbCrLf + _ +"NotebookPut[Symbol[""NotebookDiff""][" + vbCrLf + _ +"""" + Replace(sBaseDoc,"\","\\") + """," + vbCrLf + _ +"""" + Replace(sNewDoc,"\","\\") + """" + vbCrLf + _ +"]])]], NotebookDefault]" + vbCrLf + _ +"}, Saveable->False, Editable->False, Selectable->False, WindowToolbars->{}, WindowFrame->ModelessDialog, WindowElements->{}, WindowFrameElements->CloseBox, WindowTitle->""Diff"", ShowCellBracket->False, WindowSize->{Fit,Fit}]" + + +objDiffNotebook.Close + +Set objShell = CreateObject("WScript.Shell") +objShell.Run tfolder + "\" + tname diff --git a/contrib/diff-scripts/diff-odt.vbs b/contrib/diff-scripts/diff-odt.vbs index 87bcd0ca4..0330a1df0 100644 --- a/contrib/diff-scripts/diff-odt.vbs +++ b/contrib/diff-scripts/diff-odt.vbs @@ -1,99 +1,99 @@ -' extensions: odt;ods -' -' TortoiseSVN Diff script for Open Office Text files -' -' Copyright (C) 2004-2009 the TortoiseSVN team -' This file is distributed under the same license as TortoiseSVN -' -' Last commit by: -' $Author$ -' $Date$ -' $Rev$ -' -' Authors: -' Jonathan Ashley, 2007 -' Stefan Küng, 2006, 2009 -' -dim objArgs,num,sBaseDoc,sNewDoc,objScript,word,destination - -Set objArgs = WScript.Arguments -num = objArgs.Count -if num < 2 then - MsgBox "Usage: [CScript | WScript] diff-odt.vbs base.odt new.odt", vbExclamation, "Invalid arguments" - WScript.Quit 1 -end if - -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" - 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" - Wscript.Quit 1 -End If -'remove the file write protection -objScript.GetFile(sBaseDoc).Attributes = objScript.GetFile(sBaseDoc).Attributes And Not 1 -objScript.GetFile(sNewDoc).Attributes = objScript.GetFile(sNewDoc).Attributes And Not 1 - -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") -If Err.Number <> 0 Then - Wscript.Echo "You must have OpenOffice installed to perform this operation." - Wscript.Quit 1 -End If - -On Error Goto 0 - -'Because this is a diff, TortoiseSVN marks the files as read-only. -'However, OpenOffice will not compare any file with that flag set. -'Make sure we un-set that flag. -Set objFSO = CreateObject("Scripting.FileSystemObject") -Set objFile = objFSO.GetFile(sNewDoc) -If (objFile.Attributes AND 1)=1 Then - objFile.Attributes = objFile.Attributes XOR 1 -End If - -'Create the DesktopSet -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) - -'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 the frame -Set Frame = objDesktop.getCurrentFrame - -Set dispatcher=objServiceManager.CreateInstance("com.sun.star.frame.DispatchHelper") - -'Execute the comparison -dispatcher.executeDispatch Frame, ".uno:ShowTrackedChanges", "", 0, oPropertyValue -oPropertyValue(0).Name = "URL" -oPropertyValue(0).Value = sBaseDoc -dispatcher.executeDispatch Frame, ".uno:CompareDocuments", "", 0, oPropertyValue +' extensions: odt;ods +' +' TortoiseSVN Diff script for Open Office Text files +' +' Copyright (C) 2004-2009 the TortoiseSVN team +' This file is distributed under the same license as TortoiseSVN +' +' Last commit by: +' $Author$ +' $Date$ +' $Rev$ +' +' Authors: +' Jonathan Ashley, 2007 +' Stefan Küng, 2006, 2009 +' +dim objArgs,num,sBaseDoc,sNewDoc,objScript,word,destination + +Set objArgs = WScript.Arguments +num = objArgs.Count +if num < 2 then + MsgBox "Usage: [CScript | WScript] diff-odt.vbs base.odt new.odt", vbExclamation, "Invalid arguments" + WScript.Quit 1 +end if + +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" + 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" + Wscript.Quit 1 +End If +'remove the file write protection +objScript.GetFile(sBaseDoc).Attributes = objScript.GetFile(sBaseDoc).Attributes And Not 1 +objScript.GetFile(sNewDoc).Attributes = objScript.GetFile(sNewDoc).Attributes And Not 1 + +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") +If Err.Number <> 0 Then + Wscript.Echo "You must have OpenOffice installed to perform this operation." + Wscript.Quit 1 +End If + +On Error Goto 0 + +'Because this is a diff, TortoiseSVN marks the files as read-only. +'However, OpenOffice will not compare any file with that flag set. +'Make sure we un-set that flag. +Set objFSO = CreateObject("Scripting.FileSystemObject") +Set objFile = objFSO.GetFile(sNewDoc) +If (objFile.Attributes AND 1)=1 Then + objFile.Attributes = objFile.Attributes XOR 1 +End If + +'Create the DesktopSet +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) + +'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 the frame +Set Frame = objDesktop.getCurrentFrame + +Set dispatcher=objServiceManager.CreateInstance("com.sun.star.frame.DispatchHelper") + +'Execute the comparison +dispatcher.executeDispatch Frame, ".uno:ShowTrackedChanges", "", 0, oPropertyValue +oPropertyValue(0).Name = "URL" +oPropertyValue(0).Value = sBaseDoc +dispatcher.executeDispatch Frame, ".uno:CompareDocuments", "", 0, oPropertyValue diff --git a/contrib/diff-scripts/diff-ppt.js b/contrib/diff-scripts/diff-ppt.js index 7878b694e..49074a759 100644 --- a/contrib/diff-scripts/diff-ppt.js +++ b/contrib/diff-scripts/diff-ppt.js @@ -1,101 +1,105 @@ -// extensions: ppt;pptx;pptm -// -// TortoiseSVN Diff script for Powerpoint files -// -// Copyright (C) 2004-2009 the TortoiseSVN team -// This file is distributed under the same license as TortoiseSVN -// -// Last commit by: -// $Author$ -// $Date$ -// $Rev$ -// -// Authors: -// Arne Moor, 2006 -// - -/* -This script starts PowerPoint and compares the two given presentations. -To better see the changes and get the highlighting feature of PowerPoint -click on "Apply all changes to the presentation" on the reviewing toolbar. -*/ - -function PptAppMajorVersion(PowerPoint) -{ - var pptVersion; - try - { - pptVersion = PowerPoint.Version.toString(); - if (pptVersion.indexOf(".") > 0) - { - pptVersion = pptVersion.substr(0, pptVersion.indexOf(".")); - } - if (pptVersion === "") - return 0; - else - return parseInt(pptVersion); - } - catch (e) - { - return 0; - } -} - -var objArgs, num, sBasePpt, sNewPpt, objScript, powerpoint, source; - -objArgs = WScript.Arguments; -num = objArgs.length; -if (num < 2) -{ - WScript.Echo("Usage: [CScript | WScript] diff-ppt.js base.ppt new.ppt"); - WScript.Quit(1); -} - -sBasePpt = objArgs(0); -sNewPpt = objArgs(1); - -objScript = new ActiveXObject("Scripting.FileSystemObject"); - -if (!objScript.FileExists(sBasePpt)) -{ - WScript.Echo("File " + sBasePpt + " does not exist. Cannot compare the presentations."); - WScript.Quit(1); -} - -if (!objScript.FileExists(sNewPpt)) -{ - WScript.Echo("File " + sNewPpt + " does not exist. Cannot compare the presentations."); - WScript.Quit(1); -} - -objScript = null; - -try -{ - powerpoint = WScript.CreateObject("Powerpoint.Application"); -} -catch (e) -{ - WScript.Echo("You must have Microsoft Powerpoint installed to perform this operation."); - WScript.Quit(1); -} - -if (PptAppMajorVersion(powerpoint) === 12) -{ - WScript.Echo("Microsoft Powerpoint 2007 doesn't provide the DIFF features any more. Sorry!"); - WScript.Quit(1); -} -else -{ - powerpoint.visible = true; - - // Open the original (base) document - source = powerpoint.Presentations.Open(sBasePpt); - - // Merge the new document, to show the changes - source.Merge(sNewPpt); - - // Mark the comparison presentation as saved to prevent the annoying - // "Save as" dialog from appearing. - powerpoint.ActivePresentation.Saved = 1; -} +// extensions: ppt;pptx;pptm +// +// TortoiseSVN Diff script for Powerpoint files +// +// Copyright (C) 2004-2009 the TortoiseSVN team +// This file is distributed under the same license as TortoiseSVN +// +// Last commit by: +// $Author$ +// $Date$ +// $Rev$ +// +// Authors: +// Arne Moor, 2006 +// + +/* +This script starts PowerPoint and compares the two given presentations. +To better see the changes and get the highlighting feature of PowerPoint +click on "Apply all changes to the presentation" on the reviewing toolbar. +*/ + +function PptAppMajorVersion(PowerPoint) +{ + var pptVersion; + try + { + pptVersion = PowerPoint.Version.toString(); + if (pptVersion.indexOf(".") > 0) + { + pptVersion = pptVersion.substr(0, pptVersion.indexOf(".")); + } + if (pptVersion === "") + { + return 0; + } + else + { + return parseInt(pptVersion, 10); + } + } + catch (e) + { + return 0; + } +} + +var objArgs, num, sBasePpt, sNewPpt, objScript, powerpoint, source; + +objArgs = WScript.Arguments; +num = objArgs.length; +if (num < 2) +{ + WScript.Echo("Usage: [CScript | WScript] diff-ppt.js base.ppt new.ppt"); + WScript.Quit(1); +} + +sBasePpt = objArgs(0); +sNewPpt = objArgs(1); + +objScript = new ActiveXObject("Scripting.FileSystemObject"); + +if (!objScript.FileExists(sBasePpt)) +{ + WScript.Echo("File " + sBasePpt + " does not exist. Cannot compare the presentations."); + WScript.Quit(1); +} + +if (!objScript.FileExists(sNewPpt)) +{ + WScript.Echo("File " + sNewPpt + " does not exist. Cannot compare the presentations."); + WScript.Quit(1); +} + +objScript = null; + +try +{ + powerpoint = WScript.CreateObject("Powerpoint.Application"); +} +catch (e) +{ + WScript.Echo("You must have Microsoft Powerpoint installed to perform this operation."); + WScript.Quit(1); +} + +if (PptAppMajorVersion(powerpoint) === 12) +{ + WScript.Echo("Microsoft Powerpoint 2007 doesn't provide the DIFF features any more. Sorry!"); + WScript.Quit(1); +} +else +{ + powerpoint.visible = true; + + // Open the original (base) document + source = powerpoint.Presentations.Open(sBasePpt); + + // Merge the new document, to show the changes + source.Merge(sNewPpt); + + // Mark the comparison presentation as saved to prevent the annoying + // "Save as" dialog from appearing. + powerpoint.ActivePresentation.Saved = 1; +} diff --git a/contrib/diff-scripts/diff-sxw.vbs b/contrib/diff-scripts/diff-sxw.vbs index a8663d61e..87da9442d 100644 --- a/contrib/diff-scripts/diff-sxw.vbs +++ b/contrib/diff-scripts/diff-sxw.vbs @@ -1,70 +1,70 @@ -' -' TortoiseSVN Diff script for Open Office Calc files -' -' Copyright (C) 2004-2008 the TortoiseSVN team -' This file is distributed under the same license as TortoiseSVN -' -' Last commit by: -' $Author$ -' $Date$ -' $Rev$ -' -' Authors: -' Jonathan Ashley, 2007 -' Stefan Küng, 2006 -' -dim objArgs,num,sBaseDoc,sNewDoc,objScript,word,destination - -Set objArgs = WScript.Arguments -num = objArgs.Count -if num < 2 then - MsgBox "Usage: [CScript | WScript] compare.vbs base.doc new.doc", vbExclamation, "Invalid arguments" - WScript.Quit 1 -end if - -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" - 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" - Wscript.Quit 1 -End If - -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") -If Err.Number <> 0 Then - Wscript.Echo "You must have OpenOffice installed to perform this operation." - Wscript.Quit 1 -End If - -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 - -'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) +' +' TortoiseSVN Diff script for Open Office Calc files +' +' Copyright (C) 2004-2008 the TortoiseSVN team +' This file is distributed under the same license as TortoiseSVN +' +' Last commit by: +' $Author$ +' $Date$ +' $Rev$ +' +' Authors: +' Jonathan Ashley, 2007 +' Stefan Küng, 2006 +' +dim objArgs,num,sBaseDoc,sNewDoc,objScript,word,destination + +Set objArgs = WScript.Arguments +num = objArgs.Count +if num < 2 then + MsgBox "Usage: [CScript | WScript] compare.vbs base.doc new.doc", vbExclamation, "Invalid arguments" + WScript.Quit 1 +end if + +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" + 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" + Wscript.Quit 1 +End If + +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") +If Err.Number <> 0 Then + Wscript.Echo "You must have OpenOffice installed to perform this operation." + Wscript.Quit 1 +End If + +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 + +'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) diff --git a/contrib/diff-scripts/diff-xls.js b/contrib/diff-scripts/diff-xls.js index ba148aa9c..79773f7a5 100644 --- a/contrib/diff-scripts/diff-xls.js +++ b/contrib/diff-scripts/diff-xls.js @@ -1,294 +1,294 @@ -// extensions: xls;xlsx;xlsm;xlsb;xlam -// -// TortoiseSVN Diff script for Excel files -// -// Copyright (C) 2004-2008 the TortoiseSVN team -// This file is distributed under the same license as TortoiseSVN -// -// Last commit by: -// $Author$ -// $Date$ -// $Rev$ -// -// Authors: -// Hiroki Najima , 2013 -// Michael Joras , 2008 -// Suraj Barkale, 2006 -// - -// ----- configuration ----- -// Fast mode switch -// Fast mode does not copy Worksheets but require opened base document at the same time. -var bFastMode = false; - -// ----- constants ----- -var vbCritical = 0x10; -var vbExclamation = 0x30; -//var vbInformation = 0x40; - -var xlNone = -4142; -var xlMaximized = -4137; -var xlArrangeStyleHorizontal = -4128; -var xlCellValue = 1; -//var xlExpression = 2; -//var xlEqual = 3; -var xlNotEqual = 4; - -//var vOffice95 = 7; -//var vOffice97 = 8; -//var vOffice2000 = 9; -//var vOffice2002 = 10; -var vOffice2003 = 11; -//var vOffice2007 = 12; -//var vOffice2010 = 14; -//var vOffice2013 = 15; - -// ----- main ----- - -var aWarningMessages = Array(); - -var objArgs = WScript.Arguments; -if (objArgs.length < 2) -{ - Abort("Usage: [CScript | WScript] diff-xls.js base.xls new.xls", "Invalid arguments"); -} - -var sBaseDoc = objArgs(0); -var sNewDoc = objArgs(1); - -var objScript = new ActiveXObject("Scripting.FileSystemObject"); - -if (objScript.GetBaseName(sBaseDoc) === objScript.GetBaseName(sNewDoc)) -{ - Abort("File '" + sBaseDoc + "' and '" + sNewDoc + "' is same file name.\nCannot compare the documents.", "Same file name"); -} - -if (!objScript.FileExists(sBaseDoc)) -{ - Abort("File '" + sBaseDoc + "' does not exist.\nCannot compare the documents.", "File not found"); -} - -if (!objScript.FileExists(sNewDoc)) -{ - Abort("File '" + sNewDoc + "' does not exist.\nCannot compare the documents.", "File not found"); -} - -sBaseDoc = objScript.GetAbsolutePathName(sBaseDoc); -sNewDoc = objScript.GetAbsolutePathName(sNewDoc); -objScript = null; - -var objExcelApp; -try -{ - objExcelApp = WScript.CreateObject("Excel.Application"); -} -catch (e) -{ - Abort("You must have Excel installed to perform this operation.", "Excel Instantiation Failed"); -} -var fExcelVersion = parseInt(objExcelApp.Version); - -// Open base Excel book -var objBaseWorkbook; -try -{ - objBaseWorkbook = objExcelApp.Workbooks.Open(sBaseDoc, null, true); -} -catch (e) -{ - Abort("Failed to open '" + sBaseDoc + "'\nIt might not be a valid Excel file.", "File open error"); -} - -// Open new Excel book -var objNewWorkbook; -try -{ - objNewWorkbook = objExcelApp.Workbooks.Open(sNewDoc, null, true); -} -catch (e) -{ - Abort("Failed to open '" + sNewDoc + "'\nIt might not be a valid Excel file.", "File open error"); -} - -// Show Excel window -objExcelApp.Visible = true; - -// Arrange windows -if (objBaseWorkbook.ProtectWindows || objNewWorkbook.ProtectWindows) -{ - StoreWarning("Unable to arrange windows because one or both workbooks are protected."); -} -else -{ - // Make windows a compare side by side view - if (fExcelVersion >= vOffice2003) - { - objExcelApp.Windows.CompareSideBySideWith(objExcelApp.Windows(2).Caption); - } - objExcelApp.Application.WindowState = xlMaximized; - objExcelApp.Windows.Arrange(xlArrangeStyleHorizontal); -} - -if (!bFastMode && objNewWorkbook.ProtectWindows) -{ - StoreWarning("Fallback to fast mode bacause " + objNewWorkbook.Name + " is protected."); - bFastMode = true; -} - -// Mark differences in sNewDoc red -var length = objNewWorkbook.Worksheets.Count; -for (var i = 1; i <= length; i++) -{ - var objBaseWorksheet = objBaseWorkbook.Worksheets(i); - var objNewWorksheet = objNewWorkbook.Worksheets(i); - - UnhideWorksheet(objBaseWorksheet); - UnhideWorksheet(objNewWorksheet); - - if (!bFastMode) - { - objBaseWorkbook.Sheets(i).Copy(null, objNewWorkbook.Sheets(objNewWorkbook.Sheets.Count)); - var objDummyWorksheet = objNewWorkbook.Sheets(objNewWorkbook.Sheets.Count); - objDummyWorksheet.Name = "Dummy_for_Comparison" + i; - objDummyWorksheet.Visible = true; - if (fExcelVersion >= vOffice2003) - { - objDummyWorksheet.Tab.ColorIndex = 16; // 16:Dark gray RGB(128,128,128) - } - } - - if (objNewWorksheet.ProtectContents) - { - StoreWarning("Unable to mark differences to " + - ToAbsoluteReference(objNewWorksheet) + - " because the Worksheet is protected."); - } - else - { - objNewWorksheet.Cells.FormatConditions.Delete(); - var sFormula; - if (bFastMode) - { - sFormula = "=INDIRECT(\"" + ToAbsoluteReference(objBaseWorksheet) + "!\"&ADDRESS(ROW(),COLUMN()))"; - } - else - { - sFormula = "=INDIRECT(\"Dummy_for_Comparison" + i + "!\"&ADDRESS(ROW(),COLUMN()))"; - } - objNewWorksheet.Cells.FormatConditions.Add(xlCellValue, xlNotEqual, sFormula); - objNewWorksheet.Cells.FormatConditions(1).Interior.ColorIndex = 3; // 3:Red RGB(128,0,0) - } - -} - -// Activate first Worksheet -objBaseWorkbook.Sheets(1).Activate(); -objNewWorkbook.Sheets(1).Activate(); - -// Suppress save dialog if nothing changed -objBaseWorkbook.Saved = true; -objNewWorkbook.Saved = true; - -// Show warnings if exist -ShowWarning(); - -WScript.Quit(0); - - -// ----- functions ----- - -// Show Message Dialog -// VBcript's MsgBox emulation -function MsgBox(sMessage, iButtons, sTitle) -{ - var objShell = new ActiveXObject("WScript.Shell"); - objShell.popup(sMessage, 0, sTitle, iButtons); -} - -// Show an error message and quit script with cleanup Excel Application Object. -function Abort(sMessage, sTitle) -{ - MsgBox(sMessage, vbCritical, sTitle); - if (objExcelApp) - { - objExcelApp.Quit(); - } - WScript.Quit(1); -} - -// Unhide the Worksheet if it is hidden. -// This also sets color to the tab, if Office2003 or later. -// - 46(Orange) : Hidden Worksheet -// - xlNone(default) : Not hidden Worksheet -function UnhideWorksheet(objWorksheet) -{ - if (objWorksheet.Visible) - { - if (fExcelVersion >= vOffice2003) - { - if (objWorksheet.Tab.ColorIndex !== xlNone) - { - if (objWorksheet.Parent.ProtectStructure) - { - StoreWarning("Unable to set tab color to " + - ToAbsoluteReference(objWorksheet) + - " because the Workbook's structure is protected."); - } - else - { - objWorksheet.Tab.ColorIndex = xlNone; - } - } - } - } - else - { - if (objWorksheet.Parent.ProtectStructure) - { - StoreWarning("Unable to unhide " + - ToAbsoluteReference(objWorksheet) + - " because the Workbook's structure is protected."); - } - else - { - objWorksheet.Visible = true; - if (fExcelVersion >= vOffice2003) - { - objWorksheet.Tab.ColorIndex = 10; // 10:Green RGB(0,128,0) - } - } - } -} - -// Generate Absolute Reference Formula of Worksheet. -function ToAbsoluteReference(objWorksheet) -{ - return "[" + objWorksheet.Parent.Name + "]" + objWorksheet.Name; -} - -// Accumulate a warning message. -function StoreWarning(sMessage) -{ - aWarningMessages[aWarningMessages.length] = sMessage; -} - -// Show accumulated warning messages if exist. -// To avoid make huge message dialog, this limits message count to show. -function ShowWarning() -{ - if (aWarningMessages.length === 0) - { - return; - } - var sMessage = "The following warnings occurred while processing.\n"; - for (var i = 0; i < aWarningMessages.length; i++) - { - if (i >= 10) - { - sMessage += "... And more " + (aWarningMessages.length - i) + " messages"; - break; - } - sMessage += "[" + (i + 1) + "] " + aWarningMessages[i] + "\n"; - } - MsgBox(sMessage, vbExclamation, "Warning"); -} +// extensions: xls;xlsx;xlsm;xlsb;xlam +// +// TortoiseSVN Diff script for Excel files +// +// Copyright (C) 2004-2008 the TortoiseSVN team +// This file is distributed under the same license as TortoiseSVN +// +// Last commit by: +// $Author$ +// $Date$ +// $Rev$ +// +// Authors: +// Hiroki Najima , 2013 +// Michael Joras , 2008 +// Suraj Barkale, 2006 +// + +// ----- configuration ----- +// Fast mode switch +// Fast mode does not copy Worksheets but require opened base document at the same time. +var bFastMode = false; + +// ----- constants ----- +var vbCritical = 0x10; +var vbExclamation = 0x30; +//var vbInformation = 0x40; + +var xlNone = -4142; +var xlMaximized = -4137; +var xlArrangeStyleHorizontal = -4128; +var xlCellValue = 1; +//var xlExpression = 2; +//var xlEqual = 3; +var xlNotEqual = 4; + +//var vOffice95 = 7; +//var vOffice97 = 8; +//var vOffice2000 = 9; +//var vOffice2002 = 10; +var vOffice2003 = 11; +//var vOffice2007 = 12; +//var vOffice2010 = 14; +//var vOffice2013 = 15; + +// ----- main ----- + +var aWarningMessages = Array(); + +var objArgs = WScript.Arguments; +if (objArgs.length < 2) +{ + Abort("Usage: [CScript | WScript] diff-xls.js base.xls new.xls", "Invalid arguments"); +} + +var sBaseDoc = objArgs(0); +var sNewDoc = objArgs(1); + +var objScript = new ActiveXObject("Scripting.FileSystemObject"); + +if (objScript.GetBaseName(sBaseDoc) === objScript.GetBaseName(sNewDoc)) +{ + Abort("File '" + sBaseDoc + "' and '" + sNewDoc + "' is same file name.\nCannot compare the documents.", "Same file name"); +} + +if (!objScript.FileExists(sBaseDoc)) +{ + Abort("File '" + sBaseDoc + "' does not exist.\nCannot compare the documents.", "File not found"); +} + +if (!objScript.FileExists(sNewDoc)) +{ + Abort("File '" + sNewDoc + "' does not exist.\nCannot compare the documents.", "File not found"); +} + +sBaseDoc = objScript.GetAbsolutePathName(sBaseDoc); +sNewDoc = objScript.GetAbsolutePathName(sNewDoc); +objScript = null; + +var objExcelApp; +try +{ + objExcelApp = WScript.CreateObject("Excel.Application"); +} +catch (e) +{ + Abort("You must have Excel installed to perform this operation.", "Excel Instantiation Failed"); +} +var fExcelVersion = parseInt(objExcelApp.Version, 10); + +// Open base Excel book +var objBaseWorkbook; +try +{ + objBaseWorkbook = objExcelApp.Workbooks.Open(sBaseDoc, null, true); +} +catch (e) +{ + Abort("Failed to open '" + sBaseDoc + "'\nIt might not be a valid Excel file.", "File open error"); +} + +// Open new Excel book +var objNewWorkbook; +try +{ + objNewWorkbook = objExcelApp.Workbooks.Open(sNewDoc, null, true); +} +catch (e) +{ + Abort("Failed to open '" + sNewDoc + "'\nIt might not be a valid Excel file.", "File open error"); +} + +// Show Excel window +objExcelApp.Visible = true; + +// Arrange windows +if (objBaseWorkbook.ProtectWindows || objNewWorkbook.ProtectWindows) +{ + StoreWarning("Unable to arrange windows because one or both Workbooks are protected."); +} +else +{ + // Make windows a compare side by side view + if (fExcelVersion >= vOffice2003) + { + objExcelApp.Windows.CompareSideBySideWith(objExcelApp.Windows(2).Caption); + } + objExcelApp.Application.WindowState = xlMaximized; + objExcelApp.Windows.Arrange(xlArrangeStyleHorizontal); +} + +if (!bFastMode && objNewWorkbook.ProtectWindows) +{ + StoreWarning("Fall back to fast mode because " + objNewWorkbook.Name + " is protected."); + bFastMode = true; +} + +// Mark differences in sNewDoc red +var length = objNewWorkbook.Worksheets.Count; +for (var i = 1; i <= length; i++) +{ + var objBaseWorksheet = objBaseWorkbook.Worksheets(i); + var objNewWorksheet = objNewWorkbook.Worksheets(i); + + UnhideWorksheet(objBaseWorksheet); + UnhideWorksheet(objNewWorksheet); + + if (!bFastMode) + { + objBaseWorkbook.Sheets(i).Copy(null, objNewWorkbook.Sheets(objNewWorkbook.Sheets.Count)); + var objDummyWorksheet = objNewWorkbook.Sheets(objNewWorkbook.Sheets.Count); + objDummyWorksheet.Name = "Dummy_for_Comparison" + i; + objDummyWorksheet.Visible = true; + if (fExcelVersion >= vOffice2003) + { + objDummyWorksheet.Tab.ColorIndex = 16; // 16:Dark gray RGB(128,128,128) + } + } + + if (objNewWorksheet.ProtectContents) + { + StoreWarning("Unable to mark differences to " + + ToAbsoluteReference(objNewWorksheet) + + " because the Worksheet is protected."); + } + else + { + objNewWorksheet.Cells.FormatConditions.Delete(); + var sFormula; + if (bFastMode) + { + sFormula = "=INDIRECT(\"" + ToAbsoluteReference(objBaseWorksheet) + "!\"&ADDRESS(ROW(),COLUMN()))"; + } + else + { + sFormula = "=INDIRECT(\"Dummy_for_Comparison" + i + "!\"&ADDRESS(ROW(),COLUMN()))"; + } + objNewWorksheet.Cells.FormatConditions.Add(xlCellValue, xlNotEqual, sFormula); + objNewWorksheet.Cells.FormatConditions(1).Interior.ColorIndex = 3; // 3:Red RGB(128,0,0) + } + +} + +// Activate first Worksheet +objBaseWorkbook.Sheets(1).Activate(); +objNewWorkbook.Sheets(1).Activate(); + +// Suppress save dialog if nothing changed +objBaseWorkbook.Saved = true; +objNewWorkbook.Saved = true; + +// Show warnings if exist +ShowWarning(); + +WScript.Quit(0); + + +// ----- functions ----- + +// Show Message Dialog +// VBcript's MsgBox emulation +function MsgBox(sMessage, iButtons, sTitle) +{ + var objShell = new ActiveXObject("WScript.Shell"); + objShell.popup(sMessage, 0, sTitle, iButtons); +} + +// Show an error message and quit script with cleanup Excel Application Object. +function Abort(sMessage, sTitle) +{ + MsgBox(sMessage, vbCritical, sTitle); + if (objExcelApp) + { + objExcelApp.Quit(); + } + WScript.Quit(1); +} + +// Unhide the Worksheet if it is hidden. +// This also sets color to the tab, if Office2003 or later. +// - 46(Orange) : Hidden Worksheet +// - xlNone(default) : Not hidden Worksheet +function UnhideWorksheet(objWorksheet) +{ + if (objWorksheet.Visible) + { + if (fExcelVersion >= vOffice2003) + { + if (objWorksheet.Tab.ColorIndex !== xlNone) + { + if (objWorksheet.Parent.ProtectStructure) + { + StoreWarning("Unable to set tab color to " + + ToAbsoluteReference(objWorksheet) + + " because the Workbook's structure is protected."); + } + else + { + objWorksheet.Tab.ColorIndex = xlNone; + } + } + } + } + else + { + if (objWorksheet.Parent.ProtectStructure) + { + StoreWarning("Unable to unhide " + + ToAbsoluteReference(objWorksheet) + + " because the Workbook's structure is protected."); + } + else + { + objWorksheet.Visible = true; + if (fExcelVersion >= vOffice2003) + { + objWorksheet.Tab.ColorIndex = 10; // 10:Green RGB(0,128,0) + } + } + } +} + +// Generate Absolute Reference Formula of Worksheet. +function ToAbsoluteReference(objWorksheet) +{ + return "[" + objWorksheet.Parent.Name + "]" + objWorksheet.Name; +} + +// Accumulate a warning message. +function StoreWarning(sMessage) +{ + aWarningMessages[aWarningMessages.length] = sMessage; +} + +// Show accumulated warning messages if exist. +// To avoid make huge message dialog, this limits message count to show. +function ShowWarning() +{ + if (aWarningMessages.length === 0) + { + return; + } + var sMessage = "The following warnings occurred while processing.\n"; + for (var i = 0; i < aWarningMessages.length; i++) + { + if (i >= 10) + { + sMessage += "... And more " + (aWarningMessages.length - i) + " messages"; + break; + } + sMessage += "[" + (i + 1) + "] " + aWarningMessages[i] + "\n"; + } + MsgBox(sMessage, vbExclamation, "Warning"); +} diff --git a/contrib/diff-scripts/merge-doc.js b/contrib/diff-scripts/merge-doc.js index c4bea7cc8..c102638b3 100644 --- a/contrib/diff-scripts/merge-doc.js +++ b/contrib/diff-scripts/merge-doc.js @@ -1,128 +1,128 @@ -// extensions: doc;docx;docm -// -// TortoiseSVN Merge script for Word Doc files -// -// Copyright (C) 2004-2008, 2011 the TortoiseSVN team -// This file is distributed under the same license as TortoiseSVN -// -// Last commit by: -// $Author$ -// $Date$ -// $Rev$ -// -// Authors: -// Dan Sheridan, 2008 -// Davide Orlandi and Hans-Emil Skogh, 2005 -// Richard Horton, 2011 -// - -var objArgs, num, sTheirDoc, sMyDoc, sBaseDoc, sMergedDoc, - objScript, word, baseDoc, myDoc, theirDoc, WSHShell; - -// Microsoft Office versions for Microsoft Windows OS -var vOffice2000 = 9; -var vOffice2002 = 10; -//var vOffice2003 = 11; -var vOffice2007 = 12; -var vOffice2010 = 14; -// WdCompareTarget -var wdCompareTargetSelected = 0; -//var wdCompareTargetCurrent = 1; -var wdCompareTargetNew = 2; -var wdMergeTargetCurrent = 1; - -objArgs = WScript.Arguments; -num = objArgs.length; -if (num < 4) -{ - WScript.Echo("Usage: [CScript | WScript] merge-doc.js merged.doc theirs.doc mine.doc base.doc"); - WScript.Quit(1); -} - -sMergedDoc = objArgs(0); -sTheirDoc = objArgs(1); -sMyDoc = objArgs(2); -sBaseDoc = objArgs(3); - -objScript = new ActiveXObject("Scripting.FileSystemObject"); - -if (!objScript.FileExists(sTheirDoc)) -{ - WScript.Echo("File " + sTheirDoc + " does not exist. Cannot compare the documents.", vbExclamation, "File not found"); - WScript.Quit(1); -} - -if (!objScript.FileExists(sMergedDoc)) -{ - WScript.Echo("File " + sMergedDoc + " does not exist. Cannot compare the documents.", vbExclamation, "File not found"); - WScript.Quit(1); -} - -objScript = null; - -try -{ - word = WScript.CreateObject("Word.Application"); -} -catch (e) -{ - WScript.Echo("You must have Microsoft Word installed to perform this operation."); - WScript.Quit(1); -} - -word.visible = true; - -// Open the base document -baseDoc = word.Documents.Open(sTheirDoc); - -// Merge into the "My" document -if (parseInt(word.Version) < vOffice2000) -{ - baseDoc.Compare(sMergedDoc); -} -else if (parseInt(word.Version) < vOffice2007) -{ - baseDoc.Compare(sMergedDoc, "Comparison", wdCompareTargetNew, true, true); -} -else if (parseInt(word.Version) < vOffice2010) -{ - baseDoc.Merge(sMergedDoc); -} -else -{ - //2010 - handle slightly differently as the basic merge isn't that good - //note this is designed specifically for svn 3 way merges, during the commit conflict resolution process - theirDoc = baseDoc; - baseDoc = word.Documents.Open(sBaseDoc); - myDoc = word.Documents.Open(sMyDoc); - - baseDoc.Activate(); //required otherwise it compares the wrong docs !!! - baseDoc.Compare(sTheirDoc, "theirs", wdCompareTargetSelected, true, true); - - baseDoc.Activate(); //required otherwise it compares the wrong docs !!! - baseDoc.Compare(sMyDoc, "mine", wdCompareTargetSelected, true, true); - - //theirDoc.Save(); - //myDoc.Save(); - myDoc.Activate(); //required? just in case - myDoc.Merge(sTheirDoc, wdMergeTargetCurrent); -} - -// Show the merge result -if (parseInt(word.Version) < vOffice2007) -{ - word.ActiveDocument.Windows(1).Visible = 1; -} - -// Close the first document -if ((parseInt(word.Version) >= vOffice2002) && (parseInt(word.Version) < vOffice2010)) -{ - baseDoc.Close(); -} - -// Show usage hint message -WSHShell = WScript.CreateObject("WScript.Shell"); -if (WSHShell.Popup("You have to accept or reject the changes before\nsaving the document to prevent future problems.\n\nWould you like to see a help page on how to do this?", 0, "TSVN Word Merge", 4 + 64) === 6) -{ - WSHShell.Run("http://office.microsoft.com/en-us/assistance/HP030823691033.aspx"); -} +// extensions: doc;docx;docm +// +// TortoiseSVN Merge script for Word Doc files +// +// Copyright (C) 2004-2008, 2011 the TortoiseSVN team +// This file is distributed under the same license as TortoiseSVN +// +// Last commit by: +// $Author$ +// $Date$ +// $Rev$ +// +// Authors: +// Dan Sheridan, 2008 +// Davide Orlandi and Hans-Emil Skogh, 2005 +// Richard Horton, 2011 +// + +var objArgs, num, sTheirDoc, sMyDoc, sBaseDoc, sMergedDoc, + objScript, word, baseDoc, myDoc, theirDoc, WSHShell; + +// Microsoft Office versions for Microsoft Windows OS +var vOffice2000 = 9; +var vOffice2002 = 10; +//var vOffice2003 = 11; +var vOffice2007 = 12; +var vOffice2010 = 14; +// WdCompareTarget +var wdCompareTargetSelected = 0; +//var wdCompareTargetCurrent = 1; +var wdCompareTargetNew = 2; +var wdMergeTargetCurrent = 1; + +objArgs = WScript.Arguments; +num = objArgs.length; +if (num < 4) +{ + WScript.Echo("Usage: [CScript | WScript] merge-doc.js merged.doc theirs.doc mine.doc base.doc"); + WScript.Quit(1); +} + +sMergedDoc = objArgs(0); +sTheirDoc = objArgs(1); +sMyDoc = objArgs(2); +sBaseDoc = objArgs(3); + +objScript = new ActiveXObject("Scripting.FileSystemObject"); + +if (!objScript.FileExists(sTheirDoc)) +{ + WScript.Echo("File " + sTheirDoc + " does not exist. Cannot compare the documents.", vbExclamation, "File not found"); + WScript.Quit(1); +} + +if (!objScript.FileExists(sMergedDoc)) +{ + WScript.Echo("File " + sMergedDoc + " does not exist. Cannot compare the documents.", vbExclamation, "File not found"); + WScript.Quit(1); +} + +objScript = null; + +try +{ + word = WScript.CreateObject("Word.Application"); +} +catch (e) +{ + WScript.Echo("You must have Microsoft Word installed to perform this operation."); + WScript.Quit(1); +} + +word.visible = true; + +// Open the base document +baseDoc = word.Documents.Open(sTheirDoc); + +// Merge into the "My" document +if (parseInt(word.Version, 10) < vOffice2000) +{ + baseDoc.Compare(sMergedDoc); +} +else if (parseInt(word.Version, 10) < vOffice2007) +{ + baseDoc.Compare(sMergedDoc, "Comparison", wdCompareTargetNew, true, true); +} +else if (parseInt(word.Version, 10) < vOffice2010) +{ + baseDoc.Merge(sMergedDoc); +} +else +{ + //2010 - handle slightly differently as the basic merge isn't that good + //note this is designed specifically for svn 3 way merges, during the commit conflict resolution process + theirDoc = baseDoc; + baseDoc = word.Documents.Open(sBaseDoc); + myDoc = word.Documents.Open(sMyDoc); + + baseDoc.Activate(); //required otherwise it compares the wrong docs !!! + baseDoc.Compare(sTheirDoc, "theirs", wdCompareTargetSelected, true, true); + + baseDoc.Activate(); //required otherwise it compares the wrong docs !!! + baseDoc.Compare(sMyDoc, "mine", wdCompareTargetSelected, true, true); + + //theirDoc.Save(); + //myDoc.Save(); + myDoc.Activate(); //required? just in case + myDoc.Merge(sTheirDoc, wdMergeTargetCurrent); +} + +// Show the merge result +if (parseInt(word.Version, 10) < vOffice2007) +{ + word.ActiveDocument.Windows(1).Visible = 1; +} + +// Close the first document +if ((parseInt(word.Version, 10) >= vOffice2002) && (parseInt(word.Version, 10) < vOffice2010)) +{ + baseDoc.Close(); +} + +// Show usage hint message +WSHShell = WScript.CreateObject("WScript.Shell"); +if (WSHShell.Popup("You have to accept or reject the changes before\nsaving the document to prevent future problems.\n\nWould you like to see a help page on how to do this?", 0, "TSVN Word Merge", 4 + 64) === 6) +{ + WSHShell.Run("http://office.microsoft.com/en-us/assistance/HP030823691033.aspx"); +} diff --git a/contrib/diff-scripts/merge-ods.vbs b/contrib/diff-scripts/merge-ods.vbs index b6596e774..887805516 100644 --- a/contrib/diff-scripts/merge-ods.vbs +++ b/contrib/diff-scripts/merge-ods.vbs @@ -1,88 +1,88 @@ -' extensions: ods;odt;sxw -' -' TortoiseSVN Merge script for Open Office Calc files -' -' Copyright (C) 2004-2009 the TortoiseSVN team -' This file is distributed under the same license as TortoiseSVN -' -' Last commit by: -' $Author$ -' $Date$ -' $Rev$ -' -' Authors: -' Jonathan Ashley, 2007 -' Stefan Küng, 2006, 2009 -' -dim objArgs,num,sBaseDoc,sMergedDoc,sTheirDoc,sMyDoc,objScript,word,destination - -Set objArgs = WScript.Arguments -num = objArgs.Count -if num < 4 then - MsgBox "Usage: [CScript | WScript] merge-ods.vbs %merged %theirs %mine %base", vbExclamation, "Invalid arguments" - WScript.Quit 1 -end if - -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" - 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" - Wscript.Quit 1 -End If -'remove the file write protection -objScript.GetFile(sMyDoc).Attributes = objScript.GetFile(sMyDoc).Attributes And Not 1 -objScript.GetFile(sTheirDoc).Attributes = objScript.GetFile(sTheirDoc).Attributes And Not 1 - -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") -If Err.Number <> 0 Then - Wscript.Echo "You must have OpenOffice installed to perform this operation." - Wscript.Quit 1 -End If - -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 - -'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 the frame -Set Frame = objDesktop.getCurrentFrame - -Set dispatcher=objServiceManager.CreateInstance("com.sun.star.frame.DispatchHelper") - -'Execute the comparison -Dispatcher.executeDispatch Frame, ".uno:ShowTrackedChanges", "", 0, oPropertyValue -oPropertyValue(0).Name = "URL" -oPropertyValue(0).Value = sTheirDoc -Dispatcher.executeDispatch Frame, ".uno:CompareDocuments", "", 0, oPropertyValue +' extensions: ods;odt;sxw +' +' TortoiseSVN Merge script for Open Office Calc files +' +' Copyright (C) 2004-2009 the TortoiseSVN team +' This file is distributed under the same license as TortoiseSVN +' +' Last commit by: +' $Author$ +' $Date$ +' $Rev$ +' +' Authors: +' Jonathan Ashley, 2007 +' Stefan Küng, 2006, 2009 +' +dim objArgs,num,sBaseDoc,sMergedDoc,sTheirDoc,sMyDoc,objScript,word,destination + +Set objArgs = WScript.Arguments +num = objArgs.Count +if num < 4 then + MsgBox "Usage: [CScript | WScript] merge-ods.vbs %merged %theirs %mine %base", vbExclamation, "Invalid arguments" + WScript.Quit 1 +end if + +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" + 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" + Wscript.Quit 1 +End If +'remove the file write protection +objScript.GetFile(sMyDoc).Attributes = objScript.GetFile(sMyDoc).Attributes And Not 1 +objScript.GetFile(sTheirDoc).Attributes = objScript.GetFile(sTheirDoc).Attributes And Not 1 + +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") +If Err.Number <> 0 Then + Wscript.Echo "You must have OpenOffice installed to perform this operation." + Wscript.Quit 1 +End If + +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 + +'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 the frame +Set Frame = objDesktop.getCurrentFrame + +Set dispatcher=objServiceManager.CreateInstance("com.sun.star.frame.DispatchHelper") + +'Execute the comparison +Dispatcher.executeDispatch Frame, ".uno:ShowTrackedChanges", "", 0, oPropertyValue +oPropertyValue(0).Name = "URL" +oPropertyValue(0).Value = sTheirDoc +Dispatcher.executeDispatch Frame, ".uno:CompareDocuments", "", 0, oPropertyValue