Databaseconnectionclasses  0.5.3
hk_reportsection.h
1 // ****************************************************************************
2 // copyright (c) 2000-2005 Horst Knorr <hk_classes@knoda.org>
3 // This file is part of the hk_classes library.
4 // This file may be distributed and/or modified under the terms of the
5 // GNU Library Public License version 2 as published by the Free Software
6 // Foundation and appearing in the file COPYING included in the
7 // packaging of this file.
8 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
9 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
10 // ****************************************************************************
11 #ifndef HK_REPORTSECTION
12 #define HK_REPORTSECTION
13 #include "hk_definitions.h"
14 #include "hk_dsdatavisible.h"
15 #include <list>
16 #include <vector>
17 #include <map>
18 #include <iostream>
19 #include <fstream>
20 #include <time.h>
21 #include "hk_presentation.h"
22 
23 using namespace std;
24 
25 class hk_reportsection;
27 class hk_reportdata;
28 class hk_report;
29 class hk_column;
35 typedef hk_string section_replacefunctiontype(hk_reportsection*,const hk_string& );
36 
37 typedef struct
38 {
39  number sum;
40  number min;
41  number max;
42  number value;
43  unsigned long count;
44  longnumber squaresum;
45  char colname[75];
46 // enum_fieldtype fieldtype;
48 
93 {
94  friend class hk_report;
95  friend class hk_reportsectionpair;
96  friend class hk_reportdata;
97  public:
105  void set_unique(bool unique=true, bool endsection=false,bool registerchange=true);
106 //hk_string unique_column(void){return p_uniquecolumnname;}
107  bool unique(void);
111  hk_reportdata* new_data(void);
112 //hk_reportdata* new_data_at(unsigned int);
113  hk_reportdata* data_at(unsigned int);
114 //void delete_at(unsigned int);
115  vector<hk_reportdata*>* datalist(void);
119  virtual bool actual_string(void);
123  hk_string sectionbegin(void);
124  void set_sectionbegin(const hk_string& b,bool registerchange=true);
129  hk_string sectionend(void);
130  void set_sectionend(const hk_string& e,bool registerchange=true);
135  hk_string betweendata(void);
136  void set_betweendata(const hk_string& b,bool registerchange=true);
142  bool new_uniquevalue(bool justcheck=false);
146  bool endsection(void);
147 
152  void set_automatic_create_data(bool d=true,bool registerchange=true);
157  bool new_page_after_section(void);
158  void set_new_page_after_section(bool p,bool registerchange=true);
162  bool section_was_printed(void);
169  void set_subreport(const hk_string& subreport="",bool before_data=false,bool registerchange=true);
170  hk_string subreportname(void);
171  hk_report* subreport(void);
175  void add_depending_fields(const hk_string& thisreport_field, const hk_string& subreport_field,bool registerchange=true);
176  void clear_depending_fields(void);
177  list<hk_string>* depending_on_thisreportfields(void);
178  list<hk_string>* depending_on_subreportfields(void);
179 
180  bool print_subreport_before_data(void){return p_print_subreport_before_data;}
181  bool print_subreport(void);
187  void set_replacefunction(const hk_string& f,bool registerchange=true);
188  virtual hk_string replace(const hk_string& where);
189 
190  static void add_sectionreplacefunctiontype(const hk_string& name,section_replacefunctiontype* f);
191  static list<hk_string>* sectionreplacefunctionlist(void);
192 
197  void reset_count(void);
198  virtual hk_font font(void);
199  virtual unsigned long counts_as(void);
204  static void add_sectioncountfunctiontype(const hk_string& name,reportsectioncounttype* f);
205  static list<hk_string>* sectioncountfunctionlist(void);
206 
207  void set_sectioncountfunction(const hk_string& f,bool registerchange=true);
208  hk_string sectioncountfunctionstring(void);
209  reportsectioncounttype* sectioncountfunction(void);
210  virtual void savedata(ostream& s,bool userdefined=false);
211  virtual void loaddata(xmlNodePtr definition,bool userdefined=false);
212  virtual void set_datasource(hk_datasource* d);
213  virtual bool set_presentationdatasource(long n, bool registerchange=true);
218  hk_string default_reportdata(void){return p_default_data;}
219  void set_default_reportdata(const hk_string& v,bool registerchange=true);
220  hk_string default_beforereportdata(void){return p_default_beforedata;}
221  void set_default_beforereportdata(const hk_string& v,bool registerchange=true);
222  hk_string default_afterreportdata(void){return p_default_afterdata;}
223  void set_default_afterreportdata(const hk_string& v,bool registerchange=true);
224  void set_default_reportdataconfigurefunction(const hk_string& f,bool registerchange=true);
225  hk_string default_reportdataconfigurefunction(void);
226  int default_reportprecision(void);
227  void set_default_reportprecision(int, bool registerchange=true);
228 
229  bool default_use_reportseparator(void);
230  void set_default_use_reportseparator(bool, bool registerchange=true);
231 
232  void neutralize_definition(bool registerchange);
233  virtual void reset(void);
234  void clear_countingfields(void);
235  void remove_data(hk_reportdata*);
236  hk_report* report(void);
240  unsigned int horizontal2relativ(unsigned int h);
244  unsigned int vertical2relativ(unsigned int v);
248  unsigned int relativ2horizontal(unsigned int r);
252  unsigned int relativ2vertical(unsigned int r);
253  hk_reportsectionpair* reportsectionpair(void){return p_pair;}
257  bool set_offset(unsigned int o,bool registerchange=true);
258  unsigned int offset(void);
259  void bulk_operation(hk_presentation::enum_bulkoperation bulkoperation);
260  void set_automaticcreatedatafunction(reportsectionautomaticcreatedatatype*);
261  reportsectionautomaticcreatedatatype* automaticcreatedatafunction(void){ return p_automaticreatedatafunction;}
262 hk_reportdata* get_reportdatavisible(long nr);
263 hk_reportdata* get_reportdatavisible(const hk_string& identifier);
264  bool is_fully_printed(void);
265  void set_print_section(bool);
266  bool print_section(void);
267 
268 
269  protected:
271  virtual ~hk_reportsection(void);
272  virtual void before_datasource_enables(void);
273  void remove_all_datas(void);
274  virtual hk_reportdata* widget_specific_new_data(void);
275  virtual void widget_specific_after_loaddata(void){}
276  virtual void widget_specific_offset_changed(void){}
277  virtual void sizetype_changed(void);
278  virtual bool presentationmode_changed(void);
279  void automatic_create_datafields(void);
280  void force_new_section(void);
281 
282  bool p_already_automaticcreated_data;
283 
284  vector<hk_reportdata*> p_data;
285 // hk_string p_uniquecolumnname;
286  bool p_unique;
287  hk_string p_lastuniquevalue;
288  hk_string p_sectionbegin;
289  hk_string p_sectionend;
290  hk_string p_betweendata;
291  hk_report* p_report;
292  hk_report* p_subreport;
293  hk_string p_subreportstring;
294  bool p_print_subreport_before_data;
295  bool p_uniqueendsection;
296  bool p_automatic_create_datas;
297  bool p_newpageaftersection;
298  bool p_sectionwasprinted;
299  section_replacefunctiontype* p_replacefunction;
300  hk_string p_replacefunctionstring;
301  hk_string p_default_data;
302  hk_string p_default_beforedata;
303  hk_string p_default_afterdata;
304  hk_string p_default_dataconfigurefunction;
305  int p_default_precision;
306  bool p_default_use_thousandsseparator;
307  unsigned int p_offset;
310 
311  private:
312  void create_countingfields(void);
313  void count_countingfields(void);
314  void clear_counting(void);
315  reportsectioncounttype* p_sectioncountfunction;
316  hk_string p_sectioncountfunctionstring;
317  hk_datasource* p_subreportdatasource;
318  bool p_automatic_created_datasource;
319  vector<struct_countnumbers> p_countings;
320 
321  typedef map<hk_string,reportsectioncounttype*,less<hk_string> > sectioncountlisttype ;
322  static sectioncountlisttype p_sectioncountfunctions;
323  static list<hk_string> p_sectioncountfunctionlist;
324 
325  typedef map<hk_string,section_replacefunctiontype*,less<hk_string> > sectionreplacelisttype ;
326  static sectionreplacelisttype p_sectionreplacefunctions;
327  static list<hk_string> p_sectionreplacefunctionlist;
328  list<hk_string> p_depending_thisreport_fields;
329  list<hk_string> p_depending_subreport_fields;
330  hk_reportsectionpair* p_pair;
331  bool p_forcenewsection;
332  reportsectionautomaticcreatedatatype* p_automaticreatedatafunction;
333  bool p_printsection;
334 };
335 #endif
virtual void raise_widget(bool registerchange=true)
Definition: hk_reportdata.cpp:957
contains a header and a footer section
Definition: hk_reportsectionpair.h:26
represents a font
Definition: hk_font.h:26
void set_replacefunction(const hk_string &f, bool registerchange=true)
Definition: hk_reportdata.cpp:465
virtual void set_datasource(hk_datasource *d)
Definition: hk_dsdatavisible.cpp:99
Definition: hk_reportsection.h:37
represents a section of the report.
Definition: hk_reportsection.h:92
represents the data of a field within a section.
Definition: hk_reportdata.h:75
virtual void lower_widget(bool registerchange=true)
Definition: hk_reportdata.cpp:949
hk_string default_reportdata(void)
Definition: hk_reportsection.h:218
hk_string actual_string(void)
Definition: hk_reportdata.cpp:245
represents a resultquery or a table of a database.
Definition: hk_datasource.h:45
Definition: hk_definitions.h:211
hk_report * report(void)
Definition: hk_reportdata.cpp:925
base class for visible widgets with data connection
Definition: hk_dsdatavisible.h:32
basic class to create reports
Definition: hk_report.h:52
Definition: hk_definitions.h:205
represents one column of a datasource.
Definition: hk_column.h:34