OSDN Git Service

Binary Compare: Fix the problem that the file cannot be saved after creating a new one
[winmerge-jp/winmerge-jp.git] / Src / HexMergeDoc.h
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 /////////////////////////////////////////////////////////////////////////////
6 /** 
7  * @file  HexMergeDoc.h
8  *
9  * @brief Declaration of CHexMergeDoc class
10  */
11 #pragma once
12
13 #include "PathContext.h"
14 #include "FileLocation.h"
15 #include "IMergeDoc.h"
16 #include "FileTransform.h"
17
18 class CDirDoc;
19 class CHexMergeFrame;
20 class CHexMergeView;
21
22 /**
23  * @brief Document class for bytewise merging two files presented as hexdumps
24  */
25 class CHexMergeDoc : public CDocument, public IMergeDoc
26 {
27 public:
28         enum class BUFFERTYPE
29         {
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 */
34         };
35
36 // Attributes
37 public:
38         static int m_nBuffersTemp;
39         int m_nBuffers;
40         PathContext m_filePaths; /**< Filepaths for this document */
41
42 // Begin declaration of CHexMergeDoc
43
44 protected: // create from serialization only
45         CHexMergeDoc();
46         DECLARE_DYNCREATE(CHexMergeDoc)
47
48         
49         // Operations
50 public: 
51         void SetMergeViews(CHexMergeView * pView[]);
52         CHexMergeView *GetActiveMergeView() const;
53
54         // Overrides
55         // ClassWizard generated virtual function overrides
56         //{{AFX_VIRTUAL(CMergeDoc)
57         public:
58         virtual BOOL SaveModified();
59         virtual void SetTitle(LPCTSTR lpszTitle);
60         //}}AFX_VIRTUAL
61
62 // Implementation
63 public:
64         ~CHexMergeDoc();
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); }
83 private:
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
89 protected:
90         CHexMergeView * m_pView[3]; /**< Pointer to left/right view */
91         CDirDoc * m_pDirDoc;
92         String m_strDesc[3]; /**< Left/right side description text */
93         BUFFERTYPE m_nBufferType[3];
94         PackingInfo m_infoUnpacker;
95
96 // Generated message map functions
97 protected:
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);
124         //}}AFX_MSG
125         DECLARE_MESSAGE_MAP()
126 };
127