Commit eb20b49e authored by Oleg Korshul's avatar Oleg Korshul

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

parent 316cc020
......@@ -815,4 +815,9 @@ var changestype_2_AdditionalTypes = 6; // Дополнительные п
var contentchanges_Add = 1;
var contentchanges_Remove = 2;
var offlineMode = '_offline_';
\ No newline at end of file
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()
{
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)
{
......
/*
*
* (c) Copyright Ascensio System Limited 2010-2016
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7  3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7  3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
/*
*
* (c) Copyright Ascensio System Limited 2010-2016
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7  3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7  3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
"use strict";
function CTab(pos,type)
......@@ -209,6 +209,8 @@ function CHorRuler()
this.SimpleChanges = new RulerCheckSimpleChanges();
this.Units = c_oAscRulerUnits.Inch;
this.InitTablePict = function()
{
var _data = g_memory.ctx.createImageData(7, 8);
......@@ -600,8 +602,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;
......@@ -609,93 +610,178 @@ function CHorRuler()
context.font = "7pt Arial";
var index = 0;
var num = 0;
for (var i = 1; i < lCount1; i++)
if (this.Units == c_oAscRulerUnits.Millimeter)
{
var lXPos = ((left_margin + i * mm_1_4) >> 0) + 0.5;
index++;
if (index == 4)
index = 0;
var lCount1 = ((width - left_margin) / mm_1_4) >> 0;
var lCount2 = (left_margin / mm_1_4) >> 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 (1 == index)
{
// 1/4
context.beginPath();
context.moveTo(lXPos, middleVert - part1);
context.lineTo(lXPos, middleVert + part1);
context.stroke();
}
else if (2 == index)
var index = 0;
var num = 0;
for (var i = 1; i < lCount1; i++)
{
// 1/2
context.beginPath();
context.moveTo(lXPos, middleVert - part2);
context.lineTo(lXPos, middleVert + part2);
context.stroke();
var lXPos = ((left_margin + i * mm_1_4) >> 0) + 0.5;
index++;
if (index == 4)
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 (1 == index)
{
// 1/4
context.beginPath();
context.moveTo(lXPos, middleVert - part1);
context.lineTo(lXPos, middleVert + part1);
context.stroke();
}
else if (2 == index)
{
// 1/2
context.beginPath();
context.moveTo(lXPos, middleVert - part2);
context.lineTo(lXPos, middleVert + part2);
context.stroke();
}
else
{
// 1/4
context.beginPath();
context.moveTo(lXPos, middleVert - part1);
context.lineTo(lXPos, middleVert + part1);
context.stroke();
}
}
else
index = 0;
num = 0;
for (var i = 1; i <= lCount2; i++)
{
// 1/4
context.beginPath();
context.moveTo(lXPos, middleVert - part1);
context.lineTo(lXPos, middleVert + part1);
context.stroke();
var lXPos = ((left_margin - i * mm_1_4) >> 0) + 0.5;
index++;
if (index == 4)
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 (1 == index)
{
// 1/4
context.beginPath();
context.moveTo(lXPos, middleVert - part1);
context.lineTo(lXPos, middleVert + part1);
context.stroke();
}
else if (2 == index)
{
// 1/2
context.beginPath();
context.moveTo(lXPos, middleVert - part2);
context.lineTo(lXPos, middleVert + part2);
context.stroke();
}
else
{
// 1/4
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++)
else if (this.Units == c_oAscRulerUnits.Inch)
{
var lXPos = ((left_margin - i * mm_1_4) >> 0) + 0.5;
index++;
if (index == 4)
index = 0;
var lCount1 = ((width - left_margin) / inch_1_8) >> 0;
var lCount2 = (left_margin / inch_1_8) >> 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 (1 == index)
{
// 1/4
context.beginPath();
context.moveTo(lXPos, middleVert - part1);
context.lineTo(lXPos, middleVert + part1);
context.stroke();
}
else if (2 == index)
var index = 0;
var num = 0;
for (var i = 1; i < lCount1; i++)
{
// 1/2
context.beginPath();
context.moveTo(lXPos, middleVert - part2);
context.lineTo(lXPos, middleVert + part2);
context.stroke();
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();
}
}
else
index = 0;
num = 0;
for (var i = 1; i <= lCount2; i++)
{
// 1/4
context.beginPath();
context.moveTo(lXPos, middleVert - part1);
context.lineTo(lXPos, middleVert + part1);
context.stroke();
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();
}
}
}
......@@ -2504,6 +2590,8 @@ function CVerRuler()
this.SimpleChanges = new RulerCheckSimpleChanges();
this.Units = c_oAscRulerUnits.Inch;
this.CheckCanvas = function()
{
this.m_dZoom = this.m_oWordControl.m_nZoomValue / 100;
......@@ -2715,8 +2803,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;
......@@ -2724,108 +2811,208 @@ function CVerRuler()
context.font = "7pt Arial";
var index = 0;
var num = 0;
for (var i = 1; i < lCount1; i++)
if (this.Units == c_oAscRulerUnits.Millimeter)
{
var lYPos = ((top_margin + i * mm_1_4) >> 0) + 0.5;
index++;
if (index == 4)
index = 0;
var lCount1 = ((height - top_margin) / mm_1_4) >> 0;
var lCount2 = (top_margin / mm_1_4) >> 0;
if (0 == index)
var index = 0;
var num = 0;
for (var i = 1; i < lCount1; i++)
{
num++;
// number
var lYPos = ((top_margin + i * mm_1_4) >> 0) + 0.5;
index++;
var strNum = "" + num;
var lWidthText = context.measureText(strNum).width;
if (index == 4)
index = 0;
context.translate(middleHor, lYPos);
context.rotate(-Math.PI / 2);
context.fillText(strNum, -lWidthText / 2.0, 4);
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);
if (!this.IsRetina)
context.setTransform(1, 0, 0, 1, 0, 5);
else
context.setTransform(2, 0, 0, 2, 0, 10);
}
else if (1 == index)
{
// 1/4
context.beginPath();
context.moveTo(middleHor - part1, lYPos);
context.lineTo(middleHor + part1, lYPos);
context.stroke();
}
else if (2 == index)
{
// 1/2
context.beginPath();
context.moveTo(middleHor - part2, lYPos);
context.lineTo(middleHor + part2, lYPos);
context.stroke();
}
else
context.setTransform(2, 0, 0, 2, 0, 10);
}
else if (1 == index)
{
// 1/4
context.beginPath();
context.moveTo(middleHor - part1, lYPos);
context.lineTo(middleHor + part1, lYPos);
context.stroke();
}
else if (2 == index)
{
// 1/2
context.beginPath();
context.moveTo(middleHor - part2, lYPos);
context.lineTo(middleHor + part2, lYPos);
context.stroke();
}
else
{
// 1/4
context.beginPath();
context.moveTo(middleHor - part1, lYPos);
context.lineTo(middleHor + part1, lYPos);
context.stroke();
{
// 1/4
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 * mm_1_4) >> 0) + 0.5;
index++;
index = 0;
num = 0;
for (var i = 1; i <= lCount2; i++)
{
var lYPos = ((top_margin - i * mm_1_4) >> 0) + 0.5;
index++;
if (index == 4)
index = 0;
if (index == 4)
index = 0;
if (0 == index)
{
num++;
// number
var strNum = "" + num;
var lWidthText = context.measureText(strNum).width;
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);
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);
if (!this.IsRetina)
context.setTransform(1, 0, 0, 1, 0, 5);
else
context.setTransform(2, 0, 0, 2, 0, 10);
}
else if (1 == index)
{
// 1/4
context.beginPath();
context.moveTo(middleHor - part1, lYPos);
context.lineTo(middleHor + part1, lYPos);
context.stroke();
}
else if (2 == index)
{
// 1/2
context.beginPath();
context.moveTo(middleHor - part2, lYPos);
context.lineTo(middleHor + part2, lYPos);
context.stroke();
}
else
context.setTransform(2, 0, 0, 2, 0, 10);
}
else if (1 == index)
{
// 1/4
context.beginPath();
context.moveTo(middleHor - part1, lYPos);
context.lineTo(middleHor + part1, lYPos);
context.stroke();
{
// 1/4
context.beginPath();
context.moveTo(middleHor - part1, lYPos);
context.lineTo(middleHor + part1, lYPos);
context.stroke();
}
}
else if (2 == index)
}
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++)
{
// 1/2
context.beginPath();
context.moveTo(middleHor - part2, lYPos);
context.lineTo(middleHor + part2, lYPos);
context.stroke();
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();
}
}
else
index = 0;
num = 0;
for (var i = 1; i <= lCount2; i++)
{
// 1/4
context.beginPath();
context.moveTo(middleHor - part1, lYPos);
context.lineTo(middleHor + part1, lYPos);
context.stroke();
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();
}
}
}
......
......@@ -6351,6 +6351,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