2 <implements type="Automation" id="dispatcher">
3 <property name="PluginEvent">
6 <property name="PluginDescription">
9 <property name="PluginFileFilters">
12 <property name="PluginIsAutomatic">
15 <property name="PluginExtendedProperties">
18 <method name="UnpackFile"/>
19 <method name="PackFile"/>
20 <method name="IsFolder"/>
21 <method name="UnpackFolder"/>
22 <method name="PackFolder"/>
23 <method name="ShowSettingsDialog"/>
26 <script language="VBS">
28 '/////////////////////////////////////////////////////////////////////////////
29 ' This is a plugin for WinMerge.
30 ' It will display the text content of MS PowerPoint files.
31 ' Copyright (C) 2016 Takashi Sawanaka
33 ' This program is free software; you can redistribute it and/or modify
34 ' it under the terms of the GNU General Public License as published by
35 ' the Free Software Foundation; either version 2 of the License, or
36 ' (at your option) any later version.
38 ' This program is distributed in the hope that it will be useful,
39 ' but WITHOUT ANY WARRANTY; without even the implied warranty of
40 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41 ' GNU General Public License for more details.
43 ' You should have received a copy of the GNU General Public License
44 ' along with this program; if not, write to the Free Software
45 ' Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
50 Const RegKeyPath = "HKCU\Software\Thingamahoochie\WinMerge\Plugins\CompareMSPowerPointFiles.sct\"
51 Dim MsgCannotGetMacros
52 MsgCannotGetMacros = "Cannot get Macros." & vbCrLf & _
53 " To allow WinMerge to compare macros, use MS Office to alter the settings in the Macro Security for the current application." & vbCrLf & _
54 " The Trust access to Visual Basic Project feature should be turned on to use this feature in WinMerge." & vbCrLf
56 Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
57 Dim wsh: Set wsh = CreateObject("WScript.Shell")
59 Function isAccessibleVBAProject(prs)
63 count = prs.VBProject.VBComponents.Count
64 isAccessibleVBAProject = (count > 0)
67 Function regRead(Key, DefaultValue)
68 regRead = DefaultValue
70 regRead = wsh.RegRead(Key)
73 Function writeObjectProperties(fo, items)
77 fo.WriteLine o.Name & ": " & o.Value
81 Function writeShape(fo, shp)
82 Dim shp2, shpType, r, c
86 fo.Write shp.Name & ": "
88 For r = 1 To shp.Table.Rows.Count
89 For c = 1 To shp.Table.Columns.Count
90 fo.Write "(" & r & ", " & c & "): "
91 writeShape fo, shp.Table.Cell(r, c).Shape
94 ElseIf shpType = 6 Then 'msoGroup = 6
95 For Each shp2 In shp.GroupItems
98 ElseIf shp.HasTextFrame Then
99 fo.WriteLine shp.TextFrame.TextRange.Characters.Text
105 Function writeTextsInShapes(fo, shps)
114 Function getModuleExtension(cmp)
117 getModuleExtension = ".cls"
119 getModuleExtension = ".frm"
121 getModuleExtension = ".bas"
125 Function saveSlideAsImage(sld, filename)
126 sld.Export filename, "PNG"
129 Function get_PluginEvent()
130 get_PluginEvent = "FILE_FOLDER_PACK_UNPACK"
133 Function get_PluginDescription()
134 get_PluginDescription = "Display the text content of MS PowerPoint files"
137 Function get_PluginFileFilters()
138 get_PluginFileFilters = "\.ppt(\..*)?$;\.pptx(\..*)?$;\.pptm(\..*)?$;\.ppa(\..*)?$;\.ppam(\..*)?$;\.potx(\..*)?$;\.potm(\..*)?$"
141 Function get_PluginIsAutomatic()
142 get_PluginIsAutomatic = True
145 Function get_PluginExtendedProperties()
146 get_PluginExtendedProperties = "ProcessType=Content Extraction;FileType=MS-PowerPoint;MenuCaption=MS-PowerPoint"
149 Function UnpackFile(fileSrc, fileDst, pbChanged, pSubcode)
156 Set fo = fso.CreateTextFile(fileDst, True, True)
158 Set pp = CreateObject("PowerPoint.Application")
160 pp.DisplayAlerts = False
162 Set prs = pp.Presentations.Open(fileSrc)
166 If regRead(RegKeyPath & "CompareDocumentProperties", False) Then
167 fo.WriteLine "[Document Properties]"
168 writeObjectProperties fo, prs.BuiltinDocumentProperties
172 For Each sld In prs.Slides
173 If regRead(RegKeyPath & "CompareTextsInShapes", True) Then
174 fo.WriteLine "[" & sld.Name & "]"
175 writeTextsInShapes fo, sld.Shapes
178 If regRead(RegKeyPath & "CompareTextsInNotesPage", True) Then
179 fo.WriteLine "[" & sld.Name & ".NotesPage]"
180 writeTextsInShapes fo, sld.NotesPage.Shapes
185 If regRead(RegKeyPath & "CompareVBAMacros", True) Then
186 If Not isAccessibleVBAProject(prs) Then
187 fo.WriteLine MsgCannotGetMacros
189 For Each cmp In prs.VBProject.VBComponents
190 fo.WriteLine "[CodeModule." & cmp.Name & "]"
191 If cmp.CodeModule.CountOfLines > 0 Then
192 fo.WriteLine cmp.CodeModule.Lines(1, cmp.CodeModule.CountOfLines)
212 Function PackFile(fileSrc, fileDst, pbChanged, pSubcode)
216 Function IsFolder(file)
217 IsFolder = regRead(RegKeyPath & "UnpackToFolder", False)
220 Function UnpackFolder(fileSrc, folderDst, pbChanged, pSubcode)
227 If Not fso.FolderExists(folderDst) Then fso.CreateFolder folderDst
229 Set pp = CreateObject("PowerPoint.Application")
231 pp.DisplayAlerts = False
233 Set prs = pp.Presentations.Open(fileSrc)
237 If regRead(RegKeyPath & "CompareDocumentProperties", False) Then
238 Set fo = fso.CreateTextFile(fso.BuildPath(folderDst, "(0)DocumentProperties.txt"), True, True)
239 writeObjectProperties fo, prs.BuiltinDocumentProperties
243 For Each sld In prs.Slides
244 If regRead(RegKeyPath & "CompareTextsInShapes", True) Then
245 Set fo = fso.CreateTextFile(fso.BuildPath(folderDst, sld.Name & ".txt"), True, True)
246 writeTextsInShapes fo, sld.Shapes
250 If regRead(RegKeyPath & "CompareTextsInNotesPage", True) Then
251 Set fo = fso.CreateTextFile(fso.BuildPath(folderDst, sld.Name & "_NotesPage.txt"), True, True)
252 writeTextsInShapes fo, sld.NotesPage.Shapes
256 If regRead(RegKeyPath & "CompareSlideAsImage", True) Then
257 saveSlideAsImage sld, fso.BuildPath(folderDst, sld.Name & ".png")
260 If regRead(RegKeyPath & "CompareVBAMacros", True) Then
261 If Not isAccessibleVBAProject(prs) Then
262 Set fo = fso.CreateTextFile(fso.BuildPath(folderDst, "CannotGetMacros.bas"), True, True)
263 fo.WriteLine MsgCannotGetMacros
267 For Each cmp In prs.VBProject.VBComponents
268 cmp.Export fso.BuildPath(folderDst, cmp.Name & getModuleExtension(cmp))
284 Function PackFolder(fileSrc, folderDst, pbChanged, pSubcode)
288 Function ShowSettingsDialog()
289 Dim tname: tname = fso.BuildPath(fso.GetSpecialFolder(2), fso.GetTempName() & ".hta")
290 Dim tfile: Set tfile = fso.CreateTextFile(tname)
292 tfile.Write getResource("dialog1")
294 mshta = wsh.ExpandEnvironmentStrings("%SystemRoot%\mshta.exe")
295 If Not fso.FileExists(mshta) Then
296 mshta = wsh.ExpandEnvironmentStrings("%SystemRoot%\SysWOW64\mshta.exe")
298 Run wsh, """" & mshta & """ """ & tname & """"
308 <resource id="dialog1">
312 <title>CompareMSPowerPointFiles.sct WinMerge Plugin Options</title>
313 <meta content="text/html" charset="Shift_JIS">
315 body { background-color: lightgray; }
316 ul { list-style:none; }
318 <script type="text/javascript">
319 var REGKEY_PATH = "HKCU\\Software\\Thingamahoochie\\WinMerge\\Plugins\\CompareMSPowerPointFiles.sct\\";
321 function regRead(key, defaultValue) {
323 return (new ActiveXObject("WScript.Shell")).RegRead(key);
329 function regWrite(key, value, type) {
330 (new ActiveXObject("WScript.Shell")).RegWrite(key, value, type);
335 var w = 600, h = 400;
336 window.resizeTo(w, h);
337 window.moveTo((screen.width - w) / 2, (screen.height - h) / 2);
339 cboLanguage.selectedIndex = navigator.browserLanguage.substr(0, 2) === 'ja' ? 1 : 0;
340 setLanguage(navigator.browserLanguage);
341 chkUnpackToFolder.checked = regRead(REGKEY_PATH + "UnpackToFolder", false);
342 chkCompareDocumentProperties.checked = regRead(REGKEY_PATH + "CompareDocumentProperties", false);
343 chkCompareSlideAsImage.checked = regRead(REGKEY_PATH + "CompareSlideAsImage", true);
344 chkCompareTextsInShapes.checked = regRead(REGKEY_PATH + "CompareTextsInShapes", true);
345 chkCompareTextsInNotesPage.checked = regRead(REGKEY_PATH + "CompareTextsInNotesPage", true);
346 chkCompareVBAMacros.checked = regRead(REGKEY_PATH + "CompareVBAMacros", true);
347 chkUnpackToFolder_onclick();
348 chkCompareSlideAsImage_onclick();
351 function setLanguage(lang) {
352 var div = document.getElementById("language") || document.createElement('div')
354 var html = '­<style>';
355 if (lang.substr(0, 2).toLowerCase() === 'ja') {
356 html += '.en { display: none } .ja { display: inline }';
358 html += '.ja { display: none } .en { display: inline }';
360 div.innerHTML = html;
361 if (!document.getElementById("language"))
362 document.body.appendChild(div);
365 function cboLanguage_onclick() {
366 setLanguage(cboLanguage.options[cboLanguage.selectedIndex].text);
369 function chkUnpackToFolder_onclick() {
370 if (!chkUnpackToFolder.checked)
371 chkCompareSlideAsImage.checked = false;
374 function chkCompareSlideAsImage_onclick() {
375 if (chkCompareSlideAsImage.checked)
376 chkUnpackToFolder.checked = true;
379 function btnOk_onclick() {
380 regWrite(REGKEY_PATH + "UnpackToFolder", chkUnpackToFolder.checked, "REG_DWORD");
381 regWrite(REGKEY_PATH + "CompareDocumentProperties", chkCompareDocumentProperties.checked, "REG_DWORD");
382 regWrite(REGKEY_PATH + "CompareSlideAsImage", chkCompareSlideAsImage.checked, "REG_DWORD");
383 regWrite(REGKEY_PATH + "CompareTextsInShapes", chkCompareTextsInShapes.checked, "REG_DWORD");
384 regWrite(REGKEY_PATH + "CompareTextsInNotesPage", chkCompareTextsInNotesPage.checked, "REG_DWORD");
385 regWrite(REGKEY_PATH + "CompareVBAMacros", chkCompareVBAMacros.checked, "REG_DWORD"); window.close();
388 function btnCancel_onclick() {
394 <body onload="onload();">
398 <label class="en">Language: </label>
399 <label class="ja">
\8c¾
\8cê: </label>
400 <select id="cboLanguage" onclick="cboLanguage_onclick();" >
401 <option value="English">English</option>
402 <option value="Japanese">Japanese</option>
408 <input id="chkUnpackToFolder" type="checkbox" onclick="chkUnpackToFolder_onclick();"/>
409 <label class="en">Extract slide data to multiple files </label>
410 <label class="ja">
\83X
\83\89\83C
\83h
\82Ì
\8fî
\95ñ
\82ð
\95¡
\90\94\83t
\83@
\83C
\83\8b\82É
\93W
\8aJ
\82·
\82é </label>
413 <input id="chkCompareDocumentProperties" type="checkbox" />
414 <label class="en">Compare document properties </label>
415 <label class="ja">
\83h
\83L
\83\85\83\81\83\93\83g
\83v
\83\8d\83p
\83e
\83B
\82ð
\94ä
\8ar
\82·
\82é </label>
418 <input id="chkCompareSlideAsImage" type="checkbox" onclick="chkCompareSlideAsImage_onclick();"/>
419 <label class="en">Compare slides as image (very slow)</label>
420 <label class="ja">
\83X
\83\89\83C
\83h
\82ð
\89æ
\91\9c\89»
\82µ
\82Ä
\94ä
\8ar
\82·
\82é (
\8f\88\97\9d\8e\9e\8aÔ
\91\9d\91å)</label>
423 <input id="chkCompareTextsInShapes" type="checkbox" />
424 <label class="en">Compare texts in shapes </label>
425 <label class="ja">
\90}
\8c`
\93à
\82Ì
\83e
\83L
\83X
\83g
\82ð
\94ä
\8ar
\82·
\82é </label>
428 <input id="chkCompareTextsInNotesPage" type="checkbox" />
429 <label class="en">Compare texts in notes page </label>
430 <label class="ja">
\83m
\81[
\83g
\93à
\82Ì
\83e
\83L
\83X
\83g
\82ð
\94ä
\8ar
\82·
\82é </label>
433 <input id="chkCompareVBAMacros" type="checkbox" />
434 <label class="en">Compare VBA macros </label>
435 <label class="ja">VBA
\83}
\83N
\83\8d\82ð
\94ä
\8ar
\82·
\82é </label>
440 <input class="en" type="button" onclick="btnOk_onclick();" value="OK" />
441 <input class="en" type="button" onclick="btnCancel_onclick();" value="Cancel" />
442 <input class="ja" type="button" onclick="btnOk_onclick();" value="OK" />
443 <input class="ja" type="button" onclick="btnCancel_onclick();" value="
\83L
\83\83\83\93\83Z
\83\8b" />