From a2fad887d9b6304bdb7b28a127d661a4bffb70db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E8=B6=85=E7=BE=A4?= Date: Fri, 23 Jun 2017 20:09:09 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9Model=E5=90=8E=E7=9A=84bu?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ofdEditor/model/Convert/OFD_DocConvertor.cpp | 26 +++++++++++--------- ofdEditor/model/Convert/OFD_DocConvertor.h | 3 ++- ofdEditor/model/Doc/DocPage.cpp | 1 + 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ofdEditor/model/Convert/OFD_DocConvertor.cpp b/ofdEditor/model/Convert/OFD_DocConvertor.cpp index 5764488..ba8a2aa 100644 --- a/ofdEditor/model/Convert/OFD_DocConvertor.cpp +++ b/ofdEditor/model/Convert/OFD_DocConvertor.cpp @@ -37,7 +37,7 @@ DocPassage *OFD_DocConvertor::ofd_to_doc(OFD *ofd) try{ passage = new DocPassage(); - + passage->setVisible(false); // version passage->setVersion(ofd->getOfdVersion()); passage->setDocType(ofd->getDocType()); @@ -57,9 +57,8 @@ DocPassage *OFD_DocConvertor::ofd_to_doc(OFD *ofd) { // 生成每一页 - DocPage * newPage = this->buildDocPage((*pages)[i]); + DocPage * newPage = this->buildDocPage(passage, (*pages)[i]); newPage->setVisible(true); - passage->addPage(newPage); } } catch(...) @@ -67,10 +66,11 @@ DocPassage *OFD_DocConvertor::ofd_to_doc(OFD *ofd) qDebug() << "ofd_to_doc:exception."; } + passage->setVisible(true); return passage; } -DocPage *OFD_DocConvertor::buildDocPage(Page *ct_page) +DocPage *OFD_DocConvertor::buildDocPage(DocPassage *passage, Page *ct_page) { DocPage * page; try @@ -91,6 +91,7 @@ DocPage *OFD_DocConvertor::buildDocPage(Page *ct_page) page = new DocPage(); } + passage->addPage(page); // 加入到文章中来 page->setVisible(false); // 先隐藏显示 // 将每一层加入到页中 @@ -98,7 +99,7 @@ DocPage *OFD_DocConvertor::buildDocPage(Page *ct_page) for(int i = 0; i < layers->size(); i++) { CT_Layer* layer = (*layers)[i]; - qDebug() << "excute insertLayer: " << i; +// qDebug() << "excute insertLayer: " << i; this->insertLayer(page,layer); // 将该层的内容加入到页面中 } @@ -193,7 +194,7 @@ void OFD_DocConvertor::insertPageBlock(DocPage *page, */ void OFD_DocConvertor::insertCT_Text(DocPage *page, DocPage::Layer layer, CT_Text *text) { - qDebug() << "execute insert CT_Text" << text->getID(); +// qDebug() << "execute insert CT_Text" << text->getID(); CT_Color * fillColor = text->getFillColor(); // 获得填充颜色 QColor color = this->ctColorToQColor(fillColor); // 获得填充颜色 @@ -208,9 +209,9 @@ void OFD_DocConvertor::insertCT_Text(DocPage *page, DocPage::Layer layer, CT_Tex CT_Font* ctFont = (CT_Font*) base_font; QString font_name = ctFont->getFontName(); // 字体名 QString family_name = ctFont->getFamilyName(); // 字体族名 - qDebug() << font_name << " "<< family_name; +// qDebug() << font_name << " "<< family_name; textFont.setFamily(family_name); - qDebug() << "After setting font family :"<getText(); // 文本内容 qDebug() << "insert Content:" << content; - DocTextBlock *textBlock = new DocTextBlock(); - DocBlock *block = new DocBlock(); - block->setWidget(textBlock); + DocTextBlock *textBlock = new DocTextBlock(); // 新建文本块 + DocBlock *block = new DocBlock(); // 新建块 + block->setWidget(textBlock); // 将块放入文本块中 block->resize(UnitTool::mmToPixel(width), UnitTool::mmToPixel(height)); // 调整块大小 @@ -294,6 +295,7 @@ void OFD_DocConvertor::insertCT_Text(DocPage *page, DocPage::Layer layer, CT_Tex cursor.insertText(content); // 插入文本 +// qDebug()<<"page->addBlock"; page->addBlock(block,layer); // 插入到场景中 } diff --git a/ofdEditor/model/Convert/OFD_DocConvertor.h b/ofdEditor/model/Convert/OFD_DocConvertor.h index 288a4bd..035c000 100644 --- a/ofdEditor/model/Convert/OFD_DocConvertor.h +++ b/ofdEditor/model/Convert/OFD_DocConvertor.h @@ -33,7 +33,8 @@ public: private: OFD * ofdFile; // 当前处理时使用的ofd文件-用来方便获取到公用的特征 - DocPage * buildDocPage(Page * ct_page); // 生成页 + DocPage * buildDocPage(DocPassage * passage , + Page * ct_page); // 生成页 void insertLayer(DocPage * page, CT_Layer * layer ); // 将每一层加入到页中 diff --git a/ofdEditor/model/Doc/DocPage.cpp b/ofdEditor/model/Doc/DocPage.cpp index a01ce4a..e5c94f2 100644 --- a/ofdEditor/model/Doc/DocPage.cpp +++ b/ofdEditor/model/Doc/DocPage.cpp @@ -129,6 +129,7 @@ void DocPage::addBlock(DocBlock *block, DocPage::Layer layer) passage,SIGNAL(signals_currentTextBlock(DocTextBlock*))); } +// qDebug()<< "connect"; // 分到层 switch (layer) { -- Gitee From d78c8fc4f26d8e07c75d7509d77bad01f1d3d450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E8=B6=85=E7=BE=A4?= Date: Sat, 24 Jun 2017 00:53:40 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=AE=8C=E5=96=84=20DocInfo=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E7=9A=84=E5=8A=9F=E8=83=BD=E5=B0=8F=E9=83=A8=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ofdEditor/model/Convert/OFD_DocConvertor.cpp | 3 +- ofdEditor/model/Doc/DocBlock.h | 4 - ofdEditor/model/Doc/DocPassage.cpp | 28 +- ofdEditor/model/Doc/DocPassage.h | 13 +- ofdEditor/model/Widget/DocInfoDialog.cpp | 126 +++ ofdEditor/model/Widget/DocInfoDialog.h | 21 +- ofdEditor/model/Widget/DocInfoDialog.ui | 228 ++++- .../model/Widget/ParagraphFormatDialog.ui | 600 ++++++------ .../model/Widget/ParagraphFormatWidget.ui | 872 +++++++----------- .../start/ActionConnector/ActionConnector.cpp | 33 + .../start/ActionConnector/ActionConnector.h | 1 + ofdEditor/start/ui/PassageMainWindow.cpp | 7 + ofdEditor/start/ui/PassageMainWindow.h | 1 + 13 files changed, 1039 insertions(+), 898 deletions(-) diff --git a/ofdEditor/model/Convert/OFD_DocConvertor.cpp b/ofdEditor/model/Convert/OFD_DocConvertor.cpp index ba8a2aa..ea000f2 100644 --- a/ofdEditor/model/Convert/OFD_DocConvertor.cpp +++ b/ofdEditor/model/Convert/OFD_DocConvertor.cpp @@ -44,7 +44,8 @@ DocPassage *OFD_DocConvertor::ofd_to_doc(OFD *ofd) QVector * bodys = ofd->getDocBodies(); DocBody * docBody = (*bodys)[0]; // DocBody - passage->setDocInfo(*(docBody->getDocInfo())); + + passage->setDocInfo(*(docBody->getDocInfo())); // 设置文档元信息 Document * document = (*(ofd->getDocuments()))[0]; // Document diff --git a/ofdEditor/model/Doc/DocBlock.h b/ofdEditor/model/Doc/DocBlock.h index 48a842a..76fbfde 100644 --- a/ofdEditor/model/Doc/DocBlock.h +++ b/ofdEditor/model/Doc/DocBlock.h @@ -50,8 +50,6 @@ public slots: // 槽函数 void setWidget(QWidget* widget); // 旧的函数 void setWidget(DocTextBlock *textBlock); // SetWidget - - protected: void paint(QPainter *painter, @@ -67,8 +65,6 @@ protected: void mouseReleaseEvent (QGraphicsSceneMouseEvent * event); void contextMenuEvent (QGraphicsSceneContextMenuEvent *event); // 邮件菜单吧 - - private: DocBox boundary; // 该块的外包矩形 DocLayer * layer; // 该块在哪一个层之中 diff --git a/ofdEditor/model/Doc/DocPassage.cpp b/ofdEditor/model/Doc/DocPassage.cpp index 92cbcc8..3364acf 100644 --- a/ofdEditor/model/Doc/DocPassage.cpp +++ b/ofdEditor/model/Doc/DocPassage.cpp @@ -10,7 +10,7 @@ #include #include #include - +#include /** * @Author Chaoqun @@ -193,7 +193,7 @@ void DocPassage::setDocInfo(CT_DocInfo &docInfo) * @brief 测试 * @param 参数 * @return 返回值 - * @date 2017/06/xx + * @date 2017/06/22 */ void DocPassage::testMessage() { @@ -207,11 +207,9 @@ void DocPassage::testMessage() * @return CT_DocInfo * @date 2017/05/23 */ -CT_DocInfo DocPassage::getDocInfo() +CT_DocInfo *DocPassage::getDocInfo() { - CT_DocInfo docInfo; - docInfo.copy( *this->docInfo); - return docInfo; + return this->docInfo; } /** @@ -262,6 +260,22 @@ CT_CommonData* DocPassage::getCommonData() return this->commonData; } +/** + * @Author Chaoqun + * @brief 设置 docID + * @param void + * @return void + * @date 2017/06/23 + */ +void DocPassage::resetDocId() +{ + QUuid uuid = QUuid::createUuid(); // 创建uuid + QString docId = uuid.toString(); // 转换为字符串 + qDebug() << "uuid : " << docId; + + this->docInfo->setDocID(docId); +} + /** * @Author Chaoqun * @brief 设置重置响应事件,窗口大小发生调整,将会调用这个函数u @@ -289,6 +303,8 @@ void DocPassage::closeEvent(QCloseEvent *event) void DocPassage::init() { + this->docInfo = new CT_DocInfo(); // 新建文档 元信息 + this->resetDocId(); // 设置UUID this->layout = new QVBoxLayout; // 新建布局 // 新增widget diff --git a/ofdEditor/model/Doc/DocPassage.h b/ofdEditor/model/Doc/DocPassage.h index 0502ecb..9a5e7d2 100644 --- a/ofdEditor/model/Doc/DocPassage.h +++ b/ofdEditor/model/Doc/DocPassage.h @@ -13,6 +13,8 @@ #include #include #include +#include + // 类声明 class DocPage; @@ -36,7 +38,7 @@ public: QString docType,double scaleFactor); ~DocPassage(); - CT_DocInfo getDocInfo(); // 获取CT_DocInfo数据 + CT_DocInfo* getDocInfo(); // 获取CT_DocInfo数据 QString getVersion( ){return this->version;} QString getDocType( ){return this->docType;} QVector& getPages(); // 获得文档中包含的所有页面 @@ -64,6 +66,9 @@ public slots: // DocType void setDocType(QString docType){this->docType = docType;} + // docId + void resetDocId(); // 重新设置DocId + void testMessage(); // 测试信号是否走通 protected: @@ -79,6 +84,12 @@ private: QVector pages; // 既作为数据,也作为渲染 + // 文件信息 + QString filePath; + QString fileName; + QString tempPath; // 保存成文件前的临时路径 + // 个人觉得可以用上UUID tmp/"uuid-fileName" + // 渲染区 QVBoxLayout * layout; // 纵向排列 QWidget * widget; // 用widget做缓冲 diff --git a/ofdEditor/model/Widget/DocInfoDialog.cpp b/ofdEditor/model/Widget/DocInfoDialog.cpp index 513a161..5054d2b 100644 --- a/ofdEditor/model/Widget/DocInfoDialog.cpp +++ b/ofdEditor/model/Widget/DocInfoDialog.cpp @@ -1,6 +1,10 @@ #include "DocInfoDialog.h" #include "ui_DocInfoDialog.h" +#include "DataTypes/document/ct_docinfo.h" +#include +#include + DocInfoDialog::DocInfoDialog(QWidget *parent) : QDialog(parent), ui(new Ui::DocInfoDialog) @@ -8,7 +12,129 @@ DocInfoDialog::DocInfoDialog(QWidget *parent) : ui->setupUi(this); } +DocInfoDialog::DocInfoDialog(CT_DocInfo *docInfo,QWidget *parent = 0): + QDialog(parent), ui(new Ui::DocInfoDialog) +{ + ui->setupUi(this); + this->docInfo = docInfo; + this->init(); + this->initUi(); +} + DocInfoDialog::~DocInfoDialog() { delete ui; } + +/** + * @Author Chaoqun + * @brief 初始化 + * @param void + * @return void + * @date 2017/06/23 + */ +void DocInfoDialog::init() +{ + connect(ui->author, SIGNAL(textChanged(QString)), + this,SLOT(editAuthor(QString))); // 作者 + connect(ui->title, SIGNAL(textChanged(QString)), + this, SLOT(editTitle(QString))); // 题目 + connect(ui->subject, SIGNAL(textChanged(QString)), + this, SLOT(editSubject(QString))); // 主题 + connect(ui->abstract_2, SIGNAL(textChanged(QString)), + this, SLOT(editAbstract(QString))); // 摘要 + connect(ui->fileType, SIGNAL(textChanged(QString)), + this,SLOT(editFileType(QString))); // 文档类型 + connect(ui->fileCover, SIGNAL(textChanged(QString)), + this,SLOT(editFileCover(QString))); // 文档封面 + connect(ui->btn_uuid, SIGNAL(pressed()), + this, SLOT(resetDocId())); // 重置UUID + +} + +/** + * @Author Chaoqun + * @brief 初始化UI界面 + * @param void + * @return void + * @date 2017/06/23 + */ +void DocInfoDialog::initUi() +{ + // 文件名 + + // 文件id + ui->docId->setText(this->docInfo->getDocID()); + + // 标题 + ui->title->setText(this->docInfo->getTitle()); + + // 作者 + ui->author->setText(this->docInfo->getAuthor()); + + // 主题 + ui->subject->setText(this->docInfo->getSubject()); + + // 摘要 + ui->abstract_2->setText(this->docInfo->getAbstract()); + + // 文档类型 + ui->fileType->setText(this->docInfo->getDocUsage()); + + // 文档封面 + ui->fileCover->setText(this->docInfo->getCover()); + + // 创建日期 + ui->creationDate->setText(this->docInfo->getCreationDate()); + + // 最后修改时间 + ui->modDate->setText(this->docInfo->getModDate()); + + // 创建者应用程序 + ui->createApp->setText(this->docInfo->getCreator()); + + // 应用程序版本 + ui->creatorVersion->setText(this->docInfo->getCreatorVersion()); + +} + + +void DocInfoDialog::editTitle(const QString &text) +{ + this->docInfo->setTitle(text); // 设置标题 +} + +void DocInfoDialog::editAuthor(const QString &text) +{ + this->docInfo->setAuthor(text); +} + +void DocInfoDialog::editSubject(const QString &text) +{ + this->docInfo->setSubject(text); +} + +void DocInfoDialog::editAbstract(const QString &text) +{ + this->docInfo->setAbstract(text); +} + +void DocInfoDialog::editFileType(const QString &text) +{ + this->docInfo->setDocUsage(text); +} + +void DocInfoDialog::editFileCover(const QString &text) +{ + this->docInfo->setCover(text); +} + +void DocInfoDialog::resetDocId() +{ + QUuid uuid = QUuid::createUuid(); // 创建一个新的uuid + QString docId = uuid.toString(); + qDebug() << "new uuid: " << docId; + + this->docInfo->setDocID(docId); + ui->docId->setText(docId); +} diff --git a/ofdEditor/model/Widget/DocInfoDialog.h b/ofdEditor/model/Widget/DocInfoDialog.h index b911605..1593f96 100644 --- a/ofdEditor/model/Widget/DocInfoDialog.h +++ b/ofdEditor/model/Widget/DocInfoDialog.h @@ -2,21 +2,40 @@ #define DOCINFODIALOG_H #include +#include "model_global.h" +class CT_DocInfo; // 文档元信息 namespace Ui { class DocInfoDialog; } -class DocInfoDialog : public QDialog +class MODELSHARED_EXPORT DocInfoDialog : public QDialog { Q_OBJECT public: explicit DocInfoDialog(QWidget *parent = 0); + + DocInfoDialog(CT_DocInfo* docInfo,QWidget *parent); + ~DocInfoDialog(); private: Ui::DocInfoDialog *ui; + CT_DocInfo* docInfo; // 文档元信息 + void init(); // 初始化 + + void initUi(); // 初始化ui + +public slots: + void editTitle(const QString & text); // 修改标题 + void editAuthor(const QString & text); // 修改作者 + void editSubject(const QString & text); // 修改主题 + void editAbstract(const QString & text); // 修改摘要 + void editFileType(const QString & text); // 文档类型 + void editFileCover(const QString & text); // 文档封面 + void resetDocId(); // 重置UUID + }; #endif // DOCINFODIALOG_H diff --git a/ofdEditor/model/Widget/DocInfoDialog.ui b/ofdEditor/model/Widget/DocInfoDialog.ui index 2b9d3bf..28d14a4 100644 --- a/ofdEditor/model/Widget/DocInfoDialog.ui +++ b/ofdEditor/model/Widget/DocInfoDialog.ui @@ -1,25 +1,23 @@ + - - - DocInfoDialog - + 0 0 - 400 - 300 + 483 + 641 Dialog - + - 30 - 240 + 70 + 590 341 32 @@ -31,8 +29,218 @@ QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + 10 + 20 + 461 + 361 + + + + 说明 + + + + + 21 + 21 + 411 + 301 + + + + + + + 文件: + + + + + + + 文档ID: + + + + + + + 更改 + + + + + + + 标题: + + + + + + + + + + 作者: + + + + + + + + + + 主题: + + + + + + + + + + 摘要: + + + + + + + + + + 关键字: + + + + + + + + + + 文档类型: + + + + + + + + + + 文档封面: + + + + + + + + + + 创建日期: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + 420 + 461 + 151 + + + + 高级 + + + + + 20 + 30 + 431 + 111 + + + + + + + 最近修改时间: + + + + + + + + + + + + + + 创建应用程序: + + + + + + + + + + + + + + 应用程序版本: + + + + + + + + + + + + + - diff --git a/ofdEditor/model/Widget/ParagraphFormatDialog.ui b/ofdEditor/model/Widget/ParagraphFormatDialog.ui index 661cb5e..c5adafc 100644 --- a/ofdEditor/model/Widget/ParagraphFormatDialog.ui +++ b/ofdEditor/model/Widget/ParagraphFormatDialog.ui @@ -22,362 +22,278 @@ false - - - - 10 - 600 - 461 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - + 10 30 - 461 - 131 + 451 + 451 - - 对齐方式 - - - - - 10 - 30 - 70 - 20 - - - - 水平 - - - - - - 100 - 30 - 93 - 24 - - - - 0 - - - QComboBox::AdjustToContents - - - - 左对齐 - - - - - 右对齐 - - - - - 居中 - - - - - 两端对齐 - - - - - - - 10 - 60 - 70 - 20 - - - - 竖直 - - - - - - 100 - 60 - 61 - 24 - - - - QComboBox::AdjustToContents - - - - 居上 - - - - - 居下 - - - - - 居中 - - - - - - - 10 - 90 - 70 - 20 - - - - 文字方向 - - - - - - 100 - 90 - 77 - 24 - - - - QComboBox::AdjustToContents - - - - 左到右 - - - - - 右到左 - - - - - - - - 10 - 170 - 461 - 91 - - - - 缩进 - - - - - 10 - 30 - 70 - 20 - - - - 整体缩进 - - - - - - 100 - 30 - 100 - 20 - - - - 10000 - - - - - - 100 - 60 - 100 - 20 - - - - 10000.000000000000000 - - - - - - 10 - 60 - 70 - 20 - - - - 首行缩进 - - - - - - - 10 - 290 - 461 - 161 - - - - 间距 - - - - - 100 - 60 - 100 - 20 - - - - 10000.000000000000000 - - - - - - 10 - 60 - 70 - 20 - - - - 段后 - - - - - - 100 - 30 - 100 - 20 - - - - 10000.000000000000000 - - - - - - 10 - 30 - 70 - 20 - - - - 段前 - - - - - - 330 - 90 - 100 - 20 - - - - 10000.000000000000000 - - - - - - 240 - 90 - 70 - 20 - - - - - - - - - - 100 - 90 - 93 - 24 - - - - QComboBox::AdjustToContents - + - - 单倍行距 - + + + 对齐方式 + + + + + 10 + 30 + 261 + 91 + + + + + + + 水平 + + + + + + + 0 + + + QComboBox::AdjustToContents + + + + 左对齐 + + + + + 右对齐 + + + + + 居中 + + + + + 两端对齐 + + + + + + + + 竖直 + + + + + + + QComboBox::AdjustToContents + + + + 居上 + + + + + 居下 + + + + + 居中 + + + + + + + + 文字方向 + + + + + + + QComboBox::AdjustToContents + + + + 左到右 + + + + + 右到左 + + + + + + + - - 多倍行距 - + + + 缩进 + + + + + 10 + 30 + 261 + 81 + + + + + + + 整体缩进 + + + + + + + 10000 + + + + + + + 首行缩进 + + + + + + + 10000.000000000000000 + + + + + + - - 固定值 - + + + 间距 + + + + + 10 + 30 + 431 + 91 + + + + + + + 段前 + + + + + + + 10000.000000000000000 + + + + + + + 段后 + + + + + + + 10000.000000000000000 + + + + + + + 行距策略 + + + + + + + QComboBox::AdjustToContents + + + + 单倍行距 + + + + + 多倍行距 + + + + + 固定值 + + + + + 最小值 + + + + + + + + + + + + + + + 10000.000000000000000 + + + + + + - - 最小值 - + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + - - - - - 10 - 90 - 70 - 20 - - - - 行距策略 - - + diff --git a/ofdEditor/model/Widget/ParagraphFormatWidget.ui b/ofdEditor/model/Widget/ParagraphFormatWidget.ui index 993df7d..a4b4401 100644 --- a/ofdEditor/model/Widget/ParagraphFormatWidget.ui +++ b/ofdEditor/model/Widget/ParagraphFormatWidget.ui @@ -34,542 +34,348 @@ 段落属性 - + 0 - 0 - 2 - 2 - - - - - - - - 0 - 10 - 70 - 20 - - - - - 16 - - - - 常规 - - - Qt::AutoText - - - Qt::AlignCenter - - - - - - 10 - 40 - 70 - 25 - - - - 对齐方式: - - - - - - 100 - 40 - 100 - 25 - - - - QComboBox::AdjustToMinimumContentsLength - - - 10 - - - - 左对齐 - - - - - 右对齐 - - - - - 居中 - - - - - 自动对齐 - - - - - - - 0 - 110 - 70 - 20 - - - - - 宋体 - 16 - - - - 缩进 - - - Qt::AlignCenter - - - - - - 10 - 80 - 461 - 20 - - - - Qt::Horizontal - - - - - - 10 - 420 - 461 - 20 - - - - Qt::Horizontal - - - - - - 10 - 230 - 461 - 20 - - - - Qt::Horizontal - - - - - - 10 - 150 - 70 - 20 - - - - 整体缩进 - - - - - - 100 - 150 - 100 - 20 - - - - Qt::AlignCenter - - - - - - 10 - 180 - 70 - 20 - - - - 首行缩进 - - - - - - 100 - 180 - 100 - 20 - - - - Qt::AlignCenter - - - - - - 0 - 260 - 70 - 20 - - - - - 宋体 - 16 - - - - 间距 - - - Qt::AlignCenter - - - - - - 100 - 300 - 100 - 20 - - - - Qt::AlignCenter - - - - - - 10 - 330 - 70 - 20 - - - - 段后 - - - - - - 100 - 330 - 100 - 20 - - - - Qt::AlignCenter - - - - - - 10 - 300 - 70 - 20 - - - - 段前 - - - - - - 10 - 360 - 70 - 25 - - - - 行高策略 - - - - - - 100 - 360 - 100 - 25 - - - - QComboBox::AdjustToMinimumContentsLength - - - 10 - - - - 单倍行高 - - - - - 多倍行高 - - - - - 固定值 - - - - - 最小值 - - - - - - - 250 - 360 - 70 - 20 - - - - 行高值 - - - - - - 320 - 360 - 100 - 20 - - - - Qt::AlignCenter - - - - - - 10 - 490 - 70 - 20 - - - - 上边距 - - - - - - 100 - 520 - 100 - 20 - - - - Qt::AlignCenter - - - - - - 100 - 490 - 100 - 20 - - - - Qt::AlignCenter - - - - - - 0 - 450 - 70 - 20 - - - - - 宋体 - 16 - - - - 边距 - - - Qt::AlignCenter - - - - - - 10 - 520 - 70 - 20 - - - - 下边距 - - - - - - 340 - 520 - 100 - 20 - - - - Qt::AlignCenter - - - - - - 250 - 490 - 70 - 20 - - - - 左边距 - - - - - - 340 - 490 - 100 - 20 - - - - Qt::AlignCenter - - - - - - 250 - 520 - 70 - 20 - - - - 右边距 - - - - - - 270 - 610 - 80 - 25 - - - - 确定 - - - - - - 360 - 610 - 80 - 25 - - - - 取消 - - - - - - 250 - 40 - 70 - 25 - - - - 文字方向 - - - - - - 340 - 40 - 100 - 25 - - - - QComboBox::AdjustToMinimumContentsLength - - - 10 - - - - 自左向右 - - - - - 自右向左 - - + 50 + 431 + 421 + + + + + + + + + + + 16 + + + + 常规 + + + Qt::AutoText + + + Qt::AlignCenter + + + + + + + 对齐方式: + + + + + + + QComboBox::AdjustToMinimumContentsLength + + + 10 + + + + 左对齐 + + + + + 右对齐 + + + + + 居中 + + + + + 自动对齐 + + + + + + + + 文字方向 + + + + + + + QComboBox::AdjustToMinimumContentsLength + + + 10 + + + + 自左向右 + + + + + 自右向左 + + + + + + + + Qt::Horizontal + + + + + + + + 宋体 + 16 + + + + 缩进 + + + Qt::AlignCenter + + + + + + + 整体缩进 + + + + + + + Qt::AlignCenter + + + + + + + 首行缩进 + + + + + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + + + + + 宋体 + 16 + + + + 间距 + + + Qt::AlignCenter + + + + + + + 段前 + + + + + + + Qt::AlignCenter + + + + + + + 段后 + + + + + + + Qt::AlignCenter + + + + + + + 行高策略 + + + + + + + QComboBox::AdjustToMinimumContentsLength + + + 10 + + + + 单倍行高 + + + + + 多倍行高 + + + + + 固定值 + + + + + 最小值 + + + + + + + + 行高值 + + + + + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + + + + + 宋体 + 16 + + + + 边距 + + + Qt::AlignCenter + + + + + + + 上边距 + + + + + + + Qt::AlignCenter + + + + + + + 左边距 + + + + + + + Qt::AlignCenter + + + + + + + 下边距 + + + + + + + Qt::AlignCenter + + + + + + + 右边距 + + + + + + + Qt::AlignCenter + + + + + + + 确定 + + + + + + + 取消 + + + + diff --git a/ofdEditor/start/ActionConnector/ActionConnector.cpp b/ofdEditor/start/ActionConnector/ActionConnector.cpp index f26a75e..badff0f 100644 --- a/ofdEditor/start/ActionConnector/ActionConnector.cpp +++ b/ofdEditor/start/ActionConnector/ActionConnector.cpp @@ -2,6 +2,8 @@ #include "Doc/DocPassage.h" #include "ui/PassageMainWindow.h" #include "Doc/DocPage.h" +#include "DataTypes/document/ct_docinfo.h" +#include "Widget/DocInfoDialog.h" #include #include @@ -18,6 +20,22 @@ ActionConnector::ActionConnector(PassageMainWindow *mainWindow) init(); } +void ActionConnector::showAttribute() +{ + if(this->passage == NULL) + { + qDebug() << "show attribute"; + return; + } + + + CT_DocInfo * docInfo = this->passage->getDocInfo(); + DocInfoDialog* dialog = new DocInfoDialog(docInfo,this->mainWindow); // 设置窗口 + dialog->exec(); // 运行 + qDebug() << "show Attribute"; + +} + void ActionConnector::setMainWindow(PassageMainWindow *mainWindow) { this->mainWindow = mainWindow; @@ -35,6 +53,8 @@ void ActionConnector::setMainWindow(PassageMainWindow *mainWindow) void ActionConnector::addNewPage() { + if(this->passage == NULL) + return; this->passage->appendNewPage(); // 在队尾增加一页 } @@ -48,6 +68,10 @@ void ActionConnector::addNewPage() */ void ActionConnector::addNewBlock(InsertBlockInfo& blockInfo) { + if(this->passage == NULL) + { + return; + } // this->updateActivePassage(); // 更新文章 DocPage * page = qobject_cast(this->passage->focusWidget()); @@ -71,18 +95,24 @@ void ActionConnector::addNewBlock(InsertBlockInfo& blockInfo) void ActionConnector::addTextBlock() { + if(this->passage == NULL) + return; InsertBlockInfo blockInfo(this->defaultLayer,DocPage::text); // 设置插入文本框信息 this->addNewBlock(blockInfo); } void ActionConnector::addImageBlock() { + if(this->passage == NULL) + return; InsertBlockInfo blockInfo(this->defaultLayer,DocPage::image); // 设置插入文本框信息 this->addNewBlock(blockInfo); } void ActionConnector::addTableBlock() { + if(this->passage == NULL) + return; InsertBlockInfo blockInfo(this->defaultLayer,DocPage::table); // 设置插入文本框信息 this->addNewBlock(blockInfo); } @@ -115,12 +145,14 @@ void ActionConnector::updateActivePassage(QMdiSubWindow *window) { qDebug() << "updateActivePassage NULL" << "there's no actived window"; + this->passage = NULL; return; } DocPassage* passage = qobject_cast(window->widget()); // 获得文档 if(passage == NULL) { qDebug()<< "The active MdiWindow may not DocPassage"; + this->passage = NULL; } else { @@ -131,4 +163,5 @@ void ActionConnector::updateActivePassage(QMdiSubWindow *window) void ActionConnector::init() { this->defaultLayer = DocPage::Body; + this->passage = NULL; // 初始化为空 } diff --git a/ofdEditor/start/ActionConnector/ActionConnector.h b/ofdEditor/start/ActionConnector/ActionConnector.h index 9020998..b2d2eb6 100644 --- a/ofdEditor/start/ActionConnector/ActionConnector.h +++ b/ofdEditor/start/ActionConnector/ActionConnector.h @@ -25,6 +25,7 @@ public: DocPage::Layer getDefaultLayer(){return this->defaultLayer;} public slots: + void showAttribute(); // 显示文档元信息 void setMainWindow(PassageMainWindow * mainWindow); // 设置主窗口 void addNewPage(); // 添加一个新页面 void addNewBlock(InsertBlockInfo &blockInfo); // 插入一个块 diff --git a/ofdEditor/start/ui/PassageMainWindow.cpp b/ofdEditor/start/ui/PassageMainWindow.cpp index aa004e8..4fe5af5 100644 --- a/ofdEditor/start/ui/PassageMainWindow.cpp +++ b/ofdEditor/start/ui/PassageMainWindow.cpp @@ -121,6 +121,9 @@ void PassageMainWindow::initAction() this->printAction->setStatusTip(tr("Print your document")); this->printAction->setIcon(QIcon(":/icons/source/icons/print.png")); + this->attributeAction = new QAction(tr("Attribute"),NULL); // 文档属性 + this->attributeAction->setStatusTip(tr("Show you the attribute of the actived passage")); + this->undoAction = new QAction(tr("Undo"),NULL); // 撤销操作 this->undoAction->setStatusTip(tr("Undo your last action")); this->undoAction->setShortcut(QKeySequence::Undo); @@ -199,6 +202,7 @@ void PassageMainWindow::initAction() this->filesMenu->addAction(this->saveAction); this->filesMenu->addAction(this->saveAsAction); this->filesMenu->addAction(this->printAction); + this->filesMenu->addAction(this->attributeAction); this->editMenu->addAction(this->undoAction); this->editMenu->addAction(this->redoAction); @@ -261,6 +265,9 @@ void PassageMainWindow::connectAction() connect(this->openFileAtcion, SIGNAL(triggered(bool)), this, SLOT(openFile())); //打开文件 + connect(this->attributeAction, SIGNAL(triggered(bool)), + this->connector, SLOT(showAttribute())); // 显示文档属性 + connect(this->insertNewPageAction, SIGNAL(triggered(bool)), this->connector, SLOT(addNewPage())); // 在文章尾部加入新的一页 diff --git a/ofdEditor/start/ui/PassageMainWindow.h b/ofdEditor/start/ui/PassageMainWindow.h index d07719f..8ac6311 100644 --- a/ofdEditor/start/ui/PassageMainWindow.h +++ b/ofdEditor/start/ui/PassageMainWindow.h @@ -51,6 +51,7 @@ private: QAction * saveAction; // 保存 QAction * saveAsAction; // 另存为 QAction * printAction; // 打印 + QAction * attributeAction; // 文档属性 // 编辑 QAction * undoAction; // 撤销 -- Gitee From 0d85d3f4bdb7acc2386628b63a90fc850f57d10d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E8=B6=85=E7=BE=A4?= Date: Sat, 24 Jun 2017 15:29:13 +0800 Subject: [PATCH 3/5] =?UTF-8?q?APPInfo=EF=BC=8C=20=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E4=BA=86=E4=B8=80=E4=BA=9B=E9=97=AE=E9=A2=98=EF=BC=8C=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E8=BD=AC=E7=94=A8XML=E6=96=87=E4=BB=B6=E5=AD=98?= =?UTF-8?q?=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ofdEditor/model/Doc/DocPassage.cpp | 9 ++++ ofdEditor/model/Widget/DocInfoDialog.cpp | 8 ++++ ofdEditor/model/Widget/DocInfoDialog.h | 1 - .../start/ActionConnector/ActionConnector.cpp | 10 ++++- .../start/ActionConnector/ActionConnector.h | 2 + ofdEditor/start/app/APPInfo.cpp | 45 +++++++++++++++++++ ofdEditor/start/app/APPInfo.h | 30 +++++++++++++ ofdEditor/start/appinfo.qrc | 5 +++ ofdEditor/start/source/appInfo.json | 4 ++ ofdEditor/start/start.pro | 9 ++-- ofdEditor/start/ui/PassageMainWindow.cpp | 7 ++- 11 files changed, 121 insertions(+), 9 deletions(-) create mode 100644 ofdEditor/start/app/APPInfo.cpp create mode 100644 ofdEditor/start/app/APPInfo.h create mode 100644 ofdEditor/start/appinfo.qrc create mode 100644 ofdEditor/start/source/appInfo.json diff --git a/ofdEditor/model/Doc/DocPassage.cpp b/ofdEditor/model/Doc/DocPassage.cpp index 3364acf..66e39e5 100644 --- a/ofdEditor/model/Doc/DocPassage.cpp +++ b/ofdEditor/model/Doc/DocPassage.cpp @@ -271,6 +271,15 @@ void DocPassage::resetDocId() { QUuid uuid = QUuid::createUuid(); // 创建uuid QString docId = uuid.toString(); // 转换为字符串 + + // 去掉字符串的链接符号 {0142d46f-60b5-47cf-8310-50008cc7cb3a} + // 0142d46f60b547cf831050008cc7cb3a + docId.remove(docId.length()-1, 1); + docId.remove(docId.length() -13, 1); + docId.remove(docId.length() -17,1); + docId.remove(docId.length() -21, 1); + docId.remove(docId.length() - 25,1); + docId.remove(0,1); qDebug() << "uuid : " << docId; this->docInfo->setDocID(docId); diff --git a/ofdEditor/model/Widget/DocInfoDialog.cpp b/ofdEditor/model/Widget/DocInfoDialog.cpp index 5054d2b..d9d8601 100644 --- a/ofdEditor/model/Widget/DocInfoDialog.cpp +++ b/ofdEditor/model/Widget/DocInfoDialog.cpp @@ -133,6 +133,14 @@ void DocInfoDialog::resetDocId() { QUuid uuid = QUuid::createUuid(); // 创建一个新的uuid QString docId = uuid.toString(); + + docId.remove(docId.length()-1, 1); + docId.remove(docId.length() -13, 1); + docId.remove(docId.length() -17,1); + docId.remove(docId.length() -21, 1); + docId.remove(docId.length() - 25,1); + docId.remove(0,1); + qDebug() << "new uuid: " << docId; this->docInfo->setDocID(docId); diff --git a/ofdEditor/model/Widget/DocInfoDialog.h b/ofdEditor/model/Widget/DocInfoDialog.h index 1593f96..463453a 100644 --- a/ofdEditor/model/Widget/DocInfoDialog.h +++ b/ofdEditor/model/Widget/DocInfoDialog.h @@ -24,7 +24,6 @@ private: Ui::DocInfoDialog *ui; CT_DocInfo* docInfo; // 文档元信息 void init(); // 初始化 - void initUi(); // 初始化ui public slots: diff --git a/ofdEditor/start/ActionConnector/ActionConnector.cpp b/ofdEditor/start/ActionConnector/ActionConnector.cpp index badff0f..d555724 100644 --- a/ofdEditor/start/ActionConnector/ActionConnector.cpp +++ b/ofdEditor/start/ActionConnector/ActionConnector.cpp @@ -5,6 +5,8 @@ #include "DataTypes/document/ct_docinfo.h" #include "Widget/DocInfoDialog.h" +#include "app/APPInfo.h" + #include #include @@ -24,7 +26,7 @@ void ActionConnector::showAttribute() { if(this->passage == NULL) { - qDebug() << "show attribute"; + qDebug() << "show attribute this->passage == NULL"; return; } @@ -129,6 +131,11 @@ void ActionConnector::redo() this->passage->undoStack->redo(); } +void ActionConnector::setDocPassage(DocPassage *passage) +{ + this->passage = passage; +} + @@ -164,4 +171,5 @@ void ActionConnector::init() { this->defaultLayer = DocPage::Body; this->passage = NULL; // 初始化为空 + } diff --git a/ofdEditor/start/ActionConnector/ActionConnector.h b/ofdEditor/start/ActionConnector/ActionConnector.h index b2d2eb6..878056b 100644 --- a/ofdEditor/start/ActionConnector/ActionConnector.h +++ b/ofdEditor/start/ActionConnector/ActionConnector.h @@ -5,6 +5,7 @@ #include "Doc/DocPage.h" #include + class DocPassage; class PassageMainWindow; @@ -34,6 +35,7 @@ public slots: void addTableBlock(); // 插入表格 void undo(); // undo void redo(); // redo + void setDocPassage(DocPassage* passage); // 设置passage void setDefaultLayer(DocPage::Layer layer){this->defaultLayer = layer;} diff --git a/ofdEditor/start/app/APPInfo.cpp b/ofdEditor/start/app/APPInfo.cpp new file mode 100644 index 0000000..f0d377a --- /dev/null +++ b/ofdEditor/start/app/APPInfo.cpp @@ -0,0 +1,45 @@ +#include "APPInfo.h" +#include +#include +#include +#include + +APPInfo::APPInfo(QObject *parent) : QObject(parent) +{ + +} + +QString APPInfo::GetAppName() +{ + return this->appName; +} + +QString APPInfo::GetAppVersion() +{ + return this->appVersion; +} + +void APPInfo::initFromFile() +{ + QFile file(":/appInfo/source/appInfo.json"); // 将文件存在resource内 + if(!file.open(QIODevice::ReadOnly)) + { + qDebug() << "open app information file failed"; + return; + } + + QTextStream txtInput(&file); // 设置文件流 + QString str = txtInput.readAll(); // 读全部文件 + qDebug() << str; + +} + +void APPInfo::setAppName(QString &name) +{ + this->appName = name; +} + +void APPInfo::setAppVersion(QString &version) +{ + this->appVersion = version; +} diff --git a/ofdEditor/start/app/APPInfo.h b/ofdEditor/start/app/APPInfo.h new file mode 100644 index 0000000..5fe1839 --- /dev/null +++ b/ofdEditor/start/app/APPInfo.h @@ -0,0 +1,30 @@ +#ifndef APPINFO_H +#define APPINFO_H + +#include +#include + +class APPInfo + : public QObject +{ + Q_OBJECT +public: + explicit APPInfo(QObject *parent = 0); + + QString GetAppName(); // 获得应用名称 + QString GetAppVersion(); // 获得应用版本号 + + void initFromFile(); // 从文件中获取版本信息 + +signals: + +public slots: + void setAppName(QString &name); // 设置名称 + void setAppVersion(QString &version); // 设置版本号 + +private: + QString appName; // 应用名称 + QString appVersion; // app版本 +}; + +#endif // APPINFO_H diff --git a/ofdEditor/start/appinfo.qrc b/ofdEditor/start/appinfo.qrc new file mode 100644 index 0000000..e6b0c6e --- /dev/null +++ b/ofdEditor/start/appinfo.qrc @@ -0,0 +1,5 @@ + + + source/appInfo.json + + diff --git a/ofdEditor/start/source/appInfo.json b/ofdEditor/start/source/appInfo.json new file mode 100644 index 0000000..96f1088 --- /dev/null +++ b/ofdEditor/start/source/appInfo.json @@ -0,0 +1,4 @@ +{ + "AppName": "ofdEditor", + "AppVersion": "0.1.0.0" +} diff --git a/ofdEditor/start/start.pro b/ofdEditor/start/start.pro index d56a76b..153a8dc 100644 --- a/ofdEditor/start/start.pro +++ b/ofdEditor/start/start.pro @@ -28,11 +28,13 @@ DEFINES += QT_DEPRECATED_WARNINGS SOURCES += main.cpp\ mainwindow.cpp \ ui/PassageMainWindow.cpp \ - ActionConnector/ActionConnector.cpp + ActionConnector/ActionConnector.cpp \ + app/APPInfo.cpp HEADERS += mainwindow.h \ ui/PassageMainWindow.h \ - ActionConnector/ActionConnector.h + ActionConnector/ActionConnector.h \ + app/APPInfo.h DESTDIR = ../bin # 生成文件在这 MOC_DIR = ./moc # Q_OBJECT 类转换后的文件 @@ -53,6 +55,7 @@ win32{ } RESOURCES += \ - icons.qrc + icons.qrc \ + appinfo.qrc FORMS += diff --git a/ofdEditor/start/ui/PassageMainWindow.cpp b/ofdEditor/start/ui/PassageMainWindow.cpp index 4fe5af5..76f366d 100644 --- a/ofdEditor/start/ui/PassageMainWindow.cpp +++ b/ofdEditor/start/ui/PassageMainWindow.cpp @@ -53,9 +53,6 @@ DocPassage *PassageMainWindow::createMdiChild() DocPassage * child = new DocPassage(this); child->addPage(new DocPage()); // 添加一个空白页 -// this->area->addSubWindow(child); -// child->setVisible(true); // 设置可见 -// child->showMaximized(); this->addDocPassage(child); // 加入到本视区 return child; @@ -446,7 +443,9 @@ DocPassage *PassageMainWindow::addDocPassage(DocPassage *passage) return NULL; } - this->area->addSubWindow(passage); + this->area->addSubWindow(passage); // 插入子窗口 + this->connector->setDocPassage(passage); // 设置引用 + passage->setVisible(true); // 设置可见 passage->showMaximized(); -- Gitee From b85f8195d4d792ac8147dac839c634701fec26d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E8=B6=85=E7=BE=A4?= Date: Sat, 24 Jun 2017 22:31:36 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=B8=8C=E6=9C=9B=E5=81=9Adoc-ofd=E7=9A=84?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=EF=BC=8C=E4=BD=86=E5=BD=93=E5=89=8D=E8=BF=98?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=81=9A=E7=8E=A9DocTextBlock->CT=5FText?= =?UTF-8?q?=E7=9A=84=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ofdEditor/model/Convert/Doc_OFDConvertor.cpp | 299 ++++++++++++++++++- ofdEditor/model/Convert/Doc_OFDConvertor.h | 34 ++- ofdEditor/model/Convert/OFD_DocConvertor.cpp | 17 +- ofdEditor/model/Convert/OFD_DocConvertor.h | 3 + ofdEditor/model/Doc/DocBlock.cpp | 1 + ofdEditor/model/Doc/DocPage.cpp | 37 +++ ofdEditor/model/Doc/DocPage.h | 4 + ofdEditor/model/Widget/DocInfoDialog.ui | 12 +- ofdEditor/ofd/DataTypes/document/DocBody.h | 4 +- ofdEditor/ofd/DataTypes/document/docbody.h | 4 +- ofdEditor/ofd/DataTypes/page/Page.h | 1 - ofdEditor/ofd/DataTypes/page/page.h | 1 - 12 files changed, 392 insertions(+), 25 deletions(-) diff --git a/ofdEditor/model/Convert/Doc_OFDConvertor.cpp b/ofdEditor/model/Convert/Doc_OFDConvertor.cpp index 82ca3b2..80efd9e 100644 --- a/ofdEditor/model/Convert/Doc_OFDConvertor.cpp +++ b/ofdEditor/model/Convert/Doc_OFDConvertor.cpp @@ -5,9 +5,27 @@ #include "Doc/DocTextBlock.h" #include "Doc/DocLayer.h" +#include +#include +#include +#include + #include "DataTypes/basic_datatype.h" #include "DataTypes/document/ofd.h" - +#include "DataTypes/document/Res.h" +#include "DataTypes/document/docbody.h" +#include "DataTypes/document/ct_docinfo.h" +#include "DataTypes/document/document.h" +#include "DataTypes/page/ct_pages.h" +#include "DataTypes/page/page.h" +#include "DataTypes/page/ct_layer.h" +#include "DataTypes/page/CT_PageArea.h" +#include "DataTypes/Color/CT_Color.h" +#include "DataTypes/Color/CT_ColorSpace.h" +#include "DataTypes/text/CT_Font.h" +#include "DataTypes/text/ct_text.h" +#include "DataTypes/text/textcode.h" +#include "DataTypes/basic_datatype.h" Doc_OFDConvertor::Doc_OFDConvertor(QObject *parent) @@ -25,25 +43,296 @@ Doc_OFDConvertor::Doc_OFDConvertor(QObject *parent) */ OFD *Doc_OFDConvertor::doc_to_ofd(DocPassage *passage) { + this->passage = passage; // 保存passage + this->ofdFile = new OFD( ); // 建立一个新的OFD文件 + + // 构建流程 + this->buildDocBody(); // 构建DocBody + this->buildDocument(); // docment + + } -void Doc_OFDConvertor::buildDocInfo() +/** + * @Author Chaoqun + * @brief 生成DocBody + * @param void + * @return void + * @date 2017/06/24 + */ +void Doc_OFDConvertor::buildDocBody() { + qDebug() << "exec buildDocbody"; + QVector docbodys; // 新建docbodys新建带有……的docbodys + DocBody* docbody = new DocBody(this->passage->getDocInfo()); // 加入docbody + docbodys.append(docbody); // 新建DocBody + docbody->setDocRoot(QString("Doc_0/Document.xml")); // 设置文档根目录 + + this->ofdFile->setDocBodies( &docbodys); // 设置ofd的docbobys } -void Doc_OFDConvertor::buildPage() +/** + * @Author Chaoqun + * @brief 创建document相关的东西 + * @param void + * @return void + * @date 2017/06/24 + */ +void Doc_OFDConvertor::buildDocument() +{ + qDebug() << "exec buildDocument"; + QVector documents; // 新建Documents + Document* document = new Document(); // 新建Document + documents.append(document); // 添加到文件中 + + // 设置ID_Table + this->table = document->getIDTable(); // 获得IDTable + + // 设置publicRes + this->public_res = new Res(); + document->getPublicRes()->append(public_res); // 将公用资源加入到document + + // 设置common_data + CT_CommonData * commonData = new CT_CommonData(); + document->setCommonData(commonData); + // 设置指向资源文件的 + commonData->getPublicRes()->append(ST_Loc(QString("PublicRes.xml"), + QString("PublicRes.xml"), + QString("PublicRes.xml"))); + + this->buildPages(document); // 解析每一页 +} + +/** + * @Author Chaoqun + * @brief 转换所有页面 + * @param void + * @return void + * @date 2017/06/23 + */ +void Doc_OFDConvertor::buildPages(Document* document) { + qDebug() << "exec buildPages"; + QVector docPages = this->passage->getPages(); // 获得页面 + int pagesLength = docPages.size(); // 获得页面的数量 + + if(pagesLength > 1) + { + // 设置公共页大小 + CT_CommonData* commonData = document->getCommonData(); + + CT_PageArea *area = new CT_PageArea(); + + DocPage* page = docPages[0]; + area->setPhysicalBox(0,0, + page->getWidth(),page->getHeight()); + commonData->setPageArea(area); + + } + + CT_Pages * ctpages = new CT_Pages(); // 新建CT_Pages + document->setPages(ctpages); // 设置 + QVector* pages = ctpages->getPages(); // 获得Qvector + + // 遍历每个页面 + for(int i=0; i< pagesLength;i++) + { + DocPage* page = docPages.operator [](i); + + Page* ctPage = new Page(); + ctPage->setID(this->table->size()+1,this->table); // 设置ID + // 设置页的路径 + QString num; + num.setNum(i); + ctPage->setBaseLoc(QString("Pages/Page_") + num); + pages->append(ctPage); // 加入到OFD 文件中 + + this->buildPage(ctPage,page); // 单独处理每一页 + + } } -void Doc_OFDConvertor::buildLayer(DocLayer *layer) +/** + * @Author Chaoqun + * @brief 处理文档中某一页 + * @param Page *ctPage + * @param DocPage *docPage + * @return void + * @date 2017/06/24 + */ +void Doc_OFDConvertor::buildPage(Page *ctPage, DocPage *docPage) { + qDebug() << "exec buildPage"; + QVector *layers = ctPage->getContent(); + + // 分成多个层,对每个层进行处理 + DocLayer* foreground = docPage->getForegroundLayer(); // 获得前景层 + CT_Layer* foreLayer = new CT_Layer(); // 处理前景层 + foreLayer->setType("Foreground"); // 设置类型 + foreLayer->setID(this->table->size()+1,this->table); // 设置ID + layers->append(foreLayer); // 加入到Page中 + this->buildLayer(foreLayer,foreground); // 处理该层的信息 + + + // 处理正文层 + DocLayer* body = docPage->getBodyLayer(); + CT_Layer* bodyLayer = new CT_Layer(); + bodyLayer->setType("Body"); + bodyLayer->setID(this->table->size()+1,this->table); + layers->append(bodyLayer); + this->buildLayer(bodyLayer,body); + + // 背景层 + DocLayer* background = docPage->getBackgroundLayer(); + CT_Layer* backLayer = new CT_Layer(); + backLayer->setType("Background"); + backLayer->setID(this->table->size()+1,this->table); + layers->append(backLayer); + this->buildLayer(backLayer,background); } -void Doc_OFDConvertor::buildText(DocTextBlock *textBlock) +/** + * @Author Chaoqun + * @brief 建造层 + * @param Page* ctPage + * @param DocLayer* layer + * @return 返回值 + * @date 2017/06/24 + */ +void Doc_OFDConvertor::buildLayer(CT_Layer* ctLayer,DocLayer *layer) { + qDebug() << "Exec buildLayer"; + QVector *blocks = layer->getBlocks(); + int blocks_length = blocks->size(); + + // 遍历所有块 + for(int i =0; i< blocks_length; i++) + { + DocBlock* block = blocks->operator [](i); // 获得一个临时的框 + + // 如果是文字框 + if(block->isTextBlock()) + { + // 进入文字框处理模式 + this->buildText(ctLayer,block->getTextBlock()); + } + } + +} + +/** + * @Author Chaoqun + * @brief 处理文字框 + * @param CT_Layer* ctLayer + * @param DocTextBlock*textBlock + * @return void + * @date 2017/06/24 + */ +void Doc_OFDConvertor::buildText(CT_Layer* ctLayer,DocTextBlock *textBlock) +{ + // 分析TextBlock + textBlock->moveCursor(QTextCursor::Start); // 移动到块的开始 + QTextCursor cursor = textBlock->textCursor(); + + +} + +/** + * @Author Chaoqun + * @brief 加入字体 + * @param CT_Font *font + * @return int 插入的Font 的RefId + * @date 2017/06/24 + */ +int Doc_OFDConvertor::addFont(CT_Font *font) +{ + int checkId = this->checkFont(font); // 获得fontID + + if(checkId != -1) + { + // 如果检查后,存在了这个font + return checkId; + } + + // 为字体分配ID + font->setID(this->table->size()+1, this->table); + this->public_res->getFonts()->append(font); // 加入 + qDebug() << "Add Font:" << font->getFontName(); + return font->getID().getID(); +} + +/** + * @Author Chaoqun + * @brief 为公用资源添加颜色空间 + * @param CT_ColorSpace *colorSpace + * @return int + * @date 2017/06/24 + */ +int Doc_OFDConvertor::addColorSpace(CT_ColorSpace *colorSpace) +{ + int checkId = this->checkColorSpace(colorSpace); // 检查是否已有该颜色空间 + if(checkId != -1) + { + return checkId; + } + + // 为颜色空间分派id + colorSpace->setID(this->table->size()+1, this->table); + this->public_res->getColorSpaces()->append(colorSpace); + qDebug() << "Add ColorSpace: " << colorSpace->getType(); + return colorSpace->getID().getID(); +} + +/** + * @Author Chaoqun + * @brief 检查是否已经存在这个字体 + * @param CT_Font* font + * @return int + * @date 2017/06/24 + */ +int Doc_OFDConvertor::checkFont(CT_Font *font) +{ + QVector* fonts = this->public_res->getFonts(); // 获得字体 + int length = fonts->size(); + + // 遍历一遍,检查是否有相同的 + for(int i= 0; i< length; i++) + { + if((*fonts)[i]->getFamilyName() == font->getFamilyName()) + { + return (*fonts)[i]->getID().getID(); // 返回ID + } + } + + qDebug() << "this font is not stored"; + return -1; +} + +/** + * @Author Chaoqun + * @brief 检查是否已经存在此ColorSpace + * @param CT_ColorSpace + * @return int 如果存在,返回ID信息,不存在,则返回-1 + * @date 2017/06/24 + */ +int Doc_OFDConvertor::checkColorSpace(CT_ColorSpace *colorSpace) +{ + QVector* colorSpaces + = this->public_res->getColorSpaces(); // 获得颜色空间 + + int length = colorSpaces->size(); + // 遍历colorSpace检查是否有相同的 + for(int i = 0; i < length; i++) + { + if((*colorSpaces)[i]->getType() == colorSpace->getType()) + { + return (*colorSpaces)[i]->getID().getID(); // 返回ID + } + } + return -1; // 不存在已有的 } diff --git a/ofdEditor/model/Convert/Doc_OFDConvertor.h b/ofdEditor/model/Convert/Doc_OFDConvertor.h index 79b32bd..ccf6da4 100644 --- a/ofdEditor/model/Convert/Doc_OFDConvertor.h +++ b/ofdEditor/model/Convert/Doc_OFDConvertor.h @@ -11,6 +11,14 @@ class DocBlock; // 块 class DocTextBlock; // 文本框 class OFD; // OFD文件模型 +class Res; // 资源描述 +class ID_Table; // id table表 +class CT_Font; // ct_font +class CT_ColorSpace; // 颜色空间 +class Page; +class Document; +class CT_Layer; + /** * @Author Chaoqun @@ -30,14 +38,30 @@ signals: public slots: private: - void buildDocInfo(); // 存储DocInfo相关的信息 - void buildPage(); // 储存文本信息,顺便整理文件 - void buildLayer(DocLayer* layer); // 将一层中的信息存储出来 - void buildText(DocTextBlock* textBlock); // 将DocTextBlock中的信息转换处理 + + void buildDocBody(); // 生成DocBody + void buildDocument(); // 生成Document + void buildPages(Document *document); // 处理页面S + + void buildPage(Page* ctPage, + DocPage* docPage); // 处理其中某一页 + + void buildLayer(CT_Layer* ctLayer, + DocLayer* layer); // 将一层中的信息存储出来 + void buildText(CT_Layer* ctLayer,DocTextBlock* textBlock); // 将DocTextBlock中的信息转换处理 + + int addFont(CT_Font* font); // 添加字体类型到资源 + int addColorSpace(CT_ColorSpace* colorSpace); // 添加颜色空间 + + int checkFont(CT_Font* font); // 检查publicRes中是否存在该字体 + int checkColorSpace(CT_ColorSpace* colorSpace); // 检查是否存在该颜色空间 private: DocPassage* passage; // 文章 - OFD* ofdFile; // OFD对象 + OFD* ofdFile; // OFD 对象 + Res* public_res; // Res 公共资源文件 + ID_Table* table; // ID table + }; diff --git a/ofdEditor/model/Convert/OFD_DocConvertor.cpp b/ofdEditor/model/Convert/OFD_DocConvertor.cpp index ea000f2..1b75e10 100644 --- a/ofdEditor/model/Convert/OFD_DocConvertor.cpp +++ b/ofdEditor/model/Convert/OFD_DocConvertor.cpp @@ -16,6 +16,8 @@ #include "DataTypes/image/CT_DrawParam.h" #include "DataTypes/Color/CT_ColorSpace.h" #include "Convert/Objects/MinTextUnit.h" +#include "DataTypes/page/CT_PageArea.h" +#include "DataTypes/document/ct_commondata.h" OFD_DocConvertor::OFD_DocConvertor() { @@ -49,7 +51,8 @@ DocPassage *OFD_DocConvertor::ofd_to_doc(OFD *ofd) Document * document = (*(ofd->getDocuments()))[0]; // Document -// CT_CommonData * commonData = document->getCommonData(); // 获取common_data + CT_CommonData * commonData = document->getCommonData(); // 获取common_data- >内含公用页大小 + this->public_pageArea = commonData->getPageArea(); // 从common_data中获取公用边大小 // CT_Pages pages = document->pages; // 获得文档中的页 QVector * pages = document->getPages()->getPages(); // 获得页属性 @@ -81,8 +84,14 @@ DocPage *OFD_DocConvertor::buildDocPage(DocPassage *passage, Page *ct_page) // 如果定义了纸张尺寸 CT_PageArea* area = ct_page->getArea(); // 获得空间 - - // 物理空间 + if(area == NULL) + { + // 如果没有定义页面大小 + qDebug() <<"buildPage -> there is no pageArea in page"; + area = this->public_pageArea; // 使用公用的页面空间 + } + + // 使用物理空间新建页面 page = new DocPage(area->getPhysicalBox().getDeltaX(), area->getPhysicalBox().getDeltaY(), 1.0); // 设置纸张大小 @@ -110,7 +119,6 @@ DocPage *OFD_DocConvertor::buildDocPage(DocPassage *passage, Page *ct_page) qDebug() << "OFD_DocConvertor::buildDocPage exception."; } - return page; } @@ -183,7 +191,6 @@ void OFD_DocConvertor::insertPageBlock(DocPage *page, } - /** * @Author Chaoqun * @brief 将文字块插入到页面中 diff --git a/ofdEditor/model/Convert/OFD_DocConvertor.h b/ofdEditor/model/Convert/OFD_DocConvertor.h index 035c000..f330308 100644 --- a/ofdEditor/model/Convert/OFD_DocConvertor.h +++ b/ofdEditor/model/Convert/OFD_DocConvertor.h @@ -15,6 +15,7 @@ class CT_Text; class CT_Path; class CT_Image; class CT_Color; +class CT_PageArea; /** * @Author Chaoqun @@ -32,6 +33,8 @@ public: private: OFD * ofdFile; // 当前处理时使用的ofd文件-用来方便获取到公用的特征 + CT_PageArea* public_pageArea; // 公用的页面大小 + DocPage * buildDocPage(DocPassage * passage , Page * ct_page); // 生成页 diff --git a/ofdEditor/model/Doc/DocBlock.cpp b/ofdEditor/model/Doc/DocBlock.cpp index 49d029f..19b1de1 100644 --- a/ofdEditor/model/Doc/DocBlock.cpp +++ b/ofdEditor/model/Doc/DocBlock.cpp @@ -29,6 +29,7 @@ DocBlock::DocBlock(QGraphicsItem *parent , Qt::WindowFlags wFlags) this->setFlag(QGraphicsProxyWidget::ItemIsSelectable, true); // 可选择 this->setFlag(QGraphicsProxyWidget::ItemIsFocusable, true); // 可关注 this->setAcceptHoverEvents(true); + } /** diff --git a/ofdEditor/model/Doc/DocPage.cpp b/ofdEditor/model/Doc/DocPage.cpp index e5c94f2..88a0821 100644 --- a/ofdEditor/model/Doc/DocPage.cpp +++ b/ofdEditor/model/Doc/DocPage.cpp @@ -17,6 +17,7 @@ #include #include #include +#include // #include "DataTypes/page/CT_PageArea.h" // 页面大小 @@ -98,6 +99,42 @@ QSize DocPage::getSize() UnitTool::mmToPixel(height_mm)); } +/** + * @Author Chaoqun + * @brief 获得前景层 + * @param void + * @return DocLayer* + * @date 2017/06/24 + */ +DocLayer *DocPage::getForegroundLayer() +{ + return this->foregroundLayer; +} + +/** + * @Author Chaoqun + * @brief 获得正文层 + * @param void + * @return DocLayer* + * @date 2017/06/24 + */ +DocLayer *DocPage::getBodyLayer() +{ + return this->bodyLayer; +} + +/** + * @Author Chaoqun + * @brief 获得背景层 + * @param 参数 + * @return DocLayer* + * @date 2017/06/24 + */ +DocLayer *DocPage::getBackgroundLayer() +{ + return this->backgroundLayer; +} + /** * @Author Chaoqun * @brief 添加一个新的块到页面之中 diff --git a/ofdEditor/model/Doc/DocPage.h b/ofdEditor/model/Doc/DocPage.h index 8291d08..48d5388 100644 --- a/ofdEditor/model/Doc/DocPage.h +++ b/ofdEditor/model/Doc/DocPage.h @@ -44,6 +44,10 @@ public: BlockFlag getBlockFlag(){return this->newBlockFlag;} + DocLayer *getForegroundLayer(); // 获得前景层 + DocLayer* getBodyLayer(); // 获得正文层 + DocLayer* getBackgroundLayer(); // 获得背景层 + public slots: void setSize(double width, double height); // 设置页面大小 void setPassage(DocPassage * passage); // 设置文章 diff --git a/ofdEditor/model/Widget/DocInfoDialog.ui b/ofdEditor/model/Widget/DocInfoDialog.ui index 28d14a4..87d36cf 100644 --- a/ofdEditor/model/Widget/DocInfoDialog.ui +++ b/ofdEditor/model/Widget/DocInfoDialog.ui @@ -41,7 +41,7 @@ 说明 - + 21 @@ -149,21 +149,21 @@ - - + + - - + + - + diff --git a/ofdEditor/ofd/DataTypes/document/DocBody.h b/ofdEditor/ofd/DataTypes/document/DocBody.h index 31bf442..dcbbced 100644 --- a/ofdEditor/ofd/DataTypes/document/DocBody.h +++ b/ofdEditor/ofd/DataTypes/document/DocBody.h @@ -13,7 +13,9 @@ public: public: friend class OFDParser; - DocBody(CT_DocInfo * _doc_info = NULL, QString _doc_root = "", QString _signatures = "") { + DocBody(CT_DocInfo * _doc_info = NULL, + QString _doc_root = "", + QString _signatures = "") { if (_doc_info) setDocInfo(_doc_info); if (!_doc_root.isNull()) diff --git a/ofdEditor/ofd/DataTypes/document/docbody.h b/ofdEditor/ofd/DataTypes/document/docbody.h index 31bf442..dcbbced 100644 --- a/ofdEditor/ofd/DataTypes/document/docbody.h +++ b/ofdEditor/ofd/DataTypes/document/docbody.h @@ -13,7 +13,9 @@ public: public: friend class OFDParser; - DocBody(CT_DocInfo * _doc_info = NULL, QString _doc_root = "", QString _signatures = "") { + DocBody(CT_DocInfo * _doc_info = NULL, + QString _doc_root = "", + QString _signatures = "") { if (_doc_info) setDocInfo(_doc_info); if (!_doc_root.isNull()) diff --git a/ofdEditor/ofd/DataTypes/page/Page.h b/ofdEditor/ofd/DataTypes/page/Page.h index 8e168c9..2603a62 100644 --- a/ofdEditor/ofd/DataTypes/page/Page.h +++ b/ofdEditor/ofd/DataTypes/page/Page.h @@ -14,7 +14,6 @@ public: QVector * page_res_locations; QVector *content; //Actions to be implemented - public: friend class OFDParser; Page() { diff --git a/ofdEditor/ofd/DataTypes/page/page.h b/ofdEditor/ofd/DataTypes/page/page.h index 8e168c9..2603a62 100644 --- a/ofdEditor/ofd/DataTypes/page/page.h +++ b/ofdEditor/ofd/DataTypes/page/page.h @@ -14,7 +14,6 @@ public: QVector * page_res_locations; QVector *content; //Actions to be implemented - public: friend class OFDParser; Page() { -- Gitee From 4de21dd7469ec92aa1cc739986c52b15b2bf871e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E8=B6=85=E7=BE=A4?= Date: Sun, 25 Jun 2017 11:34:22 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E9=A2=84=E5=A4=87=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ofdEditor/model/Convert/Doc_OFDConvertor.cpp | 41 ++++++++++ ofdEditor/model/Doc/DocPassage.h | 4 +- ofdEditor/model/Doc/DocTextBlock.cpp | 78 ++++++++++++++++++++ ofdEditor/model/Doc/DocTextBlock.h | 4 +- 4 files changed, 124 insertions(+), 3 deletions(-) diff --git a/ofdEditor/model/Convert/Doc_OFDConvertor.cpp b/ofdEditor/model/Convert/Doc_OFDConvertor.cpp index 80efd9e..0d46dc0 100644 --- a/ofdEditor/model/Convert/Doc_OFDConvertor.cpp +++ b/ofdEditor/model/Convert/Doc_OFDConvertor.cpp @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include "DataTypes/basic_datatype.h" #include "DataTypes/document/ofd.h" @@ -234,9 +236,48 @@ void Doc_OFDConvertor::buildLayer(CT_Layer* ctLayer,DocLayer *layer) */ void Doc_OFDConvertor::buildText(CT_Layer* ctLayer,DocTextBlock *textBlock) { + if(textBlock->getContentLength() == 0) + { + // 如果文本框中没有内容 + qDebug() << "The textBlock has no content in it."; + return; + } + // 分析TextBlock textBlock->moveCursor(QTextCursor::Start); // 移动到块的开始 QTextCursor cursor = textBlock->textCursor(); + QTextDocument* document = cursor.document(); + int blockCount = document->blockCount(); // 获得Block的数量 + + qDebug() << "This textBlock has " << blockCount << " QTextBlocks"; + + for(int i =0; i #include #include +#include @@ -104,6 +105,32 @@ DocBlock *DocTextBlock::getBlock() return this->block; } +/** + * @Author Chaoqun + * @brief 获得TextBlock中的所有文本 + * @param void + * @return QString & + * @date 2017/06/25 + */ +QString &DocTextBlock::getContent() +{ + QString content = this->document()->toPlainText(); // 获得纯文本 + return content; +} + +/** + * @Author Chaoqun + * @brief 蝴蝶文字框内容长度 + * @param void + * @return int + * @date 2017/06/25 + */ +int DocTextBlock::getContentLength() +{ + QString content = this->document()->toPlainText(); + return content.length(); +} + /** * @Author Chaoqun * @brief 用来合并格式 @@ -334,6 +361,57 @@ void DocTextBlock::textUnderline() false:true); mergeFormatOnWordOrSelection(fmt); // 合并格式 + + +// /////test +// QTextCursor cursor = this->textCursor(); // 获取光标 +// cursor.movePosition(QTextCursor::Start); // 移动到文章开头 +// for(int i = 0 ; i < this->document()->blockCount(); i++) +// { +// QTextBlock block = cursor.block(); // 获得当前块 +// QTextCursor tempCursor = cursor; // 复制cursor + +// QTextBlock::Iterator iter = block.begin(); // 块的开始 +// QString lineContent; // 行内容 +// QString tempFragement; // 块 +// QTextFragment fragment; // 短句 + +// while(!iter.atEnd()) // 用来判断是否处理完了 +// { +// if(tempFragement == "") +// { +// // 如果处理字段为空 +// fragment = iter.fragment(); // 获得当前的 +// tempFragement = fragment.text(); // +// iter++; +// } +//// while(lineContent.length() < tempFragement.length()) +//// { +//// cursor.select(QTextCursor::LineUnderCursor); // 选择当前行 +//// QString currentLine = cursor.selectedText(); // 选中的文字 + +//// lineContent += currentLine; // 追加一行 +//// qDebug() << "Read Next Line: " << currentLine +//// << "LineContent: " << lineContent; +//// } +// if(lineContent == "") +// { +// cursor.select(QTextCursor::LineUnderCursor); // 选择当前行 +// QString currentLine = cursor.selectedText(); // 选中的文字 + +// lineContent += currentLine; // 追加一行 +// qDebug() << "Read Next Line: " << currentLine +// << "LineContent: " << lineContent; +// } + +// // 处理当前Fragment +//// if(fra) + + +// } + +// cursor.movePosition(QTextCursor::NextBlock); +// } } /** diff --git a/ofdEditor/model/Doc/DocTextBlock.h b/ofdEditor/model/Doc/DocTextBlock.h index 51815bc..7e1a8d7 100644 --- a/ofdEditor/model/Doc/DocTextBlock.h +++ b/ofdEditor/model/Doc/DocTextBlock.h @@ -33,8 +33,8 @@ public: DocPage* getPage(); // 获得页 DocLayer* getLayer(); // 获得层 DocBlock* getBlock(); // 获得Block - - + QString& getContent(); // 获得TextBlock中的所有文本 + int getContentLength(); // 获得内部文字长度 public slots: -- Gitee