113 lines
3.5 KiB
C
Raw Permalink Normal View History

2022-07-30 11:50:01 +08:00
/********************************************************************
@date: 2017-11-20
@author: gongwei@vishee.com
@edit_by
@brief: word操作类word
1
*********************************************************************/
#ifndef WORDOPERATE_H
#define WORDOPERATE_H
#include <QObject>
#include <QObject>
#include <ActiveQt/QAxWidget>
#include <ActiveQt/QAxObject>
#include <QTextBlockFormat>
#include <qtextedit.h>
class WordOperate : public QObject
{
Q_OBJECT
public:
enum AlignmentType{
AlignmentTypeLeft,
AlignmentTypeCenter,
AlignmentTypeRight
};
enum SpaceType//
{
Space1,
Space15,
Space2,
SpaceAtLeast,
SpaceExactly,
SpaceMuti
};
explicit WordOperate(QObject *parent = 0);
WordOperate(const QString& strFile, QObject *parent = 0);
~WordOperate();
bool open(bool bVisable = false);
bool open(const QString& strFile, bool bVisable = true);
bool close();
bool isOpen();
void save();
bool saveAs(const QString& strSaveFile);
// 创建表格
void intsertTable(int row, int column);
// 设置表格内容
QAxObject* setCellString(int nTable, int row, int column, const QString& text);
// 合并单元格
void MergeCell(int nTable,int nStartRow,int nStartCol,int nEndRow,int nEndCol,bool bVerticalCenter = false );
//拆分单元格
void SplitCell(int nTable,int nStartRow,int nStartCol,int nRow,int nCol);
// 在表格中插入图片
void insertCellPic(int nTable, int row,int column,const QString& picPath);
//光标跳转类似于表格中的tab
void moveRight();
void SetMarkPic(QString sLabel, QString sFile);
// 设置文字
void SetFont(QString strFamily,int nSize,bool bBold = false,bool bItalic = false,bool bUnderLine = false);
// 设置表格文字字体
void SetTableFont(QAxObject* cell,QString strFamily,int nSize,bool bBold = false,bool bItalic = false);
// 设置表格文字字体
void SetTableFont(int nTable,int row,int column,QString strFamily,int nSize,bool bBold = false,bool bItalic = false,bool bUnderLine=false);
// 设置对其方式
void SetAlign(AlignmentType nAlign);
// 打印当期前document
void Print();
void Print(int nPageFrom,int nPageTo);
//光标移到末尾
void moveForEnd();
//回车
void insertEnter();
//插入图片
void InsertPicture(QString picturePath);
//插入文字
void SetText(QString strText);
//获取页边距
void GetPageMargin(double &dbLeft,double &dbTop,double &dbRight,double &dbBottom);
//设置页边距
void SetPageMargin(double dbLeft,double dbTop,double dbRight,double dbBottom);
//设置文档可见
void SetVisible(bool bVisable = true);
//设置表格行高
bool SetTableRowHeight(int nTable,int row,int height);
//设置段落行间距
void SetParagraphSpacing(SpaceType type,int space=0);
//设置列宽
void SetColumnWidth(int nTable, int column, int width);
//隐藏表格边框
void HideBorder(int nTable,int row,int column,int item);
//增加table行
void AddTableRow(int tableIndex ,int nRow,int rowCount);
public:
QAxObject *m_wordDocuments;
QAxObject *m_wordWidget;
QAxObject *m_selection;
private:
bool m_bOpened;
QString m_strFilePath;
signals:
public slots:
};
#endif // WORDOPERATE_H