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) {
this.units = 3/*mm*/;
this.changeUnits( settings !== undefined && settings.units !== undefined ? settings.units : this.units );
this.fontRenderingMode = c_oAscFontRenderingModeType.noHinting;
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.fmgrGraphics = undefined !== settings.fmgrGraphics ? settings.fmgrGraphics : null;
if (null === this.fmgrGraphics) {return null;}
/** @type FontProperties */
this.font = settings !== undefined && settings.font !== undefined ? settings.font : new FontProperties("Arial", 11);
this.fillColor = {r: 255, g: 255, b: 255, a: 255};
this._init(settings.fontRenderingMode);
return this;
}
......@@ -548,11 +541,6 @@ DrawingContext.prototype = {
/** @type DrawingContext */
constructor: DrawingContext,
_init: function (fontRenderingMode) {
// Изначально мы инициализируем c_oAscFontRenderingModeType.noHinting
this.setFontRenderingMode(fontRenderingMode);
},
/**
* Returns width of drawing context in current units
* @param {Number} units Единицы измерения (0=px, 1=pt, 2=in, 3=mm) в которых будет возвращена ширина
......@@ -1186,54 +1174,7 @@ DrawingContext.prototype = {
b = fm.m_lAscender * factor,
d = Math.abs(fm.m_lDescender * factor);
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 @@
* @constructor
* @param {Element} elem
* @param {Element} input
* @param {Array} fmgrGraphics
* @param {HandlersList} handlers
* @param {Object} settings See CellEditor.defaults
*/
function CellEditor(elem, input, fontRenderingMode, handlers, settings) {
if ( !(this instanceof CellEditor) ) {return new CellEditor(elem, input, fontRenderingMode, handlers, settings);}
function CellEditor(elem, input, fmgrGraphics, handlers, settings) {
if ( !(this instanceof CellEditor) ) {return new CellEditor(elem, input, fmgrGraphics, handlers, settings);}
this.element = elem;
this.input = input;
......@@ -95,7 +96,7 @@
this.cursorTID = undefined;
this.cursorPos = 0;
this.topLineIndex = 0;
this.fontRenderingMode = fontRenderingMode;
this.fmgrGraphics = fmgrGraphics;
this.drawingCtx = undefined;
this.overlayCtx = undefined;
this.textRender = undefined;
......@@ -184,8 +185,8 @@
}
// create text render
t.drawingCtx = asc_DC({canvas: t.canvas[0], units: 1/*pt*/, fontRenderingMode: this.fontRenderingMode});
t.overlayCtx = asc_DC({canvas: t.canvasOverlay[0], units: 1/*pt*/});
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*/, fmgrGraphics: this.fmgrGraphics});
t.textRender = asc_TR(t.drawingCtx);
t.textRender.setDefaultFont(t.settings.font.clone());
......@@ -601,13 +602,9 @@
this._addChars(newText);
},
setFontRenderingMode: function (mode) {
if (mode !== this.fontRenderingMode) {
this.fontRenderingMode = mode;
this.drawingCtx.setFontRenderingMode(mode);
if (this.isOpened)
this._draw();
}
setFontRenderingMode: function () {
if (this.isOpened)
this._draw();
},
......
......@@ -66,9 +66,17 @@
this.wsViews = [];
this.cellEditor = undefined;
this.fontRenderingMode = fontRenderingMode;
//-----------------------
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();
......@@ -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*/{
"closed" : function () {self._onCloseCellEditor.apply(self, arguments);},
"updated" : function () {self.handlers.trigger.apply(self.handlers,
......@@ -295,7 +303,7 @@
"setAutoFiltersDialog" : function (arrVal) {self.handlers.trigger("asc_onSetAFDialog", arrVal);},
"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) {
......@@ -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) {
this.getWorksheet().setSelectDialogRangeMode(isSelectDialogRangeMode);
},
......@@ -1318,6 +1310,59 @@
lockDraw: function(){
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 @@
* @param {Object} canvas Canvas for drawing
* @param {Object} overlay Canvas for selection
* @param {asc_CCollaborativeEditing} collaborativeEditing
* @param {c_oAscFontRenderingModeType} fontRenderingMode
* @param {Array} fmgrGraphics
* @param {Object} settings Settings
*
* @constructor
* @memberOf Asc
*/
function WorksheetView(model, canvas, overlay, collaborativeEditing, fontRenderingMode, settings) {
function WorksheetView(model, canvas, overlay, collaborativeEditing, fmgrGraphics, settings) {
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);
......@@ -370,12 +370,11 @@
this.model = model;
this.buffers = {};
this.buffers.main = canvas.getPPIX ? canvas : asc_DC({canvas: canvas, units: 1/*pt*/, fontRenderingMode: fontRenderingMode});
this.buffers.overlay = overlay ? asc_DC({canvas: overlay, units: 1/*pt*/, fontRenderingMode: fontRenderingMode}) : null;
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*/, fmgrGraphics: fmgrGraphics}) : null;
this.drawingCtx = this.buffers.main;
this.overlayCtx = this.buffers.overlay;
this.fontRenderingMode = fontRenderingMode;
this.stringRender = asc_SR(this.drawingCtx);
this.stringRender.setDefaultFontFromFmt({fn: cells.fontName, fs: cells.fontSize});
......@@ -1147,25 +1146,27 @@
this.height_2px = asc_calcnpt(0, this._getPPIY(), 2/*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
this.maxNumWidth = asc_round( this.emSize * asc_getcvt( 1/*pt*/, 0/*px*/, this._getPPIX() ) );
} else {
// this.maxNumWidth = asc_round( this.emSize * asc_getcvt( 1/*pt*/, 0/*px*/, this._getPPIX() ) );
// } else {
// Для отображения нужно более точное значение, иначе будут прыгать строки в ячейках
// http://bugzserver/show_bug.cgi?id=15311
this.maxNumWidth = this.emSize * asc_getcvt( 1/*pt*/, 0/*px*/, this._getPPIX() );
}
// }
gc_dDefaultColWidthCharsAttribute = this._charCountToModelColWidth(gc_dDefaultColWidthChars, true);
this.defaultColWidth = this._modelColWidthToColWidth(gc_dDefaultColWidthCharsAttribute);
this.displayColWidth = this._modelColWidthToColWidth(gc_dDefaultColWidthCharsAttribute, true);
this.maxRowHeight = asc_calcnpt( 409, this._getPPIY() );
if (this.printMode) {
this.defaultRowHeight = asc_round( this.settings.cells.fontSize * this.vspRatio );
} else {
// ToDo разобраться со значениями
// if (this.printMode) {
// 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.defaultRowDescender = this._calcRowDescender(this.settings.cells.fontSize);
// calculate rows heights and visible rows
......@@ -1778,29 +1779,7 @@
return arrResult;
},
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']);
if (null === printPagesData) {
......@@ -9157,16 +9136,6 @@
var ar = this.activeRange.clone(true);
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)
{
......
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