add 在文档最后插入参考文献
This commit is contained in:
@@ -1291,9 +1291,10 @@ export default {
|
||||
this.reorderSort()
|
||||
this.equationOne()
|
||||
this.replaceData()
|
||||
this.initReferences()
|
||||
}, 500)
|
||||
},
|
||||
reorderSort(){
|
||||
reorderSort () {
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
Api.GoToFooter(1)
|
||||
@@ -1301,7 +1302,8 @@ export default {
|
||||
Api.GoToFooter(4)
|
||||
Api.asc_SetSectionStartPage(1)
|
||||
Api.ExitHeader_Footer(4)
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
}
|
||||
})
|
||||
},
|
||||
replaceData () {
|
||||
@@ -2094,6 +2096,71 @@ export default {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 初始化参考文献
|
||||
*/
|
||||
initReferences () {
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
const AllContentControls = oDocument.GetAllContentControls()
|
||||
let flag = false
|
||||
for (let i = 0; i < AllContentControls.length; i++) {
|
||||
console.log(AllContentControls[i].GetAlias())
|
||||
// 避免重复创建参考文献
|
||||
if (AllContentControls[i].GetAlias() === 'sinotruk.references') {
|
||||
flag = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
return
|
||||
}
|
||||
// 参考文献是在最后生成的,所以不需要和引言一样校验正文是否存在
|
||||
const documentCount = oDocument.GetElementsCount()
|
||||
// 获取文档最后一个段落
|
||||
const lastParagraph = oDocument.GetElement(documentCount - 1)
|
||||
// 参考文献标题文本
|
||||
const oRunTitle = Api.CreateRun()
|
||||
const oParagraphTitle = Api.CreateParagraph()
|
||||
oRunTitle.AddText('参考文献')
|
||||
const inlineLvlSdtReferences = Api.CreateInlineLvlSdt()
|
||||
inlineLvlSdtReferences.SetAlias('sinotruk.references')
|
||||
inlineLvlSdtReferences.AddElement(oRunTitle, 0)
|
||||
oParagraphTitle.AddInlineLvlSdt(inlineLvlSdtReferences)
|
||||
oParagraphTitle.SetFontSize(32)
|
||||
oParagraphTitle.SetSpacing(1.8)
|
||||
oParagraphTitle.SetSpacingBefore(949)
|
||||
oParagraphTitle.SetSpacingAfter(597)
|
||||
oParagraphTitle.SetFontFamily('黑体')
|
||||
oParagraphTitle.SetColor(0, 0, 0)
|
||||
oParagraphTitle.SetJc('center')
|
||||
oParagraphTitle.SetBold(false)
|
||||
lastParagraph.AddPageBreak()
|
||||
oDocument.Push(oParagraphTitle)
|
||||
const text = '[1] GB/T 10112-1999 术语工作 原则与方法'
|
||||
const contentParagraph = Api.CreateParagraph()
|
||||
contentParagraph.AddText(text)
|
||||
contentParagraph.SetFontSize(21)
|
||||
contentParagraph.SetFontFamily('宋体')
|
||||
contentParagraph.SetColor(0, 0, 0)
|
||||
contentParagraph.SetSpacingAfter(0)
|
||||
contentParagraph.SetBold(false)
|
||||
oDocument.Push(contentParagraph)
|
||||
// 插入终止线
|
||||
const oParagraphLine = Api.CreateParagraph()
|
||||
const oFill = Api.CreateSolidFill(Api.CreateRGBColor(0, 0, 0))
|
||||
const oStroke = Api.CreateStroke(0, Api.CreateNoFill())
|
||||
const oDrawing = Api.CreateShape('rect', 1810900, 19000, oFill, oStroke)
|
||||
oParagraphLine.SetJc('center')
|
||||
oParagraphLine.SetSpacingBefore(840)
|
||||
oParagraphLine.AddDrawing(oDrawing)
|
||||
oDocument.Push(oParagraphLine)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
created () {
|
||||
|
||||
Reference in New Issue
Block a user