Commit 1b356fd2 authored by Oleg Korshul's avatar Oleg Korshul

перегрузка функций TextMeasurer для презентаций

parent cb1678e6
...@@ -47,6 +47,31 @@ var FOCUS_OBJECT_NOTES = 2; ...@@ -47,6 +47,31 @@ var FOCUS_OBJECT_NOTES = 2;
var COMMENT_WIDTH = 18; var COMMENT_WIDTH = 18;
var COMMENT_HEIGHT = 16; var COMMENT_HEIGHT = 16;
CTextMeasurer.prototype.GetAscender = function()
{
var UnitsPerEm = this.m_oManager.m_lUnits_Per_Em;
//var Ascender = this.m_oManager.m_lAscender;
var Ascender = ( 0 !== this.m_oManager.m_lLineHeight ) ? 1.2 * UnitsPerEm * this.m_oManager.m_lAscender / this.m_oManager.m_lLineHeight : this.m_oManager.m_lAscender;
return Ascender * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm;
};
CTextMeasurer.prototype.GetDescender = function()
{
var UnitsPerEm = this.m_oManager.m_lUnits_Per_Em;
//var Descender = this.m_oManager.m_lDescender;
var Descender = ( 0 !== this.m_oManager.m_lLineHeight ) ? 1.2 * UnitsPerEm * this.m_oManager.m_lDescender / this.m_oManager.m_lLineHeight : this.m_oManager.m_lDescender;
return Descender * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm;
};
CTextMeasurer.prototype.GetHeight = function()
{
var UnitsPerEm = this.m_oManager.m_lUnits_Per_Em;
//var Height = this.m_oManager.m_lLineHeight;
var Height = ( 0 !== this.m_oManager.m_lLineHeight ) ? 1.2 * UnitsPerEm : this.m_oManager.m_lLineHeight;
return Height * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm;
};
function CTableMarkup(Table) function CTableMarkup(Table)
{ {
this.Internal = this.Internal =
......
...@@ -211,6 +211,11 @@ asc_docs_api.prototype.asc_isOffline = function() ...@@ -211,6 +211,11 @@ asc_docs_api.prototype.asc_isOffline = function()
{ {
return true; return true;
}; };
asc_docs_api.prototype.SetThemesPath = function(path)
{
this.ThemeLoader.ThemesUrl = path;
this.ThemeLoader.ThemesUrlAbs = path;
};
asc_docs_api.prototype["asc_addImage"] = asc_docs_api.prototype.asc_addImage; asc_docs_api.prototype["asc_addImage"] = asc_docs_api.prototype.asc_addImage;
asc_docs_api.prototype["AddImageUrl"] = asc_docs_api.prototype.AddImageUrl; asc_docs_api.prototype["AddImageUrl"] = asc_docs_api.prototype.AddImageUrl;
...@@ -219,6 +224,7 @@ asc_docs_api.prototype["asc_Save"] = asc_docs_api.prototype.asc_Save; ...@@ -219,6 +224,7 @@ asc_docs_api.prototype["asc_Save"] = asc_docs_api.prototype.asc_Save;
asc_docs_api.prototype["asc_DownloadAs"] = asc_docs_api.prototype.asc_DownloadAs; asc_docs_api.prototype["asc_DownloadAs"] = asc_docs_api.prototype.asc_DownloadAs;
asc_docs_api.prototype["asc_isOffline"] = asc_docs_api.prototype.asc_isOffline; asc_docs_api.prototype["asc_isOffline"] = asc_docs_api.prototype.asc_isOffline;
asc_docs_api.prototype["SetDocumentModified"] = asc_docs_api.prototype.SetDocumentModified; asc_docs_api.prototype["SetDocumentModified"] = asc_docs_api.prototype.SetDocumentModified;
asc_docs_api.prototype["SetThemesPath"] = asc_docs_api.prototype.SetThemesPath;
window["DesktopOfflineAppDocumentAddImageEnd"] = function(url) window["DesktopOfflineAppDocumentAddImageEnd"] = function(url)
{ {
......
...@@ -2441,19 +2441,22 @@ function CTextMeasurer() ...@@ -2441,19 +2441,22 @@ function CTextMeasurer()
this.m_oGrFonts = new CGrRFonts(); this.m_oGrFonts = new CGrRFonts();
this.m_oLastFont = new CFontSetup(); this.m_oLastFont = new CFontSetup();
this.LastFontOriginInfo = { Name : "", Replace : null }; this.LastFontOriginInfo = {Name : "", Replace : null};
}
this.Init = function() CTextMeasurer.prototype =
{
Init : function()
{ {
this.m_oManager.Initialize(); this.m_oManager.Initialize();
}; },
this.SetStringGid = function(bGID) SetStringGid : function(bGID)
{ {
this.m_oManager.SetStringGID(bGID); this.m_oManager.SetStringGID(bGID);
}; },
this.SetFont = function(font) SetFont : function(font)
{ {
if (!font) if (!font)
return; return;
...@@ -2480,9 +2483,9 @@ function CTextMeasurer() ...@@ -2480,9 +2483,9 @@ function CTextMeasurer()
g_fontApplication.LoadFont(_lastSetUp.SetUpName, window.g_font_loader, this.m_oManager, _lastSetUp.SetUpSize, _lastSetUp.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo); g_fontApplication.LoadFont(_lastSetUp.SetUpName, window.g_font_loader, this.m_oManager, _lastSetUp.SetUpSize, _lastSetUp.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo);
} }
}; },
this.SetFontInternal = function(_name, _size, _style) SetFontInternal : function(_name, _size, _style)
{ {
var _lastSetUp = this.m_oLastFont; var _lastSetUp = this.m_oLastFont;
if (_lastSetUp.SetUpName != _name || _lastSetUp.SetUpSize != _size || _lastSetUp.SetUpStyle != _style) if (_lastSetUp.SetUpName != _name || _lastSetUp.SetUpSize != _size || _lastSetUp.SetUpStyle != _style)
...@@ -2493,18 +2496,18 @@ function CTextMeasurer() ...@@ -2493,18 +2496,18 @@ function CTextMeasurer()
g_fontApplication.LoadFont(_lastSetUp.SetUpName, window.g_font_loader, this.m_oManager, _lastSetUp.SetUpSize, _lastSetUp.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo); g_fontApplication.LoadFont(_lastSetUp.SetUpName, window.g_font_loader, this.m_oManager, _lastSetUp.SetUpSize, _lastSetUp.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo);
} }
}; },
this.SetTextPr = function(textPr, theme) SetTextPr : function(textPr, theme)
{ {
this.m_oTextPr = textPr; this.m_oTextPr = textPr;
if (theme) if (theme)
this.m_oGrFonts.checkFromTheme(theme.themeElements.fontScheme, this.m_oTextPr.RFonts); this.m_oGrFonts.checkFromTheme(theme.themeElements.fontScheme, this.m_oTextPr.RFonts);
else else
this.m_oGrFonts = this.m_oTextPr.RFonts; this.m_oGrFonts = this.m_oTextPr.RFonts;
}; },
this.SetFontSlot = function(slot, fontSizeKoef) SetFontSlot : function(slot, fontSizeKoef)
{ {
var _rfonts = this.m_oGrFonts; var _rfonts = this.m_oGrFonts;
var _lastFont = this.m_oLastFont; var _lastFont = this.m_oLastFont;
...@@ -2575,19 +2578,19 @@ function CTextMeasurer() ...@@ -2575,19 +2578,19 @@ function CTextMeasurer()
g_fontApplication.LoadFont(_lastFont.SetUpName, window.g_font_loader, this.m_oManager, _lastFont.SetUpSize, _lastFont.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo); g_fontApplication.LoadFont(_lastFont.SetUpName, window.g_font_loader, this.m_oManager, _lastFont.SetUpSize, _lastFont.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo);
} }
}; },
this.GetTextPr = function() GetTextPr : function()
{ {
return this.m_oTextPr; return this.m_oTextPr;
}; },
this.GetFont = function() GetFont : function()
{ {
return this.m_oFont; return this.m_oFont;
}; },
this.Measure = function(text) Measure : function(text)
{ {
var Width = 0; var Width = 0;
var Height = 0; var Height = 0;
...@@ -2602,8 +2605,8 @@ function CTextMeasurer() ...@@ -2602,8 +2605,8 @@ function CTextMeasurer()
Height = 0;//Temp.fHeight; Height = 0;//Temp.fHeight;
return { Width : Width, Height : Height }; return { Width : Width, Height : Height };
}; },
this.Measure2 = function(text) Measure2 : function(text)
{ {
var Width = 0; var Width = 0;
...@@ -2635,9 +2638,9 @@ function CTextMeasurer() ...@@ -2635,9 +2638,9 @@ function CTextMeasurer()
rasterOffsetX: Temp.oBBox.rasterDistances.dist_l * 25.4 / 72, rasterOffsetX: Temp.oBBox.rasterDistances.dist_l * 25.4 / 72,
rasterOffsetY: Temp.oBBox.rasterDistances.dist_t * 25.4 / 72 rasterOffsetY: Temp.oBBox.rasterDistances.dist_t * 25.4 / 72
}; };
}; },
this.MeasureCode = function(lUnicode) MeasureCode : function(lUnicode)
{ {
var Width = 0; var Width = 0;
var Height = 0; var Height = 0;
...@@ -2651,8 +2654,8 @@ function CTextMeasurer() ...@@ -2651,8 +2654,8 @@ function CTextMeasurer()
Height = ((Temp.oBBox.fMaxY - Temp.oBBox.fMinY) * 25.4 / 72); Height = ((Temp.oBBox.fMaxY - Temp.oBBox.fMinY) * 25.4 / 72);
return { Width : Width, Height : Height, Ascent : (Temp.oBBox.fMaxY * 25.4 / 72) }; return { Width : Width, Height : Height, Ascent : (Temp.oBBox.fMaxY * 25.4 / 72) };
}; },
this.Measure2Code = function(lUnicode) Measure2Code : function(lUnicode)
{ {
var Width = 0; var Width = 0;
...@@ -2683,30 +2686,30 @@ function CTextMeasurer() ...@@ -2683,30 +2686,30 @@ function CTextMeasurer()
rasterOffsetX: (Temp.oBBox.rasterDistances.dist_l + Temp.oBBox.fMinX) * 25.4 / 72, rasterOffsetX: (Temp.oBBox.rasterDistances.dist_l + Temp.oBBox.fMinX) * 25.4 / 72,
rasterOffsetY: Temp.oBBox.rasterDistances.dist_t * 25.4 / 72 rasterOffsetY: Temp.oBBox.rasterDistances.dist_t * 25.4 / 72
}; };
}; },
this.GetAscender = function() GetAscender : function()
{ {
var UnitsPerEm = this.m_oManager.m_lUnits_Per_Em; var UnitsPerEm = this.m_oManager.m_lUnits_Per_Em;
var Ascender = this.m_oManager.m_lAscender; var Ascender = this.m_oManager.m_lAscender;
return Ascender * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm; return Ascender * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm;
}; },
this.GetDescender = function() GetDescender : function()
{ {
var UnitsPerEm = this.m_oManager.m_lUnits_Per_Em; var UnitsPerEm = this.m_oManager.m_lUnits_Per_Em;
var Descender = this.m_oManager.m_lDescender; var Descender = this.m_oManager.m_lDescender;
return Descender * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm; return Descender * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm;
}; },
this.GetHeight = function() GetHeight : function()
{ {
var UnitsPerEm = this.m_oManager.m_lUnits_Per_Em; var UnitsPerEm = this.m_oManager.m_lUnits_Per_Em;
var Height = this.m_oManager.m_lLineHeight; var Height = this.m_oManager.m_lLineHeight;
return Height * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm; return Height * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm;
}; }
} };
var g_oTextMeasurer = new CTextMeasurer(); var g_oTextMeasurer = new CTextMeasurer();
g_oTextMeasurer.Init(); g_oTextMeasurer.Init();
......
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