Commit eb20b49e authored by Oleg Korshul's avatar Oleg Korshul

линейки с дюймами

parent 316cc020
...@@ -816,3 +816,8 @@ var contentchanges_Add = 1; ...@@ -816,3 +816,8 @@ var contentchanges_Add = 1;
var contentchanges_Remove = 2; var contentchanges_Remove = 2;
var offlineMode = '_offline_'; var offlineMode = '_offline_';
var c_oAscRulerUnits = {
Millimeter : 0,
Inch : 1
};
\ No newline at end of file
...@@ -3812,6 +3812,14 @@ asc_docs_api.prototype.asc_GetViewRulers = function() ...@@ -3812,6 +3812,14 @@ asc_docs_api.prototype.asc_GetViewRulers = function()
{ {
return this.WordControl.m_bIsRuler; return this.WordControl.m_bIsRuler;
}; };
asc_docs_api.prototype.asc_SetDocumentUnits = function(_units)
{
if (this.WordControl && this.WordControl.m_oHorRuler && this.WordControl.m_oVerRuler)
{
this.WordControl.m_oHorRuler.Units = _units;
this.WordControl.m_oVerRuler.Units = _units;
}
};
asc_docs_api.prototype.SetMobileVersion = function(val) asc_docs_api.prototype.SetMobileVersion = function(val)
{ {
......
...@@ -209,6 +209,8 @@ function CHorRuler() ...@@ -209,6 +209,8 @@ function CHorRuler()
this.SimpleChanges = new RulerCheckSimpleChanges(); this.SimpleChanges = new RulerCheckSimpleChanges();
this.Units = c_oAscRulerUnits.Inch;
this.InitTablePict = function() this.InitTablePict = function()
{ {
var _data = g_memory.ctx.createImageData(7, 8); var _data = g_memory.ctx.createImageData(7, 8);
...@@ -600,8 +602,7 @@ function CHorRuler() ...@@ -600,8 +602,7 @@ function CHorRuler()
context.fillStyle = "#585B5E"; context.fillStyle = "#585B5E";
var mm_1_4 = 10 * dKoef_mm_to_pix / 4; var mm_1_4 = 10 * dKoef_mm_to_pix / 4;
var lCount1 = ((width - left_margin) / mm_1_4) >> 0; var inch_1_8 = 25.4 * dKoef_mm_to_pix / 8;
var lCount2 = (left_margin / mm_1_4) >> 0;
var middleVert = (this.m_nTop + this.m_nBottom) / 2; var middleVert = (this.m_nTop + this.m_nBottom) / 2;
var part1 = 1; var part1 = 1;
...@@ -609,6 +610,11 @@ function CHorRuler() ...@@ -609,6 +610,11 @@ function CHorRuler()
context.font = "7pt Arial"; context.font = "7pt Arial";
if (this.Units == c_oAscRulerUnits.Millimeter)
{
var lCount1 = ((width - left_margin) / mm_1_4) >> 0;
var lCount2 = (left_margin / mm_1_4) >> 0;
var index = 0; var index = 0;
var num = 0; var num = 0;
for (var i = 1; i < lCount1; i++) for (var i = 1; i < lCount1; i++)
...@@ -698,6 +704,86 @@ function CHorRuler() ...@@ -698,6 +704,86 @@ function CHorRuler()
context.stroke(); context.stroke();
} }
} }
}
else if (this.Units == c_oAscRulerUnits.Inch)
{
var lCount1 = ((width - left_margin) / inch_1_8) >> 0;
var lCount2 = (left_margin / inch_1_8) >> 0;
var index = 0;
var num = 0;
for (var i = 1; i < lCount1; i++)
{
var lXPos = ((left_margin + i * inch_1_8) >> 0) + 0.5;
index++;
if (index == 8)
index = 0;
if (0 == index)
{
num++;
// number
var strNum = "" + num;
var lWidthText = context.measureText(strNum).width;
lXPos -= (lWidthText / 2.0);
context.fillText(strNum, lXPos, this.m_nBottom - 3);
}
else if (4 == index)
{
// 1/2
context.beginPath();
context.moveTo(lXPos, middleVert - part2);
context.lineTo(lXPos, middleVert + part2);
context.stroke();
}
else if (inch_1_8 > 8)
{
// 1/8
context.beginPath();
context.moveTo(lXPos, middleVert - part1);
context.lineTo(lXPos, middleVert + part1);
context.stroke();
}
}
index = 0;
num = 0;
for (var i = 1; i <= lCount2; i++)
{
var lXPos = ((left_margin - i * inch_1_8) >> 0) + 0.5;
index++;
if (index == 8)
index = 0;
if (0 == index)
{
num++;
// number
var strNum = "" + num;
var lWidthText = context.measureText(strNum).width;
lXPos -= (lWidthText / 2.0);
context.fillText(strNum, lXPos, this.m_nBottom - 3);
}
else if (4 == index)
{
// 1/2
context.beginPath();
context.moveTo(lXPos, middleVert - part2);
context.lineTo(lXPos, middleVert + part2);
context.stroke();
}
else if (inch_1_8 > 8)
{
// 1/8
context.beginPath();
context.moveTo(lXPos, middleVert - part1);
context.lineTo(lXPos, middleVert + part1);
context.stroke();
}
}
}
if (null != markup && this.CurrentObjectType == RULER_OBJECT_TYPE_TABLE) if (null != markup && this.CurrentObjectType == RULER_OBJECT_TYPE_TABLE)
{ {
...@@ -2504,6 +2590,8 @@ function CVerRuler() ...@@ -2504,6 +2590,8 @@ function CVerRuler()
this.SimpleChanges = new RulerCheckSimpleChanges(); this.SimpleChanges = new RulerCheckSimpleChanges();
this.Units = c_oAscRulerUnits.Inch;
this.CheckCanvas = function() this.CheckCanvas = function()
{ {
this.m_dZoom = this.m_oWordControl.m_nZoomValue / 100; this.m_dZoom = this.m_oWordControl.m_nZoomValue / 100;
...@@ -2715,8 +2803,7 @@ function CVerRuler() ...@@ -2715,8 +2803,7 @@ function CVerRuler()
context.fillStyle = "#585B5E"; context.fillStyle = "#585B5E";
var mm_1_4 = 10 * dKoef_mm_to_pix / 4; var mm_1_4 = 10 * dKoef_mm_to_pix / 4;
var lCount1 = ((height - top_margin) / mm_1_4) >> 0; var inch_1_8 = 25.4 * dKoef_mm_to_pix / 8;
var lCount2 = (top_margin / mm_1_4) >> 0;
var middleHor = (this.m_nLeft + this.m_nRight) / 2; var middleHor = (this.m_nLeft + this.m_nRight) / 2;
var part1 = 1; var part1 = 1;
...@@ -2724,6 +2811,11 @@ function CVerRuler() ...@@ -2724,6 +2811,11 @@ function CVerRuler()
context.font = "7pt Arial"; context.font = "7pt Arial";
if (this.Units == c_oAscRulerUnits.Millimeter)
{
var lCount1 = ((height - top_margin) / mm_1_4) >> 0;
var lCount2 = (top_margin / mm_1_4) >> 0;
var index = 0; var index = 0;
var num = 0; var num = 0;
for (var i = 1; i < lCount1; i++) for (var i = 1; i < lCount1; i++)
...@@ -2828,6 +2920,101 @@ function CVerRuler() ...@@ -2828,6 +2920,101 @@ function CVerRuler()
context.stroke(); context.stroke();
} }
} }
}
else if (this.Units == c_oAscRulerUnits.Inch)
{
var lCount1 = ((height - top_margin) / inch_1_8) >> 0;
var lCount2 = (top_margin / inch_1_8) >> 0;
var index = 0;
var num = 0;
for (var i = 1; i < lCount1; i++)
{
var lYPos = ((top_margin + i * inch_1_8) >> 0) + 0.5;
index++;
if (index == 8)
index = 0;
if (0 == index)
{
num++;
// number
var strNum = "" + num;
var lWidthText = context.measureText(strNum).width;
context.translate(middleHor, lYPos);
context.rotate(-Math.PI / 2);
context.fillText(strNum, -lWidthText / 2.0, 4);
if (!this.IsRetina)
context.setTransform(1, 0, 0, 1, 0, 5);
else
context.setTransform(2, 0, 0, 2, 0, 10);
}
else if (4 == index)
{
// 1/2
context.beginPath();
context.moveTo(middleHor - part2, lYPos);
context.lineTo(middleHor + part2, lYPos);
context.stroke();
}
else if (inch_1_8 > 8)
{
// 1/8
context.beginPath();
context.moveTo(middleHor - part1, lYPos);
context.lineTo(middleHor + part1, lYPos);
context.stroke();
}
}
index = 0;
num = 0;
for (var i = 1; i <= lCount2; i++)
{
var lYPos = ((top_margin - i * inch_1_8) >> 0) + 0.5;
index++;
if (index == 8)
index = 0;
if (0 == index)
{
num++;
// number
var strNum = "" + num;
var lWidthText = context.measureText(strNum).width;
context.translate(middleHor, lYPos);
context.rotate(-Math.PI / 2);
context.fillText(strNum, -lWidthText / 2.0, 4);
if (!this.IsRetina)
context.setTransform(1, 0, 0, 1, 0, 5);
else
context.setTransform(2, 0, 0, 2, 0, 10);
}
else if (4 == index)
{
// 1/2
context.beginPath();
context.moveTo(middleHor - part2, lYPos);
context.lineTo(middleHor + part2, lYPos);
context.stroke();
}
else if (inch_1_8 > 8)
{
// 1/8
context.beginPath();
context.moveTo(middleHor - part1, lYPos);
context.lineTo(middleHor + part1, lYPos);
context.stroke();
}
}
}
if ((this.CurrentObjectType == RULER_OBJECT_TYPE_TABLE) && (null != markup)) if ((this.CurrentObjectType == RULER_OBJECT_TYPE_TABLE) && (null != markup))
{ {
......
...@@ -6351,6 +6351,15 @@ asc_docs_api.prototype.asc_GetViewRulers = function() ...@@ -6351,6 +6351,15 @@ asc_docs_api.prototype.asc_GetViewRulers = function()
return this.WordControl.m_bIsRuler; return this.WordControl.m_bIsRuler;
}; };
asc_docs_api.prototype.asc_SetDocumentUnits = function(_units)
{
if (this.WordControl && this.WordControl.m_oHorRuler && this.WordControl.m_oVerRuler)
{
this.WordControl.m_oHorRuler.Units = _units;
this.WordControl.m_oVerRuler.Units = _units;
}
};
asc_docs_api.prototype.SetMobileVersion = function(val) asc_docs_api.prototype.SetMobileVersion = function(val)
{ {
this.isMobileVersion = val; this.isMobileVersion = val;
......
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