Eneboo - Documentación para desarrolladores
src/kugar/mreportengine.h
Ir a la documentación de este archivo.
00001 /***************************************************************************
00002              mreportengine.h  -  Kugar report engine
00003              -------------------
00004    begin     : Sun Aug 15 1999
00005    copyright : (C) 1999 by Mutiny Bay Software
00006    email     : info@mutinybaysoftware.com
00007    copyright : (C) 2002 Alexander Dymo
00008    email     : cloudtemple@mksat.net
00009    copyright : (C) 2002-2004 InfoSiAL S.L.
00010    email     : mail@infosial.com
00011 ***************************************************************************/
00012 
00013 #ifndef MREPORTENGINE_H
00014 #define MREPORTENGINE_H
00015 
00016 #include <qobject.h>
00017 #include <qpicture.h>
00018 #include <qpaintdevicemetrics.h>
00019 #include <qsize.h>
00020 #include <qmemarray.h>
00021 #include <qvaluevector.h>
00022 #include <qdom.h>
00023 #include <FLUtil.h>
00024 #include <FLStylePainter.h>
00025 #include <math.h>
00026 
00027 #include "mlineobject.h"
00028 #include "mlabelobject.h"
00029 #include "mspecialobject.h"
00030 #include "mfieldobject.h"
00031 #include "mreportsection.h"
00032 #include "mreportdetail.h"
00033 #include "mpagecollection.h"
00034 
00040 class FL_EXPORT MReportEngine: public QObject
00041 {
00042   Q_OBJECT
00043 
00044   Q_ENUMS(RenderReportFlags)
00045 
00046 public:
00047 
00048   enum PageOrientation {
00049     Portrait,
00050     Landscape
00051   };
00052 
00053   enum PageSize {
00054     A4, B5, Letter, Legal, Executive,
00055     A0, A1, A2, A3, A5, A6, A7, A8, A9, B0, B1,
00056     B10, B2, B3, B4, B6, B7, B8, B9, C5E, Comm10E,
00057     DLE, Folio, Ledger, Tabloid, Custom, NPageSize = Custom
00058   };
00059 
00060   // Si cambias este Enum hazlo tambien en mreportviewer.h
00061   enum RenderReportFlags {
00062     Append        = 0x00000001,
00063     Display       = 0x00000002,
00064     PageBreak     = 0x00000004,
00065     FillRecords   = 0x00000008
00066   };
00067 
00068   MReportEngine(QObject *parent = 0);
00069   MReportEngine(const MReportEngine &mReportEngine, QObject *parent = 0);
00070   MReportEngine operator=(const MReportEngine &mReportEngine);
00071   virtual ~MReportEngine();
00072 
00073   bool setReportData(const QString &);
00074   bool setReportData(QIODevice *);
00075   bool setReportData(QDomNode &);
00076   bool setReportTemplate(const QString &);
00077   bool setReportTemplate(QIODevice *);
00078   bool setReportTemplate(QDomNode &);
00079 
00080   MPageCollection *renderReport(int initRow = 0, int initCol = 0,
00081                                 MPageCollection *pages = 0,
00082                                 uint flags = MReportEngine::Display);
00083 
00084 public slots:
00085 
00086   int getRenderSteps() {
00087     return records.length() / 2;
00088   }
00089 
00090   QString csvData() const {
00091     return csvData_;
00092   }
00093 
00094   float relDpi() const {
00095     return relDpi_;
00096   }
00097 
00098   float relCalcDpi() const {
00099     return relCalcDpi_;
00100   }
00101 
00102   void setStyleName(const QString &style) {
00103     styleName_ = style;
00104   }
00105 
00106   void slotCancelRendering();
00107   void setRelDpi(float relDpi);
00108 
00109 signals:
00110 
00111   void signalRenderStatus(int);
00112   void preferedTemplate(const QString &);
00113 
00114 protected:
00115 
00119   QDomDocument *rd;
00120 
00124   QDomDocument *rt;
00125 
00129   FLStylePainter *p;
00130 
00134   int pageSize;
00135 
00139   int pageOrientation;
00140 
00144   int topMargin;
00145 
00149   int bottomMargin;
00150 
00154   int leftMargin;
00155 
00159   int rightMargin;
00160 
00164   int customWidthMM;
00165 
00169   int customHeightMM;
00170 
00174   int pageWidth;
00175 
00179   int pageHeight;
00180 
00184   MReportSection *rHeader;
00185 
00189   MReportSection *pHeader;
00190 
00194   QPtrList<MReportSection> *addOnHeaders;
00195 
00199   QPtrList<MReportSection> *addOnFooters;
00200 
00204   QPtrList< MReportSection> *dHeaders;
00205 
00209   QPtrList<MReportSection> *details;
00210 
00214   QPtrList<MReportSection> *dFooters;
00215 
00219   MReportSection *pFooter;
00220 
00224   MReportSection *rFooter;
00225 
00229   int currY;
00230 
00234   int currX;
00235 
00239   int currHeight;
00240 
00244   int currPage;
00245 
00249   QDate currDate;
00250 
00254   int currRecord_;
00255 
00259   QPtrList<QMemArray<double> > *grandTotal;
00260 
00264   QPtrList<QMemArray<double> > *gDTFooters[ 10 ];
00265   QValueVector<QString> *gDTSFooters[ 10 ];
00266 
00270   bool printToPos;
00271 
00275   bool cancelRender;
00276 
00280   QString csvData_;
00281 
00285   QDomNodeList records;
00286 
00290   void clear();
00291 
00295   void clearGrantTotals();
00296 
00300   void clearFormatting();
00301 
00305   void startPage(MPageCollection *pages, int levelAddOn = -1);
00306 
00310   void endPage(MPageCollection *pages);
00311 
00315   void newPage(MPageCollection *pages, int levelAddOn = -1);
00316 
00320   void drawReportHeader(MPageCollection *pages);
00321 
00325   void drawPageHeader(MPageCollection *pages);
00326 
00330   void drawPageFooter(MPageCollection *pages);
00331 
00335   void drawReportFooter(MPageCollection *pages);
00336 
00340   void drawDetailFooter(MPageCollection *pages, int level,
00341                         QPtrList<QMemArray<double> > *gDT = 0,
00342                         QValueVector<QString> *gDTS = 0);
00343 
00347   void drawAddOnHeader(MPageCollection *pages, int level,
00348                        QPtrList<QMemArray<double> > *gDT,
00349                        QValueVector<QString> *gDTS = 0);
00350 
00355   void drawAddOnFooter(MPageCollection *pages, int level,
00356                        QPtrList<QMemArray<double> > *gDT,
00357                        QValueVector<QString> *gDTS);
00361   void drawDetailHeader(MPageCollection *pages, int level);
00362 
00366   void drawDetail(MPageCollection *pages, int level, uint &currRecord,
00367                   const int initRow = 0, const int initCol = 0);
00368 
00372   QSize getPageMetrics(int size, int orientation);
00373 
00377   void initData();
00378   void initTemplate();
00379 
00383   void setReportAttributes(QDomNode *report);
00384 
00388   void setSectionAttributes(MReportSection *section, QDomNode *report);
00389 
00393   void setDetMiscAttributes(MReportSection *section, QDomNode *report);
00394 
00398   void setDetailAttributes(MReportSection *section, QDomNode *report);
00399 
00403   void setLineAttributes(MLineObject *line, QDomNamedNodeMap *attr);
00404 
00408   void setLabelAttributes(MLabelObject *label, QDomNamedNodeMap *attr);
00409 
00413   void setSpecialAttributes(MSpecialObject *field,
00414                             QDomNamedNodeMap *attr);
00415 
00419   void setFieldAttributes(MFieldObject *field, QDomNamedNodeMap *attr);
00420 
00424   void setCalculatedFieldAttributes(MCalcObject *field,
00425                                     QDomNamedNodeMap *attr);
00426 
00432   void copy(const MReportEngine *mReportEngine);
00433 
00437   bool canDrawDetailHeader(uint level, uint currRecord, uint yPos);
00438 
00442   bool canDrawDetail(uint level, uint currRecord, uint yPos);
00443 
00447   MReportSection *findDetailHeader(int level);
00448 
00452   MReportSection *findAddOnHeader(int level);
00453 
00457   MReportSection *findDetail(int level);
00458 
00462   MReportSection *findDetailFooter(int level);
00463 
00469   MReportSection *findAddOnFooter(int level);
00470 
00475   void reserveSizeForCalcFields(QDomNamedNodeMap *fields, int level);
00476 
00482   void setFieldValues(QDomNamedNodeMap *fields, int level,
00483                       MReportSection *detail, QDomNode *ptrRecord,
00484                       bool noTotal = false);
00485 
00486   float relDpi_;
00487   float relCalcDpi_;
00488   QString styleName_;
00489   bool fillRecords_;
00490 };
00491 
00492 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'