Files
plugins_vue/src/pages/page1/components/FirstLevelListing.vue
T

230 lines
8.2 KiB
Vue

<template>
<div class="button-group__wrap">
<a-button-group style="margin-bottom: 10px">
<a-button @click="paragraphClick"></a-button>
<a-button @click="handleClickOne()">项一</a-button>
<a-button @click="handleClickTwo1()">项二</a-button>
<a-button @click="handleClick('space')">字母列项</a-button>
<a-button @click="handleClickTwo">数字列项</a-button>
</a-button-group>
</div>
</template>
<script>
export default {
methods: {
handleClickOne () {
window.Asc.scope.guid = window.Asc.plugin.info.guid
window.Asc.scope.suffType = ''
this.ctx.callCommand(() => {
try {
const oDocument = Api.GetDocument()
let oNumbering = oDocument.CreateNumbering('numbered')
const oNumLvl = oNumbering.GetLevel(0)
oNumLvl.SetCustomType('decimalZero', '——', 'right')
oNumLvl.SetSuff('none')
const oTextPr = oNumLvl.GetTextPr()
oTextPr.SetFontFamily('宋体')
oTextPr.SetFontSize(21)
const oParaPr = oNumLvl.GetParaPr()
oParaPr.SetSpacingLine(280, 'auto')
oParaPr.SetIndFirstLine(0)
const oParagraphTemp = Api.CreateParagraph()
oDocument.InsertContent([oParagraphTemp])
const oParagraph = Api.CreateParagraph()
oParagraph.AddText(oParagraphTemp.GetText())
oParagraphTemp.Delete()
oParagraph.SetNumbering(oNumLvl)
oParagraph.SetContextualSpacing(true)
oParagraph.SetFontFamily('宋体')
oParagraph.SetFontSize(21)
oParagraph.SetHighlight(255, 255, 0)
oParagraph.SetIndLeft(840)
oDocument.InsertContent([oParagraph])
let text = oParagraph.GetText()
if (text) {
let aSearch = oParagraph.Search(text)
if (aSearch && aSearch.length > 0) {
aSearch[0].SetFontFamily('宋体')
aSearch[0].SetFontSize(10.5)
}
}
// let GetNext = oParagraph.GetNext()
// GetNext.Delete()
} catch (error) {
console.error(error)
}
}, false)
},
paragraphClick () {
window.Asc.scope.guid = window.Asc.plugin.info.guid
window.Asc.scope.suffType = ''
this.ctx.callCommand(() => {
try {
const oDocument = Api.GetDocument()
const oParagraph = Api.CreateParagraph()
oParagraph.SetContextualSpacing(true)
oParagraph.SetFontFamily('宋体')
oParagraph.SetFontSize(21)
oParagraph.SetHighlight(255, 255, 0)
oParagraph.SetIndFirstLine(420)
oDocument.InsertContent([oParagraph])
let text = oParagraph.GetText()
if (text) {
let aSearch = oParagraph.Search(text)
if (aSearch && aSearch.length > 0) {
aSearch[0].SetFontFamily('宋体')
aSearch[0].SetFontSize(10.5)
}
}
// let GetNext = oParagraph.GetNext()
// GetNext.Delete()
} catch (error) {
console.error(error)
}
}, false)
},
handleClickTwo1 () {
window.Asc.scope.guid = window.Asc.plugin.info.guid
window.Asc.scope.suffType = ''
this.ctx.callCommand(() => {
try {
const oDocument = Api.GetDocument()
let oNumbering = oDocument.CreateNumbering('bullet')
const oNumLvl = oNumbering.GetLevel(0)
oNumLvl.SetSuff('none')
const oParagraphTemp = Api.CreateParagraph()
oDocument.InsertContent([oParagraphTemp])
const oParagraph = Api.CreateParagraph()
oParagraph.AddText(' ' + oParagraphTemp.GetText().replace(' ', ''))
oParagraphTemp.Delete()
const oParaPr = oNumLvl.GetParaPr()
oParaPr.SetSpacingLine(280, 'auto')
oParagraph.SetNumbering(oNumLvl)
oParagraph.SetContextualSpacing(true)
oParagraph.SetFontFamily('宋体')
oParagraph.SetFontSize(21)
oParagraph.SetIndLeft(1270)
oParagraph.SetHighlight(255, 255, 0)
oDocument.InsertContent([oParagraph])
let text = oParagraph.GetText()
if (text) {
let aSearch = oParagraph.Search(text)
if (aSearch && aSearch.length > 0) {
aSearch[0].SetFontFamily('宋体')
aSearch[0].SetFontSize(10.5)
}
}
// let GetNext = oParagraph.GetNext()
// GetNext.Delete()
} catch (error) {
console.error(error)
}
}, false)
},
handleClick (suffType) {
window.Asc.scope.guid = window.Asc.plugin.info.guid
window.Asc.scope.suffType = ''
this.ctx.callCommand(() => {
try {
const oDocument = Api.GetDocument()
let numbering = null
let oNumbering = oDocument.CreateNumbering('numbered')
numbering = oNumbering.GetLevel(0)
numbering.SetTemplateType('a)')
numbering.SetCustomType('lowerLetter', '%1) ', 'left')
numbering.SetSuff('none')
const oParagraphTemp = Api.CreateParagraph()
oDocument.InsertContent([oParagraphTemp])
const oParagraph = Api.CreateParagraph()
oParagraph.AddText(oParagraphTemp.GetText())
oParagraphTemp.Delete()
// oParagraph.SetSpacingLine(400, "auto");
let oTextPr = numbering.GetTextPr()
oTextPr.SetFontFamily('宋体')
var oParaPr = numbering.GetParaPr()
oParaPr.SetSpacingLine(240, 'auto')
oParaPr.SetJc('tab')
oParaPr.SetIndFirstLine(-420)
// oParaPr.SetIndFirstLine(0);
oParagraph.SetNumbering(numbering)
oParagraph.SetContextualSpacing(true)
oParagraph.SetFontFamily('宋体')
oParagraph.SetIndLeft(840)
oParagraph.SetFontSize(21)
oParagraph.SetHighlight(255, 255, 0)
oDocument.InsertContent([oParagraph])
let text = oParagraph.GetText()
if (text) {
let aSearch = oParagraph.Search(text)
if (aSearch && aSearch.length > 0) {
aSearch[0].SetFontFamily('宋体')
aSearch[0].SetFontSize(10.5)
}
}
} catch (error) {
console.error(error)
}
}, false)
},
handleClickTwo () {
window.Asc.scope.guid = window.Asc.plugin.info.guid
window.Asc.scope.suffType = ''
this.ctx.callCommand(() => {
try {
const oDocument = Api.GetDocument()
const allElement = oDocument.GetElementsCount()
let numbering = null
let currentNumbering = null
if (!numbering) {
if (currentNumbering) {
numbering = currentNumbering.GetNumbering().GetLevel(0)
} else {
let oNumbering = oDocument.CreateNumbering('numbered')
numbering = oNumbering.GetLevel(0)
numbering.SetCustomType('decimal', '%1) ', 'left')
}
}
numbering.SetSuff('none')
let oTextPr = numbering.GetTextPr()
oTextPr.SetFontFamily('宋体')
const oParaPr = numbering.GetParaPr()
// oParaPr.SetIndLeft(1310)
oParaPr.SetJc('left')
oParaPr.SetSpacingLine(240, 'auto')
oParaPr.SetIndFirstLine(-420)
const oParagraphTemp = Api.CreateParagraph()
oDocument.InsertContent([oParagraphTemp])
const oParagraph = Api.CreateParagraph()
oParagraph.AddText(oParagraphTemp.GetText())
oParagraphTemp.Delete()
oParagraph.SetNumbering(numbering)
oParagraph.SetContextualSpacing(true)
oParagraph.SetFontFamily('宋体')
oParagraph.SetFontSize(21)
oParagraph.SetIndLeft(1260)
oParagraph.SetHighlight(255, 255, 0)
oDocument.InsertContent([oParagraph])
let text = oParagraph.GetText()
if (text) {
let aSearch = oParagraph.Search(text)
if (aSearch && aSearch.length > 0) {
aSearch[0].SetFontFamily('宋体')
aSearch[0].SetFontSize(10.5)
}
}
} catch (error) {
console.error(error)
}
}, false)
}
}
}
</script>
<style>
</style>