Commit 50889026 authored by Sergey.Tsarkov's avatar Sergey.Tsarkov Committed by Alexander.Trofimov

добавлено меню для набора формул

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@52746 954022d7-b5bf-4e40-9824-e11837661b57
parent bcc3294c
...@@ -6958,7 +6958,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -6958,7 +6958,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
return res; return res;
}; };
this.ReadMathBox = function(type, length, oBox, oElem) this.ReadMathBox = function(type, length, oBox, props, oElem)
{ {
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
var oThis = this; var oThis = this;
......
...@@ -3006,6 +3006,61 @@ ...@@ -3006,6 +3006,61 @@
</div> </div>
</div> </div>
<div id="mathDrag" style="display:none;width:480px;background-color:#fff;top:90px;right:25px;z-index:100;position:absolute;padding-top: 5px;border: 4px ridge silver; cursor:move;">
<div id="searchCaption" style="float:left;width:480px;text-align: center;">
<b>Equations</b>
</div>
<div id="mathContent" style="width:480px;background-color:#fff;top:28px;right:-4px;z-index:100;position:absolute;padding-top: 5px;border: 4px ridge silver;">
<div id="id_fraction" class="mathList" style="float: left; background-image: url(Math/img/structures.png); width: 42px; height: 41px; background-position: 0px 41px;">
</div>
<div id="id_degree" class="mathList" style="float: left; background-image: url(Math/img/structures.png); width: 42px; height: 41px; background-position: 482px 41px;">
</div>
<div id="id_radical" class="mathList" style="float: left; background-image: url(Math/img/structures.png); width: 42px; height: 41px; background-position: 439px 41px;">
</div>
<div id="id_integral" class="mathList" style="float: left; background-image: url(Math/img/structures.png); width: 42px; height: 41px; background-position: 391px 41px;">
</div>
<div id="id_nary" class="mathList" style="float: left; background-image: url(Math/img/structures.png); width: 42px; height: 41px; background-position: 345px 41px;">
</div>
<div id="id_bracket" class="mathList" style="float: left; background-image: url(Math/img/structures.png); width: 42px; height: 41px; background-position: 308px 41px;">
</div>
<div id="id_trign" class="mathList" style="float: left; background-image: url(Math/img/structures.png); width: 42px; height: 41px; background-position: 264px 41px;">
</div>
<div id="id_accent" class="mathList" style="float: left; background-image: url(Math/img/structures.png); width: 42px; height: 41px; background-position: 214px 41px;">
</div>
<div id="id_limit" class="mathList" style="float: left; background-image: url(Math/img/structures.png); width: 42px; height: 41px; background-position: 171px 41px;">
</div>
<div id="id_operator" class="mathList" style="float: left; background-image: url(Math/img/structures.png); width: 42px; height: 41px; background-position: 112px 41px;">
</div>
<div id="id_matrix" class="mathList" style="float: left; background-image: url(Math/img/structures.png); width: 42px; height: 41px; background-position: 53px 41px;">
</div>
</div>
<div class="fraction mathContainer" style="display:none;width:480px;height:auto;background-color:#fff;top: 80px; right: -4px;z-index:100;position:absolute;padding-top: 5px;border: 4px ridge silver;overflow-y:scroll;">
<div style="float: left; background-image: url(Math/img/fraction.png); width: 80px; height: 104px; background-position: 320px 312px;" value="1"></div>
<div style="float: left; background-image: url(Math/img/fraction.png); width: 80px; height: 104px; background-position: 240px 312px;" value="2"></div>
<div style="float: left; background-image: url(Math/img/fraction.png); width: 80px; height: 104px; background-position: 160px 312px;" value="3"></div>
<div style="float: left; background-image: url(Math/img/fraction.png); width: 80px; height: 104px; background-position: 80px 312px;" value="4"></div>
<div style="float: left; background-image: url(Math/img/fraction.png); width: 80px; height: 104px; background-position: 320px 208px;" value="5"></div>
<div style="float: left; background-image: url(Math/img/fraction.png); width: 80px; height: 104px; background-position: 240px 208px;" value="6"></div>
<div style="float: left; background-image: url(Math/img/fraction.png); width: 80px; height: 104px; background-position: 160px 208px;" value="7"></div>
<div style="float: left; background-image: url(Math/img/fraction.png); width: 80px; height: 104px; background-position: 80px 208px;" value="8"></div>
<div style="float: left; background-image: url(Math/img/fraction.png); width: 80px; height: 104px; background-position: 320px 104px;" value="9"></div>
</div>
<div class="degree mathContainer" style="display:none;width:480px;background-color:#fff;top: 80px; right: -4px;z-index:100;position:absolute;padding-top: 5px;border: 4px ridge silver;overflow-y:scroll;">
<div style="float: left; background-image: url(Math/img/degree.png); width: 80px; height: 104px; background-position: 320px 208px;" value="10"></div>
<div style="float: left; background-image: url(Math/img/degree.png); width: 80px; height: 104px; background-position: 240px 208px;" value="11"></div>
<div style="float: left; background-image: url(Math/img/degree.png); width: 80px; height: 104px; background-position: 160px 208px;" value="12"></div>
<div style="float: left; background-image: url(Math/img/degree.png); width: 80px; height: 104px; background-position: 80px 208px;" value="13"></div>
<div style="float: left; background-image: url(Math/img/degree.png); width: 80px; height: 104px; background-position: 320px 104px;" value="14"></div>
<div style="float: left; background-image: url(Math/img/degree.png); width: 80px; height: 104px; background-position: 240px 104px;" value="15"></div>
<div style="float: left; background-image: url(Math/img/degree.png); width: 80px; height: 104px; background-position: 160px 104px;" value="16"></div>
<div style="float: left; background-image: url(Math/img/degree.png); width: 80px; height: 104px; background-position: 80px 104px;" value="17"></div>
</div>
</div>
<script> <script>
Drag.init( document.getElementById("commentsDrag"), null, null, null, null, null, true ); Drag.init( document.getElementById("commentsDrag"), null, null, null, null, null, true );
document.getElementById("commentsDrag").onDrag = function(X, Y) document.getElementById("commentsDrag").onDrag = function(X, Y)
...@@ -3038,6 +3093,9 @@ ...@@ -3038,6 +3093,9 @@
document.getElementById("search").style.top = sTop; document.getElementById("search").style.top = sTop;
document.getElementById("search").style.right = sRight; document.getElementById("search").style.right = sRight;
}; };
Drag.init( document.getElementById("mathDrag"), null, null, null, null, null, true );
</script> </script>
......
...@@ -7331,8 +7331,233 @@ asc_docs_api.prototype.asc_AddMath = function(Type) ...@@ -7331,8 +7331,233 @@ asc_docs_api.prototype.asc_AddMath = function(Type)
var MathElement = new ParaMath(); var MathElement = new ParaMath();
// TODO: в зависимости от типа Type сделать заполнение MathElement // TODO: в зависимости от типа Type сделать заполнение MathElement
var props = new Object();
var ctrPrp = new CTextPr();
switch (Type)
{
case 1: var sNum = "";
var sDen = "";
CreateFraction(MathElement.Math.Root, props, sNum, sDen);
break;
case 2: props = {type:SKEWED_FRACTION};
var sNum = "";
var sDen = "";
CreateFraction(MathElement.Math.Root, props, sNum, sDen);
break;
case 3: props = {type:LINEAR_FRACTION};
var sNum = "";
var sDen = "";
CreateFraction(MathElement.Math.Root, props, sNum, sDen);
break;
case 4: var oBox = new CBox();
oBox.setCtrPrp(ctrPrp);
oBox.init(props);
MathElement.Math.Root.addElementToContent(oBox);
var oElem = oBox.getBase();
//здесь выставляем для oElem argPr.argSz=-1; этой обертки нет
CreateFraction(oElem, props, sNum, sDen);
break;
case 5: var sNum = "dx";
var sDen = "dy";
CreateFraction(MathElement.Math.Root, props, sNum, sDen);
break;
case 6: var sNum = String.fromCharCode(916) + "y";
var sDen = String.fromCharCode(916) + "x";
CreateFraction(MathElement.Math.Root, props, sNum, sDen);
break;
case 7: var sNum = String.fromCharCode(8706) + "y";
var sDen = String.fromCharCode(8706) + "x";
CreateFraction(MathElement.Math.Root, props, sNum, sDen);
break;
case 8: var sNum = String.fromCharCode(948) + "y";
var sDen = String.fromCharCode(948) + "x";
CreateFraction(MathElement.Math.Root, props, sNum, sDen);
break;
case 9: var sNum = String.fromCharCode(960);
var sDen = "2";
CreateFraction(MathElement.Math.Root, props, sNum, sDen);
break;
case 10: props = {type:DEGREE_SUPERSCRIPT};
CreateDegree(MathElement.Math.Root, props, null, null, null);
break;
case 11: props = {type:DEGREE_SUBSCRIPT};
CreateDegree(MathElement.Math.Root, props, null, null, null);
break;
case 12: props = {type:DEGREE_SubSup};
CreateDegree(MathElement.Math.Root, props, null, null, null);
break;
case 13: props = {type:DEGREE_PreSubSup};
CreateDegree(MathElement.Math.Root, props, null, null, null);
break;
case 14: props = {type:DEGREE_SUBSCRIPT};
var oDegree = new CDegree();
oDegree.setCtrPrp(ctrPrp);
oDegree.init(props);
MathElement.Math.Root.addElementToContent(oDegree);
var oElem = oDegree.getBase();
var oMRun = new CMathRunPrp();
oMRun.setTxtPrp(ctrPrp);
oElem.addElementToContent(oMRun);
var oText = new CMathText();
oText.addTxt("x");
oElem.addElementToContent(oText);
var oSub = oDegree.getLowerIterator();
props = {type:DEGREE_SUPERSCRIPT};
var sBase = "y"
var sSup = "2"
CreateDegree(oSub, props, sBase, sSup, null);
break;
case 15: props = {type:DEGREE_SUPERSCRIPT};
var sBase = "e";
var sSup = "-i" + String.fromCharCode(969) + "t";
CreateDegree(MathElement.Math.Root, props, sBase, sSup, null);
break;
case 16: props = {type:DEGREE_SUPERSCRIPT};
var sBase = "x";
var sSup = "2";
CreateDegree(MathElement.Math.Root, props, sBase, sSup, null);
break;
case 17: props = {type:DEGREE_PreSubSup};
var sBase = "Y";
var sSup = "n";
var sSub = "1";
CreateDegreeSubSup(MathElement.Math.Root, props, sBase, sSup, sSub);
break;
}
this.WordControl.m_oLogicDocument.Paragraph_Add( MathElement ); this.WordControl.m_oLogicDocument.Paragraph_Add( MathElement );
} }
} }
function CreateDegreeSubSup(oParentElem,props,sBaseText,sSupText,sSubText)
{
var oDegreeSubSup = new CDegreeSubSup();
var ctrPrp = new CTextPr();
oDegreeSubSup.setCtrPrp(ctrPrp);
oDegreeSubSup.init(props);
oParentElem.addElementToContent(oDegreeSubSup);
var oElem = oDegreeSubSup.getBase();
if (sBaseText)
{
var oMRun = new CMathRunPrp();
oMRun.setTxtPrp(ctrPrp);
oElem.addElementToContent(oMRun);
for (var i=0;i<sBaseText.length;i++)
{
var oText = new CMathText();
oText.addTxt(sBaseText[i]);
oElem.addElementToContent(oText);
}
}
var oSup = oDegreeSubSup.getUpperIterator();
if (sSupText)
{
var oMRun = new CMathRunPrp();
oMRun.setTxtPrp(ctrPrp);
oSup.addElementToContent(oMRun);
for (var i=0;i<sSupText.length;i++)
{
var oText = new CMathText();
oText.addTxt(sSupText[i]);
oSup.addElementToContent(oText);
}
}
var oSub = oDegreeSubSup.getLowerIterator();
if (sSubText)
{
var oMRun = new CMathRunPrp();
oMRun.setTxtPrp(ctrPrp);
oSub.addElementToContent(oMRun);
for (var i=0;i<sSubText.length;i++)
{
var oText = new CMathText();
oText.addTxt(sSubText[i]);
oSub.addElementToContent(oText);
}
}
}
function CreateDegree(oParentElem,props,sBaseText,sSupText,sSubText)
{
var oDegree = new CDegree();
var ctrPrp = new CTextPr();
oDegree.setCtrPrp(ctrPrp);
oDegree.init(props);
oParentElem.addElementToContent(oDegree);
var oElem = oDegree.getBase();
if (sBaseText)
{
var oMRun = new CMathRunPrp();
oMRun.setTxtPrp(ctrPrp);
oElem.addElementToContent(oMRun);
for (var i=0;i<sBaseText.length;i++)
{
var oText = new CMathText();
oText.addTxt(sBaseText[i]);
oElem.addElementToContent(oText);
}
}
var oSup = oDegree.getUpperIterator();
if (sSupText)
{
var oMRun = new CMathRunPrp();
oMRun.setTxtPrp(ctrPrp);
oSup.addElementToContent(oMRun);
for (var i=0;i<sSupText.length;i++)
{
var oText = new CMathText();
oText.addTxt(sSupText[i]);
oSup.addElementToContent(oText);
}
}
var oSub = oDegree.getLowerIterator();
if (sSubText)
{
var oMRun = new CMathRunPrp();
oMRun.setTxtPrp(ctrPrp);
oSub.addElementToContent(oMRun);
for (var i=0;i<sSubText.length;i++)
{
var oText = new CMathText();
oText.addTxt(sSubText[i]);
oSub.addElementToContent(oText);
}
}
}
function CreateFraction(oParentElem,props,sNumText,sDenText)
{
var oFraction = new CFraction();
var ctrPrp = new CTextPr();
oFraction.setCtrPrp(ctrPrp);
oFraction.init(props);
oParentElem.addElementToContent(oFraction);
var oElemDen = oFraction.getDenominator();
if (sDenText)
{
var oMRun = new CMathRunPrp();
oMRun.setTxtPrp(ctrPrp);
oElemDen.addElementToContent(oMRun);
for (var i=0;i<sDenText.length;i++)
{
var oText = new CMathText();
oText.addTxt(sDenText[i]);
oElemDen.addElementToContent(oText);
}
}
var oElemNum = oFraction.getNumerator();
if(sNumText)
{
oMRun = new CMathRunPrp();
oMRun.setTxtPrp(ctrPrp);
oElemNum.addElementToContent(oMRun);
for (var i=0;i<sNumText.length;i++)
{
oText = new CMathText();
oText.addTxt(sNumText[i]);
oElemNum.addElementToContent(oText);
}
}
}
...@@ -4246,7 +4246,18 @@ $(".colorWatch").mouseover(function(){ ...@@ -4246,7 +4246,18 @@ $(".colorWatch").mouseover(function(){
editor.LoadDocument(c_DocInfo); editor.LoadDocument(c_DocInfo);
$(".mathList").click(function(event)
{
var mathClass = this.id.substring(3);
$(".mathContainer").hide();
$("."+mathClass).show();
});
$(".mathContainer div").click(function()
{
var value = parseInt(this.getAttribute("value"));
editor.asc_AddMath( value );
});
},500) },500)
...@@ -5497,6 +5508,7 @@ function CToolBox() ...@@ -5497,6 +5508,7 @@ function CToolBox()
this.Users = { Active : false, Enabled : true, Over : false }; this.Users = { Active : false, Enabled : true, Over : false };
this.Comments = { Active : false, Enabled : true, Over : false }; this.Comments = { Active : false, Enabled : true, Over : false };
this.Search = { Active : false, Enabled : true, Over : false }; this.Search = { Active : false, Enabled : true, Over : false };
this.Math = { Active : false, Enabled : true, Over : false };
var oThis = this; var oThis = this;
...@@ -5847,6 +5859,51 @@ function CToolBox() ...@@ -5847,6 +5859,51 @@ function CToolBox()
} }
} }
}; };
var ButtonMath = document.createElement("div");
ButtonMath.id = "id_toolbox_buttonMath";
ButtonMath.style["float"] = "left";
ButtonMath.style.backgroundImage = "url('Math/img/Equation.png')";
ButtonMath.style.width = "34px";
ButtonMath.style.height = "30px";
ToolBoxDiv.appendChild( ButtonMath );
ButtonMath.onmouseover = function()
{
if ( true === oThis.Math.Enabled )
{
oThis.Math.Over = true;
oThis.Internal_OnChange_Math();
}
};
ButtonMath.onmouseout = function()
{
if ( true === oThis.Math.Enabled )
{
oThis.Math.Over = false;
oThis.Internal_OnChange_Math();
}
};
ButtonMath.onmousedown = function()
{
if ( true === oThis.Math.Enabled )
{
oThis.Math.Active = oThis.Math.Active === true ? false : true;
oThis.Internal_OnChange_Math();
if ( true === oThis.Math.Active )
{
$("#mathDrag").show();
}
else
{
$("#mathDrag").hide();
$(".mathContainer").hide();
}
}
};
this.Internal_OnChange_Paragraph(); this.Internal_OnChange_Paragraph();
this.Internal_OnChange_Table(); this.Internal_OnChange_Table();
...@@ -5855,6 +5912,7 @@ function CToolBox() ...@@ -5855,6 +5912,7 @@ function CToolBox()
this.Internal_OnChange_Comments(); this.Internal_OnChange_Comments();
this.Internal_OnChange_Users(); this.Internal_OnChange_Users();
this.Internal_OnChange_Search(); this.Internal_OnChange_Search();
this.Internal_OnChange_Math();
}; };
this.Disable_Props = function() this.Disable_Props = function()
...@@ -6056,6 +6114,27 @@ function CToolBox() ...@@ -6056,6 +6114,27 @@ function CToolBox()
BackGroundPosition = "0px -680px"; BackGroundPosition = "0px -680px";
} }
Button.style.backgroundPosition = BackGroundPosition;
};
this.Internal_OnChange_Math = function()
{
var Button = document.getElementById("id_toolbox_buttonMath");
var BackGroundPosition = "";
if ( true != this.Search.Enabled )
{
BackGroundPosition = "0px -740px";
}
else
{
if ( true === this.Math.Over )
BackGroundPosition = "0px -830px";
else if ( true === this.Math.Active )
BackGroundPosition = "0px -830px";
else
BackGroundPosition = "0px -800px";
}
Button.style.backgroundPosition = BackGroundPosition; Button.style.backgroundPosition = BackGroundPosition;
}; };
} }
......
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