-
Notifications
You must be signed in to change notification settings - Fork 14
/
api.js
721 lines (619 loc) · 21.5 KB
/
api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
/*
* (c) Copyright Ascensio System SIA 2010-2024
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
var AscOForm = {};
window["AscOForm"] = window.AscOForm = AscOForm;
(function(window, document) {
window['Asc']['Addons'] = window['Asc']['Addons'] || {};
window['Asc']['Addons']['forms'] = true; // register addon
window['Asc']['asc_docs_api'].prototype['asc_AddContentControlCheckBox'] = window['Asc']['asc_docs_api'].prototype.asc_AddContentControlCheckBox = function(oPr, oFormPr, oCommonPr)
{
var oLogicDocument = this.private_GetLogicDocument();
if (!oLogicDocument)
return;
CheckCurrentSelection(oLogicDocument);
if (oPr && oFormPr)
{
if (oPr.GroupKey)
{
oPr.CheckedSymbol = 0x25C9;
oPr.UncheckedSymbol = 0x25CB;
}
else
{
oPr.CheckedSymbol = 0x2611;
oPr.UncheckedSymbol = 0x2610;
}
oPr.CheckedFont = "Segoe UI Symbol";
oPr.UncheckedFont = "Segoe UI Symbol";
}
var nCheckedSymbol = oPr && oPr.CheckedSymbol ? oPr.CheckedSymbol : Asc.c_oAscSdtCheckBoxDefaults.CheckedSymbol;
var nUncheckedSymbol = oPr && oPr.UncheckedSymbol ? oPr.UncheckedSymbol : Asc.c_oAscSdtCheckBoxDefaults.UncheckedSymbol;
var sCheckedFont = oPr && oPr.CheckedFont ? oPr.CheckedFont : Asc.c_oAscSdtCheckBoxDefaults.CheckedFont;
var sUncheckedFont = oPr && oPr.UncheckedFont ? oPr && oPr.UncheckedFont : Asc.c_oAscSdtCheckBoxDefaults.UncheckedFont;
var isLoadFonts = false;
if (!AscCommon.IsAscFontSupport(sCheckedFont, nCheckedSymbol))
{
isLoadFonts = true;
AscFonts.FontPickerByCharacter.getFontBySymbol(nCheckedSymbol);
}
if (!AscCommon.IsAscFontSupport(sUncheckedFont, nUncheckedSymbol))
{
isLoadFonts = true;
AscFonts.FontPickerByCharacter.getFontBySymbol(nUncheckedSymbol);
}
function private_ApplyPrToCheckBox(oCC)
{
if (!oCC)
return;
if (oFormPr)
{
private_ApplyFormPr(oCC, oFormPr, oLogicDocument);
if (oPr && oPr.GroupKey)
private_CheckRadioButtonChoice(oCC, oLogicDocument, oPr.GroupKey);
else
private_CheckFormKey(oCC, oLogicDocument);
}
if (oCommonPr)
oCC.SetContentControlPr(oCommonPr);
}
function private_PerformAddCheckBox()
{
if (oLogicDocument.IsTextSelectionUse())
{
let arrSelectedParagraphs = oLogicDocument.GetSelectedParagraphs();
// Select entire paragraphs so that after the action all added checkboxes are included in the selection
let nSelectDirection = oLogicDocument.GetSelectDirection();
for (let nIndex = 0, nCount = arrSelectedParagraphs.length; nIndex < nCount; ++nIndex)
{
arrSelectedParagraphs[nIndex].SelectAll(nSelectDirection);
}
let oState = oLogicDocument.SaveDocumentState(false);
if (arrSelectedParagraphs.length > 0
&& !oLogicDocument.IsSelectionLocked(AscCommon.changestype_None, {
Type : AscCommon.changestype_2_ElementsArray_and_Type,
Elements : arrSelectedParagraphs,
CheckType : AscCommon.changestype_Paragraph_Content
}))
{
oLogicDocument.StartAction(AscDFH.historydescription_Document_AddContentControlCheckBox);
oLogicDocument.RemoveSelection();
for (let nIndex = 0, nCount = arrSelectedParagraphs.length; nIndex < nCount; ++nIndex)
{
let oCC = arrSelectedParagraphs[nIndex].AddCheckBoxToStartPos(oPr);
private_ApplyPrToCheckBox(oCC);
}
oLogicDocument.LoadDocumentState(oState);
oLogicDocument.UpdateInterface();
oLogicDocument.Recalculate();
oLogicDocument.FinalizeAction();
}
else
{
oLogicDocument.LoadDocumentState(oState);
}
}
else
{
oLogicDocument.RemoveTextSelection();
if (!oLogicDocument.IsSelectionLocked(AscCommon.changestype_Paragraph_Content))
{
oLogicDocument.StartAction(AscDFH.historydescription_Document_AddContentControlCheckBox);
var oCC = oLogicDocument.AddContentControlCheckBox(oPr);
private_ApplyPrToCheckBox(oCC);
oLogicDocument.UpdateInterface();
oLogicDocument.Recalculate();
oLogicDocument.FinalizeAction();
}
}
}
if (isLoadFonts)
{
var oFonts = {};
oFonts[sCheckedFont] = true;
oFonts[sUncheckedFont] = true;
AscCommon.Check_LoadingDataBeforePrepaste(this, oFonts, {}, private_PerformAddCheckBox);
}
else
{
private_PerformAddCheckBox();
}
};
window['Asc']['asc_docs_api'].prototype['asc_AddContentControlPicture'] = window['Asc']['asc_docs_api'].prototype.asc_AddContentControlPicture = function(oFormPr, oCommonPr, isSignature)
{
var oLogicDocument = this.private_GetLogicDocument();
if (!oLogicDocument)
return;
CheckCurrentSelection(oLogicDocument);
oLogicDocument.RemoveTextSelection();
if (!oLogicDocument.IsSelectionLocked(AscCommon.changestype_Paragraph_Content))
{
oLogicDocument.StartAction(AscDFH.historydescription_Document_AddContentControlPicture);
// 150x32pt for Signature
let w = isSignature ? 150 / 72 * 25.4 : undefined;
let h = isSignature ? 32 / 72 * 25.4 : undefined;
var oCC = oLogicDocument.AddContentControlPicture(w, h);
let oFormParaDrawing = null;
if (oCC && oFormPr)
{
oCC.SetFormPr(oFormPr);
oCC.UpdatePlaceHolderTextPrForForm();
let pictPr = new AscCommon.CSdtPictureFormPr();
if (isSignature)
{
pictPr.SetSignature(true);
let glossary = oLogicDocument.GetGlossaryDocument();
if (glossary)
oCC.SetPlaceholder(glossary.GetDefaultPlaceholderSignatureOformDocPartId());
}
oCC.SetPictureFormPr(pictPr);
private_CheckFormKey(oCC, oLogicDocument);
oLogicDocument.Recalculate(true);
oFormParaDrawing = oCC.ConvertFormToFixed();
var aDrawings = oCC.GetAllDrawingObjects();
for(var nDrawing = 0; nDrawing < aDrawings.length; ++nDrawing)
{
var oDrawing = aDrawings[nDrawing];
var oGraphic = oDrawing.GraphicObj;
if(oGraphic && oGraphic.getObjectType() === AscDFH.historyitem_type_ImageShape)
{
var oSpPr = oGraphic.spPr;
if(oSpPr)
{
if(oSpPr.Fill)
{
oSpPr.setFill(null);
}
if(oSpPr.ln)
{
oSpPr.setLn(null);
}
if(oSpPr.geometry)
{
oSpPr.setGeometry(null);
}
var oXfrm = oSpPr.xfrm;
if(oXfrm)
{
if(!AscFormat.fApproxEqual(oXfrm.rot, 0.0))
{
oXfrm.setRot(0);
}
if(oXfrm.flipH)
{
oXfrm.setFlipH(false);
}
if(oXfrm.flipH)
{
oXfrm.setFlipH(false);
}
if(oXfrm.flipV)
{
oXfrm.setFlipV(false);
}
}
}
}
}
if (!oCC.IsPlaceHolder())
{
oLogicDocument.Recalculate(true);
oCC.UpdatePictureFormLayout();
}
else
{
oCC.ReplaceContentWithPlaceHolder();
oCC.ApplyPicturePr(true);
}
}
if (oCC && oCommonPr)
oCC.SetContentControlPr(oCommonPr);
oLogicDocument.UpdateInterface();
oLogicDocument.Recalculate();
if(oFormParaDrawing)
{
let oFormShape = oFormParaDrawing.GraphicObj;
if(oFormShape)
{
oFormShape.Set_CurrentElement(true, null, true);
}
}
oLogicDocument.FinalizeAction();
}
};
window['Asc']['asc_docs_api'].prototype['asc_AddContentControlSignature'] = window['Asc']['asc_docs_api'].prototype.asc_AddContentControlSignature = function(oFormPr, oCommonPr)
{
return this.asc_AddContentControlPicture(oFormPr, oCommonPr, true);
};
window['Asc']['asc_docs_api'].prototype['asc_AddContentControlList'] = window['Asc']['asc_docs_api'].prototype.asc_AddContentControlList = function(isComboBox, oPr, oFormPr, oCommonPr)
{
var oLogicDocument = this.private_GetLogicDocument();
if (!oLogicDocument)
return;
CheckCurrentSelection(oLogicDocument);
oLogicDocument.RemoveTextSelection();
if (!oLogicDocument.IsSelectionLocked(AscCommon.changestype_Paragraph_Content))
{
oLogicDocument.StartAction(AscDFH.historydescription_Document_AddContentControlList);
var oCC;
if (isComboBox)
oCC = oLogicDocument.AddContentControlComboBox(oPr);
else
oCC = oLogicDocument.AddContentControlDropDownList(oPr);
if (oCC && oFormPr)
{
private_ApplyFormPr(oCC, oFormPr, oLogicDocument);
oCC.UpdatePlaceHolderTextPrForForm();
private_CheckFormKey(oCC, oLogicDocument);
}
if (oCC && oCommonPr)
oCC.SetContentControlPr(oCommonPr);
oLogicDocument.Recalculate();
oLogicDocument.UpdateInterface();
oLogicDocument.UpdateSelection();
oLogicDocument.FinalizeAction();
}
};
window['Asc']['asc_docs_api'].prototype['asc_AddContentControlDatePicker'] = window['Asc']['asc_docs_api'].prototype.asc_AddContentControlDatePicker = function(oPr, oCommonPr)
{
var oLogicDocument = this.private_GetLogicDocument();
if (!oLogicDocument)
return;
CheckCurrentSelection(oLogicDocument);
oLogicDocument.RemoveTextSelection();
if (!oLogicDocument.IsSelectionLocked(AscCommon.changestype_Paragraph_Content))
{
oLogicDocument.StartAction(AscDFH.historydescription_Document_AddContentControlList);
let dateTimePr = null;
let formPr = null;
let ccPr = null;
// Пока для совместимости со старым форматом оставляем, чтобы настройки могли приходить по старому (oPr, oCommonPr)
// но в будущем надо перейти на новый вариант contentPr (AscCommon.CContentControlPr)
if (oPr && (oPr instanceof AscCommon.CContentControlPr))
{
dateTimePr = oPr.DateTimePr;
ccPr = oPr;
formPr = oPr.FormPr;
}
else if (oPr && (oPr instanceof AscWord.CSdtDatePickerPr))
{
dateTimePr = oPr;
ccPr = oCommonPr ? oCommonPr : null;
}
var oCC = oLogicDocument.AddContentControlDatePicker(dateTimePr);
if (oCC && ccPr)
oCC.SetContentControlPr(ccPr);
if (oCC && formPr)
{
private_ApplyFormPr(oCC, formPr, oLogicDocument);
private_CheckFormKey(oCC, oLogicDocument);
}
oLogicDocument.Recalculate();
oLogicDocument.UpdateInterface();
oLogicDocument.UpdateSelection();
oLogicDocument.FinalizeAction();
}
};
window['Asc']['asc_docs_api'].prototype['asc_AddContentControlTextForm'] = window['Asc']['asc_docs_api'].prototype.asc_AddContentControlTextForm = function(contentControlPr)
{
var oLogicDocument = this.private_GetLogicDocument();
if (!oLogicDocument)
return;
CheckCurrentSelection(oLogicDocument);
let textFormPr = contentControlPr ? contentControlPr.TextFormPr : null;
let formPr = contentControlPr ? contentControlPr.FormPr : null;
let placeholderText = contentControlPr ? contentControlPr.PlaceholderText : "";
if (!oLogicDocument.IsSelectionLocked(AscCommon.changestype_Paragraph_Content))
{
oLogicDocument.StartAction(AscDFH.historydescription_Document_AddContentControlTextForm);
var oCC = oLogicDocument.AddContentControlTextForm(textFormPr);
if (oCC)
{
if (placeholderText)
oCC.SetPlaceholderText(placeholderText);
if (formPr)
{
private_ApplyFormPr(oCC, formPr, oLogicDocument);
oCC.UpdatePlaceHolderTextPrForForm();
private_CheckFormKey(oCC, oLogicDocument);
}
}
oLogicDocument.UpdateInterface();
oLogicDocument.Recalculate();
oLogicDocument.FinalizeAction();
}
};
window['Asc']['asc_docs_api'].prototype['asc_AddComplexForm'] = window['Asc']['asc_docs_api'].prototype.asc_AddComplexForm = function(json, formPr)
{
let logicDocument = this.private_GetLogicDocument();
if (!logicDocument)
return;
CheckCurrentSelection(logicDocument, true);
function AddComplexForm()
{
if (!logicDocument.IsSelectionLocked(AscCommon.changestype_Paragraph_Content))
{
logicDocument.StartAction(AscDFH.historydescription_Document_AddComplexForm);
let complexForm = logicDocument.AddComplexForm(new AscWord.CSdtComplexFormPr(), formPr);
private_CheckFormKey(complexForm, logicDocument);
if (json)
AscWord.JsonToForm(json, complexForm);
logicDocument.UpdateInterface();
logicDocument.Recalculate();
logicDocument.FinalizeAction();
}
}
if (json)
{
AscFonts.FontPickerByCharacter.checkText(AscWord.GetUnicodesFromJsonToForm(), this, function() {
AddComplexForm();
}, true);
}
else
{
AddComplexForm();
}
};
window['Asc']['asc_docs_api'].prototype['asc_GetCurrentComplexForm'] = window['Asc']['asc_docs_api'].prototype.asc_GetCurrentComplexForm = function()
{
let logicDocument = this.private_GetLogicDocument();
if (!logicDocument)
return null;
let form = logicDocument.GetContentControl();
if (!form || !form.IsForm())
return null;
let mainForm = form.GetMainForm();
return (mainForm.IsComplexForm() ? mainForm : null);
};
window['Asc']['asc_docs_api'].prototype['asc_ConvertFormToJson'] = window['Asc']['asc_docs_api'].prototype.asc_ConvertFormToJson = function(form)
{
let logicDocument = this.private_GetLogicDocument();
if (!logicDocument)
return null;
if (typeof (form) === "string")
form = AscCommon.g_oTableId.Get_ById(form);
if (!form || !(form instanceof AscWord.CInlineLevelSdt) || !form.IsForm())
return null;
return AscWord.FormToJson(form);
};
window['Asc']['asc_docs_api'].prototype['asc_SetFormValue'] = window['Asc']['asc_docs_api'].prototype.asc_SetFormValue = function(value, formId)
{
let logicDocument = this.private_GetLogicDocument();
if (!logicDocument)
return;
let form = logicDocument.GetContentControl(formId);
if (!form || !form.IsForm())
return;
return this.private_SetFormValue(form.GetId(), value);
};
window['Asc']['asc_docs_api'].prototype['asc_GetFormValue'] = window['Asc']['asc_docs_api'].prototype.asc_GetFormValue = function(formId)
{
let logicDocument = this.private_GetLogicDocument();
if (!logicDocument)
return "";
let form = logicDocument.GetContentControl(formId);
if (!form || !form.IsForm())
return "";
if (form.IsPictureForm())
return "";
else if (form.IsCheckBox())
return form.IsCheckBoxChecked();
else if (form.IsPlaceHolder())
return "";
return form.GetInnerText();
};
window['Asc']['asc_docs_api'].prototype.private_SetFormValue = function(internalId, value)
{
let oLogicDocument = this.private_GetLogicDocument();
if (!AscCommon.g_oTableId
|| !oLogicDocument
|| !oLogicDocument.IsDocumentEditor())
return;
let oForm = AscCommon.g_oTableId.GetClass(internalId);
if (!oForm
|| !(oForm instanceof AscWord.CInlineLevelSdt)
|| !oForm.IsForm())
return;
// При проверке лока внутри параграфа мы ориентируемся на выделение внутри этого параграфа
// поэтому нужно выделить форму
let state = oLogicDocument.SaveDocumentState();
oForm.SelectContentControl();
let oParagraph = oForm.GetParagraph();
oForm.SkipFillingFormModeCheck(true);
oForm.SkipSpecialContentControlLock(true);
if (!oParagraph
|| oLogicDocument.IsSelectionLocked(AscCommon.changestype_None, {
Type : AscCommon.changestype_2_ElementsArray_and_Type,
Elements : [oParagraph],
CheckType : AscCommon.changestype_Paragraph_Content
}, true, oLogicDocument.IsFillingFormMode()))
{
oLogicDocument.LoadDocumentState(state);
oForm.SkipFillingFormModeCheck(false);
oForm.SkipSpecialContentControlLock(false);
return;
}
oLogicDocument.LoadDocumentState(state);
oForm.SkipFillingFormModeCheck(false);
oForm.SkipSpecialContentControlLock(false);
oLogicDocument.StartAction(AscDFH.historydescription_Document_FillFormInPlugin);
let isClear = false;
if (null === value)
{
isClear = true;
}
else if (oForm.IsTextForm() || oForm.IsComboBox())
{
let sValue = AscBuilder.GetStringParameter(value, "");
if (!sValue)
isClear = true;
else
oForm.SetInnerText(sValue);
}
else if (oForm.IsDropDownList())
{
let sValue = AscBuilder.GetStringParameter(value, "");
let oPr = oForm.GetDropDownListPr();
let nIndex = oPr.FindByText(sValue);
if (-1 !== nIndex)
oForm.SelectListItem(oPr.GetItemValue(nIndex));
else
isClear = true;
}
else if (oForm.IsCheckBox())
{
let isChecked = value === "true" ? true : value === "false" ? false : AscBuilder.GetBoolParameter(value, null);
if (null !== isChecked)
oForm.SetCheckBoxChecked(isChecked);
else
isClear = true;
}
else if (oForm.IsPictureForm())
{
let sValue = AscBuilder.GetStringParameter(value, "");
if (!sValue)
return;
let oImg;
let allDrawings = oForm.GetAllDrawingObjects();
for (let nDrawing = 0; nDrawing < allDrawings.length; ++nDrawing)
{
if (allDrawings[nDrawing].IsPicture())
{
oImg = allDrawings[nDrawing].GraphicObj;
break;
}
}
if (oImg)
{
oForm.SetShowingPlcHdr(false);
oImg.setBlipFill(AscFormat.CreateBlipFillRasterImageId(sValue));
}
else
{
isClear = true;
}
}
else if (oForm.IsDatePicker())
{
let sValue = AscBuilder.GetStringParameter(value, "");
if (!sValue)
isClear = true;
else
oForm.SetInnerText(sValue);
// TODO: Надо FullDate попытаться выставить по заданному значение. Сейчас мы всегда сбрасываем на текущую дату
let datePickerPr = oForm.GetDatePickerPr().Copy();
datePickerPr.SetFullDate(null);
oForm.SetDatePickerPr(datePickerPr);
}
if (isClear)
oForm.ClearContentControlExt();
oLogicDocument.OnChangeForm(oForm);
oLogicDocument.Recalculate();
oLogicDocument.UpdateTracks();
oLogicDocument.UpdateInterface();
oLogicDocument.FinalizeAction();
};
function private_CheckFormKey(form, logicDocument)
{
if (!form || !form.IsForm() || !logicDocument)
return;
let key = form.GetFormKey();
if (key && "" !== key.trim())
return;
let formManager = logicDocument.GetFormsManager();
let keyGenerator = formManager.GetKeyGenerator();
let formPr = form.GetFormPr().Copy();
if (!formPr)
return;
key = keyGenerator.GetNewKey(form);
formPr.SetKey(key);
form.SetFormPr(formPr);
}
function private_CheckRadioButtonChoice(form, logicDocument, groupKey)
{
if (!form || !form.IsForm() || !logicDocument)
return;
let choice = form.GetFormKey();
if (choice && "" !== choice.trim())
return;
let formManager = logicDocument.GetFormsManager();
let keyGenerator = formManager.GetKeyGenerator();
let formPr = form.GetFormPr().Copy();
if (!formPr)
return;
choice = keyGenerator.GetNewChoiceByGroupKey(groupKey);
formPr.SetKey(choice);
form.SetFormPr(formPr);
}
function private_ApplyFormPr(form, formPr, logicDocument)
{
if (!form || !formPr)
return;
form.SetFormPr(formPr.Copy());
let docPartId = form.GetPlaceholder();
let glossary = logicDocument.GetGlossaryDocument();
if ((form.IsTextForm()
|| form.IsDropDownList()
|| form.IsComboBox()
|| form.IsDatePicker())
&&
(docPartId === glossary.GetDefaultPlaceholderTextDocPartId()
|| docPartId === glossary.GetDefaultPlaceholderListDocPartId()
|| docPartId === glossary.GetDefaultPlaceholderDateTimeDocPartId()))
{
if (docPartId === glossary.GetDefaultPlaceholderTextDocPartId())
form.SetPlaceholder(glossary.GetDefaultPlaceholderTextOformDocPartId());
else if (docPartId === glossary.GetDefaultPlaceholderListDocPartId())
form.SetPlaceholder(glossary.GetDefaultPlaceholderListOformDocPartId());
else if (docPartId === glossary.GetDefaultPlaceholderDateTimeDocPartId())
form.SetPlaceholder(glossary.GetDefaultPlaceholderDateTimeOformDocPartId());
if (form.IsPlaceHolder())
form.private_FillPlaceholderContent();
}
let paragraph = form.GetParagraph();
if (form.IsMainForm() && formPr.GetFixed() && (!paragraph || !paragraph.GetParentShape()))
{
logicDocument.Recalculate(true);
let drawing = form.ConvertFormToFixed();
if (drawing)
drawing.SelectAsDrawing();
}
}
function CheckCurrentSelection(logicDocument, isComplex)
{
let form = logicDocument.GetContentControl();
if (!form || !form.IsForm() || (form.IsComplexForm() && !isComplex))
return;
if (isComplex)
form = form.GetMainForm();
form.MoveCursorOutsideForm(false);
}
})(window, window.document);