Databaseconnectionclasses  0.5.3
hk_report.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_REPORT
12 #define HK_REPORT
13 #include "hk_definitions.h"
14 #include "hk_presentation.h"
15 #include <list>
16 #include <vector>
17 //#include <iostream>
18 //#include <fstream>
19 #include <time.h>
20 #include <map>
21 using namespace std;
22 
23 class hk_reportsection;
25 class hk_reportdata;
26 class hk_report;
27 class hk_column;
28 
29 class hk_reportprivate;
30 
53 {
54  friend class hk_reportsectionpair;
55  friend class hk_reportsection;
56  public:
57  hk_report(void);
58  virtual ~hk_report(void);
66  void set_filename(const hk_string&,bool registerchange=true);
67  hk_string filename(void);
73  void set_use_standard_storagepath(bool s=true);
74  bool use_standard_storagepath(void);
79  hk_string outputfile(void);
80 
85  void set_begin(const hk_string&,bool registerchange=true);
86  hk_string begin(void);
91  void set_end(const hk_string&,bool registerchange=true);
92  hk_string end(void);
96  hk_reportsection* page_header(void);
100  hk_reportsection* page_footer(void);
104  hk_reportsection* report_header(void);
108  hk_reportsection* report_footer(void);
109 
114  hk_reportsection* datasection(void);
115 
120  hk_reportsectionpair* new_sectionpair(bool registerchange=true);
125  hk_reportsectionpair* new_sectionpair_at(unsigned int position,bool registerchange=true);
131  bool move_sectionpair(unsigned int actualposition,int steps);
132 
137  bool execute(void);
138  bool while_executing(void) const;
139  bool while_load_report(void) const;
140  virtual bool while_loading(void);
141  virtual bool set_mode(enum_mode s);
142 
148  void set_recodefunction(const hk_string& r,bool registerchange=true);
149  recodefunctiontype* recodefunction(void);
150  hk_string recodefunctionstring(void);
151 
152  static void add_recodetype(const hk_string& name,recodefunctiontype* f);
153  static list<hk_string>* recodelist(void);
154 
155  void new_page(void);
156 
161  void set_pagedelimiter(const hk_string& d,bool registerchange=true);
162  hk_string pagedelimiter(void);
166  vector<hk_reportsectionpair*>* sectionpairs(void);
171  virtual void set_multiplefiles(bool m=true,bool registerchange=true);
172  bool multiplefiles(void);
176  void set_fileextension(const hk_string& ext,bool registerchange=true);
177  hk_string fileextension(void);
181  void set_firstpagenumber(long int f,bool registerchange=true);
182  long int firstpagenumber(void);
188  void set_pagenamecolumn(const hk_string& c,bool registerchange=true);
189  hk_string pagenamecolumn(void);
193  void set_filebegin(const hk_string& b,bool registerchange=true);
194  hk_string filebegin(void);
198  void set_fileend(const hk_string& e,bool registerchange=true);
199  hk_string fileend(void);
207  void set_periodic(unsigned long when, const hk_string& what="",bool newpage=false,bool registerchange=true);
208  unsigned long periodic_when(void);
209  hk_string periodic_what(void);
210  bool periodic_newpage(void);
211 
215  ostream* outputstream(void);
221  void set_masterreport(hk_report* m);
222  hk_report* masterreport(void);
223  bool is_subreport(void) const;
224  bool is_subpresentation(void);
225 
229  void rowcount(unsigned long);
230  unsigned long current_rowcount(void);
231  virtual hk_font font(void);
238  long pagenumber(void);
239  long absolutepagenumber(void);
240  unsigned long rownumber(void);
241 
242  virtual bool set_presentationdatasource(long n, bool registerchange=true);
243 
244  virtual bool save_report(const hk_string& name="",bool ask=true);
245  virtual bool load_report(const hk_string& name="");
246  virtual void savedata(ostream& s);
247  virtual void loaddata(xmlNodePtr definition);
248 
253  hk_string default_reportdata(void);
254  void set_default_reportdata(const hk_string& v,bool registerchange=true);
258  hk_string default_beforereportdata(void);
259  void set_default_beforereportdata(const hk_string& v,bool registerchange=true);
263  hk_string default_afterreportdata(void);
264  void set_default_afterreportdata(const hk_string& v,bool registerchange=true);
265 
266  int default_reportprecision(void);
267  void set_default_reportprecision(int, bool registerchange=true);
268 
269  bool default_use_reportseparator(void);
270  void set_default_use_reportseparator(bool, bool registerchange=true);
271 
275  void set_default_reportdataconfigurefunction(const hk_string& f,bool registerchange=true);
276  hk_string default_reportdataconfigurefunction(void);
282  void set_default_reportsectionbegin(const hk_string& e,bool registerchange=true);
283  hk_string default_reportsectionbegin(void);
284 
290  void set_default_reportsectionend(const hk_string& e,bool registerchange=true);
291  hk_string default_reportsectionend(void);
297  void set_default_reportsectionbetweendata(const hk_string& b,bool registerchange=true);
298  hk_string default_reportsectionbetweendata(void);
304  void set_default_reportsectioncountfunction(const hk_string& f,bool registerchange=true);
305  hk_string default_reportsectioncountfunction(void);
306 
310  void set_topline(bool l=true,bool registerchange=true);
311  bool topline(void);
315  void set_bottomline(bool l=true,bool registerchange=true);
316  bool bottomline(void);
321  void set_leftline(bool l=true,bool registerchange=true);
322  bool leftline(void);
323 
327  void set_rightline(bool l=true,bool registerchange=true);
328  bool rightline(void);
332  void set_diagonalluro(bool l=true,bool registerchange=true);
333  bool diagonalluro(void);
337  void set_diagonalloru(bool l=true,bool registerchange=true);
338  bool diagonalloru(void);
343  void set_frame(bool l=true,bool registerchange=true);
344 
348  void set_borders(unsigned int left=200,unsigned int right=200,unsigned int top=200,unsigned int bottom=300,bool registerchange=true);
349  unsigned int border_left(void);
350  unsigned int border_right(void);
351  unsigned int border_top(void);
352  unsigned int border_bottom(void);
353  enum orientationtype{landscape,portrait};
357  void set_orientation(orientationtype o=portrait,bool registerchange=true);
358  orientationtype orientation(void);
359  enum pageformattype {A0=0,A1=1,A2=2,A3=3,A4=4,A5=5,A6=6,A7=7,A8=8,A9=9,A10=10,letter=11,legal=12,executive=13,tabloid=14,userdefined=15}
360  ;
364  void set_pageformat(pageformattype t=A4,bool registerchange=true);
368  void set_pageformat(unsigned int width ,unsigned int height,bool registerchange);
369  pageformattype pageformat(void);
373  unsigned int formatwidth(pageformattype t=A4) ;
377  unsigned int formatheight(pageformattype t=A4);
378  void set_reportconfigurefunction(const hk_string& f,bool registerchange);
379 
380  void set_reporttype(const hk_string&,bool registerchange=true);
381  hk_string reporttype(void);
382 
383  static void add_reporttype(const hk_string& name,reporttypefunction* f);
384  static list<hk_string>* reporttypelist(void);
385 
386  void configure_page(void);
387  void neutralize_definition(bool registerchange);
391  void init_report(void);
392  static void add_configurefunctiontype(const hk_string& name,report_configurefunction* f);
393  static list<hk_string>* configurefunctionlist(void);
394 
395  void remove_sectionpair(hk_reportsectionpair*,bool registerchange=true);
396  list<hk_string>* neededfonts(void);
397  list<hk_string>* usedfonts(void);
398  list<hk_string>* usedpsfonts(void);
402  static void set_printcommand(const hk_string& printcommand);
403  static hk_string printcommand(void);
404 
408  bool print_report(bool execute_before_printing=true);
409 
410  unsigned int designwidth(void);
411  unsigned int designheight(void);
412  unsigned int horizontal2relativ(unsigned int h);
413  unsigned int vertical2relativ(unsigned int v);
414  unsigned int relativ2horizontal(unsigned int r);
415  unsigned int relativ2vertical(unsigned int r);
416  virtual void bulk_operation(enum_bulkoperation bulkoperation);
417 static void setup_reportbasics(void);
418 hk_reportdata* get_reportdatavisible(long nr);
419 hk_reportdata* get_reportdatavisible(const hk_string& identifier);
420 
421 void set_on_new_page_action(const hk_string&,bool registerchange=true);
422 hk_string on_new_page_action(void);
423 void stop_execution(void);
424 bool execution_stopped(void);
425 
426  hk_string filelocale(void);
427  hk_string filecharset(void);
428  void set_filelocale(const hk_string&);
429  void set_filecharset(const hk_string&);
430  void set_useencodingtab(bool);
431  bool useencodingtab(void);
432  hk_encodingtab* encodingtab(void) const;
436  void set_print_full_pages_only(bool, bool registerchange);
437  bool print_full_pages_only(void);
438 
439 
440  void set_fullpagereplacefunction(const hk_string& r,bool registerchange=true);
441  recodefunctiontype* fullpagereplacefunction(void);
442  hk_string fullpagereplacefunctionstring(void);
443 
444  static void add_fullpagereplacefunctiontype(const hk_string& name,recodefunctiontype* f);
445  static list<hk_string>* fullpagereplacefunctionlist(void);
446  static void set_embedfonts(bool);
447  static bool embedfonts(void);
448 virtual hk_string tag_value(int tagnumber, bool& ok);
449 
450  protected:
451  void set_progressdialog(progress_dialogtype* progressdialog);
452  progress_dialogtype* progressdialog(void)const;
453  void remove_section(hk_reportsection*);
454 // virtual hk_string replace(const hk_string& where);
455  virtual bool datasource_disable(void);
456  virtual bool before_columns_deleted(void);
457 
461  virtual bool widget_specific_before_new_page(void);
462 
466  virtual bool widget_specific_after_new_page(void);
467 
468  virtual hk_reportsection* widget_specific_new_section(void);
469  virtual void widget_specific_after_loadreport(void){}
470  virtual void widget_specific_before_execute(void){}
471  virtual void widget_specific_after_first_outstream_created(void){}
472  virtual void widget_specific_before_last_outstream_closed(void){}
473  virtual void widget_specific_after_execute(void){}
474  virtual bool widget_specific_row_change(void);
475  virtual void widget_specific_batch_next(void);
476  virtual void widget_specific_batch_previous(void);
477  void remove_all_sections(void);
478 
479  bool p_multiplefiles;
480  vector<hk_reportsectionpair*> p_sectionpairs;
481 
482  hk_string p_default_data;
483  hk_string p_default_beforedata;
484  hk_string p_default_afterdata;
485  hk_string p_default_dataconfigurefunction;
486  virtual void sizetype_changed(void);
487  void database_delete(void);
488 
489  virtual bool action_on_new_page(void);
490 
491  private:
492  void init_section(hk_reportsection*);
493  bool internal_execute();
494  void new_outputstream(void);
495  void set_pagenumber(long int f);
496  void create_fontslists(void);
497  bool is_newfont(const hk_string&);
498  void search_sectionfonts(hk_reportsection*);
499  void write_bufferedpage(void);
500  void registerfont(hk_font*);
501  hk_reportprivate* p_private;
502 // bool p_lastpage;
503 
504  typedef map<hk_string,reporttypefunction*,less<hk_string> > reporttypelisttype ;
505  static reporttypelisttype p_reporttypefunctions;
506  static list<hk_string> p_reporttypelist;
507 
508  typedef map<hk_string,recodefunctiontype*,less<hk_string> > recodefunctionlisttype ;
509  static recodefunctionlisttype p_recodefunctions;
510  static list<hk_string> p_recodelist;
511 
512  static recodefunctionlisttype p_fullpagereplacefunctions;
513  static list<hk_string> p_fullpagereplacelist;
514 
515  typedef map<hk_string,report_configurefunction*,less<hk_string> > reportconfigurelisttype ;
516  static reportconfigurelisttype p_reportconfigurefunctions;
517  static list<hk_string> p_reportconfigurelist;
518 
519  static int p_defaultfilenumber;
520  static hk_string p_printcommand;
521  static bool p_embedfonts;
522 
523 }
524 
525 
526 ;
527 #endif
unsigned int vertical2relativ(unsigned int v)
Definition: hk_reportsection.cpp:1096
virtual bool before_columns_deleted(void)
Definition: hk_dsdatavisible.cpp:249
contains a header and a footer section
Definition: hk_reportsectionpair.h:26
represents a font
Definition: hk_font.h:26
virtual bool widget_specific_row_change(void)
Definition: hk_dsvisible.h:134
represents a section of the report.
Definition: hk_reportsection.h:92
virtual bool datasource_disable(void)
Definition: hk_dsdatavisible.cpp:207
represents the data of a field within a section.
Definition: hk_reportdata.h:75
hk_string default_reportdata(void)
Definition: hk_reportsection.h:218
base class for multidatasource based classes like forms and reports
Definition: hk_presentation.h:40
unsigned int relativ2vertical(unsigned int r)
Definition: hk_reportsection.cpp:1121
unsigned int horizontal2relativ(unsigned int h)
Definition: hk_reportsection.cpp:1083
basic class to create reports
Definition: hk_report.h:52
Definition: hk_font.h:93
unsigned int relativ2horizontal(unsigned int r)
Definition: hk_reportsection.cpp:1108
represents one column of a datasource.
Definition: hk_column.h:34
Definition: hk_report.cpp:31