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 { return &m_infoUnpacker; };
73 PackingInfo* GetUnpacker() { return &m_infoUnpacker; };
74 void SetUnpacker(const PackingInfo* infoUnpacker) override { if (infoUnpacker) m_infoUnpacker = *infoUnpacker; };
75 CHexMergeFrame * GetParentFrame() const;
76 void UpdateHeaderPath(int pane);
77 void RefreshOptions();
78 bool OpenDocs(int nFiles, const FileLocation fileloc[], const bool bRO[], const String strDesc[]);
79 void MoveOnLoad(int nPane = -1, int nLineIndex = -1);
80 void CheckFileChanged(void) override;
81 String GetDescription(int pane) const { return m_strDesc[pane]; };
82 void SaveAs(int nBuffer, bool packing = true) { DoFileSaveAs(nBuffer, packing); }
84 bool DoFileSave(int nBuffer);
85 bool DoFileSaveAs(int nBuffer, bool packing = true);
86 HRESULT LoadOneFile(int index, LPCTSTR filename, bool readOnly, const String& strDesc);
87 void RecompareAs(UINT id);
88 // Implementation data
90 CHexMergeView * m_pView[3]; /**< Pointer to left/right view */
92 String m_strDesc[3]; /**< Left/right side description text */
93 BUFFERTYPE m_nBufferType[3];
94 PackingInfo m_infoUnpacker;
96 // Generated message map functions
98 //{{AFX_MSG(CMergeDoc)
99 afx_msg void OnFileSave();
100 afx_msg void OnFileSaveLeft();
101 afx_msg void OnFileSaveMiddle();
102 afx_msg void OnFileSaveRight();
103 afx_msg void OnFileSaveAsLeft();
104 afx_msg void OnFileSaveAsMiddle();
105 afx_msg void OnFileSaveAsRight();
106 afx_msg void OnFileReload();
107 afx_msg void OnUpdateStatusNum(CCmdUI* pCmdUI);
108 afx_msg void OnUpdateFileSaveLeft(CCmdUI* pCmdUI);
109 afx_msg void OnUpdateFileSaveMiddle(CCmdUI* pCmdUI);
110 afx_msg void OnUpdateFileSaveRight(CCmdUI* pCmdUI);
111 afx_msg void OnUpdateFileSave(CCmdUI* pCmdUI);
112 afx_msg void OnL2r();
113 afx_msg void OnR2l();
114 afx_msg void OnCopyFromLeft();
115 afx_msg void OnCopyFromRight();
116 afx_msg void OnAllRight();
117 afx_msg void OnAllLeft();
118 afx_msg void OnViewZoomIn();
119 afx_msg void OnViewZoomOut();
120 afx_msg void OnViewZoomNormal();
121 afx_msg void OnRefresh();
122 afx_msg void OnFileRecompareAs(UINT nID);
123 afx_msg void OnUpdateFileRecompareAs(CCmdUI* pCmdUI);
125 DECLARE_MESSAGE_MAP()