Commit 53adf290 authored by Oleg Korshul's avatar Oleg Korshul Committed by Alexander.Trofimov

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

parent fd2ad651
......@@ -792,3 +792,8 @@ var contentchanges_Add = 1;
var contentchanges_Remove = 2;
var offlineMode = '_offline_';
var c_oAscRulerUnits = {
Millimeter : 0,
Inch : 1
};
\ No newline at end of file
......@@ -3788,6 +3788,14 @@ asc_docs_api.prototype.asc_GetViewRulers = function()
{
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)
{
......
"use strict";
"use strict";
function CTab(pos,type)
{
......@@ -185,6 +185,8 @@ function CHorRuler()
this.SimpleChanges = new RulerCheckSimpleChanges();
this.Units = c_oAscRulerUnits.Inch;
this.InitTablePict = function()
{
var _data = g_memory.ctx.createImageData(7, 8);
......@@ -576,8 +578,7 @@ function CHorRuler()
context.fillStyle = "#585B5E";
var mm_1_4 = 10 * dKoef_mm_to_pix / 4;
var lCount1 = ((width - left_margin) / mm_1_4) >> 0;
var lCount2 = (left_margin / mm_1_4) >> 0;
var inch_1_8 = 25.4 * dKoef_mm_to_pix / 8;
var middleVert = (this.m_nTop + this.m_nBottom) / 2;
var part1 = 1;
......@@ -585,6 +586,11 @@ function CHorRuler()
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 num = 0;
for (var i = 1; i < lCount1; i++)
......@@ -674,6 +680,86 @@ function CHorRuler()
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)
{
......@@ -2480,6 +2566,8 @@ function CVerRuler()
this.SimpleChanges = new RulerCheckSimpleChanges();
this.Units = c_oAscRulerUnits.Inch;
this.CheckCanvas = function()
{
this.m_dZoom = this.m_oWordControl.m_nZoomValue / 100;
......@@ -2691,8 +2779,7 @@ function CVerRuler()
context.fillStyle = "#585B5E";
var mm_1_4 = 10 * dKoef_mm_to_pix / 4;
var lCount1 = ((height - top_margin) / mm_1_4) >> 0;
var lCount2 = (top_margin / mm_1_4) >> 0;
var inch_1_8 = 25.4 * dKoef_mm_to_pix / 8;
var middleHor = (this.m_nLeft + this.m_nRight) / 2;
var part1 = 1;
......@@ -2700,6 +2787,11 @@ function CVerRuler()
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 num = 0;
for (var i = 1; i < lCount1; i++)
......@@ -2804,6 +2896,101 @@ function CVerRuler()
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))
{
......
......@@ -6327,6 +6327,15 @@ asc_docs_api.prototype.asc_GetViewRulers = function()
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)
{
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