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 UpdateDiffItem(CDirDoc * pDirDoc);
66 bool PromptAndSaveIfNeeded(bool bAllowCancel);
67 CDirDoc* GetDirDoc() const override { return m_pDirDoc; };
68 void SetDirDoc(CDirDoc * pDirDoc) override;
69 void DirDocClosing(CDirDoc * 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); }
91 bool DoFileSave(int nBuffer);
92 bool DoFileSaveAs(int nBuffer, bool packing = true);
93 HRESULT LoadOneFile(int index, LPCTSTR filename, bool readOnly, const String& strDesc);
94 void RecompareAs(UINT id);
95 // Implementation data
97 CHexMergeView * m_pView[3]; /**< Pointer to left/right view */
99 String m_strDesc[3]; /**< Left/right side description text */
100 BUFFERTYPE m_nBufferType[3];
101 PackingInfo m_infoUnpacker;
103 // Generated message map functions
105 //{{AFX_MSG(CMergeDoc)
106 afx_msg void OnFileSave();
107 afx_msg void OnFileSaveLeft();
108 afx_msg void OnFileSaveMiddle();
109 afx_msg void OnFileSaveRight();
110 afx_msg void OnFileSaveAsLeft();
111 afx_msg void OnFileSaveAsMiddle();
112 afx_msg void OnFileSaveAsRight();
113 afx_msg void OnFileReload();
114 afx_msg void OnUpdateStatusNum(CCmdUI* pCmdUI);
115 afx_msg void OnUpdateFileSaveLeft(CCmdUI* pCmdUI);
116 afx_msg void OnUpdateFileSaveMiddle(CCmdUI* pCmdUI);
117 afx_msg void OnUpdateFileSaveRight(CCmdUI* pCmdUI);
118 afx_msg void OnUpdateFileSave(CCmdUI* pCmdUI);
119 afx_msg void OnCopyX2Y(UINT nID);
120 afx_msg void OnUpdateX2Y(CCmdUI* pCmdUI);
121 afx_msg void OnL2r();
122 afx_msg void OnUpdateL2r(CCmdUI* pCmdUI);
123 afx_msg void OnR2l();
124 afx_msg void OnUpdateR2l(CCmdUI* pCmdUI);
125 afx_msg void OnUpdateL2RNext(CCmdUI* pCmdUI);
126 afx_msg void OnUpdateR2LNext(CCmdUI* pCmdUI);
127 afx_msg void OnCopyFromLeft();
128 afx_msg void OnUpdateCopyFromLeft(CCmdUI* pCmdUI);
129 afx_msg void OnCopyFromRight();
130 afx_msg void OnUpdateCopyFromRight(CCmdUI* pCmdUI);
131 afx_msg void OnAllRight();
132 afx_msg void OnUpdateAllRight(CCmdUI* pCmdUI);
133 afx_msg void OnAllLeft();
134 afx_msg void OnUpdateAllLeft(CCmdUI* pCmdUI);
135 afx_msg void OnViewZoomIn();
136 afx_msg void OnViewZoomOut();
137 afx_msg void OnViewZoomNormal();
138 afx_msg void OnRefresh();
139 afx_msg void OnFileRecompareAs(UINT nID);
140 afx_msg void OnUpdateFileRecompareAs(CCmdUI* pCmdUI);
141 afx_msg void OnOpenWithUnpacker();
143 DECLARE_MESSAGE_MAP()