1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00
LibQQt/qqtword.h

153 lines
3.3 KiB
C
Raw Normal View History

2016-12-29 16:49:18 +08:00
#ifndef QQTWORD_H
#define QQTWORD_H
#include <QObject>
#include "qqtgui-qt.h"
#include "qqtprinter.h"
#include "qqtgraphicsscene.h"
enum ESpanFlag
{
ESpanNone = 0,
ESpanLeft = 1,
ESpanTop = 2,
ESpanRight = 4,
ESpanBottom = 8,
ESpanMiddle = 16,
};
Q_DECLARE_FLAGS(ESpanFlags, ESpanFlag)
class QQTWord : public QObject
{
Q_OBJECT
public:
explicit QQTWord(QObject *parent = 0);
void addText(const QString& text, QFont m_font = QFont(),
Qt::Alignment align = Qt::AlignHCenter, QPointF point= QPointF(0, 0));
void addSignoffText(const QString& text, QFont m_font = QFont());
void addTable(const QTableView* table, QPointF pos = QPointF(0, 0));
2017-08-13 11:49:27 +08:00
int pageNum();
2016-12-29 16:49:18 +08:00
QQTGraphicsScene* getPage(int num);
void exportPdf(const QString &pdf);
void print();
QRectF clientRectF();
QRectF paperRect();
void setMargin(qreal left = 0, qreal right = 0,
qreal top = 0, qreal botoom = 0);
void setLineSpacing(qreal mainSpacing = 0);
void setHeaderSize(qreal size = 0);
void setFooterSize(qreal size = 0);
2017-08-13 11:49:27 +08:00
QFont font();
2016-12-29 16:49:18 +08:00
void setFont(QFont m_font = QFont());
void setHeaderFont(QFont m_font = QFont());
QFont mainFont() { return m_mainFont; }
QFont titleFont() { return m_titleFont; }
QFont title2Font() { return m_title2Font; }
QFont headerFont() { return m_headerFont; }
void setHeaderLine(bool show = false);
void setFooterLine(bool show = false);
void setHeaderText(const QString &text, QFont m_font = QFont(),
Qt::Alignment align = Qt::AlignHCenter);
void setFooterText(const QString& text, QFont m_font = QFont(),
Qt::Alignment align = Qt::AlignHCenter);
/**
* @brief initWordExpress
*/
void initWord();
protected:
virtual void adjustdy(qreal dy0);
virtual void createFrame();
virtual void paintPageHeader();
virtual void paintPageFooter();
signals:
public slots:
private:
2017-08-13 11:49:27 +08:00
/*
*
*/
2016-12-29 16:49:18 +08:00
QQTPrinter* pr;
2017-08-13 11:49:27 +08:00
/*
*
*/
2016-12-29 16:49:18 +08:00
QVector<QQTGraphicsScene*> pageSceneVector;
QQTGraphicsScene* pageScene;
2017-08-13 11:49:27 +08:00
/*
*
*/
2016-12-29 16:49:18 +08:00
int logicalDpiX;
int logicalDpiY;
QRectF sceneRect;
qreal xpos, xpos2, ypos, ypos2;
qreal dx, dy;
qreal leftMargin;
qreal rightMargin;
qreal topMargin;
qreal bottomMargin;
qreal mainHeight;
qreal titleHeight;
qreal title2Height;
qreal headerHeight;
qreal mainSpacing;
qreal titleSpacing;
qreal title2Spacing;
qreal headerSpacing;
2017-08-13 11:49:27 +08:00
/*
*
*/
2016-12-29 16:49:18 +08:00
qreal headerSize;
QFont m_headerFont;
QFontMetrics *headerFmt;
QString headerText;
2017-08-13 11:49:27 +08:00
/*
*
*/
2016-12-29 16:49:18 +08:00
qreal footerSize;
QString footerStdText;
QString footerText;
2017-08-13 11:49:27 +08:00
/*
*
*/
2016-12-29 16:49:18 +08:00
QFont m_titleFont;
QFontMetrics *titleFmt;
2017-08-13 11:49:27 +08:00
/*
*
*/
2016-12-29 16:49:18 +08:00
QFont m_title2Font;
QFontMetrics *title2Fmt;
2017-08-13 11:49:27 +08:00
/*
*
*/
2016-12-29 16:49:18 +08:00
QFont m_mainFont;
QFontMetrics *mainFmt;
2017-08-13 11:49:27 +08:00
/*
* 使
*/
2016-12-29 16:49:18 +08:00
QFont m_font;
QFontMetrics *fmt;
QHash<int, ESpanFlags> tableSpans(const QTableView* table);
};
#endif // QQTWORD_H