OSDN Git Service

Avoid an assertion failure when loading settings from winmerge.ini
[winmerge-jp/winmerge-jp.git] / Src / DirCmpReport.h
1 /** 
2  * @file  DirCmpReport.h
3  *
4  * @brief Declaration file for DirCmpReport.
5  *
6  */
7 #pragma once
8
9 #include <vector>
10 #include "UnicodeString.h"
11 #include "PathContext.h"
12 #include "DirReportTypes.h"
13 #include "IListCtrl.h"
14
15 struct DiffFuncStruct;
16
17 /**
18  * @brief This class creates directory compare reports.
19  *
20  * This class creates a directory compare report. To make things easier
21  * we read data from view's listview. Reading from listview avoids
22  * re-formatting data and complex GUI for selecting what info to show in
23  * reports. Downside is we only have data that is visible in GUI.
24  *
25  * @todo We should read DIFFITEMs from CDirDoc and format data to better
26  * fit for reporting. Duplicating formatting and sorting code should be
27  * avoided.
28  */
29
30 struct IFileCmpReport
31 {
32         virtual ~IFileCmpReport() {}
33         virtual bool operator()(REPORT_TYPE nReportType, IListCtrl *pList, int nIndex, const String &sDestDir, String &sLinkPath) = 0;
34 };
35
36 class DirCmpReport
37 {
38 public:
39
40         explicit DirCmpReport(const std::vector<String>& colRegKeys);
41         void SetList(IListCtrl *pList);
42         void SetRootPaths(const PathContext &paths);
43         void SetReportType(REPORT_TYPE nReportType) { m_nReportType = nReportType;  }
44         REPORT_TYPE GetReportType() const { return m_nReportType;  }
45         void SetReportFile(const String& sReportFile) { m_sReportFile = sReportFile; }
46         String GetReportFile() const { return m_sReportFile; }
47         void SetColumns(int columns);
48         void SetFileCmpReport(IFileCmpReport *pFileCmpReport);
49         void SetCopyToClipboard(bool bCopyToClipbard) { m_bCopyToClipboard = bCopyToClipbard;  }
50         bool GetCopyToClipboard() const { return m_bCopyToClipboard;  }
51         void SetIncludeFileCmpReport(bool bIncludeFileCmpReport) { m_bIncludeFileCmpReport = bIncludeFileCmpReport; }
52         bool GetIncludeFileCmpReport() const { return m_bIncludeFileCmpReport; }
53         void SetDiffFuncStruct(DiffFuncStruct* myStruct) { m_myStruct = myStruct; }
54         bool GenerateReport(String &errStr);
55
56 protected:
57         void GenerateReport(REPORT_TYPE nReportType);
58         void WriteString(const String&);
59         void WriteStringEntityAware(const String& sText);
60         void GenerateHeader();
61         void GenerateContent();
62         void GenerateHTMLHeader();
63         void GenerateHTMLHeaderBodyPortion();
64         void GenerateXmlHeader();
65         void GenerateXmlHtmlContent(bool xml);
66         void GenerateHTMLFooter();
67         void GenerateXmlFooter();
68
69 private:
70         std::unique_ptr<IListCtrl> m_pList; /**< Pointer to UI-list */
71         PathContext m_rootPaths; /**< Root paths, printed to report */
72         String m_sTitle; /**< Report title, built from root paths */
73         String m_sReportFile;
74         int m_nColumns; /**< Columns in UI */
75         String m_sSeparator; /**< Column separator for report */
76         CFile *m_pFile; /**< File to write report to */
77         std::vector<String> m_colRegKeys; /**< Key names for currently displayed columns */
78         std::unique_ptr<IFileCmpReport> m_pFileCmpReport;
79         bool m_bIncludeFileCmpReport; /**< Do we include file compare report in folder compare report? */
80         bool m_bOutputUTF8;
81         REPORT_TYPE m_nReportType; /**< Report type integer */
82         bool m_bCopyToClipboard; /**< Do we copy report to clipboard? */
83         DiffFuncStruct* m_myStruct;
84 };