Commit 15695f4d authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

"single" -> EUnderline.underlineSingle

"none" -> EUnderline.underlineNone
Ускорил renderFragment (убрал регулярное выражение)
Переделал _setStylesTextPaste (в clipboard.js).

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@53839 954022d7-b5bf-4e40-9824-e11837661b57
parent 8bed382f
......@@ -2690,7 +2690,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
if ( ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellUnderline )
ws.objectRender.controller.setCellUnderline(isUnderline);
else {
this.wb.setFontAttributes("u", isUnderline ? "single" : "none");
this.wb.setFontAttributes("u", isUnderline ? EUnderline.underlineSingle : EUnderline.underlineNone);
this.wb.restoreFocus();
}
},
......
......@@ -1652,18 +1652,9 @@ function BinaryStylesTableWriter(memory, wb, oBinaryWorksheetsTableWriter)
}
if(null != font.u)
{
var nUnderline = EUnderline.underlineNone;
switch(font.u)
{
case "double": nUnderline = EUnderline.underlineDouble;break;
case "doubleAccounting": nUnderline = EUnderline.underlineDoubleAccounting;break;
case "none": nUnderline = EUnderline.underlineNone;break;
case "single": nUnderline = EUnderline.underlineSingle;break;
case "singleAccounting": nUnderline = EUnderline.underlineSingleAccounting;break;
}
this.memory.WriteByte(c_oSerFontTypes.Underline);
this.memory.WriteByte(c_oSerPropLenType.Byte);
this.memory.WriteByte(nUnderline);
this.memory.WriteByte(font.u);
}
if(null != font.va)
{
......@@ -4027,17 +4018,7 @@ function Binary_SharedStringTableReader(stream, wb, aSharedStrings)
else if ( c_oSerFontTypes.Sz == type )
rPr.fs = this.stream.GetDoubleLE();
else if ( c_oSerFontTypes.Underline == type )
{
switch(this.stream.GetUChar())
{
case EUnderline.underlineDouble: rPr.u = "double";break;
case EUnderline.underlineDoubleAccounting: rPr.u = "doubleAccounting";break;
case EUnderline.underlineNone: rPr.u = "none";break;
case EUnderline.underlineSingle: rPr.u = "single";break;
case EUnderline.underlineSingleAccounting: rPr.u = "singleAccounting";break;
default: rPr.u = "none";break;
}
}
rPr.u = this.stream.GetUChar();
else if ( c_oSerFontTypes.VertAlign == type )
{
switch(this.stream.GetUChar())
......@@ -6231,7 +6212,7 @@ function Binary_OtherTableReader(stream, oMedia, sUrlPath, wb)
fs : 11,
b : false,
i : false,
u : "none",
u : EUnderline.underlineNone,
s : false,
c : g_oColorManager.getThemeColor(g_nColorTextDefault),
va : "baseline",
......
......@@ -696,7 +696,7 @@ Vertex.prototype = {
this.wb.dependencyFormulas.deleteMasterNodes2( wsId, cellId );
cell.formulaParsed.setRefError(wsId, cellId);
cell.setFormula(cell.formulaParsed.assemble(), true);
addToArrRecalc(wsId, cell);
addToArrRecalc(wsId, cell);
}
},
move : function(offset, wsId, toDelete)
......@@ -718,7 +718,7 @@ Vertex.prototype = {
this.wb.dependencyFormulas.deleteMasterNodes2( slave.sheetId, slave.cellId );
cell.formulaParsed.shiftCells( offset, null, this, slave.sheetId, toDelete);
cell.setFormula(cell.formulaParsed.assemble(), true);
addToArrRecalc(slave.sheetId, cell);
addToArrRecalc(slave.sheetId, cell);
}
}
this.bbox = oNewBBox;
......@@ -738,7 +738,7 @@ Vertex.prototype = {
this.wb.dependencyFormulas.deleteMasterNodes2( slave.sheetId, slave.cellId );
cell.formulaParsed.stretchArea( this, sNewName );
cell.setFormula(cell.formulaParsed.assemble(), true);
addToArrRecalc(slave.sheetId, cell);
addToArrRecalc(slave.sheetId, cell);
}
}
this.bbox = bboxTo
......@@ -4472,7 +4472,7 @@ Range.prototype.setValue2=function(array){
var oBBox = this.bbox;
History.StartTransaction();
var wb = this.worksheet.workbook, ws = this.worksheet, ar =[];
//[{"text":"qwe","format":{"b":true, "i":false, "u":"none", "s":false, "fn":"Arial", "fs": 12, "c": 0xff00ff, "va": "subscript" }},{}...]
//[{"text":"qwe","format":{"b":true, "i":false, "u":EUnderline.underlineNone, "s":false, "fn":"Arial", "fs": 12, "c": 0xff00ff, "va": "subscript" }},{}...]
var oThis = this;
/*
Устанавливаем значение в Range ячеек. В отличае от setValue, сюда мы попадаем только в случае ввода значения отличного от формулы. Таким образом, если в ячейке была формула, то для нее в графе очищается список ячеек от которых зависела. После чего выставляем флаг о необходимости пересчета.
......@@ -4700,7 +4700,6 @@ Range.prototype.setItalic=function(val){
};
Range.prototype.setUnderline=function(val){
History.Create_NewPoint();
var oBBox = this.bbox;
this.createCellOnRowColCross();
var fSetProperty = this._setProperty;
var nRangeType = this._getRangeType();
......@@ -4769,7 +4768,6 @@ Range.prototype.setFontAlign=function(val){
};
Range.prototype.setAlignVertical=function(val){
History.Create_NewPoint();
var oBBox = this.bbox;
if("none" == val)
val = null;
this.createCellOnRowColCross();
......@@ -4794,7 +4792,6 @@ Range.prototype.setAlignVertical=function(val){
};
Range.prototype.setAlignHorizontal=function(val){
History.Create_NewPoint();
var oBBox = this.bbox;
this.createCellOnRowColCross();
var fSetProperty = this._setProperty;
var nRangeType = this._getRangeType();
......@@ -5185,7 +5182,7 @@ Range.prototype.getValueWithFormat=function(){
return "";
};
Range.prototype.getValue2=function(dDigitsCount, fIsFitMeasurer){
//[{"text":"qwe","format":{"b":true, "i":false, "u":"none", "s":false, "fn":"Arial", "fs": 12, "c": 0xff00ff, "va": "subscript" }},{}...]
//[{"text":"qwe","format":{"b":true, "i":false, "u":EUnderline.underlineNone, "s":false, "fn":"Arial", "fs": 12, "c": 0xff00ff, "va": "subscript" }},{}...]
var nRow0 = this.bbox.r1;
var nCol0 = this.bbox.c1;
var cell = this.worksheet._getCellNoEmpty(this.bbox.r1, this.bbox.c1);
......@@ -5412,7 +5409,7 @@ Range.prototype.getUnderline=function(){
}
return g_oDefaultFont.u;
};
Range.prototype.getStrikeout=function(val){
Range.prototype.getStrikeout=function(){
var nRow = this.bbox.r1;
var nCol = this.bbox.c1;
var cell = this.worksheet._getCellNoEmpty(nRow, nCol);
......@@ -6165,7 +6162,7 @@ Range.prototype._getHyperlinks=function(){
}
}
return result;
}
};
Range.prototype.getHyperlink=function(){
var aHyperlinks = this._getHyperlinks();
if(null != aHyperlinks && aHyperlinks.length > 0)
......@@ -6179,16 +6176,17 @@ Range.prototype.setHyperlinkOpen=function(val){
if(null != val && false == val.isValid())
return;
this.worksheet.hyperlinkManager.add(val.Ref.getBBox0(), val);
}
};
Range.prototype.setHyperlink=function(val, bWithoutStyle){
if(null != val && false == val.isValid())
return;
//проверяем, может эта ссылка уже существует
var i, length, hyp;
var bExist = false;
var aHyperlinks = this.worksheet.hyperlinkManager.get(this.bbox);
for(var i = 0, length = aHyperlinks.all.length; i < length; i++)
for(i = 0, length = aHyperlinks.all.length; i < length; i++)
{
var hyp = aHyperlinks.all[i];
hyp = aHyperlinks.all[i];
if(hyp.data.isEqual(val))
{
bExist = true;
......@@ -6197,15 +6195,14 @@ Range.prototype.setHyperlink=function(val, bWithoutStyle){
}
if(false == bExist)
{
var oThis = this;
History.Create_NewPoint();
History.StartTransaction();
if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
{
//удаляем ссылки с тем же адресом
for(var i = 0, length = aHyperlinks.all.length; i < length; i++)
for(i = 0, length = aHyperlinks.all.length; i < length; i++)
{
var hyp = aHyperlinks.all[i];
hyp = aHyperlinks.all[i];
if(hyp.bbox.isEqual(this.bbox))
this.worksheet.hyperlinkManager.removeElement(hyp);
}
......@@ -6216,7 +6213,7 @@ Range.prototype.setHyperlink=function(val, bWithoutStyle){
var oHyperlinkFont = new Font();
oHyperlinkFont.fn = this.worksheet.workbook.getDefaultFont();
oHyperlinkFont.fs = this.worksheet.workbook.getDefaultSize();
oHyperlinkFont.u = "single";
oHyperlinkFont.u = EUnderline.underlineSingle;
oHyperlinkFont.c = g_oColorManager.getThemeColor(g_nColorHyperlink);
this.setFont(oHyperlinkFont);
}
......@@ -6243,7 +6240,7 @@ Range.prototype.removeHyperlink=function(val){
this.worksheet.hyperlinkManager.remove(bbox);
}
History.EndTransaction();
}
};
Range.prototype.deleteCellsShiftUp=function(){
return this._shiftUpDown(true);
};
......@@ -6380,7 +6377,7 @@ Range.prototype.setOffset=function(offset){//offset = {offsetCol:intNumber, offs
this.bbox.r2 = 0;
this.first = new CellAddress(this.bbox.r1, this.bbox.c1, 0);
this.last = new CellAddress(this.bbox.r2, this.bbox.c2, 0);
}
};
Range.prototype.setOffsetFirst=function(offset){//offset = {offsetCol:intNumber, offsetRow:intNumber}
this.bbox.c1 += offset.offsetCol;
if( this.bbox.c1 < 0 )
......@@ -6389,7 +6386,7 @@ Range.prototype.setOffsetFirst=function(offset){//offset = {offsetCol:intNumber,
if( this.bbox.r1 < 0 )
this.bbox.r1 = 0;
this.first = new CellAddress(this.bbox.r1, this.bbox.c1, 0);
}
};
Range.prototype.setOffsetLast=function(offset){//offset = {offsetCol:intNumber, offsetRow:intNumber}
this.bbox.c2 += offset.offsetCol;
if( this.bbox.c2 < 0 )
......@@ -6398,7 +6395,7 @@ Range.prototype.setOffsetLast=function(offset){//offset = {offsetCol:intNumber,
if( this.bbox.r2 < 0 )
this.bbox.r2 = 0;
this.last = new CellAddress(this.bbox.r2, this.bbox.c2, 0);
}
};
Range.prototype.intersect=function(range){
var oBBox1 = this.bbox;
var oBBox2 = range.bbox;
......@@ -6409,18 +6406,16 @@ Range.prototype.intersect=function(range){
if(r1 <= r2 && c1 <= c2)
return this.worksheet.getRange3(r1, c1, r2, c2);
return null;
}
};
Range.prototype.cleanCache=function(){
this._setPropertyNoEmpty(null,null,function(cell, nRow0, nCol0, nRowStart, nColStart){
cell.cleanCache();
});
}
};
Range.prototype.cleanFormat=function(){
History.Create_NewPoint();
var oBBox = this.bbox;
History.StartTransaction();
this.unmerge();
var oThis = this;
this._setPropertyNoEmpty(function(row){
row.setStyle(null);
// if(row.isEmpty())
......@@ -6435,12 +6430,10 @@ Range.prototype.cleanFormat=function(){
// cell.Remove();
});
History.EndTransaction();
}
};
Range.prototype.cleanText=function(){
History.Create_NewPoint();
var oBBox = this.bbox;
History.StartTransaction();
var oThis = this;
this._setPropertyNoEmpty(null, null,
function(cell, nRow0, nCol0, nRowStart, nColStart){
cell.setValue("");
......@@ -6448,10 +6441,9 @@ Range.prototype.cleanText=function(){
// cell.Remove();
});
History.EndTransaction();
}
};
Range.prototype.cleanAll=function(){
History.Create_NewPoint();
var oBBox = this.bbox;
History.StartTransaction();
this.unmerge();
//удаляем только гиперссылки, которые полностью лежат в области
......@@ -6472,7 +6464,7 @@ Range.prototype.cleanAll=function(){
});
buildRecalc(this.worksheet.workbook);
History.EndTransaction();
}
};
Range.prototype.sort=function(nOption, nStartCol){
//todo горизонтальная сортировка
var aMerged = this.worksheet.mergeManager.get(this.bbox);
......
......@@ -1023,65 +1023,47 @@
_setStylesTextPaste: function (spanObject)
{
var t = this;
var defaultColor = 'rgb(0, 0, 0)';
var jqSpanObject = $(spanObject), fontSize;
var oNewItem = {};
oNewItem.text = $(spanObject).text().replace(/(\r|\t|\n|)/g,'');
oNewItem.text = jqSpanObject.text().replace(/(\r|\t|\n|)/g,'');
oNewItem.format = {};
oNewItem.format.fn = t._checkFonts(spanObject.style.fontFamily.replace(/'/g,"").split(',')[0]);
oNewItem.format.fn = this._checkFonts(spanObject.style.fontFamily.replace(/'/g,"").split(',')[0]);
if(oNewItem.format.fn == null || oNewItem.format.fn == '')
if (oNewItem.format.fn == null || oNewItem.format.fn == '')
oNewItem.format.fn = 'Calibri';
if($(spanObject).css('vertical-align') == 'sub' || $(spanObject).css('vertical-align') == 'super')
{
if(($(spanObject.parentNode).css('font-size')).indexOf('pt') > -1)
oNewItem.format.fs = parseInt($(spanObject.parentNode).css('font-size'));
if (jqSpanObject.css('vertical-align') == 'sub' || jqSpanObject.css('vertical-align') == 'super') {
fontSize = $(spanObject.parentNode).css('font-size');
if(fontSize.indexOf('pt') > -1)
oNewItem.format.fs = parseInt(fontSize);
else
oNewItem.format.fs = parseInt((3/4)*Math.round(parseFloat($(spanObject.parentNode).css('font-size'))));
}
else
{
oNewItem.format.fs = parseInt((3/4)*Math.round(parseFloat(fontSize)));
} else {
if(spanObject.style.fontSize.indexOf('pt') > -1)
oNewItem.format.fs = parseInt(spanObject.style.fontSize);
else
oNewItem.format.fs = parseInt((3/4)*Math.round(parseFloat(spanObject.style.fontSize)));
}
if(isNaN(oNewItem.format.fs))
if (isNaN(oNewItem.format.fs))
oNewItem.format.fs = 11;
if($(spanObject).css('font-weight') == 'bold')
oNewItem.format.b = true;
else
oNewItem.format.b = false;
if($(spanObject).css('font-style') == 'italic')
oNewItem.format.i = true;
else
oNewItem.format.i = false;
if($(spanObject).css('text-decoration') == 'underline')
oNewItem.format.u = "single";
else
oNewItem.format.u = "none";
if($(spanObject).css('text-decoration') == 'line-through')
oNewItem.format.s = true;
else
oNewItem.format.s = false;
oNewItem.format.b = (jqSpanObject.css('font-weight') == 'bold');
oNewItem.format.i = (jqSpanObject.css('font-style') == 'italic');
oNewItem.format.u = (jqSpanObject.css('text-decoration') == 'underline') ?
EUnderline.underlineSingle : EUnderline.underlineNone;
oNewItem.format.s = (jqSpanObject.css('text-decoration') == 'line-through');
if($(spanObject).css('vertical-align') != null)
oNewItem.format.va = $(spanObject).css('vertical-align');
if( $(spanObject).css('vertical-align') == 'baseline')
if (jqSpanObject.css('vertical-align') != null)
oNewItem.format.va = jqSpanObject.css('vertical-align');
if (jqSpanObject.css('vertical-align') == 'baseline')
oNewItem.format.va = '';
oNewItem.format.c = new RgbColor(this._getBinaryColor($(spanObject).css('color')));
if(oNewItem.format.c == '')
oNewItem.format.c = new RgbColor(this._getBinaryColor(jqSpanObject.css('color')));
if (oNewItem.format.c == '')
oNewItem.format.c = null;
if($(spanObject).css('vertical-align') != null)
oNewItem.format.va = $(spanObject).css('vertical-align') === 'sub' ? 'subscript' : $(spanObject).css('vertical-align') === 'super' ? 'superscript' : 'baseline';
if (jqSpanObject.css('vertical-align') != null)
oNewItem.format.va = jqSpanObject.css('vertical-align') === 'sub' ? 'subscript' : jqSpanObject.css('vertical-align') === 'super' ? 'superscript' : 'baseline';
return oNewItem;
},
......@@ -2169,7 +2151,7 @@
function getTextDecoration(format) {
var res = [];
if (format.u !== "none") {res.push("underline");}
if (EUnderline.underlineNone !== format.u) {res.push("underline");}
if (format.s) {res.push("line-through");}
return res.length > 0 ? res.join(",") : "";
}
......@@ -2720,7 +2702,7 @@
c: colorText,
b: fb.indexOf("bold") >= 0 || parseInt(fb, 10) > 500,
i: fi.indexOf("italic") >= 0,
u: td.indexOf("underline") >= 0 ? "single" : "none",
u: td.indexOf("underline") >= 0 ? EUnderline.underlineSingle : EUnderline.underlineNone,
s: td.indexOf("line-through") >= 0,
va: va.indexOf("sub") >=0 ? "subscript" : va.indexOf("sup") >=0 ? "superscript" : "none"
},
......@@ -2739,7 +2721,7 @@
c: colorText,
b: fb.indexOf("bold") >= 0 || parseInt(fb, 10) > 500,
i: fi.indexOf("italic") >= 0,
u: td.indexOf("underline") >= 0 ? "single" : "none",
u: td.indexOf("underline") >= 0 ? EUnderline.underlineSingle : EUnderline.underlineNone,
s: td.indexOf("line-through") >= 0,
va: va.indexOf("sub") >=0 ? "subscript" : va.indexOf("sup") >=0 ? "superscript" : "none"
},
......
......@@ -929,9 +929,8 @@
var dh = prop && prop.lm && prop.lm.bl2 > 0 ? prop.lm.bl2 - prop.lm.bl : 0;
var dw = self._calcCharsWidth(strBeg, end - 1);
var so = prop.font.Strikeout;
var ul = prop.font.Underline;
var ul = EUnderline.underlineNone !== prop.font.Underline;
var isSO = so === true;
var isUL = ul === true || !( ul === undefined || ul === false || ul.search(/\w/) < 0 || ul.search(/\s*none\s*/i) >= 0 );
var fsz, x2, y, lw, dy, i, b, x_, cp, w_1px, h_1px;
if (align !== "justify" || dx < 0.000001) {
......@@ -951,7 +950,7 @@
}
}
if (isSO || isUL) {
if (isSO || ul) {
x2 = asc_calcnpt(x1 + dw, ppix);
fsz = prop.font.FontSize * self.ratio;
lw = asc_round(fsz * ppiy / 72 / 18) || 1;
......@@ -966,7 +965,7 @@
y = asc_calcnpt(y1 + l.bl - prop.lm.a * 0.275, ppiy);
ctx.lineHor(x1, y - dy * h_1px, x2 + w_1px);
}
if (isUL) {
if (ul) {
y = asc_calcnpt(y1 + l.bl + prop.lm.d * 0.4, ppiy);
ctx.lineHor(x1, y + dy * h_1px, x2 + w_1px);
}
......
......@@ -965,7 +965,7 @@
case "u":
// ToDo для двойного подчеркивания нужно будет немного переделать схему
val = !(selectionInfo.asc_getFont().asc_getUnderline());
val = val ? "single" : "none";
val = val ? EUnderline.underlineSingle : EUnderline.underlineNone;
break;
case "s":
val = !(selectionInfo.asc_getFont().asc_getStrikeout());
......
......@@ -5980,7 +5980,7 @@
cell_info.font.size = c.getFontsize();
cell_info.font.bold = c.getBold();
cell_info.font.italic = c.getItalic();
cell_info.font.underline = ("none" !== c.getUnderline()); // ToDo убрать, когда будет реализовано двойное подчеркивание
cell_info.font.underline = (EUnderline.underlineNone !== c.getUnderline()); // ToDo убрать, когда будет реализовано двойное подчеркивание
cell_info.font.strikeout = c.getStrikeout();
cell_info.font.subscript = fa === "subscript";
cell_info.font.superscript = fa === "superscript";
......
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