diff --git a/apps/pdfeditor/main/app.js b/apps/pdfeditor/main/app.js index d279289dfe..c80b67c04b 100644 --- a/apps/pdfeditor/main/app.js +++ b/apps/pdfeditor/main/app.js @@ -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() { diff --git a/apps/pdfeditor/main/app/controller/DocumentHolder.js b/apps/pdfeditor/main/app/controller/DocumentHolder.js index 9f30e49f5a..d090e1c9ce 100644 --- a/apps/pdfeditor/main/app/controller/DocumentHolder.js +++ b/apps/pdfeditor/main/app/controller/DocumentHolder.js @@ -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); diff --git a/apps/pdfeditor/main/app/controller/InsTab.js b/apps/pdfeditor/main/app/controller/InsTab.js index 925250252e..b3b41a4d02 100644 --- a/apps/pdfeditor/main/app/controller/InsTab.js +++ b/apps/pdfeditor/main/app/controller/InsTab.js @@ -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}); } }, diff --git a/apps/pdfeditor/main/app/controller/Main.js b/apps/pdfeditor/main/app/controller/Main.js index df65cfce4c..f1178f2876 100644 --- a/apps/pdfeditor/main/app/controller/Main.js +++ b/apps/pdfeditor/main/app/controller/Main.js @@ -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(); }, diff --git a/apps/pdfeditor/main/app/view/DocumentHolder.js b/apps/pdfeditor/main/app/view/DocumentHolder.js index 9730772dc1..c7df3c49d2 100644 --- a/apps/pdfeditor/main/app/view/DocumentHolder.js +++ b/apps/pdfeditor/main/app/view/DocumentHolder.js @@ -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; diff --git a/apps/pdfeditor/main/app_dev.js b/apps/pdfeditor/main/app_dev.js index 2c6ab26d81..c1fbf34c11 100644 --- a/apps/pdfeditor/main/app_dev.js +++ b/apps/pdfeditor/main/app_dev.js @@ -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() {