1 /////////////////////////////////////////////////////////////////////////////
2 // WinMerge: an interactive diff/merge utility
3 // Copyright (C) 1997-2000 Thingamahoochie Software
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /////////////////////////////////////////////////////////////////////////////
22 * @file HexMergeDoc.cpp
24 * @brief Implementation file for CHexMergeDoc
29 #include "HexMergeDoc.h"
31 #include "UnicodeString.h"
32 #include "HexMergeFrm.h"
33 #include "HexMergeView.h"
35 #include "FolderCmp.h"
36 #include "DiffContext.h" // FILE_SAME
38 #include "DirActions.h"
39 #include "OptionsDef.h"
40 #include "DiffFileInfo.h"
41 #include "SaveClosingDlg.h"
44 #include "OptionsMgr.h"
45 #include "FileOrFolderSelect.h"
46 #include "DiffWrapper.h"
47 #include "SyntaxColors.h"
49 #include "Constants.h"
56 int CHexMergeDoc::m_nBuffersTemp = 2;
58 static void UpdateDiffItem(int nBuffers, DIFFITEM &di, CDiffContext *pCtxt);
59 static int Try(HRESULT hr, UINT type = MB_OKCANCEL|MB_ICONSTOP);
62 * @brief Update diff item
64 static void UpdateDiffItem(int nBuffers, DIFFITEM &di, CDiffContext *pCtxt)
66 di.diffcode.setSideNone();
67 for (int nBuffer = 0; nBuffer < nBuffers; nBuffer++)
69 di.diffFileInfo[nBuffer].ClearPartial();
70 if (pCtxt->UpdateInfoFromDiskHalf(di, nBuffer))
71 di.diffcode.diffcode |= DIFFCODE::FIRST << nBuffer;
74 di.diffcode.diffcode &= ~(DIFFCODE::TEXTFLAGS | DIFFCODE::COMPAREFLAGS | DIFFCODE::COMPAREFLAGS3WAY);
77 di.diffcode.diffcode |= folderCmp.prepAndCompareFiles(pCtxt, di);
81 * @brief Issue an error popup if passed in HRESULT is nonzero
83 static int Try(HRESULT hr, UINT type)
85 return hr ? CInternetException(hr).ReportError(type) : 0;
88 /////////////////////////////////////////////////////////////////////////////
91 IMPLEMENT_DYNCREATE(CHexMergeDoc, CDocument)
93 BEGIN_MESSAGE_MAP(CHexMergeDoc, CDocument)
94 //{{AFX_MSG_MAP(CHexMergeDoc)
95 ON_COMMAND(ID_FILE_SAVE, OnFileSave)
96 ON_COMMAND(ID_FILE_SAVE_LEFT, OnFileSaveLeft)
97 ON_COMMAND(ID_FILE_SAVE_RIGHT, OnFileSaveRight)
98 ON_COMMAND(ID_FILE_SAVEAS_LEFT, OnFileSaveAsLeft)
99 ON_COMMAND(ID_FILE_SAVEAS_RIGHT, OnFileSaveAsRight)
100 ON_UPDATE_COMMAND_UI(ID_STATUS_DIFFNUM, OnUpdateStatusNum)
101 ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_LEFT, OnUpdateFileSaveLeft)
102 ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_RIGHT, OnUpdateFileSaveRight)
103 ON_UPDATE_COMMAND_UI(ID_FILE_SAVE, OnUpdateFileSave)
104 ON_COMMAND(ID_RESCAN, OnFileReload)
105 ON_COMMAND(ID_L2R, OnL2r)
106 ON_COMMAND(ID_R2L, OnR2l)
107 ON_COMMAND(ID_COPY_FROM_LEFT, OnCopyFromLeft)
108 ON_COMMAND(ID_COPY_FROM_RIGHT, OnCopyFromRight)
109 ON_COMMAND(ID_ALL_LEFT, OnAllLeft)
110 ON_COMMAND(ID_ALL_RIGHT, OnAllRight)
111 ON_COMMAND(ID_VIEW_ZOOMIN, OnViewZoomIn)
112 ON_COMMAND(ID_VIEW_ZOOMOUT, OnViewZoomOut)
113 ON_COMMAND(ID_VIEW_ZOOMNORMAL, OnViewZoomNormal)
114 ON_COMMAND(ID_REFRESH, OnRefresh)
115 ON_COMMAND(ID_MERGE_COMPARE_TEXT, OnFileRecompareAsText)
119 /////////////////////////////////////////////////////////////////////////////
120 // CHexMergeDoc construction/destruction
123 * @brief Constructor.
125 CHexMergeDoc::CHexMergeDoc()
128 m_nBuffers = m_nBuffersTemp;
129 m_filePaths.SetSize(m_nBuffers);
130 std::fill_n(m_pView, m_nBuffers, static_cast<CHexMergeView *>(nullptr));
131 std::fill_n(m_nBufferType, m_nBuffers, BUFFER_NORMAL);
137 * Informs associated dirdoc that mergedoc is closing.
139 CHexMergeDoc::~CHexMergeDoc()
142 m_pDirDoc->MergeDocClosing(this);
146 * @brief Return active merge edit view (or left one if neither active)
148 CHexMergeView * CHexMergeDoc::GetActiveMergeView() const
150 CView * pActiveView = GetParentFrame()->GetActiveView();
151 CHexMergeView * pHexMergeView = dynamic_cast<CHexMergeView *>(pActiveView);
153 pHexMergeView = m_pView[0]; // default to left view (in case some location or detail view active)
154 return pHexMergeView;
158 * @brief Update associated diff item
160 int CHexMergeDoc::UpdateDiffItem(CDirDoc *pDirDoc)
162 // If directory compare has results
163 if (pDirDoc && pDirDoc->HasDiffs())
165 CDiffContext &ctxt = pDirDoc->GetDiffContext();
166 if (UINT_PTR pos = FindItemFromPaths(ctxt, m_filePaths))
168 DIFFITEM &di = ctxt.GetDiffRefAt(pos);
169 ::UpdateDiffItem(m_nBuffers, di, &ctxt);
173 int lengthFirst = m_pView[0]->GetLength();
174 void *bufferFirst = m_pView[0]->GetBuffer(lengthFirst);
175 for (int nBuffer = 1; nBuffer < m_nBuffers; nBuffer++)
177 int length = m_pView[nBuffer]->GetLength();
178 if (lengthFirst != length)
182 void *buffer = m_pView[nBuffer]->GetBuffer(length);
183 bDiff = (memcmp(bufferFirst, buffer, lengthFirst) != 0);
188 GetParentFrame()->SetLastCompareResult(bDiff);
189 return bDiff ? 1 : 0;
193 * @brief Asks and then saves modified files
195 bool CHexMergeDoc::PromptAndSaveIfNeeded(bool bAllowCancel)
197 bool bLModified = false, bMModified = false, bRModified = false;
201 bLModified = m_pView[0]->GetModified();
202 bMModified = m_pView[1]->GetModified();
203 bRModified = m_pView[2]->GetModified();
207 bLModified = m_pView[0]->GetModified();
208 bRModified = m_pView[1]->GetModified();
210 if (!bLModified && !bMModified && !bRModified)
213 const String &pathLeft = m_filePaths.GetLeft();
214 const String &pathMiddle = m_filePaths.GetMiddle();
215 const String &pathRight = m_filePaths.GetRight();
218 bool bLSaveSuccess = false, bMSaveSuccess = false, bRSaveSuccess = false;
221 dlg.DoAskFor(bLModified, bMModified, bRModified);
223 dlg.m_bDisableCancel = true;
224 if (!pathLeft.empty())
225 dlg.m_sLeftFile = pathLeft;
227 dlg.m_sLeftFile = m_strDesc[0];
230 if (!pathMiddle.empty())
231 dlg.m_sMiddleFile = pathMiddle;
233 dlg.m_sMiddleFile = m_strDesc[1];
235 if (!pathRight.empty())
236 dlg.m_sRightFile = pathRight;
238 dlg.m_sRightFile = m_strDesc[1];
240 if (dlg.DoModal() == IDOK)
244 if (dlg.m_leftSave == SaveClosingDlg::SAVECLOSING_SAVE)
246 switch (Try(m_pView[0]->SaveFile(pathLeft.c_str())))
249 bLSaveSuccess = true;
258 m_pView[0]->SetSavePoint();
263 if (dlg.m_middleSave == SaveClosingDlg::SAVECLOSING_SAVE)
265 switch (Try(m_pView[1]->SaveFile(pathMiddle.c_str())))
268 bMSaveSuccess = true;
277 m_pView[1]->SetSavePoint();
282 if (dlg.m_rightSave == SaveClosingDlg::SAVECLOSING_SAVE)
284 switch (Try(m_pView[m_nBuffers - 1]->SaveFile(pathRight.c_str())))
287 bRSaveSuccess = true;
296 m_pView[m_nBuffers - 1]->SetSavePoint();
305 // If file were modified and saving was successfull,
306 // update status on dir view
307 if (bLSaveSuccess || bMSaveSuccess || bRSaveSuccess)
309 UpdateDiffItem(m_pDirDoc);
316 * @brief Save modified documents
318 BOOL CHexMergeDoc::SaveModified()
320 return PromptAndSaveIfNeeded(true);
324 * @brief Saves both files
326 void CHexMergeDoc::OnFileSave()
328 for (int nBuffer = 0; nBuffer < m_nBuffers; nBuffer++)
332 void CHexMergeDoc::DoFileSave(int nBuffer)
334 if (m_pView[nBuffer]->GetModified())
336 if (m_nBufferType[nBuffer] == BUFFER_UNNAMED)
337 DoFileSaveAs(nBuffer);
340 const String &path = m_filePaths.GetPath(nBuffer);
341 if (Try(m_pView[nBuffer]->SaveFile(path.c_str())) == IDCANCEL)
344 UpdateDiffItem(m_pDirDoc);
348 void CHexMergeDoc::DoFileSaveAs(int nBuffer)
350 const String &path = m_filePaths.GetPath(nBuffer);
354 title = _("Save Left File As");
355 else if (nBuffer == m_nBuffers - 1)
356 title = _("Save Right File As");
358 title = _("Save Middle File As");
359 if (SelectFile(AfxGetMainWnd()->GetSafeHwnd(), strPath, false, path.c_str(), title))
361 if (Try(m_pView[nBuffer]->SaveFile(strPath.c_str())) == IDCANCEL)
365 // We are saving scratchpad (unnamed file)
366 m_nBufferType[nBuffer] = BUFFER_UNNAMED_SAVED;
367 m_strDesc[nBuffer].erase();
370 m_filePaths.SetPath(nBuffer, strPath);
371 UpdateDiffItem(m_pDirDoc);
372 UpdateHeaderPath(nBuffer);
377 * @brief Saves left-side file
379 void CHexMergeDoc::OnFileSaveLeft()
385 * @brief Saves middle-side file
387 void CHexMergeDoc::OnFileSaveMiddle()
393 * @brief Saves right-side file
395 void CHexMergeDoc::OnFileSaveRight()
397 DoFileSave(m_nBuffers - 1);
401 * @brief Saves left-side file with name asked
403 void CHexMergeDoc::OnFileSaveAsLeft()
409 * @brief Saves right-side file with name asked
411 void CHexMergeDoc::OnFileSaveAsMiddle()
417 * @brief Saves right-side file with name asked
419 void CHexMergeDoc::OnFileSaveAsRight()
421 DoFileSaveAs(m_nBuffers - 1);
425 * @brief Update diff-number pane text
427 void CHexMergeDoc::OnUpdateStatusNum(CCmdUI* pCmdUI)
430 pCmdUI->SetText(s.c_str());
434 * @brief DirDoc gives us its identity just after it creates us
436 void CHexMergeDoc::SetDirDoc(CDirDoc * pDirDoc)
438 ASSERT(pDirDoc != nullptr && m_pDirDoc == nullptr);
443 * @brief Return pointer to parent frame
445 CHexMergeFrame * CHexMergeDoc::GetParentFrame() const
447 return static_cast<CHexMergeFrame *>(m_pView[0]->GetParentFrame());
451 * @brief DirDoc is closing
453 void CHexMergeDoc::DirDocClosing(CDirDoc * pDirDoc)
455 ASSERT(m_pDirDoc == pDirDoc);
460 * @brief DirDoc commanding us to close
462 bool CHexMergeDoc::CloseNow()
464 // Allow user to cancel closing
465 if (!PromptAndSaveIfNeeded(true))
468 GetParentFrame()->CloseNow();
473 * @brief Load one file
475 HRESULT CHexMergeDoc::LoadOneFile(int index, LPCTSTR filename, bool readOnly, const String& strDesc)
479 if (Try(m_pView[index]->LoadFile(filename), MB_ICONSTOP) != 0)
481 m_pView[index]->SetReadOnly(readOnly);
482 m_filePaths.SetPath(index, filename);
483 ASSERT(m_nBufferType[index] == BUFFER_NORMAL); // should have been initialized to BUFFER_NORMAL in constructor
484 if (!strDesc.empty())
486 m_strDesc[index] = strDesc;
487 m_nBufferType[index] = BUFFER_NORMAL_NAMED;
492 m_nBufferType[index] = BUFFER_UNNAMED;
493 m_strDesc[index] = strDesc;
495 UpdateHeaderPath(index);
496 m_pView[index]->ResizeWindow();
501 * @brief Load files and initialize frame's compare result icon
503 bool CHexMergeDoc::OpenDocs(int nFiles, const FileLocation fileloc[], const bool bRO[], const String strDesc[], int nPane)
505 CHexMergeFrame *pf = GetParentFrame();
506 ASSERT(pf != nullptr);
507 bool bSucceeded = true;
509 for (nBuffer = 0; nBuffer < nFiles; nBuffer++)
511 if (FAILED(LoadOneFile(nBuffer, fileloc[nBuffer].filepath.c_str(), bRO[nBuffer], strDesc ? strDesc[nBuffer] : _T(""))))
517 if (nBuffer == nFiles)
519 // An extra ResizeWindow() on the left view aligns scroll ranges, and
520 // also triggers initial diff coloring by invalidating the client area.
521 m_pView[0]->ResizeWindow();
525 if (GetOptionsMgr()->GetBool(OPT_SCROLL_TO_FIRST))
526 m_pView[0]->SendMessage(WM_COMMAND, ID_FIRSTDIFF);
530 // Use verify macro to trap possible error in debug.
531 VERIFY(pf->DestroyWindow());
536 void CHexMergeDoc::CheckFileChanged(void)
538 for (int pane = 0; pane < m_nBuffers; ++pane)
540 if (m_pView[pane]->IsFileChangedOnDisk(m_filePaths[pane].c_str()))
542 String msg = strutils::format_string1(_("Another application has updated file\n%1\nsince WinMerge scanned it last time.\n\nDo you want to reload the file?"), m_filePaths[pane]);
543 if (AfxMessageBox(msg.c_str(), MB_YESNO | MB_ICONWARNING) == IDYES)
553 * @brief Write path and filename to headerbar
554 * @note SetText() does not repaint unchanged text
556 void CHexMergeDoc::UpdateHeaderPath(int pane)
558 CHexMergeFrame *pf = GetParentFrame();
559 ASSERT(pf != nullptr);
562 if (m_nBufferType[pane] == BUFFER_UNNAMED ||
563 m_nBufferType[pane] == BUFFER_NORMAL_NAMED)
565 sText = m_strDesc[pane];
569 sText = m_filePaths.GetPath(pane);
571 m_pDirDoc->ApplyDisplayRoot(pane, sText);
573 if (m_pView[pane]->GetModified())
574 sText.insert(0, _T("* "));
575 pf->GetHeaderInterface()->SetText(pane, sText);
582 * @brief Customize a heksedit control's settings
584 static void Customize(IHexEditorWindow::Settings *settings)
586 settings->bSaveIni = false;
587 //settings->iAutomaticBPL = FALSE;
588 //settings->iBytesPerLine = 16;
589 //settings->iFontSize = 8;
593 * @brief Customize a heksedit control's colors
595 static void Customize(IHexEditorWindow::Colors *colors)
597 COptionsMgr *pOptionsMgr = GetOptionsMgr();
598 colors->iSelBkColorValue = RGB(224, 224, 224);
599 colors->iDiffBkColorValue = pOptionsMgr->GetInt(OPT_CLR_DIFF);
600 colors->iSelDiffBkColorValue = pOptionsMgr->GetInt(OPT_CLR_SELECTED_DIFF);
601 colors->iDiffTextColorValue = pOptionsMgr->GetInt(OPT_CLR_DIFF_TEXT);
602 if (colors->iDiffTextColorValue == 0xFFFFFFFF)
603 colors->iDiffTextColorValue = 0;
604 colors->iSelDiffTextColorValue = pOptionsMgr->GetInt(OPT_CLR_SELECTED_DIFF_TEXT);
605 if (colors->iSelDiffTextColorValue == 0xFFFFFFFF)
606 colors->iSelDiffTextColorValue = 0;
607 SyntaxColors *pSyntaxColors = theApp.GetMainSyntaxColors();
608 colors->iTextColorValue = pSyntaxColors->GetColor(COLORINDEX_NORMALTEXT);
609 colors->iBkColorValue = pSyntaxColors->GetColor(COLORINDEX_BKGND);
610 colors->iSelTextColorValue = pSyntaxColors->GetColor(COLORINDEX_SELTEXT);
611 colors->iSelBkColorValue = pSyntaxColors->GetColor(COLORINDEX_SELBKGND);
615 * @brief Customize a heksedit control's settings and colors
617 static void Customize(IHexEditorWindow *pif)
619 Customize(pif->get_settings());
620 Customize(pif->get_colors());
621 //LANGID wLangID = (LANGID)GetThreadLocale();
622 //pif->load_lang(wLangID);
625 void CHexMergeDoc::RefreshOptions()
627 for (int nBuffer = 0; nBuffer < m_nBuffers; nBuffer++)
629 IHexEditorWindow *pif = m_pView[nBuffer]->GetInterface();
630 pif->read_ini_data();
632 pif->resize_window();
637 * @brief Update document filenames to title
639 void CHexMergeDoc::SetTitle(LPCTSTR lpszTitle)
648 for (int nBuffer = 0; nBuffer < m_filePaths.GetSize(); nBuffer++)
649 sFileName[nBuffer] = !m_strDesc[nBuffer].empty() ? m_strDesc[nBuffer] : paths::FindFileName(m_filePaths[nBuffer]);
650 if (std::count(&sFileName[0], &sFileName[0] + m_nBuffers, sFileName[0]) == m_nBuffers)
651 sTitle = sFileName[0] + strutils::format(_T(" x %d"), m_nBuffers);
653 sTitle = strutils::join(&sFileName[0], &sFileName[0] + m_nBuffers, _T(" - "));
655 CDocument::SetTitle(sTitle.c_str());
659 * @brief We have two child views (left & right), so we keep pointers directly
660 * at them (the MFC view list doesn't have them both)
662 void CHexMergeDoc::SetMergeViews(CHexMergeView *pView[])
664 for (int nBuffer = 0; nBuffer < m_nBuffers; nBuffer++)
666 ASSERT(pView[nBuffer] != nullptr && m_pView[nBuffer] == nullptr);
667 m_pView[nBuffer] = pView[nBuffer];
668 m_pView[nBuffer]->m_nThisPane = nBuffer;
673 * @brief Called when "Save left" item is updated
675 void CHexMergeDoc::OnUpdateFileSaveLeft(CCmdUI* pCmdUI)
677 pCmdUI->Enable(m_pView[0]->GetModified());
681 * @brief Called when "Save middle" item is updated
683 void CHexMergeDoc::OnUpdateFileSaveMiddle(CCmdUI* pCmdUI)
685 pCmdUI->Enable(m_nBuffers == 3 && m_pView[1]->GetModified());
689 * @brief Called when "Save right" item is updated
691 void CHexMergeDoc::OnUpdateFileSaveRight(CCmdUI* pCmdUI)
693 pCmdUI->Enable(m_pView[m_nBuffers - 1]->GetModified());
697 * @brief Called when "Save" item is updated
699 void CHexMergeDoc::OnUpdateFileSave(CCmdUI* pCmdUI)
701 bool bModified = false;
702 for (int nBuffer = 0; nBuffer < m_nBuffers; nBuffer++)
703 bModified |= m_pView[nBuffer]->GetModified();
704 pCmdUI->Enable(bModified);
708 * @brief Reloads the opened files
710 void CHexMergeDoc::OnFileReload()
712 if (!PromptAndSaveIfNeeded(true))
715 FileLocation fileloc[3];
717 for (int pane = 0; pane < m_nBuffers; pane++)
719 fileloc[pane].setPath(m_filePaths[pane]);
720 bRO[pane] = m_pView[pane]->GetReadOnly();
722 int nActivePane = GetActiveMergeView()->m_nThisPane;
723 OpenDocs(m_nBuffers, fileloc, bRO, m_strDesc, nActivePane);
727 * @brief Copy selected bytes from left to right
729 void CHexMergeDoc::OnL2r()
731 int dstPane = (GetActiveMergeView()->m_nThisPane < m_nBuffers - 1) ? GetActiveMergeView()->m_nThisPane + 1 : m_nBuffers - 1;
732 int srcPane = dstPane - 1;
733 CHexMergeView::CopySel(m_pView[srcPane], m_pView[dstPane]);
737 * @brief Copy selected bytes from right to left
739 void CHexMergeDoc::OnR2l()
741 int dstPane = (GetActiveMergeView()->m_nThisPane > 0) ? GetActiveMergeView()->m_nThisPane - 1 : 0;
742 int srcPane = dstPane + 1;
743 CHexMergeView::CopySel(m_pView[srcPane], m_pView[dstPane]);
747 * @brief Copy selected bytes from left to active pane
749 void CHexMergeDoc::OnCopyFromLeft()
751 int dstPane = GetActiveMergeView()->m_nThisPane;
752 int srcPane = (dstPane - 1 < 0) ? 0 : dstPane - 1;
753 CHexMergeView::CopySel(m_pView[srcPane], m_pView[dstPane]);
757 * @brief Copy selected bytes from right to active pane
759 void CHexMergeDoc::OnCopyFromRight()
761 int dstPane = GetActiveMergeView()->m_nThisPane;
762 int srcPane = (dstPane + 1 > m_nBuffers - 1) ? m_nBuffers - 1 : dstPane + 1;
763 CHexMergeView::CopySel(m_pView[srcPane], m_pView[dstPane]);
767 * @brief Copy all bytes from left to right
769 void CHexMergeDoc::OnAllRight()
771 int dstPane = (GetActiveMergeView()->m_nThisPane < m_nBuffers - 1) ? GetActiveMergeView()->m_nThisPane + 1 : m_nBuffers - 1;
772 int srcPane = dstPane - 1;
773 CHexMergeView::CopyAll(m_pView[srcPane], m_pView[dstPane]);
777 * @brief Copy all bytes from right to left
779 void CHexMergeDoc::OnAllLeft()
781 int dstPane = (GetActiveMergeView()->m_nThisPane > 0) ? GetActiveMergeView()->m_nThisPane - 1 : 0;
782 int srcPane = dstPane + 1;
783 CHexMergeView::CopyAll(m_pView[srcPane], m_pView[dstPane]);
787 * @brief Called when user selects View/Zoom In from menu.
789 void CHexMergeDoc::OnViewZoomIn()
791 for (int pane = 0; pane < m_nBuffers; pane++)
792 m_pView[pane]->ZoomText(1);
796 * @brief Called when user selects View/Zoom Out from menu.
798 void CHexMergeDoc::OnViewZoomOut()
800 for (int pane = 0; pane < m_nBuffers; pane++)
801 m_pView[pane]->ZoomText(-1);
805 * @brief Called when user selects View/Zoom Normal from menu.
807 void CHexMergeDoc::OnViewZoomNormal()
809 for (int pane = 0; pane < m_nBuffers; pane++)
810 m_pView[pane]->ZoomText(0);
813 void CHexMergeDoc::OnRefresh()
815 if (UpdateDiffItem(m_pDirDoc) == 0)
816 LangMessageBox(IDS_FILESSAME, MB_ICONINFORMATION | MB_DONT_DISPLAY_AGAIN);
819 void CHexMergeDoc::OnFileRecompareAsText()
821 FileLocation fileloc[3];
824 int nBuffers = m_nBuffers;
825 CDirDoc *pDirDoc = m_pDirDoc->GetMainView() ? m_pDirDoc :
826 static_cast<CDirDoc*>(theApp.m_pDirTemplate->CreateNewDocument());
827 for (int nBuffer = 0; nBuffer < nBuffers; ++nBuffer)
829 fileloc[nBuffer].setPath(m_filePaths[nBuffer]);
830 dwFlags[nBuffer] = m_pView[nBuffer]->GetReadOnly() ? FFILEOPEN_READONLY : 0;
831 strDesc[nBuffer] = m_strDesc[nBuffer];
834 GetMainFrame()->ShowMergeDoc(pDirDoc, nBuffers, fileloc, dwFlags, strDesc);