Commit bb54214c authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Теперь у нас 2 FontManager-а на весь документ (а не по 2 на каждый лист + на CellEditor)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47322 954022d7-b5bf-4e40-9824-e11837661b57
parent aa99fba8
...@@ -526,20 +526,13 @@ function DrawingContext(settings) { ...@@ -526,20 +526,13 @@ function DrawingContext(settings) {
this.units = 3/*mm*/; this.units = 3/*mm*/;
this.changeUnits( settings !== undefined && settings.units !== undefined ? settings.units : this.units ); this.changeUnits( settings !== undefined && settings.units !== undefined ? settings.units : this.units );
this.fontRenderingMode = c_oAscFontRenderingModeType.noHinting; this.fmgrGraphics = undefined !== settings.fmgrGraphics ? settings.fmgrGraphics : null;
if (null === this.fmgrGraphics) {return null;}
this.fmgrGraphics = []; // FontManager for draw (1 для обычного + 1 для поворотного текста)
this.fmgrGraphics.push(new CFontManager()); // Для обычного
this.fmgrGraphics.push(new CFontManager()); // Для поворотного
this.fmgrGraphics[0].Initialize(true); // IE memory enable
this.fmgrGraphics[1].Initialize(true); // IE memory enable
/** @type FontProperties */ /** @type FontProperties */
this.font = settings !== undefined && settings.font !== undefined ? settings.font : new FontProperties("Arial", 11); this.font = settings !== undefined && settings.font !== undefined ? settings.font : new FontProperties("Arial", 11);
this.fillColor = {r: 255, g: 255, b: 255, a: 255}; this.fillColor = {r: 255, g: 255, b: 255, a: 255};
this._init(settings.fontRenderingMode);
return this; return this;
} }
...@@ -548,11 +541,6 @@ DrawingContext.prototype = { ...@@ -548,11 +541,6 @@ DrawingContext.prototype = {
/** @type DrawingContext */ /** @type DrawingContext */
constructor: DrawingContext, constructor: DrawingContext,
_init: function (fontRenderingMode) {
// Изначально мы инициализируем c_oAscFontRenderingModeType.noHinting
this.setFontRenderingMode(fontRenderingMode);
},
/** /**
* Returns width of drawing context in current units * Returns width of drawing context in current units
* @param {Number} units Единицы измерения (0=px, 1=pt, 2=in, 3=mm) в которых будет возвращена ширина * @param {Number} units Единицы измерения (0=px, 1=pt, 2=in, 3=mm) в которых будет возвращена ширина
...@@ -1186,54 +1174,7 @@ DrawingContext.prototype = { ...@@ -1186,54 +1174,7 @@ DrawingContext.prototype = {
b = fm.m_lAscender * factor, b = fm.m_lAscender * factor,
d = Math.abs(fm.m_lDescender * factor); d = Math.abs(fm.m_lDescender * factor);
return new TextMetrics(w, b + d, l, b, d, this.font.FontSize, 0, wBB); return new TextMetrics(w, b + d, l, b, d, this.font.FontSize, 0, wBB);
}, }
/*
* @param {c_oAscRenderingModeType} mode Режим отрисовки
*/
setFontRenderingMode: function (mode) {
if (mode !== this.fontRenderingMode) {
this.fontRenderingMode = mode;
if (c_oAscFontRenderingModeType.noHinting === mode)
this._setHintsProps(false, false);
else if (c_oAscFontRenderingModeType.hinting === mode)
this._setHintsProps(true, false);
else if (c_oAscFontRenderingModeType.hintingAndSubpixeling === mode)
this._setHintsProps(true, true);
}
},
_setHintsProps: function (bIsHinting, bIsSubpixHinting) {
var index, manager, hintProps;
for (index in this.fmgrGraphics) {
if (!this.fmgrGraphics.hasOwnProperty(index))
continue;
manager = this.fmgrGraphics[index];
hintProps = manager.m_oLibrary.tt_hint_props;
if (!hintProps)
continue;
if (bIsHinting && bIsSubpixHinting) {
hintProps.TT_USE_BYTECODE_INTERPRETER = true;
hintProps.TT_CONFIG_OPTION_SUBPIXEL_HINTING = true;
manager.LOAD_MODE = 40968;
} else if (bIsHinting) {
hintProps.TT_USE_BYTECODE_INTERPRETER = true;
hintProps.TT_CONFIG_OPTION_SUBPIXEL_HINTING = false;
manager.LOAD_MODE = 40968;
} else {
hintProps.TT_USE_BYTECODE_INTERPRETER = true;
hintProps.TT_CONFIG_OPTION_SUBPIXEL_HINTING = false;
manager.LOAD_MODE = 40970;
}
manager.ClearFontsRasterCache();
}
}
}; };
......
...@@ -76,11 +76,12 @@ ...@@ -76,11 +76,12 @@
* @constructor * @constructor
* @param {Element} elem * @param {Element} elem
* @param {Element} input * @param {Element} input
* @param {Array} fmgrGraphics
* @param {HandlersList} handlers * @param {HandlersList} handlers
* @param {Object} settings See CellEditor.defaults * @param {Object} settings See CellEditor.defaults
*/ */
function CellEditor(elem, input, fontRenderingMode, handlers, settings) { function CellEditor(elem, input, fmgrGraphics, handlers, settings) {
if ( !(this instanceof CellEditor) ) {return new CellEditor(elem, input, fontRenderingMode, handlers, settings);} if ( !(this instanceof CellEditor) ) {return new CellEditor(elem, input, fmgrGraphics, handlers, settings);}
this.element = elem; this.element = elem;
this.input = input; this.input = input;
...@@ -95,7 +96,7 @@ ...@@ -95,7 +96,7 @@
this.cursorTID = undefined; this.cursorTID = undefined;
this.cursorPos = 0; this.cursorPos = 0;
this.topLineIndex = 0; this.topLineIndex = 0;
this.fontRenderingMode = fontRenderingMode; this.fmgrGraphics = fmgrGraphics;
this.drawingCtx = undefined; this.drawingCtx = undefined;
this.overlayCtx = undefined; this.overlayCtx = undefined;
this.textRender = undefined; this.textRender = undefined;
...@@ -184,8 +185,8 @@ ...@@ -184,8 +185,8 @@
} }
// create text render // create text render
t.drawingCtx = asc_DC({canvas: t.canvas[0], units: 1/*pt*/, fontRenderingMode: this.fontRenderingMode}); t.drawingCtx = asc_DC({canvas: t.canvas[0], units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics});
t.overlayCtx = asc_DC({canvas: t.canvasOverlay[0], units: 1/*pt*/}); t.overlayCtx = asc_DC({canvas: t.canvasOverlay[0], units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics});
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());
...@@ -601,13 +602,9 @@ ...@@ -601,13 +602,9 @@
this._addChars(newText); this._addChars(newText);
}, },
setFontRenderingMode: function (mode) { setFontRenderingMode: function () {
if (mode !== this.fontRenderingMode) { if (this.isOpened)
this.fontRenderingMode = mode; this._draw();
this.drawingCtx.setFontRenderingMode(mode);
if (this.isOpened)
this._draw();
}
}, },
......
...@@ -66,9 +66,17 @@ ...@@ -66,9 +66,17 @@
this.wsViews = []; this.wsViews = [];
this.cellEditor = undefined; this.cellEditor = undefined;
this.fontRenderingMode = fontRenderingMode; this.fontRenderingMode = fontRenderingMode;
//-----------------------
this._lockDraw = false; this._lockDraw = false;
// Теперь у нас 2 FontManager-а на весь документ (а не на каждом листе свой)
this.fmgrGraphics = []; // FontManager for draw (1 для обычного + 1 для поворотного текста)
this.fmgrGraphics.push(new CFontManager()); // Для обычного
this.fmgrGraphics.push(new CFontManager()); // Для поворотного
this.fmgrGraphics[0].Initialize(true); // IE memory enable
this.fmgrGraphics[1].Initialize(true); // IE memory enable
//-----------------------
this.init(); this.init();
...@@ -233,7 +241,7 @@ ...@@ -233,7 +241,7 @@
} }
}); });
this.cellEditor = new asc_CE(this.element, this.input, this.fontRenderingMode, this.cellEditor = new asc_CE(this.element, this.input, this.fmgrGraphics,
/*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,
...@@ -295,7 +303,7 @@ ...@@ -295,7 +303,7 @@
"setAutoFiltersDialog" : function (arrVal) {self.handlers.trigger("asc_onSetAFDialog", arrVal);}, "setAutoFiltersDialog" : function (arrVal) {self.handlers.trigger("asc_onSetAFDialog", arrVal);},
"selectionRangeChanged" : function (val) {self.handlers.trigger("asc_onSelectionRangeChanged", val);} "selectionRangeChanged" : function (val) {self.handlers.trigger("asc_onSelectionRangeChanged", val);}
}); });
return new asc_WSV(wsModel, this.canvas[0], this.canvasOverlay[0], this.collaborativeEditing, this.fontRenderingMode, opt); return new asc_WSV(wsModel, this.canvas[0], this.canvasOverlay[0], this.collaborativeEditing, this.fmgrGraphics, opt);
}, },
_onSelectionNameChanged: function (name) { _onSelectionNameChanged: function (name) {
...@@ -1191,22 +1199,6 @@ ...@@ -1191,22 +1199,6 @@
} }
}, },
setFontRenderingMode: function (mode) {
var item, activeIndex;
if (mode !== this.fontRenderingMode) {
this.fontRenderingMode = mode;
activeIndex = this.model.getActive();
for(var i in this.wsViews) {
if (this.wsViews.hasOwnProperty(i)) {
item = this.wsViews[i];
item.setFontRenderingMode(mode, /*isDraw*/i == activeIndex);
}
}
this.cellEditor.setFontRenderingMode(mode);
}
},
setSelectDialogRangeMode: function (isSelectDialogRangeMode) { setSelectDialogRangeMode: function (isSelectDialogRangeMode) {
this.getWorksheet().setSelectDialogRangeMode(isSelectDialogRangeMode); this.getWorksheet().setSelectDialogRangeMode(isSelectDialogRangeMode);
}, },
...@@ -1318,6 +1310,59 @@ ...@@ -1318,6 +1310,59 @@
lockDraw: function(){ lockDraw: function(){
this._lockDraw = true; this._lockDraw = true;
},
/*
* @param {c_oAscRenderingModeType} mode Режим отрисовки
*/
setFontRenderingMode: function (mode) {
var ws;
if (mode !== this.fontRenderingMode) {
this.fontRenderingMode = mode;
if (c_oAscFontRenderingModeType.noHinting === mode)
this._setHintsProps(false, false);
else if (c_oAscFontRenderingModeType.hinting === mode)
this._setHintsProps(true, false);
else if (c_oAscFontRenderingModeType.hintingAndSubpixeling === mode)
this._setHintsProps(true, true);
ws = this.getWorksheet();
ws.draw();
this.cellEditor.setFontRenderingMode(mode);
}
},
_setHintsProps: function (bIsHinting, bIsSubpixHinting) {
var index, manager, hintProps;
for (index in this.fmgrGraphics) {
if (!this.fmgrGraphics.hasOwnProperty(index))
continue;
manager = this.fmgrGraphics[index];
hintProps = manager.m_oLibrary.tt_hint_props;
if (!hintProps)
continue;
if (bIsHinting && bIsSubpixHinting) {
hintProps.TT_USE_BYTECODE_INTERPRETER = true;
hintProps.TT_CONFIG_OPTION_SUBPIXEL_HINTING = true;
manager.LOAD_MODE = 40968;
} else if (bIsHinting) {
hintProps.TT_USE_BYTECODE_INTERPRETER = true;
hintProps.TT_CONFIG_OPTION_SUBPIXEL_HINTING = false;
manager.LOAD_MODE = 40968;
} else {
hintProps.TT_USE_BYTECODE_INTERPRETER = true;
hintProps.TT_CONFIG_OPTION_SUBPIXEL_HINTING = false;
manager.LOAD_MODE = 40970;
}
manager.ClearFontsRasterCache();
}
} }
}; };
......
...@@ -348,15 +348,15 @@ ...@@ -348,15 +348,15 @@
* @param {Object} canvas Canvas for drawing * @param {Object} canvas Canvas for drawing
* @param {Object} overlay Canvas for selection * @param {Object} overlay Canvas for selection
* @param {asc_CCollaborativeEditing} collaborativeEditing * @param {asc_CCollaborativeEditing} collaborativeEditing
* @param {c_oAscFontRenderingModeType} fontRenderingMode * @param {Array} fmgrGraphics
* @param {Object} settings Settings * @param {Object} settings Settings
* *
* @constructor * @constructor
* @memberOf Asc * @memberOf Asc
*/ */
function WorksheetView(model, canvas, overlay, collaborativeEditing, fontRenderingMode, settings) { function WorksheetView(model, canvas, overlay, collaborativeEditing, fmgrGraphics, settings) {
if ( !(this instanceof WorksheetView) ) { if ( !(this instanceof WorksheetView) ) {
return new WorksheetView(model, canvas, overlay, collaborativeEditing, fontRenderingMode, settings); return new WorksheetView(model, canvas, overlay, collaborativeEditing, fmgrGraphics, settings);
} }
this.settings = $.extend(true, {}, this.defaults, settings); this.settings = $.extend(true, {}, this.defaults, settings);
...@@ -370,12 +370,11 @@ ...@@ -370,12 +370,11 @@
this.model = model; this.model = model;
this.buffers = {}; this.buffers = {};
this.buffers.main = canvas.getPPIX ? canvas : asc_DC({canvas: canvas, units: 1/*pt*/, fontRenderingMode: fontRenderingMode}); this.buffers.main = canvas.getPPIX ? canvas : asc_DC({canvas: canvas, units: 1/*pt*/, fmgrGraphics: fmgrGraphics});
this.buffers.overlay = overlay ? asc_DC({canvas: overlay, units: 1/*pt*/, fontRenderingMode: fontRenderingMode}) : null; this.buffers.overlay = overlay ? asc_DC({canvas: overlay, units: 1/*pt*/, fmgrGraphics: fmgrGraphics}) : null;
this.drawingCtx = this.buffers.main; this.drawingCtx = this.buffers.main;
this.overlayCtx = this.buffers.overlay; this.overlayCtx = this.buffers.overlay;
this.fontRenderingMode = fontRenderingMode;
this.stringRender = asc_SR(this.drawingCtx); this.stringRender = asc_SR(this.drawingCtx);
this.stringRender.setDefaultFontFromFmt({fn: cells.fontName, fs: cells.fontSize}); this.stringRender.setDefaultFontFromFmt({fn: cells.fontName, fs: cells.fontSize});
...@@ -1147,25 +1146,27 @@ ...@@ -1147,25 +1146,27 @@
this.height_2px = asc_calcnpt(0, this._getPPIY(), 2/*px*/); this.height_2px = asc_calcnpt(0, this._getPPIY(), 2/*px*/);
this.height_3px = asc_calcnpt(0, this._getPPIY(), 3/*px*/); this.height_3px = asc_calcnpt(0, this._getPPIY(), 3/*px*/);
if (this.printMode) { // ToDo разобраться со значениями
// if (this.printMode) {
// Для печати используем алгоритм из спецификации // Для печати используем алгоритм из спецификации
// Ecma-376 Office Open XML Part 1, пункт 18.3.1.13 // Ecma-376 Office Open XML Part 1, пункт 18.3.1.13
this.maxNumWidth = asc_round( this.emSize * asc_getcvt( 1/*pt*/, 0/*px*/, this._getPPIX() ) ); // this.maxNumWidth = asc_round( this.emSize * asc_getcvt( 1/*pt*/, 0/*px*/, this._getPPIX() ) );
} else { // } else {
// Для отображения нужно более точное значение, иначе будут прыгать строки в ячейках // Для отображения нужно более точное значение, иначе будут прыгать строки в ячейках
// http://bugzserver/show_bug.cgi?id=15311 // http://bugzserver/show_bug.cgi?id=15311
this.maxNumWidth = this.emSize * asc_getcvt( 1/*pt*/, 0/*px*/, this._getPPIX() ); this.maxNumWidth = this.emSize * asc_getcvt( 1/*pt*/, 0/*px*/, this._getPPIX() );
} // }
gc_dDefaultColWidthCharsAttribute = this._charCountToModelColWidth(gc_dDefaultColWidthChars, true); gc_dDefaultColWidthCharsAttribute = this._charCountToModelColWidth(gc_dDefaultColWidthChars, true);
this.defaultColWidth = this._modelColWidthToColWidth(gc_dDefaultColWidthCharsAttribute); this.defaultColWidth = this._modelColWidthToColWidth(gc_dDefaultColWidthCharsAttribute);
this.displayColWidth = this._modelColWidthToColWidth(gc_dDefaultColWidthCharsAttribute, true); this.displayColWidth = this._modelColWidthToColWidth(gc_dDefaultColWidthCharsAttribute, true);
this.maxRowHeight = asc_calcnpt( 409, this._getPPIY() ); this.maxRowHeight = asc_calcnpt( 409, this._getPPIY() );
if (this.printMode) { // ToDo разобраться со значениями
this.defaultRowHeight = asc_round( this.settings.cells.fontSize * this.vspRatio ); // if (this.printMode) {
} else { // this.defaultRowHeight = asc_round( this.settings.cells.fontSize * this.vspRatio );
// } else {
this.defaultRowHeight = asc_calcnpt( this.settings.cells.fontSize * this.vspRatio, this._getPPIY() ) + this.height_1px; this.defaultRowHeight = asc_calcnpt( this.settings.cells.fontSize * this.vspRatio, this._getPPIY() ) + this.height_1px;
} // }
this.defaultRowDescender = this._calcRowDescender(this.settings.cells.fontSize); this.defaultRowDescender = this._calcRowDescender(this.settings.cells.fontSize);
// calculate rows heights and visible rows // calculate rows heights and visible rows
...@@ -1778,29 +1779,7 @@ ...@@ -1778,29 +1779,7 @@
return arrResult; return arrResult;
}, },
drawForPrint: function (drawingCtx, printPagesData) { drawForPrint: function (drawingCtx, printPagesData) {
var p, sett = {}, w, h, cnv, ws;
// Копируем все опции, кроме обработчиков
for (p in this.settings) if (this.settings.hasOwnProperty(p)) {
if (typeof this.settings[p] === "function") {continue;}
sett[p] = asc_clone(this.settings[p]);
}
sett.printMode = true;
// Создаем канву для печати
w = this.drawingCtx.getWidth();
h = this.drawingCtx.getHeight();
cnv = $('<canvas width="' + w + '" height="' + h + '"/>')[0];
sett.objectRender = this.objectRender;
ws = new WorksheetView(this.model, cnv, null, null, this.fontRenderingMode, sett);
ws._print(drawingCtx, printPagesData);
},
_print: function (drawingCtx, printPagesData) {
var isAppBridge = (undefined != window['appBridge']); var isAppBridge = (undefined != window['appBridge']);
if (null === printPagesData) { if (null === printPagesData) {
...@@ -9157,16 +9136,6 @@ ...@@ -9157,16 +9136,6 @@
var ar = this.activeRange.clone(true); var ar = this.activeRange.clone(true);
this.autoFilters.sortColFilter(type, cellId, this, ar); this.autoFilters.sortColFilter(type, cellId, this, ar);
}, },
setFontRenderingMode: function (mode, isDraw) {
if (mode !== this.fontRenderingMode) {
this.fontRenderingMode = mode;
this.drawingCtx.setFontRenderingMode(mode);
this.overlayCtx.setFontRenderingMode(mode);
if (isDraw)
this.draw();
}
},
getAddFormatTableOptions: function(nameOption) getAddFormatTableOptions: function(nameOption)
{ {
......
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