OSDN Git Service

add contrib dir
[tortoisegit/TortoiseGitJp.git] / contrib / other / diff-scripts / merge-sxw.vbs
diff --git a/contrib/other/diff-scripts/merge-sxw.vbs b/contrib/other/diff-scripts/merge-sxw.vbs
new file mode 100644 (file)
index 0000000..e80631e
--- /dev/null
@@ -0,0 +1,84 @@
+'\r
+' TortoiseSVN Merge script for Open Office Writer files\r
+'\r
+' Copyright (C) 2004-2008 the TortoiseSVN team\r
+' This file is distributed under the same license as TortoiseSVN\r
+'\r
+' Last commit by:\r
+' $Author: steveking $\r
+' $Date: 2008-06-17 03:36:28 +0800 (Tue, 17 Jun 2008) $\r
+' $Rev: 13285 $\r
+'\r
+' Authors:\r
+' Jonathan Ashley, 2007\r
+' Stefan Küng, 2006\r
+'\r
+\r
+dim objArgs,num,sBaseDoc,sMergedDoc,sTheirDoc,sMyDoc,objScript,word,destination\r
+\r
+Set objArgs = WScript.Arguments\r
+num = objArgs.Count\r
+if num < 4 then\r
+   MsgBox "Usage: [CScript | WScript] merge-sxw.vbs %merged %theirs %mine %base", vbExclamation, "Invalid arguments"\r
+   WScript.Quit 1\r
+end if\r
+\r
+sMergedDoc=objArgs(0)\r
+sTheirDoc=objArgs(1)\r
+sMyDoc=objArgs(2)\r
+sBaseDoc=objArgs(3)\r
+\r
+Set objScript = CreateObject("Scripting.FileSystemObject")\r
+If objScript.FileExists(sMyDoc) = False Then\r
+    MsgBox "File " + sMyDoc +" does not exist.  Cannot compare the documents.", vbExclamation, "File not found"\r
+    Wscript.Quit 1\r
+End If\r
+If objScript.FileExists(sTheirDoc) = False Then\r
+    MsgBox "File " + sTheirDoc +" does not exist.  Cannot compare the documents.", vbExclamation, "File not found"\r
+    Wscript.Quit 1\r
+End If\r
+\r
+Set objScript = Nothing\r
+\r
+On Error Resume Next\r
+'The service manager is always the starting point\r
+'If there is no office running then an office is started\r
+Set objServiceManager= Wscript.CreateObject("com.sun.star.ServiceManager")\r
+If Err.Number <> 0 Then\r
+   Wscript.Echo "You must have OpenOffice installed to perform this operation."\r
+   Wscript.Quit 1\r
+End If\r
+\r
+On Error Goto 0\r
+'Create the DesktopSet \r
+Set objDesktop = objServiceManager.createInstance("com.sun.star.frame.Desktop")\r
+'Adjust the paths for OO\r
+sMyDoc=Replace(sMyDoc, "\", "/")\r
+sMyDoc=Replace(sMyDoc, ":", "|")\r
+sMyDoc=Replace(sMyDoc, "%", "%25")\r
+sMyDoc=Replace(sMyDoc, " ", "%20")\r
+sMyDoc="file:///"&sMyDoc\r
+sTheirDoc=Replace(sTheirDoc, "\", "/")\r
+sTheirDoc=Replace(sTheirDoc, ":", "|")\r
+sTheirDoc=Replace(sTheirDoc, "%", "%25")\r
+sTheirDoc=Replace(sTheirDoc, " ", "%20")\r
+sTheirDoc="file:///"&sTheirDoc\r
+\r
+'Open the %mine document\r
+Dim oPropertyValue(0)\r
+Set oPropertyValue(0) = objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")\r
+oPropertyValue(0).Name = "ShowTrackedChanges"\r
+oPropertyValue(0).Value = true\r
+Set objDocument=objDesktop.loadComponentFromURL(sMyDoc,"_blank", 0, oPropertyValue)\r
+\r
+'Set the frame\r
+Set Frame = objDesktop.getCurrentFrame\r
+\r
+Set dispatcher=objServiceManager.CreateInstance("com.sun.star.frame.DispatchHelper")\r
+\r
+'Execute the comparison\r
+Dispatcher.executeDispatch Frame, ".uno:ShowTrackedChanges", "", 0, oPropertyValue\r
+oPropertyValue(0).Name = "URL"\r
+oPropertyValue(0).Value = sTheirDoc\r
+Dispatcher.executeDispatch Frame, ".uno:CompareDocuments", "", 0, oPropertyValue\r
+\r