[SSE] repaired 'edit diagram' mode

This commit is contained in:
Maxim Kadushkin 2017-04-28 15:24:57 +03:00
parent b87e85ac92
commit aa1fa0dd31
5 changed files with 116 additions and 50 deletions

View file

@ -1297,7 +1297,7 @@ define([
this.updateWindowTitle(change);
Common.Gateway.setDocumentModified(change);
if (this.toolbarView && this.api) {
if (this.toolbarView && this.toolbarView.btnSave && this.api) {
var isSyncButton = $('.btn-icon', this.toolbarView.btnSave.cmpEl).hasClass('btn-synch'),
forcesave = this.appOptions.forcesave;
var cansave = this.api.asc_isDocumentCanSave();

View file

@ -1336,14 +1336,16 @@ define([
if ( !this.appConfig.isEditDiagram && !this.appConfig.isEditMailMerge ) {
this.api.asc_registerCallback('asc_onSheetsChanged', _.bind(this.onApiSheetChanged, this));
this.api.asc_registerCallback('asc_onUpdateSheetViewSettings', _.bind(this.onApiSheetChanged, this));
this.api.asc_registerCallback('asc_onEndAddShape', _.bind(this.onApiEndAddShape, this));
} else {
}
this.api.asc_registerCallback('asc_onShowChartDialog', _.bind(this.onApiChartDblClick, this));
this.api.asc_registerCallback('asc_onCanUndoChanged', _.bind(this.onApiCanRevert, this, 'undo'));
this.api.asc_registerCallback('asc_onCanRedoChanged', _.bind(this.onApiCanRevert, this, 'redo'));
this.api.asc_registerCallback('asc_onEditCell', _.bind(this.onApiEditCell, this));
this.api.asc_registerCallback('asc_onEndAddShape', _.bind(this.onApiEndAddShape, this));
this.api.asc_registerCallback('asc_onStopFormatPainter', _.bind(this.onApiStyleChange, this));
this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onApiSelectionChanged, this));
Common.util.Shortcuts.delegateShortcuts({
shortcuts: {
@ -1392,11 +1394,9 @@ define([
}
});
this.wrapOnSelectionChanged = _.bind(this.onApiSelectionChanged, this);
this.api.asc_registerCallback('asc_onSelectionChanged', this.wrapOnSelectionChanged);
this.onApiSelectionChanged(this.api.asc_getCellInfo());
this.api.asc_registerCallback('asc_onEditorSelectionChanged', _.bind(this.onApiEditorSelectionChanged, this));
this.onApiSelectionChanged(this.api.asc_getCellInfo());
this.attachToControlEvents();
this.onApiSheetChanged();
@ -1715,6 +1715,8 @@ define([
onApiSelectionChanged: function(info) {
if (!this.editMode) return;
if ( this.toolbar.mode.isEditDiagram )
return this.onApiSelectionChanged_DiagramEditor(info);
var selectionType = info.asc_getFlags().asc_getSelectionType(),
coauth_disable = (!this.toolbar.mode.isEditMailMerge && !this.toolbar.mode.isEditDiagram) ? (info.asc_getLocked()===true || info.asc_getLockedTable()===true) : false,
@ -1725,21 +1727,17 @@ define([
val, need_disable = false;
/* read font name */
if ( toolbar.cmbFontName ) {
var fontparam = fontobj.asc_getName();
if (fontparam != toolbar.cmbFontName.getValue()) {
Common.NotificationCenter.trigger('fonts:change', fontobj);
}
}
/* read font size */
if ( toolbar.cmbFontSize ) {
var str_size = fontobj.asc_getSize();
if (this._state.fontsize !== str_size) {
toolbar.cmbFontSize.setValue((str_size !== undefined) ? str_size : '');
this._state.fontsize = str_size;
}
}
toolbar.lockToolbar(SSE.enumLock.cantHyperlink, (selectionType == Asc.c_oAscSelectionType.RangeShapeText) && (this.api.asc_canAddShapeHyperlink()===false), { array: [toolbar.btnInsertHyperlink]});
@ -1748,7 +1746,7 @@ define([
if (this._state.sparklines_disabled !== need_disable) {
this._state.sparklines_disabled = need_disable;
var len = toolbar.mnuInsertChartPicker.store.length;
for (var i=0; i<3; i++) {
for (var i = 0; i < 3; i++) {
toolbar.mnuInsertChartPicker.store.at(len-i-1).set({disabled: need_disable});
}
}
@ -2062,6 +2060,70 @@ define([
}
},
onApiSelectionChanged_DiagramEditor: function(info) {
if ( !this.editMode || this.api.isCellEdited || this.api.isRangeSelection) return;
var me = this;
var _disableEditOptions = function(seltype, coauth_disable) {
var is_chart_text = seltype == Asc.c_oAscSelectionType.RangeChartText,
is_chart = seltype == Asc.c_oAscSelectionType.RangeChart,
is_shape_text = seltype == Asc.c_oAscSelectionType.RangeShapeText,
is_shape = seltype == Asc.c_oAscSelectionType.RangeShape,
is_image = seltype == Asc.c_oAscSelectionType.RangeImage,
is_mode_2 = is_shape_text || is_shape || is_chart_text || is_chart,
is_objLocked = false;
if ( !(is_mode_2 || is_image) &&
me._state.selection_type === seltype &&
me._state.coauthdisable === coauth_disable )
return (seltype === Asc.c_oAscSelectionType.RangeImage);
if ( is_mode_2 ) {
var selectedObjects = me.api.asc_getGraphicObjectProps();
is_objLocked = selectedObjects.some( function(object) {
return object.asc_getObjectType() == Asc.c_oAscTypeSelectElement.Image && object.asc_getObjectValue().asc_getLocked();
} );
}
var _set = SSE.enumLock;
var type = seltype;
switch ( seltype ) {
case Asc.c_oAscSelectionType.RangeImage: type = _set.selImage; break;
case Asc.c_oAscSelectionType.RangeShape: type = _set.selShape; break;
case Asc.c_oAscSelectionType.RangeShapeText: type = _set.selShapeText; break;
case Asc.c_oAscSelectionType.RangeChart: type = _set.selChart; break;
case Asc.c_oAscSelectionType.RangeChartText: type = _set.selChartText; break;
}
me.toolbar.lockToolbar(type, type != seltype, {
clear: [_set.selImage, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.coAuth]
});
me.toolbar.lockToolbar(SSE.enumLock.coAuthText, is_objLocked);
return is_image;
};
var selectionType = info.asc_getFlags().asc_getSelectionType(),
coauth_disable = false;
if ( _disableEditOptions(selectionType, coauth_disable) ) return;
if (selectionType == Asc.c_oAscSelectionType.RangeChart || selectionType == Asc.c_oAscSelectionType.RangeChartText)
return;
var val = info.asc_getNumFormatInfo();
if ( val ) {
this._state.numformat = info.asc_getNumFormat();
this._state.numformatinfo = val;
val = val.asc_getType();
if (this._state.numformattype !== val) {
me.toolbar.cmbNumberFormat.setValue(val, me.toolbar.txtCustom);
this._state.numformattype = val;
}
}
},
onApiStyleChange: function() {
this.toolbar.btnCopyStyle.toggle(false, true);
this.modeAlwaysSetStyle = false;
@ -2108,6 +2170,7 @@ define([
this._state.clrback = undefined;
this.onApiSelectionChanged(this.api.asc_getCellInfo());
}
this._state.clrtext_asccolor = undefined;
this._state.clrshd_asccolor = undefined;

View file

@ -99,6 +99,9 @@ define([
config.customization && config.customization.compactToolbar ))
{
me.viewport.vlayout.panels[0].height = 40;
} else
if ( config.isEditDiagram || config.isEditMailMerge ) {
me.viewport.vlayout.panels[0].height = 40;
}
},

View file

@ -1,4 +1,4 @@
<div class="toolbar" style="<%= (isEditDiagram || isEditMailMerge) ? 'height: 41px;' : 'height: 67px;' %>">
<div class="toolbar" style="height: 41px; padding: 10px 0;">
<% if ( isEditDiagram ) { %>
<!----------------------->
<!-- Edit diagram mode -->

View file

@ -1213,6 +1213,11 @@ define([
})
});
var hidetip = Common.localStorage.getItem("sse-hide-synch");
me.showSynchTip = !(hidetip && parseInt(hidetip) == 1);
me.needShowSynchTip = false;
}
me.lockControls = [
me.cmbFontName, me.cmbFontSize, me.btnIncFontSize, me.btnDecFontSize, me.btnBold,
me.btnItalic, me.btnUnderline, me.btnTextColor, me.btnHorizontalAlign, me.btnAlignLeft,
@ -1227,10 +1232,6 @@ define([
/*me.btnSave, */me.btnClearStyle, me.btnCopyStyle
];
var hidetip = Common.localStorage.getItem("sse-hide-synch");
me.showSynchTip = !(hidetip && parseInt(hidetip) == 1);
me.needShowSynchTip = false;
var _temp_array = [me.cmbFontName, me.cmbFontSize, me.btnAlignLeft,me.btnAlignCenter,me.btnAlignRight,me.btnAlignJust,me.btnAlignTop,
me.btnAlignMiddle, me.btnAlignBottom, me.btnHorizontalAlign, me.btnVerticalAlign,
me.btnInsertImage, me.btnInsertText, me.btnInsertShape, me.btnInsertEquation, me.btnIncFontSize, me.btnDecFontSize,
@ -1246,7 +1247,6 @@ define([
if (cmp && _.isFunction(cmp.setDisabled))
cmp.setDisabled(true);
});
}
},
render: function (mode) {