14.06.2023

This commit is contained in:
Plotnikov
2023-06-14 18:08:32 +03:00
parent b0a0566f19
commit bdf6eab9ec
221 changed files with 203557 additions and 585 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

View File

@@ -25,7 +25,7 @@ class EditorMainWindow : public QMainWindow
Q_OBJECT
public:
QString version = "вер. 1.16";
QString version = "вер. 1.15";
EditorMainWindow(QWidget *parent = nullptr);
~EditorMainWindow();

View File

@@ -447,22 +447,6 @@
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@@ -182,7 +182,7 @@ void HTML::Generate(S1000D_Manager* _SM, bool _toScorm, SplashForm* _splash) {
}
if(newTitle == id)
if(!SM->isConsole)
qDebug() << "[html: "+QString::number(i)+"] Ссылка не переименована: " + id + " ("+SM->item->fileName+")";
qDebug() << "Ссылка не переименована: " << id << "("+SM->item->importedFromLyX+")";
SM->item->html[i].replace(SM->item->html[i].mid(_b, _e-_b), newTitle);
}
@@ -322,74 +322,12 @@ void HTML::parseNode(QDomNode node, int lvl) {
}
id = id.replace(".", "_").replace(":", "_").replace("-", "_").replace(" ", "_"); //normID
//qDebug() << "internalRef: "+id;
cat("<a href=\"#"+id+"\">");
cat("idTitle_"+id); //TODO
cat("</a>");
return;
}
if(name == "dmSegmentRef") {
QString tPath = node.toElement().attribute("targetPath");
//int _b = tPath.indexOf("'");
//QString id = tPath.mid(_b+1, tPath.indexOf("'", _b+1)-(_b+1));
QString refFileCode = SM->dmCodeIdentString(node.toElement().namedItem("dmRefIdent").namedItem("dmCode"));
QString refTechName = node.toElement().namedItem("dmRefAddressItems").namedItem("dmTitle").namedItem("techName").childNodes().at(0).toText().data();
QString refInfoName = node.toElement().namedItem("dmRefAddressItems").namedItem("dmTitle").namedItem("infoName").childNodes().at(0).toText().data();
int refItemInd = -1;
int tmpCurItem = SM->itemIndex;
for(int i=0;i<SM->items.count();i++)
if(SM->items[i].moduleType == mtDM){
SM->setCurItem(i);
QString itemFileCode = SM->dmIdentString("identAndStatusSection.dmAddress.dmIdent");
QString itemTechName = SM->item->doc.namedItem("dmodule").namedItem("identAndStatusSection").namedItem("dmAddress").namedItem("dmAddressItems").namedItem("dmTitle").namedItem("techName").childNodes().at(0).toText().data();
QString itemInfoName = SM->item->doc.namedItem("dmodule").namedItem("identAndStatusSection").namedItem("dmAddress").namedItem("dmAddressItems").namedItem("dmTitle").namedItem("infoName").childNodes().at(0).toText().data();
if(refFileCode == itemFileCode && refTechName == itemTechName && refInfoName == itemInfoName)
{
refItemInd = i; break;
}
}
if(refItemInd == -1) {
qDebug() << "HTML dmSegmentRef: ref item not found ("+refTechName+" "+refFileCode+")";
return;
}
QString labelTitle = "";
QDomNode labelNode = SM->getNodeFromXPath(tPath); //, true
if(labelNode.isNull()) {
qDebug() << "HTML dmSegmentRef: labelNode.isNull ";
qDebug() << " " << tPath;
qDebug() << " " << SM->item->fileName;
return;
}
else {
//qDebug() << "HTML dmSegmentRef: OK - " << tPath;
}
if(labelNode.toElement().namedItem("title").isNull()) {
qDebug() << "HTML dmSegmentRef: labelNode.title.isNull";
//return;
} else {
labelTitle = labelNode.toElement().namedItem("title").toElement().firstChild().toText().data();
}
QString id = labelNode.attributes().namedItem("id").nodeValue();
id = id.replace(".", "_").replace(":", "_").replace("-", "_").replace(" ", "_"); //normID
QString htmlFileName = QString(SM->item->fileName).replace(".xml", ".html");
SM->setCurItem(tmpCurItem);
//***********
//qDebug() << "<a href=\""+htmlFileName+"#"+id+"\">";
cat("<a href=\""+htmlFileName+"#"+id+"\">");
cat(refTechName + " / " + labelTitle);
cat("</a>");
return;
}
if(name == "randomList") {
bool oldParaIdent = paraIdent; paraIdent = false;
if(node.firstChild().nodeName() == "title") {
@@ -821,6 +759,8 @@ void HTML::parseNode(QDomNode node, int lvl) {
paraIdent = oldParaIdent;
return;
}
//<span style="font-weight:bold;background-color:#000000;color:#FFFFFF">ОТКЛ</span>
//<span style="font-weight:bold;background-color:#000000;color:#00FF00">ВКЛ</span>
if(name == "supScript" || name == "subScript") {
if(node.childNodes().count() == 1)
@@ -1023,10 +963,9 @@ void HTML::parseNode(QDomNode node, int lvl) {
}
QString s = "<b><i>(-unknown-)</i> " + node.nodeName() + " " + node.nodeValue() + "</b><br>";
qDebug() << "Unknown S1000D node: "+node.nodeName();
add(0, s);
//for(int j=0;j<node.childNodes().count();j++)
// parseNode(node.childNodes().at(j), lvl+1);
for(int j=0;j<node.childNodes().count();j++)
parseNode(node.childNodes().at(j), lvl+1);
}
QString HTML::spc(int n) {

View File

@@ -121,7 +121,7 @@ bool LyX::Import(S1000D_Manager* _SM, QString fileName, SplashForm* _splash) {
curChapterItem = curSectionItem = curSubsectionItem = -1;
tocItemNum = acrListItemNum = -1;
tableOfContentsRoot.childs.clear(); domTableOfContentsNode.clear(); domAcronymListNode.clear();
labelList.clear(); acronymList.clear(); refList.clear();
labelList.clear(); acronymList.clear();
cntTable = cntFigure = cntPar = 0;
tableTitle = ""; tableID = "";
flags.align = ""; flags.bold = false; flags.italic = false; flags.underlined = false;
@@ -176,20 +176,8 @@ bool LyX::readLyXFile(QString fileName) {
parseBlock(i+1, findTagEnd(i)-1, domRootNode); // поехали
//if(lyxLog.count() == 2) lyxLog.append("#Завершено без ошибок.");
if(lyxLog.count() == 2) lyxLog.append("#Завершено без ошибок."); //SM->item->
if(curSubsectionItem != -1) SM->items[curSubsectionItem].lyxLog = lyxLog;
//for(int i=0;i<SM->items.count();i++)
// qDebug() << i << SM->items[i].fileName << SM->items[i].doc.namedItem("dmodule").nodeName() << SM->items[i].doc.namedItem("dmodule").childNodes().count();
//qDebug() << "";
//SM->SaveProject();
connectRefsWithLabels();
for(int i=0;i<SM->items.count();i++)
if(SM->items[i].lyxLog.count() == 2) SM->items[i].lyxLog.append("#Завершено без ошибок.");
return true;
}
@@ -271,7 +259,7 @@ void LyX::parseBlock(int _beg, int _end, QDomNode _domCurLevelNode) {
appendChapter(title);
checkForOldIdent();
SM->item->importedFromLyX = curLyXFileName;
domCurLevelNode = SM->item->doc.namedItem("pm").namedItem("content");
domCurLevelNode.clear();
continue;
}
@@ -293,7 +281,7 @@ void LyX::parseBlock(int _beg, int _end, QDomNode _domCurLevelNode) {
appendSection(title);
checkForOldIdent();
SM->item->importedFromLyX = curLyXFileName;
domCurLevelNode = SM->item->doc.namedItem("pm").namedItem("content");
domCurLevelNode.clear();
continue;
}
@@ -313,13 +301,12 @@ void LyX::parseBlock(int _beg, int _end, QDomNode _domCurLevelNode) {
//if(DBG) qDebug() << " " + title;
//qDebug() << internalRefList.count();
/*
for(int j=0;j<internalRefList.count();j++) {
QString id = internalRefList[j];
lyxLog.append("![] Некорректная ссылка ("+id+")");
//SM->item->isQualifyed = false; ???
}
internalRefList.clear(); */
internalRefList.clear();
if(docChapter == -1) appendChapter("");
if(docSection == -1) appendSection("");
@@ -547,67 +534,26 @@ void LyX::parseBlock(int _beg, int _end, QDomNode _domCurLevelNode) {
}
if(itemName == "\\begin_layout Enumerate" || itemName == "\\begin_layout Itemize") { //
// QDomNode titleNodeClone;
// if(domCurLevelNode.hasChildNodes())
// if(domCurLevelNode.lastChild().nodeName() == "para") {
// titleNodeClone = domCurLevelNode.lastChild().cloneNode();
// domCurLevelNode.removeChild(domCurLevelNode.lastChild());
// titleNodeClone.toElement().setTagName("title");
// }
QDomNode lastPara;
QDomNode titleNodeClone;
if(domCurLevelNode.hasChildNodes())
if(domCurLevelNode.lastChild().nodeName() == "para")
lastPara = domCurLevelNode.lastChild();
if(domCurLevelNode.lastChild().nodeName() == "para") {
titleNodeClone = domCurLevelNode.lastChild().cloneNode();
domCurLevelNode.removeChild(domCurLevelNode.lastChild());
titleNodeClone.toElement().setTagName("title");
}
QDomNode listNode;
if(itemName == "\\begin_layout Enumerate") listNode = SM->item->doc.createElement("sequentialList");
if(itemName == "\\begin_layout Itemize") listNode = SM->item->doc.createElement("randomList");
domCurLevelNode.appendChild(listNode);
// QDomNode titleNode;
// if(titleNodeClone.isNull()) {
// //titleNode = SM->item->doc.createElement("title");
// //titleNode.appendChild(SM->item->doc.createTextNode(""));
// //listNode.appendChild(titleNode);
// }
// else {
// titleNode = SM->item->doc.importNode(titleNodeClone, true);
// listNode.appendChild(titleNode);
// }
if(!lastPara.isNull()) // вышестоящий абзац берем как заголовок, делаем из para -> title
{
QDomNode titleNode = SM->item->doc.createElement("title");
while(lastPara.hasChildNodes()) {
QDomNode ch = lastPara.removeChild(lastPara.firstChild());
titleNode.appendChild(ch);
}
QDomNode titleNode;
if(titleNodeClone.isNull()) {
//titleNode = SM->item->doc.createElement("title");
//titleNode.appendChild(SM->item->doc.createTextNode(""));
//listNode.appendChild(titleNode);
}
else {
titleNode = SM->item->doc.importNode(titleNodeClone, true);
listNode.appendChild(titleNode);
lastPara.parentNode().removeChild(lastPara);
QList<QDomNode> list;
QDomNode node;
list.append(titleNode);
while(!list.isEmpty()) { // обновляем refList и labelList для перемещенных узлов
node = list.takeFirst();
if(node.nodeName().startsWith("blankRefNode")) {
for(int n=0;refList.count();n++)
if(refList[n].nodeXPath.endsWith(node.nodeName())) {
refList[n].nodeXPath = SM->makeNodeXPath(node);
break;
}
}
QString nodeID = node.attributes().namedItem("id").nodeValue();
if(nodeID != "")
for(int n=0;labelList.count();n++)
if(labelList[n].id == nodeID) {
labelList[n].nodeXPath = SM->makeNodeXPath(node);
break;
}
for(int n=0;n<node.childNodes().count();n++)
list.append(node.childNodes().at(n));
}
}
int _childBeg, _childEnd=i;
@@ -815,11 +761,10 @@ void LyX::parseBlock(int _beg, int _end, QDomNode _domCurLevelNode) {
footnoteRef.toElement().setAttribute("internalRefId", acronymList[acroNum].id);
domCurLevelNode.appendChild(footnoteRef);
} else { // внутренняя ссылка
/*
int foundLabel = -1;
for(int j=0;j<labelList.count();j++)
if(refID == labelList[j].lyxLabel) { foundLabel = j; break; }
QDomNode internalRef = SM->item->doc.createElement("internalRef");
if(foundLabel == -1) {
if(internalRefList.indexOf(refID) == -1)
internalRefList.append(refID);
@@ -829,20 +774,19 @@ void LyX::parseBlock(int _beg, int _end, QDomNode _domCurLevelNode) {
//qDebug() << "internalRef foundLabel: "+refID+" -> "+labelList[foundLabel].id;
refID = labelList[foundLabel].id;
}
*/
QDomNode internalRef = SM->item->doc.createElement("blankRefNode"+QString::number(refList.count()));
internalRef.toElement().setAttribute("xlink:actuate", "onRequest");
internalRef.toElement().setAttribute("xlink:show", "replace");
internalRef.toElement().setAttribute("xlink:href", "#"+refID); //labelList[foundLabel].id
internalRef.toElement().setAttribute("internalRefId", refID); //labelList[foundLabel].id
QString refTarget = "irtt07";
if(refID.left(3) == "fig") refTarget = "irtt01";
if(refID.left(3) == "tab") refTarget = "irtt02";
if(refID.left(3) == "par") refTarget = "irtt07";
if(refID.left(3) == "mma") refTarget = "irtt03";
if(refID.left(3) == "fig" && refID.mid(9,3) == "hot") refTarget = "irtt11";
internalRef.toElement().setAttribute("internalRefTargetType", refTarget);
domCurLevelNode.appendChild(internalRef);
refStruct ref;
ref.itemInd = SM->itemIndex;
ref.labelFound = false;
ref.lineNum = _insetBeg+lyxEmptyCnt[_insetBeg];
ref.lyxRef = refID;
//internalRef = domCurLevelNode.childNodes().at(domCurLevelNode.childNodes().count()-1);
ref.nodeXPath = SM->makeNodeXPath(internalRef);
refList.append(ref);
}
continue;
// <objectUse>attribute internalRefTargetType - Тип объекта внутренней ссылки [BRDP-S1-00100] (Глава 3.9.6.1, таблица 25)</objectUse>
@@ -967,17 +911,14 @@ void LyX::parseBlock(int _beg, int _end, QDomNode _domCurLevelNode) {
}
} else {
labelStruct lbl;
lbl.itemInd = SM->itemIndex;
lbl.lyxLabel = lyxID;
lbl.id = figureID; lbl.used = false;
lbl.lineNum = _insetBeg+lyxEmptyCnt[_insetBeg];
lbl.id = figureID;
labelList.append(lbl); foundLabel = labelList.count()-1;
//qDebug() << "+fig: lyx="+lyxID+" id="+figureID+" internalRefList.count()="+QString::number(internalRefList.count());
}
labelList[foundLabel].defined = true;
/*
for(int j=0;j<internalRefList.count();j++) {
QString id = internalRefList[j];
if(id == lyxID) {
@@ -1019,7 +960,7 @@ void LyX::parseBlock(int _beg, int _end, QDomNode _domCurLevelNode) {
//qDebug() << " "+QString::number(j)+": "+id+" != "+lyxID;
}
}
*/
}
if(_graphicsBeg == -1 || _graphicsEnd == -1)
lyxLog.append("!["+QString::number(_insetBeg+lyxEmptyCnt[_insetBeg])+"] Ошибка вставки плавающего рисунка \""+figureTitle+"\"");
@@ -1040,7 +981,7 @@ void LyX::parseBlock(int _beg, int _end, QDomNode _domCurLevelNode) {
}
if(filename == "") {
lyxLog.append("!["+QString::number(_insetBeg+lyxEmptyCnt[_insetBeg])+"] Ошибка чтения LyX Graphics ("+figureTitle+")");
SM->item->isQualifyed = false; figureID = "";
SM->item->isQualifyed = false;
continue;
}
if(filename.startsWith("../")) filename = filename.mid(3);
@@ -1055,7 +996,7 @@ void LyX::parseBlock(int _beg, int _end, QDomNode _domCurLevelNode) {
}
if(oldfilename == "") {
lyxLog.append("!["+QString::number(_insetBeg+lyxEmptyCnt[_insetBeg])+"] Файл изображения не найден "+filename+" ("+figureTitle+")");
SM->item->isQualifyed = false; figureID = "";
SM->item->isQualifyed = false;
continue;
}
newfilename = SM->projectPath+"/"+ QString::number(docChapter+1) + "." + QString::number(docSection+1) + "." + QString::number(docSubsection+1) +
@@ -1081,12 +1022,6 @@ void LyX::parseBlock(int _beg, int _end, QDomNode _domCurLevelNode) {
figure.appendChild(graphic);
graphic.toElement().setAttribute("infoEntityIdent", QFileInfo(newfilename).fileName());
int labelInd = -1;
for(int j=0;j<labelList.count();j++)
if(figureID == labelList[j].id) {labelInd = j; break;}
if(labelInd != -1)
labelList[labelInd].nodeXPath = SM->makeNodeXPath(figure);
// если есть файл .txt с хотспотами - копируем его и файлы в нем указанные
QString txtoldfilename = oldfilename; txtoldfilename.replace(".svg", ".txt");
QString txtnewfilename = newfilename; txtnewfilename.replace(".svg", ".txt");
@@ -1183,7 +1118,7 @@ void LyX::parseBlock(int _beg, int _end, QDomNode _domCurLevelNode) {
}
if(insetName == "CommandInset label") {
lyxLog.append("!["+QString::number(_insetBeg+lyxEmptyCnt[_insetBeg])+"] Использование меток допускается только в сносках и плавающих таблицах/рисунках.");
lyxLog.append("!["+QString::number(_insetBeg+lyxEmptyCnt[_insetBeg])+"] Команда <метка> вне слоя, обратитесь к разработчику");
SM->item->isQualifyed = false;
continue;
}
@@ -1230,15 +1165,13 @@ void LyX::parseBlock(int _beg, int _end, QDomNode _domCurLevelNode) {
}
} else {
labelStruct lbl;
lbl.itemInd = SM->itemIndex;
lbl.lyxLabel = lyxID;
lbl.id = tableID; lbl.used = false;
lbl.lineNum = _insetBeg+lyxEmptyCnt[_insetBeg];
lbl.id = tableID; // в дальнейшем возможно пересмотреть и присваивать номера (tab-0001)
labelList.append(lbl); foundLabel = labelList.count()-1;
}
labelList[foundLabel].defined = true;
/*
for(int j=0;j<internalRefList.count();j++) {
QString id = internalRefList[j];
if(id == lyxID) {
@@ -1267,7 +1200,7 @@ void LyX::parseBlock(int _beg, int _end, QDomNode _domCurLevelNode) {
internalRefList.removeAt(j); j--;
}
}
*/
}
if(_tabularBeg == -1 || _tabularEnd == -1)
@@ -1306,8 +1239,7 @@ void LyX::parseBlock(int _beg, int _end, QDomNode _domCurLevelNode) {
QDomNode table = SM->item->doc.createElement("table");
domCurLevelNode.appendChild(table);
table.toElement().setAttribute("frame", "topbot");
if(tableID != "")
table.toElement().setAttribute("id", tableID);
if(tableID != "") table.toElement().setAttribute("id", tableID);
table.toElement().setAttribute("colsep", "0");
table.toElement().setAttribute("rowsep", "0");
table.toElement().setAttribute("tocentry", "1");
@@ -1327,12 +1259,6 @@ void LyX::parseBlock(int _beg, int _end, QDomNode _domCurLevelNode) {
tgroup.appendChild(colspec); //<colspec colname="col2" colwidth="1*"/>
}
int labelInd = -1;
for(int j=0;j<labelList.count();j++)
if(tableID == labelList[j].id) {labelInd = j; break;}
if(labelInd != -1)
labelList[labelInd].nodeXPath = SM->makeNodeXPath(table);
QList<QList<cellStruct>> tableArr;
// cellStruct** tableArr = new cellStruct*[rows];
@@ -1441,15 +1367,6 @@ void LyX::parseBlock(int _beg, int _end, QDomNode _domCurLevelNode) {
for(int j=0;j<rows;j++) {
QDomNode row = SM->item->doc.createElement("row");
//if(!multiRowFlag) rowToHead = false;
if(j <= lastHeadRow) { //j==0 || rowToHead
row.toElement().setAttribute("rowsep", "1");
thead.appendChild(row);
} else {
row.toElement().setAttribute("rowsep", "0");
tbody.appendChild(row);
}
//bool multiRowFlag = false;
for(int k=0;k<cols;k++) {
if (tableArr[j][k].createS1000D_entry) {
@@ -1466,6 +1383,15 @@ void LyX::parseBlock(int _beg, int _end, QDomNode _domCurLevelNode) {
} //cols
//if(tableArr[j][k].multiRow != "") multiRowFlag = true;
}
//if(!multiRowFlag) rowToHead = false;
if(j <= lastHeadRow) { //j==0 || rowToHead
row.toElement().setAttribute("rowsep", "1");
thead.appendChild(row);
} else {
row.toElement().setAttribute("rowsep", "0");
tbody.appendChild(row);
}
} //rows
// for(int j=0;j<rows;j++)
@@ -1634,11 +1560,12 @@ void LyX::appendChapter(QString title) {
// }
docChapter++; docSection = docSubsection = -1;
cntTable = cntFigure = cntPar = 0;
//if(lyxLog.count() == 2) lyxLog.append("#Завершено без ошибок.");
if(lyxLog.count() == 2) lyxLog.append("#Завершено без ошибок.");
if(curSubsectionItem != -1) SM->items[curSubsectionItem].lyxLog = lyxLog;
curChapterItem = SM->createPM(-1, -1);
SM->setCurItem(curChapterItem);
curSectionItem = curSubsectionItem = -1;
SM->item->origTitle = title;
SM->item->fileName = QString::number(docChapter+1) + " " + title + ".xml"; // SM->projectPath + "/" +
SM->setNodeText("identAndStatusSection.pmAddress.pmAddressItems.pmTitle", title);
@@ -1654,11 +1581,12 @@ void LyX::appendSection(QString title) {
// lyxLog.append("!Ошибка в структуре заголовков: "+title);
// }
docSection++; docSubsection = -1;
//if(lyxLog.count() == 2) lyxLog.append("#Завершено без ошибок.");
if(lyxLog.count() == 2) lyxLog.append("#Завершено без ошибок.");
if(curSubsectionItem != -1) SM->items[curSubsectionItem].lyxLog = lyxLog;
curSectionItem = SM->createPM(curChapterItem, SM->items[curChapterItem].child.count()-1);
SM->setCurItem(curSectionItem);
curSubsectionItem = -1;
SM->item->origTitle = title;
SM->item->fileName = QString::number(docChapter+1) + "." + QString::number(docSection+1) + " " + title + ".xml";
SM->setNodeText("identAndStatusSection.pmAddress.pmAddressItems.pmTitle", title);
@@ -1674,7 +1602,7 @@ void LyX::appendSubsection(QString title) {
// lyxLog.append("!Ошибка в структуре заголовков: "+title);
// }
docSubsection++;
//if(lyxLog.count() == 2) lyxLog.append("#Завершено без ошибок.");
if(lyxLog.count() == 2) lyxLog.append("#Завершено без ошибок.");
if(curSubsectionItem != -1) SM->items[curSubsectionItem].lyxLog = lyxLog;
//SM->item->fileName = QString::number(docChapter+1) + "." + QString::number(docSection+1) + "." + QString::number(docSubsection+1) + " " + title + ".xml";
if(title.startsWith("~")) {
@@ -1683,6 +1611,7 @@ void LyX::appendSubsection(QString title) {
} else
curSubsectionItem = SM->createDM(curSectionItem, SM->items[curSectionItem].child.count()-1, "DESCRIPT");
SM->setCurItem(curSubsectionItem);
SM->item->origTitle = title;
SM->item->fileName = QString::number(docChapter+1) + "." + QString::number(docSection+1) + "." + QString::number(docSubsection+1) + " " + title + ".xml";
SM->setNodeText("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.techName", title);
@@ -1937,117 +1866,6 @@ void LyX::addQuestInteraction(QDomNode domLearnNode, QString question, QStringLi
}
}
void LyX::connectRefsWithLabels() {
int i, j;
for(i=0;i<refList.count();i++) {
refList[i].labelFound = false;
for(j=0;j<labelList.count();j++)
if(refList[i].lyxRef == labelList[j].lyxLabel)
break;
QDomNode refNode, labelNode;
if(j >= labelList.count()) {
SM->items[refList[i].itemInd].lyxLog.append("!["+QString::number(refList[i].lineNum)+"] Ссылка на неизвестную метку: "+refList[i].lyxRef);
qDebug() << "Ref to unknown label["+QString::number(refList[i].lineNum)+"]: "+refList[i].lyxRef;
}
else {
labelList[j].used = true; refList[i].labelFound = true;
SM->setCurItem(refList[i].itemInd);
QDomNode oldrefNode = SM->getNodeFromXPath(refList[i].nodeXPath);
if(oldrefNode.isNull()) {
qDebug() << "ref "+refList[i].lyxRef+" ignored - refNode.isNull():" << refList[i].nodeXPath << SM->items[refList[i].itemInd].fileName;
refNode = SM->getNodeFromXPath(refList[i].nodeXPath, true);
continue;
}
if(!oldrefNode.nodeName().startsWith("blankRefNode"))
qDebug() << "Rename "+oldrefNode.nodeName()+" to REF("+refList[i].nodeXPath+")";
if(refList[i].itemInd == labelList[j].itemInd) {
QString refID = labelList[j].id; // ссылка внутри модуля данных
refNode = SM->item->doc.createElement("internalRef");
oldrefNode.parentNode().replaceChild(refNode, oldrefNode);
refNode.toElement().setAttribute("xlink:actuate", "onRequest");
refNode.toElement().setAttribute("xlink:show", "replace");
refNode.toElement().setAttribute("xlink:href", "#"+refID);
refNode.toElement().setAttribute("internalRefId", refID);
QString refTarget = "irtt07";
if(refID.left(3) == "fig") refTarget = "irtt01";
if(refID.left(3) == "tab") refTarget = "irtt02";
if(refID.left(3) == "par") refTarget = "irtt07";
if(refID.left(3) == "mma") refTarget = "irtt03";
if(refID.left(3) == "fig" && refID.mid(9,3) == "hot") refTarget = "irtt11";
refNode.toElement().setAttribute("internalRefTargetType", refTarget);
//qDebug() << "Internal ref["+QString::number(refList[i].lineNum)+"]:" << labelList[j].id;
} else { // ссылка на внешний модуль
refNode = SM->item->doc.createElement("dmSegmentRef");
oldrefNode.parentNode().replaceChild(refNode, oldrefNode);
//QString tPath = "//"+labelList[j].nodeName+"[@id='"+labelList[j].id+"']"; //SM->makeXPathToNode(labelNode); // //title[@lang='en']
refNode.toElement().setAttribute("targetPath", labelList[j].nodeXPath);
SM->setCurItem(refList[i].itemInd);
QDomElement dmRefIdent = SM->item->doc.createElement("dmRefIdent");
refNode.appendChild(dmRefIdent);
QDomElement dmCode = SM->item->doc.createElement("dmCode");
dmRefIdent.appendChild(dmCode);
SM->setCurItem(labelList[j].itemInd);
QDomNode labelDMNode = SM->findElement("identAndStatusSection.dmAddress.dmIdent.dmCode");
SM->setCurItem(refList[i].itemInd);
for(int k=0;k<labelDMNode.toElement().attributes().count();k++)
dmCode.setAttribute(labelDMNode.toElement().attributes().item(k).nodeName(),
labelDMNode.toElement().attributes().item(k).nodeValue());
QDomElement issueInfo = SM->item->doc.createElement("issueInfo");
dmRefIdent.appendChild(issueInfo);
issueInfo.setAttribute("inWork", SM->ru_const.inWork);
issueInfo.setAttribute("issueNumber", SM->ru_const.issueNumber);
QDomElement language = SM->item->doc.createElement("language");
dmRefIdent.appendChild(language);
language.setAttribute("languageIsoCode", SM->ru_const.languageIsoCode);
language.setAttribute("countryIsoCode", SM->ru_const.countryIsoCode);
SM->setCurItem(labelList[j].itemInd);
QString techName = SM->findElement("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.techName").childNodes().at(0).toText().data();
QString infoName = SM->findElement("identAndStatusSection.dmAddress.dmAddressItems.dmTitle.infoName").childNodes().at(0).toText().data();
SM->setCurItem(refList[i].itemInd);
QDomElement dmRefAddressItems = SM->item->doc.createElement("dmRefAddressItems");
refNode.appendChild(dmRefAddressItems);
QDomElement dmTitle = SM->item->doc.createElement("dmTitle");
dmRefAddressItems.appendChild(dmTitle);
QDomElement dmTechName = SM->item->doc.createElement("techName");
dmTitle.appendChild(dmTechName);
dmTechName.appendChild(SM->item->doc.createTextNode(techName));
QDomElement dmInfoName = SM->item->doc.createElement("infoName");
dmTitle.appendChild(dmInfoName);
dmInfoName.appendChild(SM->item->doc.createTextNode(infoName));
//qDebug() << "External ref["+QString::number(refList[i].lineNum)+"]:" << labelList[j].id << labelList[j].lyxLabel << labelList[j].itemInd << refList[i].itemInd;
}
}
}
for(j=0;j<labelList.count();j++)
if(!labelList[j].used) {
SM->items[labelList[j].itemInd].lyxLog.append("#["+QString::number(labelList[j].lineNum)+"] Неиспользуемая метка: "+labelList[j].lyxLabel);
//qDebug() << "Label not used ["+QString::number(labelList[j].lineNum)+"]: "+labelList[j].id;
}
}
//QString LyX::questLyXtoHTML(QString answer) {
// // функция пока не используется
// qDebug() << answer;

View File

@@ -34,7 +34,6 @@ public:
// QString questLyXtoHTML(QString answer);
void addQuestInteraction(QDomNode domLearnNode, QString question, QStringList answers);
QDomNode searchSVGNodeForSpanNode(QDomNode node);
void connectRefsWithLabels();
QStringList lyxList;
QStringList lyxLog;
@@ -58,22 +57,10 @@ public:
};
QList<acronymStruct> acronymList;
struct labelStruct {
int itemInd;
QString lyxLabel, id;
bool defined = false;
bool used = false;
QString nodeXPath;
int lineNum;
bool defined;
};
QList<labelStruct> labelList;
struct refStruct {
int itemInd;
QString lyxRef;
bool labelFound;
QString nodeXPath;
int lineNum;
};
QList<refStruct> refList;
int cntTable, cntFigure, cntPar;
struct cellStruct {

View File

@@ -554,23 +554,6 @@ QString S1000D_Manager::dmIdentString(QString dmIdentPath) {
//resStr += getNodeAttr(dmIdentPath+".issueInfo", "inWork");
return resStr;
}
QString S1000D_Manager::dmCodeIdentString(QDomNode node) {
QString resStr = "";
resStr += node.toElement().attribute("modelIdentCode")+"-";
resStr += node.toElement().attribute("systemDiffCode")+"-";
resStr += node.toElement().attribute("systemCode")+"-";
resStr += node.toElement().attribute("subSystemCode");
resStr += node.toElement().attribute("subSubSystemCode")+"-";
resStr += node.toElement().attribute("assyCode")+"-";
resStr += node.toElement().attribute("disassyCode");
resStr += node.toElement().attribute("disassyCodeVariant")+"-";
resStr += node.toElement().attribute("infoCode");
resStr += node.toElement().attribute("infoCodeVariant")+"-";
resStr += node.toElement().attribute("itemLocationCode");
QString learnStr = "-"+node.toElement().attribute("learnCode")+node.toElement().attribute("learnEventCode");
if(learnStr != "-") resStr += learnStr;
return resStr;
}
QString S1000D_Manager::pmIdentString(QString pmIdentPath) {
QString resStr = "";
@@ -1545,20 +1528,6 @@ bool S1000D_Manager::exportSCORM(QString packDir, QString packName, QString pack
// }
resetICN();
for(int i=0;i<items.count();i++) {
setCurItem(i);
QString _issueInfo = "identAndStatusSection.dmAddress.dmIdent.issueInfo";
QString _language = "identAndStatusSection.dmAddress.dmIdent.language";
if(item->schemeType == stLEARNING) {
item->SCORM_fileName = "DMC-" + item->fileCode + "_"+getNodeAttr(_issueInfo, "issueNumber")+"-"+getNodeAttr(_issueInfo, "inWork")+"_"+getNodeAttr(_language, "languageIsoCode")+"-"+getNodeAttr(_language, "countryIsoCode")+".xml";
if(QFile::exists(SCORMpath+"/" + item->SCORM_fileName)) QFile::remove(SCORMpath+"/" + item->SCORM_fileName);
if(!QFile::copy(projectPath+"/"+item->fileName, SCORMpath+"/" + item->SCORM_fileName))
if(DBG) qDebug() << "scorm: Error copy" << projectPath+"/"+item->fileName << "to" << SCORMpath+"/" + item->SCORM_fileName;
continue;
}
item->SCORM_fileName = "DMC-" + item->fileCode + "_"+getNodeAttr(_issueInfo, "issueNumber")+"-"+getNodeAttr(_issueInfo, "inWork")+"_"+getNodeAttr(_language, "languageIsoCode")+"-"+getNodeAttr(_language, "countryIsoCode")+".html";
}
for(int i=0;i<items.count();i++)
if(items[i].toExport && items[i].moduleType == mtDM) {
if(!isConsole) {
@@ -1575,7 +1544,9 @@ bool S1000D_Manager::exportSCORM(QString packDir, QString packName, QString pack
}
return false;
}
QString htmlFileName = projectPath + "/" + item->fileName; htmlFileName.replace(".xml", ".html");
QString htmlFileName = projectPath + "/" + item->fileName;
if (item->schemeType != stLEARNING)
htmlFileName.replace(".xml", ".html");
if (item->moduleType == mtDM && !QFile::exists(htmlFileName) && item->schemeType != stLEARNING) {
if(!isConsole) {
splash->hide();
@@ -1584,6 +1555,16 @@ bool S1000D_Manager::exportSCORM(QString packDir, QString packName, QString pack
}
return false;
}
QString _issueInfo = "identAndStatusSection.dmAddress.dmIdent.issueInfo";
QString _language = "identAndStatusSection.dmAddress.dmIdent.language";
if(item->schemeType == stLEARNING) {
item->SCORM_fileName = SCORMpath+"/" + "DMC-" + item->fileCode + "_"+getNodeAttr(_issueInfo, "issueNumber")+"-"+getNodeAttr(_issueInfo, "inWork")+"_"+getNodeAttr(_language, "languageIsoCode")+"-"+getNodeAttr(_language, "countryIsoCode")+".xml";
if(QFile::exists(item->SCORM_fileName)) QFile::remove(item->SCORM_fileName);
if(!QFile::copy(projectPath+"/"+item->fileName, item->SCORM_fileName))
if(DBG) qDebug() << "scorm: Error copy" << projectPath+"/"+item->fileName << "to" << item->SCORM_fileName;
continue;
}
item->SCORM_fileName = SCORMpath+"/" + "DMC-" + item->fileCode + "_"+getNodeAttr(_issueInfo, "issueNumber")+"-"+getNodeAttr(_issueInfo, "inWork")+"_"+getNodeAttr(_language, "languageIsoCode")+"-"+getNodeAttr(_language, "countryIsoCode")+".html";
QFile htmlFile(htmlFileName);
if (!htmlFile.open(QFile::ReadOnly | QFile::Text)){
@@ -1646,35 +1627,19 @@ bool S1000D_Manager::exportSCORM(QString packDir, QString packName, QString pack
if(k > -1) {
QString fn = htmlText[j].mid(k+s.length(), htmlText[j].indexOf("\"",k+s.length())-k-s.length());
if(!fn.startsWith("#")) {
if(fn.contains(".html#")) { // межмодульная ссылка
fn = fn.left(fn.indexOf("#"));
QString name;
for(int n=0;n<items.count();n++) {
name = items[n].fileName;
name = name.replace(".xml", ".html");
if(fn == name) {
htmlText[j].replace(fn, items[n].SCORM_fileName);
name = "Ok"; break;
QDir dir(projectPath+"/"+fn.split("/")[0]);
QDir dir2(SCORMpath+"/"+fn.split("/")[0]);
if(dir.exists() && !dir2.exists())
if(!copyDir(projectPath+"/"+fn.split("/")[0], SCORMpath+"/"+fn.split("/")[0]))
{
if(!isConsole) {
splash->hide();
splash->ErrMessage("Ошибка", "href: Ошибка копирования:/n'"+projectPath+"/"+fn.split("/")[0]+"' в '"+SCORMpath+"/"+fn.split("/")[0]+"'");
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
}
return false;
}
if(name != "Ok")
qDebug() << "HTML->SCORM - <a href: cant find DM "+fn;
}
else { // папки с Docs и т.д.
QDir dir(projectPath+"/"+fn.split("/")[0]);
QDir dir2(SCORMpath+"/"+fn.split("/")[0]);
if(dir.exists() && !dir2.exists())
if(!copyDir(projectPath+"/"+fn.split("/")[0], SCORMpath+"/"+fn.split("/")[0]))
{
if(!isConsole) {
splash->hide();
splash->ErrMessage("Ошибка", "href: Ошибка копирования:/n'"+projectPath+"/"+fn.split("/")[0]+"' в '"+SCORMpath+"/"+fn.split("/")[0]+"'");
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
}
return false;
}
}
} //#
}
} //<a href=
//s = "<iframe ";
@@ -1722,8 +1687,8 @@ bool S1000D_Manager::exportSCORM(QString packDir, QString packName, QString pack
// onmousemove="showTooltipImg(evt, 'inline.svg');"
// <iframe src="fuselage/index.html" width="100%" height="580px" align="center">
if(QFile::exists(SCORMpath+"/" + item->SCORM_fileName)) QFile::remove(SCORMpath+"/" + item->SCORM_fileName);
QFile htmlOutFile(SCORMpath+"/" + item->SCORM_fileName);
if(QFile::exists(item->SCORM_fileName)) QFile::remove(item->SCORM_fileName);
QFile htmlOutFile(item->SCORM_fileName);
if (htmlOutFile.open(QFile::WriteOnly | QFile::Text)) {
QTextStream out(&htmlOutFile); out.setCodec("UTF-8");
for(int j=0;j<htmlText.count();j++)
@@ -1816,18 +1781,9 @@ bool S1000D_Manager::exportSCORM(QString packDir, QString packName, QString pack
params << "a"<<"-r"<<"-y" << QString(packDir+"/"+packName+".zip") << QString(SCORMpath+"/*.*") << ">nul";
QProcess pc;
pc.start(QString(QCoreApplication::applicationDirPath()+"/7z.exe"), params, QIODevice::ReadWrite);
if(pc.waitForStarted(2000))
while(!pc.waitForFinished(50)) {
if(!isConsole) {splash->Step();}
QCoreApplication::processEvents();
}
else {
qDebug() << "Failed to start 7z";
if(!isConsole) {
splash->hide();
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
}
return false;
while(!pc.waitForFinished(50)) {
if(!isConsole) {splash->Step(); splash->Step(); splash->Step(); }
QCoreApplication::processEvents();
}
}
else
@@ -1835,19 +1791,10 @@ bool S1000D_Manager::exportSCORM(QString packDir, QString packName, QString pack
params << "a"<<"-r"<<"-y" << QString(packDir+"/"+packName+".zip") << QString(SCORMpath+"/*.*");// << ">nul";
QProcess pc;
pc.start("7z", params, QIODevice::ReadWrite);
if(pc.waitForStarted(2000))
while(!pc.waitForFinished(50))
{
if(!isConsole) {splash->Step();}
QCoreApplication::processEvents();
}
else {
qDebug() << "Failed to start 7z";
if(!isConsole) {
splash->hide();
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
}
return false;
while(!pc.waitForFinished(50))
{
if(!isConsole) {splash->Step(); splash->Step(); splash->Step(); }
QCoreApplication::processEvents();
}
}
@@ -2276,162 +2223,7 @@ bool S1000D_Manager::exportS1000D(QString dirName, QString packName, QString pac
return true;
}
/*
void S1000D_Manager::searchPrepare() {
item->searchList.clear();
QList<QDomNode> nodeList;
nodeList.append(item->doc.namedItem("dmodule"));
QDomNode node;
while(!nodeList.isEmpty()) {
node = nodeList.takeFirst();
searchListStruct sItem;
sItem.name = node.nodeName(); sItem.node = node;
item->searchList.append(sItem);
for(int k=0;k<node.childNodes().count();k++)
nodeList.append(node.childNodes().at(k));
}
}
QDomNode S1000D_Manager::searchNodeWithTag(QString tag) { //QDomNode startNode,
for(int i=0;i<item->searchList.count();i++)
if(item->searchList[i].name == tag) {
qDebug() << "Found node " + tag;
return item->searchList[i].node;
}
QDomNode nullNode;
return nullNode;
}
QDomNode S1000D_Manager::searchNodeWithAttr(QString attrName, QString attrVal) { //QDomNode startNode,
for(int i=0;i<item->searchList.count();i++) {
if(item->searchList[i].node.toElement().hasAttribute(attrName) && item->searchList[i].node.toElement().attribute(attrName) == attrVal)
return item->searchList[i].node;
}
QDomNode nullNode;
return nullNode;
}
*/
// targetPath="//lcInstruction/description/levelledPara[attribute::id = 'para-000' and child::levelledPara[fn:position() = 1]]"
QString S1000D_Manager::makeNodeXPath(QDomNode node) {
if(item->doc.namedItem("dmodule").childNodes().count() == 0)
qDebug() << "Empty item: " << itemIndex << item->fileName << item->doc.namedItem("dmodule").nodeName() << item->doc.namedItem("dmodule").childNodes().count();
//else
// qDebug() << itemIndex << "Ok";
QString path="";
QString pos;
int ind=-1, cnt=0;
QDomNode cur = node;
QDomNode chNode;
//if(node.nodeName() == "blankRefNode9")
// qDebug() << "blankRefNode9 debug";
while(1) {
pos = "";
if(!cur.parentNode().isNull()) {
cnt = 0; ind = 0;
for(int i=0;i<cur.parentNode().childNodes().count();i++) {
chNode = cur.parentNode().childNodes().at(i);
if(chNode.nodeName() == cur.nodeName())
cnt++;
if(chNode == cur) {
//if(node.nodeName() == "blankRefNode9")
// qDebug() << "blankRefNode9 debug: " << "cur: " << cur.nodeName() << cnt << " parent: " << cur.parentNode().nodeName();
ind = cnt;
}
}
if(cnt > 1)
pos = "["+QString::number(ind)+"]";
}
path = "/"+cur.nodeName()+pos+path;
if(cur.parentNode().isNull() || cur.parentNode().nodeName() == "#document") {
//if(cur.parentNode().nodeName() != "#document")
// qDebug() << "makeNodeXPath: parentNode("+cur.nodeName()+").isNull";
break;
}
cur = cur.parentNode();
};
QDomNode nd = getNodeFromXPath(path); //, true
if(nd.nodeName() != node.nodeName())
qDebug() << "makeNodeXPath fail: Need "+node.nodeName()+node.nodeType()+" Found "+nd.nodeName()+nd.nodeType()+" Path "+path+"";
//else
// qDebug() << "makeNodeXPath OK";
//if(path.contains("description/para")) {
// qDebug() << "makeNodeXPath: description/para !! " << path << item->fileName;
//}
return path;
}
QDomNode S1000D_Manager::getNodeFromXPath(QString path, bool debugTrace) {
QStringList list = path.mid(1).split("/");
if(debugTrace) qDebug() << "getNodeFromXPath: "+path;
QDomNode node = item->doc.namedItem("dmodule").parentNode(); //namedItem("dmodule").parentNode(); //namedItem("#document")
if(node.isNull()) {
//if(debugTrace)
qDebug() << " node is NULL: item->doc.namedItem(dmodule).parentNode()";
if(debugTrace) qDebug() << " " << itemIndex << item->fileName << item->doc.namedItem("dmodule").nodeName() << item->doc.namedItem("dmodule").childNodes().count();
if(debugTrace)
for(int i=0;i<item->doc.childNodes().count();i++) {
qDebug() << " " << item->doc.childNodes().at(i).nodeName() << item->doc.childNodes().at(i).childNodes().count();
for(int j=0;j<item->doc.childNodes().at(i).childNodes().count();j++) {
qDebug() << " " << item->doc.childNodes().at(i).childNodes().at(j).nodeName() << item->doc.childNodes().at(i).childNodes().at(j).childNodes().count();
for(int k=0;k<item->doc.childNodes().at(i).childNodes().at(j).childNodes().count();k++)
qDebug() << " " << item->doc.childNodes().at(i).childNodes().at(j).childNodes().at(k).nodeName() << item->doc.childNodes().at(i).childNodes().at(j).childNodes().at(k).childNodes().count();
}
}
QDomNode nullNode;
return nullNode;
}
int pos;
if(debugTrace) qDebug() << " ------------------------- ";
while(list.count() > 0) {
if(debugTrace) {
qDebug() << " node: "+node.nodeName()+" child cnt: "+QString::number(node.childNodes().count());
for(int i=0;i<node.childNodes().count();i++)
qDebug() << " "+node.childNodes().at(i).nodeName();
}
QString name = list.takeFirst();
int b = name.indexOf("[");
QString _name = name.mid(0, b);
if(b == -1)
node = node.namedItem(name);
else {
pos = name.mid(b+1, name.indexOf("]")-(b+1)).toInt();
int cnt=0;
bool found = false;
for(int i=0;i<node.childNodes().count();i++) {
if(node.childNodes().at(i).nodeName() == _name)
cnt++;
if(cnt == pos) {
node = node.childNodes().at(i);
found = true;
break;
}
}
if(!found) {
qDebug() << "getNodeFromXPath: node "+_name+" at pos "+name.mid(b+1, name.indexOf("]")-(b+1))+" NOT FOUND ("+path+")";
//for(int i=0;i<node.childNodes().count();i++)
// qDebug() << " "+node.childNodes().at(i).nodeName();
QDomNode nullNode;
return nullNode;
}
}
if(debugTrace) qDebug() << " need: "+name+" found: "+node.nodeName();
}
if(debugTrace) qDebug() << "--Result node: "+node.nodeName();
//if(!node.nodeName().startsWith("blankRefNode"))
// qDebug() << "Rename "+node.nodeName()+" to REF ("+path+")";
return node;
}
/*

View File

@@ -32,11 +32,6 @@ public:
//static bool validateXML(const QString &xsdschema, const QString &xmlschema);
QDomNode findElementRec(QDomNode domNode, QString path);
QDomNode findElement(QString path);
//void searchPrepare();
//QDomNode searchNodeWithTag(QString tag); //QDomNode startNode,
//QDomNode searchNodeWithAttr(QString attrName, QString attrVal); //QDomNode startNode,
QString makeNodeXPath(QDomNode node);
QDomNode getNodeFromXPath(QString path, bool debugTrace=false);
QString getNodeText(QString path);
void setNodeText(QString path, QString text);
void deleteNode(QString path);
@@ -50,7 +45,6 @@ public:
int getNodePathIndex(QString name);
QString dmIdentString(QString dmIdentPath);
QString pmIdentString(QString pmIdentPath);
QString dmCodeIdentString(QDomNode node);
void setCurItem(int ind);
void clearItems();
@@ -84,10 +78,6 @@ public:
int bugCnt=0;
RU_Const ru_const;
//struct searchListStruct {
// QString name;
// QDomNode node;
//};
struct ItemStruct { // Основная структура хранения данных
QString fileName, S1000D_fileName, SCORM_fileName;