-//Merge7z/revision.txt\r
-\r
-"*"//2003-12-16 Jochen Tucht GuessFormat() now checks for directory\r
-"*"//2004-03-15 Jochen Tucht Fix Visual Studio 2003 build issue\r
-"*"//2004-04-13 Jochen Tucht Experimental DllGetVersion() based on rcsid.\r
-"*"//2004-08-19 Laurent Ganier Compression of folders\r
-// Through EnumerateDirectory (from code of 7zip)\r
-\r
-VERSION(2,1)\r
-\r
-"*"//2004-10-10 Jochen Tucht Support 7z409 beta. DllGetVersion() no longer\r
-//based on rcsid. Revision numbers will be generated from new file REVISION.TXT.\r
-\r
-"*"//2004-10-17 Jochen Tucht Leave decision whether to recurse into folders\r
-//to enumerator (Mask.Recurse)\r
-\r
-"*"//2004-10-18 Jochen Tucht Change generation of revision numbers to allow\r
-//for arbitrary version numbers at any stage without affecting build number.\r
-//Merge7z may now follow a WinMerge-like versioning policy, or just use same\r
-//version numbers as WinMerge, yet provide a build number simply reflecting\r
-//the number of changes recorded in this revision.txt.\r
-\r
-VERSION(2,2)\r
-\r
-"*"//2005-01-15 Jochen Tucht New interface Merge7z::Format::Inspector\r
-// New interface Merge7z::Format::Updater\r
-// New method Merge7z::LoadLang() to set UI language\r
-\r
-"*"//2005-02-26 Jochen Tucht Fix extensions when unwrapping tgz, rpm, ...\r
-// Expose some handler properties\r
-// Fix crash on failure to open archive\r
-// Use canned system messages wherever possible\r
-// Fix Merge7z::LoadLang() for no.txt (Norwegian)\r
-// Use DLLPSTUB if DllBuild_Merge7z >= 10\r
-// Optimize release builds for size\r
-\r
-"*"//2005-03-19 Jochen Tucht Set UI language during Merge7z::Initialize()\r
-// according to LANGID given in HIWORD(dwFlags)\r
-// Allow for Merge7z::LoadLang(MAKEINTATOM(LANGID))\r
-// Don't show error message on intentional abort\r
-\r
-"*"//2005-06-22 Jochen Tucht Treat .ear and .war like .zip\r
-"*"//2005-08-20 Jochen Tucht Option to guess archive format by signature\r
-"*"//2005-08-25 Jochen Tucht Fix broken GuessFormatByExtension()\r
-"*"//2005-10-02 Jochen Tucht Add CHM format\r
-"*"//2005-10-04 Jochen Tucht Don't rely on 7-Zip's format CLSIDs\r
-"*"//2005-11-19 Jochen Tucht Minor changes to build against 7z430 beta\r
-"*"//2006-06-28 Jochen Neubeck Add ISO format (introduced with 7z436 beta)\r
-// Add NSIS format (introduced with 7z440 beta)\r
-// Avoid to occasionally prompt for password twice\r
-"*"//2007-01-27 Jochen Neubeck Unassociate .exe filename extension from NSIS\r
-// format due to undesired side effect on WinMerge\r
-"*"//2007-04-20 Jochen Neubeck Cope with 7z445's revised plugin system\r
-"*"//2007-07-13 Jochen Neubeck Pass MSI files to CAB handler\r
-// Drop support for 7-Zip versions prior to 4.32\r
-"*"//2007-07-15 Jochen Neubeck Add WIM format (introduced with 7z449 beta)\r
-"*"//2007-07-16 Jochen Neubeck Cope with revised CThread::Create() in 7z446\r
-"*"//2007-08-25 Jochen Neubeck Add COM format (introduced with 7z452 beta)\r
-// No longer pass MSI files to CAB handler\r
-"*"//2007-09-01 Jochen Neubeck Some refactoring to build against 7z453 beta\r
-"*"//2007-12-22 Jochen Neubeck Unassociate .001 filename extension\r
-"*"//2008-08-03 Jochen Neubeck Fix OpenArchive.* being taken from wrong folder\r
-// Add LZMA format (introduced with 7z458 beta)\r
-"*"//2010-04-24 Jochen Neubeck New formats introduced with 7z459 beta:\r
-// XAR, MUB, HFS, DMG, ELF (not sure if they work)\r
-// Support 7z465, 7z907, 7z909-7z913\r
+//Merge7z/revision.txt
+
+"*"//2003-12-16 Jochen Tucht GuessFormat() now checks for directory
+"*"//2004-03-15 Jochen Tucht Fix Visual Studio 2003 build issue
+"*"//2004-04-13 Jochen Tucht Experimental DllGetVersion() based on rcsid.
+"*"//2004-08-19 Laurent Ganier Compression of folders
+// Through EnumerateDirectory (from code of 7zip)
+
+VERSION(2,1)
+
+"*"//2004-10-10 Jochen Tucht Support 7z409 beta. DllGetVersion() no longer
+//based on rcsid. Revision numbers will be generated from new file REVISION.TXT.
+
+"*"//2004-10-17 Jochen Tucht Leave decision whether to recurse into folders
+//to enumerator (Mask.Recurse)
+
+"*"//2004-10-18 Jochen Tucht Change generation of revision numbers to allow
+//for arbitrary version numbers at any stage without affecting build number.
+//Merge7z may now follow a WinMerge-like versioning policy, or just use same
+//version numbers as WinMerge, yet provide a build number simply reflecting
+//the number of changes recorded in this revision.txt.
+
+VERSION(2,2)
+
+"*"//2005-01-15 Jochen Tucht New interface Merge7z::Format::Inspector
+// New interface Merge7z::Format::Updater
+// New method Merge7z::LoadLang() to set UI language
+
+"*"//2005-02-26 Jochen Tucht Fix extensions when unwrapping tgz, rpm, ...
+// Expose some handler properties
+// Fix crash on failure to open archive
+// Use canned system messages wherever possible
+// Fix Merge7z::LoadLang() for no.txt (Norwegian)
+// Use DLLPSTUB if DllBuild_Merge7z >= 10
+// Optimize release builds for size
+
+"*"//2005-03-19 Jochen Tucht Set UI language during Merge7z::Initialize()
+// according to LANGID given in HIWORD(dwFlags)
+// Allow for Merge7z::LoadLang(MAKEINTATOM(LANGID))
+// Don't show error message on intentional abort
+
+"*"//2005-06-22 Jochen Tucht Treat .ear and .war like .zip
+"*"//2005-08-20 Jochen Tucht Option to guess archive format by signature
+"*"//2005-08-25 Jochen Tucht Fix broken GuessFormatByExtension()
+"*"//2005-10-02 Jochen Tucht Add CHM format
+"*"//2005-10-04 Jochen Tucht Don't rely on 7-Zip's format CLSIDs
+"*"//2005-11-19 Jochen Tucht Minor changes to build against 7z430 beta
+"*"//2006-06-28 Jochen Neubeck Add ISO format (introduced with 7z436 beta)
+// Add NSIS format (introduced with 7z440 beta)
+// Avoid to occasionally prompt for password twice
+"*"//2007-01-27 Jochen Neubeck Unassociate .exe filename extension from NSIS
+// format due to undesired side effect on WinMerge
+"*"//2007-04-20 Jochen Neubeck Cope with 7z445's revised plugin system
+"*"//2007-07-13 Jochen Neubeck Pass MSI files to CAB handler
+// Drop support for 7-Zip versions prior to 4.32
+"*"//2007-07-15 Jochen Neubeck Add WIM format (introduced with 7z449 beta)
+"*"//2007-07-16 Jochen Neubeck Cope with revised CThread::Create() in 7z446
+"*"//2007-08-25 Jochen Neubeck Add COM format (introduced with 7z452 beta)
+// No longer pass MSI files to CAB handler
+"*"//2007-09-01 Jochen Neubeck Some refactoring to build against 7z453 beta
+"*"//2007-12-22 Jochen Neubeck Unassociate .001 filename extension
+"*"//2008-08-03 Jochen Neubeck Fix OpenArchive.* being taken from wrong folder
+// Add LZMA format (introduced with 7z458 beta)
+"*"//2010-04-24 Jochen Neubeck New formats introduced with 7z459 beta:
+// XAR, MUB, HFS, DMG, ELF (not sure if they work)
+// Support 7z465, 7z907, 7z909-7z913
*/
void CDirDoc::SetDescriptions(const String strDesc[])
{
- std::copy(strDesc, strDesc + m_nDirs, m_strDesc);
+ if (strDesc)
+ std::copy(strDesc, strDesc + m_nDirs, m_strDesc);
}
/**
DWORD dwFlags[3];
for (int nIndex = 0; nIndex < pathsParent.GetSize(); ++nIndex)
dwFlags[nIndex] = FFILEOPEN_NOMRU | (pDoc->GetReadOnly(nIndex) ? FFILEOPEN_READONLY : 0);
- GetMainFrame()->DoFileOpen(&pathsParent, dwFlags, GetDiffContext().m_bRecursive, (GetAsyncKeyState(VK_CONTROL) & 0x8000) ? NULL : pDoc);
+ GetMainFrame()->DoFileOpen(&pathsParent, dwFlags, NULL, GetDiffContext().m_bRecursive, (GetAsyncKeyState(VK_CONTROL) & 0x8000) ? NULL : pDoc);
}
// fall through (no break!)
case AllowUpwardDirectory::No:
{
// Open subfolders
// Don't add folders to MRU
- GetMainFrame()->DoFileOpen(&paths, dwFlags, GetDiffContext().m_bRecursive, (GetAsyncKeyState(VK_CONTROL) & 0x8000) ? NULL : pDoc);
+ GetMainFrame()->DoFileOpen(&paths, dwFlags, NULL, GetDiffContext().m_bRecursive, (GetAsyncKeyState(VK_CONTROL) & 0x8000) ? NULL : pDoc);
}
else if (HasZipSupport() && std::count_if(paths.begin(), paths.end(), ArchiveGuessFormat) == paths.GetSize())
{
// Open archives, not adding paths to MRU
- GetMainFrame()->DoFileOpen(&paths, dwFlags, GetDiffContext().m_bRecursive, NULL, _T(""), infoUnpacker);
+ GetMainFrame()->DoFileOpen(&paths, dwFlags, NULL, GetDiffContext().m_bRecursive, NULL, _T(""), infoUnpacker);
}
else
{
// Open identical and different files
FileLocation fileloc[3];
+ String strDesc[3];
if (paths.GetSize() < 3)
{
- theApp.m_strDescriptions[0].erase();
- theApp.m_strDescriptions[1].erase();
if (pdi[0] == pdi[1] && !pdi[0]->diffcode.exists(0))
{
paths[0] = _T("");
- theApp.m_strDescriptions[0] = _("Untitled left");
+ strDesc[0] = _("Untitled left");
}
if (pdi[0] == pdi[1] && !pdi[0]->diffcode.exists(1))
{
paths[1] = _T("");
- theApp.m_strDescriptions[1] = _("Untitled right");
+ strDesc[1] = _("Untitled right");
}
}
else
{
- theApp.m_strDescriptions[0].erase();
- theApp.m_strDescriptions[1].erase();
- theApp.m_strDescriptions[2].erase();
if (pdi[0] == pdi[1] && pdi[0] == pdi[2] && !pdi[0]->diffcode.exists(0))
{
paths[0] = _T("");
- theApp.m_strDescriptions[0] = _("Untitled left");
+ strDesc[0] = _("Untitled left");
}
if (pdi[0] == pdi[1] && pdi[0] == pdi[2] && !pdi[0]->diffcode.exists(1))
{
paths[1] = _T("");
- theApp.m_strDescriptions[1] = _("Untitled middle");
+ strDesc[1] = _("Untitled middle");
}
if (pdi[0] == pdi[1] && pdi[0] == pdi[2] && !pdi[0]->diffcode.exists(2))
{
paths[2] = _T("");
- theApp.m_strDescriptions[2] = _("Untitled right");
+ strDesc[2] = _("Untitled right");
}
}
fileloc[nIndex].encoding = pdi[nIndex]->diffFileInfo[nPane[nIndex]].encoding;
}
GetMainFrame()->ShowAutoMergeDoc(pDoc, paths.GetSize(), fileloc,
- dwFlags, infoUnpacker);
+ dwFlags, strDesc, infoUnpacker);
}
}
}
// Open identical and different files
- bool bRO[3];
- for (int nIndex = 0; nIndex < paths.GetSize(); nIndex++)
- bRO[nIndex] = !!pDoc->GetReadOnly(nPane[nIndex]);
-
- GetMainFrame()->ShowHexMergeDoc(pDoc, paths, bRO);
+ DWORD dwFlags[3] = { 0 };
+ FileLocation fileloc[3];
+ for (int pane = 0; pane < paths.GetSize(); pane++)
+ {
+ fileloc[pane].setPath(paths[pane]);
+ dwFlags[pane] |= FFILEOPEN_NOMRU | (pDoc->GetReadOnly(nPane[pane]) ? FFILEOPEN_READONLY : 0);
+ }
+ GetMainFrame()->ShowHexMergeDoc(pDoc, paths.GetSize(), fileloc, dwFlags, NULL);
}
/// User chose (context menu) delete left
/**
* @brief Load one file
*/
-HRESULT CHexMergeDoc::LoadOneFile(int index, LPCTSTR filename, BOOL readOnly)
+HRESULT CHexMergeDoc::LoadOneFile(int index, LPCTSTR filename, BOOL readOnly, const String& strDesc)
{
if (filename[0])
{
m_pView[index]->SetReadOnly(readOnly);
m_filePaths.SetPath(index, filename);
ASSERT(m_nBufferType[index] == BUFFER_NORMAL); // should have been initialized to BUFFER_NORMAL in constructor
- String strDesc = theApp.m_strDescriptions[index];
if (!strDesc.empty())
{
m_strDesc[index] = strDesc;
else
{
m_nBufferType[index] = BUFFER_UNNAMED;
- m_strDesc[index] = theApp.m_strDescriptions[index];
-
+ m_strDesc[index] = strDesc;
}
UpdateHeaderPath(index);
m_pView[index]->ResizeWindow();
/**
* @brief Load files and initialize frame's compare result icon
*/
-HRESULT CHexMergeDoc::OpenDocs(const PathContext &paths, const bool bRO[])
+bool CHexMergeDoc::OpenDocs(int nFiles, const FileLocation fileloc[], const bool bRO[], const String strDesc[], int nPane)
{
CHexMergeFrame *pf = GetParentFrame();
ASSERT(pf);
- HRESULT hr = E_FAIL;
+ bool bSucceeded = true;
int nBuffer;
- for (nBuffer = 0; nBuffer < m_nBuffers; nBuffer++)
+ for (nBuffer = 0; nBuffer < nFiles; nBuffer++)
{
- if (FAILED(hr = LoadOneFile(nBuffer, paths.GetPath(nBuffer).c_str(), bRO[nBuffer])))
+ if (FAILED(LoadOneFile(nBuffer, fileloc[nBuffer].filepath.c_str(), bRO[nBuffer], strDesc ? strDesc[nBuffer] : _T(""))))
+ {
+ bSucceeded = false;
break;
+ }
}
- if (nBuffer == m_nBuffers)
+ if (nBuffer == nFiles)
{
UpdateDiffItem(0);
// An extra ResizeWindow() on the left view aligns scroll ranges, and
// Use verify macro to trap possible error in debug.
VERIFY(pf->DestroyWindow());
}
- return hr;
+ return bSucceeded;
}
void CHexMergeDoc::CheckFileChanged(void)
if (!PromptAndSaveIfNeeded(true))
return;
+ FileLocation fileloc[3];
bool bRO[3];
for (int pane = 0; pane < m_nBuffers; pane++)
{
+ fileloc[pane].setPath(m_filePaths[pane]);
bRO[pane] = !!m_pView[pane]->GetReadOnly();
- theApp.m_strDescriptions[pane] = m_strDesc[pane];
}
int nActivePane = GetActiveMergeView()->m_nThisPane;
- OpenDocs(m_filePaths, bRO);
+ OpenDocs(m_nBuffers, fileloc, bRO, m_strDesc, nActivePane);
}
/**
#include "PathContext.h"
#include "DiffFileInfo.h"
+#include "FileLocation.h"
#include "IMergeDoc.h"
class CDirDoc;
CHexMergeFrame * GetParentFrame() const;
void UpdateHeaderPath(int pane);
void RefreshOptions();
- HRESULT OpenDocs(const PathContext &paths, const bool bRO[]);
+ bool OpenDocs(int nFiles, const FileLocation fileloc[], const bool bRO[], const String strDesc[], int nPane);
void CheckFileChanged(void);
private:
static void CopySel(CHexMergeView *pViewSrc, CHexMergeView *pViewDst);
static void CopyAll(CHexMergeView *pViewSrc, CHexMergeView *pViewDst);
void DoFileSave(int nBuffer);
void DoFileSaveAs(int nBuffer);
- HRESULT LoadOneFile(int index, LPCTSTR filename, BOOL readOnly);
+ HRESULT LoadOneFile(int index, LPCTSTR filename, BOOL readOnly, const String& strDesc);
// Implementation data
protected:
CHexMergeView * m_pView[3]; /**< Pointer to left/right view */
#include "FileOrFolderSelect.h"
#include "UniFile.h"
#include "SaveClosingDlg.h"
+#include "FileLocation.h"
+#include "Constants.h"
#include <cmath>
#include <cstdint>
#include <Shlwapi.h>
}
}
-bool CImgMergeFrame::OpenImages(const PathContext& paths, const bool bRO[], int nPane, CMDIFrameWnd *pParent)
+bool CImgMergeFrame::OpenDocs(int nFiles, const FileLocation fileloc[], const bool bRO[], const String strDesc[], int nPane, CMDIFrameWnd *pParent)
{
- m_filePaths = paths;
- for (int pane = 0; pane < paths.GetSize(); ++pane)
+ for (int pane = 0; pane < nFiles; ++pane)
{
+ m_filePaths.SetPath(pane, fileloc[pane].filepath);
m_bRO[pane] = bRO[pane];
- if (theApp.m_strDescriptions[pane].empty())
- m_nBufferType[pane] = BUFFER_NORMAL;
- else
- {
- m_nBufferType[pane] = BUFFER_NORMAL_NAMED;
- m_strDesc[pane] = theApp.m_strDescriptions[pane];
- theApp.m_strDescriptions[pane].erase();
- }
+ m_strDesc[pane] = strDesc ? strDesc[pane] : _T("");
+ m_nBufferType[pane] = (!strDesc || strDesc[pane].empty()) ? BUFFER_NORMAL : BUFFER_NORMAL_NAMED;
}
SetTitle(NULL);
void CImgMergeFrame::OnFileRecompareAsBinary()
{
- GetMainFrame()->ShowHexMergeDoc(m_pDirDoc, m_filePaths, m_bRO);
+ DWORD dwFlags[3] = { 0 };
+ FileLocation fileloc[3];
+ for (int pane = 0; pane < m_filePaths.GetSize(); pane++)
+ {
+ fileloc[pane].setPath(m_filePaths[pane]);
+ dwFlags[pane] |= FFILEOPEN_NOMRU | (m_bRO[pane] ? FFILEOPEN_READONLY : 0);
+ }
+ GetMainFrame()->ShowHexMergeDoc(m_pDirDoc, m_filePaths.GetSize(), fileloc, dwFlags, m_strDesc);
ShowWindow(SW_RESTORE);
DestroyWindow();
}
#include "IMergeDoc.h"
#include "WinIMergeLib.h"
#include "LocationBar.h"
+#include "FileLocation.h"
class CDirDoc;
// Operations
public:
- bool OpenImages(const PathContext& paths, const bool bRO[], int nPane, CMDIFrameWnd *pParent);
+ bool OpenDocs(int nFiles, const FileLocation fileloc[], const bool bRO[], const String strDesc[], int nPane, CMDIFrameWnd *pParent);
void SetDirDoc(CDirDoc * pDirDoc);
void UpdateResources();
bool CloseNow();
fileloc.encoding = GuessCodepageEncoding(fileloc.filepath, iGuessEncoding);
}
-int CMainFrame::ShowAutoMergeDoc(CDirDoc * pDirDoc,
+bool CMainFrame::ShowAutoMergeDoc(CDirDoc * pDirDoc,
int nFiles, const FileLocation ifileloc[],
- const DWORD dwFlags[] /*=0*/, const PackingInfo * infoUnpacker /*= NULL*/)
+ const DWORD dwFlags[] /*=0*/, const String strDesc[], const PackingInfo * infoUnpacker /*= NULL*/)
{
int pane;
FileFilterHelper filterImg, filterBin;
for (pane = 0; pane < nFiles; ++pane)
{
if (filterImg.includeFile(ifileloc[pane].filepath))
- return ShowImgMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags, infoUnpacker);
+ return ShowImgMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags, strDesc, infoUnpacker);
else if (filterBin.includeFile(ifileloc[pane].filepath))
- {
- bool bRO[3];
- for (int pane = 0; pane < nFiles; pane++)
- bRO[pane] = (dwFlags) ? ((dwFlags[pane] & FFILEOPEN_READONLY) > 0) : FALSE;
- ShowHexMergeDoc(pDirDoc,
- (nFiles == 2) ?
- PathContext(ifileloc[0].filepath, ifileloc[1].filepath) :
- PathContext(ifileloc[0].filepath, ifileloc[1].filepath, ifileloc[2].filepath)
- , bRO);
- return 0;
- }
+ return ShowHexMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags, strDesc, infoUnpacker);
+ }
+ return ShowMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags, strDesc, infoUnpacker);
+}
+
+std::array<bool, 3> GetROFromFlags(int nFiles, const DWORD dwFlags[])
+{
+ std::array<bool, 3> bRO;
+ for (int pane = 0; pane < nFiles; pane++)
+ {
+ if (dwFlags)
+ bRO[pane] = ((dwFlags[pane] & FFILEOPEN_READONLY) > 0);
+ else
+ bRO[pane] = false;
+ }
+ return bRO;
+}
+
+int GetActivePaneFromFlags(int nFiles, const DWORD dwFlags[])
+{
+ int nActivePane = -1;
+ for (int pane = 0; pane < nFiles; ++pane)
+ {
+ if (dwFlags && (dwFlags[pane] & FFILEOPEN_SETFOCUS))
+ nActivePane = pane;
}
- return ShowMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags, infoUnpacker);
+ return nActivePane;
}
/**
* @param [in] dwLeftFlags Left side flags.
* @param [in] dwRightFlags Right side flags.
* @param [in] infoUnpacker Plugin info.
- * @return OPENRESULTS_TYPE for success/failure code.
+ * @return success/failure
*/
-int CMainFrame::ShowMergeDoc(CDirDoc * pDirDoc,
+bool CMainFrame::ShowMergeDoc(CDirDoc * pDirDoc,
int nFiles, const FileLocation ifileloc[],
- const DWORD dwFlags[] /*=0*/, const PackingInfo * infoUnpacker /*= NULL*/)
+ const DWORD dwFlags[], const String strDesc[], const PackingInfo * infoUnpacker /*= NULL*/)
{
if (!m_pMenus[MENU_MERGEVIEW])
theApp.m_pDiffTemplate->m_hMenuShared = NewMergeViewMenu();
// Make local copies, so we can change encoding if we guess it below
FileLocation fileloc[3];
- bool bRO[3];
- int pane;
- for (pane = 0; pane < nFiles; pane++)
- {
- fileloc[pane] = ifileloc[pane];
- if (dwFlags)
- bRO[pane] = (dwFlags[pane] & FFILEOPEN_READONLY) > 0;
- else
- bRO[pane] = FALSE;
- }
+ std::copy(ifileloc, ifileloc + nFiles, fileloc);
ASSERT(pMergeDoc); // must ASSERT to get an answer to the question below ;-)
if (!pMergeDoc)
- return OPENRESULTS_FAILED_MISC; // when does this happen ?
+ return false; // when does this happen ?
// if an unpacker is selected, it must be used during LoadFromFile
// MergeDoc must memorize it for SaveToFile
// detect codepage
int iGuessEncodingType = GetOptionsMgr()->GetInt(OPT_CP_DETECT);
- for (pane = 0; pane < nFiles; pane++)
+ for (int pane = 0; pane < nFiles; pane++)
{
if (fileloc[pane].encoding.m_unicoding == -1)
fileloc[pane].encoding.m_unicoding = ucr::NONE;
#endif
}
- int nActivePane = -1;
- for (pane = 0; pane < nFiles; pane++)
- {
- if (dwFlags && (dwFlags[pane] & FFILEOPEN_SETFOCUS))
- nActivePane = pane;
- }
-
// Note that OpenDocs() takes care of closing compare window when needed.
- OPENRESULTS_TYPE openResults = pMergeDoc->OpenDocs(fileloc, bRO, nActivePane);
+ bool openResults = pMergeDoc->OpenDocs(nFiles, fileloc, GetROFromFlags(nFiles, dwFlags).data(), strDesc, GetActivePaneFromFlags(nFiles, dwFlags));
- if (openResults == OPENRESULTS_SUCCESS)
+ if (openResults == true)
{
- for (pane = 0; pane < nFiles; pane++)
+ for (int pane = 0; pane < nFiles; pane++)
{
if (dwFlags)
{
return openResults;
}
-void CMainFrame::ShowHexMergeDoc(CDirDoc * pDirDoc,
- const PathContext &paths, const bool bRO[])
+bool CMainFrame::ShowHexMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
+ const DWORD dwFlags[] /*=0*/, const String strDesc[], const PackingInfo * infoUnpacker /*= NULL*/)
{
if (!m_pMenus[MENU_HEXMERGEVIEW])
theApp.m_pHexMergeTemplate->m_hMenuShared = NewHexMergeViewMenu();
- if (CHexMergeDoc *pHexMergeDoc = GetMergeDocForDiff<CHexMergeDoc>(theApp.m_pHexMergeTemplate, pDirDoc, paths.GetSize()))
- pHexMergeDoc->OpenDocs(paths, bRO);
+ if (CHexMergeDoc *pHexMergeDoc = GetMergeDocForDiff<CHexMergeDoc>(theApp.m_pHexMergeTemplate, pDirDoc, nFiles))
+ return pHexMergeDoc->OpenDocs(nFiles, fileloc, GetROFromFlags(nFiles, dwFlags).data(), strDesc, GetActivePaneFromFlags(nFiles, dwFlags));
+ return false;
}
-int CMainFrame::ShowImgMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
- const DWORD dwFlags[], const PackingInfo * infoUnpacker/* = NULL*/)
+bool CMainFrame::ShowImgMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
+ const DWORD dwFlags[], const String strDesc[], const PackingInfo * infoUnpacker/* = NULL*/)
{
CImgMergeFrame *pImgMergeFrame = new CImgMergeFrame();
if (!CImgMergeFrame::menu.m_hMenu)
CImgMergeFrame::menu.m_hMenu = NewImgMergeViewMenu();
pImgMergeFrame->SetSharedMenu(CImgMergeFrame::menu.m_hMenu);
- PathContext files;
- int pane;
- for (pane = 0; pane < nFiles; ++pane)
- files.SetPath(pane, fileloc[pane].filepath, false);
-
- bool bRO[3];
- for (pane = 0; pane < nFiles; pane++)
- {
- if (dwFlags)
- bRO[pane] = (dwFlags[pane] & FFILEOPEN_READONLY) > 0;
- else
- bRO[pane] = FALSE;
- }
-
- int nActivePane = -1;
- for (pane = 0; pane < nFiles; pane++)
- {
- if (dwFlags && (dwFlags[pane] & FFILEOPEN_SETFOCUS))
- nActivePane = pane;
- }
pImgMergeFrame->SetDirDoc(pDirDoc);
pDirDoc->AddMergeDoc(pImgMergeFrame);
-
- if (!pImgMergeFrame->OpenImages(files, bRO, nActivePane, this))
+
+ if (!pImgMergeFrame->OpenDocs(nFiles, fileloc, GetROFromFlags(nFiles, dwFlags).data(), strDesc, GetActivePaneFromFlags(nFiles, dwFlags), this))
{
- ShowMergeDoc(pDirDoc, nFiles, fileloc, dwFlags, infoUnpacker);
+ ShowMergeDoc(pDirDoc, nFiles, fileloc, dwFlags, strDesc, infoUnpacker);
}
else
{
- for (pane = 0; pane < nFiles; pane++)
+ for (int pane = 0; pane < nFiles; pane++)
{
if (dwFlags[pane] & FFILEOPEN_AUTOMERGE)
pImgMergeFrame->DoAutoMerge(pane);
* @return TRUE if opening files and compare succeeded, FALSE otherwise.
*/
BOOL CMainFrame::DoFileOpen(const PathContext * pFiles /*=NULL*/,
- const DWORD dwFlags[] /*=0*/, bool bRecurse /*=FALSE*/, CDirDoc *pDirDoc/*=NULL*/,
+ const DWORD dwFlags[] /*=0*/, const String strDesc[], bool bRecurse /*=FALSE*/, CDirDoc *pDirDoc/*=NULL*/,
String prediffer /*=_T("")*/, const PackingInfo *infoUnpacker/*=NULL*/)
{
if (pDirDoc && !pDirDoc->CloseMergeDocs())
// exception. There is no point in checking return value.
pDirDoc->InitCompare(files, bRecurse, pTempPathContext);
- pDirDoc->SetDescriptions(theApp.m_strDescriptions);
+ pDirDoc->SetDescriptions(strDesc);
pDirDoc->SetTitle(NULL);
for (int nIndex = 0; nIndex < files.GetSize(); nIndex++)
- {
pDirDoc->SetReadOnly(nIndex, bRO[nIndex]);
- theApp.m_strDescriptions[nIndex].erase();
- }
pDirDoc->Rescan();
}
pDirDoc->GetPluginManager().SetPrediffer(strBothFilenames, prediffer);
}
- ShowAutoMergeDoc(pDirDoc, files.GetSize(), fileloc, dwFlags,
+ ShowAutoMergeDoc(pDirDoc, files.GetSize(), fileloc, dwFlags, strDesc,
infoUnpacker);
}
}
}
- DoFileOpen(&files, dwFlags, recurse);
+ DoFileOpen(&files, dwFlags, NULL, recurse);
}
void CMainFrame::OnPluginUnpackMode(UINT nID )
// Load emptyfile descriptors and open empty docs
// Use default codepage
DWORD dwFlags[3] = {0, 0, 0};
+ String strDesc[3];
FileLocation fileloc[3];
if (nPanes == 2)
{
- theApp.m_strDescriptions[0] = _("Untitled left");
- theApp.m_strDescriptions[1] = _("Untitled right");
+ strDesc[0] = _("Untitled left");
+ strDesc[1] = _("Untitled right");
fileloc[0].encoding.SetCodepage(ucr::getDefaultCodepage());
fileloc[1].encoding.SetCodepage(ucr::getDefaultCodepage());
- ShowMergeDoc(pDirDoc, 2, fileloc, dwFlags);
+ ShowMergeDoc(pDirDoc, 2, fileloc, dwFlags, strDesc);
}
else
{
- theApp.m_strDescriptions[0] = _("Untitled left");
- theApp.m_strDescriptions[1] = _("Untitled middle");
- theApp.m_strDescriptions[2] = _("Untitled right");
+ strDesc[0] = _("Untitled left");
+ strDesc[1] = _("Untitled middle");
+ strDesc[2] = _("Untitled right");
fileloc[0].encoding.SetCodepage(ucr::getDefaultCodepage());
fileloc[1].encoding.SetCodepage(ucr::getDefaultCodepage());
fileloc[2].encoding.SetCodepage(ucr::getDefaultCodepage());
- ShowMergeDoc(pDirDoc, 3, fileloc, dwFlags);
+ ShowMergeDoc(pDirDoc, 3, fileloc, dwFlags, strDesc);
}
-
- // Empty descriptors now that docs are open
- theApp.m_strDescriptions[0].erase();
- theApp.m_strDescriptions[1].erase();
- theApp.m_strDescriptions[2].erase();
}
/**
// Open two parsed files to WinMerge, telling WinMerge to
// save over original file (given as third filename).
theApp.m_strSaveAsPath = conflictFile;
- String theirs = _("Theirs File");
- String my = _("Mine File");
- theApp.m_strDescriptions[0] = theirs;
- theApp.m_strDescriptions[1] = my;
-
+ String strDesc[2] = { _("Theirs File"), _("Mine File") };
DWORD dwFlags[2] = {FFILEOPEN_READONLY | FFILEOPEN_NOMRU, FFILEOPEN_NOMRU | FFILEOPEN_MODIFIED};
conflictCompared = DoFileOpen(&PathContext(revFile, workFile),
dwFlags);
void UpdatePrediffersMenu();
BOOL DoFileOpen(const PathContext *pFiles = NULL,
- const DWORD dwFlags[] = NULL, bool bRecurse = false, CDirDoc *pDirDoc = NULL, String prediffer = _T(""), const PackingInfo * infoUnpacker = NULL);
- int ShowAutoMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
- const DWORD dwFlags[], const PackingInfo * infoUnpacker = NULL);
- int ShowMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
- const DWORD dwFlags[], const PackingInfo * infoUnpacker = NULL);
- void ShowHexMergeDoc(CDirDoc * pDirDoc,
- const PathContext &paths, const bool bRO[]);
- int ShowImgMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
- const DWORD dwFlags[], const PackingInfo * infoUnpacker = NULL);
+ const DWORD dwFlags[] = NULL, const String strDesc[] = NULL, bool bRecurse = false, CDirDoc *pDirDoc = NULL, String prediffer = _T(""), const PackingInfo * infoUnpacker = NULL);
+ bool ShowAutoMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
+ const DWORD dwFlags[], const String strDesc[], const PackingInfo * infoUnpacker = NULL);
+ bool ShowMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
+ const DWORD dwFlags[], const String strDesc[], const PackingInfo * infoUnpacker = NULL);
+ bool ShowHexMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
+ const DWORD dwFlags[], const String strDesc[], const PackingInfo * infoUnpacker = NULL);
+ bool ShowImgMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
+ const DWORD dwFlags[], const String strDesc[], const PackingInfo * infoUnpacker = NULL);
void UpdateResources();
void ClearStatusbarItemCount();
BOOL CMergeApp::ParseArgsAndDoOpen(MergeCmdLineInfo& cmdInfo, CMainFrame* pMainFrame)
{
BOOL bCompared = FALSE;
+ String strDesc[3];
m_bNonInteractive = cmdInfo.m_bNonInteractive;
// Set the global file filter.
m_strSaveAsPath = cmdInfo.m_sOutputpath;
- m_strDescriptions[0] = cmdInfo.m_sLeftDesc;
+ strDesc[0] = cmdInfo.m_sLeftDesc;
if (cmdInfo.m_Files.GetSize() < 3)
{
- m_strDescriptions[1] = cmdInfo.m_sRightDesc;
+ strDesc[1] = cmdInfo.m_sRightDesc;
}
else
{
- m_strDescriptions[1] = cmdInfo.m_sMiddleDesc;
- m_strDescriptions[2] = cmdInfo.m_sRightDesc;
+ strDesc[1] = cmdInfo.m_sMiddleDesc;
+ strDesc[2] = cmdInfo.m_sRightDesc;
}
if (cmdInfo.m_Files.GetSize() > 2)
cmdInfo.m_dwRightFlags |= FFILEOPEN_CMDLINE;
DWORD dwFlags[3] = {cmdInfo.m_dwLeftFlags, cmdInfo.m_dwMiddleFlags, cmdInfo.m_dwRightFlags};
bCompared = pMainFrame->DoFileOpen(&cmdInfo.m_Files,
- dwFlags, cmdInfo.m_bRecurse, NULL,
+ dwFlags, strDesc, cmdInfo.m_bRecurse, NULL,
cmdInfo.m_sPreDiffer);
}
else if (cmdInfo.m_Files.GetSize() > 1)
{
DWORD dwFlags[3] = {cmdInfo.m_dwLeftFlags, cmdInfo.m_dwRightFlags, FFILEOPEN_NONE};
bCompared = pMainFrame->DoFileOpen(&cmdInfo.m_Files,
- dwFlags, cmdInfo.m_bRecurse, NULL,
+ dwFlags, strDesc, cmdInfo.m_bRecurse, NULL,
cmdInfo.m_sPreDiffer);
}
else if (cmdInfo.m_Files.GetSize() == 1)
{
DWORD dwFlags[3] = {cmdInfo.m_dwLeftFlags, cmdInfo.m_dwRightFlags, FFILEOPEN_NONE};
bCompared = pMainFrame->DoFileOpen(&cmdInfo.m_Files,
- dwFlags, cmdInfo.m_bRecurse, NULL,
+ dwFlags, strDesc, cmdInfo.m_bRecurse, NULL,
cmdInfo.m_sPreDiffer);
}
}
GetOptionsMgr()->SaveOption(OPT_CMP_INCLUDE_SUBDIRS, bRecursive);
- BOOL rtn = GetMainFrame()->DoFileOpen(&files, dwFlags, bRecursive);
+ BOOL rtn = GetMainFrame()->DoFileOpen(&files, dwFlags, NULL, bRecursive);
AddToRecentProjectsMRU(sProject.c_str());
return !!rtn;
std::unique_ptr<LineFiltersList> m_pLineFilters; /**< List of linefilters */
std::unique_ptr<FilterCommentsManager> m_pFilterCommentsManager;
- /**
- * @name Textual labels/descriptors
- * These descriptors overwrite dir/filename usually shown in headerbar
- * and can be given from command-line. For example version control
- * system can set these to "WinMerge v2.1.2.0" and "WinMerge 2.1.4.0"
- * which is more pleasant and informative than temporary paths.
- */
- /*@{*/
- String m_strDescriptions[3];
- /*@}*/
-
WORD GetLangId() const;
void SetIndicators(CStatusBar &, const UINT *, int) const;
void TranslateMenu(HMENU) const;
* @param [in] encoding File's encoding.
* @return One of FileLoadResult values.
*/
-DWORD CMergeDoc::LoadOneFile(int index, String filename, bool readOnly,
+DWORD CMergeDoc::LoadOneFile(int index, String filename, bool readOnly, const String& strDesc,
const FileTextEncoding & encoding)
{
DWORD loadSuccess = FileLoadResult::FRESULT_ERROR;;
+ m_strDesc[index] = strDesc;
if (!filename.empty())
{
- if (theApp.m_strDescriptions[index].empty())
+ if (strDesc.empty())
m_nBufferType[index] = BUFFER_NORMAL;
else
- {
m_nBufferType[index] = BUFFER_NORMAL_NAMED;
- m_strDesc[index] = theApp.m_strDescriptions[index];
- theApp.m_strDescriptions[index].erase();
- }
m_pSaveFileInfo[index]->Update(filename);
m_pRescanFileInfo[index]->Update(filename);
{
m_nBufferType[index] = BUFFER_UNNAMED;
m_ptBuf[index]->InitNew();
- m_strDesc[index] = theApp.m_strDescriptions[index];
m_ptBuf[index]->m_encoding = encoding;
loadSuccess = FileLoadResult::FRESULT_OK;
}
* @todo Options are still read from CMainFrame, this will change
* @sa CMainFrame::ShowMergeDoc()
*/
-OPENRESULTS_TYPE CMergeDoc::OpenDocs(FileLocation fileloc[],
- bool bRO[], int nPane/* = -1 */, int nLineIndex/* = -1 */)
+bool CMergeDoc::OpenDocs(int nFiles, const FileLocation ifileloc[],
+ const bool bRO[], const String strDesc[], int nPane/* = -1 */, int nLineIndex/* = -1 */)
{
IDENTLEVEL identical = IDENTLEVEL_NONE;
int nRescanResult = RESCAN_OK;
int nBuffer;
+ FileLocation fileloc[3];
+
+ std::copy(ifileloc, ifileloc + 3, fileloc);
// Filter out invalid codepages, or editor will display all blank
for (nBuffer = 0; nBuffer < m_nBuffers; nBuffer++)
DWORD nSuccess[3];
for (nBuffer = 0; nBuffer < m_nBuffers; nBuffer++)
{
- nSuccess[nBuffer] = LoadOneFile(nBuffer, fileloc[nBuffer].filepath, bRO[nBuffer],
+ nSuccess[nBuffer] = LoadOneFile(nBuffer, fileloc[nBuffer].filepath, bRO[nBuffer], strDesc ? strDesc[nBuffer] : _T(""),
fileloc[nBuffer].encoding);
}
const bool bFiltersEnabled = GetOptionsMgr()->GetBool(OPT_PLUGINS_ENABLED);
// Bail out if either side failed
if (std::find_if(nSuccess, nSuccess + m_nBuffers, std::not1(std::ptr_fun(FileLoadResult::IsOk))) != nSuccess + m_nBuffers)
{
- OPENRESULTS_TYPE retVal = OPENRESULTS_FAILED_MISC;
CChildFrame *pFrame = GetParentFrame();
if (pFrame)
{
// Use verify macro to trap possible error in debug.
VERIFY(pFrame->DestroyWindow());
}
- return retVal;
+ return false;
}
// Warn user if file load was lossy (bad encoding)
// your temp directory, doing nothing is graceful enough for that).
ShowRescanError(nRescanResult, identical);
GetParentFrame()->DestroyWindow();
- return OPENRESULTS_FAILED_MISC;
+ return false;
}
// Force repaint of location pane to update it in case we had some warning
if (m_pView[0])
m_pView[0]->RepaintLocationPane();
- return OPENRESULTS_SUCCESS;
+ return true;
}
/**
if (HasZipSupport() && std::count_if(m_filePaths.begin(), m_filePaths.end(), ArchiveGuessFormat) == m_nBuffers)
{
DWORD dwFlags[3] = {FFILEOPEN_NOMRU, FFILEOPEN_NOMRU, FFILEOPEN_NOMRU};
- GetMainFrame()->DoFileOpen(&m_filePaths, dwFlags,
+ GetMainFrame()->DoFileOpen(&m_filePaths, dwFlags, m_strDesc,
GetOptionsMgr()->GetBool(OPT_CMP_INCLUDE_SUBDIRS), NULL, _T(""), &infoUnpacker);
CloseNow();
}
fileloc[pane].encoding.m_unicoding = m_ptBuf[pane]->getUnicoding();
fileloc[pane].encoding.m_codepage = m_ptBuf[pane]->getCodepage();
fileloc[pane].setPath(m_filePaths[pane]);
- theApp.m_strDescriptions[pane] = m_strDesc[pane];
}
int nActivePane = GetActiveMergeView()->m_nThisPane;
CPoint pt = m_pView[nActivePane]->GetCursorPos();
- OpenDocs(fileloc, bRO, nActivePane, pt.y);
+ OpenDocs(m_nBuffers, fileloc, bRO, m_strDesc, nActivePane, pt.y);
}
/**
void CMergeDoc::OnBnClickedHexView()
{
- bool bRO[3];
+ DWORD dwFlags[3] = { 0 };
+ FileLocation fileloc[3];
for (int pane = 0; pane < m_nBuffers; pane++)
- bRO[pane] = m_ptBuf[pane]->GetReadOnly();
+ {
+ fileloc[pane].setPath(m_filePaths[pane]);
+ dwFlags[pane] |= FFILEOPEN_NOMRU | (m_ptBuf[pane]->GetReadOnly() ? FFILEOPEN_READONLY : 0);
+ }
if (m_pEncodingErrorBar && m_pEncodingErrorBar->IsWindowVisible())
m_pView[0]->GetParentFrame()->ShowControlBar(m_pEncodingErrorBar.get(), FALSE, FALSE);
- GetMainFrame()->ShowHexMergeDoc(m_pDirDoc, m_filePaths, bRO);
+ GetMainFrame()->ShowHexMergeDoc(m_pDirDoc, m_nBuffers, fileloc, dwFlags, m_strDesc);
GetParentFrame()->ShowWindow(SW_RESTORE);
GetParentFrame()->DestroyWindow();
}
SAVE_CANCELLED, /**< Saving was cancelled */
};
-/**
- * @brief Result of trying to open file in MergeEditView display
- */
-typedef enum {
- OPENRESULTS_SUCCESS, /**< Open succeeded */
- OPENRESULTS_FAILED_BINARY, /**< Open failed because one or both files were binary */
- OPENRESULTS_FAILED_MISC /**< Open failed for some other reason */
-} OPENRESULTS_TYPE;
-
enum MERGEVIEW_INDEX_TYPE
{
MERGEVIEW_PANE0 = 0, /**< Pane0 MergeView */
void UpdateHeaderActivity(int pane, bool bActivate);
void RefreshOptions();
void UpdateResources();
- OPENRESULTS_TYPE OpenDocs(FileLocation fileloc[],
- bool bRO[], int nPane = -1, int nLineIndex = -1);
+ bool OpenDocs(int nFiles, const FileLocation fileloc[],
+ const bool bRO[], const String strDesc[], int nPane = -1, int nLineIndex = -1);
int LoadFile(CString sFileName, int nBuffer, bool & readOnly, const FileTextEncoding & encoding);
void RescanIfNeeded(float timeOutInSecond);
int Rescan(bool &bBinary, IDENTLEVEL &identical, bool bForced = false);
bool GetByteColoringOption() const;
bool IsValidCodepageForMergeEditor(unsigned cp) const;
void SanityCheckCodepage(FileLocation & fileinfo);
- DWORD LoadOneFile(int index, String filename, bool readOnly, const FileTextEncoding & encoding);
+ DWORD LoadOneFile(int index, String filename, bool readOnly, const String& strDesc, const FileTextEncoding & encoding);
// Implementation data
protected:
fileloc[pane].encoding.m_codepage = m_ptBuf[pane]->getCodepage();
}
fileloc[pane].setPath(m_filePaths[pane]);
- theApp.m_strDescriptions[pane] = m_strDesc[pane];
}
- OpenDocs(fileloc, bRO);
+ OpenDocs(m_nBuffers, fileloc, bRO, m_strDesc);
if (dlg.GetSaveCodepage() != dlg.GetLoadCodepage())
{
GetParentFrame()->PostMessage(WM_CLOSE);
GetMainFrame()->DoFileOpen(
- &PathContext(pDoc->m_files), &std::vector<DWORD>(pDoc->m_dwFlags, pDoc->m_dwFlags + 3)[0], !!pDoc->m_bRecurse, NULL, _T(""), &PackingInfo(pDoc->m_infoHandler));
+ &PathContext(pDoc->m_files), &std::vector<DWORD>(pDoc->m_dwFlags, pDoc->m_dwFlags + 3)[0], NULL, !!pDoc->m_bRecurse, NULL, _T(""), &PackingInfo(pDoc->m_infoHandler));
}
/**