Initial commit
This commit is contained in:
@@ -0,0 +1,791 @@
|
||||
<template>
|
||||
<div>
|
||||
<a-button-group style="margin-bottom: 10px">
|
||||
<a-button @click="handleInsertName">表题</a-button>
|
||||
<a-button @click="handleInsertTableClick(1)">插入表格</a-button>
|
||||
<a-button @click="handleInsertNoteFou">表格脚注</a-button>
|
||||
</a-button-group>
|
||||
<a-button-group style="margin-bottom: 10px">
|
||||
<a-button @click="handleInsertNoteThe">表格注</a-button>
|
||||
<a-button @click="handleInsertNoteOne">表格注X</a-button>
|
||||
<a-button @click="handleInsertNoteTwo">表格首注</a-button>
|
||||
</a-button-group>
|
||||
<a-modal v-model="visible" title="插入表格" @ok="handleOk">
|
||||
<a-form-model
|
||||
id="components-form-demo-validate-other"
|
||||
:model="form"
|
||||
v-bind="formItemLayout"
|
||||
@submit="handleSubmit"
|
||||
>
|
||||
<a-form-item label="行数">
|
||||
<a-input
|
||||
v-model="form.rows"
|
||||
placeholder="请输入行数"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="列数">
|
||||
<a-input
|
||||
v-model="form.column"
|
||||
placeholder="请输入列数"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form-model>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "SaicTable",
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
formItemLayout: {
|
||||
labelCol: {span: 6},
|
||||
wrapperCol: {span: 14},
|
||||
},
|
||||
loading: false,
|
||||
imageUrl: '',
|
||||
form: {
|
||||
title: '',
|
||||
size: '中'
|
||||
},
|
||||
numData: {
|
||||
1: 'A',
|
||||
2: 'B',
|
||||
3: 'C',
|
||||
4: 'D',
|
||||
5: 'E',
|
||||
6: 'F',
|
||||
7: 'G',
|
||||
8: 'H',
|
||||
9: 'I',
|
||||
10: 'J',
|
||||
11: 'K',
|
||||
12: 'L',
|
||||
13: 'M',
|
||||
14: 'N',
|
||||
15: 'O',
|
||||
16: 'P',
|
||||
17: 'Q',
|
||||
18: 'R',
|
||||
19: 'S',
|
||||
20: 'T',
|
||||
21: 'U',
|
||||
22: 'V',
|
||||
23: 'W',
|
||||
24: 'X',
|
||||
25: 'Y',
|
||||
26: 'Z'
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleSubmit() {
|
||||
this.visible = false
|
||||
},
|
||||
handleOk() {
|
||||
this.handleInsertTable(this.form)
|
||||
},
|
||||
handleInsertTableClick(){
|
||||
this.visible = true
|
||||
this.form = {
|
||||
rows:7,
|
||||
column:4,
|
||||
}
|
||||
},
|
||||
// 插入表格含题注
|
||||
handleInsertTable(data) {
|
||||
Asc.scope.rows = data.rows
|
||||
Asc.scope.column = data.column
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument();
|
||||
const oTable = Api.CreateTable(Asc.scope.column,Asc.scope.rows);
|
||||
oTable.SetWidth("percent", 100);
|
||||
oTable.SetTableLayout('fixed');
|
||||
oTable.SetTableCellMarginRight(0.2 * (1440 / 2.54));
|
||||
oTable.SetTableCellMarginTop(0.2 * (1440 / 2.54));
|
||||
oTable.SetTableCellMarginLeft(0.2 * (1440 / 2.54));
|
||||
oTable.SetTableCellMarginBottom(0.2 * (1440 / 2.54));
|
||||
oTable.SetTableBorderTop("single", 9, 0, 0, 0, 0);
|
||||
oTable.SetTableBorderBottom("single", 9, 0, 0, 0, 0);
|
||||
oTable.SetTableBorderLeft("single", 9, 0, 0, 0, 0);
|
||||
oTable.SetTableBorderRight("single", 9, 0, 0, 0, 0);
|
||||
oTable.SetTableBorderInsideV("single", 6, 0, 0, 0, 0);
|
||||
oTable.SetTableBorderInsideH("single", 6, 0, 0, 0, 0);
|
||||
const oRowsCount = oTable.GetRowsCount();
|
||||
oTable.SetTableDescription("tableOp");
|
||||
oDocument.InsertContent([oTable]);
|
||||
for (let i = 0; i < oRowsCount; i++) {
|
||||
const oCellsCount = oTable.GetRow(i).GetCellsCount();
|
||||
for (let j = 0; j < oCellsCount; j++) {
|
||||
const cellEle = oTable
|
||||
.GetRow(i)
|
||||
.GetCell(j)
|
||||
.GetContent()
|
||||
.GetElement(0);
|
||||
cellEle.SetSpacingAfter(10)
|
||||
cellEle.SetFontSize(18)
|
||||
cellEle.SetColor(0, 0, 0);
|
||||
// if (i === 0) {
|
||||
// oTable
|
||||
// .GetRow(i)
|
||||
// .GetCell(j)
|
||||
// .SetCellBorderTop("single", 0, 0, 255, 255, 255);
|
||||
// oTable
|
||||
// .GetRow(i)
|
||||
// .GetCell(j)
|
||||
// .SetCellBorderRight("single", 0, 0, 255, 255, 255);
|
||||
// oTable
|
||||
// .GetRow(i)
|
||||
// .GetCell(j)
|
||||
// .SetCellBorderBottom("single", 0, 0, 255, 255, 255);
|
||||
// oTable
|
||||
// .GetRow(i)
|
||||
// .GetCell(j)
|
||||
// .SetCellBorderLeft("single", 0, 0, 255, 255, 255);
|
||||
// // cellEle.SetFontFamily("宋体");
|
||||
// } else
|
||||
// 表头
|
||||
if (i === 0) {
|
||||
oTable
|
||||
.GetRow(i)
|
||||
.GetCell(j)
|
||||
.SetCellBorderTop("single", 9, 0, 0, 0, 0);
|
||||
// oTable
|
||||
// .GetRow(i)
|
||||
// .GetCell(j)
|
||||
// .SetCellBorderRight("single", 6, 0, 0, 0, 0);
|
||||
oTable
|
||||
.GetRow(i)
|
||||
.GetCell(j)
|
||||
.SetCellBorderBottom("single", 9, 0, 0, 0, 0);
|
||||
// oTable
|
||||
// .GetRow(i)
|
||||
// .GetCell(j)
|
||||
// .SetCellBorderLeft("single", 6, 0, 0, 0, 0);
|
||||
// cellEle.SetFontFamily("宋体");
|
||||
} else if (i === oRowsCount - 2) {
|
||||
oTable
|
||||
.GetRow(i)
|
||||
.GetCell(j)
|
||||
.SetCellBorderBottom("single", 9, 0, 0, 0, 0);
|
||||
} else {
|
||||
// cellEle.SetFontFamily("宋体");
|
||||
}
|
||||
cellEle.SetFontSize(18);
|
||||
}
|
||||
}
|
||||
|
||||
// const oParagraph = oDocument.Document.GetCurrentParagraph(
|
||||
// undefined,
|
||||
// undefined,
|
||||
// { CheckDocContent: true }
|
||||
// );
|
||||
// const newParagraph = Api.CreateParagraph();
|
||||
// newParagraph.SetParagraphWx(oParagraph);
|
||||
// var oRow = oTable.GetRow(0);
|
||||
// oRow.MergeCells();
|
||||
// const oCell = oTable.GetRow(0).GetCell(0);
|
||||
// const oInlineLvlSdt = Api.CreateInlineLvlSdt();
|
||||
// oInlineLvlSdt.SetAlias("smtc.table");
|
||||
|
||||
// let oNumbering = null,
|
||||
// oNumLvl = null;
|
||||
//
|
||||
// // 获取全部控件,找到smtc.table,从而得到编号
|
||||
// const AllControl = oDocument.GetAllContentControls();
|
||||
// for (let i = 0; i < AllControl.length; i++) {
|
||||
// if (AllControl[i].GetAlias() === "smtc.table") {
|
||||
// const tableContent = AllControl[i]
|
||||
// .GetElement(0)
|
||||
// .GetParentTableCell()
|
||||
// .GetContent();
|
||||
// const count = tableContent.GetElementsCount();
|
||||
// for (let j = 0; j < count; j++) {
|
||||
// const ele = tableContent.GetElement(j);
|
||||
// if (
|
||||
// ele &&
|
||||
// ele.GetClassType() === "paragraph" &&
|
||||
// ele.GetNumbering() &&
|
||||
// ele.GetNumbering().GetLevelIndex() === 0
|
||||
// ) {
|
||||
// oNumLvl = ele.GetNumbering();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (!oNumLvl) {
|
||||
// oNumbering = oDocument.CreateNumbering("numbered");
|
||||
// oNumLvl = oNumbering.GetLevel(0);
|
||||
// const sFormatString = "表 %1 ";
|
||||
// oNumLvl.SetCustomType("decimal", sFormatString, "center");
|
||||
// }
|
||||
// var textPr = oNumLvl.GetTextPr();
|
||||
// textPr.SetFontFamily("黑体");
|
||||
// textPr.SetFontSize(21)
|
||||
// const CNParagraph = Api.CreateParagraph();
|
||||
// CNParagraph.SetJc("center");
|
||||
// CNParagraph.AddText("企业技术标准类别及代号");
|
||||
// CNParagraph.SetFontSize(21);
|
||||
// CNParagraph.SetFontFamily("黑体");
|
||||
// CNParagraph.SetSpacingAfter(0)
|
||||
// CNParagraph.AddInlineLvlSdt(oInlineLvlSdt);
|
||||
// CNParagraph.SetNumbering(oNumLvl);
|
||||
// oCell.AddElement(1, CNParagraph);
|
||||
// 获取编号文本
|
||||
// const tableNum = CNParagraph.Paragraph.GetNumberingText();
|
||||
|
||||
// const Unit = Api.CreateParagraph();
|
||||
// Unit.SetJc("right");
|
||||
// const UnitCN = Api.CreateRun();
|
||||
// UnitCN.AddText("单位为XXX");
|
||||
// UnitCN.SetFontSize(21);
|
||||
// UnitCN.SetFontFamily("SimHei");
|
||||
// Unit.AddElement(UnitCN);
|
||||
// oCell.AddElement(1, Unit);
|
||||
// oCell.AddElement(2, oTable);
|
||||
|
||||
// 表格注
|
||||
const oLastRow = oTable.GetRow(oTable.GetRowsCount() - 1);
|
||||
oLastRow.MergeCells();
|
||||
oLastRow.SetHeight("atLeast", 540);
|
||||
|
||||
// const noteNumbering = oDocument.CreateNumbering("numbered");
|
||||
// const noteNumLevel = noteNumbering.GetLevel(0);
|
||||
// const sFormatString = "注%1:";
|
||||
// noteNumLevel.SetCustomType("decimal", sFormatString, "center");
|
||||
// for (let i = 0; i < 3; i++) {
|
||||
// const noteParagraph = Api.CreateParagraph();
|
||||
// noteParagraph.SetNumbering(noteNumLevel);
|
||||
// noteParagraph.AddText("XXX");
|
||||
// noteParagraph.SetSpacingAfter(10);
|
||||
// noteParagraph.SetFontFamily('宋体')
|
||||
// noteParagraph.SetFontSize(23)
|
||||
// noteParagraph.SetColor(49, 36, 19);
|
||||
// if (i > 0) {
|
||||
// oLastRow.GetCell(0).AddElement(i * 2, noteParagraph);
|
||||
// } else {
|
||||
// oLastRow.GetCell(0).AddElement(0, noteParagraph);
|
||||
// }
|
||||
// }
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}, false);
|
||||
this.visible = false
|
||||
},
|
||||
|
||||
// 插入表格注
|
||||
handleInsertNote() {
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument();
|
||||
const newParagraph = Api.CreateParagraph();
|
||||
const oTableCell = newParagraph.GetParentTableCell();
|
||||
console.log(oTableCell);
|
||||
const elementsCount = oTableCell.GetContent().GetElementsCount();
|
||||
let noteNumLevel = null;
|
||||
for (let i = 0; i < elementsCount; i++) {
|
||||
const ele = oTableCell.GetContent().GetElement(i);
|
||||
if (
|
||||
ele &&
|
||||
ele.GetClassType() === "paragraph" &&
|
||||
ele.GetNumbering()
|
||||
) {
|
||||
noteNumLevel = ele.GetNumbering();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!noteNumLevel) {
|
||||
const noteNumbering = oDocument.CreateNumbering("numbered");
|
||||
noteNumLevel = noteNumbering.GetLevel(0);
|
||||
const sFormatString = "注%1:";
|
||||
noteNumLevel.SetCustomType("decimal", sFormatString, "center");
|
||||
}
|
||||
|
||||
// 表格中文注
|
||||
var textPr = noteNumLevel.GetTextPr();
|
||||
textPr.SetFontFamily("黑体");
|
||||
textPr.SetFontSize(18)
|
||||
const noteParagraph = Api.CreateParagraph();
|
||||
noteParagraph.SetNumbering(noteNumLevel);
|
||||
noteParagraph.AddText("XXX");
|
||||
noteParagraph.SetFontSize(18);
|
||||
noteParagraph.SetFontFamily("SimSun");
|
||||
|
||||
if (elementsCount > 0) {
|
||||
oTableCell.AddElement(elementsCount - 1, noteParagraph);
|
||||
} else {
|
||||
oTableCell.AddElement(0, noteParagraph);
|
||||
}
|
||||
|
||||
if (elementsCount > 0) {
|
||||
// oTableCell.AddElement(elementsCount, noteParagraphEN);
|
||||
} else {
|
||||
oTableCell.AddElement(1, noteParagraph);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
handleInsertNoteThe() {
|
||||
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("space");
|
||||
const oParaPr = oNumLvl.GetParaPr();
|
||||
// oParaPr.SetSpacingLine(280, "auto");
|
||||
// oParaPr.SetJc("both");
|
||||
oParaPr.SetIndFirstLine(-86);
|
||||
const textPr = oNumLvl.GetTextPr();
|
||||
textPr.SetFontFamily("黑体");
|
||||
textPr.SetFontSize(18)
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oParagraph.SetNumbering(oNumLvl)
|
||||
oParagraph.SetContextualSpacing(true)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
oParagraph.SetFontSize(18)
|
||||
oParagraph.SetIndLeft(766);
|
||||
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(9)
|
||||
}
|
||||
}
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
|
||||
handleInsertNoteOne() {
|
||||
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
|
||||
for (let index = 0; index < allElement; index++) {
|
||||
const element = oDocument.GetElement(index)
|
||||
if ("table" === element.GetClassType()) {
|
||||
for (let i = 0; i < element.GetRowsCount(); i++) {
|
||||
if (element.GetCell(i, 0).GetContent().GetElement(0)) {
|
||||
const Count = element.GetCell(i, 0).GetContent().GetElementsCount();
|
||||
if (Count > 1) {
|
||||
for (let j = 0; j < Count; j++) {
|
||||
const getNumbering = element.GetCell(i, 0).GetContent().GetElement(j).GetNumbering()
|
||||
const text = element.GetCell(i, 0).GetContent().GetElement(j).GetSpacingBefore()
|
||||
if (text == 50) {
|
||||
if (getNumbering !== null) {
|
||||
currentNumbering = getNumbering
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!numbering) {
|
||||
if (currentNumbering) {
|
||||
numbering = currentNumbering.GetNumbering().GetLevel(0)
|
||||
} else {
|
||||
let oNumbering = oDocument.CreateNumbering('numbered')
|
||||
numbering = oNumbering.GetLevel(0)
|
||||
const sFormatString = '注%1:';
|
||||
numbering.SetCustomType("decimal", sFormatString, "right");
|
||||
numbering.SetSuff("space");
|
||||
}
|
||||
}
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
// oParagraph.SetSpacingLine(400, "auto");
|
||||
const oParaPr = numbering.GetParaPr();
|
||||
// oParaPr.SetSpacingLine(280, "auto");
|
||||
// oParaPr.SetJc("both");
|
||||
oParaPr.SetIndFirstLine(-86);
|
||||
const textPr = numbering.GetTextPr();
|
||||
textPr.SetFontFamily("黑体");
|
||||
textPr.SetFontSize(18)
|
||||
oParagraph.SetNumbering(numbering)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
oParagraph.SetSpacingBefore(50)
|
||||
oParagraph.SetSpacingAfter(50)
|
||||
oParagraph.SetIndLeft(856);
|
||||
oParagraph.SetFontSize(18)
|
||||
oParagraph.SetBold(false);
|
||||
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(9)
|
||||
}
|
||||
}
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
// oNumbering = oParagraph.GetNumbering().GetNumbering()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
|
||||
handleInsertNoteTwo() {
|
||||
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('decimal', "注%1:", "right")
|
||||
oNumLvl.SetSuff("space");
|
||||
var oParaPr = oNumLvl.GetParaPr();
|
||||
// oParaPr.SetSpacingLine(280, "auto");
|
||||
// oParaPr.SetJc("both");
|
||||
oParaPr.SetIndFirstLine(-86);
|
||||
var textPr = oNumLvl.GetTextPr();
|
||||
textPr.SetFontFamily("黑体");
|
||||
textPr.SetFontSize(18)
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oParagraph.SetNumbering(oNumLvl)
|
||||
oParagraph.SetFontFamily('宋体')
|
||||
oParagraph.SetSpacingBefore(50)
|
||||
oParagraph.SetSpacingAfter(50)
|
||||
oParagraph.SetIndLeft(856);
|
||||
oParagraph.SetBold(false);
|
||||
oParagraph.SetFontSize(18)
|
||||
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(9)
|
||||
}
|
||||
}
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleInsertName(){
|
||||
Asc.scope.numData = this.numData
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let num = oParagraph.GetPosInParent()
|
||||
let oNumLvl
|
||||
let currentNumbering
|
||||
let table
|
||||
let SpacingBefore
|
||||
for (let i = num - 1; i >= 0; i--) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
table = element
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 33) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const allElement = oDocument.GetElementsCount()
|
||||
if (table){
|
||||
let number = table.GetCell(0, 0).GetContent().GetElement(1);
|
||||
SpacingBefore = number.GetSpacingBefore();
|
||||
}
|
||||
if (SpacingBefore){
|
||||
if (currentNumbering){
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
}else{
|
||||
for (let i = num + 1; i < allElement; i++) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 33) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentNumbering){
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
}else{
|
||||
let oNumbering = oDocument.CreateNumbering("numbered");
|
||||
oNumLvl = oNumbering.GetLevel(0);
|
||||
const sFormatString = "表"+Asc.scope.numData[SpacingBefore]+".%1";
|
||||
oNumLvl.SetCustomType("decimal", sFormatString, "center");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if (currentNumbering){
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
}else{
|
||||
for (let i = num + 1; i < allElement; i++) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'appendix') {
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 33) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentNumbering){
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
}else{
|
||||
let oNumbering = oDocument.CreateNumbering("numbered");
|
||||
oNumLvl = oNumbering.GetLevel(0);
|
||||
const sFormatString = "表 %1";
|
||||
oNumLvl.SetCustomType("decimal", sFormatString, "center");
|
||||
}
|
||||
}
|
||||
}
|
||||
const oNewDocumentStyle = oDocument.GetStyle("List Paragraph");
|
||||
const oTextPr3 = oNewDocumentStyle.GetTextPr();
|
||||
oTextPr3.SetFontFamily("黑体");
|
||||
const textPr = oNumLvl.GetTextPr();
|
||||
textPr.SetFontFamily("黑体");
|
||||
textPr.SetFontSize(21)
|
||||
// const CNParagraph = Api.CreateParagraph();
|
||||
oParagraph.SetJc("center");
|
||||
// oParagraph.AddText("企业技术标准类别及代号");
|
||||
oParagraph.SetFontSize(21);
|
||||
oParagraph.SetStyle(oNewDocumentStyle);
|
||||
oParagraph.SetFontFamily("黑体");
|
||||
oParagraph.SetSpacingAfter(33,false)
|
||||
oParagraph.SetNumbering(oNumLvl);
|
||||
oDocument.InsertContent([oParagraph])
|
||||
let GetNext = oParagraph.GetNext()
|
||||
GetNext.Delete()
|
||||
// oParagraph.Delete()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
handleInsertNoteFou() {
|
||||
this.ctx.callCommand(() => {
|
||||
try {
|
||||
const oDocument = Api.GetDocument()
|
||||
const oParagraph = Api.CreateParagraph()
|
||||
oDocument.InsertContent([oParagraph])
|
||||
const parentTable = oParagraph.GetParentTable()
|
||||
if (!parentTable) {
|
||||
let num = oParagraph.GetPosInParent()
|
||||
let table
|
||||
let oNumLvl
|
||||
let currentNumbering
|
||||
for (let i = num - 1; i >= 0; i--) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'tableOp') {
|
||||
table = element
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 30) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (table) {
|
||||
const oRowsCount = table.GetRowsCount();
|
||||
for (let i = 0; i < oRowsCount; i++) {
|
||||
const oCellsCount = table.GetRow(i).GetCellsCount();
|
||||
if (i == 0) {
|
||||
|
||||
} else {
|
||||
for (let j = 0; j < oCellsCount; j++) {
|
||||
const cellEle = table
|
||||
.GetRow(i)
|
||||
.GetCell(j)
|
||||
.GetContent()
|
||||
.GetElementsCount();
|
||||
for (let k = 0; k < cellEle; k++) {
|
||||
const cellEle1 = table
|
||||
.GetRow(i)
|
||||
.GetCell(j)
|
||||
.GetContent()
|
||||
.GetElement(k);
|
||||
cellEle1.SetFontSize(18)
|
||||
let GetNumbering = cellEle1.GetNumbering()
|
||||
if (GetNumbering) {
|
||||
let spacingAfter = cellEle1.GetSpacingAfter()
|
||||
if (spacingAfter == 30) {
|
||||
currentNumbering = GetNumbering;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentNumbering) {
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
} else {
|
||||
|
||||
let oNumbering = oDocument.CreateNumbering("numbered");
|
||||
oNumLvl = oNumbering.GetLevel(0);
|
||||
}
|
||||
const sFormatString = "%1";
|
||||
oNumLvl.SetCustomType("lowerLetter", sFormatString, "left");
|
||||
oNumLvl.SetSuff("space");
|
||||
const textPr = oNumLvl.GetTextPr()
|
||||
textPr.SetFontSize(18);
|
||||
textPr.SetFontFamily('黑体')
|
||||
textPr.SetSmallCaps(true);
|
||||
textPr.SetVertAlign("superscript");
|
||||
const paraPr = oNumLvl.GetParaPr()
|
||||
paraPr.SetSpacingBefore(0);
|
||||
paraPr.SetJc("left");
|
||||
paraPr.SetIndFirstLine(-150);
|
||||
const oParagraph1 = Api.CreateParagraph()
|
||||
oParagraph1.SetIndLeft(574);
|
||||
oParagraph1.SetNumbering(oNumLvl)
|
||||
oParagraph1.SetSpacingAfter(30)
|
||||
oParagraph1.SetFontSize(18)
|
||||
oDocument.InsertContent([oParagraph1])
|
||||
} else {
|
||||
const oRowsCount = parentTable.GetRowsCount();
|
||||
let oNumLvl
|
||||
let currentNumbering
|
||||
for (let i = 0; i < oRowsCount; i++) {
|
||||
const oCellsCount = parentTable.GetRow(i).GetCellsCount();
|
||||
if (i == 0) {
|
||||
|
||||
} else {
|
||||
for (let j = 0; j < oCellsCount; j++) {
|
||||
const cellEle = parentTable
|
||||
.GetRow(i)
|
||||
.GetCell(j)
|
||||
.GetContent()
|
||||
.GetElementsCount();
|
||||
for (let k = 0; k < cellEle; k++) {
|
||||
const cellEle1 = parentTable
|
||||
.GetRow(i)
|
||||
.GetCell(j)
|
||||
.GetContent()
|
||||
.GetElement(k);
|
||||
cellEle1.SetFontSize(18)
|
||||
let GetNumbering = cellEle1.GetNumbering()
|
||||
if (GetNumbering) {
|
||||
let spacingAfter = cellEle1.GetSpacingAfter()
|
||||
if (spacingAfter == 30) {
|
||||
currentNumbering = GetNumbering;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!currentNumbering) {
|
||||
let numIndex = parentTable.GetPosInParent();
|
||||
const allElement = oDocument.GetElementsCount()
|
||||
for (let i = numIndex + 1; i < allElement; i++) {
|
||||
const element = oDocument.GetElement(i)
|
||||
if ("table" === element.GetClassType()) {
|
||||
if (element.GetTableDescription() == 'tableOp') {
|
||||
break
|
||||
}
|
||||
} else if ("paragraph" === element.GetClassType()) {
|
||||
const getNumbering = element.GetNumbering()
|
||||
const text = element.GetSpacingAfter()
|
||||
if (getNumbering !== null) {
|
||||
if (text == 30) {
|
||||
currentNumbering = getNumbering
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentNumbering) {
|
||||
oNumLvl = currentNumbering.GetNumbering().GetLevel(0)
|
||||
} else {
|
||||
let oNumbering = oDocument.CreateNumbering("numbered");
|
||||
oNumLvl = oNumbering.GetLevel(0);
|
||||
|
||||
}
|
||||
const sFormatString = "%1";
|
||||
oNumLvl.SetCustomType("lowerLetter", sFormatString, "left");
|
||||
oNumLvl.SetSuff("space");
|
||||
const textPr = oNumLvl.GetTextPr()
|
||||
textPr.SetFontSize(18);
|
||||
textPr.SetFontFamily('黑体')
|
||||
textPr.SetSmallCaps(true);
|
||||
textPr.SetVertAlign("superscript");
|
||||
const paraPr = oNumLvl.GetParaPr()
|
||||
paraPr.SetSpacingBefore(0);
|
||||
paraPr.SetJc("left");
|
||||
paraPr.SetIndFirstLine(-150);
|
||||
const oParagraph1 = Api.CreateParagraph()
|
||||
oParagraph1.SetIndLeft(586);
|
||||
oParagraph1.SetNumbering(oNumLvl)
|
||||
oParagraph1.SetSpacingAfter(30)
|
||||
oParagraph1.SetFontSize(18)
|
||||
oDocument.InsertContent([oParagraph1])
|
||||
let GetNext = oParagraph1.GetNext()
|
||||
GetNext.Delete()
|
||||
}
|
||||
oParagraph.Delete();
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, false)
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user