Commit 800e065e authored by Alexander.Trofimov's avatar Alexander.Trofimov

fix bug 33607 🐛

parent b90efd53
......@@ -498,7 +498,8 @@
t._moveCursor(kEndOfText);
};
CellEditor.prototype.move = function ( l, t, r, b ) {
CellEditor.prototype.move = function (l, t, r, b) {
this.textFlags.wrapOnlyCE = false;
this.sides = this.options.getSides();
this.left = this.sides.cellX;
this.top = this.sides.cellY;
......@@ -506,36 +507,34 @@
this.bottom = this.sides.b[0];
// ToDo вынести в отдельную функцию
var canExpW = true, canExpH = true, tm, expW, expH, fragments = this._getRenderFragments();
if ( 0 < fragments.length ) {
tm = this.textRender.measureString( fragments, this.textFlags, this._getContentWidth() );
if (0 < fragments.length) {
tm = this.textRender.measureString(fragments, this.textFlags, this._getContentWidth());
expW = tm.width > this._getContentWidth();
expH = tm.height > this._getContentHeight();
while ( expW && canExpW || expH && canExpH ) {
if ( expW ) {
while (expW && canExpW || expH && canExpH) {
if (expW) {
canExpW = this._expandWidth();
}
if ( expH ) {
if (expH) {
canExpH = this._expandHeight();
}
if ( !canExpW ) {
this.textFlags.wrapText = true;
tm = this.textRender.measureString( fragments, this.textFlags, this._getContentWidth() );
}
else {
tm = this.textRender.measure( this._getContentWidth() );
if (!canExpW) {
this.textFlags.wrapOnlyCE = true;
tm = this.textRender.measureString(fragments, this.textFlags, this._getContentWidth());
} else {
tm = this.textRender.measure(this._getContentWidth());
}
expW = tm.width > this._getContentWidth();
expH = tm.height > this._getContentHeight();
}
}
if ( this.left < l || this.top < t || this.left > r || this.top > b ) {
if (this.left < l || this.top < t || this.left > r || this.top > b) {
// hide
this._hideCanvas();
}
else {
} else {
this._adjustCanvas();
this._showCanvas();
this._renderText();
......@@ -1109,25 +1108,24 @@
CellEditor.prototype._draw = function () {
var canExpW = true, canExpH = true, tm, expW, expH, fragments = this._getRenderFragments();
if ( 0 < fragments.length ) {
tm = this.textRender.measureString( fragments, this.textFlags, this._getContentWidth() );
if (0 < fragments.length) {
tm = this.textRender.measureString(fragments, this.textFlags, this._getContentWidth());
expW = tm.width > this._getContentWidth();
expH = tm.height > this._getContentHeight();
while ( expW && canExpW || expH && canExpH ) {
if ( expW ) {
while (expW && canExpW || expH && canExpH) {
if (expW) {
canExpW = this._expandWidth();
}
if ( expH ) {
if (expH) {
canExpH = this._expandHeight();
}
if ( !canExpW ) {
this.textFlags.wrapText = true;
tm = this.textRender.measureString( fragments, this.textFlags, this._getContentWidth() );
}
else {
tm = this.textRender.measure( this._getContentWidth() );
if (!canExpW) {
this.textFlags.wrapOnlyCE = true;
tm = this.textRender.measureString(fragments, this.textFlags, this._getContentWidth());
} else {
tm = this.textRender.measure(this._getContentWidth());
}
expW = tm.width > this._getContentWidth();
expH = tm.height > this._getContentHeight();
......@@ -1139,59 +1137,59 @@
this._adjustCanvas();
this._showCanvas();
this._renderText();
this.input.value = this._getFragmentsText( fragments );
this.input.value = this._getFragmentsText(fragments);
this._updateCursorPosition();
this._showCursor();
};
CellEditor.prototype._update = function () {
this._updateFormulaEditMod( /*bIsOpen*/false );
this._updateFormulaEditMod(/*bIsOpen*/false);
var tm, canExpW, canExpH, oldLC, doAjust = false, fragments = this._getRenderFragments();
if ( 0 < fragments.length ) {
if (0 < fragments.length) {
oldLC = this.textRender.getLinesCount();
tm = this.textRender.measureString( fragments, this.textFlags, this._getContentWidth() );
if ( this.textRender.getLinesCount() < oldLC ) {
tm = this.textRender.measureString(fragments, this.textFlags, this._getContentWidth());
if (this.textRender.getLinesCount() < oldLC) {
this.topLineIndex -= oldLC - this.textRender.getLinesCount();
}
canExpW = !this.textFlags.wrapText;
while ( tm.width > this._getContentWidth() && canExpW ) {
canExpW = !(this.textFlags.wrapText || this.textFlags.wrapOnlyCE);
while (tm.width > this._getContentWidth() && canExpW) {
canExpW = this._expandWidth();
if ( !canExpW ) {
this.textFlags.wrapText = true;
tm = this.textRender.measureString( fragments, this.textFlags, this._getContentWidth() );
if (!canExpW) {
this.textFlags.wrapOnlyCE = true;
tm = this.textRender.measureString(fragments, this.textFlags, this._getContentWidth());
}
doAjust = true;
}
canExpH = true;
while ( tm.height > this._getContentHeight() && canExpH ) {
while (tm.height > this._getContentHeight() && canExpH) {
canExpH = this._expandHeight();
doAjust = true;
}
if ( this.textRender.isLastCharNL() && !doAjust && canExpH ) {
var lm = this.textRender.calcCharHeight( this.textRender.getCharsCount() - 1 );
if ( tm.height + lm.th > this._getContentHeight() ) {
if (this.textRender.isLastCharNL() && !doAjust && canExpH) {
var lm = this.textRender.calcCharHeight(this.textRender.getCharsCount() - 1);
if (tm.height + lm.th > this._getContentHeight()) {
this._expandHeight();
doAjust = true;
}
}
}
if ( doAjust ) {
if (doAjust) {
this._adjustCanvas();
}
this._renderText(); // вызов нужен для пересчета поля line.startX, которое используется в _updateCursorPosition
this._fireUpdated(); // вызов нужен для обновление текста верхней строки, перед обновлением позиции курсора
this._updateCursorPosition( true );
this._updateCursorPosition(true);
this._showCursor();
this._updateUndoRedoChanged();
if ( window['IS_NATIVE_EDITOR'] && !this.dontUpdateText ) {
window['native']['onCellEditorChangeText']( this._getFragmentsText( this.options.fragments ) );
if (window['IS_NATIVE_EDITOR'] && !this.dontUpdateText) {
window['native']['onCellEditorChangeText'](this._getFragmentsText(this.options.fragments));
}
};
......
......@@ -556,7 +556,7 @@
* @return {Number}
*/
StringRender.prototype._calcLineWidth = function (startPos, endPos) {
var wrap = this.flags && (this.flags.wrapText || this.flags.wrapOnlyNL);
var wrap = this.flags && (this.flags.wrapText || this.flags.wrapOnlyNL || this.flags.wrapOnlyCE);
var isAtEnd, j, chProp, tw;
if (endPos === undefined || endPos < 0) {
......@@ -813,7 +813,7 @@
StringRender.prototype._measureChars = function (maxWidth) {
var self = this;
var ctx = this.drawingCtx;
var wrap = this.flags && this.flags.wrapText && !this.flags.isNumberFormat;
var wrap = this.flags && (this.flags.wrapText || this.flags.wrapOnlyCE) && !this.flags.isNumberFormat;
var wrapNL = this.flags && this.flags.wrapOnlyNL;
var hasRepeats = false;
var i, j, fr, fmt, text, p, p_ = {}, pIndex, f, f_, eq, startCh;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment