Commit 3a718e12 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Теперь Font у DrawingContext обязательный параметр (Font теперь общий на все...

Теперь Font у DrawingContext обязательный параметр (Font теперь общий на все DrawingContext-ы в документе, т.к. они пользуют одни FontManager-ы)
Баг http://bugzserver/show_bug.cgi?id=19784

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@52014 954022d7-b5bf-4e40-9824-e11837661b57
parent 3793ec5c
...@@ -501,8 +501,7 @@ function DrawingContext(settings) { ...@@ -501,8 +501,7 @@ function DrawingContext(settings) {
return new DrawingContext(settings); return new DrawingContext(settings);
} }
if (undefined !== settings) this.setCanvas(settings.canvas);
this.setCanvas(settings.canvas);
var ppiTest = var ppiTest =
$('<div style="position: absolute; width: 10in; height:10in; visibility:hidden; padding:0;"/>') $('<div style="position: absolute; width: 10in; height:10in; visibility:hidden; padding:0;"/>')
...@@ -523,13 +522,15 @@ function DrawingContext(settings) { ...@@ -523,13 +522,15 @@ function DrawingContext(settings) {
this._1px_x = getCvtRatio(0/*px*/, 3/*mm*/, this.ppiX); this._1px_x = getCvtRatio(0/*px*/, 3/*mm*/, this.ppiX);
this._1px_y = getCvtRatio(0/*px*/, 3/*mm*/, this.ppiY); this._1px_y = getCvtRatio(0/*px*/, 3/*mm*/, this.ppiY);
this.units = 3/*mm*/; this.units = 3/*mm*/;
this.changeUnits( settings !== undefined && settings.units !== undefined ? settings.units : this.units ); this.changeUnits(undefined !== settings.units ? settings.units : this.units);
this.fmgrGraphics = undefined !== settings.fmgrGraphics ? settings.fmgrGraphics : null; this.fmgrGraphics = undefined !== settings.fmgrGraphics ? settings.fmgrGraphics : null;
if (null === this.fmgrGraphics) {return null;} if (null === this.fmgrGraphics) {return null;}
/** @type FontProperties */ /** @type FontProperties */
this.font = settings !== undefined && settings.font !== undefined ? settings.font : new FontProperties("Arial", 11); this.font = undefined !== settings.font ? settings.font : null;
// Font должен быть передан (он общий для всех DrawingContext, т.к. может возникнуть ситуация как в баге http://bugzserver/show_bug.cgi?id=19784)
if (null === this.font) {return null;}
// CColor // CColor
this.fillColor = new CColor(255, 255, 255); this.fillColor = new CColor(255, 255, 255);
......
...@@ -778,11 +778,11 @@ ...@@ -778,11 +778,11 @@
asc_getDocStyles: function () { return this.docStyles; }, asc_getDocStyles: function () { return this.docStyles; },
asc_getDefaultStylesImage: function () { return this.defaultStylesImage; }, asc_getDefaultStylesImage: function () { return this.defaultStylesImage; },
asc_getDocStylesImage: function () { return this.docStylesImage; }, asc_getDocStylesImage: function () { return this.docStylesImage; },
generateStylesAll: function (cellStylesAll, fmgrGraphics, stringRenderer) { generateStylesAll: function (cellStylesAll, fmgrGraphics, oFont, stringRenderer) {
this.generateDefaultStyles(cellStylesAll, fmgrGraphics, stringRenderer); this.generateDefaultStyles(cellStylesAll, fmgrGraphics, oFont, stringRenderer);
this.generateDocumentStyles(cellStylesAll, fmgrGraphics, stringRenderer); this.generateDocumentStyles(cellStylesAll, fmgrGraphics, oFont, stringRenderer);
}, },
generateDefaultStyles: function (cellStylesAll, fmgrGraphics, stringRenderer) { generateDefaultStyles: function (cellStylesAll, fmgrGraphics, oFont, stringRenderer) {
var nDefaultStylesCount = cellStylesAll.getDefaultStylesCount(); var nDefaultStylesCount = cellStylesAll.getDefaultStylesCount();
var cellStyles = cellStylesAll.DefaultStyles; var cellStyles = cellStylesAll.DefaultStyles;
var nLength = cellStyles.length; var nLength = cellStyles.length;
...@@ -793,7 +793,7 @@ ...@@ -793,7 +793,7 @@
ctx.fillStyle = "#FFFFFF"; ctx.fillStyle = "#FFFFFF";
ctx.fillRect(0, 0, oCanvas.width, oCanvas.height); ctx.fillRect(0, 0, oCanvas.width, oCanvas.height);
var oGraphics = asc.DrawingContext({canvas: oCanvas, units: 1/*pt*/, fmgrGraphics: fmgrGraphics}); var oGraphics = asc.DrawingContext({canvas: oCanvas, units: 1/*pt*/, fmgrGraphics: fmgrGraphics, font: oFont});
var oStyle = null; var oStyle = null;
this.defaultStyles = []; this.defaultStyles = [];
...@@ -808,7 +808,7 @@ ...@@ -808,7 +808,7 @@
this.defaultStylesImage = (0 === styleIndex) ? "" : oCanvas.toDataURL("image/png"); this.defaultStylesImage = (0 === styleIndex) ? "" : oCanvas.toDataURL("image/png");
}, },
generateDocumentStyles: function (cellStylesAll, fmgrGraphics, stringRenderer) { generateDocumentStyles: function (cellStylesAll, fmgrGraphics, oFont, stringRenderer) {
var nDocumentStylesCount = cellStylesAll.getCustomStylesCount(); var nDocumentStylesCount = cellStylesAll.getCustomStylesCount();
var cellStyles = cellStylesAll.CustomStyles; var cellStyles = cellStylesAll.CustomStyles;
var nLength = cellStyles.length; var nLength = cellStyles.length;
...@@ -819,7 +819,7 @@ ...@@ -819,7 +819,7 @@
ctx.fillStyle = "#FFFFFF"; ctx.fillStyle = "#FFFFFF";
ctx.fillRect(0, 0, oCanvas.width, oCanvas.height); ctx.fillRect(0, 0, oCanvas.width, oCanvas.height);
var oGraphics = asc.DrawingContext({canvas: oCanvas, units: 1/*pt*/, fmgrGraphics: fmgrGraphics}); var oGraphics = asc.DrawingContext({canvas: oCanvas, units: 1/*pt*/, fmgrGraphics: fmgrGraphics, font: oFont});
var oStyle = null; var oStyle = null;
this.docStyles = []; this.docStyles = [];
......
...@@ -77,10 +77,11 @@ ...@@ -77,10 +77,11 @@
* @param {Element} elem * @param {Element} elem
* @param {Element} input * @param {Element} input
* @param {Array} fmgrGraphics * @param {Array} fmgrGraphics
* @param {FontProperties} oFont
* @param {HandlersList} handlers * @param {HandlersList} handlers
* @param {Object} settings See CellEditor.defaults * @param {Object} settings See CellEditor.defaults
*/ */
function CellEditor(elem, input, fmgrGraphics, handlers, settings) { function CellEditor(elem, input, fmgrGraphics, oFont, handlers, settings) {
if ( !(this instanceof CellEditor) ) {return new CellEditor(elem, input, fmgrGraphics, handlers, settings);} if ( !(this instanceof CellEditor) ) {return new CellEditor(elem, input, fmgrGraphics, handlers, settings);}
this.element = elem; this.element = elem;
...@@ -96,6 +97,7 @@ ...@@ -96,6 +97,7 @@
this.cursorTID = undefined; this.cursorTID = undefined;
this.cursorPos = 0; this.cursorPos = 0;
this.topLineIndex = 0; this.topLineIndex = 0;
this.m_oFont = oFont;
this.fmgrGraphics = fmgrGraphics; this.fmgrGraphics = fmgrGraphics;
this.drawingCtx = undefined; this.drawingCtx = undefined;
this.overlayCtx = undefined; this.overlayCtx = undefined;
...@@ -187,8 +189,8 @@ ...@@ -187,8 +189,8 @@
} }
// create text render // create text render
t.drawingCtx = asc_DC({canvas: t.canvas[0], units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics}); t.drawingCtx = asc_DC({canvas: t.canvas[0], units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics, font: this.m_oFont});
t.overlayCtx = asc_DC({canvas: t.canvasOverlay[0], units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics}); t.overlayCtx = asc_DC({canvas: t.canvasOverlay[0], units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics, font: this.m_oFont});
t.textRender = asc_TR(t.drawingCtx); t.textRender = asc_TR(t.drawingCtx);
t.textRender.setDefaultFont(t.settings.font.clone()); t.textRender.setDefaultFont(t.settings.font.clone());
......
...@@ -73,6 +73,9 @@ ...@@ -73,6 +73,9 @@
this._lockDraw = false; this._lockDraw = false;
// Фонт, который выставлен в DrawingContext, он должен быть один на все DrawingContext-ы
this.m_oFont = new asc_FP(this.model.getDefaultFont(), this.model.getDefaultSize());
// Теперь у нас 2 FontManager-а на весь документ + 1 для автофигур (а не на каждом листе свой) // Теперь у нас 2 FontManager-а на весь документ + 1 для автофигур (а не на каждом листе свой)
this.fmgrGraphics = []; // FontManager for draw (1 для обычного + 1 для поворотного текста) this.fmgrGraphics = []; // FontManager for draw (1 для обычного + 1 для поворотного текста)
this.fmgrGraphics.push(new CFontManager()); // Для обычного this.fmgrGraphics.push(new CFontManager()); // Для обычного
...@@ -137,12 +140,14 @@ ...@@ -137,12 +140,14 @@
.attr("width", outer.width()) .attr("width", outer.width())
.attr("height", outer.height()); .attr("height", outer.height());
this.buffers.main = asc_DC({canvas: this.canvas[0], units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics}); this.buffers.main = asc_DC({canvas: this.canvas[0], units: 1/*pt*/,
this.buffers.overlay = asc_DC({canvas: this.canvasOverlay[0], units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics}); fmgrGraphics: this.fmgrGraphics, font: this.m_oFont});
this.buffers.overlay = asc_DC({canvas: this.canvasOverlay[0], units: 1/*pt*/,
fmgrGraphics: this.fmgrGraphics, font: this.m_oFont});
this.buffers.overlay.ctx.isOverlay = true; // Для разруливания _activateOverlayCtx / _deactivateOverlayCtx this.buffers.overlay.ctx.isOverlay = true; // Для разруливания _activateOverlayCtx / _deactivateOverlayCtx
this.drawingCtx = this.buffers.main; this.drawingCtx = this.buffers.main;
this.overlayCtx = this.buffers.overlay; this.overlayCtx = this.buffers.overlay;
// Shapes // Shapes
this.buffers.shapeCtx = new CGraphics(); this.buffers.shapeCtx = new CGraphics();
...@@ -153,7 +158,7 @@ ...@@ -153,7 +158,7 @@
this.buffers.shapeOverlayCtx.init(this.overlayCtx.ctx, this.overlayCtx.getWidth(0), this.overlayCtx.getHeight(0), this.overlayCtx.getWidth(3), this.overlayCtx.getHeight(3)); this.buffers.shapeOverlayCtx.init(this.overlayCtx.ctx, this.overlayCtx.getWidth(0), this.overlayCtx.getHeight(0), this.overlayCtx.getWidth(3), this.overlayCtx.getHeight(3));
this.buffers.shapeOverlayCtx.m_oFontManager = this.fmgrGraphics[2]; this.buffers.shapeOverlayCtx.m_oFontManager = this.fmgrGraphics[2];
this.drawingCtxCharts = asc_DC({units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics}); this.drawingCtxCharts = asc_DC({units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics, font: this.m_oFont});
this.stringRender = asc_SR(this.buffers.main); this.stringRender = asc_SR(this.buffers.main);
this.stringRender.setDefaultFont(this.defaultFont); this.stringRender.setDefaultFont(this.defaultFont);
...@@ -345,7 +350,7 @@ ...@@ -345,7 +350,7 @@
} }
}); });
this.cellEditor = new asc_CE(this.element, this.input, this.fmgrGraphics, this.cellEditor = new asc_CE(this.element, this.input, this.fmgrGraphics, this.m_oFont,
/*handlers*/{ /*handlers*/{
"closed" : function () {self._onCloseCellEditor.apply(self, arguments);}, "closed" : function () {self._onCloseCellEditor.apply(self, arguments);},
"updated" : function () {self.handlers.trigger.apply(self.handlers, "updated" : function () {self.handlers.trigger.apply(self.handlers,
...@@ -974,7 +979,7 @@ ...@@ -974,7 +979,7 @@
getCellStyles: function () { getCellStyles: function () {
var oStylesPainter = new asc_CSP(); var oStylesPainter = new asc_CSP();
oStylesPainter.generateStylesAll(this.model.CellStyles, this.fmgrGraphics, this.stringRender); oStylesPainter.generateStylesAll(this.model.CellStyles, this.fmgrGraphics, this.m_oFont, this.stringRender);
return oStylesPainter; return oStylesPainter;
}, },
......
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