[PDF] Insert charts, ole objects

This commit is contained in:
Julia Radzhabova
2024-03-20 20:28:17 +03:00
parent 54943b30f7
commit b4c4c80cbc
6 changed files with 98 additions and 2 deletions

View File

@ -159,6 +159,8 @@ require([
'Common.Controllers.Comments',
'Common.Controllers.Draw',
'Common.Controllers.Plugins',
'Common.Controllers.ExternalDiagramEditor',
'Common.Controllers.ExternalOleEditor',
'Common.Controllers.Protection'
]
});
@ -190,6 +192,8 @@ require([
'common/main/lib/controller/Chat',
/** coauthoring end **/
'common/main/lib/controller/Plugins',
'common/main/lib/controller/ExternalDiagramEditor',
'common/main/lib/controller/ExternalOleEditor',
'common/main/lib/controller/Draw',
'common/main/lib/controller/Protection'
], function() {

View File

@ -218,6 +218,52 @@ define([
view.menuPDFFormsCut.on('click', _.bind(me.onCutCopyPaste, me));
view.menuPDFFormsCopy.on('click', _.bind(me.onCutCopyPaste, me));
view.menuPDFFormsPaste.on('click', _.bind(me.onCutCopyPaste, me));
} else if (type==='edit') {
var diagramEditor = this.getApplication().getController('Common.Controllers.ExternalDiagramEditor').getView('Common.Views.ExternalDiagramEditor');
if (diagramEditor) {
diagramEditor.on('internalmessage', _.bind(function(cmp, message) {
var command = message.data.command;
var data = message.data.data;
if (this.api) {
( diagramEditor.isEditMode() )
? this.api.asc_editChartDrawingObject(data)
: this.api.asc_addChartDrawingObject(data, diagramEditor.getPlaceholder());
}
}, this));
diagramEditor.on('hide', _.bind(function(cmp, message) {
if (this.api) {
this.api.asc_onCloseChartFrame();
this.api.asc_enableKeyEvents(true);
}
var me = this;
setTimeout(function(){
me.editComplete();
}, 10);
}, this));
}
var oleEditor = this.getApplication().getController('Common.Controllers.ExternalOleEditor').getView('Common.Views.ExternalOleEditor');
if (oleEditor) {
oleEditor.on('internalmessage', _.bind(function(cmp, message) {
var command = message.data.command;
var data = message.data.data;
if (this.api) {
oleEditor.isEditMode()
? this.api.asc_editTableOleObject(data)
: this.api.asc_addTableOleObject(data);
}
}, this));
oleEditor.on('hide', _.bind(function(cmp, message) {
if (this.api) {
this.api.asc_enableKeyEvents(true);
this.api.asc_onCloseChartFrame();
}
var me = this;
setTimeout(function(){
me.editComplete();
}, 10);
}, this));
}
}
},
@ -274,6 +320,20 @@ define([
return {menu_to_show: documentHolder.viewPDFModeMenu, menu_props: {}};
},
fillPDFEditMenuProps: function(selectedElements) {
// if (!selectedElements || !_.isArray(selectedElements)) return;
var documentHolder = this.documentHolder;
if (!documentHolder.editPDFModeMenu)
documentHolder.createDelayedElementsPDFEditor();
return {menu_to_show: documentHolder.editPDFModeMenu, menu_props: {}};
},
applyEditorMode: function() {
if (this.mode && this.mode.isPDFEdit && !this.documentHolder.editPDFModeMenu)
this.documentHolder.createDelayedElementsPDFEditor();
},
fillFormsMenuProps: function(selectedElements) {
if (!selectedElements || !_.isArray(selectedElements)) return;
@ -314,7 +374,7 @@ define([
showObjectMenu: function(event, docElement, eOpts){
var me = this;
if (me.api){
var obj = me.mode && me.mode.isRestrictedEdit ? (event.get_Type() == 0 ? me.fillFormsMenuProps(me.api.getSelectedElements()) : null) : me.fillViewMenuProps();
var obj = me.mode && me.mode.isRestrictedEdit ? (event.get_Type() == 0 ? me.fillFormsMenuProps(me.api.getSelectedElements()) : null) : (me.mode && me.mode.isPDFEdit ? me.fillPDFEditMenuProps(me.api.getSelectedElements()) : me.fillViewMenuProps());
if (obj) me.showPopupMenu(obj.menu_to_show, obj.menu_props, event, docElement, eOpts);
}
},
@ -337,7 +397,7 @@ define([
var me = this,
currentMenu = me.documentHolder.currentMenu;
if (currentMenu && currentMenu.isVisible()){
var obj = me.mode && me.mode.isRestrictedEdit ? me.fillFormsMenuProps(selectedElements) : me.fillViewMenuProps(selectedElements);
var obj = me.mode && me.mode.isRestrictedEdit ? me.fillFormsMenuProps(selectedElements) : (me.mode && me.mode.isPDFEdit ? me.fillPDFEditMenuProps(selectedElements) : me.fillViewMenuProps(selectedElements));
if (obj) {
if (obj.menu_to_show===currentMenu) {
currentMenu.options.initMenu(obj.menu_props);

View File

@ -156,6 +156,10 @@ define([
if (this.mode && this.mode.isPDFEdit) {
var shapes = this.api.asc_getPropertyEditorShapes();
shapes && this.fillAutoShapes(shapes[0], shapes[1]);
this.getApplication().getController('Common.Controllers.ExternalDiagramEditor').setApi(this.api).loadConfig({config:this.mode, customization: this.mode.customization});
this.getApplication().getController('Common.Controllers.ExternalOleEditor').setApi(this.api).loadConfig({config:this.mode, customization: this.mode.customization});
Common.Utils.lockControls(Common.enumLock.disableOnStart, false, {array: this.view.lockedControls});
}
},

View File

@ -1049,6 +1049,7 @@ define([
var timer_sl = setTimeout(function(){
toolbarController.createDelayedElements();
toolbarController.activateControls();
documentHolderController.applyEditorMode();
if (me.needToUpdateVersion)
toolbarController.onApiCoAuthoringDisconnect();
toolbarController.onApiFocusObject([]);
@ -1418,6 +1419,7 @@ define([
this.onPdfModeApply();
this.getApplication().getController('Toolbar').applyMode();
this.getApplication().getController('Viewport').applyEditorMode();
this.getApplication().getController('DocumentHolder').applyEditorMode();
},

View File

@ -125,6 +125,28 @@ define([
this.fireEvent('createdelayedelements', [this, 'pdf']);
},
createDelayedElementsPDFEditor: function() {
var me = this;
this.editPDFModeMenu = new Common.UI.Menu({
cls: 'shifted-right',
initMenu: function (value) {
},
items: [
]
}).on('hide:after', function (menu, e, isFromInputControl) {
me.clearCustomItems(menu);
me.currentMenu = null;
if (me.suppressEditComplete) {
me.suppressEditComplete = false;
return;
}
if (!isFromInputControl) me.fireEvent('editcomplete', me);
});
this.fireEvent('createdelayedelements', [this, 'edit']);
},
createDelayedElementsPDFForms: function() {
var me = this;

View File

@ -150,6 +150,8 @@ require([
,'Common.Controllers.Comments'
,'Common.Controllers.Draw'
,'Common.Controllers.Plugins'
,'Common.Controllers.ExternalDiagramEditor'
,'Common.Controllers.ExternalOleEditor'
,'Common.Controllers.Protection'
]
});
@ -180,6 +182,8 @@ require([
'common/main/lib/controller/Comments'
,'common/main/lib/controller/Chat'
,'common/main/lib/controller/Plugins'
,'common/main/lib/controller/ExternalDiagramEditor'
,'common/main/lib/controller/ExternalOleEditor'
,'common/main/lib/controller/Draw'
,'common/main/lib/controller/Protection'
], function() {