00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef HK_REPORTSECTION
00012 #define HK_REPORTSECTION
00013 #include "hk_definitions.h"
00014 #include "hk_dsdatavisible.h"
00015 #include <list>
00016 #include <vector>
00017 #include <map>
00018 #include <iostream>
00019 #include <fstream>
00020 #include <time.h>
00021 #include "hk_presentation.h"
00022
00023 using namespace std;
00024
00025 class hk_reportsection;
00026 class hk_reportsectionpair;
00027 class hk_reportdata;
00028 class hk_report;
00029 class hk_column;
00035 typedef hk_string section_replacefunctiontype(hk_reportsection*,const hk_string& );
00036
00037 typedef struct
00038 {
00039 number sum;
00040 number min;
00041 number max;
00042 number value;
00043 unsigned long count;
00044 longnumber squaresum;
00045 char colname[75];
00046
00047 } struct_countnumbers;
00048
00092 class hk_reportsection : public hk_dsdatavisible
00093 {
00094 friend class hk_report;
00095 friend class hk_reportsectionpair;
00096 friend class hk_reportdata;
00097 public:
00105 void set_unique(bool unique=true, bool endsection=false,bool registerchange=true);
00106
00107 bool unique(void);
00111 hk_reportdata* new_data(void);
00112
00113 hk_reportdata* data_at(unsigned int);
00114
00115 vector<hk_reportdata*>* datalist(void);
00119 virtual bool actual_string(void);
00123 hk_string sectionbegin(void);
00124 void set_sectionbegin(const hk_string& b,bool registerchange=true);
00129 hk_string sectionend(void);
00130 void set_sectionend(const hk_string& e,bool registerchange=true);
00135 hk_string betweendata(void);
00136 void set_betweendata(const hk_string& b,bool registerchange=true);
00142 bool new_uniquevalue(bool justcheck=false);
00146 bool endsection(void);
00147
00152 void set_automatic_create_data(bool d=true,bool registerchange=true);
00157 bool new_page_after_section(void);
00158 void set_new_page_after_section(bool p,bool registerchange=true);
00162 bool section_was_printed(void);
00169 void set_subreport(const hk_string& subreport="",bool before_data=false,bool registerchange=true);
00170 hk_string subreportname(void);
00171 hk_report* subreport(void);
00175 void add_depending_fields(const hk_string& thisreport_field, const hk_string& subreport_field,bool registerchange=true);
00176 void clear_depending_fields(void);
00177 list<hk_string>* depending_on_thisreportfields(void);
00178 list<hk_string>* depending_on_subreportfields(void);
00179
00180 bool print_subreport_before_data(void){return p_print_subreport_before_data;}
00181 bool print_subreport(void);
00187 void set_replacefunction(const hk_string& f,bool registerchange=true);
00188 virtual hk_string replace(const hk_string& where);
00189
00190 static void add_sectionreplacefunctiontype(const hk_string& name,section_replacefunctiontype* f);
00191 static list<hk_string>* sectionreplacefunctionlist(void);
00192
00197 void reset_count(void);
00198 virtual hk_font font(void);
00199 virtual unsigned long counts_as(void);
00204 static void add_sectioncountfunctiontype(const hk_string& name,reportsectioncounttype* f);
00205 static list<hk_string>* sectioncountfunctionlist(void);
00206
00207 void set_sectioncountfunction(const hk_string& f,bool registerchange=true);
00208 hk_string sectioncountfunctionstring(void);
00209 reportsectioncounttype* sectioncountfunction(void);
00210 virtual void savedata(ostream& s,bool userdefined=false);
00211 virtual void loaddata(const hk_string& definition,bool userdefined=false);
00212 virtual void set_datasource(hk_datasource* d);
00213 virtual bool set_presentationdatasource(long n, bool registerchange=true);
00218 hk_string default_reportdata(void){return p_default_data;}
00219 void set_default_reportdata(const hk_string& v,bool registerchange=true);
00220 hk_string default_beforereportdata(void){return p_default_beforedata;}
00221 void set_default_beforereportdata(const hk_string& v,bool registerchange=true);
00222 hk_string default_afterreportdata(void){return p_default_afterdata;}
00223 void set_default_afterreportdata(const hk_string& v,bool registerchange=true);
00224 void set_default_reportdataconfigurefunction(const hk_string& f,bool registerchange=true);
00225 hk_string default_reportdataconfigurefunction(void);
00226 int default_reportprecision(void);
00227 void set_default_reportprecision(int, bool registerchange=true);
00228
00229 bool default_use_reportseparator(void);
00230 void set_default_use_reportseparator(bool, bool registerchange=true);
00231
00232 void neutralize_definition(bool registerchange);
00233 virtual void reset(void);
00234 void clear_countingfields(void);
00235 void remove_data(hk_reportdata*);
00236 hk_report* report(void);
00240 unsigned int horizontal2relativ(unsigned int h);
00244 unsigned int vertical2relativ(unsigned int v);
00248 unsigned int relativ2horizontal(unsigned int r);
00252 unsigned int relativ2vertical(unsigned int r);
00253 hk_reportsectionpair* reportsectionpair(void){return p_pair;}
00257 bool set_offset(unsigned int o,bool registerchange=true);
00258 unsigned int offset(void);
00259 void bulk_operation(hk_presentation::enum_bulkoperation bulkoperation);
00260 void set_automaticcreatedatafunction(reportsectionautomaticcreatedatatype*);
00261 reportsectionautomaticcreatedatatype* automaticcreatedatafunction(void){ return p_automaticreatedatafunction;}
00262 hk_reportdata* get_reportdatavisible(long nr);
00263 hk_reportdata* get_reportdatavisible(const hk_string& identifier);
00264
00265 protected:
00266 hk_reportsection(hk_report*);
00267 virtual ~hk_reportsection(void);
00268 virtual void before_datasource_enables(void);
00269 void remove_all_datas(void);
00270 virtual hk_reportdata* widget_specific_new_data(void);
00271 virtual void widget_specific_after_loaddata(void){}
00272 virtual void widget_specific_offset_changed(void){}
00273 virtual void sizetype_changed(void);
00274 virtual bool presentationmode_changed(void);
00275 void automatic_create_datafields(void);
00276 void force_new_section(void);
00277
00278 bool p_already_automaticcreated_data;
00279
00280 vector<hk_reportdata*> p_data;
00281
00282 bool p_unique;
00283 hk_string p_lastuniquevalue;
00284 hk_string p_sectionbegin;
00285 hk_string p_sectionend;
00286 hk_string p_betweendata;
00287 hk_report* p_report;
00288 hk_report* p_subreport;
00289 hk_string p_subreportstring;
00290 bool p_print_subreport_before_data;
00291 bool p_uniqueendsection;
00292 bool p_automatic_create_datas;
00293 bool p_newpageaftersection;
00294 bool p_sectionwasprinted;
00295 section_replacefunctiontype* p_replacefunction;
00296 hk_string p_replacefunctionstring;
00297 hk_string p_default_data;
00298 hk_string p_default_beforedata;
00299 hk_string p_default_afterdata;
00300 hk_string p_default_dataconfigurefunction;
00301 int p_default_precision;
00302 bool p_default_use_thousandsseparator;
00303 unsigned int p_offset;
00304 void raise_widget(hk_reportdata*);
00305 void lower_widget(hk_reportdata*);
00306
00307 private:
00308 void create_countingfields(void);
00309 void count_countingfields(void);
00310 void clear_counting(void);
00311 reportsectioncounttype* p_sectioncountfunction;
00312 hk_string p_sectioncountfunctionstring;
00313 hk_datasource* p_subreportdatasource;
00314 bool p_automatic_created_datasource;
00315 vector<struct_countnumbers> p_countings;
00316
00317 typedef map<hk_string,reportsectioncounttype*,less<hk_string> > sectioncountlisttype ;
00318 static sectioncountlisttype p_sectioncountfunctions;
00319 static list<hk_string> p_sectioncountfunctionlist;
00320
00321 typedef map<hk_string,section_replacefunctiontype*,less<hk_string> > sectionreplacelisttype ;
00322 static sectionreplacelisttype p_sectionreplacefunctions;
00323 static list<hk_string> p_sectionreplacefunctionlist;
00324 list<hk_string> p_depending_thisreport_fields;
00325 list<hk_string> p_depending_subreport_fields;
00326 hk_reportsectionpair* p_pair;
00327 bool p_forcenewsection;
00328 reportsectionautomaticcreatedatatype* p_automaticreatedatafunction;
00329 };
00330 #endif