fix 目录生成有错误:附录、标题显示的层级太多。层级太多,只要两级

This commit is contained in:
赵霄
2023-09-08 10:29:10 +08:00
parent 0b135b1ac7
commit 79570c4ded
+11 -10
View File
@@ -527,7 +527,8 @@ export default {
oParagraphTwo.SetJc('center') oParagraphTwo.SetJc('center')
oParagraphTwo.SetBold(false) oParagraphTwo.SetBold(false)
oDocument.InsertContent([oParagraphTwo]) oDocument.InsertContent([oParagraphTwo])
Api.asc_AddTableOfContents() // 目录层级只留两级
oDocument.AddTableOfContents({ 'BuildFrom': { 'OutlineLvls': 2 } })
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} }
@@ -1204,7 +1205,6 @@ export default {
oParagraph5.SetColor(0, 0, 0) oParagraph5.SetColor(0, 0, 0)
oDocument.InsertContent([oParagraph5]) oDocument.InsertContent([oParagraph5])
// oParagraph6.Search("GB/T 321")[0].SetFontFamily('Times New Roman'); // oParagraph6.Search("GB/T 321")[0].SetFontFamily('Times New Roman');
// //
@@ -1791,31 +1791,32 @@ export default {
if (list && list.length > 0) { if (list && list.length > 0) {
for (let i = 0; i < list.length; i++) { for (let i = 0; i < list.length; i++) {
list[i].SetFontFamily('宋体') list[i].SetFontFamily('宋体')
if (list[i].GetText().indexOf('前 言') != -1 || list[i].GetText().indexOf('前言') != -1){ if (list[i].GetText().indexOf('前 言') !== -1 || list[i].GetText().indexOf('前言') !== -1) {
let text = list[i].GetText() let text = list[i].GetText()
text = text.replace(/\s*/g, '') text = text.replace(/\s*/g, '')
text = text.substring(0, 2) text = text.substring(0, 2)
var aSearch = list[i].Search("前 言"); var aSearch = list[i].Search('前 言')
aSearch[0].AddText('前言') aSearch[0].AddText('前言')
var aSearch1 = list[i].Search("前 言"); var aSearch1 = list[i].Search('前 言')
aSearch1[0].Delete() aSearch1[0].Delete()
} }
if (list[i].GetText().indexOf('引 言') != -1 || list[i].GetText().indexOf('引言') != -1){ if (list[i].GetText().indexOf('引 言') !== -1 || list[i].GetText().indexOf('引言') !== -1) {
let text = list[i].GetText() let text = list[i].GetText()
text = text.replace(/\s*/g, '') text = text.replace(/\s*/g, '')
text = text.substring(0, 2) text = text.substring(0, 2)
var aSearch = list[i].Search("引 言"); var aSearch = list[i].Search('引 言')
aSearch[0].AddText('引言') aSearch[0].AddText('引言')
var aSearch1 = list[i].Search("引 言"); var aSearch1 = list[i].Search('引 言')
aSearch1[0].Delete() aSearch1[0].Delete()
} }
if (list[i].GetText().indexOf('附 录') != -1 || list[i].GetText().indexOf('附录') != -1) { if (list[i].GetText().indexOf('附 录') !== -1 || list[i].GetText().indexOf('附录') !== -1) {
let text = list[i].GetText() let text = list[i].GetText()
text = text.replace(/\s*/g, '') text = text.replace(/\s*/g, '')
text = text.substring(0, 2) text = text.substring(0, 2)
oDocument.SearchAndReplace({ 'searchString': '附 录 ', 'replaceString': text }) oDocument.SearchAndReplace({ 'searchString': '附 录 ', 'replaceString': text })
list[i].SetPosition(0) list[i].SetPosition(0)
} }
// 3.1
if (list[i].GetIndLeft() == 283) { if (list[i].GetIndLeft() == 283) {
list[i].SetIndLeft(320) list[i].SetIndLeft(320)
let textOne = list[i].GetText() let textOne = list[i].GetText()
@@ -1825,7 +1826,7 @@ export default {
oDocument.SearchAndReplace({ oDocument.SearchAndReplace({
'searchString': name + ' ', 'replaceString': name 'searchString': name + ' ', 'replaceString': name
}) })
} else if (list[i].GetIndLeft() == 567) { } else if (list[i].GetIndLeft() == 567) { // 3.1.1
list[i].SetIndLeft(420) list[i].SetIndLeft(420)
} else if (list[i].GetIndLeft() == 850) { } else if (list[i].GetIndLeft() == 850) {
list[i].SetIndLeft(520) list[i].SetIndLeft(520)