Browse Source

插入评估方案信息。

Ulricy 1 year ago
parent
commit
e8ebc870e7

+ 50 - 2
QFD/common/ExportReportManager.cpp

@@ -110,7 +110,55 @@ void ExportReportManager::insertCommonInfo()
     insertText("bmEvalPurpose", m_proj->estimateObjective);
 }
 
-void ExportReportManager::insertSchemeInfo() { }
+void ExportReportManager::insertSchemeInfo()
+{
+    QList<SchemaEval *> schemeList;
+    bool ret = SchemeInfoService().QuerySchemeInfoByEngineerId(&schemeList, m_proj->id, 0);
+    if (ret == false) {
+        qDebug() << __FUNCTION__ << __LINE__ << "query" << endl;
+        return;
+    }
+
+    for (int i = schemeList.size() - 1; i >= 0; --i) {
+        // 插入图片
+        QAxObject *bmSchemes = m_word->getDocument()->querySubObject("Bookmarks(QVariant)", "bmSchemes");
+        if (bmSchemes != nullptr) {
+            bmSchemes->dynamicCall("Select(void)");
+            QAxObject *range        = bmSchemes->querySubObject("Range");
+            QAxObject *inlineShapes = range->querySubObject("InlineShapes");
+            QAxObject *shape = inlineShapes->querySubObject("AddPicture(const QString&)", schemeList[i]->filePath);
+            if (shape != nullptr) {
+                shape->setProperty("Width", 200);
+                shape->setProperty("Height", 200);
+            }
+        }
+
+        m_word->insertMoveDown();
+
+        // 插入图片标题
+
+        QString remark  = schemeList[i]->remark;
+        int picTtlIndex = remark.lastIndexOf("(图");
+        QString subStr  = remark.mid(picTtlIndex + 1, 8);
+        QString picTtl  = "";
+        if (subStr.contains(")")) {
+            picTtl = subStr.split(")").first();
+        }
+
+        m_word->setFontName(QString::fromLocal8Bit("黑体"));
+        m_word->setFontSize(9);
+        m_word->setParagraphAlignment(0);
+        m_word->insertText(picTtl + " " + "阵地位置图");
+        m_word->insertMoveDown();
+
+        // 插入方案描述
+        insertText("bmSchemes", schemeList[i]->name + ":" + schemeList[i]->remark);
+
+        if (i != 0) {
+            m_word->insertMoveDown();
+        }
+    }
+}
 
 bool ExportReportManager::insertText(const QString &bookmark, const QString &text)
 {
@@ -119,7 +167,7 @@ bool ExportReportManager::insertText(const QString &bookmark, const QString &tex
     QAxObject *bmProjName = doc->querySubObject("Bookmarks(QVariant)", bookmark);
 
     if (bmProjName != nullptr) {
-        bmProjName->dynamicCall("Select(void)");  //选中要选中的区域
+        bmProjName->dynamicCall("Select(void)");
         QAxObject *range = bmProjName->querySubObject("Range");
         ret              = range->setProperty("Text", text);
     }

+ 18 - 0
QFD/common/ExportReportManager.h

@@ -46,6 +46,24 @@ private:
 
 #endif  // EXPORTREPORTMANAGER_H
 
+/*
+
+            bmSchemes->dynamicCall("Select(void)");
+            QAxObject *selection = m_word->getWordApp()->querySubObject("Selection");
+            if (!selection)
+                return;
+
+            selection->dynamicCall("InsertAfter(QString&)", "\n");
+            // selection->dynamicCall("MoveLeft(int)", 1);
+            selection->querySubObject("ParagraphFormat")->dynamicCall("Alignment", "wdAlignParagraphCenter");
+            // selection->dynamicCall("TypeText(QString&)", "Table Test");//设置标题
+
+            QAxObject *range1 = selection->querySubObject("Range");
+            QAxObject *tables = doc->querySubObject("Tables");
+            QAxObject *table  = tables->querySubObject("Add(QVariant,int,int)", range1->asVariant(), 2, 2);
+
+*/
+
 /**
  * 标签名称
  *

+ 6 - 1
QFD/helper/QWord/QWord.cpp

@@ -12,6 +12,8 @@
 #    include <ActiveQt/QAxBase>
 #    include <QTextFormat>
 
+#    include <QDebug>
+
 QWord::QWord(QObject *parent)
 {
     CoInitializeEx(NULL, COINIT_MULTITHREADED);  //解决非主线程无法调用word问题
@@ -108,6 +110,9 @@ bool QWord::openword(bool bVisable)
         return false;
     }
     documents->dynamicCall("Add(QString)", m_strFilePath);
+
+    m_document = m_word->querySubObject("ActiveDocument");
+
     m_bOpened = true;
     return m_bOpened;
 }
@@ -674,7 +679,7 @@ void QWord::addTableRow(int tableIndex, int nRow, int rowCount)
 ////创建表格
 void QWord::insertTable(int tableIndex, int row, int column)
 {
-
+    qDebug() << __FUNCTION__ << __LINE__ << m_document << endl;
     QAxObject *tables = m_document->querySubObject("Tables");
     if (nullptr == tables) {
         return;

+ 0 - 2
QFD/widgets/EvalReportWidget.cpp

@@ -48,8 +48,6 @@ EvalReportWidget::~EvalReportWidget()
 
 void EvalReportWidget::exportReport()
 {
-    qDebug() << __FUNCTION__ << __LINE__ << m_exportMngr->evalType() << endl;
-
     m_exportMngr->exportReport();
 
     return;