[PE][SSE] Add crop for images and shapes to context menu

This commit is contained in:
Julia Radzhabova 2019-04-09 14:29:51 +03:00
parent 3fbf4713e8
commit 2bbfec1e18
8 changed files with 124 additions and 15 deletions

View file

@ -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))
]

View file

@ -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 || {}));
});

View file

@ -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);
},

View file

@ -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",

View file

@ -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,

View file

@ -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 || {}));
});

View file

@ -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) {

View file

@ -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",