Commit 8f1c4a7e authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Для бордеров храним еще и толщину бордера (а не рассчитываем каждый раз при рисовании)

Для этого поправил функции выставления стилей бордера

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@51027 954022d7-b5bf-4e40-9824-e11837661b57
parent a399b604
...@@ -164,6 +164,14 @@ var c_oAscBorderOptions = { ...@@ -164,6 +164,14 @@ var c_oAscBorderOptions = {
InnerH : 7 InnerH : 7
}; };
// Толщина бордера
var c_oAscBorderWidth = {
None : 0, // 0px
Thin : 1, // 1px
Medium : 2, // 2px
Thick : 3 // 3px
};
// Располагаются в порядке значимости для отрисовки // Располагаются в порядке значимости для отрисовки
var c_oAscBorderStyles = { var c_oAscBorderStyles = {
None : 0, None : 0,
......
...@@ -4351,21 +4351,21 @@ function Binary_StylesTableReader(stream, wb, aCellXfs, Dxfs) ...@@ -4351,21 +4351,21 @@ function Binary_StylesTableReader(stream, wb, aCellXfs, Dxfs)
{ {
switch(this.stream.GetUChar()) switch(this.stream.GetUChar())
{ {
case EBorderStyle.borderstyleDashDot: oBorderProp.s = c_oAscBorderStyles.DashDot;break; case EBorderStyle.borderstyleDashDot: oBorderProp.setStyle(c_oAscBorderStyles.DashDot);break;
case EBorderStyle.borderstyleDashDotDot: oBorderProp.s = c_oAscBorderStyles.DashDotDot;break; case EBorderStyle.borderstyleDashDotDot: oBorderProp.setStyle(c_oAscBorderStyles.DashDotDot);break;
case EBorderStyle.borderstyleDashed: oBorderProp.s = c_oAscBorderStyles.Dashed;break; case EBorderStyle.borderstyleDashed: oBorderProp.setStyle(c_oAscBorderStyles.Dashed);break;
case EBorderStyle.borderstyleDotted: oBorderProp.s = c_oAscBorderStyles.Dotted;break; case EBorderStyle.borderstyleDotted: oBorderProp.setStyle(c_oAscBorderStyles.Dotted);break;
case EBorderStyle.borderstyleDouble: oBorderProp.s = c_oAscBorderStyles.Double;break; case EBorderStyle.borderstyleDouble: oBorderProp.setStyle(c_oAscBorderStyles.Double);break;
case EBorderStyle.borderstyleHair: oBorderProp.s = c_oAscBorderStyles.Hair;break; case EBorderStyle.borderstyleHair: oBorderProp.setStyle(c_oAscBorderStyles.Hair);break;
case EBorderStyle.borderstyleMedium: oBorderProp.s = c_oAscBorderStyles.Medium;break; case EBorderStyle.borderstyleMedium: oBorderProp.setStyle(c_oAscBorderStyles.Medium);break;
case EBorderStyle.borderstyleMediumDashDot: oBorderProp.s = c_oAscBorderStyles.MediumDashDot;break; case EBorderStyle.borderstyleMediumDashDot: oBorderProp.setStyle(c_oAscBorderStyles.MediumDashDot);break;
case EBorderStyle.borderstyleMediumDashDotDot: oBorderProp.s = c_oAscBorderStyles.MediumDashDotDot;break; case EBorderStyle.borderstyleMediumDashDotDot: oBorderProp.setStyle(c_oAscBorderStyles.MediumDashDotDot);break;
case EBorderStyle.borderstyleMediumDashed: oBorderProp.s = c_oAscBorderStyles.MediumDashed;break; case EBorderStyle.borderstyleMediumDashed: oBorderProp.setStyle(c_oAscBorderStyles.MediumDashed);break;
case EBorderStyle.borderstyleNone: oBorderProp.s = c_oAscBorderStyles.None;break; case EBorderStyle.borderstyleNone: oBorderProp.setStyle(c_oAscBorderStyles.None);break;
case EBorderStyle.borderstyleSlantDashDot: oBorderProp.s = c_oAscBorderStyles.SlantDashDot;break; case EBorderStyle.borderstyleSlantDashDot: oBorderProp.setStyle(c_oAscBorderStyles.SlantDashDot);break;
case EBorderStyle.borderstyleThick: oBorderProp.s = c_oAscBorderStyles.Thick;break; case EBorderStyle.borderstyleThick: oBorderProp.setStyle(c_oAscBorderStyles.Thick);break;
case EBorderStyle.borderstyleThin: oBorderProp.s = c_oAscBorderStyles.Thin;break; case EBorderStyle.borderstyleThin: oBorderProp.setStyle(c_oAscBorderStyles.Thin);break;
default : oBorderProp.s = c_oAscBorderStyles.None;break; default : oBorderProp.setStyle(c_oAscBorderStyles.None);break;
} }
} }
else if ( c_oSerBorderPropTypes.Color == type ) else if ( c_oSerBorderPropTypes.Color == type )
......
This diff is collapsed.
...@@ -337,7 +337,7 @@ function Font(val) ...@@ -337,7 +337,7 @@ function Font(val)
//skip и repeat не сохраняются в файл нужны здесь только чтобы класс Font можно было использовать в комплексных строках //skip и repeat не сохраняются в файл нужны здесь только чтобы класс Font можно было использовать в комплексных строках
this.skip = val.skip; this.skip = val.skip;
this.repeat = val.repeat; this.repeat = val.repeat;
}; }
Font.prototype = Font.prototype =
{ {
clean : function() clean : function()
...@@ -557,7 +557,7 @@ function Fill(val) ...@@ -557,7 +557,7 @@ function Fill(val)
bg: 0 bg: 0
}; };
this.bg = val.bg; this.bg = val.bg;
}; }
Fill.prototype = Fill.prototype =
{ {
_mergeProperty : function(first, second, def) _mergeProperty : function(first, second, def)
...@@ -630,10 +630,38 @@ function BorderProp() ...@@ -630,10 +630,38 @@ function BorderProp()
c: 1 c: 1
}; };
this.s = c_oAscBorderStyles.None; this.s = c_oAscBorderStyles.None;
//this.w = c_oAscBorderWidth.None; this.w = c_oAscBorderWidth.None;
this.c = g_oColorManager.getThemeColor(1); this.c = g_oColorManager.getThemeColor(1);
} }
BorderProp.prototype = { BorderProp.prototype = {
setStyle : function (style) {
this.s = style;
switch (this.s) {
case c_oAscBorderStyles.Thin:
case c_oAscBorderStyles.DashDot:
case c_oAscBorderStyles.DashDotDot:
case c_oAscBorderStyles.Dashed:
case c_oAscBorderStyles.Dotted:
case c_oAscBorderStyles.Hair:
this.w = c_oAscBorderWidth.Thin;
break;
case c_oAscBorderStyles.Medium:
case c_oAscBorderStyles.MediumDashDot:
case c_oAscBorderStyles.MediumDashDotDot:
case c_oAscBorderStyles.MediumDashed:
case c_oAscBorderStyles.None:
case c_oAscBorderStyles.SlantDashDot:
this.w = c_oAscBorderWidth.Medium;
break;
case c_oAscBorderStyles.Thick:
case c_oAscBorderStyles.Double:
this.w = c_oAscBorderWidth.Thick;
break;
default:
this.w = c_oAscBorderWidth.None;
break;
}
},
getRgbOrNull : function() getRgbOrNull : function()
{ {
var nRes = null; var nRes = null;
...@@ -660,6 +688,7 @@ BorderProp.prototype = { ...@@ -660,6 +688,7 @@ BorderProp.prototype = {
if(null != oBorderProp.s && c_oAscBorderStyles.None !== oBorderProp.s) if(null != oBorderProp.s && c_oAscBorderStyles.None !== oBorderProp.s)
{ {
this.s = oBorderProp.s; this.s = oBorderProp.s;
this.w = oBorderProp.w;
if(null != oBorderProp.c) if(null != oBorderProp.c)
this.c = oBorderProp.c; this.c = oBorderProp.c;
} }
...@@ -801,14 +830,7 @@ Border.prototype = ...@@ -801,14 +830,7 @@ Border.prototype =
this.dd = g_oDefaultBorder.dd; this.dd = g_oDefaultBorder.dd;
this.du = g_oDefaultBorder.du; this.du = g_oDefaultBorder.du;
}, },
set : function(border)
{
//border может быть не класса Border
this.clean();
this.mergeInner(border);
},
mergeInner : function(border){ mergeInner : function(border){
//border может быть не класса Border
if(border){ if(border){
if(border.l) if(border.l)
this.l.merge(border.l); this.l.merge(border.l);
......
This diff is collapsed.
...@@ -740,44 +740,6 @@ ...@@ -740,44 +740,6 @@
this.bIsReInit = false; this.bIsReInit = false;
} }
/** @constructor */
function CBorderUtils () {
/**
* cell border styles
* @const
*/
this.kcbThick = c_oAscBorderStyles.Thick;
this.kcbThin = c_oAscBorderStyles.Thin;
this.kcbMedium = c_oAscBorderStyles.Medium;
this.kcbDashDot = c_oAscBorderStyles.DashDot;
this.kcbDashDotDot = c_oAscBorderStyles.DashDotDot;
this.kcbDashed = c_oAscBorderStyles.Dashed;
this.kcbDotted = c_oAscBorderStyles.Dotted;
this.kcbDouble = c_oAscBorderStyles.Double;
this.kcbHair = c_oAscBorderStyles.Hair;
this.kcbMediumDashDot = c_oAscBorderStyles.MediumDashDot;
this.kcbMediumDashDotDot = c_oAscBorderStyles.MediumDashDotDot;
this.kcbMediumDashed = c_oAscBorderStyles.MediumDashed;
this.kcbSlantDashDot = c_oAscBorderStyles.SlantDashDot;
this.kcbThinBorders = [this.kcbThin, this.kcbDashDot, this.kcbDashDotDot, this.kcbDashed, this.kcbDotted, this.kcbHair];
this.kcbMediumBorders = [this.kcbMedium, this.kcbMediumDashDot, this.kcbMediumDashDotDot, this.kcbMediumDashed, this.kcbSlantDashDot];
this.kcbThickBorders = [this.kcbThick, this.kcbDouble];
}
CBorderUtils.prototype = {
_isThinBorder : function (bs) { return $.inArray(bs, this.kcbThinBorders) >= 0; },
_isMediumBorder : function (bs) { return $.inArray(bs, this.kcbMediumBorders) >= 0; },
_isThickBorder : function (bs) { return $.inArray(bs, this.kcbThickBorders) >= 0; },
calcBorderWidth : function (b) {
var s = b.s;
return b === undefined ? 0 : (
this._isThinBorder(s) ? 1 : (
this._isMediumBorder(s) ? 2 : (
this._isThickBorder(s) ? 3 : 0)));
}
};
/** @constructor */ /** @constructor */
function asc_CStyleImage(name, thumbnailOffset, type) { function asc_CStyleImage(name, thumbnailOffset, type) {
this.name = name; this.name = name;
...@@ -806,8 +768,6 @@ ...@@ -806,8 +768,6 @@
this.styleThumbnailHeight = 18; this.styleThumbnailHeight = 18;
this.styleThumbnailWidthPt = this.styleThumbnailWidth * 72 / 96; this.styleThumbnailWidthPt = this.styleThumbnailWidth * 72 / 96;
this.styleThumbnailHeightPt = this.styleThumbnailHeight * 72 / 96; this.styleThumbnailHeightPt = this.styleThumbnailHeight * 72 / 96;
this.oBorderUtils = new CBorderUtils();
} }
asc_CStylesPainter.prototype = { asc_CStylesPainter.prototype = {
...@@ -886,18 +846,15 @@ ...@@ -886,18 +846,15 @@
oGraphics.rect(0, nOffsetY, this.styleThumbnailWidthPt, this.styleThumbnailHeightPt).clip(); oGraphics.rect(0, nOffsetY, this.styleThumbnailWidthPt, this.styleThumbnailHeightPt).clip();
oGraphics.fill(); oGraphics.fill();
var bc, bw; var bc;
var t = this; var t = this;
var drawBorder = function (b, x1, y1, x2, y2) { var drawBorder = function (b, x1, y1, x2, y2) {
if (null != b && c_oAscBorderStyles.None !== b.s) { if (null != b && c_oAscBorderStyles.None !== b.s) {
bc = asc.numberToCSSColor(b.c.getRgb()); bc = asc.numberToCSSColor(b.c.getRgb());
oGraphics.setStrokeStyle(bc); oGraphics.setStrokeStyle(bc);
bw = t.oBorderUtils.calcBorderWidth(b); // ToDo поправить
if (0 < bw) { oGraphics.setLineWidth(b.w).beginPath().moveTo(x1, y1).lineTo(x2, y2).stroke();
// ToDo поправить
oGraphics.setLineWidth(bw).beginPath().moveTo(x1, y1).lineTo(x2, y2).stroke();
}
} }
}; };
...@@ -1057,10 +1014,6 @@ ...@@ -1057,10 +1014,6 @@
prot["asc_setShowGridLines"] = prot.asc_setShowGridLines; prot["asc_setShowGridLines"] = prot.asc_setShowGridLines;
prot["asc_setShowRowColHeaders"] = prot.asc_setShowRowColHeaders; prot["asc_setShowRowColHeaders"] = prot.asc_setShowRowColHeaders;
window["Asc"].CBorderUtils = CBorderUtils;
prot = CBorderUtils.prototype;
prot["calcBorderWidth"] = prot.calcBorderWidth;
window["Asc"]["asc_CStyleImage"] = window["Asc"].asc_CStyleImage = asc_CStyleImage; window["Asc"]["asc_CStyleImage"] = window["Asc"].asc_CStyleImage = asc_CStyleImage;
prot = asc_CStyleImage.prototype; prot = asc_CStyleImage.prototype;
prot["asc_getName"] = prot.asc_getName; prot["asc_getName"] = prot.asc_getName;
......
...@@ -75,28 +75,7 @@ ...@@ -75,28 +75,7 @@
var kvaCenter = "center"; var kvaCenter = "center";
var kvaBottom = "bottom"; var kvaBottom = "bottom";
/** var kNone = "none";
* cell border styles
* @const
*/
var kcbNone = "none";
var kcbThick = c_oAscBorderStyles.Thick;
var kcbThin = c_oAscBorderStyles.Thin;
var kcbMedium = c_oAscBorderStyles.Medium;
var kcbDashDot = c_oAscBorderStyles.DashDot;
var kcbDashDotDot = c_oAscBorderStyles.DashDotDot;
var kcbDashed = c_oAscBorderStyles.Dashed;
var kcbDotted = c_oAscBorderStyles.Dotted;
var kcbDouble = c_oAscBorderStyles.Double;
var kcbHair = c_oAscBorderStyles.Hair;
var kcbMediumDashDot = c_oAscBorderStyles.MediumDashDot;
var kcbMediumDashDotDot = c_oAscBorderStyles.MediumDashDotDot;
var kcbMediumDashed = c_oAscBorderStyles.MediumDashed;
var kcbSlantDashDot = c_oAscBorderStyles.SlantDashDot;
var kcbThinBorders = [kcbThin, kcbDashDot, kcbDashDotDot, kcbDashed, kcbDotted, kcbHair];
var kcbMediumBorders = [kcbMedium, kcbMediumDashDot, kcbMediumDashDotDot, kcbMediumDashed, kcbSlantDashDot];
var kcbThickBorders = [kcbThick, kcbDouble];
/** /**
* cursor styles * cursor styles
...@@ -4011,13 +3990,12 @@ ...@@ -4011,13 +3990,12 @@
} }
function makeBorder(border, type, isActive) { function makeBorder(border, type, isActive) {
var tmpBorder = self._getBorderPropById(border, type);
return new CellBorder( return new CellBorder(
self._getBorderPropById( border, type ).s, tmpBorder.s, tmpBorder.c, tmpBorder.w,
self._getBorderPropById( border, type ).c, type === kcbidLeft ? self._isLeftBorderErased(col, row) : (type === kcbidRight ?
self._calcBorderWidth( self._getBorderPropById( border, type ) ), self._isRightBorderErased(col, row) : false),
type === kcbidLeft ? self._isLeftBorderErased(col, row) : (type === kcbidRight ? isActive !== undefined ? isActive : false);
self._isRightBorderErased(col, row) : false),
isActive !== undefined ? isActive : false);
} }
var cc = self._fetchCellCache(col, row); var cc = self._fetchCellCache(col, row);
...@@ -4149,7 +4127,7 @@ ...@@ -4149,7 +4127,7 @@
_getCellFlags: function (col, row) { _getCellFlags: function (col, row) {
var c = row !== undefined ? this._getCell(col, row) : col; var c = row !== undefined ? this._getCell(col, row) : col;
var fl = {wrapText: false, shrinkToFit: false, isMerged: false, textAlign: kcbNone}; var fl = {wrapText: false, shrinkToFit: false, isMerged: false, textAlign: kNone};
if (c !== undefined) { if (c !== undefined) {
fl.wrapText = c.getWrap(); fl.wrapText = c.getWrap();
fl.shrinkToFit = c.getShrinkToFit(); fl.shrinkToFit = c.getShrinkToFit();
...@@ -4192,26 +4170,6 @@ ...@@ -4192,26 +4170,6 @@
return c.getValue().search(/[^ ]/) < 0; return c.getValue().search(/[^ ]/) < 0;
}, },
_isThinBorder: function (bs) {
return $.inArray(bs, kcbThinBorders) >= 0;
},
_isMediumBorder: function (bs) {
return $.inArray(bs, kcbMediumBorders) >= 0;
},
_isThickBorder: function (bs) {
return $.inArray(bs, kcbThickBorders) >= 0;
},
_calcBorderWidth: function (b) {
var s = b.s;
return b === undefined ? 0 : (
this._isThinBorder(s) ? 1 : (
this._isMediumBorder(s) ? 2 : (
this._isThickBorder(s) ? 3 : 0)));
},
_getRange: function (c1, r1, c2, r2) { _getRange: function (c1, r1, c2, r2) {
return this.model.getRange3(r1, c1, r2, c2); return this.model.getRange3(r1, c1, r2, c2);
}, },
...@@ -6903,20 +6861,19 @@ ...@@ -6903,20 +6861,19 @@
} }
var isLargeRange = t._isLargeRange(range), callTrigger = false; var isLargeRange = t._isLargeRange(range), callTrigger = false;
var res, flag; var res;
var mc, r, c, cell; var mc, r, c, cell;
function makeBorder(b) { function makeBorder(b) {
var border = {}; var border = new BorderProp();
if (b === false) { if (b === false) {
border.s = c_oAscBorderStyles.None; border.setStyle(c_oAscBorderStyles.None);
} else if (b) { } else if (b) {
if (b.style !== null && b.style !== undefined) {border.s = b.style;} if (b.style !== null && b.style !== undefined) {border.setStyle(b.style);}
if (b.color !== null && b.color !== undefined) { if (b.color !== null && b.color !== undefined) {
if(b.color instanceof CAscColor) if(b.color instanceof CAscColor)
border.c = CorrectAscColor(b.color); border.c = CorrectAscColor(b.color);
} }
flag = flag || (b.width === null || b.style === null || b.color === null);
} }
return border; return border;
} }
...@@ -6945,13 +6902,12 @@ ...@@ -6945,13 +6902,12 @@
case "border": case "border":
if (isLargeRange) { callTrigger = true; t._trigger("slowOperation", true); } if (isLargeRange) { callTrigger = true; t._trigger("slowOperation", true); }
res = {};
flag = false;
// None // None
if (val.length < 1) { if (val.length < 1) {
range.setBorder(null); range.setBorder(null);
break; break;
} }
res = new Border();
// Diagonal // Diagonal
res.d = makeBorder( val[c_oAscBorderOptions.DiagD] || val[c_oAscBorderOptions.DiagU] ); res.d = makeBorder( val[c_oAscBorderOptions.DiagD] || val[c_oAscBorderOptions.DiagU] );
res.dd = val[c_oAscBorderOptions.DiagD] ? true : false; res.dd = val[c_oAscBorderOptions.DiagD] ? true : false;
...@@ -6965,7 +6921,7 @@ ...@@ -6965,7 +6921,7 @@
res.ih = makeBorder( val[c_oAscBorderOptions.InnerH] ); res.ih = makeBorder( val[c_oAscBorderOptions.InnerH] );
res.b = makeBorder( val[c_oAscBorderOptions.Bottom] ); res.b = makeBorder( val[c_oAscBorderOptions.Bottom] );
// Change border // Change border
range.setBorder(res, flag); range.setBorder(res);
break; break;
case "merge": case "merge":
if (isLargeRange) { callTrigger = true; t._trigger("slowOperation", true); } if (isLargeRange) { callTrigger = true; t._trigger("slowOperation", true); }
...@@ -7374,8 +7330,6 @@ ...@@ -7374,8 +7330,6 @@
{ {
var range = t.model.getRange3(r + autoR*plRow, c + autoC*plCol, r + autoR*plRow, c + autoC*plCol); var range = t.model.getRange3(r + autoR*plRow, c + autoC*plCol, r + autoR*plRow, c + autoC*plCol);
var res, flag, v;
var currentObj = values[r][c][0]; var currentObj = values[r][c][0];
if( currentObj.length === 1 ){ if( currentObj.length === 1 ){
//if(!isMultiple) //if(!isMultiple)
...@@ -7426,11 +7380,11 @@ ...@@ -7426,11 +7380,11 @@
} }
if(currentObj.length === 1 && currentObj[0].format.fs !== '' && currentObj[0].format.fs !== null && currentObj[0].format.fs !== undefined) if(currentObj.length === 1 && currentObj[0].format.fs !== '' && currentObj[0].format.fs !== null && currentObj[0].format.fs !== undefined)
range.setFontsize(currentObj[0].format.fs) range.setFontsize(currentObj[0].format.fs);
if(!isOneMerge) if(!isOneMerge)
range.setAlignHorizontal(currentObj.a); range.setAlignHorizontal(currentObj.a);
var isMerged = false; var isMerged = false;
for(mergeCheck = 0; mergeCheck < mergeArr.length; ++mergeCheck) for(var mergeCheck = 0; mergeCheck < mergeArr.length; ++mergeCheck)
{ {
if(r + 1 + autoR*plRow <= mergeArr[mergeCheck].r2 && r + 1 + autoR*plRow >= mergeArr[mergeCheck].r1 && c + autoC*plCol + 1 <= mergeArr[mergeCheck].c2 && c + 1 + autoC*plCol >= mergeArr[mergeCheck].c1) if(r + 1 + autoR*plRow <= mergeArr[mergeCheck].r2 && r + 1 + autoR*plRow >= mergeArr[mergeCheck].r1 && c + autoC*plCol + 1 <= mergeArr[mergeCheck].c2 && c + 1 + autoC*plCol >= mergeArr[mergeCheck].c1)
isMerged = true; isMerged = true;
...@@ -7451,9 +7405,8 @@ ...@@ -7451,9 +7405,8 @@
range.setValue(''); range.setValue('');
range.merge(c_oAscMergeOptions.Merge); range.merge(c_oAscMergeOptions.Merge);
} }
//range.setBorder(null);
if(!isOneMerge) if(!isOneMerge)
range.setBorderSrc(currentObj.borders, false); range.setBorderSrc(currentObj.borders);
range.setWrap(currentObj.wrap); range.setWrap(currentObj.wrap);
if(currentObj.bc && currentObj.bc != 'rgba(0, 0, 0, 0)' && currentObj.bc != 'transparent' && '' != currentObj.bc && !isOneMerge) if(currentObj.bc && currentObj.bc != 'rgba(0, 0, 0, 0)' && currentObj.bc != 'transparent' && '' != currentObj.bc && !isOneMerge)
range.setFill(new RgbColor(asc_parsecolor(currentObj.bc).binary)); range.setFill(new RgbColor(asc_parsecolor(currentObj.bc).binary));
...@@ -7756,7 +7709,7 @@ ...@@ -7756,7 +7709,7 @@
if(!isOneMerge) if(!isOneMerge)
range.setAlignHorizontal(newVal.horAlign); range.setAlignHorizontal(newVal.horAlign);
if(!isOneMerge) if(!isOneMerge)
range.setBorderSrc(newVal.borders, false); range.setBorderSrc(newVal.borders);
var nameFormat; var nameFormat;
/*if(newVal.format.oPositiveFormat) /*if(newVal.format.oPositiveFormat)
......
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