bool bRet = false;
DirCmpReportDlg dlg;
- if (dlg.DoModal() == IDOK) try
+ dlg.LoadSettings();
+ dlg.m_sReportFile = m_sReportFile;
+
+ if (!m_sReportFile.empty() || dlg.DoModal() == IDOK) try
{
CWaitCursor waitstatus;
if (dlg.m_bCopyToClipboard)
explicit DirCmpReport(const std::vector<String>& colRegKeys);
void SetList(IListCtrl *pList);
void SetRootPaths(const PathContext &paths);
+ void SetReportFile(const String& sReportFile) { m_sReportFile = sReportFile; }
void SetColumns(int columns);
void SetFileCmpReport(IFileCmpReport *pFileCmpReport);
bool GenerateReport(String &errStr);
IListCtrl * m_pList; /**< Pointer to UI-list */
PathContext m_rootPaths; /**< Root paths, printed to report */
String m_sTitle; /**< Report title, built from root paths */
+ String m_sReportFile;
int m_nColumns; /**< Columns in UI */
String m_sSeparator; /**< Column separator for report */
CFile *m_pFile; /**< File to write report to */
},
};
+void DirCmpReportDlg::LoadSettings()
+{
+ m_nReportType = static_cast<REPORT_TYPE>(AfxGetApp()->GetProfileInt(_T("ReportFiles"), _T("ReportType"), 0));
+ m_bCopyToClipboard = !!AfxGetApp()->GetProfileInt(_T("ReportFiles"), _T("CopoyToClipboard"), false);
+ m_bIncludeFileCmpReport = !!AfxGetApp()->GetProfileInt(_T("ReportFiles"), _T("IncludeFileCmpReport"), false);
+}
+
/**
* @brief Dialog initializer function.
*/
{
CTrDialog::OnInitDialog();
+ LoadSettings();
+
m_ctlReportFile.LoadState(_T("ReportFiles"));
- m_nReportType = static_cast<REPORT_TYPE>(AfxGetApp()->GetProfileInt(_T("ReportFiles"), _T("ReportType"), 0));
- m_bCopyToClipboard = !!AfxGetApp()->GetProfileInt(_T("ReportFiles"), _T("CopoyToClipboard"), false);
- m_bIncludeFileCmpReport = !!AfxGetApp()->GetProfileInt(_T("ReportFiles"), _T("IncludeFileCmpReport"), false);
for (int i = 0; i < sizeof(f_types) / sizeof(f_types[0]); ++i)
{
DECLARE_MESSAGE_MAP()
public:
+ void LoadSettings();
+
// Generated message map functions
//{{AFX_MSG(DirCmpReportDlg)
afx_msg void OnBtnClickReportBrowse();
bool GetReadOnly(int nIndex) const;
const bool *GetReadOnly(void) const;
void SetReadOnly(int nIndex, bool bReadOnly);
+ String GetReportFile() const { return m_sReportFile; }
+ void SetReportFile(const String& sReportFile) { m_sReportFile = sReportFile; }
bool HasDirView() const { return m_pDirView != NULL; }
void RefreshOptions();
void CompareReady();
MergeDocPtrList m_MergeDocs; /**< List of file compares opened from this compare */
bool m_bRO[3]; /**< Is left/middle/right side read-only */
String m_strDesc[3]; /**< Left/middle/right side desription text */
+ String m_sReportFile;
PluginManager m_pluginman;
bool m_bMarkedRescan; /**< If TRUE next rescan scans only marked items */
};
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, NULL, GetDiffContext().m_bRecursive, (GetAsyncKeyState(VK_CONTROL) & 0x8000) ? NULL : pDoc);
+ GetMainFrame()->DoFileOpen(&pathsParent, dwFlags, NULL, _T(""), 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, NULL, GetDiffContext().m_bRecursive, (GetAsyncKeyState(VK_CONTROL) & 0x8000) ? NULL : pDoc);
+ GetMainFrame()->DoFileOpen(&paths, dwFlags, NULL, _T(""), 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, NULL, GetDiffContext().m_bRecursive, NULL, _T(""), infoUnpacker);
+ GetMainFrame()->DoFileOpen(&paths, dwFlags, NULL, _T(""), GetDiffContext().m_bRecursive, NULL, _T(""), infoUnpacker);
}
else
{
fileloc[nIndex].encoding = pdi[nIndex]->diffFileInfo[nPane[nIndex]].encoding;
}
GetMainFrame()->ShowAutoMergeDoc(pDoc, paths.GetSize(), fileloc,
- dwFlags, strDesc, infoUnpacker);
+ dwFlags, strDesc, _T(""), infoUnpacker);
}
}
Redisplay();
+ if (!pDoc->GetReportFile().empty())
+ {
+ OnToolsGenerateReport();
+ pDoc->SetReportFile(_T(""));
+ }
+
if (GetOptionsMgr()->GetBool(OPT_SCROLL_TO_FIRST))
OnFirstdiff();
else
void CDirView::OnToolsGenerateReport()
{
CDirDoc *pDoc = GetDocument();
- if (!pDoc->HasDiffs())
- {
- // No items, no report
- return;
- }
-
const CDiffContext& ctxt = GetDiffContext();
// Make list of registry keys for columns
report.SetRootPaths(paths);
report.SetColumns(m_pColItems->GetDispColCount());
report.SetFileCmpReport(&freport);
+ report.SetReportFile(pDoc->GetReportFile());
String errStr;
if (report.GenerateReport(errStr))
{
if (errStr.empty())
- LangMessageBox(IDS_REPORT_SUCCESS, MB_OK | MB_ICONINFORMATION);
+ {
+ if (pDoc->GetReportFile().empty())
+ LangMessageBox(IDS_REPORT_SUCCESS, MB_OK | MB_ICONINFORMATION);
+ }
else
{
String msg = string_format_string1(
bool CMainFrame::ShowAutoMergeDoc(CDirDoc * pDirDoc,
int nFiles, const FileLocation ifileloc[],
- const DWORD dwFlags[] /*=0*/, const String strDesc[], const PackingInfo * infoUnpacker /*= NULL*/)
+ const DWORD dwFlags[] /*=0*/, const String strDesc[], const String& sReportFile,
+ 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, strDesc, infoUnpacker);
+ return ShowImgMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags, strDesc, sReportFile, infoUnpacker);
else if (filterBin.includeFile(ifileloc[pane].filepath))
- return ShowHexMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags, strDesc, infoUnpacker);
+ return ShowHexMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags, strDesc, sReportFile, infoUnpacker);
}
- return ShowMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags, strDesc, infoUnpacker);
+ return ShowMergeDoc(pDirDoc, nFiles, ifileloc, dwFlags, strDesc, sReportFile, infoUnpacker);
}
std::array<bool, 3> GetROFromFlags(int nFiles, const DWORD dwFlags[])
*/
bool CMainFrame::ShowMergeDoc(CDirDoc * pDirDoc,
int nFiles, const FileLocation ifileloc[],
- const DWORD dwFlags[], const String strDesc[], const PackingInfo * infoUnpacker /*= NULL*/)
+ const DWORD dwFlags[], const String strDesc[], const String& sReportFile,
+ const PackingInfo * infoUnpacker /*= NULL*/)
{
if (!m_pMenus[MENU_MERGEVIEW])
theApp.m_pDiffTemplate->m_hMenuShared = NewMergeViewMenu();
}
// Note that OpenDocs() takes care of closing compare window when needed.
- bool openResults = pMergeDoc->OpenDocs(nFiles, fileloc, GetROFromFlags(nFiles, dwFlags).data(), strDesc, GetActivePaneFromFlags(nFiles, dwFlags));
+ if (!pMergeDoc->OpenDocs(nFiles, fileloc, GetROFromFlags(nFiles, dwFlags).data(), strDesc, GetActivePaneFromFlags(nFiles, dwFlags)))
+ return false;
- if (openResults == true)
+ for (int pane = 0; pane < nFiles; pane++)
{
- for (int pane = 0; pane < nFiles; pane++)
+ if (dwFlags)
{
- if (dwFlags)
+ BOOL bModified = (dwFlags[pane] & FFILEOPEN_MODIFIED) > 0;
+ if (bModified)
+ {
+ pMergeDoc->m_ptBuf[pane]->SetModified(TRUE);
+ pMergeDoc->UpdateHeaderPath(pane);
+ }
+ if (dwFlags[pane] & FFILEOPEN_AUTOMERGE)
{
- BOOL bModified = (dwFlags[pane] & FFILEOPEN_MODIFIED) > 0;
- if (bModified)
- {
- pMergeDoc->m_ptBuf[pane]->SetModified(TRUE);
- pMergeDoc->UpdateHeaderPath(pane);
- }
- if (dwFlags[pane] & FFILEOPEN_AUTOMERGE)
- {
- pMergeDoc->DoAutoMerge(pane);
- }
+ pMergeDoc->DoAutoMerge(pane);
}
}
}
- return openResults;
+
+ if (!sReportFile.empty())
+ pMergeDoc->GenerateReport(sReportFile);
+
+ return true;
}
bool CMainFrame::ShowHexMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
- const DWORD dwFlags[] /*=0*/, const String strDesc[], const PackingInfo * infoUnpacker /*= NULL*/)
+ const DWORD dwFlags[] /*=0*/, const String strDesc[], const String& sReportFile,
+ const PackingInfo * infoUnpacker /*= NULL*/)
{
if (!m_pMenus[MENU_HEXMERGEVIEW])
theApp.m_pHexMergeTemplate->m_hMenuShared = NewHexMergeViewMenu();
- 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;
+ CHexMergeDoc *pHexMergeDoc = GetMergeDocForDiff<CHexMergeDoc>(theApp.m_pHexMergeTemplate, pDirDoc, nFiles);
+ if (!pHexMergeDoc)
+ return false;
+
+ if (!pHexMergeDoc->OpenDocs(nFiles, fileloc, GetROFromFlags(nFiles, dwFlags).data(), strDesc, GetActivePaneFromFlags(nFiles, dwFlags)))
+ return false;
+
+ if (!sReportFile.empty())
+ pHexMergeDoc->GenerateReport(sReportFile);
+
+ return true;
}
bool CMainFrame::ShowImgMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
- const DWORD dwFlags[], const String strDesc[], const PackingInfo * infoUnpacker/* = NULL*/)
+ const DWORD dwFlags[], const String strDesc[], const String& sReportFile,
+ const PackingInfo * infoUnpacker/* = NULL*/)
{
CImgMergeFrame *pImgMergeFrame = new CImgMergeFrame();
if (!CImgMergeFrame::menu.m_hMenu)
pDirDoc->AddMergeDoc(pImgMergeFrame);
if (!pImgMergeFrame->OpenDocs(nFiles, fileloc, GetROFromFlags(nFiles, dwFlags).data(), strDesc, GetActivePaneFromFlags(nFiles, dwFlags), this))
+ return ShowMergeDoc(pDirDoc, nFiles, fileloc, dwFlags, strDesc, sReportFile, infoUnpacker);
+
+ for (int pane = 0; pane < nFiles; pane++)
{
- ShowMergeDoc(pDirDoc, nFiles, fileloc, dwFlags, strDesc, infoUnpacker);
- }
- else
- {
- for (int pane = 0; pane < nFiles; pane++)
- {
- if (dwFlags[pane] & FFILEOPEN_AUTOMERGE)
- pImgMergeFrame->DoAutoMerge(pane);
- }
+ if (dwFlags[pane] & FFILEOPEN_AUTOMERGE)
+ pImgMergeFrame->DoAutoMerge(pane);
}
- return 0;
+ if (!sReportFile.empty())
+ pImgMergeFrame->GenerateReport(sReportFile);
+
+ return true;
}
/**
* @return TRUE if opening files and compare succeeded, FALSE otherwise.
*/
BOOL CMainFrame::DoFileOpen(const PathContext * pFiles /*=NULL*/,
- const DWORD dwFlags[] /*=0*/, const String strDesc[], bool bRecurse /*=FALSE*/, CDirDoc *pDirDoc/*=NULL*/,
+ const DWORD dwFlags[] /*=0*/, const String strDesc[], const String& sReportFile, 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->SetReportFile(sReportFile);
pDirDoc->SetDescriptions(strDesc);
pDirDoc->SetTitle(NULL);
for (int nIndex = 0; nIndex < files.GetSize(); nIndex++)
pDirDoc->GetPluginManager().SetPrediffer(strBothFilenames, prediffer);
}
- ShowAutoMergeDoc(pDirDoc, files.GetSize(), fileloc, dwFlags, strDesc,
+ ShowAutoMergeDoc(pDirDoc, files.GetSize(), fileloc, dwFlags, strDesc, sReportFile,
infoUnpacker);
}
}
}
- DoFileOpen(&files, dwFlags, NULL, recurse);
+ DoFileOpen(&files, dwFlags, NULL, _T(""), recurse);
}
void CMainFrame::OnPluginUnpackMode(UINT nID )
void UpdatePrediffersMenu();
BOOL DoFileOpen(const PathContext *pFiles = NULL,
- const DWORD dwFlags[] = NULL, const String strDesc[] = NULL, bool bRecurse = false, CDirDoc *pDirDoc = NULL, String prediffer = _T(""), const PackingInfo * infoUnpacker = NULL);
+ const DWORD dwFlags[] = NULL, const String strDesc[] = NULL, const String& sReportFile = _T(""), 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);
+ const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = NULL);
bool ShowMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
- const DWORD dwFlags[], const String strDesc[], const PackingInfo * infoUnpacker = NULL);
+ const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = NULL);
bool ShowHexMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
- const DWORD dwFlags[], const String strDesc[], const PackingInfo * infoUnpacker = NULL);
+ const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = NULL);
bool ShowImgMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
- const DWORD dwFlags[], const String strDesc[], const PackingInfo * infoUnpacker = NULL);
+ const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = NULL);
void UpdateResources();
void ClearStatusbarItemCount();
cmdInfo.m_dwRightFlags |= FFILEOPEN_CMDLINE;
DWORD dwFlags[3] = {cmdInfo.m_dwLeftFlags, cmdInfo.m_dwMiddleFlags, cmdInfo.m_dwRightFlags};
bCompared = pMainFrame->DoFileOpen(&cmdInfo.m_Files,
- dwFlags, strDesc, cmdInfo.m_bRecurse, NULL,
+ dwFlags, strDesc, cmdInfo.m_sReportFile, 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, strDesc, cmdInfo.m_bRecurse, NULL,
+ dwFlags, strDesc, cmdInfo.m_sReportFile, 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, strDesc, cmdInfo.m_bRecurse, NULL,
+ dwFlags, strDesc, cmdInfo.m_sReportFile, cmdInfo.m_bRecurse, NULL,
cmdInfo.m_sPreDiffer);
}
}
* @param [in] sProject Full path to project file.
* @return TRUE if loading project file and starting compare succeeded.
*/
-bool CMergeApp::LoadAndOpenProjectFile(const String& sProject)
+bool CMergeApp::LoadAndOpenProjectFile(const String& sProject, const String& sReportFile)
{
ProjectFile project;
if (!LoadProjectFile(sProject, project))
GetOptionsMgr()->SaveOption(OPT_CMP_INCLUDE_SUBDIRS, bRecursive);
- BOOL rtn = GetMainFrame()->DoFileOpen(&files, dwFlags, NULL, bRecursive);
+ BOOL rtn = GetMainFrame()->DoFileOpen(&files, dwFlags, NULL, sReportFile, bRecursive);
AddToRecentProjectsMRU(sProject.c_str());
return !!rtn;
bool LoadProjectFile(const String& sProject, ProjectFile &project);
bool SaveProjectFile(const String& sProject, const ProjectFile &project);
- bool LoadAndOpenProjectFile(const String& sFilepath);
+ bool LoadAndOpenProjectFile(const String& sFilepath, const String& sReportFile = _T(""));
bool IsProjectFile(const String& filepath) const;
//@{
// -o "outputfilename"
q = EatParam(q, m_sOutputpath);
}
+ else if (param == _T("or"))
+ {
+ // -or "reportfilename"
+ q = EatParam(q, m_sReportFile);
+ }
else if (param == _T("dl"))
{
// -dl "desc" - description for left file
String m_sPreDiffer; /**< Pre-differ name. */
String m_sOutputpath;
+ String m_sReportFile;
PathContext m_Files; /**< Files (or directories) to compare. */
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, m_strDesc,
+ GetMainFrame()->DoFileOpen(&m_filePaths, dwFlags, m_strDesc, _T(""),
GetOptionsMgr()->GetBool(OPT_CMP_INCLUDE_SUBDIRS), NULL, _T(""), &infoUnpacker);
CloseNow();
}
GetParentFrame()->PostMessage(WM_CLOSE);
GetMainFrame()->DoFileOpen(
- &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));
+ &PathContext(pDoc->m_files), &std::vector<DWORD>(pDoc->m_dwFlags, pDoc->m_dwFlags + 3)[0],
+ NULL, _T(""), !!pDoc->m_bRecurse, NULL, _T(""), &PackingInfo(pDoc->m_infoHandler));
}
/**