Skip to content

Make the plugin settings dialog translatable and enable saving settings to an INI file #1783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Apr 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
72213ad
Make plugin settings dialog translatable
sdottaka Mar 30, 2023
56c2ffe
Make plugin settings dialog translatable (2)
sdottaka Mar 30, 2023
23803b6
Merge branch 'master' into make-plugin-settings-dialog-translatable
sdottaka Mar 30, 2023
ecaf525
Make plugin settings dialog translatable (3)
sdottaka Mar 31, 2023
9bf685f
Make plugin settings dialog translatable (4)
sdottaka Apr 1, 2023
4615fd3
Merge branch 'master' into make-plugin-settings-dialog-translatable
sdottaka Apr 1, 2023
fe8f908
Make plugin settings dialog translatable (5)
sdottaka Apr 2, 2023
9764fb6
Make plugin settings dialog translatable (6)
sdottaka Apr 4, 2023
7b90d77
Merge branch 'master' into make-plugin-settings-dialog-translatable
sdottaka Apr 4, 2023
b67ef69
Make plugin settings dialog translatable (7)
sdottaka Apr 5, 2023
db58748
Make plugin settings dialog translatable (8)
sdottaka Apr 8, 2023
6750b94
Merge branch 'master' into make-plugin-settings-dialog-translatable
sdottaka Apr 8, 2023
4f328c0
Make plugin settings dialog translatable (9)
sdottaka Apr 9, 2023
2f30fe8
Make plugin settings dialog translatable (10)
sdottaka Apr 9, 2023
781246e
Make plugin settings dialog translatable (11)
sdottaka Apr 9, 2023
7a2b296
Make plugin settings dialog translatable (12)
sdottaka Apr 9, 2023
a518f00
Make plugin settings dialog translatable (13)
sdottaka Apr 9, 2023
e5cb486
Make plugin settings dialog translatable (14)
sdottaka Apr 10, 2023
de28707
Make plugin settings dialog translatable (15)
sdottaka Apr 10, 2023
1f33346
Merge branch 'master' into make-plugin-settings-dialog-translatable
sdottaka Apr 11, 2023
76e47a8
Make plugin settings dialog translatable (16)
sdottaka Apr 11, 2023
6dec4c9
Make plugin settings dialog translatable (17)
sdottaka Apr 12, 2023
db9e398
Make plugin settings dialog translatable (18)
sdottaka Apr 12, 2023
fb9be57
Make plugin settings dialog translatable (19)
sdottaka Apr 12, 2023
ff1bdf2
Make plugin settings dialog translatable (20)
sdottaka Apr 12, 2023
a64b947
Merge branch 'master' into make-plugin-settings-dialog-translatable
sdottaka Apr 13, 2023
7455c76
Make plugin settings dialog translatable (21)
sdottaka Apr 14, 2023
458451f
Make plugin settings dialog translatable (22)
sdottaka Apr 14, 2023
0421c92
Merge branch 'master' into make-plugin-settings-dialog-translatable
sdottaka Apr 15, 2023
a96ef2e
Make plugin settings dialog translatable (23)
sdottaka Apr 15, 2023
6f62c07
Make plugin settings dialog translatable (24)
sdottaka Apr 15, 2023
ad1517f
Merge branch 'master' into make-plugin-settings-dialog-translatable
sdottaka Apr 16, 2023
949a3e8
Merge branch 'master' into make-plugin-settings-dialog-translatable
sdottaka Apr 16, 2023
5849439
Make plugin settings dialog translatable (25)
sdottaka Apr 16, 2023
966acbf
Make plugin settings dialog translatable (26)
sdottaka Apr 16, 2023
2b121d1
Make plugin settings dialog translatable (27)
sdottaka Apr 16, 2023
7da0a64
Make plugin settings dialog translatable (28)
sdottaka Apr 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Plugins/Strings.rc
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,24 @@ BEGIN
"Windows Registry URL Scheme Handler. \r\nArguments: Command line options passed to the reg.exe command."
END

STRINGTABLE
BEGIN
IDS_PLUGIN_COMPAREMSEXCELFILES_STR1
"Extract workbook data to multiple files"
IDS_PLUGIN_COMPAREMSEXCELFILES_STR2 "Update external references(links)"
IDS_PLUGIN_COMPAREMSEXCELFILES_STR3 "Compare document properties"
IDS_PLUGIN_COMPAREMSEXCELFILES_STR4 "Compare names"
IDS_PLUGIN_COMPAREMSEXCELFILES_STR5 "Compare cell values"
IDS_PLUGIN_COMPAREMSEXCELFILES_STR6
"Compare worksheets as image (very slow)"
IDS_PLUGIN_COMPAREMSEXCELFILES_STR7 " - Image split size: "
IDS_PLUGIN_COMPAREMSEXCELFILES_STR8 "Compare worksheets as HTML"
IDS_PLUGIN_COMPAREMSEXCELFILES_STR9 "Compare formulas"
IDS_PLUGIN_COMPAREMSEXCELFILES_STR10 "Compare texts in shapes"
IDS_PLUGIN_COMPAREMSEXCELFILES_STR11 "Compare headers and footers"
IDS_PLUGIN_COMPAREMSEXCELFILES_STR12 "Compare VBA macros"
END

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////

Expand Down
98 changes: 39 additions & 59 deletions Plugins/dlls/CompareMSExcelFiles.sct
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<property name="PluginExtendedProperties">
<get/>
</property>
<method name="OnEvent"/>
<method name="UnpackFile"/>
<method name="PackFile"/>
<method name="IsFolder"/>
Expand Down Expand Up @@ -59,6 +60,7 @@ MsgCannotGetMacros = "Cannot get Macros." & vbCrLf & _

Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
Dim wsh: Set wsh = CreateObject("WScript.Shell")
Dim winmergeObj

Function isAccessibleVBAProject(wbk)
Dim count
Expand Down Expand Up @@ -405,6 +407,10 @@ Function get_PluginExtendedProperties()
get_PluginExtendedProperties = "ProcessType=Content Extraction;FileType=MS-Excel;MenuCaption=MS-Excel"
End Function

Sub OnEvent(eventType, wmobj)
Set winmergeObj = wmobj
End Sub

Function UnpackFile(fileSrc, fileDst, pbChanged, pSubcode)
Dim fo
Dim xl
Expand Down Expand Up @@ -615,11 +621,29 @@ Function PackFolder(fileSrc, folderDst, pbChanged, pSubcode)
PackFolder = False
End Function

Function Translate(text)
Dim re: Set re = CreateObject("VBScript.RegExp")
re.Pattern = "\${([^}]+)}"
re.Global = True
Translate = text
Dim match
Dim matches:Set matches = re.Execute(text)
if IsEmpty(winmergeObj) Then
For Each match in matches
Translate = Replace(Translate, match.Value, match.Submatches(0))
Next
Else
For Each match in matches
Translate = Replace(Translate, match.Value, winmergeObj.Translate(match.Submatches(0)))
Next
End If
End Function

Function ShowSettingsDialog()
Dim tname: tname = fso.BuildPath(fso.GetSpecialFolder(2), fso.GetTempName() & ".hta")
Dim tfile: Set tfile = fso.CreateTextFile(tname)
Dim mshta
tfile.Write getResource("dialog1")
tfile.Write Translate(getResource("dialog1"))
tfile.Close
mshta = wsh.ExpandEnvironmentStrings("%SystemRoot%\mshta.exe")
If Not fso.FileExists(mshta) Then
Expand Down Expand Up @@ -665,8 +689,6 @@ End Sub
window.resizeTo(w, h);
window.moveTo((screen.width - w) / 2, (screen.height - h) / 2);

cboLanguage.selectedIndex = navigator.browserLanguage.substr(0, 2) === 'ja' ? 1 : 0;
setLanguage(navigator.browserLanguage);
chkUnpackToFolder.checked = regRead(REGKEY_PATH + "UnpackToFolder", false);
chkUpdateLinks.checked = (regRead(REGKEY_PATH + "UpdateLinks", 0) == 3);
chkCompareDocumentProperties.checked = regRead(REGKEY_PATH + "CompareDocumentProperties", false);
Expand All @@ -685,24 +707,6 @@ End Sub
chkCompareWorksheetsAsHTML_onclick();
}

function setLanguage(lang) {
var div = document.getElementById("language") || document.createElement('div')
div.id = "language";
var html = '&shy;<style>';
if (lang.substr(0, 2).toLowerCase() === 'ja') {
html += '.en { display: none } .ja { display: inline }';
} else {
html += '.ja { display: none } .en { display: inline }';
}
div.innerHTML = html;
if (!document.getElementById("language"))
document.body.appendChild(div);
}

function cboLanguage_onclick() {
setLanguage(cboLanguage.options[cboLanguage.selectedIndex].text);
}

function chkUnpackToFolder_onclick() {
if (!chkUnpackToFolder.checked) {
chkCompareWorksheetsAsImage.checked = false;
Expand Down Expand Up @@ -777,84 +781,60 @@ End Sub
</head>
<body onload="onload();">
<div>
<ul>
<li>
<label class="en">Language: </label>
<label class="ja">����: </label>
<select id="cboLanguage" onclick="cboLanguage_onclick();" >
<option value="English">English</option>
<option value="Japanese">Japanese</option>
</select>
</li>
</ul>
<ul>
<li>
<input id="chkUnpackToFolder" type="checkbox" onclick="chkUnpackToFolder_onclick();"/>
<label class="en">Extract workbook data to multiple files</label>
<label class="ja">���[�N�u�b�N�̏��𕡐��t�@�C���ɓW�J����</label>
<label class="en">${Extract workbook data to multiple files}</label>
</li>
<li>
<input id="chkUpdateLinks" type="checkbox" />
<label class="en">Update external references(links)</label>
<label class="ja">��r���A�O���Q��(�����N)���X�V����</label>
<label class="en">${Update external references(links)}</label>
</li>
<li>
<input id="chkCompareDocumentProperties" type="checkbox" />
<label class="en">Compare document properties</label>
<label class="ja">�h�L�������g�v���p�e�B���r����</label>
<label class="en">${Compare document properties}</label>
</li>
<li>
<input id="chkCompareNames" type="checkbox" />
<label class="en">Compare names</label>
<label class="ja">���O�̒�`���r����</label>
<label class="en">${Compare names}</label>
</li>
<li>
<input id="chkCompareCellValues" type="checkbox" />
<label class="en">Compare cell values</label>
<label class="ja">�e�Z���̒l���r����</label>
<label class="en">${Compare cell values}</label>
</li>
<li>
<input id="chkCompareWorksheetsAsImage" type="checkbox" onclick="chkCompareWorksheetsAsImage_onclick();"/>
<label class="en">Compare worksheets as image (very slow)</label>
<label class="ja">���[�N�V�[�g���摜�����Ĕ�r���� (�������ԑ���)</label>
<span class="en"> - Image split size: </span>
<span class="ja"> - �摜�����T�C�Y: </span>
<label class="en">${Compare worksheets as image (very slow)}</label>
<span class="en">${ - Image split size: }</span>
<input id="txtImageWidth" type="text" size="5" maxlength="4" onkeyDown="return onlyNumeric();" onpaste="return onPaste();" />
<span> x </span>
<input id="txtImageHeight" type="text" size="5" maxlength="4" onkeyDown="return onlyNumeric();" onpaste="return onPaste();" />
</li>
<li>
<input id="chkCompareWorksheetsAsHTML" type="checkbox" onclick="chkCompareWorksheetsAsHTML_onclick();"/>
<label class="en">Compare worksheets as HTML</label>
<label class="ja">���[�N�V�[�g��HTML�Ƃ��ĕۑ����Ĕ�r����</label>
<label class="en">${Compare worksheets as HTML}</label>
</li>
<li>
<input id="chkCompareFormulas" type="checkbox" />
<label class="en">Compare formulas</label>
<label class="ja">�������r����</label>
<label class="en">${Compare formulas}</label>
</li>
<li>
<input id="chkCompareTextsInShapes" type="checkbox" />
<label class="en">Compare texts in shapes</label>
<label class="ja">�}�`���̃e�L�X�g���r����</label>
<label class="en">${Compare texts in shapes}</label>
</li>
<li>
<input id="chkCompareHeadersAndFooters" type="checkbox" />
<label class="en">Compare headers and footers</label>
<label class="ja">�w�b�_�[�ƃt�b�^�[���r����</label>
<label class="en">${Compare headers and footers}</label>
</li>
<li>
<input id="chkCompareVBAMacros" type="checkbox" />
<label class="en">Compare VBA macros</label>
<label class="ja">VBA �}�N�����r����</label>
<label class="en">${Compare VBA macros}</label>
</li>
</ul>
<ul>
<li>
<input class="en" type="button" onclick="btnOk_onclick();" value="OK" />
<input class="en" type="button" onclick="btnCancel_onclick();" value="Cancel" />
<input class="ja" type="button" onclick="btnOk_onclick();" value="OK" />
<input class="ja" type="button" onclick="btnCancel_onclick();" value="�L�����Z��" />
<input class="en" type="button" onclick="btnOk_onclick();" value="${OK}" />
<input class="en" type="button" onclick="btnCancel_onclick();" value="${Cancel}" />
</li>
</ul>
</div>
Expand Down
25 changes: 23 additions & 2 deletions Plugins/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Microsoft Visual C++ generated include file.
// Used by Strings.rc
//
#define LANG_ENGLISH 0x09
#define SUBLANG_ENGLISH_US 0x01
#define SUBLANG_ENGLISH_US 0x01
#define LANG_ENGLISH 0x09
#define IDS_PLUGIN_PROCESS_TYPE1 44202
#define IDS_PLUGIN_PROCESS_TYPE2 44203
#define IDS_PLUGIN_PROCESS_TYPE3 44204
Expand Down Expand Up @@ -113,11 +113,32 @@
#define IDS_PLUGIN_DESCRIPTION58 44408
#define IDS_PLUGIN_DESCRIPTION59 44409
#define IDS_PLUGIN_DESCRIPTION60 44410
#define IDS_PLUGIN_COMPAREMSEXCELFILES_STR1 44420
#define IDS_PLUGIN_COMPAREMSEXCELFILES_STR2 44421
#define IDS_PLUGIN_COMPAREMSEXCELFILES_STR3 44422
#define IDS_PLUGIN_COMPAREMSEXCELFILES_STR4 44423
#define IDS_PLUGIN_COMPAREMSEXCELFILES_STR5 44424
#define IDS_PLUGIN_COMPAREMSEXCELFILES_STR6 44425
#define IDS_PLUGIN_COMPAREMSEXCELFILES_STR7 44426
#define IDS_PLUGIN_COMPAREMSEXCELFILES_STR8 44427
#define IDS_PLUGIN_COMPAREMSEXCELFILES_STR9 44428
#define IDS_PLUGIN_COMPAREMSEXCELFILES_STR10 44429
#define IDS_PLUGIN_COMPAREMSEXCELFILES_STR11 44430
#define IDS_PLUGIN_COMPAREMSEXCELFILES_STR12 44431
#define IDS_PLUGIN_COMPAREMSEXCELFILES_STR13 44432
#define IDS_PLUGIN_COMPAREMSEXCELFILES_STR14 44433
#define IDS_PLUGIN_COMPAREMSEXCELFILES_STR15 44434
#define IDS_PLUGIN_COMPAREMSEXCELFILES_STR16 44435
#define IDS_PLUGIN_COMPAREMSEXCELFILES_STR17 44436
#define IDS_PLUGIN_COMPAREMSEXCELFILES_STR18 44437
#define IDS_PLUGIN_COMPAREMSEXCELFILES_STR19 44438
#define IDS_PLUGIN_COMPAREMSEXCELFILES_STR20 44439

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 258
#define _APS_NEXT_COMMAND_VALUE 34194
Expand Down
2 changes: 2 additions & 0 deletions Src/InternalPlugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,8 @@ struct Loader
int validFuncs = plugin::GetMethodsFromScript(plugin->m_lpDispatch, namesArray, idArray);
for (int i = 0; i < validFuncs; ++i)
{
if (namesArray[i] == L"OnEvent")
continue;
if (plugins.find(L"FILE_PACK_UNPACK") == plugins.end())
plugins[L"FILE_PACK_UNPACK"].reset(new PluginArray);
PluginInfoPtr pluginNew(new PluginInfo());
Expand Down
3 changes: 3 additions & 0 deletions Src/Merge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include "TestMain.h"
#include "charsets.h" // For shutdown cleanup
#include "OptionsProject.h"
#include "WinMergeComObject.h"

#ifdef _DEBUG
#define new DEBUG_NEW
Expand Down Expand Up @@ -112,9 +113,11 @@ CMergeApp::CMergeApp() :
, m_pMarkers(new CCrystalTextMarkers())
, m_bMergingMode(false)
, m_bEnableExitCode(false)
, m_pWinMergeComObject(new WinMergeComObject())
{
// add construction code here,
// Place all significant initialization in InitInstance
m_pWinMergeComObject->AddRef();
}

/**
Expand Down
2 changes: 2 additions & 0 deletions Src/Merge.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class SubstitutionFiltersList;
class SyntaxColors;
class CCrystalTextMarkers;
class PackingInfo;
class WinMergeComObject;

/////////////////////////////////////////////////////////////////////////////
// CMergeApp:
Expand Down Expand Up @@ -67,6 +68,7 @@ class CMergeApp : public CWinApp
MergeCmdLineInfo::ExitNoDiff m_bExitIfNoDiff; /**< Exit if files are identical? */
std::unique_ptr<LineFiltersList> m_pLineFilters; /**< List of linefilters */
std::unique_ptr<SubstitutionFiltersList> m_pSubstitutionFiltersList;
std::unique_ptr<WinMergeComObject> m_pWinMergeComObject;

WORD GetLangId() const;
String GetLangName() const;
Expand Down
2 changes: 2 additions & 0 deletions Src/Merge.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,7 @@
<ClCompile Include="WildcardDropList.cpp" />
<ClCompile Include="WindowsManagerDialog.cpp" />
<ClCompile Include="WMGotoDlg.cpp" />
<ClCompile Include="WinMergeComObject.cpp" />
<ClCompile Include="xdiff_gnudiff_compat.cpp">
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName)2.pch</PrecompiledHeaderOutputFile>
Expand Down Expand Up @@ -1634,6 +1635,7 @@
<ClInclude Include="WinMergePluginBase.h" />
<ClInclude Include="Win_VersionHelper.h" />
<ClInclude Include="WMGotoDlg.h" />
<ClInclude Include="WinMergeComObject.h" />
<ClInclude Include="xdiff_gnudiff_compat.h" />
</ItemGroup>
<ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions Src/Merge.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,9 @@
<ClCompile Include="Common\cio.cpp">
<Filter>Common\Source Files</Filter>
</ClCompile>
<ClCompile Include="WinMergeComObject.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="charsets.h">
Expand Down Expand Up @@ -1361,6 +1364,9 @@
<ClInclude Include="FileLoadResult.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="WinMergeComObject.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="res\binarydiff.ico">
Expand Down
17 changes: 17 additions & 0 deletions Src/Plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,9 @@ int PluginInfo::MakeInfo(const String & scriptletFilepath, IDispatch *lpDispatch
// get optional property PluginVariables
m_hasVariablesProperty = SearchScriptForDefinedProperties(L"PluginVariables");

// get optional method OnEvent
m_hasOnEventMethod = SearchScriptForMethodName(L"OnEvent");

// keep the filename
m_name = paths::FindFileName(scriptletFilepath);

Expand Down Expand Up @@ -1634,4 +1637,18 @@ bool InvokePutPluginVariables(const String& vars, LPDISPATCH piScript)
return SUCCEEDED(h);
}

bool InvokeOnEvent(int eventType, LPDISPATCH wmobj, LPDISPATCH piScript)
{
// argument wmobj
VARIANT vdispWinMerge{ VT_DISPATCH };
vdispWinMerge.pdispVal = wmobj;
vdispWinMerge.pdispVal->AddRef();
// argument eventType
VARIANT viEventType{ VT_I4 };
viEventType.intVal = eventType;

HRESULT h = ::safeInvokeW(piScript, nullptr, L"OnEvent", opFxn[2], vdispWinMerge, viEventType);
return SUCCEEDED(h);
}

}
7 changes: 7 additions & 0 deletions Src/Plugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class PluginInfo
, m_disabled(false)
, m_hasArgumentsProperty(false)
, m_hasVariablesProperty(false)
, m_hasOnEventMethod(false)
, m_bAutomaticDefault(false)
{
}
Expand Down Expand Up @@ -85,6 +86,7 @@ class PluginInfo
bool m_disabled;
bool m_hasArgumentsProperty;
bool m_hasVariablesProperty;
bool m_hasOnEventMethod;
std::vector<FileFilterElementPtr> m_filters;
/// only for plugins with free function names (EDITOR_SCRIPT)
int m_nFreeFunctions;
Expand Down Expand Up @@ -269,4 +271,9 @@ bool InvokePutPluginArguments(const String& args, LPDISPATCH piScript);
* @brief Set value to the plugin "PluginVariables" property
*/
bool InvokePutPluginVariables(const String& args, LPDISPATCH piScript);

/**
* @brief call the plugin "OnEvent" method
*/
bool InvokeOnEvent(int eventType, LPDISPATCH wmobj, LPDISPATCH piScript);
}
Loading