1 //////////////////////////////////////////////////////////////////////////
2 //
3 // pgAdmin III - PostgreSQL Tools
4 //
5 // Copyright (C) 2002 - 2016, The pgAdmin Development Team
6 // This software is released under the PostgreSQL Licence
7 //
8 // frmReport.h - The report file dialogue
9 //
10 //////////////////////////////////////////////////////////////////////////
11 
12 #ifndef FRMREPORT_H
13 #define FRMREPORT_H
14 
15 #include "dlg/dlgClasses.h"
16 #include "ctl/ctlListView.h"
17 #include "ctl/ctlSQLResult.h"
18 
19 // Class declarations
20 class frmReport : public pgDialog
21 {
22 public:
23 	frmReport(wxWindow *p);
24 	~frmReport();
25 
26 	void SetReportTitle(const wxString &t);
27 
28 	void XmlAddHeaderValue(const wxString &name, const wxString &value);
29 	int XmlCreateSection(const wxString &name);
30 	void XmlSetSectionTableHeader(const int section, const int columns, const wxChar *name, ...);
31 	void XmlAddSectionTableRow(const int section, const int number, const int columns, const wxChar *value, ...);
32 	void XmlAddSectionTableFromListView(const int section, ctlListView *list);
33 	void XmlAddSectionTableFromGrid(const int section, ctlSQLResult *grid);
XmlSetSectionTableInfo(const int section,const wxString & info)34 	void XmlSetSectionTableInfo(const int section, const wxString &info)
35 	{
36 		sectionTableInfo[section - 1] = info;
37 	};
38 	void XmlSetSectionSql(int section, const wxString &sql);
39 	void XmlAddSectionValue(const int section, const wxString &name, const wxString &value);
40 
41 private:
42 	void OnChange(wxCommandEvent &ev);
43 	void OnHelp(wxCommandEvent &ev);
44 	void OnOK(wxCommandEvent &ev);
45 	void OnCancel(wxCommandEvent &ev);
46 	void OnBrowseFile(wxCommandEvent &ev);
47 	void OnBrowseStylesheet(wxCommandEvent &ev);
48 
49 	wxString GetSectionTableColumns(const int section);
50 	wxString GetSectionTableRows(const int section);
51 	wxString GetSectionTable(const int section);
52 	wxString GetSection(const int section);
53 	wxString GetXmlReport(const wxString &stylesheet);
54 	wxString XslProcessReport(const wxString &xml, const wxString &xsl);
55 
56 	wxString GetCssLink(const wxString &file);
57 	wxString GetEmbeddedCss(const wxString &css);
58 	const wxString GetDefaultCss();
59 	wxString GetDefaultXsl(const wxString &css);
60 
61 	wxWindow *parent;
62 	wxString header;
63 	wxArrayString sectionName, sectionData, sectionTableHeader, sectionTableRows, sectionTableInfo, sectionSql;
64 
65 	DECLARE_EVENT_TABLE()
66 };
67 
68 ///////////////////////////////////////////////////////
69 // Report Factory base class
70 ///////////////////////////////////////////////////////
71 class reportBaseFactory : public actionFactory
72 {
73 protected:
reportBaseFactory(menuFactoryList * list)74 	reportBaseFactory(menuFactoryList *list) : actionFactory(list) {}
75 	wxWindow *StartDialog(frmMain *form, pgObject *obj);
GetFrmMain()76 	frmMain *GetFrmMain()
77 	{
78 		return parent;
79 	};
GenerateReport(frmReport * report,pgObject * object)80 	virtual void GenerateReport(frmReport *report, pgObject *object) {};
81 
82 	frmMain *parent;
83 public:
CheckEnable(pgObject * obj)84 	bool CheckEnable(pgObject *obj)
85 	{
86 		return false;
87 	};
88 };
89 
90 
91 ///////////////////////////////////////////////////////
92 // Object properties report
93 ///////////////////////////////////////////////////////
94 class reportObjectPropertiesFactory : public reportBaseFactory
95 {
96 public:
97 	reportObjectPropertiesFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
98 	bool CheckEnable(pgObject *obj);
99 	void GenerateReport(frmReport *report, pgObject *object);
100 };
101 
102 ///////////////////////////////////////////////////////
103 // Object DDL report
104 ///////////////////////////////////////////////////////
105 class reportObjectDdlFactory : public reportBaseFactory
106 {
107 public:
108 	reportObjectDdlFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
109 	bool CheckEnable(pgObject *obj);
110 	void GenerateReport(frmReport *report, pgObject *object);
111 };
112 
113 ///////////////////////////////////////////////////////
114 // Object Data dictionary report
115 ///////////////////////////////////////////////////////
116 class reportObjectDataDictionaryFactory : public reportBaseFactory
117 {
118 public:
119 	reportObjectDataDictionaryFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
120 	bool CheckEnable(pgObject *obj);
121 	void GenerateReport(frmReport *report, pgObject *object);
122 };
123 
124 ///////////////////////////////////////////////////////
125 // Object statistics report
126 ///////////////////////////////////////////////////////
127 class reportObjectStatisticsFactory : public reportBaseFactory
128 {
129 public:
130 	reportObjectStatisticsFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
131 	bool CheckEnable(pgObject *obj);
132 	void GenerateReport(frmReport *report, pgObject *object);
133 };
134 
135 ///////////////////////////////////////////////////////
136 // Object dependencies report
137 ///////////////////////////////////////////////////////
138 class reportObjectDependenciesFactory : public reportBaseFactory
139 {
140 public:
141 	reportObjectDependenciesFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
142 	bool CheckEnable(pgObject *obj);
143 	void GenerateReport(frmReport *report, pgObject *object);
144 };
145 
146 ///////////////////////////////////////////////////////
147 // Object Dependents report
148 ///////////////////////////////////////////////////////
149 class reportObjectDependentsFactory : public reportBaseFactory
150 {
151 public:
152 	reportObjectDependentsFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
153 	bool CheckEnable(pgObject *obj);
154 	void GenerateReport(frmReport *report, pgObject *object);
155 };
156 
157 ///////////////////////////////////////////////////////
158 // Object list report
159 ///////////////////////////////////////////////////////
160 class reportObjectListFactory : public reportBaseFactory
161 {
162 public:
163 	reportObjectListFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
164 	bool CheckEnable(pgObject *obj);
165 	void GenerateReport(frmReport *report, pgObject *object);
166 };
167 
168 #endif
169