Commit 1788c01c authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Добавил класс Fragment

В редакторе ячейки перешел на новый класс Fragment

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@52053 954022d7-b5bf-4e40-9824-e11837661b57
parent 12f8ebc7
......@@ -315,6 +315,32 @@ ColorManager.prototype =
}
g_oColorManager = new ColorManager();
/** @constructor */
function Fragment(val) {
this.text = null;
this.format = null;
this.sFormula = null;
this.sId = null;
if (null != val) {
this.set(val);
}
}
Fragment.prototype = {
clone : function () {
return new Fragment(this);
},
set : function(oVal) {
if (null != oVal.text)
this.text = oVal.text;
if (null != oVal.format)
this.format = oVal.format;
if (null != oVal.sFormula)
this.sFormula = oVal.sFormula;
if (null != oVal.sId)
this.sId = oVal.sId;
}
};
/** @constructor */
function Font(val)
{
......@@ -2939,7 +2965,7 @@ CCellValue.prototype =
else
cellfont = g_oDefaultFont;
if(null != sText){
var oNewItem = {text: null, format: null, sFormula: null, sId: null};
var oNewItem = new Fragment();
oNewItem.text = sText;
oNewItem.format = cellfont.clone();
color = oNewItem.format.c;
......@@ -2962,13 +2988,12 @@ CCellValue.prototype =
aResult.push(oNewItem);
} else if(null != aText){
for(var i = 0; i < aText.length; i++){
var oNewItem = {text: null, format: null, sFormula: null, sId: null};
var oNewItem = new Fragment();
var oCurtext = aText[i];
if(null != oCurtext.text)
{
oNewItem.text = oCurtext.text;
var oCurFormat = new Font();
oCurFormat = new Font();
oCurFormat.set(cellfont);
if(null != oCurtext.format)
oCurFormat.set(oCurtext.format);
......
......@@ -21,7 +21,6 @@
var asc_getcvt = asc.getCvtRatio;
var asc_round = asc.round;
var asc_search = asc.search;
var asc_clone = asc.clone;
var asc_lastidx = asc.lastIndexOf;
var asc_HL = asc.HandlersList;
......@@ -1252,7 +1251,7 @@
}
if (t.newTextFormat) {
var oNewObj = {format: t.newTextFormat, text: str, theme: null, tint: null};
var oNewObj = new Fragment({format: t.newTextFormat, text: str});
t._addFragments([oNewObj], pos);
delete t.newTextFormat;
} else {
......@@ -1409,8 +1408,8 @@
Array.prototype.splice.apply(
opt.fragments,
[f.index, 1].concat([
{format: fr.format.clone(), text: fr.text.slice(0, pos - f.begin)},
{format: fr.format.clone(), text: fr.text.slice(pos - f.begin)}]));
new Fragment({format: fr.format.clone(), text: fr.text.slice(0, pos - f.begin)}),
new Fragment({format: fr.format.clone(), text: fr.text.slice(pos - f.begin)})]));
}
},
......@@ -1422,18 +1421,18 @@
if (!first || !last) {throw "Can not extract fragment of text";}
if (first.index === last.index) {
fr = asc_clone(opt.fragments[first.index]);
fr = opt.fragments[first.index].clone();
fr.text = fr.text.slice(startPos - first.begin, endPos - first.begin + 1);
res.push(fr);
} else {
fr = asc_clone(opt.fragments[first.index]);
fr = opt.fragments[first.index].clone();
fr.text = fr.text.slice(startPos - first.begin);
res.push(fr);
for (i = first.index + 1; i < last.index; ++i) {
fr = asc_clone(opt.fragments[i]);
fr = opt.fragments[i].clone();
res.push(fr);
}
fr = asc_clone(opt.fragments[last.index]);
fr = opt.fragments[last.index].clone();
fr.text = fr.text.slice(0, endPos - last.begin + 1);
res.push(fr);
}
......@@ -1487,7 +1486,7 @@
var fr = opt.fragments[i];
var nextFr = opt.fragments[i + 1];
if(fr.format.isEqual(nextFr.format)) {
opt.fragments.splice(i, 2, {format: fr.format, text: fr.text + nextFr.text});
opt.fragments.splice(i, 2, new Fragment({format: fr.format, text: fr.text + nextFr.text}));
continue;
}
}
......
......@@ -8817,7 +8817,7 @@
v = c.getValueForEdit2().slice(0, 1);
// Создаем новый массив, т.к. getValueForEdit2 возвращает ссылку
newValue = [];
newValue[0] = {text: cellValue, format: v[0].format.clone()};
newValue[0] = new Fragment({text: cellValue, format: v[0].format.clone()});
t._saveCellValueAfterEdit(oCellEdit, c, newValue, /*flags*/undefined, /*skipNLCheck*/false,
/*isNotHistory*/true);
......@@ -9115,6 +9115,13 @@
var oFontColor = c.getFontcolor();
// Скрываем окно редактирования комментария
this.model.workbook.handlers.trigger("asc_onHideComment");
if (fragments === undefined) {
var _fragmentsTmp = c.getValueForEdit2();
fragments = [];
for (var i = 0; i < _fragmentsTmp.length; ++i)
fragments.push(_fragmentsTmp[i].clone());
}
editor.open({
cellX: t.cellsLeft + tc[!fl.isMerged ? col : mc.c1].left - tc[vr.c1].left,
......@@ -9122,7 +9129,7 @@
leftSide: getLeftSide(!fl.isMerged ? col : mc.c1),
rightSide: getRightSide(!fl.isMerged ? col : mc.c2),
bottomSide: getBottomSide(!fl.isMerged ? row : mc.r2),
fragments: fragments !== undefined ? fragments : c.getValueForEdit2(),
fragments: fragments,
flags: fl,
font: new asc_FP(c.getFontname(), c.getFontsize()),
background: bg !== null ? bg : t.settings.cells.defaultState.background,
......@@ -9154,7 +9161,7 @@
v = c.getValueForEdit2().slice(0, 1);
// Создаем новый массив, т.к. getValueForEdit2 возвращает ссылку
copyValue = [];
copyValue[0] = {text: text, format: v[0].format.clone()};
copyValue[0] = new Fragment({text: text, format: v[0].format.clone()});
var bSuccess = t.openCellEditor(editor, 0, 0, /*isCoord*/false, /*fragments*/undefined, /*cursorPos*/undefined, isFocus, /*isClearCell*/true,
/*isHideCursor*/false, activeRange);
......
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