diff --git a/apps/documenteditor/main/app/view/DocumentHolder.js b/apps/documenteditor/main/app/view/DocumentHolder.js index 95d5d350a..3c9fb27f2 100644 --- a/apps/documenteditor/main/app/view/DocumentHolder.js +++ b/apps/documenteditor/main/app/view/DocumentHolder.js @@ -2387,17 +2387,17 @@ define([ menuAlign: 'tl-tr', items: [ new Common.UI.MenuItem({ - caption: this.textCrop, + caption: me.textCrop, checkable: true, allowDepress: true, value : 0 }).on('click', _.bind(me.onImgCrop, me)), new Common.UI.MenuItem({ - caption: this.textCropFill, + caption: me.textCropFill, value : 1 }).on('click', _.bind(me.onImgCrop, me)), new Common.UI.MenuItem({ - caption: this.textCropFit, + caption: me.textCropFit, value : 2 }).on('click', _.bind(me.onImgCrop, me)) ] diff --git a/apps/presentationeditor/main/app/view/DocumentHolder.js b/apps/presentationeditor/main/app/view/DocumentHolder.js index ca8d9c08c..dc9986181 100644 --- a/apps/presentationeditor/main/app/view/DocumentHolder.js +++ b/apps/presentationeditor/main/app/view/DocumentHolder.js @@ -1568,6 +1568,10 @@ define([ pasteContainer.hide(); }; + var onChangeCropState = function(state) { + this.menuImgCrop.menu.items[0].setChecked(state, true); + }; + this.setApi = function(o) { me.api = o; @@ -1591,6 +1595,7 @@ define([ me.api.asc_registerCallback('asc_onSpellCheckVariantsFound', _.bind(onSpellCheckVariantsFound, me)); me.api.asc_registerCallback('asc_onShowSpecialPasteOptions', _.bind(onShowSpecialPasteOptions, me)); me.api.asc_registerCallback('asc_onHideSpecialPasteOptions', _.bind(onHideSpecialPasteOptions, me)); + me.api.asc_registerCallback('asc_ChangeCropState', _.bind(onChangeCropState, me)); } me.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(onCoAuthoringDisconnect, me)); @@ -1612,12 +1617,6 @@ define([ this.mode = {}; this.setMode = function(mode) { - if (me.api && mode.isEdit) { - me.api.asc_registerCallback('asc_onDialogAddHyperlink', _.bind(onDialogAddHyperlink, me)); - me.api.asc_registerCallback('asc_doubleClickOnChart', onDoubleClickOnChart); - me.api.asc_registerCallback('asc_onSpellCheckVariantsFound', _.bind(onSpellCheckVariantsFound, me)); - } - me.mode = mode; /** coauthoring begin **/ !(me.mode.canCoAuthoring && me.mode.canComments) @@ -2820,6 +2819,40 @@ define([ }) }); + var onImgCrop = function(item) { + if (item.value == 1) { + me.api.asc_cropFill(); + } else if (item.value == 2) { + me.api.asc_cropFit(); + } else { + item.checked ? me.api.asc_startEditCrop() : me.api.asc_endEditCrop(); + } + me.fireEvent('editcomplete', me); + }; + + me.menuImgCrop = new Common.UI.MenuItem({ + caption : me.textCrop, + menu : new Common.UI.Menu({ + menuAlign: 'tl-tr', + items: [ + new Common.UI.MenuItem({ + caption: me.textCrop, + checkable: true, + allowDepress: true, + value : 0 + }).on('click', _.bind(onImgCrop, me)), + new Common.UI.MenuItem({ + caption: me.textCropFill, + value : 1 + }).on('click', _.bind(onImgCrop, me)), + new Common.UI.MenuItem({ + caption: me.textCropFit, + value : 2 + }).on('click', _.bind(onImgCrop, me)) + ] + }) + }); + /** coauthoring begin **/ var menuAddCommentPara = new Common.UI.MenuItem({ caption : me.addCommentText @@ -3234,6 +3267,10 @@ define([ if (menuImgReplace.isVisible()) menuImgReplace.setDisabled(disabled || pluginGuid===null); + me.menuImgCrop.setVisible(me.api.asc_canEditCrop()); + if (me.menuImgCrop.isVisible()) + me.menuImgCrop.setDisabled(disabled); + menuImageAdvanced.setVisible(isimage); menuShapeAdvanced.setVisible(_.isUndefined(value.imgProps) && _.isUndefined(value.chartProps)); menuChartEdit.setVisible(_.isUndefined(value.imgProps) && !_.isUndefined(value.chartProps) && (_.isUndefined(value.shapeProps) || value.shapeProps.isChart)); @@ -3267,6 +3304,7 @@ define([ menuImgShapeAlign, menuImgShapeRotate, menuImgShapeSeparator, + me.menuImgCrop, menuImgOriginalSize, menuImgReplace, menuImageAdvanced, @@ -3534,7 +3572,10 @@ define([ textRotate90: 'Rotate 90° Clockwise', textFlipV: 'Flip Vertically', textFlipH: 'Flip Horizontally', - textRotate: 'Rotate' + textRotate: 'Rotate', + textCrop: 'Crop', + textCropFill: 'Fill', + textCropFit: 'Fit' }, PE.Views.DocumentHolder || {})); }); \ No newline at end of file diff --git a/apps/presentationeditor/main/app/view/ImageSettings.js b/apps/presentationeditor/main/app/view/ImageSettings.js index f6c3cc17b..2b5d3a479 100644 --- a/apps/presentationeditor/main/app/view/ImageSettings.js +++ b/apps/presentationeditor/main/app/view/ImageSettings.js @@ -70,7 +70,8 @@ define([ Width: 0, Height: 0, DisabledControls: false, - isOleObject: false + isOleObject: false, + cropMode: false }; this.lockedControls = []; this._locked = false; @@ -148,6 +149,7 @@ define([ split: true, enableToggle: true, allowDepress: true, + pressed: this._state.cropMode, width: 100, menu : new Common.UI.Menu({ style : 'min-width: 100px;', @@ -156,6 +158,7 @@ define([ caption: this.textCrop, checkable: true, allowDepress: true, + checked: this._state.cropMode, value: 0 }, { @@ -347,6 +350,9 @@ define([ }, _changeCropState: function(state) { + this._state.cropMode = state; + + if (!this.btnCrop) return; this.btnCrop.toggle(state, true); this.btnCrop.menu.items[0].setChecked(state, true); }, diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index 0892bb1f1..4b9e210bd 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -1110,6 +1110,9 @@ "PE.Views.DocumentHolder.txtUnderbar": "Bar under text", "PE.Views.DocumentHolder.txtUngroup": "Ungroup", "PE.Views.DocumentHolder.vertAlignText": "Vertical Alignment", + "PE.Views.DocumentHolder.textCrop": "Crop", + "PE.Views.DocumentHolder.textCropFill": "Fill", + "PE.Views.DocumentHolder.textCropFit": "Fit", "PE.Views.DocumentPreview.goToSlideText": "Go to Slide", "PE.Views.DocumentPreview.slideIndexText": "Slide {0} of {1}", "PE.Views.DocumentPreview.txtClose": "Close slideshow", diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 75e12fada..8b5684d96 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -186,6 +186,7 @@ define([ view.pmiAddNamedRange.on('click', _.bind(me.onAddNamedRange, me)); view.menuImageArrange.menu.on('item:click', _.bind(me.onImgMenu, me)); view.menuImgRotate.menu.on('item:click', _.bind(me.onImgMenu, me)); + view.menuImgCrop.menu.on('item:click', _.bind(me.onImgCrop, me)); view.menuImageAlign.menu.on('item:click', _.bind(me.onImgMenuAlign, me)); view.menuParagraphVAlign.menu.on('item:click', _.bind(me.onParagraphVAlign, me)); view.menuParagraphDirection.menu.on('item:click', _.bind(me.onParagraphDirection, me)); @@ -283,6 +284,7 @@ define([ this.api.asc_registerCallback('asc_onHideSpecialPasteOptions', _.bind(this.onHideSpecialPasteOptions, this)); this.api.asc_registerCallback('asc_onToggleAutoCorrectOptions', _.bind(this.onToggleAutoCorrectOptions, this)); this.api.asc_registerCallback('asc_onFormulaInfo', _.bind(this.onFormulaInfo, this)); + this.api.asc_registerCallback('asc_ChangeCropState', _.bind(this.onChangeCropState, this)); } return this; }, @@ -663,6 +665,19 @@ define([ } }, + onImgCrop: function(menu, item) { + if (this.api) { + if (item.value == 1) { + this.api.asc_cropFill(); + } else if (item.value == 2) { + this.api.asc_cropFit(); + } else { + item.checked ? this.api.asc_startEditCrop() : this.api.asc_endEditCrop(); + } + } + Common.NotificationCenter.trigger('edit:complete', this.documentHolder); + }, + onImgMenuAlign: function(menu, item) { if (this.api) { if (item.value>-1 && item.value < 6) { @@ -1563,6 +1578,10 @@ define([ documentHolder.menuImgRotate.setVisible(!ischartmenu && (pluginGuid===null || pluginGuid===undefined)); documentHolder.menuImgRotate.setDisabled(isObjLocked); + documentHolder.menuImgCrop.setVisible(this.api.asc_canEditCrop()); + if (documentHolder.menuImgCrop.isVisible()) + documentHolder.menuImgCrop.setDisabled(isObjLocked); + var isInSign = !!signGuid; documentHolder.menuSignatureEditSign.setVisible(isInSign); documentHolder.menuSignatureEditSetup.setVisible(isInSign); @@ -2288,6 +2307,10 @@ define([ this.namedrange_locked = (state == Asc.c_oAscDefinedNameReason.LockDefNameManager); }, + onChangeCropState: function(state) { + this.documentHolder.menuImgCrop.menu.items[0].setChecked(state, true); + }, + initEquationMenu: function() { if (!this._currentMathObj) return; var me = this, diff --git a/apps/spreadsheeteditor/main/app/view/DocumentHolder.js b/apps/spreadsheeteditor/main/app/view/DocumentHolder.js index 6ed0e2be7..aefbbf1c2 100644 --- a/apps/spreadsheeteditor/main/app/view/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/view/DocumentHolder.js @@ -605,6 +605,29 @@ define([ }) }); + me.menuImgCrop = new Common.UI.MenuItem({ + caption : me.textCrop, + menu : new Common.UI.Menu({ + menuAlign: 'tl-tr', + items: [ + new Common.UI.MenuItem({ + caption: me.textCrop, + checkable: true, + allowDepress: true, + value : 0 + }), + new Common.UI.MenuItem({ + caption: me.textCropFill, + value : 1 + }), + new Common.UI.MenuItem({ + caption: me.textCropFit, + value : 2 + }) + ] + }) + }); + me.mnuBringToFront = new Common.UI.MenuItem({ caption : this.textArrangeFront, iconCls : 'mnu-arrange-front', @@ -732,6 +755,7 @@ define([ me.menuImageAlign, me.menuImgRotate, me.mnuShapeSeparator, + me.menuImgCrop, me.mnuChartEdit, me.mnuShapeAdvanced, me.menuImgOriginalSize, @@ -1053,7 +1077,10 @@ define([ textFlipH: 'Flip Horizontally', textRotate: 'Rotate', textArrange: 'Arrange', - textAlign: 'Align' + textAlign: 'Align', + textCrop: 'Crop', + textCropFill: 'Fill', + textCropFit: 'Fit' }, SSE.Views.DocumentHolder || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/view/ImageSettings.js b/apps/spreadsheeteditor/main/app/view/ImageSettings.js index 7501a672d..bca7fe23b 100644 --- a/apps/spreadsheeteditor/main/app/view/ImageSettings.js +++ b/apps/spreadsheeteditor/main/app/view/ImageSettings.js @@ -73,7 +73,8 @@ define([ Height: 0, DisabledControls: false, keepRatio: false, - isOleObject: false + isOleObject: false, + cropMode: false }; this.spinners = []; this.lockedControls = []; @@ -204,6 +205,7 @@ define([ split: true, enableToggle: true, allowDepress: true, + pressed: this._state.cropMode, width: 100, menu : new Common.UI.Menu({ style : 'min-width: 100px;', @@ -212,6 +214,7 @@ define([ caption: this.textCrop, checkable: true, allowDepress: true, + checked: this._state.cropMode, value: 0 }, { @@ -445,6 +448,9 @@ define([ }, _changeCropState: function(state) { + this._state.cropMode = state; + + if (!this.btnCrop) return; this.btnCrop.toggle(state, true); this.btnCrop.menu.items[0].setChecked(state, true); }, @@ -453,7 +459,7 @@ define([ if (this.api) { btn.pressed ? this.api.asc_startEditCrop() : this.api.asc_endEditCrop(); } - Common.NotificationCenter.trigger('edit:complete', me); + Common.NotificationCenter.trigger('edit:complete', this); }, onCropMenu: function(menu, item) { @@ -466,7 +472,7 @@ define([ item.checked ? this.api.asc_startEditCrop() : this.api.asc_endEditCrop(); } } - Common.NotificationCenter.trigger('edit:complete', me); + Common.NotificationCenter.trigger('edit:complete', this); }, onBtnRotateClick: function(btn) { diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 529def99f..5c38e3620 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -1449,6 +1449,9 @@ "SSE.Views.DocumentHolder.txtUngroup": "Ungroup", "SSE.Views.DocumentHolder.txtWidth": "Width", "SSE.Views.DocumentHolder.vertAlignText": "Vertical Alignment", + "SSE.Views.DocumentHolder.textCrop": "Crop", + "SSE.Views.DocumentHolder.textCropFill": "Fill", + "SSE.Views.DocumentHolder.textCropFit": "Fit", "SSE.Views.FileMenu.btnBackCaption": "Open file location", "SSE.Views.FileMenu.btnCloseMenuCaption": "Close Menu", "SSE.Views.FileMenu.btnCreateNewCaption": "Create New",