Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
sdottaka committed Jan 21, 2024
1 parent ca5ef85 commit e570cac
Show file tree
Hide file tree
Showing 8 changed files with 233 additions and 106 deletions.
193 changes: 95 additions & 98 deletions Plugins/dlls/CompareMSExcelFiles.sct
Original file line number Diff line number Diff line change
Expand Up @@ -420,57 +420,55 @@ function UnpackFile(fileSrc, fileDst, pbChanged, pSubcode) {
}
}
var wbk = xl.Workbooks.Open(fileSrc2, regRead(REGKEY_PATH + "UpdateLinks", 0), null, null, null, null, null, null, null, null, null, null,null, true);
try {
if (regRead(REGKEY_PATH + "CompareDocumentProperties", false)) {
fo.WriteLine("[Document Properties]");
writeObjectProperties(fo, wbk.BuiltinDocumentProperties);
if (regRead(REGKEY_PATH + "CompareDocumentProperties", false)) {
fo.WriteLine("[Document Properties]");
writeObjectProperties(fo, wbk.BuiltinDocumentProperties);
fo.WriteLine("");
}

if (regRead(REGKEY_PATH + "CompareNames", true)) {
fo.WriteLine("[Names]");
writeObjectProperties(fo, wbk.Names);
fo.WriteLine("");
}

for (var it = new Enumerator(wbk.Worksheets), sht = it.item(); !it.atEnd(); it.moveNext(), sht = it.item()) {
if (regRead(REGKEY_PATH + "CompareCellValues", true)) {
fo.WriteLine("[" + sht.Name + "]");
writeCellValues(fo, sht);
fo.WriteLine("");
}

if (regRead(REGKEY_PATH + "CompareNames", true)) {
fo.WriteLine("[Names]");
writeObjectProperties(fo, wbk.Names);
if (regRead(REGKEY_PATH + "CompareFormulas", false)) {
fo.WriteLine("[" + sht.Name + ".Formulas]");
writeFormulas(fo, sht);
fo.WriteLine("");
}

for (var it = new Enumerator(wbk.Worksheets), sht = it.item(); !it.atEnd(); it.moveNext(), sht = it.item()) {
if (regRead(REGKEY_PATH + "CompareCellValues", true)) {
fo.WriteLine("[" + sht.Name + "]");
writeCellValues(fo, sht);
fo.WriteLine("");
}
if (regRead(REGKEY_PATH + "CompareFormulas", false)) {
fo.WriteLine("[" + sht.Name + ".Formulas]");
writeFormulas(fo, sht);
fo.WriteLine("");
}
if (regRead(REGKEY_PATH + "CompareTextsInShapes", true)) {
fo.WriteLine("[" + sht.Name + ".Shapes]");
ungroupShapes(sht);
writeTextsInShapes(fo, sht);
fo.WriteLine("");
}
if (regRead(REGKEY_PATH + "CompareHeadersAndFooters", true)) {
fo.WriteLine("[" + sht.Name + ".HeadersAndFooters]");
writeHeadersAndFooters(fo, sht);
fo.WriteLine("");
}
if (regRead(REGKEY_PATH + "CompareTextsInShapes", true)) {
fo.WriteLine("[" + sht.Name + ".Shapes]");
ungroupShapes(sht);
writeTextsInShapes(fo, sht);
fo.WriteLine("");
}
if (regRead(REGKEY_PATH + "CompareHeadersAndFooters", true)) {
fo.WriteLine("[" + sht.Name + ".HeadersAndFooters]");
writeHeadersAndFooters(fo, sht);
fo.WriteLine("");
}
}

if (regRead(REGKEY_PATH + "CompareVBAMacros", true)) {
if (!isAccessibleVBAProject(wbk)) {
fo.WriteLine(Translate(MsgCannotGetMacros));
}
for (var it = new Enumerator(wbk.VBProject.VBComponents), cmp = it.item(); !it.atEnd(); it.moveNext(), cmp = it.item()) {
fo.WriteLine("[CodeModule." + cmp.Name + "]");
if (cmp.CodeModule.CountOfLines > 0) {
fo.WriteLine(cmp.CodeModule.Lines(1, cmp.CodeModule.CountOfLines));
}
fo.WriteLine("");
if (regRead(REGKEY_PATH + "CompareVBAMacros", true)) {
if (!isAccessibleVBAProject(wbk)) {
fo.WriteLine(Translate(MsgCannotGetMacros));
}
for (var it = new Enumerator(wbk.VBProject.VBComponents), cmp = it.item(); !it.atEnd(); it.moveNext(), cmp = it.item()) {
fo.WriteLine("[CodeModule." + cmp.Name + "]");
if (cmp.CodeModule.CountOfLines > 0) {
fo.WriteLine(cmp.CodeModule.Lines(1, cmp.CodeModule.CountOfLines));
}
fo.WriteLine("");
}
sht = null;
} catch (e) { }
}
sht = null;

wbk.Close();
wbk = null;
Expand Down Expand Up @@ -516,74 +514,73 @@ function UnpackFolder(fileSrc, folderDst, pbChanged, pSubcode) {
}
var wbk = xl.Workbooks.Open(fileSrc2, regRead(REGKEY_PATH + "UpdateLinks", 0), null, null, null, null, null, null, null, null, null, null, null, true);

try {
digit = String(wbk.Worksheets.Count).length;
if (digit <= 0) { digit = 1; }
var zf = Array(digit + 1).join("0");
digit = String(wbk.Worksheets.Count).length;
if (digit <= 0) { digit = 1; }
var zf = Array(digit + 1).join("0");

if (regRead(REGKEY_PATH + "CompareDocumentProperties", false)) {
fo = fso.CreateTextFile(fso.BuildPath(folderDst, "(" + zf + ")DocumentProperties.txt"), true, true);
writeObjectProperties(fo, wbk.BuiltinDocumentProperties);
fo.Close();
}

if (regRead(REGKEY_PATH + "CompareDocumentProperties", false)) {
fo = fso.CreateTextFile(fso.BuildPath(folderDst, "(" + zf + ")DocumentProperties.txt"), true, true);
writeObjectProperties(fo, wbk.BuiltinDocumentProperties);
if (regRead(REGKEY_PATH + "CompareNames", true)) {
fo = fso.CreateTextFile(fso.BuildPath(folderDst, "(" + zf + ")Names.txt"), true, true);
writeObjectProperties(fo, wbk.Names);
fo.Close();
}

var No = 1;
for (var it = new Enumerator(wbk.Worksheets), sht = it.item(); !it.atEnd(); it.moveNext(), sht = it.item()) {
No = zf + No;
No = No.substr(No.length - digit, digit);
if (regRead(REGKEY_PATH + "CompareCellValues", true)) {
fo = fso.CreateTextFile(fso.BuildPath(folderDst, "(" + No + ")" + escape(sht.Name) + ".tsv"), true, true);
writeCellValues(fo, sht);
fo.Close();
}

if (regRead(REGKEY_PATH + "CompareNames", true)) {
fo = fso.CreateTextFile(fso.BuildPath(folderDst, "(" + zf + ")Names.txt"), true, true);
writeObjectProperties(fo, wbk.Names);
if (regRead(REGKEY_PATH + "CompareFormulas", false)) {
fo = fso.CreateTextFile(fso.BuildPath(folderDst, "(" + No + ")" + escape(sht.Name) + "_Formulas.txt"), true, true);
writeFormulas(fo, sht);
fo.Close();
}

var No = 1;
for (var it = new Enumerator(wbk.Worksheets), sht = it.item(); !it.atEnd(); it.moveNext(), sht = it.item()) {
No = zf + No;
No = No.substr(No.length() - digit, digit);
if (regRead(REGKEY_PATH + "CompareCellValues", true)) {
fo = fso.CreateTextFile(fso.BuildPath(folderDst, "(" + No + ")" + escape(sht.Name) + ".tsv"), true, true);
writeCellValues(fo, sht);
fo.Close();
}

if (regRead(REGKEY_PATH + "CompareFormulas", false)) {
fo = fso.CreateTextFile(fso.BuildPath(folderDst, "(" + No + ")" + escape(sht.Name) + "_Formulas.txt"), true, true);
writeCellValues(fo, sht);
fo.Close();
}

if (regRead(REGKEY_PATH + "CompareTextsInShapes", true)) {
fo = fso.CreateTextFile(fso.BuildPath(folderDst, "(" + No + ")" + escape(sht.Name) + "_Shapes.txt"), true, true);
ungroupShapes(sht);
writeTextsInShapes(fo, sht);
fo.Close();
}
if (regRead(REGKEY_PATH + "CompareTextsInShapes", true)) {
fo = fso.CreateTextFile(fso.BuildPath(folderDst, "(" + No + ")" + escape(sht.Name) + "_Shapes.txt"), true, true);
ungroupShapes(sht);
writeTextsInShapes(fo, sht);
fo.Close();
}

if (regRead(REGKEY_PATH + "CompareHeadersAndFooters", true)) {
fo = fso.CreateTextFile(fso.BuildPath(folderDst, "(" + No + ")" + escape(sht.Name) + "_HeadersAndFooters.txt"), true, true);
writeHeadersAndFooters(fo, sht);
fo.Close();
}
if (regRead(REGKEY_PATH + "CompareHeadersAndFooters", true)) {
fo = fso.CreateTextFile(fso.BuildPath(folderDst, "(" + No + ")" + escape(sht.Name) + "_HeadersAndFooters.txt"), true, true);
writeHeadersAndFooters(fo, sht);
fo.Close();
}

if (regRead(REGKEY_PATH + "CompareWorksheetsAsImage", true)) {
saveSheetAsImage(sht, fso.BuildPath(folderDst, "(" + No + ")" + escape(sht.Name)));
}
if (regRead(REGKEY_PATH + "CompareWorksheetsAsImage", true)) {
saveSheetAsImage(sht, fso.BuildPath(folderDst, "(" + No + ")" + escape(sht.Name)));
}

if (regRead(REGKEY_PATH + "CompareWorksheetsAsHTML", false)) {
saveSheetAsHTML(sht, fso.BuildPath(folderDst, "(" + No + ")" + escape(sht.Name) + ".html"));
}
No = parseInt(No) + 1;
if (regRead(REGKEY_PATH + "CompareWorksheetsAsHTML", false)) {
saveSheetAsHTML(sht, fso.BuildPath(folderDst, "(" + No + ")" + escape(sht.Name) + ".html"));
}
No = parseInt(No) + 1;
}
if (regRead(REGKEY_PATH + "CompareVBAMacros", true)) {
if (!isAccessibleVBAProject(wbk)) {
fo = fso.CreateTextFile(fso.BuildPath(folderDst, "CannotGetMacros.bas"), true, true);
fo.WriteLine(Translate(MsgCannotGetMacros));
fo.Close();
}
if (regRead(REGKEY_PATH + "CompareVBAMacros", true)) {
if (!isAccessibleVBAProject(wbk)) {
fo = fso.CreateTextFile(fso.BuildPath(folderDst, "CannotGetMacros.bas"), true, true);
fo.WriteLine(Translate(MsgCannotGetMacros));
fo.Close();
}

for (var it = new Enumerator(wbk.VBProject.VBComponents), cmp = it.item(); !it.atEnd(); it.moveNext(), cmp = it.item()) {
cmp.Export(fso.BuildPath(folderDst, cmp.Name + getModuleExtension(cmp)));
}
for (var it = new Enumerator(wbk.VBProject.VBComponents), cmp = it.item(); !it.atEnd(); it.moveNext(), cmp = it.item()) {
cmp.Export(fso.BuildPath(folderDst, cmp.Name + getModuleExtension(cmp)));
}
sht = null;
} catch (e) { }
}
sht = null;

wbk.Close();
wbk = null;
xl.ErrorCheckingOptions.BackgroundChecking = backgroundChecking;
Expand Down
21 changes: 18 additions & 3 deletions Src/Merge.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2342,6 +2342,17 @@ BEGIN
CONTROL "",IDC_LIST_FILE,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,0,0,309,176
END

IDD_INPUTBOX DIALOGEX 0, 0, 234, 68
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LTEXT "",IDC_INPUTBOX_PROMPT,6,6,162,40
EDITTEXT IDC_INPUTBOX_EDIT,6,50,224,12,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,170,6,60,14
PUSHBUTTON "Cancel",IDCANCEL,170,22,60,14
END


/////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -2479,9 +2490,8 @@ BEGIN
BEGIN
END

IDD_WEBPAGEDIFF_BAR, DIALOG
IDD_INPUTBOX, DIALOG
BEGIN
RIGHTMARGIN, 237
END
END
#endif // APSTUDIO_INVOKED
Expand Down Expand Up @@ -3049,6 +3059,11 @@ BEGIN
100, 100, 0, 0
END

IDD_INPUTBOX AFX_DIALOG_LAYOUT
BEGIN
0
END


/////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -3511,7 +3526,7 @@ BEGIN
IDS_CONFIRM_MOVE_CAPTION "Confirm Move"
IDS_CONFIRM_CLOSE_WINDOW_COMPARING
"You are about to close the window that is comparing folders. Are you sure you want to close the window?"
IDS_CONFIRM_CLOSE_WINDOW_LONG_COMPARISON
IDS_CONFIRM_CLOSE_WINDOW_LONG_COMPARISON
"You are about to close the folder comparison window that took a significant amount of time. Are you sure you want to close the window?"
IDS_ERROR_INVALID_DIR_FILE_NAME
"The file or folder name is invalid."
Expand Down
5 changes: 5 additions & 0 deletions Src/MergeApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ void AppErrorMessageBox(const String& msg)
AppMsgBox::error(msg);
}

void* AppGetMainHWND()
{
return AfxGetMainWnd()->m_hWnd;
}

namespace AppMsgBox
{

Expand Down
1 change: 1 addition & 0 deletions Src/MergeApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ COptionsMgr * GetOptionsMgr();
void LogErrorString(const String& sz);
void LogErrorStringUTF8(const std::string& sz);
void AppErrorMessageBox(const String& msg);
void* AppGetMainHWND();

namespace AppMsgBox
{
Expand Down
Loading

0 comments on commit e570cac

Please sign in to comment.