fix 编辑目录无法正常生成问题
This commit is contained in:
@@ -1260,27 +1260,27 @@ export default {
|
|||||||
oParagraph9.SetColor(0, 0, 0)
|
oParagraph9.SetColor(0, 0, 0)
|
||||||
oDocument.InsertContent([oParagraph9])
|
oDocument.InsertContent([oParagraph9])
|
||||||
|
|
||||||
setTimeout(() => {
|
// setTimeout(() => {
|
||||||
Api.asc_UpdateTableOfContents()
|
// Api.asc_UpdateTableOfContents()
|
||||||
const allElement = oDocument.GetElementsCount()
|
// const allElement = oDocument.GetElementsCount()
|
||||||
let ContentsPr = null
|
// let ContentsPr = null
|
||||||
for (let index = 0; index < allElement; index++) {
|
// for (let index = 0; index < allElement; index++) {
|
||||||
const element = oDocument.GetElement(index)
|
// const element = oDocument.GetElement(index)
|
||||||
if ('blockLvlSdt' === element.GetClassType()) {
|
// if ('blockLvlSdt' === element.GetClassType()) {
|
||||||
if (element.GetPlaceholderText() == '在此输入文字') {
|
// if (element.GetPlaceholderText() == '在此输入文字') {
|
||||||
ContentsPr = element
|
// ContentsPr = element
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (ContentsPr) {
|
// if (ContentsPr) {
|
||||||
const list = ContentsPr.GetAllParagraphs()
|
// const list = ContentsPr.GetAllParagraphs()
|
||||||
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('宋体')
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}, 700)
|
// }, 700)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
@@ -1775,10 +1775,61 @@ export default {
|
|||||||
let that = this
|
let that = this
|
||||||
that.ctx.callCommand(() => {
|
that.ctx.callCommand(() => {
|
||||||
try {
|
try {
|
||||||
Api.asc_UpdateTableOfContents()
|
|
||||||
const oDocument = Api.GetDocument()
|
const oDocument = Api.GetDocument()
|
||||||
const allElement = oDocument.GetElementsCount()
|
const allElement = oDocument.GetElementsCount()
|
||||||
let ContentsPr = null
|
let ContentsPr = null
|
||||||
|
for (let index = 0; index < allElement; index++) {
|
||||||
|
const element = oDocument.GetElement(index)
|
||||||
|
if ('paragraph' === element.GetClassType()) {
|
||||||
|
const getNumbering = element.GetNumbering()
|
||||||
|
const text = element.GetSpacingAfter()
|
||||||
|
// 前言
|
||||||
|
if (text === 597 && (element.GetText().indexOf('前 言') !== -1 || element.GetText().indexOf('前言') !== -1)) {
|
||||||
|
let oNewDocumentStyle = oDocument.GetStyle('Heading 1')
|
||||||
|
element.SetStyle(oNewDocumentStyle)
|
||||||
|
element.SetFontSize(32)
|
||||||
|
element.SetSpacing(1.8)
|
||||||
|
element.SetSpacingBefore(549)
|
||||||
|
element.SetSpacingAfter(597)
|
||||||
|
element.SetFontFamily('黑体')
|
||||||
|
element.SetColor(0, 0, 0)
|
||||||
|
element.SetJc('center')
|
||||||
|
element.SetBold(false)
|
||||||
|
}
|
||||||
|
// 引言
|
||||||
|
if (text === 597 && (element.GetText().indexOf('引 言') !== -1 || element.GetText().indexOf('引言') !== -1)) {
|
||||||
|
let oNewDocumentStyle = oDocument.GetStyle('Heading 1')
|
||||||
|
element.SetStyle(oNewDocumentStyle)
|
||||||
|
element.SetFontSize(32)
|
||||||
|
element.SetSpacing(1.8)
|
||||||
|
element.SetSpacingBefore(549)
|
||||||
|
element.SetSpacingAfter(597)
|
||||||
|
element.SetFontFamily('黑体')
|
||||||
|
element.SetColor(0, 0, 0)
|
||||||
|
element.SetJc('center')
|
||||||
|
element.SetBold(false)
|
||||||
|
}
|
||||||
|
// 一级
|
||||||
|
if (text === 267) {
|
||||||
|
const oNewDocumentStyle = oDocument.GetStyle('Heading 1')
|
||||||
|
const oTextPr3 = oNewDocumentStyle.GetTextPr()
|
||||||
|
element.SetStyle(oNewDocumentStyle)
|
||||||
|
element.SetFontSize(21)
|
||||||
|
element.SetFontFamily(element.GetFontNames()[0])
|
||||||
|
}
|
||||||
|
// 二级
|
||||||
|
const serialNumber = element.GetText().split(' ')[0]
|
||||||
|
const serialNumberList = serialNumber.split('.')
|
||||||
|
if (text === 127 && serialNumberList.length === 2) {
|
||||||
|
const oNewDocumentStyle = oDocument.GetStyle('Heading 2')
|
||||||
|
const oTextPr3 = oNewDocumentStyle.GetTextPr()
|
||||||
|
oTextPr3.SetFontFamily('黑体')
|
||||||
|
element.SetStyle(oNewDocumentStyle)
|
||||||
|
element.SetFontFamily(element.GetFontNames()[0])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Api.asc_UpdateTableOfContents()
|
||||||
for (let index = 0; index < allElement; index++) {
|
for (let index = 0; index < allElement; index++) {
|
||||||
const element = oDocument.GetElement(index)
|
const element = oDocument.GetElement(index)
|
||||||
if ('blockLvlSdt' === element.GetClassType()) {
|
if ('blockLvlSdt' === element.GetClassType()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user