OSDN Git Service

Merge from rev.7103:7118
[winmerge-jp/winmerge-jp.git] / Src / DiffTextBuffer.h
1 /** 
2  * @file  DiffTextBuffer.h
3  *
4  * @brief Declaration of CDiffTextBuffer class
5  */
6 // ID line follows -- this is updated by SVN
7 // $Id: DiffTextBuffer.h 6879 2009-06-29 10:00:33Z kimmov $
8
9 #ifndef _DIFFTEXT_BUFFER_H_
10 #define _DIFFTEXT_BUFFER_H_
11
12 #include "GhostTextBuffer.h"
13 #include "FileTextEncoding.h"
14
15 class CMergedoc;
16 class PackingInfo;
17
18 /**
19  * @brief Specialized buffer to save file data
20  */
21 class CDiffTextBuffer : public CGhostTextBuffer
22 {
23         friend class CMergeDoc;
24
25 private :
26         CMergeDoc * m_pOwnerDoc; /**< Merge document owning this buffer. */
27         int m_nThisPane; /**< Left/Right side */
28         String m_strTempPath; /**< Temporary files folder. */
29         int m_unpackerSubcode; /**< Plugin information. */
30         bool m_bMixedEOL; /**< EOL style of this buffer is mixed? */
31
32         /** 
33          * @brief Unicode encoding from ucr::UNICODESET.
34          *
35          * @note m_unicoding and m_codepage are indications of how the buffer is
36          * supposed to be saved on disk. In memory, it is invariant, depending on
37          * build:
38          * - ANSI: in memory it is CP_ACP/CP_THREAD_ACP 8-bit characters
39          * - Unicode: in memory it is wchars
40          */
41         FileTextEncoding m_encoding;
42
43         BOOL FlagIsSet(UINT line, DWORD flag) const;
44
45 public :
46         CDiffTextBuffer(CMergeDoc * pDoc, int pane);
47
48         void SetTempPath(const String &path);
49         virtual void AddUndoRecord (BOOL bInsert, const CPoint & ptStartPos,
50                 const CPoint & ptEndPos, LPCTSTR pszText, int cchText,
51                 int nLinesToValidate, int nActionType = CE_ACTION_UNKNOWN,
52                 CDWordArray *paSavedRevisonNumbers = NULL);
53         bool curUndoGroup();
54         void ReplaceFullLines(CDiffTextBuffer& dbuf, CDiffTextBuffer& sbuf, CCrystalTextView * pSource, int nLineBegin, int nLineEnd, int nAction =CE_ACTION_UNKNOWN);
55
56         int LoadFromFile(LPCTSTR pszFileName, PackingInfo * infoUnpacker,
57                 LPCTSTR filteredFilenames, BOOL & readOnly, CRLFSTYLE nCrlfStyle,
58                 const FileTextEncoding & encoding, CString &sError);
59         int SaveToFile (LPCTSTR pszFileName, BOOL bTempFile, String & sError,
60                 PackingInfo * infoUnpacker = NULL, CRLFSTYLE nCrlfStyle = CRLF_STYLE_AUTOMATIC,
61                 BOOL bClearModifiedFlag = TRUE, BOOL bForceUTF8 = FALSE);
62         ucr::UNICODESET getUnicoding() const { return m_encoding.m_unicoding; }
63         void setUnicoding(ucr::UNICODESET value) { m_encoding.m_unicoding = value; }
64         int getCodepage() const { return m_encoding.m_codepage; }
65         void setCodepage(int value) { m_encoding.m_codepage = value; }
66         bool getHasBom() const { return m_encoding.m_bom; }
67         void setHasBom(bool value) { m_encoding.m_bom = value; }
68         const FileTextEncoding & getEncoding() const { return m_encoding; }
69         bool IsMixedEOL() const { return m_bMixedEOL; }
70         void SetMixedEOL(bool bMixed) { m_bMixedEOL = bMixed; }
71
72         // If line has text (excluding eol), set strLine to text (excluding eol)
73         BOOL GetLine(int nLineIndex, CString &strLine) const;
74
75         // if line has any text (including eol), set strLine to text (including eol)
76         BOOL GetFullLine(int nLineIndex, CString &strLine) const;
77
78         virtual void SetModified (BOOL bModified = TRUE);
79         void prepareForRescan();
80         virtual void OnNotifyLineHasBeenEdited(int nLine);
81         bool IsInitialized() const;
82 };
83
84 #endif // _DIFFTEXT_BUFFER_H_