1 /////////////////////////////////////////////////////////////////////////////
2 // WinMerge: an interactive diff/merge utility
3 // Copyright (C) 1997 Dean P. Grimm
4 // SPDX-License-Identifier: GPL-2.0-or-later
5 /////////////////////////////////////////////////////////////////////////////
9 * @brief Declaration of CHexMergeDoc class
13 #include "PathContext.h"
14 #include "FileLocation.h"
15 #include "IMergeDoc.h"
16 #include "FileTransform.h"
23 * @brief Document class for bytewise merging two files presented as hexdumps
25 class CHexMergeDoc : public CDocument, public IMergeDoc
30 NORMAL = 0, /**< Normal, file loaded from disk */
31 NORMAL_NAMED, /**< Normal, description given */
32 UNNAMED, /**< Empty, created buffer */
33 UNNAMED_SAVED, /**< Empty buffer saved with filename */
38 static int m_nBuffersTemp;
40 PathContext m_filePaths; /**< Filepaths for this document */
42 // Begin declaration of CHexMergeDoc
44 protected: // create from serialization only
46 DECLARE_DYNCREATE(CHexMergeDoc)
51 void SetMergeViews(CHexMergeView * pView[]);
52 CHexMergeView *GetActiveMergeView() const;
55 // ClassWizard generated virtual function overrides
56 //{{AFX_VIRTUAL(CMergeDoc)
58 virtual BOOL SaveModified();
59 virtual void SetTitle(LPCTSTR lpszTitle);
65 int UpdateLastCompareResult();
66 bool PromptAndSaveIfNeeded(bool bAllowCancel);
67 IDirDoc* GetDirDoc() const override { return m_pDirDoc; };
68 void SetDirDoc(IDirDoc * pDirDoc) override;
69 void DirDocClosing(IDirDoc * pDirDoc) override;
70 bool CloseNow() override;
71 bool GenerateReport(const String& sFileName) const override { return true; }
72 const PackingInfo* GetUnpacker() const override { return &m_infoUnpacker; };
73 PackingInfo* GetUnpacker() { return &m_infoUnpacker; };
74 void SetUnpacker(const PackingInfo* infoUnpacker) override { if (infoUnpacker) m_infoUnpacker = *infoUnpacker; };
75 const PrediffingInfo* GetPrediffer() const override { return nullptr; };
76 int GetFileCount() const override { return m_filePaths.GetSize(); }
77 String GetPath(int pane) const override { return m_filePaths[pane]; }
78 bool GetReadOnly(int pane) const override;
79 CString GetTooltipString() const override;
80 CHexMergeFrame * GetParentFrame() const;
81 void UpdateHeaderPath(int pane);
82 void RefreshOptions();
83 bool OpenDocs(int nFiles, const FileLocation fileloc[], const bool bRO[], const String strDesc[]);
84 void MoveOnLoad(int nPane = -1, int nLineIndex = -1);
85 void ChangeFile(int nBuffer, const String& path, int nLineIndex = -1);
86 void CheckFileChanged(void) override;
87 String GetDescription(int pane) const override { return m_strDesc[pane]; };
88 void SetDescription(int pane, const String& strDesc) { m_strDesc[pane] = strDesc; };
89 void SaveAs(int nBuffer, bool packing = true) { DoFileSaveAs(nBuffer, packing); }
90 String GetSaveAsPath() const { return m_strSaveAsPath; }
91 void SetSaveAsPath(const String& strSaveAsPath) { m_strSaveAsPath = strSaveAsPath; }
92 bool IsModified() const;
95 bool DoFileSave(int nBuffer);
96 bool DoFileSaveAs(int nBuffer, bool packing = true);
97 HRESULT LoadOneFile(int index, const tchar_t* filename, bool readOnly, const String& strDesc);
98 void RecompareAs(UINT id);
99 // Implementation data
101 CHexMergeView * m_pView[3]; /**< Pointer to left/right view */
103 String m_strDesc[3]; /**< Left/right side description text */
104 BUFFERTYPE m_nBufferType[3];
105 PackingInfo m_infoUnpacker;
106 String m_strSaveAsPath; /**< "3rd path" where output saved if given */
108 // Generated message map functions
110 //{{AFX_MSG(CMergeDoc)
111 afx_msg void OnFileSave();
112 afx_msg void OnFileSaveLeft();
113 afx_msg void OnFileSaveMiddle();
114 afx_msg void OnFileSaveRight();
115 afx_msg void OnFileSaveAsLeft();
116 afx_msg void OnFileSaveAsMiddle();
117 afx_msg void OnFileSaveAsRight();
118 afx_msg void OnFileReload();
119 afx_msg void OnUpdateStatusNum(CCmdUI* pCmdUI);
120 afx_msg void OnUpdateFileSaveLeft(CCmdUI* pCmdUI);
121 afx_msg void OnUpdateFileSaveMiddle(CCmdUI* pCmdUI);
122 afx_msg void OnUpdateFileSaveRight(CCmdUI* pCmdUI);
123 afx_msg void OnUpdateFileSave(CCmdUI* pCmdUI);
124 afx_msg void OnCopyX2Y(UINT nID);
125 afx_msg void OnUpdateX2Y(CCmdUI* pCmdUI);
126 afx_msg void OnL2r();
127 afx_msg void OnUpdateL2r(CCmdUI* pCmdUI);
128 afx_msg void OnR2l();
129 afx_msg void OnUpdateR2l(CCmdUI* pCmdUI);
130 afx_msg void OnUpdateL2RNext(CCmdUI* pCmdUI);
131 afx_msg void OnUpdateR2LNext(CCmdUI* pCmdUI);
132 afx_msg void OnCopyFromLeft();
133 afx_msg void OnUpdateCopyFromLeft(CCmdUI* pCmdUI);
134 afx_msg void OnCopyFromRight();
135 afx_msg void OnUpdateCopyFromRight(CCmdUI* pCmdUI);
136 afx_msg void OnAllRight();
137 afx_msg void OnUpdateAllRight(CCmdUI* pCmdUI);
138 afx_msg void OnAllLeft();
139 afx_msg void OnUpdateAllLeft(CCmdUI* pCmdUI);
140 afx_msg void OnViewZoomIn();
141 afx_msg void OnViewZoomOut();
142 afx_msg void OnViewZoomNormal();
143 afx_msg void OnRefresh();
144 afx_msg void OnFileRecompareAs(UINT nID);
145 afx_msg void OnUpdateFileRecompareAs(CCmdUI* pCmdUI);
146 afx_msg void OnOpenWithUnpacker();
148 DECLARE_MESSAGE_MAP()