OSDN Git Service

* Use standard order of header files
authorsdottaka <none@none>
Sat, 18 Jan 2014 12:33:26 +0000 (21:33 +0900)
committersdottaka <none@none>
Sat, 18 Jan 2014 12:33:26 +0000 (21:33 +0900)
* Reduce inter-module dependencies. Especially from MainFrm.h
* Move the following variables and functions in CMainFrame class to CMergeApp class:

SyncFileToVCS()
CreateBackup()
HandleReadonlySave()
ShowVSSError()
ShowHelp()
UpdateCodepageModule()
CheckinToClearCase()
OpenFileToExternalEditor()
InitializeSourceControlMembers()
SaveToVersionControl()
GetMainSyntaxColors()
OpenFileOrUrl()
m_strSaveAsPath
m_bEscShutdown
m_vssHelper
m_bClearCaseTool
m_bExitIfNoDiff
m_pLineFilters
m_strVssUser
m_strVssPassword
m_strVssDatabase
m_strCCComment
m_bCheckinVCS
m_CheckOutMulti
m_bVCProjSync
m_bVssSuppressPathCheck
m_strDescriptions
m_pSyntaxColors

* Remove
CMainFrame::CenterToMainFrame()
CMainFrame::SetMainIcon()
CMainFrame::GetMainSyntaxColors()

--HG--
branch : stable

113 files changed:
Src/7zCommon.cpp
Src/7zCommon.h
Src/AboutDlg.cpp
Src/CCPrompt.cpp
Src/ChildFrm.cpp
Src/Common/Bitmap.cpp
Src/Common/CMoveConstraint.cpp
Src/Common/DragDrop.cpp
Src/Common/ExConverter.cpp
Src/Common/LanguageSelect.cpp
Src/Common/Picture.cpp
Src/Common/PreferencesDlg.cpp
Src/Common/RegKey.cpp
Src/Common/RegKey.h
Src/Common/RegOptionsMgr.cpp
Src/Common/RegOptionsMgr.h
Src/Common/ShellFileOperations.cpp
Src/Common/ShellFileOperations.h
Src/Common/SuperComboBox.cpp
Src/Common/unicoder.cpp
Src/ConfigLog.cpp
Src/ConfirmFolderCopyDlg.cpp
Src/DiffTextBuffer.cpp
Src/DiffViewBar.cpp
Src/DiffViewBar.h
Src/DiffWrapper.h
Src/DirActions.cpp
Src/DirCmpReportDlg.cpp
Src/DirColsDlg.cpp
Src/DirCompProgressBar.cpp
Src/DirDoc.cpp
Src/DirFrame.cpp
Src/DirItem.h
Src/DirView.cpp
Src/DirView.h
Src/DirViewColHandler.cpp
Src/DirViewColItems.cpp
Src/EditorFilepathBar.cpp
Src/EncodingErrorBar.cpp
Src/FileActionScript.cpp
Src/FileFilter.cpp
Src/FileFilter.h
Src/FileFiltersDlg.cpp
Src/FileFiltersDlg.h
Src/FileOrFolderSelect.cpp
Src/FileOrFolderSelect.h
Src/FilepathEdit.cpp
Src/FilterList.h
Src/GhostTextBuffer.cpp
Src/HexMergeDoc.cpp
Src/HexMergeDoc.h
Src/HexMergeFrm.cpp
Src/HexMergeView.cpp
Src/LineFiltersDlg.cpp
Src/LoadSaveCodepageDlg.cpp
Src/LocationBar.cpp
Src/LocationView.cpp
Src/LocationView.h
Src/MainFrm.cpp
Src/MainFrm.h
Src/Merge.cpp
Src/Merge.h
Src/Merge.vcxproj.filters
Src/MergeApp.cpp
Src/MergeApp.h
Src/MergeDoc.cpp
Src/MergeDoc.h
Src/MergeDocDiffSync.cpp
Src/MergeDocEncoding.cpp
Src/MergeDocLineDiffs.cpp
Src/MergeEditView.cpp
Src/MergeEditView.h
Src/OpenDoc.cpp
Src/OpenFrm.cpp
Src/OpenView.cpp
Src/OpenView.h
Src/OptionsInit.cpp
Src/PatchDlg.cpp
Src/PatchTool.cpp
Src/PatchTool.h
Src/Plugins.cpp
Src/PluginsListDlg.cpp
Src/ProjectFilePathsDlg.cpp
Src/PropArchive.cpp
Src/PropBackups.cpp
Src/PropCodepage.cpp
Src/PropColors.cpp
Src/PropCompare.cpp
Src/PropCompareFolder.cpp
Src/PropEditor.cpp
Src/PropGeneral.cpp
Src/PropRegistry.cpp
Src/PropShell.cpp
Src/PropSyntaxColors.cpp
Src/PropTextColors.cpp
Src/PropVss.cpp
Src/SaveClosingDlg.cpp
Src/SelectUnpackerDlg.cpp
Src/SelectUnpackerDlg.h
Src/SharedFilterDlg.cpp
Src/SourceControl.cpp
Src/Splash.cpp
Src/TestFilterDlg.cpp
Src/VSSHelper.cpp
Src/VSSHelper.h
Src/VssPrompt.cpp
Src/WMGotoDlg.cpp
Src/codepage.cpp
Src/dllpstub.cpp
Src/markdown.cpp
Src/paths.cpp
Src/stringdiffs.cpp
Translations/WinMerge/English.pot

index 1de4bdc..692929c 100644 (file)
@@ -98,17 +98,17 @@ DATE:               BY:                                     DESCRIPTION:
 // $Id: 7zCommon.cpp 7169 2010-05-16 14:44:19Z jtuc $
 
 #include "stdafx.h"
+#include "7zCommon.h"
+#include <afxinet.h>
+#include <shlwapi.h>
+#include <paths.h>
 #include "OptionsDef.h"
+#include "OptionsMgr.h"
 #include "Merge.h"             // DirDocFilter theApp GetOptionsMgr()
 #include "resource.h"
 #include "DirDoc.h"
-#include "MainFrm.h"
-#include "7zCommon.h"
 //#include "ExternalArchiveFormat.h"
 #include "version.h"
-#include <afxinet.h>
-#include <shlwapi.h>
-#include <paths.h>
 #include "Environment.h"
 
 #ifdef _DEBUG
index 0c64fd5..3e6ddc8 100644 (file)
@@ -5,7 +5,6 @@
 #include "dllpstub.h"
 #include "../ArchiveSupport/Merge7z/Merge7z.h"
 
-#include "DiffContext.h"
 #include "DirView.h"
 #include <list>
 
index 0a94852..0ccb01c 100644 (file)
@@ -24,9 +24,9 @@
 // $Id: AboutDlg.cpp 6380 2009-01-25 22:13:36Z kimmov $
 
 #include "stdafx.h"
+#include "AboutDlg.h"
 #include "Constants.h"
 #include "Merge.h"
-#include "AboutDlg.h"
 #include "version.h"
 #include "paths.h"
 #include "Environment.h"
index f6a908e..dbc1261 100644 (file)
@@ -23,8 +23,8 @@
 // $Id$
 
 #include "stdafx.h"
-#include "merge.h"
 #include "CCPrompt.h"
+#include "Merge.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
index 4071ad6..f1a6681 100644 (file)
 // $Id: ChildFrm.cpp 7075 2009-12-30 22:57:20Z kimmov $
 
 #include "stdafx.h"
-#include "Merge.h"
-
 #include "ChildFrm.h"
+#include "Merge.h"
 #include "MainFrm.h"
+#include "MergeDoc.h"
 #include "MergeEditView.h"
 #include "LocationView.h"
 #include "DiffViewBar.h"
 #include "charsets.h"
 #include "OptionsDef.h"
+#include "OptionsMgr.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
index 0ef8c5a..589996b 100644 (file)
@@ -8,9 +8,9 @@
 // $Id$
 
 #include "StdAfx.h"
+#include "Bitmap.h"
 #include <math.h>
 #include <boost/scoped_array.hpp>
-#include "Bitmap.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
index c751160..eea532d 100644 (file)
@@ -16,12 +16,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
 
 #include "StdAfx.h"
-
+#include "CMoveConstraint.h"
 #include <afxtempl.h>       // MFC template collection classes
 #include <afxext.h> // needed for CFormView
 
-#include "CMoveConstraint.h"
-
 #ifndef NOSUBCLASS
 #include "CSubclass.h"
 #endif // NOSUBCLASS
index 2887b10..4fa7604 100644 (file)
@@ -1,6 +1,6 @@
 #include "DragDrop.h"
-#include "paths.h"
 #include <boost/scoped_array.hpp>
+#include "paths.h"
 
 //
 //     OnDropFiles code from CDropEdit
index 73ec24d..89ad51d 100644 (file)
@@ -6,10 +6,10 @@
 // ID line follows -- this is updated by SVN
 // $Id: $
 
+#include "ExConverter.h"
 #include <windows.h>
 #include <mlang.h>
 #include <boost/scoped_array.hpp>
-#include "ExConverter.h"
 #include "unicoder.h"
 #include "codepage.h"
 
index d9c5d64..e04ef70 100644 (file)
@@ -7,11 +7,14 @@
 // $Id: LanguageSelect.cpp 6499 2009-02-25 13:31:52Z kimmov $
 
 #include "StdAfx.h"
+#include "LanguageSelect.h"
+#include <locale.h>
+#include <sstream>
 #include "OptionsDef.h"
+#include "OptionsMgr.h"
 #include "Merge.h"
 #include "version.h"
 #include "resource.h"
-#include "LanguageSelect.h"
 #include "BCMenu.h"
 #include "MainFrm.h"
 #include "OpenFrm.h"
@@ -19,8 +22,6 @@
 #include "DirFrame.h"
 #include "paths.h"
 #include "Environment.h"
-#include <locale.h>
-#include <sstream>
 
 // Escaped character constants in range 0x80-0xFF are interpreted in current codepage
 // Using C locale gets us direct mapping to Unicode codepoints
@@ -1195,11 +1196,10 @@ void CLanguageSelect::OnOK()
                if (SetLanguage(lang))
                        GetOptionsMgr()->SaveOption(OPT_SELECTED_LANGUAGE, (int)lang);
 
-               CMainFrame *pMainFrame = static_cast<CMainFrame *>(AfxGetApp()->m_pMainWnd);
-               pMainFrame->UpdateCodepageModule();
+               theApp.UpdateCodepageModule();
 
                // Update status bar inicator texts
-               SetIndicators(pMainFrame->m_wndStatusBar, 0, 0);
+               SetIndicators(GetMainFrame()->m_wndStatusBar, 0, 0);
 
                // Update the current menu
                if (m_bReloadMenu)
@@ -1217,8 +1217,6 @@ BOOL CLanguageSelect::OnInitDialog()
 {
        TranslateDialog(m_hWnd);
        CDialog::OnInitDialog();
-       
-       CMainFrame::SetMainIcon(this);
 
        // setup handler for resizing this dialog       
        m_constraint.InitializeCurrentSize(this);
@@ -1229,7 +1227,7 @@ BOOL CLanguageSelect::OnInitDialog()
        m_constraint.SubclassWnd(); // install subclassing
        m_constraint.LoadPosition(_T("ResizeableDialogs"), _T("LanguageSelectDlg"), false); // persist size via registry
 
-       GetMainFrame()->CenterToMainFrame(this);
+       AfxGetMainWnd()->CenterWindow(this);
 
        LoadAndDisplayLanguages();
 
index 81bedc7..0c64c51 100644 (file)
@@ -6,8 +6,8 @@
 // Set tabsize = 3 in your editor.
 //
 #include "StdAfx.h"
-#include <afxpriv2.h>
 #include "Picture.h"
+#include <afxpriv2.h>
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
index 7f39fa3..3bb065e 100644 (file)
 // $Id$
 
 #include "StdAfx.h"
+#include "PreferencesDlg.h"
 #include "resource.h"
 #include "UnicodeString.h"
 #include "OptionsDef.h"
 #include "OptionsMgr.h"
 #include "SyntaxColors.h"
-#include "PreferencesDlg.h"
-#include "MainFrm.h"
 #include "Merge.h"
 #include "paths.h" //paths_SplitFilename()
 #include "FileOrFolderSelect.h"
@@ -141,7 +140,7 @@ void CPreferencesDlg::OnDestroy()
 
 void CPreferencesDlg::OnHelpButton() 
 {
-       GetMainFrame()->ShowHelp(OptionsHelpLocation);
+       theApp.ShowHelp(OptionsHelpLocation);
 }
 
 void CPreferencesDlg::AddPage(CPropertyPage* pPage, UINT nResourceID)
index 2615de3..fae8529 100644 (file)
@@ -7,8 +7,8 @@
 // $Id$
 
 #define NOMINMAX
-#include <windows.h>
 #include "RegKey.h"
+#include <windows.h>
 #include <cassert>
 #include "UnicodeString.h"
 #include "coretypes.h"
index b8e908a..aa5c0f7 100644 (file)
@@ -6,6 +6,7 @@
 // ID line follows -- this is updated by SVN
 // $Id$
 
+#include <Windows.h>
 #include "UnicodeString.h"
 
 /**
index a6d184c..3674a26 100644 (file)
@@ -7,8 +7,8 @@
 // ID line follows -- this is updated by SVN
 // $Id$
 
-#include <windows.h>
 #include "RegOptionsMgr.h"
+#include <windows.h>
 #include <tchar.h>
 #include <vector>
 #include "varprop.h"
index 50e55f3..e27d0ac 100644 (file)
@@ -11,6 +11,7 @@
 #ifndef _REG_OPTIONSMGR_H_
 #define _REG_OPTIONSMGR_H_
 
+#include <Windows.h>
 #include "OptionsMgr.h"
 
 class COptionsMgr;
index c2c27c3..0b7f730 100644 (file)
 // ID line follows -- this is updated by SVN
 // $Id$
 
+#include "ShellFileOperations.h"
 #include <windows.h>
 #include <tchar.h>
 #include <shlwapi.h>
 #include <vector>
 #include <shellapi.h>
 #include "UnicodeString.h"
-#include "ShellFileOperations.h"
 
 using std::vector;
 
index 37871fe..ee48cab 100644 (file)
@@ -26,6 +26,8 @@
 #define _SHELL_FILE_OPERATIONS_H_
 
 #include <vector>
+#include <Windows.h>
+#include "UnicodeString.h"
 
 /**
  * @brief A wrapper class for SHFileOperation().
index db6f5ba..bb7d2de 100644 (file)
@@ -3,10 +3,9 @@
 
 #include "StdAfx.h"
 #include "SuperComboBox.h"
-#include "DragDrop.h"
-
 #include <shlwapi.h>
 #include <vector>
+#include "DragDrop.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
index eb56494..58df74c 100644 (file)
@@ -16,8 +16,8 @@ The above copyright notice and this permission notice shall be included in all c
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include <windows.h>
 #include "unicoder.h"
+#include <windows.h>
 #include <tchar.h>
 #include <cassert>
 #include <boost/scoped_array.hpp>
index 3262ec3..3105f60 100644 (file)
@@ -24,9 +24,9 @@
 
 #include "ConfigLog.h"
 #include <cassert>
-#include <boost/scoped_array.hpp>
 #include <windows.h>
 #include <mbctype.h>
+#include <boost/scoped_array.hpp>
 #include "Constants.h"
 #include "version.h"
 #include "UniFile.h"
index f062461..171be9b 100644 (file)
@@ -23,8 +23,8 @@
 // $Id$
 
 #include "stdafx.h"
-#include "Merge.h"
 #include "ConfirmFolderCopyDlg.h"
+#include "Merge.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
index a0e081d..f716fb5 100644 (file)
@@ -17,6 +17,7 @@
 #include "paths.h"
 #include "Merge.h"
 #include "OptionsDef.h"
+#include "OptionsMgr.h"
 #include "Environment.h"
 #include "MergeLineFlags.h"
 #include "MergeDoc.h"
index b48c78b..f878e43 100644 (file)
 //////////////////////////////////////////////////////////////////////
 
 #include "stdafx.h"
-#include "Merge.h"
-
-#include "ChildFrm.h"
 #include "DiffViewBar.h"
+#include "Merge.h"
+#include "SplitterWndEx.h"
 
 #ifdef _DEBUG
 #undef THIS_FILE
index 8d85810..87ec305 100644 (file)
@@ -15,7 +15,8 @@
 
 #include "sizecbar.h"
 #include "scbarcf.h"
-#include "SplitterWndEx.h"
+
+class CSplitterWndEx;
 
 // You must #define this for viewbar to compile properly
 #define TViewBarBase CSizingControlBarCF
index fbba789..e1309c3 100644 (file)
@@ -27,6 +27,7 @@
 #ifndef _DIFFWRAPPER_H
 #define _DIFFWRAPPER_H
 
+#include <boost/scoped_ptr.hpp>
 #include "diff.h"
 #include "FileLocation.h"
 #include "PathContext.h"
@@ -34,7 +35,6 @@
 #include "CompareOptions.h"
 #include "DiffList.h"
 #include "UnicodeString.h"
-#include <boost/scoped_ptr.hpp>
 
 class CDiffContext;
 class PrediffingInfo;
index c6e72b8..2caccb1 100644 (file)
@@ -20,7 +20,6 @@
 #include "UnicodeString.h"
 #include "DirView.h"
 #include "DirDoc.h"
-#include "MainFrm.h"
 #include "coretools.h"
 #include "paths.h"
 #include "7zCommon.h"
@@ -33,6 +32,7 @@
 #include "IntToIntMap.h"
 #include "FileOrFolderSelect.h"
 #include "ConfirmFolderCopyDlg.h"
+#include "OptionsMgr.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -980,15 +980,15 @@ bool CDirView::ConfirmActionList(const FileActionScript & actionList, int selCou
 /**
  * @brief Perform an array of actions
  * @note There can be only COPY or DELETE actions, not both!
- * @sa CMainFrame::SaveToVersionControl()
- * @sa CMainFrame::SyncFilesToVCS()
+ * @sa MergeApp::SaveToVersionControl()
+ * @sa MergeApp::SyncFilesToVCS()
  */
 void CDirView::PerformActionList(FileActionScript & actionScript)
 {
        // Reset suppressing VSS dialog for multiple files.
        // Set in CMainFrame::SaveToVersionControl().
-       GetMainFrame()->m_CheckOutMulti = false;
-       GetMainFrame()->m_bVssSuppressPathCheck = false;
+       theApp.m_CheckOutMulti = false;
+       theApp.m_bVssSuppressPathCheck = false;
 
        // Check option and enable putting deleted items to Recycle Bin
        if (GetOptionsMgr()->GetBool(OPT_USE_RECYCLE_BIN))
@@ -1028,8 +1028,8 @@ void CDirView::UpdateAfterFileScript(FileActionScript & actionList)
                // Synchronized items may need VCS operations
                if (act.UIResult == FileActionItem::UI_SYNC)
                {
-                       if (GetMainFrame()->m_bCheckinVCS)
-                               GetMainFrame()->CheckinToClearCase(act.dest);
+                       if (theApp.m_bCheckinVCS)
+                               theApp.CheckinToClearCase(act.dest);
                }
 
                // Update UI
@@ -1466,7 +1466,7 @@ void CDirView::DoOpenWithEditor(SIDE_TYPE stype)
        String file = GetSelectedFileName(stype);
        if (file.empty()) return;
 
-       GetMainFrame()->OpenFileToExternalEditor(file);
+       theApp.OpenFileToExternalEditor(file);
 }
 
 /**
index 771b469..8a03828 100644 (file)
@@ -9,13 +9,12 @@
 //
 
 #include "stdafx.h"
-#include "Coretools.h"
 #include "DirCmpReportDlg.h"
+#include "Coretools.h"
 #include "DirReportTypes.h"
 #include "paths.h"
 #include "FileOrFolderSelect.h"
 #include "Merge.h"
-#include "DirCmpReportDlg.h"
 
 IMPLEMENT_DYNAMIC(DirCmpReportDlg, CDialog)
 
index 4dd6f34..d9a2a01 100644 (file)
@@ -10,9 +10,9 @@
 
 
 #include "stdafx.h"
-#include "merge.h"
 #include "DirColsDlg.h"
 #include <algorithm>
+#include "Merge.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
index e04b744..5820ffe 100644 (file)
@@ -9,7 +9,6 @@
 #include "stdafx.h"
 #include "DirCompProgressBar.h"
 #include "Merge.h"
-#include "DirDoc.h"
 #include "CompareStats.h"
 
 #ifdef _DEBUG
index 6da416a..c7b839d 100644 (file)
 //
 
 #include "StdAfx.h"
+#include "DirDoc.h"
 #include <shlwapi.h>           // PathFindFileName()
 #include <Poco/StringTokenizer.h>
 #include "Merge.h"
+#include "MergeDoc.h"
 #include "HexMergeDoc.h"
 #include "UnicodeString.h"
 #include "CompareStats.h"
 #include "FilterList.h"
 #include "DirView.h"
-#include "DirDoc.h"
 #include "DirFrame.h"
-#include "MainFrm.h"
 #include "coretools.h"
 #include "paths.h"
 #include "WaitStatusCursor.h"
 #include "7zCommon.h"
 #include "OptionsDef.h"
+#include "OptionsMgr.h"
 #include "OptionsDiffOptions.h"
 #include "FileActionScript.h"
 #include "LineFiltersList.h"
+#include "FileFilterHelper.h"
 #include "unicoder.h"
 
 #ifdef _DEBUG
@@ -280,7 +282,7 @@ void CDirDoc::LoadLineFilterList()
        ASSERT(m_pCtxt);
        
        BOOL bFilters = GetOptionsMgr()->GetBool(OPT_LINEFILTER_ENABLED);
-       String filters = GetMainFrame()->m_pLineFilters->GetAsString();
+       String filters = theApp.m_pLineFilters->GetAsString();
        if (!bFilters || filters.empty())
        {
                m_pCtxt->m_pFilterList.reset();
@@ -365,11 +367,11 @@ void CDirDoc::Rescan()
        pf->GetHeaderInterface()->Resize();
 
        // Make sure filters are up-to-date
-       theApp.m_globalFileFilter.ReloadUpdatedFilters();
-       m_pCtxt->m_piFilterGlobal = &theApp.m_globalFileFilter;
+       theApp.m_pGlobalFileFilter->ReloadUpdatedFilters();
+       m_pCtxt->m_piFilterGlobal = theApp.m_pGlobalFileFilter.get();
 
        // Show active filter name in statusbar
-       pf->SetFilterStatusDisplay(theApp.m_globalFileFilter.GetFilterNameOrMask().c_str());
+       pf->SetFilterStatusDisplay(theApp.m_pGlobalFileFilter->GetFilterNameOrMask().c_str());
 
        // Folder names to compare are in the compare context
        m_diffThread.SetContext(m_pCtxt.get());
@@ -416,7 +418,7 @@ bool CDirDoc::IsShowable(const DIFFITEM & di)
                                return FALSE;
 
                        // result filters
-                       if (di.diffcode.isResultError() && !GetMainFrame()->m_bShowErrors)
+                       if (di.diffcode.isResultError())
                                return FALSE;
                }
                else // recursive mode (including tree-mode)
@@ -435,7 +437,7 @@ bool CDirDoc::IsShowable(const DIFFITEM & di)
                        if (GetOptionsMgr()->GetBool(OPT_TREE_MODE))
                        {
                                // result filters
-                               if (di.diffcode.isResultError() && !GetMainFrame()->m_bShowErrors)
+                               if (di.diffcode.isResultError())
                                        return FALSE;
 
                                // result filters
@@ -461,7 +463,7 @@ bool CDirDoc::IsShowable(const DIFFITEM & di)
                // result filters
                if (di.diffcode.isResultSame() && !GetOptionsMgr()->GetBool(OPT_SHOW_IDENTICAL))
                        return FALSE;
-               if (di.diffcode.isResultError() && !GetMainFrame()->m_bShowErrors)
+               if (di.diffcode.isResultError())
                        return FALSE;
                if (di.diffcode.isResultDiff() && !GetOptionsMgr()->GetBool(OPT_SHOW_DIFFERENT))
                        return FALSE;
index 383e2fc..d9ba458 100644 (file)
 // $Id: DirFrame.cpp 4739 2007-11-12 20:41:16Z jtuc $
 
 #include "stdafx.h"
-#include "Merge.h"
 #include "DirFrame.h"
-#include "FilepathEdit.h"
-#include "DirDoc.h"
+#include "Merge.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
index cb2c93d..a850193 100644 (file)
 #ifndef _DIR_ITEM_H_INCLUDED
 #define _DIR_ITEM_H_INCLUDED
 
-#include "UnicodeString.h"
-#include "FileVersion.h"
 #define POCO_NO_UNWINDOWS 1
 #include <Poco/Types.h>
 #include <Poco/File.h>
 #include <Poco/Timestamp.h>
 #include <boost/flyweight.hpp>
+#include "UnicodeString.h"
+#include "FileVersion.h"
 
 /**
  * @brief Class for fileflags.
index 0cbc1cb..930f3fd 100644 (file)
 // $Id: DirView.cpp 7063 2009-12-27 15:28:16Z kimmov $
 
 #include "StdAfx.h"
+#include "DirView.h"
 #include "Constants.h"
 #include "Merge.h"
 #include "ClipBoard.h"
-#include "DirView.h"
 #include "DirFrame.h"  // StatePane
 #include "DirDoc.h"
+#include "MergeDoc.h"
 #include "HexMergeFrm.h"
 #include "HexMergeDoc.h"
 #include "MainFrm.h"
@@ -45,6 +46,7 @@
 #include "paths.h"
 #include "7zCommon.h"
 #include "OptionsDef.h"
+#include "OptionsMgr.h"
 #include "BCMenu.h"
 #include "DirCmpReport.h"
 #include "DirCompProgressBar.h"
@@ -1806,38 +1808,38 @@ void CDirView::OpenSelection(SELECTIONTYPE selectionType /*= SELECTIONTYPE_NORMA
                FileLocation fileloc[3];
                if (pDoc->m_nDirs < 3)
                {
-                       GetMainFrame()->m_strDescriptions[0].erase();
-                       GetMainFrame()->m_strDescriptions[1].erase();
+                       theApp.m_strDescriptions[0].erase();
+                       theApp.m_strDescriptions[1].erase();
                        if (di1 == di2 && !di1->diffcode.isExists(0))
                        {
                                paths[0] = _T("");
-                               GetMainFrame()->m_strDescriptions[0] = theApp.LoadString(IDS_EMPTY_LEFT_FILE);
+                               theApp.m_strDescriptions[0] = theApp.LoadString(IDS_EMPTY_LEFT_FILE);
                        }
                        if (di1 == di2 && !di1->diffcode.isExists(1))
                        {
                                paths[1] = _T("");
-                               GetMainFrame()->m_strDescriptions[1] = theApp.LoadString(IDS_EMPTY_RIGHT_FILE);
+                               theApp.m_strDescriptions[1] = theApp.LoadString(IDS_EMPTY_RIGHT_FILE);
                        }
                }
                else
                {
-                       GetMainFrame()->m_strDescriptions[0].erase();
-                       GetMainFrame()->m_strDescriptions[1].erase();
-                       GetMainFrame()->m_strDescriptions[2].erase();
+                       theApp.m_strDescriptions[0].erase();
+                       theApp.m_strDescriptions[1].erase();
+                       theApp.m_strDescriptions[2].erase();
                        if (di1 == di2 && di1 == di3 && !di1->diffcode.isExists(0))
                        {
                                paths[0] = _T("");
-                               GetMainFrame()->m_strDescriptions[0] = theApp.LoadString(IDS_EMPTY_LEFT_FILE);
+                               theApp.m_strDescriptions[0] = theApp.LoadString(IDS_EMPTY_LEFT_FILE);
                        }
                        if (di1 == di2 && di1 == di3 && !di1->diffcode.isExists(1))
                        {
                                paths[1] = _T("");
-                               GetMainFrame()->m_strDescriptions[1] = theApp.LoadString(IDS_EMPTY_MIDDLE_FILE);
+                               theApp.m_strDescriptions[1] = theApp.LoadString(IDS_EMPTY_MIDDLE_FILE);
                        }
                        if (di1 == di2 && di1 == di3 && !di1->diffcode.isExists(2))
                        {
                                paths[2] = _T("");
-                               GetMainFrame()->m_strDescriptions[2] = theApp.LoadString(IDS_EMPTY_RIGHT_FILE);
+                               theApp.m_strDescriptions[2] = theApp.LoadString(IDS_EMPTY_RIGHT_FILE);
                        }
                }
 
@@ -3301,7 +3303,7 @@ struct FileCmpReport: public IFileCmpReport
                
                m_pDirView->OpenSelection();
                CFrameWnd * pFrame = GetMainFrame()->GetActiveFrame();
-               if (GetMainFrame()->GetFrameType(pFrame) == FRAME_FILE)
+               if (GetMainFrame()->GetFrameType(pFrame) == CMainFrame::FRAME_FILE)
                {
                        CMergeDoc * pMergeDoc = (CMergeDoc *) pFrame->GetActiveDocument();
                        pMergeDoc->GenerateReport(paths_ConcatPath(sDestDir, sLinkPath).c_str());
@@ -4195,7 +4197,7 @@ void CDirView::OnUpdateFileEncoding(CCmdUI* pCmdUI)
 /** @brief Open help from mainframe when user presses F1*/
 void CDirView::OnHelp()
 {
-       GetMainFrame()->ShowHelp(DirViewHelpLocation);
+       theApp.ShowHelp(DirViewHelpLocation);
 }
 
 /**
index 625cfb9..a3c33ec 100644 (file)
@@ -34,6 +34,7 @@
 #include <afxcview.h>
 #include <map>
 #include <boost/scoped_ptr.hpp>
+#define POCO_NO_UNWINDOWS 1
 #include <Poco/Types.h>
 #include "OptionsDiffColors.h"
 #include "SortHeaderCtrl.h"
index 358739f..ef2e19d 100644 (file)
@@ -10,8 +10,8 @@
 
 
 #include "StdAfx.h"
-#include "Merge.h"
 #include "DirView.h"
+#include "Merge.h"
 #include "DirDoc.h"
 #include "resource.h"
 #include "coretools.h"
index e908742..93ce8d0 100644 (file)
 
 
 #include "stdafx.h"
+#include "DirViewColItems.h"
 #include <shlwapi.h>
 #include <Poco/Timestamp.h>
 #include "UnicodeString.h"
 #include "Merge.h"
 #include "DirView.h"
 #include "DirDoc.h"
-#include "MainFrm.h"
 #include "resource.h"
-#include "DirViewColItems.h"
 #include "locality.h"
 #include "unicoder.h"
 #include "coretools.h"
index 9c15e7a..779cc9a 100644 (file)
@@ -27,7 +27,6 @@
 // $Id: EditorFilepathBar.cpp 5401 2008-05-30 12:09:27Z kimmov $
 
 #include "stdafx.h"
-#include "Merge.h"
 #include "EditorFilepathBar.h"
 
 #ifdef _DEBUG
index 912d8fb..52307ab 100644 (file)
@@ -2,9 +2,8 @@
 //
 
 #include "stdafx.h"
-#include "Merge.h"
-#include "resource.h"
 #include "EncodingErrorBar.h"
+#include "Merge.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
index 819f683..85a9080 100644 (file)
 // $Id$
 
 #include "stdafx.h"
+#include "FileActionScript.h"
 #include <vector>
 #include "UnicodeString.h"
 #include "Merge.h"
 #include "OptionsDef.h"
+#include "OptionsMgr.h"
 #include "MainFrm.h"
-#include "FileActionScript.h"
 #include "ShellFileOperations.h"
 #include "paths.h"
 
@@ -109,7 +110,7 @@ int FileActionScript::VCSCheckOut(const String &path, BOOL &bApplyToAll)
                return retVal;
 
        // TODO: First param is not used!
-       int nRetVal = GetMainFrame()->SyncFileToVCS(path.c_str(), bApplyToAll, strErr);
+       int nRetVal = theApp.SyncFileToVCS(path.c_str(), bApplyToAll, strErr);
        if (nRetVal == -1)
        {
                retVal = SCRIPT_FAIL; // So we exit without file operations done
@@ -172,7 +173,7 @@ int FileActionScript::CreateOperationsScripts()
 
                        if (bContinue)
                        {
-                               if (!GetMainFrame()->CreateBackup(TRUE, (*iter).dest.c_str()))
+                               if (!theApp.CreateBackup(TRUE, (*iter).dest.c_str()))
                                {
                                        String strErr = theApp.LoadString(IDS_ERROR_BACKUP);
                                        AfxMessageBox(strErr.c_str(), MB_OK | MB_ICONERROR);
index 940f031..bee48c6 100644 (file)
@@ -20,8 +20,8 @@
 // ID line follows -- this is updated by SVN
 // $Id$
 
-#include <vector>
 #include "FileFilter.h"
+#include <vector>
 
 using std::vector;
 
index fe2cbdf..1319305 100644 (file)
 #define __FILEFILTER_H__
 
 #include <vector>
-#include "UnicodeString.h"
 #define POCO_NO_UNWINDOWS 1
 #include <Poco/RegularExpression.h>
 #include <boost/shared_ptr.hpp>
+#include "UnicodeString.h"
 
 /**
  * @brief FileFilter rule.
index f9cdba8..a2a5f84 100644 (file)
 // $Id$
 
 #include "stdafx.h"
+#include "FileFiltersDlg.h"
 #include <vector>
 #include "UnicodeString.h"
-#include "merge.h"
-#include "MainFrm.h"
-#include "FileFiltersDlg.h"
+#include "Merge.h"
 #include "FileFilterMgr.h"
+#include "FileFilterHelper.h"
 #include "paths.h"
 #include "SharedFilterDlg.h"
 #include "TestFilterDlg.h"
@@ -248,7 +248,7 @@ void FileFiltersDlg::OnFiltersEditbtn()
  */
 void FileFiltersDlg::EditFileFilter(LPCTSTR path)
 {
-       CMainFrame::OpenFileToExternalEditor(path);
+       theApp.OpenFileToExternalEditor(path);
 }
 
 /**
@@ -374,9 +374,9 @@ void FileFiltersDlg::OnBnClickedFilterfileTestButton()
        m_sFileFilterPath = m_listFilters.GetItemText(sel, 2);
 
        // Ensure filter is up-to-date (user probably just edited it)
-       theApp.m_globalFileFilter.ReloadUpdatedFilters();
+       theApp.m_pGlobalFileFilter->ReloadUpdatedFilters();
 
-       FileFilterMgr *pMgr = theApp.m_globalFileFilter.GetManager();
+       FileFilterMgr *pMgr = theApp.m_pGlobalFileFilter->GetManager();
        FileFilter * pFileFilter = pMgr->GetFilterByPath(m_sFileFilterPath);
        if (!pFileFilter)
                return;
@@ -397,8 +397,8 @@ void FileFiltersDlg::OnBnClickedFilterfileTestButton()
  */
 void FileFiltersDlg::OnBnClickedFilterfileNewbutton()
 {
-       String globalPath = theApp.m_globalFileFilter.GetGlobalFilterPathWithCreate();
-       String userPath = theApp.m_globalFileFilter.GetUserFilterPathWithCreate();
+       String globalPath = theApp.m_pGlobalFileFilter->GetGlobalFilterPathWithCreate();
+       String userPath = theApp.m_pGlobalFileFilter->GetUserFilterPathWithCreate();
 
        if (globalPath.empty() && userPath.empty())
        {
@@ -461,15 +461,15 @@ void FileFiltersDlg::OnBnClickedFilterfileNewbutton()
                        return;
                }
                EditFileFilter(s.c_str());
-               FileFilterMgr *pMgr = theApp.m_globalFileFilter.GetManager();
+               FileFilterMgr *pMgr = theApp.m_pGlobalFileFilter->GetManager();
                int retval = pMgr->AddFilter(s.c_str());
                if (retval == FILTER_OK)
                {
                        // Remove all from filterslist and re-add so we can update UI
                        String selected;
                        m_Filters->clear();
-                       theApp.m_globalFileFilter.LoadAllFileFilters();
-                       theApp.m_globalFileFilter.GetFileFilters(m_Filters, selected);
+                       theApp.m_pGlobalFileFilter->LoadAllFileFilters();
+                       theApp.m_pGlobalFileFilter->GetFileFilters(m_Filters, selected);
 
                        UpdateFiltersList();
                }
@@ -498,13 +498,13 @@ void FileFiltersDlg::OnBnClickedFilterfileDelete()
                {
                        if (DeleteFile(path))
                        {
-                               FileFilterMgr *pMgr = theApp.m_globalFileFilter.GetManager();
+                               FileFilterMgr *pMgr = theApp.m_pGlobalFileFilter->GetManager();
                                pMgr->RemoveFilter((LPCTSTR)path);
                                
                                // Remove all from filterslist and re-add so we can update UI
                                String selected;
                                m_Filters->clear();
-                               theApp.m_globalFileFilter.GetFileFilters(m_Filters, selected);
+                               theApp.m_pGlobalFileFilter->GetFileFilters(m_Filters, selected);
 
                                UpdateFiltersList();
                        }
@@ -541,7 +541,7 @@ void FileFiltersDlg::UpdateFiltersList()
  */
 void FileFiltersDlg::OnHelp()
 {
-       GetMainFrame()->ShowHelp(FilterHelpLocation);
+       theApp.ShowHelp(FilterHelpLocation);
 }
 
 /**
@@ -556,7 +556,7 @@ void FileFiltersDlg::OnBnClickedFilterfileInstall()
 {
        String s;
        String path;
-       String userPath = theApp.m_globalFileFilter.GetUserFilterPathWithCreate();
+       String userPath = theApp.m_pGlobalFileFilter->GetUserFilterPathWithCreate();
 
        if (SelectFile(GetSafeHwnd(), s, path.c_str(), IDS_FILEFILTER_INSTALL, IDS_FILEFILTER_FILEMASK,
                TRUE))
@@ -590,13 +590,13 @@ void FileFiltersDlg::OnBnClickedFilterfileInstall()
                }
                else
                {
-                       FileFilterMgr *pMgr = theApp.m_globalFileFilter.GetManager();
+                       FileFilterMgr *pMgr = theApp.m_pGlobalFileFilter->GetManager();
                        pMgr->AddFilter(userPath.c_str());
 
                        // Remove all from filterslist and re-add so we can update UI
                        String selected;
                        m_Filters->clear();
-                       theApp.m_globalFileFilter.GetFileFilters(m_Filters, selected);
+                       theApp.m_pGlobalFileFilter->GetFileFilters(m_Filters, selected);
 
                        UpdateFiltersList();
                }
index 0024434..cf7cd3b 100644 (file)
@@ -31,6 +31,8 @@
 
 #include <vector>
 
+struct FileFilterInfo;
+
 /**
  * @brief Class for dialog allowing user to select
  * and edit used file filters
index 21b8bb6..49efbd8 100644 (file)
 // $Id: FileOrFolderSelect.cpp 6569 2009-03-15 14:33:03Z kimmov $
 
 #include <windows.h>
+#include "FileOrFolderSelect.h"
 #include <shlobj.h>
 #include <sys/stat.h>
-#include "UnicodeString.h"
 #include "Environment.h"
-#include "FileOrFolderSelect.h"
 #include "paths.h"
 #include "MergeApp.h"
 #include "resource.h"
index 387440b..613d1af 100644 (file)
@@ -29,6 +29,7 @@
 #ifndef _FILE_OR_FOLDER_SELECTION_H_
 #define _FILE_OR_FOLDER_SELECTION_H_
 
+#include "UnicodeString.h"
 
 BOOL SelectFile(HWND parent, String& path, LPCTSTR initialPath = NULL, 
                         UINT titleid = 0, UINT filterid = 0,
index 24d9807..4f9b326 100644 (file)
@@ -27,9 +27,9 @@
 // $Id: FilepathEdit.cpp 6500 2009-02-25 13:36:26Z kimmov $
 
 #include "stdafx.h"
+#include "FilepathEdit.h"
 #include "Merge.h"
 #include "BCMenu.h"
-#include "FilepathEdit.h"
 #include "ClipBoard.h"
 #include "Shlwapi.h"
 
index 3f76a3c..b766249 100644 (file)
 
 #include <vector>
 #include <string>
-#include "codepage.h"
 #define POCO_NO_UNWINDOWS 1
 #include <Poco/RegularExpression.h>
 #include <boost/shared_ptr.hpp>
+#include "codepage.h"
 
 /**
  * @brief Container for one filtering rule / compiled expression.
index d8e2ccd..a15ae46 100644 (file)
@@ -32,7 +32,6 @@
 // $Id: GhostTextBuffer.cpp 6878 2009-06-29 09:28:13Z kimmov $
 
 #include "StdAfx.h"
-#include <vector>
 #include "GhostTextBuffer.h"
 
 #ifdef _DEBUG
index da4184c..8a19abe 100644 (file)
 // $Id: HexMergeDoc.cpp 7166 2010-05-16 12:05:13Z jtuc $
 
 #include "stdafx.h"
+#include "HexMergeDoc.h"
 #include <afxinet.h>
 #include "UnicodeString.h"
 #include "FileTextEncoding.h"
 #include "Merge.h"
-#include "HexMergeDoc.h"
 #include "HexMergeFrm.h"
 #include "HexMergeView.h"
 #include "DiffItem.h"
 #include "FolderCmp.h"
-#include "MainFrm.h"
 #include "Environment.h"
 #include "diffcontext.h"       // FILE_SAME
 #include "dirdoc.h"
@@ -48,6 +47,7 @@
 #include "paths.h"
 #include "OptionsMgr.h"
 #include "FileOrFolderSelect.h"
+#include "DiffWrapper.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -372,7 +372,7 @@ void CHexMergeDoc::DoFileSaveAs(int nBuffer)
                id = IDS_SAVE_RIGHT_AS;
        else
                id = IDS_SAVE_MIDDLE_AS;
-       if (SelectFile(GetMainFrame()->GetSafeHwnd(), strPath, path.c_str(), id, NULL, FALSE))
+       if (SelectFile(AfxGetMainWnd()->GetSafeHwnd(), strPath, path.c_str(), id, NULL, FALSE))
        {
                if (Try(m_pView[nBuffer]->SaveFile(strPath.c_str())) == IDCANCEL)
                        return;
@@ -497,7 +497,7 @@ HRESULT CHexMergeDoc::LoadOneFile(int index, LPCTSTR filename, BOOL readOnly)
                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 = GetMainFrame()->m_strDescriptions[index];
+               String strDesc = theApp.m_strDescriptions[index];
                if (!strDesc.empty())
                {
                        m_strDesc[index] = strDesc;
@@ -507,7 +507,7 @@ HRESULT CHexMergeDoc::LoadOneFile(int index, LPCTSTR filename, BOOL readOnly)
        else
        {
                m_nBufferType[index] = BUFFER_UNNAMED;
-               m_strDesc[index] = GetMainFrame()->m_strDescriptions[index];
+               m_strDesc[index] = theApp.m_strDescriptions[index];
 
        }
        UpdateHeaderPath(index);
index 0cf489b..a7525c3 100644 (file)
@@ -37,6 +37,15 @@ class CHexMergeView;
  */
 class CHexMergeDoc : public CDocument
 {
+public:
+       enum BUFFERTYPE
+       {
+               BUFFER_NORMAL = 0, /**< Normal, file loaded from disk */
+               BUFFER_NORMAL_NAMED, /**< Normal, description given */
+               BUFFER_UNNAMED, /**< Empty, created buffer */
+               BUFFER_UNNAMED_SAVED, /**< Empty buffer saved with filename */
+       };
+
 // Attributes
 public:
        static int m_nBuffersTemp;
index b493962..9a93ee6 100644 (file)
 // $Id: HexMergeFrm.cpp 7166 2010-05-16 12:05:13Z jtuc $
 
 #include "stdafx.h"
-#include "Merge.h"
-#include "MainFrm.h"
 #include "HexMergeFrm.h"
+#include "Merge.h"
 #include "HexMergeDoc.h"
 #include "HexMergeView.h"
 #include "OptionsDef.h"
+#include "OptionsMgr.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
index daf1641..cb0c118 100644 (file)
 // $Id: HexMergeView.cpp 7165 2010-05-15 14:04:43Z jtuc $
 
 #include "stdafx.h"
+#include "HexMergeFrm.h"
 #include "Merge.h"
 #include "MainFrm.h"
-#include "HexMergeFrm.h"
 #include "HexMergeView.h"
 #include "OptionsDef.h"
+#include "OptionsMgr.h"
 #include "Environment.h"
 
 #ifdef _DEBUG
@@ -304,11 +305,11 @@ HRESULT CHexMergeView::SaveFile(LPCTSTR path)
        // Ask user what to do about FILE_ATTRIBUTE_READONLY
        String strPath = path;
        BOOL bApplyToAll = FALSE;
-       if (GetMainFrame()->HandleReadonlySave(strPath, FALSE, bApplyToAll) == IDCANCEL)
+       if (theApp.HandleReadonlySave(strPath, FALSE, bApplyToAll) == IDCANCEL)
                return S_OK;
        path = strPath.c_str();
        // Take a chance to create a backup
-       if (!GetMainFrame()->CreateBackup(FALSE, path))
+       if (!theApp.CreateBackup(FALSE, path))
                return S_OK;
        // Write data to an intermediate file
        String tempPath = env_GetTempPath();
index 04083c3..625da72 100644 (file)
@@ -7,9 +7,8 @@
 // $Id$
 
 #include "stdafx.h"
-#include "merge.h"
 #include "LineFiltersList.h"
-#include "MainFrm.h"
+#include "Merge.h"
 #include "LineFiltersDlg.h"
 
 #ifdef _DEBUG
@@ -111,7 +110,7 @@ void LineFiltersDlg::InitList()
  */
 void LineFiltersDlg::OnHelp()
 {
-       GetMainFrame()->ShowHelp(FilterHelpLocation);
+       theApp.ShowHelp(FilterHelpLocation);
 }
 
 /**
index 5734166..5791dd3 100644 (file)
@@ -7,10 +7,9 @@
 // $Id: LoadSaveCodepageDlg.cpp 5394 2008-05-29 09:47:36Z kimmov $
 
 #include "stdafx.h"
+#include "LoadSaveCodepageDlg.h"
 #include "Merge.h"
-#include "MainFrm.h"
 #include "resource.h"
-#include "LoadSaveCodepageDlg.h"
 #include "unicoder.h"
 #include "ExConverter.h"
 
@@ -87,8 +86,6 @@ BOOL CLoadSaveCodepageDlg::OnInitDialog()
        theApp.TranslateDialog(m_hWnd);
        CDialog::OnInitDialog();
 
-       CMainFrame::SetMainIcon(this);
-       
        // setup handler for resizing this dialog       
        m_constraint.InitializeCurrentSize(this);
        // configure how individual controls adjust when dialog resizes
@@ -130,7 +127,7 @@ BOOL CLoadSaveCodepageDlg::OnInitDialog()
                combo.Detach();
        }
 
-       CMainFrame::CenterToMainFrame(this);
+       AfxGetMainWnd()->CenterWindow(this);
 
        SetDlgItemText(IDC_LEFT_FILES_LABEL, m_sAffectsLeftString);
        SetDlgItemText(IDC_MIDDLE_FILES_LABEL, m_sAffectsMiddleString);
index 21f2007..54ff90f 100644 (file)
 //////////////////////////////////////////////////////////////////////
 
 #include "stdafx.h"
-#include "Merge.h"
-
-#include "ChildFrm.h"
 #include "LocationBar.h"
+#include "Merge.h"
 
 #ifdef _DEBUG
 #undef THIS_FILE
index badcfee..8826c7f 100644 (file)
 // $Id: LocationView.cpp 7127 2010-03-10 21:03:58Z kimmov $
 
 #include "StdAfx.h"
+#include "LocationView.h"
 #include <vector>
 #include "Merge.h"
 #include "OptionsMgr.h"
 #include "MergeEditView.h"
-#include "LocationView.h"
 #include "MergeDoc.h"
 #include "BCMenu.h"
 #include "OptionsDef.h"
-#include "MergeLineFlags.h"
 #include "Bitmap.h"
 #include "memdc.h"
 #include "SyntaxColors.h"
index 1a8e4aa..c97bac3 100644 (file)
@@ -16,6 +16,9 @@
 #include <vector>
 #include <boost/scoped_ptr.hpp>
 
+class CMergeDoc;
+class CMergeEditView;
+
 /**
  * @brief Status for display moved block
  */
index 7451fd7..05390b2 100644 (file)
 // $Id: MainFrm.cpp 7063 2009-12-27 15:28:16Z kimmov $
 
 #include "StdAfx.h"
+#include "MainFrm.h"
 #include <vector>
-#include <htmlhelp.h>  // From HTMLHelp Workshop (incl. in Platform SDK)
 #include <shlwapi.h>
+#include <Poco/Exception.h>
 #include "Constants.h"
 #include "Merge.h"
+#include "FileFilterHelper.h"
 #include "UnicodeString.h"
 #include "BCMenu.h"
-#include "MainFrm.h"
 #include "OpenFrm.h"
 #include "DirFrame.h"          // Include type information
 #include "ChildFrm.h"
 #include "DirDoc.h"
 #include "OpenDoc.h"
 #include "OpenView.h"
+#include "MergeDoc.h"
 #include "MergeEditView.h"
 #include "HexMergeDoc.h"
-#include "LocationView.h"
-#include "SyntaxColors.h"
 #include "LineFiltersList.h"
 #include "ConflictFileParser.h"
 #include "Splash.h"
 #include "OptionsDef.h"
 #include "codepage_detect.h"
 #include "unicoder.h"
-#include "VSSHelper.h"
 #include "codepage.h"
 #include "PreferencesDlg.h"
 #include "ProjectFilePathsDlg.h"
-#include "MergeCmdLineInfo.h"
 #include "FileOrFolderSelect.h"
-#include "PropBackups.h"
 #include "unicoder.h"
 #include "PluginsListDlg.h"
 #include "stringdiffs.h"
 #include "MergeCmdLineInfo.h"
-#include "OptionsSyntaxColors.h"
 #include "OptionsFont.h"
 #include "TFile.h"
 #include "JumpList.h"
 #include "DragDrop.h"
-#include <Poco/Exception.h>
 
 using std::vector;
 
@@ -267,9 +262,6 @@ static const UINT ID_TIMER_FLASH = 1;
 /** @brief Timeout for window flashing timer, in milliseconds. */
 static const UINT WINDOW_FLASH_TIMEOUT = 500;
 
-/** @brief Backup file extension. */
-static const TCHAR BACKUP_FILE_EXT[] = _T("bak");
-
 /**
   * @brief Return a const reference to a CMultiDocTemplate's list of documents.
   */
@@ -293,50 +285,8 @@ static const CPtrList &GetDocList(const CMultiDocTemplate *pTemplate)
 CMainFrame::CMainFrame()
 : m_bFlashing(FALSE)
 , m_bFirstTime(TRUE)
-, m_bEscShutdown(FALSE)
-, m_bClearCaseTool(FALSE)
-, m_bExitIfNoDiff(MergeCmdLineInfo::Disabled)
-, m_bShowErrors(TRUE)
-, m_CheckOutMulti(FALSE)
-, m_bVCProjSync(FALSE)
-, m_bVssSuppressPathCheck(FALSE)
-, m_pLineFilters(new LineFiltersList())
-, m_pSyntaxColors(new SyntaxColors())
 {
        ZeroMemory(&m_pMenus[0], sizeof(m_pMenus));
-       UpdateCodepageModule();
-
-       InitializeSourceControlMembers();
-       g_bUnpackerMode = theApp.GetProfileInt(_T("Settings"), _T("UnpackerMode"), PLUGIN_MANUAL);
-       g_bPredifferMode = theApp.GetProfileInt(_T("Settings"), _T("PredifferMode"), PLUGIN_MANUAL);
-
-       if (m_pSyntaxColors)
-               Options::SyntaxColors::Load(m_pSyntaxColors.get());
-
-       if (m_pLineFilters)
-               m_pLineFilters->Initialize(GetOptionsMgr());
-
-       // If there are no filters loaded, and there is filter string in previous
-       // option string, import old filters to new place.
-       if (m_pLineFilters->GetCount() == 0)
-       {
-               String oldFilter = theApp.GetProfileString(_T("Settings"), _T("RegExps"));
-               if (!oldFilter.empty())
-                       m_pLineFilters->Import(oldFilter);
-       }
-
-       // Check if filter folder is set, and create it if not
-       String pathMyFolders = GetOptionsMgr()->GetString(OPT_FILTER_USERPATH);
-       if (pathMyFolders.empty())
-       {
-               // No filter path, set it to default and make sure it exists.
-               String pathFilters = theApp.GetDefaultFilterUserPath(TRUE);
-               GetOptionsMgr()->SaveOption(OPT_FILTER_USERPATH, pathFilters);
-               theApp.m_globalFileFilter.SetFileFilterPath(pathFilters.c_str());
-       }
-
-       sd_Init(); // String diff init
-       sd_SetBreakChars(GetOptionsMgr()->GetString(OPT_BREAK_SEPARATORS).c_str());
 }
 
 CMainFrame::~CMainFrame()
@@ -891,121 +841,7 @@ void CMainFrame::OnUpdateOptionsShowSkipped(CCmdUI* pCmdUI)
 void CMainFrame::OnHelpGnulicense() 
 {
        const String spath = env_GetProgPath() + LicenseFile;
-       OpenFileOrUrl(spath.c_str(), LicenceUrl);
-}
-
-/**
- * @brief Checks if path (file/folder) is read-only and asks overwriting it.
- *
- * @param strSavePath [in,out] Path where to save (file or folder)
- * @param bMultiFile [in] Single file or multiple files/folder
- * @param bApplyToAll [in,out] Apply last user selection for all items?
- * @return Users selection:
- * - IDOK: Item was not readonly, no actions
- * - IDYES/IDYESTOALL: Overwrite readonly item
- * - IDNO: User selected new filename (single file) or user wants to skip
- * - IDCANCEL: Cancel operation
- * @sa CMainFrame::SyncFileToVCS()
- * @sa CMergeDoc::DoSave()
- */
-int CMainFrame::HandleReadonlySave(String& strSavePath, BOOL bMultiFile,
-               BOOL &bApplyToAll)
-{
-       CFileStatus status;
-       UINT userChoice = 0;
-       int nRetVal = IDOK;
-       BOOL bFileRO = FALSE;
-       BOOL bFileExists = FALSE;
-       String s;
-       String str;
-       CString title;
-       int nVerSys = 0;
-
-       try
-       {
-               TFile file(strSavePath);
-               bFileExists = file.exists();
-               if (bFileExists)
-                       bFileRO = !file.canWrite();
-       }
-       catch (...)
-       {
-       }
-       nVerSys = GetOptionsMgr()->GetInt(OPT_VCS_SYSTEM);
-       
-       if (bFileExists && bFileRO)
-       {
-               // Version control system used?
-               // Checkout file from VCS and modify, don't ask about overwriting
-               // RO files etc.
-               if (nVerSys != VCS_NONE)
-               {
-                       BOOL bRetVal = SaveToVersionControl(strSavePath);
-                       if (bRetVal)
-                               return IDYES;
-                       else
-                               return IDCANCEL;
-               }
-               
-               // Don't ask again if its already asked
-               if (bApplyToAll)
-                       userChoice = IDYES;
-               else
-               {
-                       // Prompt for user choice
-                       if (bMultiFile)
-                       {
-                               // Multiple files or folder
-                               str = LangFormatString1(IDS_SAVEREADONLY_MULTI, strSavePath.c_str());
-                               userChoice = AfxMessageBox(str.c_str(), MB_YESNOCANCEL |
-                                               MB_ICONWARNING | MB_DEFBUTTON3 | MB_DONT_ASK_AGAIN |
-                                               MB_YES_TO_ALL, IDS_SAVEREADONLY_MULTI);
-                       }
-                       else
-                       {
-                               // Single file
-                               str = LangFormatString1(IDS_SAVEREADONLY_FMT, strSavePath.c_str());
-                               userChoice = AfxMessageBox(str.c_str(), MB_YESNOCANCEL |
-                                               MB_ICONWARNING | MB_DEFBUTTON2 | MB_DONT_ASK_AGAIN,
-                                               IDS_SAVEREADONLY_FMT);
-                       }
-               }
-               switch (userChoice)
-               {
-               // Overwrite read-only file
-               case IDYESTOALL:
-                       bApplyToAll = TRUE;  // Don't ask again (no break here)
-               case IDYES:
-                       CFile::GetStatus(strSavePath.c_str(), status);
-                       status.m_mtime = 0;             // Avoid unwanted changes
-                       status.m_attribute &= ~CFile::readOnly;
-                       CFile::SetStatus(strSavePath.c_str(), status);
-                       nRetVal = IDYES;
-                       break;
-               
-               // Save to new filename (single) /skip this item (multiple)
-               case IDNO:
-                       if (!bMultiFile)
-                       {
-                               if (SelectFile(GetSafeHwnd(), s, strSavePath.c_str(), IDS_SAVE_AS_TITLE, NULL, FALSE))
-                               {
-                                       strSavePath = s;
-                                       nRetVal = IDNO;
-                               }
-                               else
-                                       nRetVal = IDCANCEL;
-                       }
-                       else
-                               nRetVal = IDNO;
-                       break;
-
-               // Cancel saving
-               case IDCANCEL:
-                       nRetVal = IDCANCEL;
-                       break;
-               }
-       }
-       return nRetVal;
+       theApp.OpenFileOrUrl(spath.c_str(), LicenceUrl);
 }
 
 /// Wrapper to set the global option 'm_bAllowMixedEol'
@@ -1021,16 +857,16 @@ void CMainFrame::SetEOLMixed(BOOL bAllow)
 void CMainFrame::OnOptions() 
 {
        // Using singleton shared syntax colors
-       CPreferencesDlg dlg(GetOptionsMgr(), m_pSyntaxColors.get());
+       CPreferencesDlg dlg(GetOptionsMgr(), theApp.GetMainSyntaxColors());
        int rv = dlg.DoModal();
 
        if (rv == IDOK)
        {
                // Set new filterpath
                String filterPath = GetOptionsMgr()->GetString(OPT_FILTER_USERPATH);
-               theApp.m_globalFileFilter.SetUserFilterPath(filterPath);
+               theApp.m_pGlobalFileFilter->SetUserFilterPath(filterPath);
 
-               UpdateCodepageModule();
+               theApp.UpdateCodepageModule();
                // Call the wrapper to set m_bAllowMixedEol (the wrapper updates the registry)
                SetEOLMixed(GetOptionsMgr()->GetBool(OPT_ALLOW_MIXED_EOL));
 
@@ -1325,12 +1161,12 @@ BOOL CMainFrame::DoFileOpen(PathContext * pFiles /*=NULL*/,
                        // exception. There is no point in checking return value.
                        pDirDoc->InitCompare(files, bRecurse, pTempPathContext);
 
-                       pDirDoc->SetDescriptions(m_strDescriptions);
+                       pDirDoc->SetDescriptions(theApp.m_strDescriptions);
                        pDirDoc->SetTitle(NULL);
                        for (int nIndex = 0; nIndex < files.GetSize(); nIndex++)
                        {
                                pDirDoc->SetReadOnly(nIndex, bRO[nIndex]);
-                               m_strDescriptions[nIndex].erase();
+                               theApp.m_strDescriptions[nIndex].erase();
                        }
 
                        pDirDoc->Rescan();
@@ -1369,143 +1205,6 @@ BOOL CMainFrame::DoFileOpen(PathContext * pFiles /*=NULL*/,
        return TRUE;
 }
 
-/**
- * @brief Creates backup before file is saved or copied over.
- * This function handles formatting correct path and filename for
- * backup file. Formatting is done based on several options available
- * for users in Options/Backups dialog. After path is formatted, file
- * is simply just copied. Not much error checking, just if copying
- * succeeded or failed.
- * @param [in] bFolder Are we creating backup in folder compare?
- * @param [in] pszPath Full path to file to backup.
- * @return TRUE if backup succeeds, or isn't just done.
- */
-BOOL CMainFrame::CreateBackup(BOOL bFolder, const String& pszPath)
-{
-       // If user doesn't want to backups in folder compare, return
-       // success so operations don't abort.
-       if (bFolder && !(GetOptionsMgr()->GetBool(OPT_BACKUP_FOLDERCMP)))
-               return TRUE;
-       // Likewise if user doesn't want backups in file compare
-       else if (!bFolder && !(GetOptionsMgr()->GetBool(OPT_BACKUP_FILECMP)))
-               return TRUE;
-
-       // create backup copy of file if destination file exists
-       if (paths_DoesPathExist(pszPath) == IS_EXISTING_FILE)
-       {
-               String bakPath;
-               String path;
-               String filename;
-               String ext;
-       
-               paths_SplitFilename(pszPath, &path, &filename, &ext);
-
-               // Determine backup folder
-               if (GetOptionsMgr()->GetInt(OPT_BACKUP_LOCATION) ==
-                       PropBackups::FOLDER_ORIGINAL)
-               {
-                       // Put backups to same folder than original file
-                       bakPath = path;
-               }
-               else if (GetOptionsMgr()->GetInt(OPT_BACKUP_LOCATION) ==
-                       PropBackups::FOLDER_GLOBAL)
-               {
-                       // Put backups to global folder defined in options
-                       bakPath = GetOptionsMgr()->GetString(OPT_BACKUP_GLOBALFOLDER);
-                       if (bakPath.empty())
-                               bakPath = path;
-                       else
-                               bakPath = paths_GetLongPath(bakPath);
-               }
-               else
-               {
-                       _RPTF0(_CRT_ERROR, "Unknown backup location!");
-               }
-
-               BOOL success = FALSE;
-               if (GetOptionsMgr()->GetBool(OPT_BACKUP_ADD_BAK))
-               {
-                       // Don't add dot if there is no existing extension
-                       if (ext.size() > 0)
-                               ext += _T(".");
-                       ext += BACKUP_FILE_EXT;
-               }
-
-               // Append time to filename if wanted so
-               // NOTE just adds timestamp at the moment as I couldn't figure out
-               // nice way to add a real time (invalid chars etc).
-               if (GetOptionsMgr()->GetBool(OPT_BACKUP_ADD_TIME))
-               {
-                       struct tm *tm;
-                       time_t curtime = 0;
-                       time(&curtime);
-                       tm = localtime(&curtime);
-                       CString timestr;
-                       timestr.Format(_T("%04d%02d%02d%02d%02d%02d"), tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
-                       filename += _T("-");
-                       filename += timestr;
-               }
-
-               // Append filename and extension (+ optional .bak) to path
-               if ((bakPath.length() + filename.length() + ext.length())
-                       < MAX_PATH)
-               {
-                       success = TRUE;
-                       if (!paths_EndsWithSlash(bakPath))
-                               bakPath += _T("\\");
-                       bakPath = paths_ConcatPath(bakPath, filename);
-                       bakPath += _T(".");
-                       bakPath += ext;
-               }
-
-               if (success)
-                       success = CopyFile(pszPath.c_str(), bakPath.c_str(), FALSE);
-               
-               if (!success)
-               {
-                       if (ResMsgBox1(IDS_BACKUP_FAILED_PROMPT, pszPath.c_str(),
-                                       MB_YESNO | MB_ICONWARNING | MB_DONT_ASK_AGAIN, 
-                                       IDS_BACKUP_FAILED_PROMPT) != IDYES)
-                               return FALSE;
-               }
-               return TRUE;
-       }
-
-       // we got here because we're either not backing up of there was nothing to backup
-       return TRUE;
-}
-
-/**
- * @brief Sync file to Version Control System
- * @param pszDest [in] Where to copy (incl. filename)
- * @param bApplyToAll [in,out] Apply user selection to all items
- * @param psError [out] Error string that can be shown to user in caller func
- * @return User selection or -1 if error happened
- * @sa CMainFrame::HandleReadonlySave()
- * @sa CDirView::PerformActionList()
- */
-int CMainFrame::SyncFileToVCS(const String& pszDest, BOOL &bApplyToAll,
-       String& sError)
-{
-       String sActionError;
-       String strSavePath(pszDest);
-       int nVerSys = 0;
-
-       nVerSys = GetOptionsMgr()->GetInt(OPT_VCS_SYSTEM);
-       
-       int nRetVal = HandleReadonlySave(strSavePath, TRUE, bApplyToAll);
-       if (nRetVal == IDCANCEL || nRetVal == IDNO)
-               return nRetVal;
-       
-       // If VC project opened from VSS sync and version control used
-       if ((nVerSys == VCS_VSS4 || nVerSys == VCS_VSS5) && m_bVCProjSync)
-       {
-               if (!m_vssHelper.ReLinkVCProj(strSavePath, sError))
-                       nRetVal = -1;
-       }
-       return nRetVal;
-}
-
 void CMainFrame::UpdateFont(FRAMETYPE frame)
 {
        if (frame == FRAME_FOLDER)
@@ -1642,33 +1341,13 @@ void CMainFrame::UpdateResources()
 }
 
 /**
- * @brief Open file, if it exists, else open url
- */
-void CMainFrame::OpenFileOrUrl(LPCTSTR szFile, LPCTSTR szUrl)
-{
-       if (paths_DoesPathExist(szFile) == IS_EXISTING_FILE)
-               ShellExecute(m_hWnd, _T("open"), _T("notepad.exe"), szFile, NULL, SW_SHOWNORMAL);
-       else
-               ShellExecute(NULL, _T("open"), szUrl, NULL, NULL, SW_SHOWNORMAL);
-}
-
-/**
  * @brief Open WinMerge help.
  *
  * If local HTMLhelp file is found, open it, otherwise open HTML page from web.
  */
 void CMainFrame::OnHelpContents()
 {
-       String sPath = env_GetProgPath();
-       LANGID LangId = theApp.GetLangId();
-       if (PRIMARYLANGID(LangId) == LANG_JAPANESE)
-               sPath += DocsPath_ja;
-       else
-               sPath += DocsPath;
-       if (paths_DoesPathExist(sPath) == IS_EXISTING_FILE)
-               ::HtmlHelp(NULL, sPath.c_str(), HH_DISPLAY_TOC, NULL);
-       else
-               ShellExecute(NULL, _T("open"), DocsURL, NULL, NULL, SW_SHOWNORMAL);
+       theApp.ShowHelp();
 }
 
 /**
@@ -1759,7 +1438,7 @@ void CMainFrame::OnClose()
        }
 
        // Save last selected filter
-       String filter = theApp.m_globalFileFilter.GetFilterNameOrMask();
+       String filter = theApp.m_pGlobalFileFilter->GetFilterNameOrMask();
        GetOptionsMgr()->SaveOption(OPT_FILEFILTER_CURRENT, filter);
 
        // save main window position
@@ -2071,7 +1750,7 @@ void CMainFrame::OnToolsGeneratePatch()
                {
                        if (patcher.GetOpenToEditor())
                        {
-                               OpenFileToExternalEditor(patcher.GetPatchFile().c_str());
+                               theApp.OpenFileToExternalEditor(patcher.GetPatchFile().c_str());
                        }
                }
        }
@@ -2255,62 +1934,6 @@ void CMainFrame::UpdatePrediffersMenu()
 }
 
 /**
- * @brief Open given file to external editor specified in options.
- * @param [in] file Full path to file to open.
- *
- * Opens file to defined (in Options/system), Notepad by default,
- * external editor. Path is decorated with quotation marks if needed
- * (contains spaces). Also '$file' in editor path is replaced by
- * filename to open.
- * @param [in] file Full path to file to open.
- * @param [in] nLineNumber Line number to go to.
- */
-void CMainFrame::OpenFileToExternalEditor(const String& file, int nLineNumber/* = 1*/)
-{
-       String sCmd = GetOptionsMgr()->GetString(OPT_EXT_EDITOR_CMD);
-       String sFile(file);
-       string_replace(sCmd, _T("$linenum"), string_format(_T("%d"), nLineNumber));
-
-       int nIndex = sCmd.find(_T("$file"));
-       if (nIndex > -1)
-       {
-               sFile.insert(0, _T("\""));
-               string_replace(sCmd, _T("$file"), sFile);
-               nIndex = sCmd.find(' ', nIndex + sFile.length());
-               if (nIndex > -1)
-                       sCmd.insert(nIndex, _T("\""));
-               else
-                       sCmd += '"';
-       }
-       else
-       {
-               sCmd += _T(" \"");
-               sCmd += sFile;
-               sCmd += _T("\"");
-       }
-
-       BOOL retVal = FALSE;
-       STARTUPINFO stInfo = {0};
-       stInfo.cb = sizeof(STARTUPINFO);
-       PROCESS_INFORMATION processInfo;
-
-       retVal = CreateProcess(NULL, (LPTSTR)sCmd.c_str(),
-               NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE, NULL, NULL,
-               &stInfo, &processInfo);
-
-       if (!retVal)
-       {
-               // Error invoking external editor
-               ResMsgBox1(IDS_ERROR_EXECUTE_FILE, sCmd.c_str(), MB_ICONSTOP);
-       }
-       else
-       {
-               CloseHandle(processInfo.hThread);
-               CloseHandle(processInfo.hProcess);
-       }
-}
-
-/**
  * @brief Save WinMerge configuration and info to file
  */
 void CMainFrame::OnSaveConfigData()
@@ -2321,7 +1944,7 @@ void CMainFrame::OnSaveConfigData()
        if (configLog.WriteLogFile(sError))
        {
                String sFileName = configLog.GetFileName();
-               OpenFileToExternalEditor(sFileName);
+               theApp.OpenFileToExternalEditor(sFileName);
        }
        else
        {
@@ -2351,17 +1974,17 @@ void CMainFrame::FileNew(int nPanes)
        FileLocation fileloc[3];
        if (nPanes == 2)
        {
-               m_strDescriptions[0] = theApp.LoadString(IDS_EMPTY_LEFT_FILE);
-               m_strDescriptions[1] = theApp.LoadString(IDS_EMPTY_RIGHT_FILE);
+               theApp.m_strDescriptions[0] = theApp.LoadString(IDS_EMPTY_LEFT_FILE);
+               theApp.m_strDescriptions[1] = theApp.LoadString(IDS_EMPTY_RIGHT_FILE);
                fileloc[0].encoding.SetCodepage(ucr::getDefaultCodepage());
                fileloc[1].encoding.SetCodepage(ucr::getDefaultCodepage());
                ShowMergeDoc(pDirDoc, 2, fileloc, dwFlags);
        }
        else
        {
-               m_strDescriptions[0] = theApp.LoadString(IDS_EMPTY_LEFT_FILE);
-               m_strDescriptions[1] = theApp.LoadString(IDS_EMPTY_MIDDLE_FILE);
-               m_strDescriptions[2] = theApp.LoadString(IDS_EMPTY_RIGHT_FILE);
+               theApp.m_strDescriptions[0] = theApp.LoadString(IDS_EMPTY_LEFT_FILE);
+               theApp.m_strDescriptions[1] = theApp.LoadString(IDS_EMPTY_MIDDLE_FILE);
+               theApp.m_strDescriptions[2] = theApp.LoadString(IDS_EMPTY_RIGHT_FILE);
                fileloc[0].encoding.SetCodepage(ucr::getDefaultCodepage());
                fileloc[1].encoding.SetCodepage(ucr::getDefaultCodepage());
                fileloc[2].encoding.SetCodepage(ucr::getDefaultCodepage());
@@ -2369,9 +1992,9 @@ void CMainFrame::FileNew(int nPanes)
        }
 
        // Empty descriptors now that docs are open
-       m_strDescriptions[0].erase();
-       m_strDescriptions[1].erase();
-       m_strDescriptions[2].erase();
+       theApp.m_strDescriptions[0].erase();
+       theApp.m_strDescriptions[1].erase();
+       theApp.m_strDescriptions[2].erase();
 }
 
 /**
@@ -2406,21 +2029,21 @@ void CMainFrame::OnToolsFilters()
        vector<FileFilterInfo> fileFilters;
        boost::scoped_ptr<LineFiltersList> lineFilters(new LineFiltersList());
        String selectedFilter;
-       const String origFilter = theApp.m_globalFileFilter.GetFilterNameOrMask();
+       const String origFilter = theApp.m_pGlobalFileFilter->GetFilterNameOrMask();
        sht.AddPage(&fileFiltersDlg);
        sht.AddPage(&lineFiltersDlg);
        sht.m_psh.dwFlags |= PSH_NOAPPLYNOW; // Hide 'Apply' button since we don't need it
 
        // Make sure all filters are up-to-date
-       theApp.m_globalFileFilter.ReloadUpdatedFilters();
+       theApp.m_pGlobalFileFilter->ReloadUpdatedFilters();
 
-       theApp.m_globalFileFilter.GetFileFilters(&fileFilters, selectedFilter);
+       theApp.m_pGlobalFileFilter->GetFileFilters(&fileFilters, selectedFilter);
        fileFiltersDlg.SetFilterArray(&fileFilters);
        fileFiltersDlg.SetSelected(selectedFilter);
        const BOOL lineFiltersEnabledOrig = GetOptionsMgr()->GetBool(OPT_LINEFILTER_ENABLED);
        lineFiltersDlg.m_bIgnoreRegExp = lineFiltersEnabledOrig;
 
-       lineFilters->CloneFrom(m_pLineFilters.get());
+       lineFilters->CloneFrom(theApp.m_pLineFilters.get());
        lineFiltersDlg.SetList(lineFilters.get());
 
        if (sht.DoModal() == IDOK)
@@ -2430,18 +2053,18 @@ void CMainFrame::OnToolsFilters()
                if (path.find(strNone) != String::npos)
                {
                        // Don't overwrite mask we already have
-                       if (!theApp.m_globalFileFilter.IsUsingMask())
+                       if (!theApp.m_pGlobalFileFilter->IsUsingMask())
                        {
                                String sFilter(_T("*.*"));
-                               theApp.m_globalFileFilter.SetFilter(sFilter);
+                               theApp.m_pGlobalFileFilter->SetFilter(sFilter);
                                GetOptionsMgr()->SaveOption(OPT_FILEFILTER_CURRENT, sFilter);
                        }
                }
                else
                {
-                       theApp.m_globalFileFilter.SetFileFilterPath(path);
-                       theApp.m_globalFileFilter.UseMask(FALSE);
-                       String sFilter = theApp.m_globalFileFilter.GetFilterNameOrMask();
+                       theApp.m_pGlobalFileFilter->SetFileFilterPath(path);
+                       theApp.m_pGlobalFileFilter->UseMask(FALSE);
+                       String sFilter = theApp.m_pGlobalFileFilter->GetFilterNameOrMask();
                        GetOptionsMgr()->SaveOption(OPT_FILEFILTER_CURRENT, sFilter);
                }
                BOOL linefiltersEnabled = lineFiltersDlg.m_bIgnoreRegExp;
@@ -2455,16 +2078,16 @@ void CMainFrame::OnToolsFilters()
                if (frame == FRAME_FILE)
                {
                        if (lineFiltersEnabledOrig != linefiltersEnabled ||
-                                       !m_pLineFilters->Compare(lineFilters.get()))
+                                       !theApp.m_pLineFilters->Compare(lineFilters.get()))
                        {
                                bFileCompareRescan = TRUE;
                        }
                }
                else if (frame == FRAME_FOLDER)
                {
-                       const String newFilter = theApp.m_globalFileFilter.GetFilterNameOrMask();
+                       const String newFilter = theApp.m_pGlobalFileFilter->GetFilterNameOrMask();
                        if (lineFiltersEnabledOrig != linefiltersEnabled || 
-                                       !m_pLineFilters->Compare(lineFilters.get()) || origFilter != newFilter)
+                                       !theApp.m_pLineFilters->Compare(lineFilters.get()) || origFilter != newFilter)
                        {
                                int res = LangMessageBox(IDS_FILTERCHANGED, MB_ICONWARNING | MB_YESNO);
                                if (res == IDYES)
@@ -2473,8 +2096,8 @@ void CMainFrame::OnToolsFilters()
                }
 
                // Save new filters before (possibly) rescanning
-               m_pLineFilters->CloneFrom(lineFilters.get());
-               m_pLineFilters->SaveFilters();
+               theApp.m_pLineFilters->CloneFrom(lineFilters.get());
+               theApp.m_pLineFilters->SaveFilters();
 
                if (bFileCompareRescan)
                {
@@ -2525,7 +2148,7 @@ BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
                const HexMergeDocList &hexDocs = GetAllHexMergeDocs();
                const DirDocList &dirDocs = GetAllDirDocs();
 
-               if (m_bEscShutdown)
+               if (theApp.m_bEscShutdown)
                {
                        if (openDocs.GetCount() + hexDocs.GetCount() + dirDocs.GetCount() <= 1)
                        {
@@ -2549,63 +2172,6 @@ BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
 }
 
 /**
- * @brief Shows VSS error from exception and writes log.
- */
-void CMainFrame::ShowVSSError(CException *e, const String& strItem)
-{
-       TCHAR errStr[1024] = {0};
-       if (e->GetErrorMessage(errStr, 1024))
-       {
-               String errMsg = theApp.LoadString(IDS_VSS_ERRORFROM);
-               String logMsg = errMsg;
-               errMsg += _T("\n");
-               errMsg += errStr;
-               logMsg += _T(" ");
-               logMsg += errStr;
-               if (!strItem.empty())
-               {
-                       errMsg += _T("\n\n");
-                       errMsg += strItem;
-                       logMsg += _T(": ");
-                       logMsg += strItem;
-               }
-               LogErrorString(logMsg);
-               AfxMessageBox(errMsg.c_str(), MB_ICONSTOP);
-       }
-       else
-       {
-               LogErrorString(_T("VSSError (unable to GetErrorMessage)"));
-               e->ReportError(MB_ICONSTOP, IDS_VSS_RUN_ERROR);
-       }
-}
-
-/**
- * @brief Show Help - this is for opening help from outside mainframe.
- * @param [in] helpLocation Location inside help, if NULL main help is opened.
- */
-void CMainFrame::ShowHelp(LPCTSTR helpLocation /*= NULL*/)
-{
-       if (helpLocation == NULL)
-       {
-               OnHelpContents();
-       }
-       else
-       {
-               String sPath = env_GetProgPath();
-               LANGID LangId = GetUserDefaultLangID();
-               if (PRIMARYLANGID(LangId) == LANG_JAPANESE)
-                       sPath += DocsPath_ja;
-               else
-                       sPath += DocsPath;
-               if (paths_DoesPathExist(sPath) == IS_EXISTING_FILE)
-               {
-                       sPath += helpLocation;
-                       ::HtmlHelp(NULL, sPath.c_str(), HH_DISPLAY_TOPIC, NULL);
-               }
-       }
-}
-
-/**
  * @brief Tell user why archive support is not available.
  */
 void CMainFrame::OnHelpMerge7zmismatch() 
@@ -2740,16 +2306,6 @@ LRESULT CMainFrame::OnUser1(WPARAM wParam, LPARAM lParam)
 }
 
 /**
- * @brief Send current option settings into codepage module
- */
-void CMainFrame::UpdateCodepageModule()
-{
-       // Get current codepage settings from the options module
-       // and push them into the codepage module
-       theApp.UpdateDefaultCodepage(GetOptionsMgr()->GetInt(OPT_CP_DEFAULT_MODE), GetOptionsMgr()->GetInt(OPT_CP_DEFAULT_CUSTOM));
-}
-
-/**
  * @brief Handle timer events.
  * @param [in] nIDEvent Timer that timed out.
  */
@@ -2824,64 +2380,6 @@ CMainFrame * GetMainFrame()
        return pMainframe;
 }
 
-/**
- * @brief Access to the singleton set of syntax colors
- */
-SyntaxColors * GetMainSyntaxColors()
-{
-       return GetMainFrame()->GetMainSyntaxColors();
-}
-
-/** 
- * @brief Move dialog to center of MainFrame
- */
-void CMainFrame::CenterToMainFrame(CDialog * dlg)
-{
-       CRect rectFrame;
-       CRect rectBar;
-       AfxGetMainWnd()->GetWindowRect(&rectFrame);
-       dlg->GetClientRect(&rectBar);
-       // Middlepoint of MainFrame
-       int x = rectFrame.left + (rectFrame.right - rectFrame.left) / 2;
-       int y = rectFrame.top + (rectFrame.bottom - rectFrame.top) / 2;
-       // Reduce by half of dialog's size
-       x -= rectBar.right / 2;
-       y -= rectBar.bottom / 2;
-
-       // This refreshes dialog size after m_constraint rezizing dialog so we get
-       // correct dialog positioning
-       dlg->CenterWindow();
-
-       // Calculate real desktop coordinates (if we have multiple monitors or
-       // virtual desktops
-       CRect dsk_rc;
-       dsk_rc.left = ::GetSystemMetrics(SM_XVIRTUALSCREEN);
-       dsk_rc.top = ::GetSystemMetrics(SM_YVIRTUALSCREEN);
-       dsk_rc.right = dsk_rc.left + ::GetSystemMetrics(SM_CXVIRTUALSCREEN);
-       dsk_rc.bottom = dsk_rc.top + ::GetSystemMetrics(SM_CYVIRTUALSCREEN);
-
-       // Only move Open-dialog if its fully visible in new position
-       CPoint ptLeftTop(x, y);
-       CPoint ptRightBottom(x + rectBar.right, y + rectBar.bottom);
-       if (dsk_rc.PtInRect(ptLeftTop) && dsk_rc.PtInRect(ptRightBottom))
-       {
-               dlg->SetWindowPos(&CWnd::wndTop, x, y, rectBar.right,
-                       rectBar.bottom, SWP_NOOWNERZORDER | SWP_NOSIZE );
-       }
-}
-
-/**
- * @brief Assign the main WinMerge 16x16 icon to dialog
- */
-void CMainFrame::SetMainIcon(CDialog * dlg)
-{
-       // Note: LoadImage gets shared icon, don't need to destroy
-       HICON hMergeIcon = (HICON) LoadImage(AfxGetInstanceHandle(),
-                       MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 16, 16,
-                       LR_DEFAULTSIZE | LR_SHARED);
-       dlg->SetIcon(hMergeIcon, TRUE);
-}
-
 /** 
  * @brief Opens dialog for user to Load, edit and save project files.
  * This dialog gets current compare paths and filter (+other properties
@@ -2927,7 +2425,7 @@ void CMainFrame::OnSaveProject()
                pathsDlg.m_bRightPathReadOnly = pDoc->GetReadOnly(pDoc->m_nDirs - 1);
        }
 
-       String filterNameOrMask = theApp.m_globalFileFilter.GetFilterNameOrMask();
+       String filterNameOrMask = theApp.m_pGlobalFileFilter->GetFilterNameOrMask();
        pathsDlg.m_sFilter = filterNameOrMask.c_str();
        sht.DoModal();
 }
@@ -3318,11 +2816,11 @@ BOOL CMainFrame::DoOpenConflict(const String& conflictFile, bool checked)
        {
                // Open two parsed files to WinMerge, telling WinMerge to
                // save over original file (given as third filename).
-               m_strSaveAsPath = conflictFile.c_str();
+               theApp.m_strSaveAsPath = conflictFile.c_str();
                String theirs = LoadResString(IDS_CONFLICT_THEIRS_FILE);
                String my = LoadResString(IDS_CONFLICT_MINE_FILE);
-               m_strDescriptions[0] = theirs;
-               m_strDescriptions[1] = my;
+               theApp.m_strDescriptions[0] = theirs;
+               theApp.m_strDescriptions[1] = my;
 
                DWORD dwFlags[2] = {FFILEOPEN_READONLY | FFILEOPEN_NOMRU, FFILEOPEN_NOMRU | FFILEOPEN_MODIFIED};
                conflictCompared = DoFileOpen(&PathContext(revFile, workFile), 
@@ -3340,7 +2838,7 @@ BOOL CMainFrame::DoOpenConflict(const String& conflictFile, bool checked)
  * @param [in] pFrame Pointer to frame to check.
  * @return FRAMETYPE of the given frame.
 */
-FRAMETYPE CMainFrame::GetFrameType(const CFrameWnd * pFrame) const
+CMainFrame::FRAMETYPE CMainFrame::GetFrameType(const CFrameWnd * pFrame) const
 {
        BOOL bMergeFrame = pFrame->IsKindOf(RUNTIME_CLASS(CChildFrame));
        BOOL bDirFrame = pFrame->IsKindOf(RUNTIME_CLASS(CDirFrame));
index 3d35158..23fe693 100644 (file)
 #include <boost/shared_ptr.hpp>
 #include "ToolBarXPThemes.h"
 #include "MDITabBar.h"
-#include "OptionsMgr.h"
-#include "VSSHelper.h"
 #include "PathContext.h"
-#include "MergeCmdLineInfo.h"
-
-/**
- * @brief Supported versioncontrol systems.
- */
-enum
-{
-       VCS_NONE = 0,
-       VCS_VSS4,
-       VCS_VSS5,
-       VCS_CLEARCASE,
-};
-
-/**
- * @brief Frame/View/Document types.
- */
-enum FRAMETYPE
-{
-       FRAME_FOLDER, /**< Folder compare frame. */
-       FRAME_FILE, /**< File compare frame. */
-       FRAME_OTHER, /**< No frame? */
-};
-
-enum { WM_NONINTERACTIVE = 888 }; // timer value
 
 class BCMenu;
 class CDiffView;
@@ -94,6 +68,18 @@ class CMainFrame : public CMDIFrameWnd
        friend CLanguageSelect;
        DECLARE_DYNAMIC(CMainFrame)
 public:
+       /**
+        * @brief Frame/View/Document types.
+        */
+       enum FRAMETYPE
+       {
+               FRAME_FOLDER, /**< Folder compare frame. */
+               FRAME_FILE, /**< File compare frame. */
+               FRAME_OTHER, /**< No frame? */
+       };
+
+       enum { WM_NONINTERACTIVE = 888 }; // timer value
+
        CMainFrame();
 
 // Attributes
@@ -113,7 +99,6 @@ public:
        HMENU GetPrediffersSubmenu(HMENU mainMenu);
        void UpdatePrediffersMenu();
 
-       BOOL SyncFileToVCS(const String& pszDest,       BOOL &bApplyToAll, String& psError);
        BOOL DoFileOpen(PathContext *pFiles = NULL,
                DWORD dwFlags[] = NULL, bool bRecurse = false, CDirDoc *pDirDoc = NULL, String prediffer = _T(""), PackingInfo * infoUnpacker = NULL);
        int ShowMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[],
@@ -121,26 +106,16 @@ public:
        void ShowHexMergeDoc(CDirDoc * pDirDoc,
                const PathContext &paths, bool bRO[]);
        void UpdateResources();
-       BOOL CreateBackup(BOOL bFolder, const String& pszPath);
-       int HandleReadonlySave(String& strSavePath, BOOL bMultiFile, BOOL &bApplyToAll);
        CString SetStatus(LPCTSTR status);
        void ClearStatusbarItemCount();
        void ApplyViewWhitespace();
        void SetEOLMixed(BOOL bAllow);
        void SelectFilter();
-       void ShowVSSError(CException *e, const String& strItem);
-       void ShowHelp(LPCTSTR helpLocation = NULL);
-       void UpdateCodepageModule();
-       void CheckinToClearCase(const String& strDestinationPath);
-       static void CenterToMainFrame(CDialog * dlg);
-       static void SetMainIcon(CDialog * dlg);
        void StartFlashing();
        bool AskCloseConfirmation();
        BOOL DoOpenConflict(const String& conflictFile, bool checked = false);
        FRAMETYPE GetFrameType(const CFrameWnd * pFrame) const;
 
-       static void OpenFileToExternalEditor(const String& file, int nLineNumber = 1);
-
 // Overrides
        virtual void GetMessageString(UINT nID, CString& rMessage) const;
        // ClassWizard generated virtual function overrides
@@ -155,50 +130,11 @@ public:
 // Implementation methods
 protected:
        virtual ~CMainFrame();
-// Implementation in SourceControl.cpp
-       void InitializeSourceControlMembers();
-       BOOL SaveToVersionControl(const String& strSavePath);
-// End SourceControl.cpp
-
 
 // Public implementation data
 public:
        BOOL m_bFirstTime; /**< If first time frame activated, get  pos from reg */
-       CString m_strSaveAsPath; /**< "3rd path" where output saved if given */
-       BOOL m_bEscShutdown; /**< If commandline switch -e given ESC closes appliction */
-       VSSHelper m_vssHelper; /**< Helper class for VSS integration */
-       SyntaxColors * GetMainSyntaxColors() { return m_pSyntaxColors.get(); }
-       BOOL m_bClearCaseTool; /**< WinMerge is executed as an external Rational ClearCase compare/merge tool. */
        BOOL m_bFlashing; /**< Window is flashing. */
-       MergeCmdLineInfo::ExitNoDiff m_bExitIfNoDiff; /**< Exit if files are identical? */
-       boost::scoped_ptr<LineFiltersList> m_pLineFilters; /**< List of linefilters */
-
-       /**
-        * @name Version Control System (VCS) integration.
-        */
-       /*@{*/ 
-protected:
-       CString m_strVssUser; /**< Visual Source Safe User ID */
-       CString m_strVssPassword; /**< Visual Source Safe Password */
-       CString m_strVssDatabase; /**< Visual Source Safe database */
-       CString m_strCCComment; /**< ClearCase comment */
-public:
-       BOOL m_bCheckinVCS;     /**< TRUE if files should be checked in after checkout */
-       BOOL m_CheckOutMulti; /**< Suppresses VSS int. code asking checkout for every file */
-       BOOL m_bVCProjSync; /**< VC project opened from VSS sync? */
-       BOOL m_bVssSuppressPathCheck; /**< Suppresses VSS int code asking about different path */
-       /*@}*/
-
-       /**
-        * @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];
-       /*@}*/
 
        /** @brief Possible toolbar image sizes. */
        enum TOOLBAR_SIZE
@@ -260,7 +196,6 @@ protected:
        static const MENUITEM_ICON m_MenuIcons[];
 
        boost::scoped_ptr<BCMenu> m_pMenus[MENU_COUNT]; /**< Menus for different views */
-       boost::scoped_ptr<SyntaxColors> m_pSyntaxColors; /**< Syntax color container */
        std::vector<TempFilePtr> m_tempFiles; /**< List of possibly needed temp files. */
 
 // Generated message map functions
@@ -356,7 +291,6 @@ private:
        CHexMergeDoc * GetHexMergeDocToShow(int nDirs, CDirDoc * pDirDoc, BOOL * pNew);
        CDirDoc * GetDirDocToShow(int nDirs, BOOL * pNew);
        void UpdateFont(FRAMETYPE frame);
-       void OpenFileOrUrl(LPCTSTR szFile, LPCTSTR szUrl);
        BOOL CreateToobar();
        CMergeEditView * GetActiveMergeEditView();
        void LoadToolbarImages();
@@ -364,7 +298,6 @@ private:
 };
 
 CMainFrame * GetMainFrame(); // access to the singleton main frame object
-SyntaxColors * GetMainSyntaxColors(); // access to the singleton set of syntax colors
 
 /////////////////////////////////////////////////////////////////////////////
 
index 993bf7b..6596cb0 100644 (file)
 // $Id: Merge.cpp 6861 2009-06-25 12:11:07Z kimmov $
 
 #include "stdafx.h"
+#include "Merge.h"
 #include "Constants.h"
 #include "UnicodeString.h"
 #include "unicoder.h"
 #include "Environment.h"
 #include "OptionsMgr.h"
-#include "Merge.h"
+#include "RegOptionsMgr.h"
 #include "OpenDoc.h"
 #include "OpenFrm.h"
 #include "OpenView.h"
 #include "DirDoc.h"
 #include "DirView.h"
 #include "Splash.h"
+#include "PropBackups.h"
+#include "FileOrFolderSelect.h"
 #include "paths.h"
 #include "FileFilterHelper.h"
+#include "LineFiltersList.h"
+#include "SyntaxColors.h"
+#include "OptionsSyntaxColors.h"
 #include "Plugins.h"
 #include "ProjectFile.h"
 #include "MergeEditView.h"
@@ -59,6 +65,9 @@
 #include "ConflictFileParser.h"
 #include "codepage.h"
 #include "JumpList.h"
+#include "stringdiffs.h"
+#include "TFile.h"
+#include "VSSHelper.h"
 
 // For shutdown cleanup
 #include "charsets.h"
@@ -77,6 +86,9 @@ static TCHAR CommandLineHelpLocation[] = _T("::/htmlhelp/Command_line.html");
 // registry dir to WinMerge
 static String f_RegDir = _T("Software\\Thingamahoochie\\WinMerge");
 
+/** @brief Backup file extension. */
+static const TCHAR BACKUP_FILE_EXT[] = _T("bak");
+
 #ifndef WIN64
 /**
  * @brief Turn STL exceptions into MFC exceptions.
@@ -188,8 +200,18 @@ CMergeApp::CMergeApp() :
 , m_nLastCompareResult(0)
 , m_bNonInteractive(false)
 , m_pOptions(new CRegOptionsMgr())
+, m_pGlobalFileFilter(new FileFilterHelper())
 , m_nActiveOperations(0)
 , m_pLangDlg(new CLanguageSelect(IDR_MAINFRAME, IDR_MAINFRAME))
+, m_bEscShutdown(FALSE)
+, m_bClearCaseTool(FALSE)
+, m_bExitIfNoDiff(MergeCmdLineInfo::Disabled)
+, m_pLineFilters(new LineFiltersList())
+, m_pSyntaxColors(new SyntaxColors())
+, m_pVssHelper(new VSSHelper())
+, m_CheckOutMulti(FALSE)
+, m_bVCProjSync(FALSE)
+, m_bVssSuppressPathCheck(FALSE)
 {
        // add construction code here,
        // Place all significant initialization in InitInstance
@@ -197,6 +219,7 @@ CMergeApp::CMergeApp() :
 
 CMergeApp::~CMergeApp()
 {
+       sd_Close();
 }
 /////////////////////////////////////////////////////////////////////////////
 // The one and only CMergeApp object
@@ -340,13 +363,47 @@ BOOL CMergeApp::InitInstance()
        // Read last used filter from registry
        // If filter fails to set, reset to default
        const String filterString = m_pOptions->GetString(OPT_FILEFILTER_CURRENT);
-       BOOL bFilterSet = theApp.m_globalFileFilter.SetFilter(filterString.c_str());
+       BOOL bFilterSet = m_pGlobalFileFilter->SetFilter(filterString.c_str());
        if (!bFilterSet)
        {
-               String filter = theApp.m_globalFileFilter.GetFilterNameOrMask();
+               String filter = m_pGlobalFileFilter->GetFilterNameOrMask();
                m_pOptions->SaveOption(OPT_FILEFILTER_CURRENT, filter);
        }
 
+       UpdateCodepageModule();
+
+       InitializeSourceControlMembers();
+       g_bUnpackerMode = theApp.GetProfileInt(_T("Settings"), _T("UnpackerMode"), PLUGIN_MANUAL);
+       g_bPredifferMode = theApp.GetProfileInt(_T("Settings"), _T("PredifferMode"), PLUGIN_MANUAL);
+
+       if (m_pSyntaxColors)
+               Options::SyntaxColors::Load(m_pSyntaxColors.get());
+
+       if (m_pLineFilters)
+               m_pLineFilters->Initialize(GetOptionsMgr());
+
+       // If there are no filters loaded, and there is filter string in previous
+       // option string, import old filters to new place.
+       if (m_pLineFilters->GetCount() == 0)
+       {
+               String oldFilter = theApp.GetProfileString(_T("Settings"), _T("RegExps"));
+               if (!oldFilter.empty())
+                       m_pLineFilters->Import(oldFilter);
+       }
+
+       // Check if filter folder is set, and create it if not
+       String pathMyFolders = GetOptionsMgr()->GetString(OPT_FILTER_USERPATH);
+       if (pathMyFolders.empty())
+       {
+               // No filter path, set it to default and make sure it exists.
+               String pathFilters = GetDefaultFilterUserPath(TRUE);
+               GetOptionsMgr()->SaveOption(OPT_FILTER_USERPATH, pathFilters);
+               theApp.m_pGlobalFileFilter->SetFileFilterPath(pathFilters.c_str());
+       }
+
+       sd_Init(); // String diff init
+       sd_SetBreakChars(GetOptionsMgr()->GetString(OPT_BREAK_SEPARATORS).c_str());
+
        CSplashWnd::EnableSplashScreen(!bDisableSplash && !bCommandLineInvoke);
 
        // Initialize i18n (multiple language) support
@@ -601,9 +658,9 @@ void CMergeApp::InitializeFileFilters()
 
        if (!filterPath.IsEmpty())
        {
-               m_globalFileFilter.SetUserFilterPath((LPCTSTR)filterPath);
+               m_pGlobalFileFilter->SetUserFilterPath((LPCTSTR)filterPath);
        }
-       m_globalFileFilter.LoadAllFileFilters();
+       m_pGlobalFileFilter->LoadAllFileFilters();
 }
 
 /** @brief Read command line arguments and open files for comparison.
@@ -623,7 +680,7 @@ BOOL CMergeApp::ParseArgsAndDoOpen(MergeCmdLineInfo& cmdInfo, CMainFrame* pMainF
        // Set the global file filter.
        if (!cmdInfo.m_sFileFilter.empty())
        {
-               m_globalFileFilter.SetFilter(cmdInfo.m_sFileFilter.c_str());
+               m_pGlobalFileFilter->SetFilter(cmdInfo.m_sFileFilter.c_str());
        }
 
        // Set codepage.
@@ -636,27 +693,27 @@ BOOL CMergeApp::ParseArgsAndDoOpen(MergeCmdLineInfo& cmdInfo, CMainFrame* pMainF
        // comparison.
        if (cmdInfo.m_bShowUsage)
        {
-               pMainFrame->ShowHelp(CommandLineHelpLocation);
+               ShowHelp(CommandLineHelpLocation);
        }
        else
        {
                // Set the required information we need from the command line:
 
-               pMainFrame->m_bClearCaseTool = cmdInfo.m_bClearCaseTool;
-               pMainFrame->m_bExitIfNoDiff = cmdInfo.m_bExitIfNoDiff;
-               pMainFrame->m_bEscShutdown = cmdInfo.m_bEscShutdown;
+               m_bClearCaseTool = cmdInfo.m_bClearCaseTool;
+               m_bExitIfNoDiff = cmdInfo.m_bExitIfNoDiff;
+               m_bEscShutdown = cmdInfo.m_bEscShutdown;
 
-               pMainFrame->m_strSaveAsPath = cmdInfo.m_sOutputpath.c_str();
+               m_strSaveAsPath = cmdInfo.m_sOutputpath.c_str();
 
-               pMainFrame->m_strDescriptions[0] = cmdInfo.m_sLeftDesc;
+               m_strDescriptions[0] = cmdInfo.m_sLeftDesc;
                if (cmdInfo.m_Files.GetSize() < 3)
                {
-                       pMainFrame->m_strDescriptions[1] = cmdInfo.m_sRightDesc;
+                       m_strDescriptions[1] = cmdInfo.m_sRightDesc;
                }
                else
                {
-                       pMainFrame->m_strDescriptions[1] = cmdInfo.m_sMiddleDesc;
-                       pMainFrame->m_strDescriptions[2] = cmdInfo.m_sRightDesc;
+                       m_strDescriptions[1] = cmdInfo.m_sMiddleDesc;
+                       m_strDescriptions[2] = cmdInfo.m_sRightDesc;
                }
 
                if (cmdInfo.m_Files.GetSize() > 2)
@@ -716,7 +773,7 @@ void CMergeApp::UpdateDefaultCodepage(int cpDefaultMode, int cpCustomCodepage)
                        break;
                case 1:
                        TCHAR buff[32];
-                       wLangId = theApp.GetLangId();
+                       wLangId = GetLangId();
                        if (GetLocaleInfo(wLangId, LOCALE_IDEFAULTANSICODEPAGE, buff, sizeof(buff)/sizeof(buff[0])))
                                ucr::setDefaultCodepage(_ttol(buff));
                        else
@@ -732,11 +789,398 @@ void CMergeApp::UpdateDefaultCodepage(int cpDefaultMode, int cpCustomCodepage)
        }
 }
 
+/**
+ * @brief Send current option settings into codepage module
+ */
+void CMergeApp::UpdateCodepageModule()
+{
+       // Get current codepage settings from the options module
+       // and push them into the codepage module
+       UpdateDefaultCodepage(GetOptionsMgr()->GetInt(OPT_CP_DEFAULT_MODE), GetOptionsMgr()->GetInt(OPT_CP_DEFAULT_CUSTOM));
+}
 
 /** @brief Open help from mainframe when user presses F1*/
 void CMergeApp::OnHelp()
 {
-       GetMainFrame()->ShowHelp();
+       ShowHelp();
+}
+
+/**
+ * @brief Open given file to external editor specified in options.
+ * @param [in] file Full path to file to open.
+ *
+ * Opens file to defined (in Options/system), Notepad by default,
+ * external editor. Path is decorated with quotation marks if needed
+ * (contains spaces). Also '$file' in editor path is replaced by
+ * filename to open.
+ * @param [in] file Full path to file to open.
+ * @param [in] nLineNumber Line number to go to.
+ */
+void CMergeApp::OpenFileToExternalEditor(const String& file, int nLineNumber/* = 1*/)
+{
+       String sCmd = GetOptionsMgr()->GetString(OPT_EXT_EDITOR_CMD);
+       String sFile(file);
+       string_replace(sCmd, _T("$linenum"), string_format(_T("%d"), nLineNumber));
+
+       int nIndex = sCmd.find(_T("$file"));
+       if (nIndex > -1)
+       {
+               sFile.insert(0, _T("\""));
+               string_replace(sCmd, _T("$file"), sFile);
+               nIndex = sCmd.find(' ', nIndex + sFile.length());
+               if (nIndex > -1)
+                       sCmd.insert(nIndex, _T("\""));
+               else
+                       sCmd += '"';
+       }
+       else
+       {
+               sCmd += _T(" \"");
+               sCmd += sFile;
+               sCmd += _T("\"");
+       }
+
+       BOOL retVal = FALSE;
+       STARTUPINFO stInfo = {0};
+       stInfo.cb = sizeof(STARTUPINFO);
+       PROCESS_INFORMATION processInfo;
+
+       retVal = CreateProcess(NULL, (LPTSTR)sCmd.c_str(),
+               NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE, NULL, NULL,
+               &stInfo, &processInfo);
+
+       if (!retVal)
+       {
+               // Error invoking external editor
+               ResMsgBox1(IDS_ERROR_EXECUTE_FILE, sCmd.c_str(), MB_ICONSTOP);
+       }
+       else
+       {
+               CloseHandle(processInfo.hThread);
+               CloseHandle(processInfo.hProcess);
+       }
+}
+
+/**
+ * @brief Open file, if it exists, else open url
+ */
+void CMergeApp::OpenFileOrUrl(LPCTSTR szFile, LPCTSTR szUrl)
+{
+       if (paths_DoesPathExist(szFile) == IS_EXISTING_FILE)
+               ShellExecute(NULL, _T("open"), _T("notepad.exe"), szFile, NULL, SW_SHOWNORMAL);
+       else
+               ShellExecute(NULL, _T("open"), szUrl, NULL, NULL, SW_SHOWNORMAL);
+}
+
+/**
+ * @brief Show Help - this is for opening help from outside mainframe.
+ * @param [in] helpLocation Location inside help, if NULL main help is opened.
+ */
+void CMergeApp::ShowHelp(LPCTSTR helpLocation /*= NULL*/)
+{
+       String sPath = env_GetProgPath();
+       LANGID LangId = GetLangId();
+       if (PRIMARYLANGID(LangId) == LANG_JAPANESE)
+               sPath += DocsPath_ja;
+       else
+               sPath += DocsPath;
+       if (helpLocation == NULL)
+       {
+               if (paths_DoesPathExist(sPath) == IS_EXISTING_FILE)
+                       ::HtmlHelp(NULL, sPath.c_str(), HH_DISPLAY_TOC, NULL);
+               else
+                       ShellExecute(NULL, _T("open"), DocsURL, NULL, NULL, SW_SHOWNORMAL);
+       }
+       else
+       {
+               if (paths_DoesPathExist(sPath) == IS_EXISTING_FILE)
+               {
+                       sPath += helpLocation;
+                       ::HtmlHelp(NULL, sPath.c_str(), HH_DISPLAY_TOPIC, NULL);
+               }
+       }
+}
+
+/**
+ * @brief Creates backup before file is saved or copied over.
+ * This function handles formatting correct path and filename for
+ * backup file. Formatting is done based on several options available
+ * for users in Options/Backups dialog. After path is formatted, file
+ * is simply just copied. Not much error checking, just if copying
+ * succeeded or failed.
+ * @param [in] bFolder Are we creating backup in folder compare?
+ * @param [in] pszPath Full path to file to backup.
+ * @return TRUE if backup succeeds, or isn't just done.
+ */
+BOOL CMergeApp::CreateBackup(BOOL bFolder, const String& pszPath)
+{
+       // If user doesn't want to backups in folder compare, return
+       // success so operations don't abort.
+       if (bFolder && !(GetOptionsMgr()->GetBool(OPT_BACKUP_FOLDERCMP)))
+               return TRUE;
+       // Likewise if user doesn't want backups in file compare
+       else if (!bFolder && !(GetOptionsMgr()->GetBool(OPT_BACKUP_FILECMP)))
+               return TRUE;
+
+       // create backup copy of file if destination file exists
+       if (paths_DoesPathExist(pszPath) == IS_EXISTING_FILE)
+       {
+               String bakPath;
+               String path;
+               String filename;
+               String ext;
+       
+               paths_SplitFilename(pszPath, &path, &filename, &ext);
+
+               // Determine backup folder
+               if (GetOptionsMgr()->GetInt(OPT_BACKUP_LOCATION) ==
+                       PropBackups::FOLDER_ORIGINAL)
+               {
+                       // Put backups to same folder than original file
+                       bakPath = path;
+               }
+               else if (GetOptionsMgr()->GetInt(OPT_BACKUP_LOCATION) ==
+                       PropBackups::FOLDER_GLOBAL)
+               {
+                       // Put backups to global folder defined in options
+                       bakPath = GetOptionsMgr()->GetString(OPT_BACKUP_GLOBALFOLDER);
+                       if (bakPath.empty())
+                               bakPath = path;
+                       else
+                               bakPath = paths_GetLongPath(bakPath);
+               }
+               else
+               {
+                       _RPTF0(_CRT_ERROR, "Unknown backup location!");
+               }
+
+               BOOL success = FALSE;
+               if (GetOptionsMgr()->GetBool(OPT_BACKUP_ADD_BAK))
+               {
+                       // Don't add dot if there is no existing extension
+                       if (ext.size() > 0)
+                               ext += _T(".");
+                       ext += BACKUP_FILE_EXT;
+               }
+
+               // Append time to filename if wanted so
+               // NOTE just adds timestamp at the moment as I couldn't figure out
+               // nice way to add a real time (invalid chars etc).
+               if (GetOptionsMgr()->GetBool(OPT_BACKUP_ADD_TIME))
+               {
+                       struct tm *tm;
+                       time_t curtime = 0;
+                       time(&curtime);
+                       tm = localtime(&curtime);
+                       CString timestr;
+                       timestr.Format(_T("%04d%02d%02d%02d%02d%02d"), tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
+                       filename += _T("-");
+                       filename += timestr;
+               }
+
+               // Append filename and extension (+ optional .bak) to path
+               if ((bakPath.length() + filename.length() + ext.length())
+                       < MAX_PATH)
+               {
+                       success = TRUE;
+                       if (!paths_EndsWithSlash(bakPath))
+                               bakPath += _T("\\");
+                       bakPath = paths_ConcatPath(bakPath, filename);
+                       bakPath += _T(".");
+                       bakPath += ext;
+               }
+
+               if (success)
+                       success = CopyFile(pszPath.c_str(), bakPath.c_str(), FALSE);
+               
+               if (!success)
+               {
+                       if (ResMsgBox1(IDS_BACKUP_FAILED_PROMPT, pszPath.c_str(),
+                                       MB_YESNO | MB_ICONWARNING | MB_DONT_ASK_AGAIN, 
+                                       IDS_BACKUP_FAILED_PROMPT) != IDYES)
+                               return FALSE;
+               }
+               return TRUE;
+       }
+
+       // we got here because we're either not backing up of there was nothing to backup
+       return TRUE;
+}
+
+/**
+ * @brief Sync file to Version Control System
+ * @param pszDest [in] Where to copy (incl. filename)
+ * @param bApplyToAll [in,out] Apply user selection to all items
+ * @param psError [out] Error string that can be shown to user in caller func
+ * @return User selection or -1 if error happened
+ * @sa CMainFrame::HandleReadonlySave()
+ * @sa CDirView::PerformActionList()
+ */
+int CMergeApp::SyncFileToVCS(const String& pszDest, BOOL &bApplyToAll,
+       String& sError)
+{
+       String sActionError;
+       String strSavePath(pszDest);
+       int nVerSys = 0;
+
+       nVerSys = GetOptionsMgr()->GetInt(OPT_VCS_SYSTEM);
+       
+       int nRetVal = HandleReadonlySave(strSavePath, TRUE, bApplyToAll);
+       if (nRetVal == IDCANCEL || nRetVal == IDNO)
+               return nRetVal;
+       
+       // If VC project opened from VSS sync and version control used
+       if ((nVerSys == VCS_VSS4 || nVerSys == VCS_VSS5) && m_bVCProjSync)
+       {
+               if (!m_pVssHelper->ReLinkVCProj(strSavePath, sError))
+                       nRetVal = -1;
+       }
+       return nRetVal;
+}
+
+/**
+ * @brief Checks if path (file/folder) is read-only and asks overwriting it.
+ *
+ * @param strSavePath [in,out] Path where to save (file or folder)
+ * @param bMultiFile [in] Single file or multiple files/folder
+ * @param bApplyToAll [in,out] Apply last user selection for all items?
+ * @return Users selection:
+ * - IDOK: Item was not readonly, no actions
+ * - IDYES/IDYESTOALL: Overwrite readonly item
+ * - IDNO: User selected new filename (single file) or user wants to skip
+ * - IDCANCEL: Cancel operation
+ * @sa CMainFrame::SyncFileToVCS()
+ * @sa CMergeDoc::DoSave()
+ */
+int CMergeApp::HandleReadonlySave(String& strSavePath, BOOL bMultiFile,
+               BOOL &bApplyToAll)
+{
+       CFileStatus status;
+       UINT userChoice = 0;
+       int nRetVal = IDOK;
+       BOOL bFileRO = FALSE;
+       BOOL bFileExists = FALSE;
+       String s;
+       String str;
+       CString title;
+       int nVerSys = 0;
+
+       try
+       {
+               TFile file(strSavePath);
+               bFileExists = file.exists();
+               if (bFileExists)
+                       bFileRO = !file.canWrite();
+       }
+       catch (...)
+       {
+       }
+       nVerSys = GetOptionsMgr()->GetInt(OPT_VCS_SYSTEM);
+       
+       if (bFileExists && bFileRO)
+       {
+               // Version control system used?
+               // Checkout file from VCS and modify, don't ask about overwriting
+               // RO files etc.
+               if (nVerSys != VCS_NONE)
+               {
+                       BOOL bRetVal = SaveToVersionControl(strSavePath);
+                       if (bRetVal)
+                               return IDYES;
+                       else
+                               return IDCANCEL;
+               }
+               
+               // Don't ask again if its already asked
+               if (bApplyToAll)
+                       userChoice = IDYES;
+               else
+               {
+                       // Prompt for user choice
+                       if (bMultiFile)
+                       {
+                               // Multiple files or folder
+                               str = LangFormatString1(IDS_SAVEREADONLY_MULTI, strSavePath.c_str());
+                               userChoice = AfxMessageBox(str.c_str(), MB_YESNOCANCEL |
+                                               MB_ICONWARNING | MB_DEFBUTTON3 | MB_DONT_ASK_AGAIN |
+                                               MB_YES_TO_ALL, IDS_SAVEREADONLY_MULTI);
+                       }
+                       else
+                       {
+                               // Single file
+                               str = LangFormatString1(IDS_SAVEREADONLY_FMT, strSavePath.c_str());
+                               userChoice = AfxMessageBox(str.c_str(), MB_YESNOCANCEL |
+                                               MB_ICONWARNING | MB_DEFBUTTON2 | MB_DONT_ASK_AGAIN,
+                                               IDS_SAVEREADONLY_FMT);
+                       }
+               }
+               switch (userChoice)
+               {
+               // Overwrite read-only file
+               case IDYESTOALL:
+                       bApplyToAll = TRUE;  // Don't ask again (no break here)
+               case IDYES:
+                       CFile::GetStatus(strSavePath.c_str(), status);
+                       status.m_mtime = 0;             // Avoid unwanted changes
+                       status.m_attribute &= ~CFile::readOnly;
+                       CFile::SetStatus(strSavePath.c_str(), status);
+                       nRetVal = IDYES;
+                       break;
+               
+               // Save to new filename (single) /skip this item (multiple)
+               case IDNO:
+                       if (!bMultiFile)
+                       {
+                               if (SelectFile(AfxGetMainWnd()->GetSafeHwnd(), s, strSavePath.c_str(), IDS_SAVE_AS_TITLE, NULL, FALSE))
+                               {
+                                       strSavePath = s;
+                                       nRetVal = IDNO;
+                               }
+                               else
+                                       nRetVal = IDCANCEL;
+                       }
+                       else
+                               nRetVal = IDNO;
+                       break;
+
+               // Cancel saving
+               case IDCANCEL:
+                       nRetVal = IDCANCEL;
+                       break;
+               }
+       }
+       return nRetVal;
+}
+
+/**
+ * @brief Shows VSS error from exception and writes log.
+ */
+void CMergeApp::ShowVSSError(CException *e, const String& strItem)
+{
+       TCHAR errStr[1024] = {0};
+       if (e->GetErrorMessage(errStr, 1024))
+       {
+               String errMsg = theApp.LoadString(IDS_VSS_ERRORFROM);
+               String logMsg = errMsg;
+               errMsg += _T("\n");
+               errMsg += errStr;
+               logMsg += _T(" ");
+               logMsg += errStr;
+               if (!strItem.empty())
+               {
+                       errMsg += _T("\n\n");
+                       errMsg += strItem;
+                       logMsg += _T(": ");
+                       logMsg += strItem;
+               }
+               LogErrorString(logMsg);
+               AfxMessageBox(errMsg.c_str(), MB_ICONSTOP);
+       }
+       else
+       {
+               LogErrorString(_T("VSSError (unable to GetErrorMessage)"));
+               e->ReportError(MB_ICONSTOP, IDS_VSS_RUN_ERROR);
+       }
 }
 
 /**
@@ -765,7 +1209,7 @@ bool CMergeApp::LoadProjectFile(const String& sProject, ProjectFile &project)
        }
        catch (Poco::Exception& e)
        {
-               String sErr = theApp.LoadString(IDS_UNK_ERROR_READING_PROJECT);
+               String sErr = LoadString(IDS_UNK_ERROR_READING_PROJECT);
                sErr += ucr::toTString(e.displayText());
                String msg = LangFormatString2(IDS_ERROR_FILEOPEN, sProject.c_str(), sErr.c_str());
                AfxMessageBox(msg.c_str(), MB_ICONSTOP);
@@ -783,7 +1227,7 @@ bool CMergeApp::SaveProjectFile(const String& sProject, const ProjectFile &proje
        }
        catch (Poco::Exception& e)
        {
-               String sErr = theApp.LoadString(IDS_UNK_ERROR_SAVING_PROJECT);
+               String sErr = LoadString(IDS_UNK_ERROR_SAVING_PROJECT);
                sErr += ucr::toTString(e.displayText());
                String msg = LangFormatString2(IDS_ERROR_FILEOPEN, sProject.c_str(), sErr.c_str());
                AfxMessageBox(msg.c_str(), MB_ICONSTOP);
@@ -817,7 +1261,7 @@ bool CMergeApp::LoadAndOpenProjectFile(const String& sProject)
        {
                String filter = project.GetFilter();
                filter = string_trim_ws(filter);
-               m_globalFileFilter.SetFilter(filter);
+               m_pGlobalFileFilter->SetFilter(filter);
        }
        if (project.HasSubfolders())
                bRecursive = project.GetSubfolders() > 0;
index df27d60..dea1ef6 100644 (file)
 #endif
 
 #include <boost/scoped_ptr.hpp>
+#include "MergeCmdLineInfo.h"
 #include "resource.h"       // main symbols
-#include "MergeApp.h"
-#include "MergeDoc.h"
-#include "OptionsMgr.h"
-#include "RegOptionsMgr.h"
-#include "FileFilterHelper.h"
 
 struct FileFilter;
+class FileFilterHelper;
 class CAssureScriptsForThread;
 class CMainFrame;
 class CLanguageSelect;
 class MergeCmdLineInfo;
 class ProjectFile;
+class COptionsMgr;
+class LineFiltersList;
+class SyntaxColors;
+class VSSHelper;
 
 /////////////////////////////////////////////////////////////////////////////
 // CMergeApp:
@@ -55,6 +56,17 @@ class ProjectFile;
 
 enum { IDLE_TIMER = 9754 };
 
+/**
+ * @brief Supported versioncontrol systems.
+ */
+enum
+{
+       VCS_NONE = 0,
+       VCS_VSS4,
+       VCS_VSS5,
+       VCS_CLEARCASE,
+};
+
 /** 
  * @brief WinMerge application class
  */
@@ -67,7 +79,42 @@ public:
        CMultiDocTemplate* m_pHexMergeTemplate;
        CMultiDocTemplate* m_pDirTemplate;
        boost::scoped_ptr<CLanguageSelect> m_pLangDlg;
-       FileFilterHelper m_globalFileFilter;
+       boost::scoped_ptr<FileFilterHelper> m_pGlobalFileFilter;
+       boost::scoped_ptr<SyntaxColors> m_pSyntaxColors; /**< Syntax color container */
+       boost::scoped_ptr<VSSHelper> m_pVssHelper; /**< Helper class for VSS integration */
+       CString m_strSaveAsPath; /**< "3rd path" where output saved if given */
+       BOOL m_bEscShutdown; /**< If commandline switch -e given ESC closes appliction */
+       SyntaxColors * GetMainSyntaxColors() { return m_pSyntaxColors.get(); }
+       BOOL m_bClearCaseTool; /**< WinMerge is executed as an external Rational ClearCase compare/merge tool. */
+       MergeCmdLineInfo::ExitNoDiff m_bExitIfNoDiff; /**< Exit if files are identical? */
+       boost::scoped_ptr<LineFiltersList> m_pLineFilters; /**< List of linefilters */
+
+       /**
+        * @name Version Control System (VCS) integration.
+        */
+       /*@{*/ 
+protected:
+       CString m_strVssUser; /**< Visual Source Safe User ID */
+       CString m_strVssPassword; /**< Visual Source Safe Password */
+       CString m_strVssDatabase; /**< Visual Source Safe database */
+       CString m_strCCComment; /**< ClearCase comment */
+public:
+       BOOL m_bCheckinVCS;     /**< TRUE if files should be checked in after checkout */
+       BOOL m_CheckOutMulti; /**< Suppresses VSS int. code asking checkout for every file */
+       BOOL m_bVCProjSync; /**< VC project opened from VSS sync? */
+       BOOL m_bVssSuppressPathCheck; /**< Suppresses VSS int code asking about different path */
+       /*@}*/
+
+       /**
+        * @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;
@@ -87,9 +134,22 @@ public:
        String GetDefaultFilterUserPath(BOOL bCreate = FALSE);
 
        COptionsMgr * GetMergeOptionsMgr() { return static_cast<COptionsMgr *> (m_pOptions.get()); }
+       FileFilterHelper * GetGlobalFileFilter() { return m_pGlobalFileFilter.get(); }
        void OptionsInit();
        void ResetOptions() { OptionsInit(); }
        void SetFontDefaults();
+       void ShowHelp(LPCTSTR helpLocation = NULL);
+       void OpenFileToExternalEditor(const String& file, int nLineNumber = 1);
+       void OpenFileOrUrl(LPCTSTR szFile, LPCTSTR szUrl);
+       void ShowVSSError(CException *e, const String& strItem);
+       void CheckinToClearCase(const String& strDestinationPath);
+// Implementation in SourceControl.cpp
+       void InitializeSourceControlMembers();
+       BOOL SaveToVersionControl(const String& strSavePath);
+// End SourceControl.cpp
+       BOOL CreateBackup(BOOL bFolder, const String& pszPath);
+       int HandleReadonlySave(String& strSavePath, BOOL bMultiFile, BOOL &bApplyToAll);
+       BOOL SyncFileToVCS(const String& pszDest,       BOOL &bApplyToAll, String& psError);
 
 // Implementation
 protected:
@@ -108,6 +168,7 @@ protected:
        void InitializeFileFilters();
        BOOL ParseArgsAndDoOpen(MergeCmdLineInfo& cmdInfo, CMainFrame* pMainFrame);
        void UpdateDefaultCodepage(int cpDefaultMode, int cpCustomCodepage);
+       void UpdateCodepageModule();
 
        // End MergeArgs.cpp
 
@@ -152,7 +213,7 @@ protected:
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
 private:
-       boost::scoped_ptr<CRegOptionsMgr> m_pOptions;
+       boost::scoped_ptr<COptionsMgr> m_pOptions;
        CAssureScriptsForThread * m_mainThreadScripts;
        int m_nLastCompareResult;
        bool m_bNonInteractive;
index 19fb55f..928fda6 100644 (file)
     <ClCompile Include="FolderCmp.cpp">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="LineFiltersList.cpp">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
     <ClCompile Include="locality.cpp">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
     <ClCompile Include="Splash.cpp">\r
       <Filter>MFCGui\Source Files</Filter>\r
     </ClCompile>\r
+    <ClCompile Include="LineFiltersList.cpp">\r
+      <Filter>MFCGui\Source Files</Filter>\r
+    </ClCompile>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClInclude Include="charsets.h">\r
     <ClInclude Include="FileOrFolderSelect.h">\r
       <Filter>MFCGui\Header Files</Filter>\r
     </ClInclude>\r
-    <ClInclude Include="7zCommon.h">\r
-      <Filter>MFCGui\Header Files</Filter>\r
-    </ClInclude>\r
     <ClInclude Include="BCMenu.h">\r
       <Filter>MFCGui\Header Files</Filter>\r
     </ClInclude>\r
     <ClInclude Include="Common\DragDrop.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="7zCommon.h">\r
+      <Filter>MFCGui\Source Files</Filter>\r
+    </ClInclude>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <None Include="res\binarydiff.ico">\r
index cc18e94..6da8673 100644 (file)
@@ -1,6 +1,7 @@
 #include "StdAfx.h"
 #include "MergeApp.h"
 #include "Merge.h"
+#include "unicoder.h"
 
 // Get user language description of error, if available
 String GetSysError(int nerr /* =-1 */)
index ead3af0..b31663e 100644 (file)
@@ -4,6 +4,7 @@
 #include "UnicodeString.h"
 
 class COptionsMgr;
+class FileFilterHelper;
 
 /** @brief Retrieve error description from Windows; uses FormatMessage */
 String GetSysError(int nerr = -1);
index e2fc7e7..f3e6e21 100644 (file)
 // $Id: MergeDoc.cpp 7107 2010-01-14 21:43:14Z kimmov $
 
 #include "StdAfx.h"
+#include "MergeDoc.h"
 #include <shlwapi.h>           // PathCompactPathEx()
 #include <io.h>
 #include <Poco/Timestamp.h>
+#include <Poco/Exception.h>
 #include "UnicodeString.h"
 #include "Merge.h"
 #include "MainFrm.h"
@@ -63,7 +65,6 @@
 #include "EncodingErrorBar.h"
 #include "MergeCmdLineInfo.h"
 #include "TFile.h"
-#include <Poco/Exception.h>
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -418,7 +419,7 @@ int CMergeDoc::Rescan(bool &bBinary, IDENTLEVEL &identical,
 
        if (GetOptionsMgr()->GetBool(OPT_LINEFILTER_ENABLED))
        {
-               m_diffWrapper.SetFilterList(GetMainFrame()->m_pLineFilters->GetAsString());
+               m_diffWrapper.SetFilterList(theApp.m_pLineFilters->GetAsString());
        }
        else
        {
@@ -783,7 +784,7 @@ void CMergeDoc::ShowRescanError(int nRescanResult, IDENTLEVEL identical)
                {
                        UINT nFlags = MB_ICONINFORMATION | MB_DONT_DISPLAY_AGAIN;
 
-                       if (GetMainFrame()->m_bExitIfNoDiff == MergeCmdLineInfo::Exit)
+                       if (theApp.m_bExitIfNoDiff == MergeCmdLineInfo::Exit)
                        {
                                // Show the "files are identical" for basic "exit no diff" flag
                                // If user don't want to see the message one uses the quiet version
@@ -791,14 +792,14 @@ void CMergeDoc::ShowRescanError(int nRescanResult, IDENTLEVEL identical)
                                nFlags &= ~MB_DONT_DISPLAY_AGAIN;
                        }
 
-                       if (GetMainFrame()->m_bExitIfNoDiff != MergeCmdLineInfo::ExitQuiet)
+                       if (theApp.m_bExitIfNoDiff != MergeCmdLineInfo::ExitQuiet)
                                LangMessageBox(IDS_FILESSAME, nFlags);
 
                        // Exit application if files are identical.
-                       if (GetMainFrame()->m_bExitIfNoDiff == MergeCmdLineInfo::Exit ||
-                               GetMainFrame()->m_bExitIfNoDiff == MergeCmdLineInfo::ExitQuiet)
+                       if (theApp.m_bExitIfNoDiff == MergeCmdLineInfo::Exit ||
+                               theApp.m_bExitIfNoDiff == MergeCmdLineInfo::ExitQuiet)
                        {
-                               GetMainFrame()->PostMessage(WM_COMMAND, ID_APP_EXIT);
+                               AfxGetMainWnd()->PostMessage(WM_COMMAND, ID_APP_EXIT);
                        }
                }
        }
@@ -1341,27 +1342,27 @@ bool CMergeDoc::DoSave(LPCTSTR szPath, bool &bSaveSuccess, int nBuffer)
        bSaveSuccess = false;
        
        // Check third arg possibly given from command-line
-       if (!GetMainFrame()->m_strSaveAsPath.IsEmpty())
+       if (!theApp.m_strSaveAsPath.IsEmpty())
        {
-               if (paths_DoesPathExist((const TCHAR *)GetMainFrame()->m_strSaveAsPath) == IS_EXISTING_DIR)
+               if (paths_DoesPathExist((const TCHAR *)theApp.m_strSaveAsPath) == IS_EXISTING_DIR)
                {
                        // third arg was a directory, so get append the filename
                        String sname;
                        paths_SplitFilename(szPath, 0, &sname, 0);
-                       strSavePath = GetMainFrame()->m_strSaveAsPath;
-                       if (GetMainFrame()->m_strSaveAsPath.Right(1) != _T('\\'))
+                       strSavePath = theApp.m_strSaveAsPath;
+                       if (theApp.m_strSaveAsPath.Right(1) != _T('\\'))
                                strSavePath += _T('\\');
                        strSavePath += sname;
                }
                else
-                       strSavePath = GetMainFrame()->m_strSaveAsPath;  
+                       strSavePath = theApp.m_strSaveAsPath;   
        }
 
-       nRetVal = GetMainFrame()->HandleReadonlySave(strSavePath, false, bApplyToAll);
+       nRetVal = theApp.HandleReadonlySave(strSavePath, false, bApplyToAll);
        if (nRetVal == IDCANCEL)
                return false;
 
-       if (!GetMainFrame()->CreateBackup(false, strSavePath))
+       if (!theApp.CreateBackup(false, strSavePath))
                return false;
 
        // false as long as the user is not satisfied
@@ -2187,10 +2188,10 @@ bool CMergeDoc::PromptAndSaveIfNeeded(bool bAllowCancel)
                dlg.m_bDisableCancel = true;
        if (!m_filePaths.GetLeft().empty())
        {
-               if (GetMainFrame()->m_strSaveAsPath.IsEmpty())
+               if (theApp.m_strSaveAsPath.IsEmpty())
                        dlg.m_sLeftFile = m_filePaths.GetLeft().c_str();
                else
-                       dlg.m_sLeftFile = GetMainFrame()->m_strSaveAsPath;
+                       dlg.m_sLeftFile = theApp.m_strSaveAsPath;
        }
        else
                dlg.m_sLeftFile = m_strDesc[0].c_str();
@@ -2198,20 +2199,20 @@ bool CMergeDoc::PromptAndSaveIfNeeded(bool bAllowCancel)
        {
                if (!m_filePaths.GetMiddle().empty())
                {
-                       if (GetMainFrame()->m_strSaveAsPath.IsEmpty())
+                       if (theApp.m_strSaveAsPath.IsEmpty())
                                dlg.m_sMiddleFile = m_filePaths.GetMiddle().c_str();
                        else
-                               dlg.m_sMiddleFile = GetMainFrame()->m_strSaveAsPath;
+                               dlg.m_sMiddleFile = theApp.m_strSaveAsPath;
                }
                else
                        dlg.m_sMiddleFile = m_strDesc[1].c_str();
        }
        if (!m_filePaths.GetRight().empty())
        {
-               if (GetMainFrame()->m_strSaveAsPath.IsEmpty())
+               if (theApp.m_strSaveAsPath.IsEmpty())
                        dlg.m_sRightFile = m_filePaths.GetRight().c_str();
                else
-                       dlg.m_sRightFile = GetMainFrame()->m_strSaveAsPath;
+                       dlg.m_sRightFile = theApp.m_strSaveAsPath;
        }
        else
                dlg.m_sRightFile = m_strDesc[m_nBuffers - 1].c_str();
@@ -2440,13 +2441,13 @@ DWORD CMergeDoc::LoadOneFile(int index, String filename, bool readOnly,
        
        if (!filename.empty())
        {
-               if (GetMainFrame()->m_strDescriptions[index].empty())
+               if (theApp.m_strDescriptions[index].empty())
                        m_nBufferType[index] = BUFFER_NORMAL;
                else
                {
                        m_nBufferType[index] = BUFFER_NORMAL_NAMED;
-                       m_strDesc[index] = GetMainFrame()->m_strDescriptions[index];
-                       GetMainFrame()->m_strDescriptions[index].erase();
+                       m_strDesc[index] = theApp.m_strDescriptions[index];
+                       theApp.m_strDescriptions[index].erase();
                }
                m_pSaveFileInfo[index]->Update(filename);
                m_pRescanFileInfo[index]->Update(filename);
@@ -2457,7 +2458,7 @@ DWORD CMergeDoc::LoadOneFile(int index, String filename, bool readOnly,
        {
                m_nBufferType[index] = BUFFER_UNNAMED;
                m_ptBuf[index]->InitNew();
-               m_strDesc[index] = GetMainFrame()->m_strDescriptions[index];
+               m_strDesc[index] = theApp.m_strDescriptions[index];
                m_ptBuf[index]->m_encoding = encoding;
                loadSuccess = FileLoadResult::FRESULT_OK;
        }
@@ -2580,8 +2581,8 @@ OPENRESULTS_TYPE CMergeDoc::OpenDocs(FileLocation fileloc[],
                m_pDetailView[nBuffer]->AttachToBuffer();
 
                // Currently there is only one set of syntax colors, which all documents & views share
-               m_pView[nBuffer]->SetColorContext(GetMainSyntaxColors());
-               m_pDetailView[nBuffer]->SetColorContext(GetMainSyntaxColors());
+               m_pView[nBuffer]->SetColorContext(theApp.GetMainSyntaxColors());
+               m_pDetailView[nBuffer]->SetColorContext(theApp.GetMainSyntaxColors());
 
                // Set read-only statuses
                m_ptBuf[nBuffer]->SetReadOnly(bRO[nBuffer]);
@@ -2733,7 +2734,7 @@ OPENRESULTS_TYPE CMergeDoc::OpenDocs(FileLocation fileloc[],
 
                // Exit if files are identical should only work for the first
                // comparison and must be disabled afterward.
-               GetMainFrame()->m_bExitIfNoDiff = MergeCmdLineInfo::Disabled;
+               theApp.m_bExitIfNoDiff = MergeCmdLineInfo::Disabled;
        }
        else
        {
@@ -3061,7 +3062,7 @@ void CMergeDoc::OnFileReload()
                fileloc[pane].encoding.m_unicoding = m_ptBuf[pane]->getUnicoding();
                fileloc[pane].encoding.m_codepage = m_ptBuf[pane]->getCodepage();
                fileloc[pane].setPath(m_filePaths[pane]);
-               GetMainFrame()->m_strDescriptions[pane] = m_strDesc[pane];
+               theApp.m_strDescriptions[pane] = m_strDesc[pane];
        }
        int nActivePane = GetActiveMergeView()->m_nThisPane;
        CPoint pt = m_pView[nActivePane]->GetCursorPos();
@@ -3129,7 +3130,7 @@ String CMergeDoc::GetFileExt(LPCTSTR sFileName, LPCTSTR sDescription)
        String sExt;
        paths_SplitFilename(sFileName, NULL, NULL, &sExt);
 
-       if (GetMainFrame()->m_bClearCaseTool)
+       if (theApp.m_bClearCaseTool)
        {
                // If no extension found in real file name.
                if (sExt.empty())
@@ -3310,7 +3311,7 @@ void CMergeDoc::OnToolsGenerateReport()
        String s;
        CString folder;
 
-       if (!SelectFile(GetMainFrame()->GetSafeHwnd(), s, folder, IDS_SAVE_AS_TITLE, IDS_HTML_REPORT_FILES, false, _T("htm")))
+       if (!SelectFile(AfxGetMainWnd()->GetSafeHwnd(), s, folder, IDS_SAVE_AS_TITLE, IDS_HTML_REPORT_FILES, false, _T("htm")))
                return;
 
        GenerateReport(s.c_str());
index 1834db7..7eab84d 100644 (file)
 #define AFX_MERGEDOC_H__BBCD4F90_34E4_11D1_BAA6_00A024706EDC__INCLUDED_
 
 #include "DiffTextBuffer.h"
-#include <boost/scoped_ptr.hpp>
 #include <vector>
 #include <map>
+#include <boost/scoped_ptr.hpp>
 #include "DiffWrapper.h"
 #include "DiffList.h"
-#include "stringdiffs.h"
 #include "TempFile.h"
 #include "PathContext.h"
 #include "DiffFileInfo.h"
@@ -232,8 +231,6 @@ public:
        CMergeEditView * GetView(int pane) const { return m_pView[pane]; }
        CMergeEditView * GetDetailView(int pane) const { return m_pDetailView[pane]; }
        CChildFrame * GetParentFrame();
-       const FileTextEncoding & GetEncoding(int file) const
-                       { return m_ptBuf[file]->getEncoding(); }
 
        void AddSyncPoint();
        void ClearSyncPoints();
index ebf58cf..e346f82 100644 (file)
@@ -13,7 +13,7 @@
 
 #include "Merge.h"
 #include "DiffList.h"
-#include "MergeLineFlags.h"
+#include "stringdiffs.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
index ad97979..7a42c29 100644 (file)
@@ -29,9 +29,8 @@
 // $Id: MergeDocEncoding.cpp 4921 2008-01-16 20:20:54Z kimmov $
 
 #include "stdafx.h"
-
-#include "MainFrm.h"
 #include "MergeDoc.h"
+#include "Merge.h"
 #include "LoadSaveCodepageDlg.h"
 #include "unicoder.h"
 
@@ -77,7 +76,7 @@ bool CMergeDoc::DoFileEncodingDialog()
                        fileloc[pane].encoding.m_codepage = m_ptBuf[pane]->getCodepage();
                }
                fileloc[pane].setPath(m_filePaths[pane]);
-               GetMainFrame()->m_strDescriptions[pane] = m_strDesc[pane];
+               theApp.m_strDescriptions[pane] = m_strDesc[pane];
        }
        OpenDocs(fileloc, bRO);
 
index 8051a39..93f437b 100644 (file)
@@ -8,12 +8,12 @@
 // $Id: MergeDocLineDiffs.cpp 7067 2009-12-29 14:22:46Z kimmov $
 
 #include "StdAfx.h"
+#include "MergeDoc.h"
 #include <vector>
 #include <boost/scoped_array.hpp>
 #include "Merge.h"
-#include "MainFrm.h"
-
 #include "MergeEditView.h"
+#include "DiffTextBuffer.h"
 #include "stringdiffs.h"
 #include "UnicodeString.h"
 
index a4cb89b..b471b2e 100644 (file)
 // $Id: MergeEditView.cpp 7142 2010-04-28 17:05:50Z kimmov $
 
 #include "StdAfx.h"
+#include "MergeEditView.h"
 #include <vector>
 #include "BCMenu.h"
 #include "Merge.h"
 #include "LocationView.h"
-#include "MergeEditView.h"
 #include "MergeDoc.h"
 #include "MainFrm.h"
 #include "OptionsMgr.h"
@@ -39,7 +39,6 @@
 #include "WaitStatusCursor.h"
 #include "FileTransform.h"
 #include "Plugins.h"
-#include "lwdisp.h"
 #include "WMGotoDlg.h"
 #include "OptionsDef.h"
 #include "SyntaxColors.h"
@@ -245,6 +244,7 @@ CMergeDoc* CMergeEditView::GetDocument() // non-debug version is inline
        ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMergeDoc)));
        return (CMergeDoc*)m_pDocument;
 }
+
 #endif //_DEBUG
 
 /////////////////////////////////////////////////////////////////////////////
@@ -265,6 +265,17 @@ void CMergeEditView::UpdateResources()
 {
 }
 
+CMergeEditView *CMergeEditView::GetGroupView(int nPane) const
+{
+       return (this == GetDocument()->GetView(this->m_nThisPane)) ? GetDocument()->GetView(nPane) : GetDocument()->GetDetailView(nPane);
+}
+
+bool CMergeEditView::IsDetailViewPane() const
+{
+       return (GetDocument()->GetView(m_nThisPane) != this);
+};
+
+
 void CMergeEditView::PrimeListWithFile()
 {
        // Set the tab size now, just in case the options change...
@@ -3462,7 +3473,7 @@ void CMergeEditView::OnOpenFileWithEditor()
                return;
 
        int nRealLine = ComputeRealLine(GetCursorPos().y) + 1;
-       GetMainFrame()->OpenFileToExternalEditor(sFileName.c_str(), nRealLine);
+       theApp.OpenFileToExternalEditor(sFileName.c_str(), nRealLine);
 }
 
 /**
@@ -3801,7 +3812,7 @@ bool CMergeEditView::IsDiffVisible(const DIFFRANGE& diff, int nLinesBelow /*=0*/
 /** @brief Open help from mainframe when user presses F1*/
 void CMergeEditView::OnHelp()
 {
-       GetMainFrame()->ShowHelp(MergeViewHelpLocation);
+       theApp.ShowHelp(MergeViewHelpLocation);
 }
 
 /**
index 5e057c5..8fadbaa 100644 (file)
@@ -128,6 +128,7 @@ public:
        CString GetSelectedText();
        CString GetLineText(int idx);
        CMergeDoc* GetDocument();
+       const CMergeDoc *GetDocument() const { return const_cast<CMergeEditView *>(this)->GetDocument(); }
        void UpdateResources();
        BOOL IsModified() { return (LocateTextBuffer()->IsModified()); }
        void PrimeListWithFile();
@@ -166,10 +167,8 @@ public:
        virtual void PrintFooter(CDC * pdc, int nPageNum);
        virtual void SetWordWrapping( bool bWordWrap );
        void UpdateStatusbar();
-       CMergeEditView *GetGroupView(int nPane) {
-               return (this == GetDocument()->GetView(this->m_nThisPane)) ? GetDocument()->GetView(nPane) : GetDocument()->GetDetailView(nPane);
-       }
-       bool IsDetailViewPane() { return (GetDocument()->GetView(m_nThisPane) != this); };
+       CMergeEditView *GetGroupView(int nPane) const;
+       bool IsDetailViewPane() const;
 
        virtual void OnDisplayDiff(int nDiff=0);
 
index dc5c39b..c46628a 100644 (file)
@@ -2,9 +2,7 @@
 //
 
 #include "stdafx.h"
-#include "Merge.h"
 #include "OpenDoc.h"
-#include "Constants.h"
 
 // COpenDoc
 
index 49c2140..e38ea7e 100644 (file)
@@ -1,9 +1,8 @@
 // ChildFrm.cpp : implementation of the COpenFrame class
 //
 #include "stdafx.h"
-#include "Merge.h"
-
 #include "OpenFrm.h"
+#include "Merge.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
index 91981d9..66f1ab1 100644 (file)
 // $Id: OpenDlg.cpp 6861 2009-06-25 12:11:07Z kimmov $
 
 #include "stdafx.h"
+#include "OpenView.h"
 #include <vector>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include "UnicodeString.h"
 #include "Merge.h"
 #include "OpenDoc.h"
-#include "OpenView.h"
 #include "ProjectFile.h"
 #include "paths.h"
 #include "SelectUnpackerDlg.h"
@@ -45,6 +45,7 @@
 #include "Constants.h"
 #include "Picture.h"
 #include "DragDrop.h"
+#include "FileFilterHelper.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -225,8 +226,8 @@ void COpenView::OnInitialUpdate()
                m_ctlPath[2].SetAutoComplete(nSource);
        }
 
-       String filterNameOrMask = theApp.m_globalFileFilter.GetFilterNameOrMask();
-       BOOL bMask = theApp.m_globalFileFilter.IsUsingMask();
+       String filterNameOrMask = theApp.m_pGlobalFileFilter->GetFilterNameOrMask();
+       BOOL bMask = theApp.m_pGlobalFileFilter->IsUsingMask();
 
        if (!bMask)
        {
@@ -475,19 +476,19 @@ void COpenView::OnOK()
        {
                // Remove prefix + space
                filter.erase(0, filterPrefix.length());
-               if (!theApp.m_globalFileFilter.SetFilter(filter))
+               if (!theApp.m_pGlobalFileFilter->SetFilter(filter))
                {
                        // If filtername is not found use default *.* mask
-                       theApp.m_globalFileFilter.SetFilter(_T("*.*"));
+                       theApp.m_pGlobalFileFilter->SetFilter(_T("*.*"));
                        filter = _T("*.*");
                }
                GetOptionsMgr()->SaveOption(OPT_FILEFILTER_CURRENT, filter);
        }
        else
        {
-               BOOL bFilterSet = theApp.m_globalFileFilter.SetFilter(filter);
+               BOOL bFilterSet = theApp.m_pGlobalFileFilter->SetFilter(filter);
                if (!bFilterSet)
-                       m_strExt = theApp.m_globalFileFilter.GetFilterNameOrMask().c_str();
+                       m_strExt = theApp.m_pGlobalFileFilter->GetFilterNameOrMask().c_str();
                GetOptionsMgr()->SaveOption(OPT_FILEFILTER_CURRENT, filter);
        }
 
@@ -853,15 +854,15 @@ void COpenView::OnSelectFilter()
        String filterPrefix = theApp.LoadString(IDS_FILTER_PREFIX);
        CString curFilter;
 
-       const BOOL bUseMask = theApp.m_globalFileFilter.IsUsingMask();
+       const BOOL bUseMask = theApp.m_pGlobalFileFilter->IsUsingMask();
        GetDlgItemText(IDC_EXT_COMBO, curFilter);
        curFilter.TrimLeft();
        curFilter.TrimRight();
 
        GetMainFrame()->SelectFilter();
        
-       String filterNameOrMask = theApp.m_globalFileFilter.GetFilterNameOrMask();
-       if (theApp.m_globalFileFilter.IsUsingMask())
+       String filterNameOrMask = theApp.m_pGlobalFileFilter->GetFilterNameOrMask();
+       if (theApp.m_pGlobalFileFilter->IsUsingMask())
        {
                // If we had filter chosen and now has mask we can overwrite filter
                if (!bUseMask || curFilter[0] != '*')
@@ -996,7 +997,7 @@ void COpenView::OnEditUndo()
  */
 void COpenView::OnHelp()
 {
-       GetMainFrame()->ShowHelp(OpenDlgHelpLocation);
+       theApp.ShowHelp(OpenDlgHelpLocation);
 }
 
 /////////////////////////////////////////////////////////////////////////////
index 8fe743b..deb0110 100644 (file)
@@ -37,6 +37,7 @@
 #include "CMoveConstraint.h"
 
 class ProjectFile;
+class COpenDoc;
 
 /**
  * @brief The Open-View class.
index 207422b..c5031fa 100644 (file)
@@ -9,9 +9,9 @@
 #include "stdafx.h"
 #include <vector>
 #include "Merge.h"
-#include "MainFrm.h"
 #include "OptionsDef.h"
 #include "OptionsMgr.h"
+#include "RegOptionsMgr.h"
 #include "OptionsDiffOptions.h"
 #include "OptionsDiffColors.h"
 #include "OptionsFont.h"
@@ -38,7 +38,7 @@ void CMergeApp::OptionsInit()
        // Copy some values from HKLM to HKCU
        CopyHKLMValues();
 
-       m_pOptions->SetRegRootKey(_T("Thingamahoochie\\WinMerge\\"));
+       static_cast<CRegOptionsMgr *>(m_pOptions.get())->SetRegRootKey(_T("Thingamahoochie\\WinMerge\\"));
 
        LANGID LangId = GetUserDefaultLangID();
        if (PRIMARYLANGID(LangId) == LANG_JAPANESE)
index 4a71bab..8e9df7a 100644 (file)
@@ -23,9 +23,9 @@
 // $Id: PatchDlg.cpp 6783 2009-05-25 06:47:22Z kimmov $
 
 #include "StdAfx.h"
+#include "PatchDlg.h"
 #include "Merge.h"
 #include "PatchTool.h"
-#include "PatchDlg.h"
 #include "diff.h"
 #include "coretools.h"
 #include "paths.h"
index 7f0ad97..572a273 100644 (file)
 // $Id: PatchTool.cpp 6858 2009-06-25 07:48:26Z kimmov $
 
 #include "StdAfx.h"
+#include "PatchTool.h"
 #include "UnicodeString.h"
 #include "DiffWrapper.h"
 #include "PathContext.h"
-#include "PatchTool.h"
 #include "PatchDlg.h"
 #include "paths.h"
 
index 82d7813..1fff3eb 100644 (file)
@@ -25,6 +25,8 @@
 #ifndef _PATCHTOOL_H_
 #define _PATCHTOOL_H_
 
+#include "DiffWrapper.h"
+
 class CPatchDlg;
 
 /** 
index 7352bc5..ad5cb3c 100644 (file)
@@ -26,6 +26,7 @@
 // ID line follows -- this is updated by SVN
 // $Id: Plugins.cpp 7052 2009-12-22 17:45:22Z kimmov $
 
+#include "Plugins.h"
 #define POCO_NO_UNWINDOWS 1
 #include <vector>
 #include <list>
@@ -36,7 +37,6 @@
 #include <Poco/ScopedLock.h>
 #include <Poco/RegularExpression.h>
 #include <windows.h>
-#include "Plugins.h"
 #include "MergeApp.h"
 #include "FileTransform.h"
 #include "FileFilterMgr.h"
index 6dd1a36..5da0046 100644 (file)
@@ -7,11 +7,12 @@
 // $Id$
 
 #include "stdafx.h"
+#include "PluginsListDlg.h"
 #include "UnicodeString.h"
 #include "Merge.h"
 #include "Plugins.h"
-#include "PluginsListDlg.h"
 #include "OptionsDef.h"
+#include "OptionsMgr.h"
 
 IMPLEMENT_DYNAMIC(PluginsListDlg, CDialog)
 
index 21b0461..9ca737c 100644 (file)
@@ -7,14 +7,16 @@
 // $Id$
 
 #include "stdafx.h"
+#include "ProjectFilePathsDlg.h"
 #include "UnicodeString.h"
 #include "Merge.h"
 #include "MainFrm.h"
 #include "paths.h"
 #include "OptionsDef.h"
+#include "OptionsMgr.h"
 #include "ProjectFile.h"
-#include "ProjectFilePathsDlg.h"
 #include "FileOrFolderSelect.h"
+#include "FileFilterHelper.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -109,15 +111,15 @@ void ProjectFilePathsDlg::OnBnClickedProjFilterSelect()
        String filterPrefix = theApp.LoadString(IDS_FILTER_PREFIX);
        CString curFilter;
 
-       const BOOL bUseMask = theApp.m_globalFileFilter.IsUsingMask();
+       const BOOL bUseMask = theApp.m_pGlobalFileFilter->IsUsingMask();
        GetDlgItemText(IDC_PROJ_FILTER_EDIT, curFilter);
        curFilter.TrimLeft();
        curFilter.TrimRight();
 
        GetMainFrame()->SelectFilter();
        
-       String filterNameOrMask = theApp.m_globalFileFilter.GetFilterNameOrMask();
-       if (theApp.m_globalFileFilter.IsUsingMask())
+       String filterNameOrMask = theApp.m_pGlobalFileFilter->GetFilterNameOrMask();
+       if (theApp.m_pGlobalFileFilter->IsUsingMask())
        {
                // If we had filter chosen and now has mask we can overwrite filter
                if (!bUseMask || curFilter[0] != '*')
index 0ff193c..ac90066 100644 (file)
@@ -7,9 +7,9 @@
 // $Id$
 
 #include "stdafx.h"
+#include "PropArchive.h"
 #include "Constants.h"
 #include "Merge.h"
-#include "PropArchive.h"
 #include "OptionsDef.h"
 #include "OptionsMgr.h"
 #include "OptionsPanel.h"
index 1c9d417..f2fe939 100644 (file)
@@ -7,8 +7,8 @@
 // $Id$
 
 #include "stdafx.h"
-#include "Merge.h"
 #include "PropBackups.h"
+#include "Merge.h"
 #include "OptionsDef.h"
 #include "OptionsMgr.h"
 #include "OptionsPanel.h"
index d4998dd..f381268 100644 (file)
 // $Id: PropCodepage.cpp 6908 2009-07-11 08:29:49Z kimmov $
 
 #include "stdafx.h"
+#include "PropCodepage.h"
 #include "common/unicoder.h"
 #include "common/ExConverter.h"
-#include "merge.h"
-#include "PropCodepage.h"
+#include "Merge.h"
 #include "OptionsDef.h"
 #include "OptionsMgr.h"
 #include "OptionsPanel.h"
index 67459fe..e9aa67d 100644 (file)
@@ -7,8 +7,8 @@
 // $Id: PropColors.cpp 6908 2009-07-11 08:29:49Z kimmov $
 
 #include "stdafx.h"
-#include "merge.h"
 #include "PropColors.h"
+#include "Merge.h"
 #include "CustomColors.h"
 #include "OptionsDef.h"
 #include "OptionsMgr.h"
index 4705a69..363453c 100644 (file)
@@ -7,8 +7,8 @@
 // $Id$
 
 #include "stdafx.h"
-#include "merge.h"
 #include "PropCompare.h"
+#include "Merge.h"
 #include "OptionsDef.h"
 #include "OptionsMgr.h"
 #include "OptionsPanel.h"
index 1c97026..238da2c 100644 (file)
@@ -7,8 +7,8 @@
 // $Id: PropCompareFolder.cpp 6921 2009-07-23 15:20:41Z kimmov $
 
 #include "stdafx.h"
-#include "merge.h"
 #include "PropCompareFolder.h"
+#include "Merge.h"
 #include "OptionsDef.h"
 #include "OptionsMgr.h"
 #include "OptionsPanel.h"
index 86045c9..ab52601 100644 (file)
@@ -7,8 +7,8 @@
 // $Id$
 
 #include "stdafx.h"
-#include "merge.h"
 #include "PropEditor.h"
+#include "Merge.h"
 #include "OptionsDef.h"
 #include "OptionsMgr.h"
 #include "OptionsPanel.h"
index 08287ee..70d34be 100644 (file)
@@ -28,8 +28,8 @@
 // $Id$
 
 #include "stdafx.h"
-#include "merge.h"
 #include "PropGeneral.h"
+#include "Merge.h"
 #include "OptionsDef.h"
 #include "OptionsMgr.h"
 #include "OptionsPanel.h"
index c8e62bd..82318d2 100644 (file)
@@ -23,7 +23,6 @@
 // $Id: PropRegistry.cpp 6908 2009-07-11 08:29:49Z kimmov $
 
 #include "stdafx.h"
-#include "resource.h"
 #include "PropRegistry.h"
 #include "RegKey.h"
 #include "coretools.h"
index 4ce980d..bf3f628 100644 (file)
@@ -8,9 +8,8 @@
 // $Id: PropShell.cpp 6725 2009-05-09 14:31:24Z kimmov $
 
 #include "stdafx.h"
-#include "resource.h"
-#include "merge.h"
 #include "PropShell.h"
+#include "Merge.h"
 #include "RegKey.h"
 #include "OptionsDef.h"
 #include "OptionsMgr.h"
index e22e9a6..a10cd98 100644 (file)
@@ -7,10 +7,9 @@
 // $Id$
 
 #include "stdafx.h"
-#include "resource.h"
+#include "PropSyntaxColors.h"
 #include "SyntaxColors.h"
 #include "OptionsSyntaxColors.h"
-#include "PropSyntaxColors.h"
 #include "CustomColors.h"
 #include "Merge.h"
 #include "OptionsPanel.h"
index 12d92d9..8184e13 100644 (file)
@@ -7,9 +7,8 @@
 // $Id$
 
 #include "stdafx.h"
-#include "resource.h"
-#include "Merge.h"
 #include "PropTextColors.h"
+#include "Merge.h"
 #include "SyntaxColors.h"
 #include "CustomColors.h"
 #include "OptionsDef.h"
index ffa3952..e1f92c3 100644 (file)
 // $Id$
 
 #include "stdafx.h"
+#include "PropVss.h"
 #include "FileOrFolderSelect.h"
-#include "MainFrm.h" // VCS_* constants
 #include "Merge.h"
-#include "PropVss.h"
 #include "OptionsDef.h"
 #include "OptionsMgr.h"
 #include "OptionsPanel.h"
index eb8d4b7..62b822b 100644 (file)
@@ -23,8 +23,8 @@
 // $Id: SaveClosingDlg.cpp 4704 2007-11-03 12:10:48Z jtuc $
 
 #include "stdafx.h"
-#include "Merge.h"
 #include "SaveClosingDlg.h"
+#include "Merge.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
index 3fbe688..0df8315 100644 (file)
@@ -28,8 +28,8 @@
 //
 
 #include "stdafx.h"
-#include "merge.h"
 #include "SelectUnpackerDlg.h"
+#include "Merge.h"
 #include "Plugins.h"
 #include "FileTransform.h"
 
index 735591b..282e76a 100644 (file)
@@ -30,6 +30,7 @@
 #define AFX_SELECTUNPACKERDLG_H__C8FD4C3A_5ED5_43D3_ADAE_A2378369705C__INCLUDED_
 
 #include <vector>
+#include <boost/scoped_ptr.hpp>
 
 /////////////////////////////////////////////////////////////////////////////
 // CSelectUnpackerDlgDlg dialog
index 16fc9b3..d53d479 100644 (file)
@@ -7,8 +7,8 @@
 // $Id$
 
 #include "stdafx.h"
-#include "merge.h"
 #include "SharedFilterDlg.h"
+#include "Merge.h"
 #include "OptionsDef.h"
 #include "OptionsMgr.h"
 
index 7bcfee3..2c4962e 100644 (file)
 #include <direct.h>
 #include "UnicodeString.h"
 #include "unicoder.h"
-#include "MainFrm.h"
 #include "Merge.h"
 #include "OptionsDef.h"
+#include "OptionsMgr.h"
 #include "RegKey.h"
 #include "paths.h"
 #include "VssPrompt.h"
 #include "WaitStatusCursor.h"
 #include "ssapi.h"      // BSP - Includes for Visual Source Safe COM interface
 #include "CCPrompt.h"
+#include "VSSHelper.h"
 
 using Poco::format;
 using Poco::Process;
 using Poco::ProcessHandle;
 
 void
-CMainFrame::InitializeSourceControlMembers()
+CMergeApp::InitializeSourceControlMembers()
 {
-       m_vssHelper.SetProjectBase((const TCHAR *)theApp.GetProfileString(_T("Settings"), _T("VssProject"), _T("")));
+       m_pVssHelper->SetProjectBase((const TCHAR *)theApp.GetProfileString(_T("Settings"), _T("VssProject"), _T("")));
        m_strVssUser = theApp.GetProfileString(_T("Settings"), _T("VssUser"), _T(""));
 //     m_strVssPassword = theApp.GetProfileString(_T("Settings"), _T("VssPassword"), _T(""));
        theApp.WriteProfileString(_T("Settings"), _T("VssPassword"), _T(""));
@@ -59,7 +60,7 @@ CMainFrame::InitializeSourceControlMembers()
 * @return Tells if caller can continue (no errors happened)
 * @sa CheckSavePath()
 */
-BOOL CMainFrame::SaveToVersionControl(const String& strSavePath)
+BOOL CMergeApp::SaveToVersionControl(const String& strSavePath)
 {
        CFileStatus status;
        UINT userChoice = 0;
@@ -77,7 +78,7 @@ BOOL CMainFrame::SaveToVersionControl(const String& strSavePath)
                // Prompt for user choice
                CVssPrompt dlg;
                dlg.m_strMessage = LangFormatString1(IDS_SAVE_FMT, strSavePath.c_str()).c_str();
-               dlg.m_strProject = m_vssHelper.GetProjectBase().c_str();
+               dlg.m_strProject = m_pVssHelper->GetProjectBase().c_str();
                dlg.m_strUser = m_strVssUser;          // BSP - Add VSS user name to dialog box
                dlg.m_strPassword = m_strVssPassword;
 
@@ -95,8 +96,8 @@ BOOL CMainFrame::SaveToVersionControl(const String& strSavePath)
                if (userChoice == IDOK)
                {
                        WaitStatusCursor waitstatus(IDS_VSS_CHECKOUT_STATUS);
-                       m_vssHelper.SetProjectBase((const TCHAR *)dlg.m_strProject);
-                       theApp.WriteProfileString(_T("Settings"), _T("VssProject"), m_vssHelper.GetProjectBase().c_str());
+                       m_pVssHelper->SetProjectBase((const TCHAR *)dlg.m_strProject);
+                       theApp.WriteProfileString(_T("Settings"), _T("VssProject"), m_pVssHelper->GetProjectBase().c_str());
                        String path, name;
                        paths_SplitFilename(strSavePath, &path, &name, NULL);
                        String spath(path);
@@ -112,7 +113,7 @@ BOOL CMainFrame::SaveToVersionControl(const String& strSavePath)
                                std::string sn;
                                std::vector<std::string> args;
                                args.push_back("checkout");
-                               format(sn, "\"%s/%s\"", ucr::toUTF8(m_vssHelper.GetProjectBase()), ucr::toUTF8(sname));
+                               format(sn, "\"%s/%s\"", ucr::toUTF8(m_pVssHelper->GetProjectBase()), ucr::toUTF8(sname));
                                args.push_back(sn);
                                ProcessHandle hVss(Process::launch(vssPath, args));
                                int code = Process::wait(hVss);
@@ -140,7 +141,7 @@ BOOL CMainFrame::SaveToVersionControl(const String& strSavePath)
                CString spath, sname;
 
                dlg.m_strMessage = LangFormatString1(IDS_SAVE_FMT, strSavePath.c_str()).c_str();
-               dlg.m_strProject = m_vssHelper.GetProjectBase().c_str();
+               dlg.m_strProject = m_pVssHelper->GetProjectBase().c_str();
                dlg.m_strUser = m_strVssUser;          // BSP - Add VSS user name to dialog box
                dlg.m_strPassword = m_strVssPassword;
                dlg.m_strSelectedDatabase = m_strVssDatabase;
@@ -161,14 +162,14 @@ BOOL CMainFrame::SaveToVersionControl(const String& strSavePath)
                {
                        WaitStatusCursor waitstatus(IDS_VSS_CHECKOUT_STATUS);
                        BOOL bOpened = FALSE;
-                       m_vssHelper.SetProjectBase((const TCHAR *)dlg.m_strProject);
+                       m_pVssHelper->SetProjectBase((const TCHAR *)dlg.m_strProject);
                        m_strVssUser = dlg.m_strUser;
                        m_strVssPassword = dlg.m_strPassword;
                        m_strVssDatabase = dlg.m_strSelectedDatabase;
                        m_bVCProjSync = dlg.m_bVCProjSync;                                      
 
                        theApp.WriteProfileString(_T("Settings"), _T("VssDatabase"), m_strVssDatabase);
-                       theApp.WriteProfileString(_T("Settings"), _T("VssProject"), m_vssHelper.GetProjectBase().c_str());
+                       theApp.WriteProfileString(_T("Settings"), _T("VssProject"), m_pVssHelper->GetProjectBase().c_str());
                        theApp.WriteProfileString(_T("Settings"), _T("VssUser"), m_strVssUser);
 //                     theApp.WriteProfileString(_T("Settings"), _T("VssPassword"), m_strVssPassword);
 
@@ -235,7 +236,7 @@ BOOL CMainFrame::SaveToVersionControl(const String& strSavePath)
                        static TCHAR buffer2[nBufferSize];
 
                        _tcscpy(buffer1, strSavePath.c_str());
-                       _tcscpy(buffer2, m_vssHelper.GetProjectBase().c_str());
+                       _tcscpy(buffer2, m_pVssHelper->GetProjectBase().c_str());
                        _tcslwr(buffer1);
                        _tcslwr(buffer2);
 
@@ -246,7 +247,7 @@ BOOL CMainFrame::SaveToVersionControl(const String& strSavePath)
                                        buffer1[k] = '\\';
                        }
 
-                       m_vssHelper.SetProjectBase(buffer2);
+                       m_pVssHelper->SetProjectBase(buffer2);
                        TCHAR * pbuf2 = &buffer2[2];//skip the $/
                        TCHAR * pdest =  _tcsstr(buffer1, pbuf2);
                        if (pdest)
@@ -264,7 +265,7 @@ BOOL CMainFrame::SaveToVersionControl(const String& strSavePath)
                                        sname = buffer;
                                }
                        }
-                       String strItem = m_vssHelper.GetProjectBase() + _T("\\") + static_cast<const TCHAR *>(sname);
+                       String strItem = m_pVssHelper->GetProjectBase() + _T("\\") + static_cast<const TCHAR *>(sname);
 
                        TRY
                        {
@@ -384,7 +385,7 @@ BOOL CMainFrame::SaveToVersionControl(const String& strSavePath)
 /**
  * @brief Checkin in file into ClearCase.
  */ 
-void CMainFrame::CheckinToClearCase(const String &strDestinationPath)
+void CMergeApp::CheckinToClearCase(const String &strDestinationPath)
 {
        String spath, sname;
        paths_SplitFilename(strDestinationPath, &spath, &sname, 0);
index 26e88a8..63607b7 100644 (file)
 // $Id$
 
 #include "stdafx.h"
-#include "resource.h"
+#include "Splash.h"
 #include "UnicodeString.h"
 #include "Picture.h"
-#include "Splash.h"
 #include "version.h"
 
 #ifdef _DEBUG
index e14045a..e179051 100644 (file)
@@ -7,10 +7,10 @@
 // $Id$
 
 #include "stdafx.h"
+#include "TestFilterDlg.h"
 #include "Merge.h"
 #include "resource.h"
 #include "UnicodeString.h"
-#include "TestFilterDlg.h"
 #include "FileFilterMgr.h"
 
 #ifdef _DEBUG
index 9c137ee..cccfe0c 100644 (file)
@@ -23,8 +23,8 @@
 // $Id$
 
 
-#include <windows.h>
 #include "VSSHelper.h"
+#include <windows.h>
 #include <algorithm>
 #include <cassert>
 #include "UnicodeString.h"
index 957cbbb..ad51d20 100644 (file)
@@ -25,6 +25,7 @@
 #ifndef _VSSHELPER_H_
 #define _VSSHELPER_H_
 
+#include <Windows.h>
 #include "UnicodeString.h"
 
 /**
index ae11af9..6460fe1 100644 (file)
@@ -27,8 +27,8 @@
 // $Id$
 
 #include "stdafx.h"
-#include "Merge.h"
 #include "VssPrompt.h"
+#include "Merge.h"
 #include "RegKey.h"
 
 #ifdef _DEBUG
index 2517103..e0ea98f 100644 (file)
@@ -23,8 +23,8 @@
 // $Id$
 
 #include "stdafx.h"
-#include "merge.h"
 #include "WMGotoDlg.h"
+#include "Merge.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
index 73cf0b8..b97f46f 100644 (file)
@@ -24,8 +24,8 @@
 // RCS ID line follows -- this is updated by SVN
 // $Id$
 
-#include <windows.h>
 #include "codepage.h"
+#include <windows.h>
 #include <map>
 #include <cassert>
 #include <tchar.h>
index 2ac624b..72f67fa 100644 (file)
@@ -25,10 +25,10 @@ DATE:               BY:                                     DESCRIPTION:
 */
 
 #include "stdafx.h"
+#include "dllpstub.h"
 #include <shlwapi.h>
 #include <afxdisp.h>
 #include <afxinet.h>
-#include "dllpstub.h"
 
 /**
  * @brief Throw DLLPSTUB related exception.
index 2387859..83f05d0 100644 (file)
@@ -83,11 +83,11 @@ DATE:               BY:                                     DESCRIPTION:
 */
 
 #include "markdown.h"
-#include "unicoder.h"
 #include <cstring>
 #include <Poco/ByteOrder.h>
 #include <Poco/NumberParser.h>
 #include <Poco/SharedMemory.h>
+#include "unicoder.h"
 #include "TFile.h"
 
 #define MAKEWORD(a, b)      ((unsigned short)(((unsigned char)((unsigned)(a) & 0xff)) | ((unsigned short)((unsigned char)((unsigned)(b) & 0xff))) << 8))
index 3c2e0f7..188a5ec 100644 (file)
@@ -6,8 +6,8 @@
 // ID line follows -- this is updated by SVN
 // $Id: paths.cpp 6514 2009-03-01 16:55:11Z kimmov $
 
-#include <windows.h>
 #include "paths.h"
+#include <windows.h>
 #include <cassert>
 #include <direct.h>
 #include <mbctype.h> // MBCS (multibyte codepage stuff)
index 52b94e5..9a9b37d 100644 (file)
@@ -7,13 +7,13 @@
 // RCS ID line follows -- this is updated by CVS
 // $Id: stringdiffs.cpp 7149 2010-05-03 17:08:20Z kimmov $
 
+#include "stringdiffs.h"
 #define NOMINMAX
 #include <windows.h>
 #include <tchar.h>
 #include <cassert>
 #include <climits>
 #include <mbctype.h>
-#include "stringdiffs.h"
 #include "CompareOptions.h"
 #include "stringdiffsi.h"
 #include "Diff3.h"
index 3ebdae7..550dcf3 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: WinMerge\n"
 "Report-Msgid-Bugs-To: http://bugs.winmerge.org/\n"
-"POT-Creation-Date: 2014-01-13 23:04+0000\n"
+"POT-Creation-Date: 2014-01-18 13:40+0000\n"
 "PO-Revision-Date: \n"
 "Last-Translator: \n"
 "Language-Team: English <winmerge-translate@lists.sourceforge.net>\n"