Commit 98d3e79f authored by Sergey.Luzyanin's avatar Sergey.Luzyanin

git-svn-id:...

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@51399 954022d7-b5bf-4e40-9824-e11837661b57
parent aea82a77
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
function NullShapeState()
{
this.id = 0;
this.OnMouseDown = function(AutoShapes, e, X, Y)
{
AutoShapes.stX=X;
AutoShapes.stY=Y;
var glyphs = AutoShapes.ArrGlyph;
var trackObjects = AutoShapes.ArrTrackObj;
//if( e.ClickCount == 1 )
{
if( AutoShapes.NumSelected > 0 ) {
if(AutoShapes.NumSelected == 1) {
for(var i = 0, n = glyphs.length; i < n; ++i) {
if(glyphs[i].selected)
{
var hit = glyphs[i].HitAdj(X, Y);
if( hit.hit )
{
AutoShapes.obj = glyphs[i];
trackObjects.length = 0;
var _track_shape = glyphs[i].createDuplicateForTrack(AutoShapes);
_track_shape.Recalculate();
var trackObject =
{
obj: _track_shape,
hit: hit,
num: i
};
trackObjects.push(trackObject);
AutoShapes.preTrackArr = trackObjects;
AutoShapes.ArrTrackObj = [];
AutoShapes.NumEditShape=i;
AutoShapes.DrawingDocument.SetCursorType("crosshair");
AutoShapes.ChangeState(new PreChangeAdjState());
AutoShapes.updateSelectionMap();
AutoShapes.Document.CurPos.Type = docpostype_Content;
AutoShapes.Document.Document_UpdateInterfaceState();
return;
}
else {
break;
}
}
}
}
hit = {hit: false};
for( i = glyphs.length - 1; i>-1; --i ) {
if( glyphs[i].selected ){
hit=glyphs[i].HitHandle(X, Y);
if(hit.hit) {
break;
}
}
}
if( i>-1 ) {
if( hit.num != 8 ) {
var cardDirection = glyphs[i].NumToCardDir(hit.num);
AutoShapes.NumHResize = hit.num;
AutoShapes.obj = glyphs[i];
trackObjects.length = 0;
for( j=0; j < glyphs.length; ++j ) {
if( glyphs[j].selected ) {
var _track_shape = glyphs[j].createDuplicateForTrack(AutoShapes);
_track_shape.Recalculate();
trackObject = {
obj: _track_shape,
num_h: glyphs[j].CardDirToNum(cardDirection),
num: j
};
trackObjects.push(trackObject);
if( i == j ){
AutoShapes.NumEditShape = trackObjects.length-1;
}
}
}
AutoShapes.preTrackArr = trackObjects;
AutoShapes.ArrTrackObj = [];
AutoShapes.ChangeState(new PreResizeState());
AutoShapes.DrawingDocument.SetCursorType("crosshair");
AutoShapes.updateSelectionMap();
AutoShapes.Document.CurPos.Type = docpostype_Content;
AutoShapes.Document.Document_UpdateInterfaceState();
return;
}
else {
AutoShapes.obj = glyphs[i];
trackObjects.length = 0;
for(var j = 0; j < glyphs.length; ++j) {
if( glyphs[j].selected ) {
var _track_shape = glyphs[j].createDuplicateForTrack(AutoShapes);
_track_shape.Recalculate();
trackObject = {
obj: (_track_shape),
num: j
};
trackObjects.push(trackObject);
}
}
AutoShapes.preTrackArr = trackObjects;
AutoShapes.ArrTrackObj = [];
AutoShapes.ChangeState(new PreRotateState());
AutoShapes.DrawingDocument.SetCursorType("crosshair");
AutoShapes.NumEditShape = i;
AutoShapes.updateSelectionMap();
AutoShapes.Document.CurPos.Type = docpostype_Content;
AutoShapes.Document.Document_UpdateInterfaceState();
return;
}
}
}
for(i = glyphs.length-1; i > -1; --i) {
var glyph = glyphs[i];
if(glyph.Hit(X, Y)
||(/*glyph.text_flag&& TODO:*/ glyph.InTextRect(X, Y))
||(glyph.selected && glyph.HitInBox(X, Y))) {
break;
}
}
AutoShapes.selectedCount();
if(i>-1)
{
if((!e.CtrlKey || (AutoShapes.Document.CurPos.Type == docpostype_FlowObjects && AutoShapes.obj == glyph) || glyph.hitToHyperlink(X, Y))
&& glyph.text_flag
&& glyph.InTextRect(X, Y)
&& !glyph.HitInPath(X, Y)
&& !( glyph.selected && glyph.HitInBox(X, Y)))
{
AutoShapes.obj = glyph;
AutoShapes.NumEditShape = i;
glyph.addTextFlag = true;
//AutoShapes.Document.Document_UpdateInterfaceState();
AutoShapes.ChangeState(new AddTextState());
if(glyph.txBody && glyph.txBody.compiledBodyPr && glyph.txBody.compiledBodyPr.anchor != undefined)
{
var _vertical_align = glyph.txBody.compiledBodyPr.anchor;
editor.sync_VerticalTextAlign(_vertical_align);
}
AutoShapes.Document.CurPos.Type=docpostype_FlowObjects;
for(var p=0; p < glyphs.length; ++p)
{
glyphs[p].selected=false;
}
glyph.selected = true;
AutoShapes.NumSelected = 1;
if(glyph.isEmptyPlaceholder())
{
AutoShapes.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum, AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
}
// AutoShapes.Document.DrawingDocument.m_oWordControl.OnUpdateOverlay(true);
AutoShapes.updateSelectionMap();
return;
}
var preMoveObj = null;
if(e.CtrlKey || e.ShiftKey) {
if(!glyph.selected) {
glyph.selected = true;
++AutoShapes.NumSelected;
AutoShapes.SelectGroup = false;
}
else {
AutoShapes.SelectGroup = glyph.IsGroup();
preMoveObj = glyph;
}
}
else {
if(!glyph.selected) {
for( j=0; j < glyphs.length; ++j) {
glyphs[j].selected = false;
}
glyph.selected = true;
AutoShapes.NumSelected = 1;
AutoShapes.SelectGroup = false;
}
else {
AutoShapes.SelectGroup = glyph.IsGroup();
}
}
trackObjects.length = 0;
for(j=0; j < glyphs.length; ++j)
{
if( glyphs[j].selected )
{
var _track_shape = glyphs[j].createDuplicateForTrack(AutoShapes);
_track_shape.Recalculate();
trackObject = {
obj: _track_shape,
stX: glyphs[j].pH,
stY: glyphs[j].pV,
num: j
};
AutoShapes.ArrTrackObj.push(trackObject);
}
if(i==j) {
AutoShapes.NumEditShape = trackObjects.length-1;
}
}
AutoShapes.obj = glyph;
if(glyph.IsGroup()) {
AutoShapes.NumGroup=i;
}
AutoShapes.preTrackArr = trackObjects;
AutoShapes.ArrTrackObj = [];
AutoShapes.Document.CurPos.Type = docpostype_Content;
AutoShapes.Document.Document_UpdateInterfaceState();
AutoShapes.ChangeState(new PreMoveState(preMoveObj));
AutoShapes.Document.DrawingDocument.m_oWordControl.OnUpdateOverlay(true);
AutoShapes.DrawingDocument.SetCursorType("move");
AutoShapes.updateSelectionMap();
return;
}
else
{
for( j=0; j < glyphs.length; ++j) {
glyphs[j].selected = false;
}
AutoShapes.NumSelected=0;
AutoShapes.Document.DrawingDocument.m_oWordControl.OnUpdateOverlay(true);
AutoShapes.updateSelectionMap();
AutoShapes.Document.CurPos.Type = docpostype_Content;
// AutoShapes.Document.Document_UpdateInterfaceState();
AutoShapes.selectionRect = {x : X, y : X, w: 0, h: 0};
AutoShapes.ChangeState(new TrackSelectionRect());
/* var _empty_para_pr =
{
Ind : { Left : UnknownValue, Right : UnknownValue, FirstLine : UnknownValue },
Jc : UnknownValue,
Spacing : { Line : UnknownValue, LineRule : UnknownValue, Before : UnknownValue, After : UnknownValue, AfterAutoSpacing : UnknownValue, BeforeAutoSpacing : UnknownValue },
PageBreakBefore : UnknownValue,
KeepLines : UnknownValue,
ContextualSpacing : UnknownValue,
Shd : UnknownValue,
StyleId : -1,
NumPr : null,
Brd :
{
Between : null,
Bottom : null,
Left : null,
Right : null
},
ListType:
{
Type: -1,
SubType: -1
}
};
var _empty_text_pr =
{
Bold : false,
Italic : false,
Underline : false,
Strikeout : false,
FontSize : "",
FontFamily : {Index : 0, Name : ""},
VertAlign : vertalign_Baseline,
Color : { r : 0, g : 0, b : 0},
HighLight : highlight_None
};
editor.UpdateTextPr(_empty_text_pr);
editor.UpdateParagraphProp(_empty_para_pr);
editor.asc_fireCallback("asc_canIncreaseIndent", false);
editor.asc_fireCallback("asc_canDecreaseIndent", false); */
editor.ClearPropObjCallback();
editor.sync_BeginCatchSelectedElements();
editor.sync_slidePropCallback(AutoShapes.Document.Slides[AutoShapes.Document.CurPage]);
editor.sync_EndCatchSelectedElements();
return;
}
}
/*else if(e.ClickCount>=2) {
for(i = glyphs.length-1; i > -1; --i) {
glyph = glyphs[i];
if( glyph.Hit(X, Y)
|| ( glyph.InTextRect(X, Y)
&& !glyph.HitInPath(X, Y) ) ) {
break;
}
}
if(i>-1)
{
if( glyph.text_flag
&& glyph.InTextRect(X, Y)
&& !glyph.HitInPath(X, Y) )
{
AutoShapes.obj = glyph;
AutoShapes.NumEditShape = i;
glyph.addTextFlag = true;
AutoShapes.Document.Document_UpdateInterfaceState();
AutoShapes.ChangeState(new AddTextState());
if(glyph.txBody && glyph.txBody.compiledBodyPr && glyph.txBody.compiledBodyPr.anchor)
{
var _vertical_align = glyph.txBody.compiledBodyPr.anchor;
editor.sync_VerticalTextAlign(_vertical_align);
}
if(glyph.isEmptyPlaceholder())
{
AutoShapes.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum, AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
}
AutoShapes.Document.CurPos.Type=docpostype_FlowObjects;
for(p=0; p<glyphs.length; ++p){
glyphs[p].slected = false;
}
glyphs[i].slected=true;
AutoShapes.NumSelected=1;
AutoShapes.updateSelectionMap();
}
}
} */
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
AutoShapes.updateCursorType(X, Y, e);
return;
var glyphs = AutoShapes.ArrGlyph;
if( AutoShapes.NumSelected > 0 )
{
if(AutoShapes.NumSelected == 1)
{
for(var i = 0, n = glyphs.length; i < n; ++i)
{
if(glyphs[i].selected)
{
var hit = glyphs[i].HitAdj(X, Y);
if( hit.hit )
{
AutoShapes.obj = glyphs[i];
AutoShapes.DrawingDocument.SetCursorType("crosshair");
return;
}
else
{
break;
}
}
}
}
hit = {hit: false};
for( i = glyphs.length - 1; i>-1; --i )
{
if( glyphs[i].selected )
{
hit=glyphs[i].HitHandle(X, Y);
if(hit.hit)
{
break;
}
}
}
if( i>-1 ) {
if( hit.num != 8 )
{
var cardDirection = glyphs[i].NumToCardDir(hit.num);
switch(cardDirection)
{
case N:
case S:
{
AutoShapes.DrawingDocument.SetCursorType("s-resize");
break;
}
case W:
case E:
{
AutoShapes.DrawingDocument.SetCursorType("w-resize");
break;
}
case SE:
case NW: {
AutoShapes.DrawingDocument.SetCursorType("se-resize");
break;
}
case SW:
case NE:
{
AutoShapes.DrawingDocument.SetCursorType("sw-resize");
break;
}
}
return;
}
else
{
AutoShapes.DrawingDocument.SetCursorType("crosshair");
return;
}
}
}
for(i = glyphs.length-1; i > -1; --i)
{
var glyph = glyphs[i];
if(glyph.Hit(X, Y)
||(/*glyph.text_flag&& TODO:*/ glyph.InTextRect(X, Y))
||(glyph.selected && glyph.HitInBox(X, Y)))
{
break;
}
}
if(i>-1)
{
if( glyph.text_flag && glyph.InTextRect(X, Y)
&& !glyph.HitInPath(X, Y)
&& !( glyph.selected && glyph.HitInBox(X, Y)) )
{
if(glyph instanceof CGraphicFrame && glyph.graphicObject !== null && typeof glyph.graphicObject === "object"
&& typeof glyph.graphicObject.Update_CursorType === "function")
{
glyph.graphicObject.Update_CursorType(X - glyph.pH, Y - glyph.pV, AutoShapes.SlideNum)
}
else
{
AutoShapes.DrawingDocument.SetCursorType("text");
}
return;
}
AutoShapes.DrawingDocument.SetCursorType("move");
return;
}
else
{
AutoShapes.DrawingDocument.SetCursorType("default");
return;
}
};
this.OnMouseUp=function(AutoShapes, e, X, Y)
{
return;
};
}
function TrackSelectionRect()
{
this.OnMouseDown = function(AutoShapes, e, X, Y)
{
return;
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
AutoShapes.selectionRect = {x : AutoShapes.stX, y : AutoShapes.stY, w : X - AutoShapes.stX, h : Y - AutoShapes.stY};
AutoShapes.Document.DrawingDocument.m_oWordControl.OnUpdateOverlay(true);
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
var _glyph_index;
var _glyphs_array = AutoShapes.ArrGlyph;
var _glyph, _glyph_transform;
var _xlt, _ylt, _xrt, _yrt, _xrb, _yrb, _xlb, _ylb;
var _rect_l = Math.min(AutoShapes.selectionRect.x, AutoShapes.selectionRect.x + AutoShapes.selectionRect.w);
var _rect_r = Math.max(AutoShapes.selectionRect.x, AutoShapes.selectionRect.x + AutoShapes.selectionRect.w);
var _rect_t = Math.min(AutoShapes.selectionRect.y, AutoShapes.selectionRect.y + AutoShapes.selectionRect.h);
var _rect_b = Math.max(AutoShapes.selectionRect.y, AutoShapes.selectionRect.y + AutoShapes.selectionRect.h);
for(_glyph_index = 0; _glyph_index < _glyphs_array.length; ++_glyph_index)
{
_glyph = _glyphs_array[_glyph_index];
_glyph_transform = _glyph.TransformMatrix;
_xlt = _glyph_transform.TransformPointX(0, 0);
_ylt = _glyph_transform.TransformPointY(0, 0);
_xrt = _glyph_transform.TransformPointX( _glyph.ext.cx, 0);
_yrt = _glyph_transform.TransformPointY( _glyph.ext.cx, 0);
_xrb = _glyph_transform.TransformPointX( _glyph.ext.cx, _glyph.ext.cy);
_yrb = _glyph_transform.TransformPointY( _glyph.ext.cx, _glyph.ext.cy);
_xlb = _glyph_transform.TransformPointX(0, _glyph.ext.cy);
_ylb = _glyph_transform.TransformPointY(0, _glyph.ext.cy);
_glyph.selected = (_xlb >= _rect_l && _xlb <= _rect_r) && (_xrb >= _rect_l && _xrb <= _rect_r)
&& (_xlt >= _rect_l && _xlt <= _rect_r) && (_xrt >= _rect_l && _xrt <= _rect_r) &&
(_ylb >= _rect_t && _ylb <= _rect_b) && (_yrb >= _rect_t && _yrb <= _rect_b)
&& (_ylt >= _rect_t && _ylt <= _rect_b) && (_yrt >= _rect_t && _yrt <= _rect_b);
}
AutoShapes.selectionRect = null;
AutoShapes.updateSelectionMap();
AutoShapes.selectedCount();
AutoShapes.Document.DrawingDocument.m_oWordControl.OnUpdateOverlay(true);
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.Document.Document_UpdateInterfaceState();
};
}
function ShapeAddState()
{
this.id=1;
this.OnMouseDown = function(AutoShapes, e, X, Y)
{
AutoShapes.resetState();
AutoShapes.Document.CurPos.Type = docpostype_Content;
AutoShapes.Document.RecalculateCurPos();
AutoShapes.Document.Document_UpdateSelectionState();
AutoShapes.stX=X;
AutoShapes.stY=Y;
var shape;
shape = new CShape(AutoShapes.Document.Slides[AutoShapes.SlideNum]);
shape.nvSpPr = new UniNvPr();
shape.nvSpPr.cNvPr.id = ++AutoShapes.Document.Slides[AutoShapes.SlideNum].maxId;
shape.spPr.xfrm.offX = X;
shape.spPr.xfrm.offY = Y;
shape.spPr.xfrm.extX = 1;
shape.spPr.xfrm.extY = 1;
shape.setContainer(AutoShapes);
shape.txBody = new CTextBody(shape);
shape.txBody.bodyPr = new CBodyPr();
shape.txBody.bodyPr.setDefault();
shape.txBody.bodyPr.anchor = 1;//center
shape.txBody.content = new CDocumentContent(shape, AutoShapes.DrawingDocument,0, 0, 0, 0, 0, 0);
shape.txBody.content.Content[0].Set_Align( 2, false );
if(AutoShapes.CurPreset != "textRect")
{
shape.style = CreateDefaultShapeStyle();
shape.spPr.Geometry = CreateGeometry(AutoShapes.CurPreset);
}
else
{
shape.style = null;
shape.spPr.Geometry = CreateGeometry("rect");
}
shape.geometry = shape.spPr.Geometry;
shape.calculate2();
AutoShapes.resetState();
AutoShapes.ArrTrackObj.length=0;
AutoShapes.ArrTrackObj.push({obj:shape});
AutoShapes.ChangeState(new TrackNewShapeState());
AutoShapes.Document.DrawingDocument.StartTrackAutoshape();
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
}
}
function StateAddArrows(bTailEnd, bHeadEnd)
{
this.id=1;
this.bTailEnd = bTailEnd;
this.bHeadEnd = bHeadEnd;
this.OnMouseDown = function(AutoShapes, e, X, Y)
{
AutoShapes.resetState();
AutoShapes.Document.CurPos.Type = docpostype_Content;
AutoShapes.Document.RecalculateCurPos();
AutoShapes.Document.Document_UpdateSelectionState();
AutoShapes.stX=X;
AutoShapes.stY=Y;
var shape;
shape = new CShape(AutoShapes.Document.Slides[AutoShapes.SlideNum]);
shape.nvSpPr = new UniNvPr();
shape.nvSpPr.cNvPr.id = ++AutoShapes.Document.Slides[AutoShapes.SlideNum].maxId;
shape.spPr.xfrm.offX = X;
shape.spPr.xfrm.offY = Y;
shape.spPr.xfrm.extX = 1;
shape.spPr.xfrm.extY = 1;
shape.txBody = new CTextBody(shape);
shape.txBody.bodyPr = new CBodyPr();
shape.txBody.bodyPr.setDefault();
shape.txBody.bodyPr.anchor = 1;//center
shape.style = CreateDefaultShapeStyle();
shape.txBody.content = new CDocumentContent(shape, AutoShapes.DrawingDocument,0, 0, 0, 0, 0, 0);
shape.txBody.content.Content[0].Set_Align( 2, false );
shape.spPr.Geometry = CreateGeometry(AutoShapes.CurPreset);
shape.spPr.ln = new CLn();
if(this.bTailEnd)
{
shape.spPr.ln.tailEnd = new EndArrow();
shape.spPr.ln.tailEnd.type = LineEndType.Arrow;
}
if(this.bHeadEnd)
{
shape.spPr.ln.headEnd = new EndArrow();
shape.spPr.ln.headEnd.type = LineEndType.Arrow;
}
shape.geometry = shape.spPr.Geometry;
shape.calculate2();
AutoShapes.resetState();
AutoShapes.ArrTrackObj.length=0;
AutoShapes.ArrTrackObj.push({obj:shape});
AutoShapes.ChangeState(new TrackNewShapeState());
AutoShapes.Document.DrawingDocument.StartTrackAutoshape();
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
};
this.OnMouseUp =function(AutoShapes, e, X, Y)
{
}
}
function TrackNewShapeState()
{
this.id=2;
this.OnMouseDown = function(AutoShapes, e, X, Y)
{
AutoShapes.stX=X;
AutoShapes.stY=Y;
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
if(e.IsLocked) {
var dx=0, dy=0, i, j;
for(i=0; i<AutoShapes.ArrGlyph.length; i++)
{
dx=JoinedH(AutoShapes.ArrTrackObj[0].obj, AutoShapes.ArrGlyph[i]);
if(Math.abs(dx)>0)
break;
if(AutoShapes.ArrGlyph[i].IsGroup())
{
for(j=0; j<AutoShapes.ArrGlyph[i].ArrGlyph.length; ++j)
{
dx=JoinedH(AutoShapes.ArrTrackObj[0].obj, AutoShapes.ArrGlyph[i].ArrGlyph[j]);
if(Math.abs(dx)>0)
break;
}
}
if(Math.abs(dx)>0)
break;
}
for(i=0; i<AutoShapes.ArrGlyph.length; i++)
{
dy=JoinedV(AutoShapes.ArrTrackObj[0].obj, AutoShapes.ArrGlyph[i]);
if(Math.abs(dy)>0)
break;
if(AutoShapes.ArrGlyph[i].IsGroup())
{
for(j=0; j<AutoShapes.ArrGlyph[i].ArrGlyph.length; ++j)
{
dy=JoinedV(AutoShapes.ArrTrackObj[0].obj, AutoShapes.ArrGlyph[i].ArrGlyph[j]);
if(Math.abs(dy)>0)
break;
}
}
if(Math.abs(dy)>0)
break;
}
if(Math.abs(X-AutoShapes.stX)<min_distance_joined)
X=AutoShapes.stX;
else
X-=dx;
if(Math.abs(Y-AutoShapes.stY)<min_distance_joined)
Y=AutoShapes.stY;
else
Y-=dy;
var pH, pV, ext={}, off={x:0, y:0};
var DX=X-AutoShapes.stX, DY=Y-AutoShapes.stY;
if( !AutoShapes.ArrTrackObj[0].obj.isLine )
{
if(e.CtrlKey)
{
if(X>AutoShapes.stX)
{
if(DX>min_size2 || AutoShapes.ArrTrackObj[0].obj.IsLine())
{
ext.cx=2*DX;
pH=2*AutoShapes.stX-X;
}
else
{
ext.cx=2*min_size2;
pH=AutoShapes.stX-min_size2;
}
}
else
{
if(DX<-min_size2 || AutoShapes.ArrTrackObj[0].obj.IsLine())
{
ext.cx=2*Math.abs(DX);
pH=X;
}
else
{
ext.cx=2*min_size2;
pH=AutoShapes.stX-min_size2;
}
}
if(Y>AutoShapes.stY )
{
if(DY>min_size2 || AutoShapes.ArrTrackObj[0].obj.IsLine())
{
ext.cy=2*DY;
pV=2*AutoShapes.stY-Y;
}
else
{
ext.cy=2*min_size2;
pV=AutoShapes.stY-min_size2;
}
}
else
{
if(DY<-min_size2 || AutoShapes.ArrTrackObj[0].obj.IsLine())
{
ext.cy=2*Math.abs(DY);
pV=Y;
}
else
{
ext.cy=2*min_size2;
pV=AutoShapes.stY-min_size2;
}
}
}
else
{
if(X>AutoShapes.stX)
{
if(DX>min_size2 || AutoShapes.ArrTrackObj[0].obj.IsLine())
{
ext.cx=DX;
}
else
{
ext.cx=min_size2;
}
pH=AutoShapes.stX;
}
else
{
if(DX<-min_size2 || AutoShapes.ArrTrackObj[0].obj.IsLine())
{
ext.cx=-DX;
pH=X;
}
else
{
ext.cx=min_size2;
pH=AutoShapes.stX-min_size2;
}
}
if(Y>AutoShapes.stY)
{
if(DY>min_size2 || AutoShapes.ArrTrackObj[0].obj.IsLine())
{
ext.cy=DY;
}
else
{
ext.cy=min_size2;
}
pV=AutoShapes.stY;
}
else
{
if(DY<-min_size2 || AutoShapes.ArrTrackObj[0].obj.IsLine())
{
ext.cy=-DY;
pV=Y;
}
else
{
ext.cy=min_size2;
pV=AutoShapes.stY-min_size2;
}
}
}
}
else
{
DX=X-AutoShapes.stX;
DY=Y-AutoShapes.stY;
if(X>=AutoShapes.stX&&Y>=AutoShapes.stY)
{
pH=AutoShapes.stX;
pV=AutoShapes.stY;
AutoShapes.ArrTrackObj[0].obj.flipH=false;
AutoShapes.ArrTrackObj[0].obj.flipV=false;
off = {x: 0, y:0};
ext = {cx: X-AutoShapes.stX, cy: Y-AutoShapes.stY};
}
else if(X>=AutoShapes.stX&&Y<AutoShapes.stY)
{
pH=AutoShapes.stX;
pV=Y;
AutoShapes.ArrTrackObj[0].obj.flipH=false;
AutoShapes.ArrTrackObj[0].obj.flipV=true;
off = {x: 0, y:0};
ext = {cx: X-AutoShapes.stX, cy: AutoShapes.stY-Y};
}
else if(X<AutoShapes.stX&&Y>=AutoShapes.stY)
{
pH=X;
pV=AutoShapes.stY;
AutoShapes.ArrTrackObj[0].obj.flipH=true;
AutoShapes.ArrTrackObj[0].obj.flipV=false;
off = {x: 0, y:0};
ext = {cx: AutoShapes.stX-X, cy: Y-AutoShapes.stY};
}
else if(X<AutoShapes.stX&&Y<AutoShapes.stY)
{
pH=X;
pV=Y;
AutoShapes.ArrTrackObj[0].obj.flipH=true;
AutoShapes.ArrTrackObj[0].obj.flipV=true;
off = {x: 0, y:0};
ext = {cx: AutoShapes.stX-X, cy: AutoShapes.stY-Y};
}
}
AutoShapes.ArrTrackObj[0].obj.pH=pH;
AutoShapes.ArrTrackObj[0].obj.pV=pV;
AutoShapes.ArrTrackObj[0].obj.off=off;
AutoShapes.ArrTrackObj[0].obj.ext=ext;
if(AutoShapes.ArrTrackObj[0].obj.IsLine())
{
AutoShapes.ArrTrackObj[0].obj.flipH = AutoShapes.stX > X;
AutoShapes.ArrTrackObj[0].obj.flipV = AutoShapes.stY > Y;
}
AutoShapes.ArrTrackObj[0].obj.Recalculate();
AutoShapes.Document.DrawingDocument.m_oWordControl.OnUpdateOverlay(false);
// AutoShapes.DrawingDocument.OnRecalculatePage( AutoShapes.SlideNum, AutoShapes.Document.Pages[AutoShapes.SlideNum] );
}
};
this.OnMouseUp =function(AutoShapes, e, X, Y) {
var trackShape = AutoShapes.ArrTrackObj[0].obj;
if( AutoShapes.stX == X && AutoShapes.stY == Y ) {
trackShape.ext = { cx : 60, cy : 60 };
trackShape.Recalculate();
}
History.Create_NewPoint();
var historyData = {};
historyData.num = AutoShapes.ArrGlyph.length;
historyData.shape = trackShape;
historyData.undo_function = function(data)
{
this.ArrGlyph.splice(data.num, 1);
};
historyData.redo_function = function(data)
{
this.ArrGlyph.splice(data.num, 0, data.shape);
};
History.Add(AutoShapes, historyData);
AutoShapes.Document.Document_UpdateUndoRedoState();
AutoShapes.Add(trackShape);
trackShape.Container = AutoShapes;
AutoShapes.ArrTrackObj.length=0;
if(AutoShapes.CurPreset == "textRect")
{
AutoShapes.obj = trackShape;
AutoShapes.NumEditShape = AutoShapes.ArrGlyph.length-1;
trackShape.addTextFlag = true;
trackShape.txBody.content.Selection_SetStart(0, 0, 0 , e);
trackShape.txBody.content.Selection_SetEnd(0, 0, 0 , e);
AutoShapes.ChangeState(new AddTextState());
if(trackShape.txBody && trackShape.txBody.compiledBodyPr && trackShape.txBody.compiledBodyPr.anchor != undefined)
{
var _vertical_align = trackShape.txBody.compiledBodyPr.anchor;
editor.sync_VerticalTextAlign(_vertical_align);
}
AutoShapes.Document.CurPos.Type=docpostype_FlowObjects;
AutoShapes.Document.Document_UpdateSelectionState();
AutoShapes.DrawingDocument.EndTrackAutoShape();
AutoShapes.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum, AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
}
else
{
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.DrawingDocument.EndTrackAutoShape();
AutoShapes.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum, AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
}
AutoShapes.obj=trackShape;
trackShape.calculateXfrm();
editor.sync_EndAddShape();
};
}
function PreResizeState()
{
this.OnMouseDown = function(AutoShapes, e, X, Y)
{};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
if(AutoShapes.Document.viewMode === true)
{
AutoShapes.ArrTrackObj = [];
AutoShapes.preTrackArr = [];
AutoShapes.ChangeState(new NullShapeState());
return;
}
AutoShapes.ArrTrackObj = AutoShapes.preTrackArr;
AutoShapes.preTrackArr = [];
AutoShapes.DrawingDocument.StartTrackAutoshape();
AutoShapes.ChangeState(new ResizeGroupObjState());
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
AutoShapes.ArrTrackObj = [];
AutoShapes.preTrackArr = [];
AutoShapes.ChangeState(new NullShapeState());
};
}
function ResizeGroupObjState()
{
this.OnMouseDown = function (AutoShapes, e, X, Y) {
AutoShapes.stX=X;
AutoShapes.stY=Y;
};
this.OnMouseMove = function (AutoShapes, e, X, Y) {
var dx=0, dy=0, i, j;
for(i=0; i<AutoShapes.ArrGlyph.length; i++)
{
dx=JoinedPointH(X, AutoShapes.ArrGlyph[i]);
if(Math.abs(dx)>0)
break;
if(AutoShapes.ArrGlyph[i].IsGroup())
{
for(j=0; j<AutoShapes.ArrGlyph[i].ArrGlyph.length; ++j)
{
dx=JoinedPointH(X, AutoShapes.ArrGlyph[i].ArrGlyph[j]);
if(Math.abs(dx)>0)
break;
}
}
if(Math.abs(dx)>0)
break;
}
for(i=0; i<AutoShapes.ArrGlyph.length; i++)
{
dy=JoinedPointV(Y, AutoShapes.ArrGlyph[i]);
if(Math.abs(dy)>0)
break;
if(AutoShapes.ArrGlyph[i].IsGroup())
{
for(j=0; j<AutoShapes.ArrGlyph[i].ArrGlyph.length; ++j)
{
dy=JoinedPointV(Y, AutoShapes.ArrGlyph[i].ArrGlyph[j]);
if(Math.abs(dy)>0)
break;
}
}
if(Math.abs(dy)>0)
break;
}
var K=AutoShapes.obj.DefineResizeCoef(AutoShapes.NumHResize, X-dx, Y-dy);
if(!e.CtrlKey && !e.ShiftKey)
{
for(i=0; i<AutoShapes.ArrTrackObj.length; ++i)
{
AutoShapes.ArrTrackObj[i].obj = AutoShapes.ArrGlyph[AutoShapes.ArrTrackObj[i].num].createDuplicateForTrack(AutoShapes);//clone(AutoShapes.ArrGlyph[AutoShapes.ArrTrackObj[i].num]);
var trackObj = AutoShapes.ArrTrackObj[i].obj;
trackObj.Resize(AutoShapes.ArrTrackObj[i].num_h, K.kd1, K.kd2);
}
}
else if(e.ShiftKey)
{
for(i=0; i<AutoShapes.ArrTrackObj.length; ++i)
{
AutoShapes.ArrTrackObj[i].obj = AutoShapes.ArrGlyph[AutoShapes.ArrTrackObj[i].num].createDuplicateForTrack(AutoShapes);//clone(AutoShapes.ArrGlyph[AutoShapes.ArrTrackObj[i].num]);
var trackObj = AutoShapes.ArrTrackObj[i].obj;
var kd1, kd2;
if(AutoShapes.ArrTrackObj[i].num_h % 2 == 0)
{
var _old_aspect = trackObj.getAspect(AutoShapes.ArrTrackObj[i].num_h);
var _new_aspect = _old_aspect*(Math.abs(K.kd1/ K.kd2));
if (_new_aspect >= _old_aspect)
{
kd1 = K.kd1;
var sign = K.kd2 >= 0 ? 1 : -1 ;
kd2 = Math.abs(kd1)*sign;
}
else
{
kd1 = Math.abs(K.kd2)*(K.kd1 >= 0 ? 1 : -1);
kd2 = K.kd2;
}
}
else
{
kd1 = K.kd1;
kd2 = K.kd2;
}
trackObj.Resize(AutoShapes.ArrTrackObj[i].num_h, kd1, kd2);
}
}
else if(e.CtrlKey)
{
for(i=0; i<AutoShapes.ArrTrackObj.length; ++i)
{
AutoShapes.ArrTrackObj[i].obj = AutoShapes.ArrGlyph[AutoShapes.ArrTrackObj[i].num].createDuplicateForTrack(AutoShapes);//clone(AutoShapes.ArrGlyph[AutoShapes.ArrTrackObj[i].num]);
var trackObj = AutoShapes.ArrTrackObj[i].obj;
trackObj.ResizeRelativeCenter(AutoShapes.ArrTrackObj[i].num_h, K.kd1, K.kd2);
}
}
AutoShapes.Document.DrawingDocument.m_oWordControl.OnUpdateOverlay(false);
};
this.OnMouseUp = function (AutoShapes, e, X, Y)
{
var numResizeShapeInTrackArray = 0, trackObjects = AutoShapes.ArrTrackObj;
var i, j;
for(i = 0; i < trackObjects.length; ++i)
{
if(trackObjects[i].num == AutoShapes.NumEditShape)
{
numResizeShapeInTrackArray = i;
break;
}
}
if(trackObjects[numResizeShapeInTrackArray].obj.ext.cx!=AutoShapes.ArrGlyph[AutoShapes.NumEditShape].ext.cx
|| trackObjects[numResizeShapeInTrackArray].obj.ext.cy!=AutoShapes.ArrGlyph[AutoShapes.NumEditShape].ext.cy
|| trackObjects[numResizeShapeInTrackArray].obj.flipH!=AutoShapes.ArrGlyph[AutoShapes.NumEditShape].flipH
|| trackObjects[numResizeShapeInTrackArray].obj.flipV!=AutoShapes.ArrGlyph[AutoShapes.NumEditShape].flipV)
{
History.Create_NewPoint();
AutoShapes.addHistorySelectedState();
for(i=0; i<AutoShapes.ArrTrackObj.length; i++)
{
var shape = AutoShapes.ArrGlyph[AutoShapes.ArrTrackObj[i].num];
var trackObj = AutoShapes.ArrTrackObj[i].obj;
shape.copyTransform(trackObj);
shape.Recalculate();
shape.updateCursorTypes();
shape.calculateXfrm();
}
}
AutoShapes.ArrTrackObj.length=0;
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.Document.DrawingDocument.EndTrackAutoShape();
AutoShapes.Document.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum,AutoShapes.Document.Slides[AutoShapes.SlideNum]);
var shp=AutoShapes.obj;
AutoShapes.Document.Document_UpdateUndoRedoState();
}
}
function PreChangeAdjState()
{
this.OnMouseDown = function(AutoShapes, e, X, Y)
{};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
if(AutoShapes.Document.viewMode === true)
{
AutoShapes.ArrTrackObj = [];
AutoShapes.preTrackArr = [];
AutoShapes.ChangeState(new NullShapeState());
return;
}
AutoShapes.ArrTrackObj = AutoShapes.preTrackArr;
AutoShapes.preTrackArr = [];
var shape =AutoShapes.obj, hit = AutoShapes.ArrTrackObj[0].hit, trackShape = AutoShapes.ArrTrackObj[0].obj;
var geometry = shape.geometry;
var tmpHistory = {};
if(hit.type == xy)
{
trackShape.CalculateAdjRange(hit.num);
if(geometry.ahXYLst[hit.num].gdRefX!=undefined && geometry.gdLst[geometry.ahXYLst[hit.num].gdRefX]!= undefined)
{
tmpHistory.old_gdValue1 = geometry.gdLst[geometry.ahXYLst[hit.num].gdRefX];
}
if(geometry.ahXYLst[hit.num].gdRefY!=undefined && geometry.gdLst[geometry.ahXYLst[hit.num].gdRefY]!= undefined)
{
tmpHistory.old_gdValue2 = geometry.gdLst[geometry.ahXYLst[hit.num].gdRefY];
}
}
else
{
trackShape.CalculateAdjPolarRangeR(hit.num);
if(geometry.ahPolarLst[hit.num].gdRefR!=undefined && geometry.gdLst[geometry.ahPolarLst[hit.num].gdRefR])
{
tmpHistory.old_gdValue1 = geometry.gdLst[geometry.ahPolarLst[hit.num].gdRefR];
}
if(geometry.ahPolarLst[hit.num].gdRefAng!=undefined && geometry.gdLst[geometry.ahPolarLst[hit.num].gdRefAng] != undefined)
{
tmpHistory.old_gdValue2 = geometry.gdLst[geometry.ahPolarLst[hit.num].gdRefAng];
}
}
AutoShapes.tmpHistoryData = tmpHistory;
AutoShapes.DrawingDocument.StartTrackAutoshape();
AutoShapes.ChangeState(new ChangeAdjState());
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
AutoShapes.ArrTrackObj = [];
AutoShapes.preTrackArr = [];
AutoShapes.ChangeState(new NullShapeState());
};
}
function ChangeAdjState()
{
this.id=4;
this.OnMouseDown = function(AutoShapes, e, X, Y)
{
AutoShapes.stX=X;
AutoShapes.stY=Y;
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
var trackObject = AutoShapes.ArrTrackObj[0];
if(trackObject.hit.type == xy)
{
trackObject.obj.ChangeAdjXY(trackObject.hit.num, X, Y);
}
else
{
trackObject.obj.ChangeAdjPolar(trackObject.hit.num, X, Y);
}
AutoShapes.Document.DrawingDocument.m_oWordControl.OnUpdateOverlay(false);
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
var shape =AutoShapes.ArrGlyph[AutoShapes.ArrTrackObj[0].num], trackShape = AutoShapes.ArrTrackObj[0].obj,
hit=AutoShapes.ArrTrackObj[0].hit;
var bRecalculateShape = false;//нужно ли пересчитывать фигуру и добавлять изменения в историю
var geometry = trackShape.geometry;
if(hit.type == xy)
{
if(geometry.ahXYLst[hit.num].gdRefX!=undefined)
{
bRecalculateShape = geometry.gdLst[geometry.ahXYLst[hit.num].gdRefX] != AutoShapes.tmpHistoryData.old_gdValue1;
}
if(!bRecalculateShape && geometry.ahXYLst[hit.num].gdRefY!=undefined)
{
bRecalculateShape = geometry.gdLst[geometry.ahXYLst[hit.num].gdRefY] != AutoShapes.tmpHistoryData.old_gdValue2;
}
}
else
{
if(geometry.ahPolarLst[hit.num].gdRefR!=undefined)
{
bRecalculateShape = geometry.gdLst[geometry.ahPolarLst[hit.num].gdRefR] != AutoShapes.tmpHistoryData.old_gdValue1;
}
if(!bRecalculateShape && geometry.ahPolarLst[hit.num].gdRefAng!=undefined)
{
bRecalculateShape = geometry.gdLst[geometry.ahPolarLst[hit.num].gdRefAng] != AutoShapes.tmpHistoryData.old_gdValue2;
}
}
if(bRecalculateShape)
{
History.Create_NewPoint();
AutoShapes.addHistorySelectedState();
var historyData = {};
if(hit.type==xy)
{
if(geometry.ahXYLst[hit.num].gdRefX!=undefined)
{
historyData.old_gdValue1 = AutoShapes.tmpHistoryData.old_gdValue1;
historyData.nameGuide1 = geometry.ahXYLst[hit.num].gdRefX;
}
if(geometry.ahXYLst[hit.num].gdRefY!=undefined)
{
historyData.old_gdValue2 = AutoShapes.tmpHistoryData.old_gdValue2;
historyData.nameGuide2 = geometry.ahXYLst[hit.num].gdRefY;
}
if(geometry.ahXYLst[hit.num].gdRefX!=undefined)
{
historyData.new_gdValue1 = geometry.gdLst[geometry.ahXYLst[hit.num].gdRefX];
shape.geometry.gdLst[geometry.ahXYLst[hit.num].gdRefX] = geometry.gdLst[geometry.ahXYLst[hit.num].gdRefX];
}
if(geometry.ahXYLst[hit.num].gdRefY!=undefined)
{
historyData.new_gdValue2 = geometry.gdLst[geometry.ahXYLst[hit.num].gdRefY];
shape.geometry.gdLst[geometry.ahXYLst[hit.num].gdRefY] = geometry.gdLst[geometry.ahXYLst[hit.num].gdRefY];
}
}
else
{
if(geometry.ahPolarLst[hit.num].gdRefR!=undefined)
{
historyData.old_gdValue1 = AutoShapes.tmpHistoryData.old_gdValue1;
historyData.nameGuide1 = geometry.ahPolarLst[hit.num].gdRefR;
}
if(geometry.ahPolarLst[hit.num].gdRefAng!=undefined)
{
historyData.old_gdValue2 = AutoShapes.tmpHistoryData.old_gdValue2;
historyData.nameGuide2 = geometry.ahPolarLst[hit.num].gdRefAng;
}
if(geometry.ahPolarLst[hit.num].gdRefR!=undefined)
{
historyData.new_gdValue1 = geometry.gdLst[geometry.ahPolarLst[hit.num].gdRefR];
shape.geometry.gdLst[geometry.ahPolarLst[hit.num].gdRefR] = geometry.gdLst[geometry.ahPolarLst[hit.num].gdRefR];
}
if(geometry.ahPolarLst[hit.num].gdRefAng!=undefined)
{
historyData.new_gdValue2 = geometry.gdLst[geometry.ahPolarLst[hit.num].gdRefAng];
shape.geometry.gdLst[geometry.ahPolarLst[hit.num].gdRefAng] = geometry.gdLst[geometry.ahPolarLst[hit.num].gdRefAng];
}
}
historyData.undo_function = function(data)
{
if(historyData.old_gdValue1 != undefined)
{
this.geometry.gdLst[historyData.nameGuide1] = historyData.old_gdValue1;
}
if(historyData.old_gdValue2 != undefined)
{
this.geometry.gdLst[historyData.nameGuide2] = historyData.old_gdValue2;
}
this.Recalculate();
};
historyData.redo_function = function(data)
{
if(historyData.old_gdValue1 != undefined)
{
this.geometry.gdLst[historyData.nameGuide1] = historyData.new_gdValue1;
}
if(historyData.old_gdValue2 != undefined)
{
this.geometry.gdLst[historyData.nameGuide2] = historyData.new_gdValue2;
}
this.Recalculate();
};
History.Add(shape, historyData);
AutoShapes.Document.Document_UpdateUndoRedoState();
shape.Recalculate();
}
AutoShapes.ArrTrackObj.length=0;
AutoShapes.tmpHistoryData = {};
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.Document.DrawingDocument.EndTrackAutoShape();
AutoShapes.Document.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum,AutoShapes.Document.Slides[AutoShapes.SlideNum]);
}
}
function PreMoveState(preMoveObj)
{
this.preMoveObj = preMoveObj;
this.OnMouseDown = function(AutoShapes, e, X, Y)
{};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
if(AutoShapes.Document.viewMode === true)
{
AutoShapes.ArrTrackObj = [];
AutoShapes.preTrackArr = [];
AutoShapes.ChangeState(new NullShapeState());
return;
}
if(AutoShapes.stX == X && AutoShapes.stY == Y)
{
return;
}
AutoShapes.ArrTrackObj = AutoShapes.preTrackArr;
AutoShapes.preTrackArr = [];
AutoShapes.DrawingDocument.StartTrackAutoshape();
AutoShapes.ChangeState(new MoveState());
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
if( AutoShapes.obj.IsGroup()
&& AutoShapes.NumSelected == 1
&& AutoShapes.SelectGroup ) {
AutoShapes.group=AutoShapes.obj;
AutoShapes.ArrTrackObj.length=0;
AutoShapes.ChangeState(new GroupState());
AutoShapes.group.OnMouseDown(e, X, Y);
AutoShapes.group.OnMouseUp(e, X, Y);
AutoShapes.obj=AutoShapes.group.obj;
return;
}
AutoShapes.ArrTrackObj = [];
AutoShapes.preTrackArr = [];
AutoShapes.ChangeState(new NullShapeState());
if(this.preMoveObj != null)
{
var _shapes = AutoShapes.ArrGlyph;
var _shape_index;
for(_shape_index = _shapes.length-1; _shape_index > -1; --_shape_index)
{
var glyph = _shapes[_shape_index];
if(glyph.Hit(X, Y)
||(/*glyph.text_flag&& TODO:*/ glyph.InTextRect(X, Y))
||(glyph.selected && glyph.HitInBox(X, Y)))
{
glyph.selected = false;
AutoShapes.selectedCount();
AutoShapes.Document.DrawingDocument.m_oWordControl.OnUpdateOverlay(true);
break;
}
}
}
};
}
function MoveState()
{
this.OnMouseDown = function(AutoShapes, e, X, Y)
{
AutoShapes.stX=X;
AutoShapes.stY=Y;
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
if(e.IsLocked)
{
if(!e.ShiftKey)
{
var DX, DY;
var dx=0, dy=0, i, j;
DX=X-AutoShapes.stX;
DY=Y-AutoShapes.stY;
for( i=0; i<AutoShapes.ArrTrackObj.length; i++)
AutoShapes.ArrTrackObj[i].obj.Move(AutoShapes.ArrTrackObj[i].stX+DX, AutoShapes.ArrTrackObj[i].stY+DY);
if(AutoShapes.ArrTrackObj[0]!=undefined)
{
for(i=0; i<AutoShapes.ArrGlyph.length; i++)
{
dx=JoinedH(AutoShapes.ArrTrackObj[0].obj, AutoShapes.ArrGlyph[i]);
if(dx>0)
break;
if(AutoShapes.ArrGlyph[i].IsGroup())
{
for(j=0; j<AutoShapes.ArrGlyph[i].ArrGlyph.length; ++j)
{
dx=JoinedH(AutoShapes.ArrTrackObj[0].obj, AutoShapes.ArrGlyph[i].ArrGlyph[j]);
if(dx>0)
break;
}
}
if(dx>0)
break;
}
for(i=0; i<AutoShapes.ArrGlyph.length; i++)
{
dy=JoinedV(AutoShapes.ArrTrackObj[0].obj, AutoShapes.ArrGlyph[i]);
if(dy>0)
break;
if(AutoShapes.ArrGlyph[i].IsGroup())
{
for(j=0; j<AutoShapes.ArrGlyph[i].ArrGlyph.length; ++j)
{
dy=JoinedV(AutoShapes.ArrTrackObj[0].obj, AutoShapes.ArrGlyph[i].ArrGlyph[j]);
if(dy>0)
break;
}
}
if(dy>0)
break;
}
}
for(i=0; i<AutoShapes.ArrTrackObj.length; i++)
{
AutoShapes.ArrTrackObj[i].obj.Move(AutoShapes.ArrTrackObj[i].stX+DX-dx, AutoShapes.ArrTrackObj[i].stY+DY-dy);
}
}
else
{
var _dx = 0, _dy = 0, t = AutoShapes.DrawingDocument.GetMMPerDot(3);
if(Math.abs(X-AutoShapes.stX) > t || Math.abs(Y-AutoShapes.stY) > t)
{
if(Math.abs(X-AutoShapes.stX) > Math.abs(Y-AutoShapes.stY))
{
_dx = X-AutoShapes.stX;
_dy = 0;
}
else
{
_dx = 0;
_dy = Y-AutoShapes.stY;
}
}
for(i=0; i<AutoShapes.ArrTrackObj.length; i++)
{
AutoShapes.ArrTrackObj[i].obj.Move(AutoShapes.ArrTrackObj[i].stX + _dx, AutoShapes.ArrTrackObj[i].stY + _dy);
}
}
AutoShapes.Document.DrawingDocument.m_oWordControl.OnUpdateOverlay(false);
}
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
var trackObjects = AutoShapes.ArrTrackObj;
if(trackObjects.length == 0)
{
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.Document.DrawingDocument.EndTrackAutoShape();
AutoShapes.Document.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum,AutoShapes.Document.Slides[AutoShapes.SlideNum]);
return;
}
var glyphs = AutoShapes.ArrGlyph;
if(e.CtrlKey)
{
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.Document.glyphsBuffer = AutoShapes.glyphsCopy();
AutoShapes.glyphsPaste(true);
AutoShapes.Document.glyphsBuffer.length = 0;
var _start_pos = AutoShapes.ArrGlyph.length - trackObjects.length;
for(var i=0, n = trackObjects.length; i < n ; ++i )
{
var trackObj = trackObjects[i];
AutoShapes.ArrGlyph[_start_pos + i].pH = trackObj.obj.pH;
AutoShapes.ArrGlyph[_start_pos + i].pV = trackObj.obj.pV;
AutoShapes.ArrGlyph[_start_pos + i].Recalculate();
AutoShapes.ArrGlyph[_start_pos + i].calculateXfrm();
}
}
else
{
if(AutoShapes.obj.pH != trackObjects[AutoShapes.NumEditShape].obj.pH
|| AutoShapes.obj.pV != trackObjects[AutoShapes.NumEditShape].obj.pV)
{
History.Create_NewPoint();
AutoShapes.addHistorySelectedState();
for(var i=0, n = trackObjects.length; i < n ; ++i )
{
var trackObj = trackObjects[i];
var glyph = glyphs[trackObj.num];
var historyData = {};
historyData.old_pH = glyph.pH;
historyData.old_pV = glyph.pV;
historyData.new_pH = trackObj.obj.pH;
historyData.new_pV = trackObj.obj.pV;
historyData.undo_function = function(data)
{
this.pH = data.old_pH;
this.pV = data.old_pV;
this.Recalculate();
};
historyData.redo_function = function(data)
{
this.pH = data.new_pH;
this.pV = data.new_pV;
this.Recalculate();
};
History.Add(glyph, historyData);
glyph.pH = trackObj.obj.pH;
glyph.pV = trackObj.obj.pV;
glyph.Recalculate();
glyph.calculateXfrm();
}
AutoShapes.Document.Document_UpdateUndoRedoState();
}
}
AutoShapes.ArrTrackObj.length=0;
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.Document.DrawingDocument.EndTrackAutoShape();
AutoShapes.Document.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum,AutoShapes.Document.Slides[AutoShapes.SlideNum]);
};
this.id=5;
}
function PreRotateState()
{
this.OnMouseDown = function(AutoShapes, e, X, Y)
{};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
if(AutoShapes.Document.viewMode === true)
{
AutoShapes.ArrTrackObj = [];
AutoShapes.preTrackArr = [];
AutoShapes.ChangeState(new NullShapeState());
return;
}
AutoShapes.ArrTrackObj = AutoShapes.preTrackArr;
AutoShapes.preTrackArr = [];
AutoShapes.DrawingDocument.StartTrackAutoshape();
AutoShapes.ChangeState(new RotateState());
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
AutoShapes.ArrTrackObj = [];
AutoShapes.preTrackArr = [];
AutoShapes.ChangeState(new NullShapeState());
};
}
function RotateState()
{
this.id=6;
this.OnMouseDown = function(AutoShapes, e, X, Y)
{
AutoShapes.stX=X;
AutoShapes.stY=Y;
};
this.OnMouseMove = function(AutoShapes, e, X, Y) {
if(e.IsLocked)
{
var ang=AutoShapes.obj.GetAngle(X, Y);
for(var i= 0, n = AutoShapes.ArrTrackObj.length; i < n; ++i) {
var trackObject = AutoShapes.ArrTrackObj[i];
trackObject.obj.rot = AutoShapes.ArrGlyph[trackObject.num].rot;
trackObject.obj.Rotate(ang, e.ShiftKey);
}
AutoShapes.Document.DrawingDocument.m_oWordControl.OnUpdateOverlay(false);
}
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
var numRotateShapeInTrackArray = 0, trackObjects = AutoShapes.ArrTrackObj;
for(var i = 0; i < trackObjects.length; ++i)
{
if(trackObjects[i].num == AutoShapes.NumEditShape)
{
numRotateShapeInTrackArray = i;
break;
}
}
if(trackObjects[numRotateShapeInTrackArray].obj.rot!=AutoShapes.ArrGlyph[AutoShapes.NumEditShape].rot)
{
History.Create_NewPoint();
var glyphs = AutoShapes.ArrGlyph;
AutoShapes.addHistorySelectedState();
for(i=0; i<trackObjects.length; ++i)
{
var shape = glyphs[trackObjects[i].num];
var historyData = {};
historyData.old_rot = shape.rot;
historyData.new_rot = trackObjects[i].obj.rot;
historyData.undo_function = function(data)
{
this.rot = data.old_rot;
this.Recalculate();
this.updateCursorTypes();
};
historyData.redo_function = function(data)
{
this.rot = data.new_rot;
this.Recalculate();
this.updateCursorTypes();
};
History.Add(shape, historyData);
shape.rot=trackObjects[i].obj.rot;
shape.Recalculate();
shape.updateCursorTypes();
shape.calculateXfrm();
}
}
AutoShapes.ArrTrackObj.length=0;
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.Document.Document_UpdateUndoRedoState();
AutoShapes.Document.DrawingDocument.EndTrackAutoShape();
AutoShapes.Document.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum,AutoShapes.Document.Slides[AutoShapes.SlideNum]);
}
}
function AddTextState()
{
this.id=7;
this.OnMouseDown = function(AutoShapes, e, X, Y) {
AutoShapes.ChangeState(new NullShapeState());
var oldObj = AutoShapes.obj;
AutoShapes.State.OnMouseDown(AutoShapes, e, X, Y);
if(AutoShapes.State.id!=7)
{
AutoShapes.Document.CurPos.Type = docpostype_Content;
AutoShapes.Document.RecalculateCurPos();
AutoShapes.Document.Document_UpdateSelectionState();
if(oldObj && oldObj.graphicObject && typeof oldObj.graphicObject.Selection_Remove === "function")
oldObj.graphicObject.Selection_Remove();
oldObj.addTextFlag = false;
if(oldObj.isEmptyPlaceholder())
{
AutoShapes.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum, AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
}
}
/*else if(e.ClickCount == 2)
{
if( oldObj != AutoShapes.obj)
{
oldObj.addTextFlag = false;
if(oldObj.isEmptyPlaceholder())
{
AutoShapes.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum, AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
}
}
//AutoShapes.obj.Select_All();
var glyph = AutoShapes.obj;
if(glyph.txBody && glyph.txBody.compiledBodyPr && glyph.txBody.compiledBodyPr.anchor)
{
var _vertical_align = glyph.txBody.compiledBodyPr.anchor;
editor.sync_VerticalTextAlign(_vertical_align);
}
} */
else
{
if( oldObj != AutoShapes.obj)
{
if(oldObj && oldObj.graphicObject && typeof oldObj.graphicObject.Selection_Remove === "function")
oldObj.graphicObject.Selection_Remove();
var glyph = AutoShapes.obj;
if(glyph.txBody && glyph.txBody.compiledBodyPr && glyph.txBody.compiledBodyPr.anchor!=undefined)
{
var _vertical_align = glyph.txBody.compiledBodyPr.anchor;
editor.sync_VerticalTextAlign(_vertical_align);
}
oldObj.addTextFlag = false;
if(oldObj.isEmptyPlaceholder())
{
AutoShapes.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum, AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
}
}
//AutoShapes.Document.RecalculateCurPos();
}
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
if(!e.IsLocked)
{
var glyph = AutoShapes.obj;
if( glyph.HitAdj(X, Y).hit )
{
AutoShapes.DrawingDocument.SetCursorType("crosshair");
return;
}
var hit;
hit=glyph.HitHandle(X, Y);
if(hit.hit)
{
if(hit.num != 8)
{
AutoShapes.DrawingDocument.SetCursorType(glyph.cursorTypes[hit.num]);
}
else
{
AutoShapes.DrawingDocument.SetCursorType("crosshair");
}
return;
}
var glyphs = AutoShapes.ArrGlyph;
for(var i = glyphs.length-1; i > -1; --i)
{
glyph = glyphs[i];
var bHit = glyph.Hit(X, Y);
var bInTextRect = glyph.InTextRect(X, Y);
var bInBox = glyph.HitInBox(X, Y);
if(bHit ||(/*glyph.text_flag&& TODO:*/ bInTextRect) ||(glyph.selected && bInBox))
{
break;
}
}
if(i>-1)
{
if( glyph.text_flag && bInTextRect && !glyph.HitInPath(X, Y) && !( glyph.selected && bInBox) )
{
if(glyph instanceof CGraphicFrame && glyph.graphicObject !== null && typeof glyph.graphicObject === "object"
&& typeof glyph.graphicObject.Update_CursorType === "function")
{
glyph.graphicObject.Update_CursorType(X - glyph.pH, Y - glyph.pV, AutoShapes.SlideNum)
}
else
{
if(typeof glyph.Update_CursorType === "function")
glyph.Update_CursorType(X, Y);
}
return;
}
AutoShapes.DrawingDocument.SetCursorType("move");
return;
}
else
{
AutoShapes.DrawingDocument.SetCursorType("default");
return;
}
}
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
AutoShapes.Document.Document_UpdateInterfaceState();
//editor.WordControl.m_oLogicDocument.Document_Format_Paste();
}
}
function SplineBezierState()
{
this.OnMouseDown = function(AutoShapes, e, X, Y)
{
AutoShapes.resetState();
AutoShapes.Document.CurPos.Type = docpostype_Content;
AutoShapes.Document.RecalculateCurPos();
AutoShapes.Document.Document_UpdateSelectionState();
AutoShapes.Spline = new Spline(AutoShapes.Document.Slides[AutoShapes.SlideNum]);
AutoShapes.Spline.path.push(new SplineCommandMoveTo(X, Y));
AutoShapes.ChangeState(new SplineBezierState33(X, Y));
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
AutoShapes.ChangeState(new NullShapeState());
editor.sync_EndAddShape();
};
}
function SplineBezierState33(startX, startY)
{
this.startX = startX;
this.startY = startY;
this.OnMouseDown = function(AutoShapes, e, X, Y)
{
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
if(X == this.startX && Y === this.startY)
{
return;
}
AutoShapes.Spline.path.push(new SplineCommandLineTo(X, Y));
AutoShapes.ChangeState(new SplineBezierState2());
AutoShapes.Document.DrawingDocument.m_oWordControl.OnUpdateOverlay(false);
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
};
}
function SplineBezierState2()
{
this.OnMouseDown = function(AutoShapes, e, X, Y)
{
if(e.ClickCount == 2)
{
History.Create_NewPoint();
var shape = AutoShapes.Spline.createShape(AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
var historyData = {};
historyData.num = AutoShapes.ArrGlyph.length;
historyData.shape = shape;
historyData.undo_function = function(data)
{
this.ArrGlyph.splice(data.num, 1);
};
historyData.redo_function = function(data)
{
this.ArrGlyph.splice(data.num, 0, data.shape);
};
History.Add(AutoShapes, historyData);
AutoShapes.Document.Document_UpdateUndoRedoState();
AutoShapes.Add(shape);
shape.Container = AutoShapes;
AutoShapes.ArrTrackObj.length=0;
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.DrawingDocument.EndTrackAutoShape();
AutoShapes.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum, AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
AutoShapes.obj=shape;
AutoShapes.Spline = new Spline(AutoShapes.Document.Slides[AutoShapes.SlideNum]);
editor.sync_EndAddShape();
}
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
AutoShapes.Spline.path[1].changePoint(X, Y);
AutoShapes.Document.DrawingDocument.m_oWordControl.OnUpdateOverlay(false);
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
if(e.ClickCount == 1 || e.ClickCount == 0)
{
AutoShapes.ChangeState(new SplineBezierState3(X, Y));
}
};
}
function SplineBezierState3(startX, startY)
{
this.startX = startX;
this.startY = startY;
this.OnMouseDown = function(AutoShapes, e, X, Y)
{
if(e.ClickCount == 2)
{
History.Create_NewPoint();
var shape = AutoShapes.Spline.createShape(AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
var historyData = {};
historyData.num = AutoShapes.ArrGlyph.length;
historyData.shape = shape;
historyData.undo_function = function(data)
{
this.ArrGlyph.splice(data.num, 1);
};
historyData.redo_function = function(data)
{
this.ArrGlyph.splice(data.num, 0, data.shape);
};
History.Add(AutoShapes, historyData);
AutoShapes.Add(shape);
shape.Container = AutoShapes;
AutoShapes.ArrTrackObj.length=0;
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.DrawingDocument.EndTrackAutoShape();
AutoShapes.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum, AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
AutoShapes.obj=shape;
AutoShapes.Spline = new Spline(AutoShapes.Document.Slides[AutoShapes.SlideNum]);
AutoShapes.Document.Document_UpdateUndoRedoState();
editor.sync_EndAddShape();
}
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
if(X== this.startX && Y == this.startY)
{
return;
}
var x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
x0 = AutoShapes.Spline.path[0].x;
y0 = AutoShapes.Spline.path[0].y;
x3 = AutoShapes.Spline.path[1].x;
y3 = AutoShapes.Spline.path[1].y;
x6 = X;
y6 = Y;
var vx = (x6 - x0)/6;
var vy = (y6 - y0)/6;
x2 = x3 - vx;
y2 = y3 - vy;
x4 = x3 + vx;
y4 = y3 + vy;
x1 = (x0 + x2)*0.5;
y1 = (y0 + y2)*0.5;
x5 = (x4 + x6)*0.5;
y5 = (y4 + y6)*0.5;
AutoShapes.Spline.path.length = 1;
AutoShapes.Spline.path.push(new SplineCommandBezier(x1, y1, x2, y2, x3, y3));
AutoShapes.Spline.path.push(new SplineCommandBezier(x4, y4, x5, y5, x6, y6));
AutoShapes.Document.DrawingDocument.m_oWordControl.OnUpdateOverlay(false);
AutoShapes.ChangeState(new SplineBezierState4());
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
if(e.ClickCount == 2)
{
History.Create_NewPoint();
var shape = AutoShapes.Spline.createShape(AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
var historyData = {};
historyData.num = AutoShapes.ArrGlyph.length;
historyData.shape = shape;
historyData.undo_function = function(data)
{
this.ArrGlyph.splice(data.num, 1);
};
historyData.redo_function = function(data)
{
this.ArrGlyph.splice(data.num, 0, data.shape);
};
History.Add(AutoShapes, historyData);
AutoShapes.Document.Document_UpdateUndoRedoState();
AutoShapes.Add(shape);
shape.Container = AutoShapes;
AutoShapes.ArrTrackObj.length=0;
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.DrawingDocument.EndTrackAutoShape();
AutoShapes.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum, AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
AutoShapes.obj=shape;
AutoShapes.Spline = new Spline(AutoShapes.Document.Slides[AutoShapes.SlideNum]);
editor.sync_EndAddShape();
}
};
}
function SplineBezierState4()
{
this.OnMouseDown = function(AutoShapes, e, X, Y)
{
if(e.ClickCount == 2)
{
History.Create_NewPoint();
var shape = AutoShapes.Spline.createShape(AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
var historyData = {};
historyData.num = AutoShapes.ArrGlyph.length;
historyData.shape = shape;
historyData.undo_function = function(data)
{
this.ArrGlyph.splice(data.num, 1);
};
historyData.redo_function = function(data)
{
this.ArrGlyph.splice(data.num, 0, data.shape);
};
History.Add(AutoShapes, historyData);
AutoShapes.Document.Document_UpdateUndoRedoState();
AutoShapes.Add(shape);
shape.Container = AutoShapes;
AutoShapes.ArrTrackObj.length=0;
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.DrawingDocument.EndTrackAutoShape();
AutoShapes.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum, AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
AutoShapes.obj=shape;
AutoShapes.Spline = new Spline(AutoShapes.Document.Slides[AutoShapes.SlideNum]);
editor.sync_EndAddShape();
}
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
var lastCommand = AutoShapes.Spline.path[AutoShapes.Spline.path.length-1];
var preLastCommand = AutoShapes.Spline.path[AutoShapes.Spline.path.length-2];
var x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
if(AutoShapes.Spline.path[AutoShapes.Spline.path.length-3].id == 0)
{
x0 = AutoShapes.Spline.path[AutoShapes.Spline.path.length-3].x;
y0 = AutoShapes.Spline.path[AutoShapes.Spline.path.length-3].y;
}
else
{
x0 = AutoShapes.Spline.path[AutoShapes.Spline.path.length-3].x3;
y0 = AutoShapes.Spline.path[AutoShapes.Spline.path.length-3].y3;
}
x3 = preLastCommand.x3;
y3 = preLastCommand.y3;
x6 = X;
y6 = Y;
var vx = (x6 - x0)/6;
var vy = (y6 - y0)/6;
x2 = x3 - vx;
y2 = y3 - vy;
x4 = x3 + vx;
y4 = y3 + vy;
x5 = (x4 + x6)*0.5;
y5 = (y4 + y6)*0.5;
if(AutoShapes.Spline.path[AutoShapes.Spline.path.length-3].id == 0)
{
preLastCommand.x1 = (x0 + x2)*0.5;
preLastCommand.y1 = (y0 + y2)*0.5;
}
preLastCommand.x2 = x2;
preLastCommand.y2 = y2;
preLastCommand.x3 = x3;
preLastCommand.y3 = y3;
lastCommand.x1 = x4;
lastCommand.y1 = y4;
lastCommand.x2 = x5;
lastCommand.y2 = y5;
lastCommand.x3 = x6;
lastCommand.y3 = y6;
AutoShapes.Document.DrawingDocument.m_oWordControl.OnUpdateOverlay(false);
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
if(e.ClickCount == 1 || e.ClickCount == 0)
{
AutoShapes.ChangeState(new SplineBezierState5(X, Y));
}
};
}
function SplineBezierState5(startX, startY)
{
this.startX = startX;
this.startY = startY;
this.moveCount = 0;
this.OnMouseDown = function(AutoShapes, e, X, Y)
{
if(e.ClickCount == 2)
{
History.Create_NewPoint();
var shape = AutoShapes.Spline.createShape(AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
var historyData = {};
historyData.num = AutoShapes.ArrGlyph.length;
historyData.shape = shape;
historyData.undo_function = function(data)
{
this.ArrGlyph.splice(data.num, 1);
};
historyData.redo_function = function(data)
{
this.ArrGlyph.splice(data.num, 0, data.shape);
};
History.Add(AutoShapes, historyData);
AutoShapes.Document.Document_UpdateUndoRedoState();
AutoShapes.Add(shape);
shape.Container = AutoShapes;
AutoShapes.ArrTrackObj.length=0;
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.DrawingDocument.EndTrackAutoShape();
AutoShapes.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum, AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
AutoShapes.obj=shape;
AutoShapes.Spline = new Spline(AutoShapes.Document.Slides[AutoShapes.SlideNum]);
editor.sync_EndAddShape();
}
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
if(X == this.startX && Y == this.startY)
{
return;
}
var lastCommand = AutoShapes.Spline.path[AutoShapes.Spline.path.length-1];
var x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
if(AutoShapes.Spline.path[AutoShapes.Spline.path.length-2].id == 0)
{
x0 = AutoShapes.Spline.path[AutoShapes.Spline.path.length-2].x;
y0 = AutoShapes.Spline.path[AutoShapes.Spline.path.length-2].y;
}
else
{
x0 = AutoShapes.Spline.path[AutoShapes.Spline.path.length-2].x3;
y0 = AutoShapes.Spline.path[AutoShapes.Spline.path.length-2].y3;
}
x3 = lastCommand.x3;
y3 = lastCommand.y3;
x6 = X;
y6 = Y;
var vx = (x6 - x0)/6;
var vy = (y6 - y0)/6;
x2 = x3 - vx;
y2 = y3 - vy;
x1 = (x2+x1)*0.5;
y1 = (y2+y1)*0.5;
x4 = x3 + vx;
y4 = y3 + vy;
x5 = (x4 + x6)*0.5;
y5 = (y4 + y6)*0.5;
if(AutoShapes.Spline.path[AutoShapes.Spline.path.length-2].id == 0)
{
lastCommand.x1 = x1;
lastCommand.y1 = y1;
}
lastCommand.x2 = x2;
lastCommand.y2 = y2;
AutoShapes.Spline.path.push(new SplineCommandBezier(x4, y4, x5, y5, x6, y6));
AutoShapes.Document.DrawingDocument.m_oWordControl.OnUpdateOverlay(false);
AutoShapes.ChangeState(new SplineBezierState4());
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
if(e.ClickCount == 2)
{
History.Create_NewPoint();
var shape = AutoShapes.Spline.createShape(AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
var historyData = {};
historyData.num = AutoShapes.ArrGlyph.length;
historyData.shape = shape;
historyData.undo_function = function(data)
{
this.ArrGlyph.splice(data.num, 1);
};
historyData.redo_function = function(data)
{
this.ArrGlyph.splice(data.num, 0, data.shape);
};
History.Add(AutoShapes, historyData);
AutoShapes.Document.Document_UpdateUndoRedoState();
AutoShapes.Add(shape);
shape.Container = AutoShapes;
AutoShapes.ArrTrackObj.length=0;
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.DrawingDocument.EndTrackAutoShape();
AutoShapes.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum, AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
AutoShapes.obj=shape;
AutoShapes.Spline = new Spline(AutoShapes.Document.Slides[AutoShapes.SlideNum]);
editor.sync_EndAddShape();
}
};
}
//Состояния прия работе с полилиниями
function PolyLineAddState()
{
this.OnMouseDown = function(AutoShapes, e, X, Y)
{
AutoShapes.PolyLine = new PolyLine(AutoShapes.Document.Slides[AutoShapes.SlideNum]);
AutoShapes.PolyLine.arrPoint.push({x : X, y: Y});
var _min_distance = AutoShapes.DrawingDocument.GetMMPerDot(1);
AutoShapes.ChangeState(new PolyLineAddState2(_min_distance, X, Y));
AutoShapes.DrawingDocument.StartTrackAutoshape();
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.DrawingDocument.EndTrackAutoShape();
AutoShapes.PolyLine = null;
editor.sync_EndAddShape();
};
}
function PolyLineAddState2(minDistance, X, Y)
{
this.minDistance = minDistance;
this.OnMouseDown = function(AutoShapes, e, X, Y)
{
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
var _last_point = AutoShapes.PolyLine.arrPoint[AutoShapes.PolyLine.arrPoint.length - 1];
var dx = X - _last_point.x;
var dy = Y - _last_point.y;
if(Math.sqrt(dx*dx + dy*dy) >= this.minDistance)
{
AutoShapes.PolyLine.arrPoint.push({x : X, y : Y});
AutoShapes.DrawingDocument.m_oWordControl.OnUpdateOverlay(false);
}
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
if(AutoShapes.PolyLine.arrPoint.length > 1)
{
History.Create_NewPoint();
var shape = AutoShapes.PolyLine.createShape(AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
var historyData = {};
historyData.num = AutoShapes.ArrGlyph.length;
historyData.shape = shape;
historyData.undo_function = function(data)
{
this.ArrGlyph.splice(data.num, 1);
};
historyData.redo_function = function(data)
{
this.ArrGlyph.splice(data.num, 0, data.shape);
};
History.Add(AutoShapes, historyData);
AutoShapes.Document.Document_UpdateUndoRedoState();
AutoShapes.Add(shape);
shape.Container = AutoShapes;
AutoShapes.ArrTrackObj.length=0;
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.DrawingDocument.EndTrackAutoShape();
AutoShapes.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum, AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
AutoShapes.obj=shape;
AutoShapes.PolyLine = null;
editor.sync_EndAddShape();
}
else
{
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.DrawingDocument.EndTrackAutoShape();
AutoShapes.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum, AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
AutoShapes.PolyLine = null;
editor.asc_fireCallback("asc_onEndAddShape");
}
};
}
function AddPolyLine2State()
{
this.OnMouseDown = function(AutoShapes, e, X, Y)
{
AutoShapes.PolyLine = new PolyLine(AutoShapes.Document.Slides[AutoShapes.SlideNum]);
AutoShapes.PolyLine.arrPoint.push({x : X, y: Y});
AutoShapes.DrawingDocument.StartTrackAutoshape();
AutoShapes.ChangeState(new AddPolyLine2State2(X, Y));
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
};
}
function AddPolyLine2State2(X, Y)
{
this.X = X;
this.Y = Y;
this.OnMouseDown = function(AutoShapes, e, X, Y)
{
if(e.ClickCount > 1)
{
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.DrawingDocument.EndTrackAutoShape();
AutoShapes.PolyLine = null;
editor.sync_EndAddShape();
}
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
if(this.X !== X || this.Y !== Y)
{
AutoShapes.PolyLine.arrPoint.push({x : X, y: Y});
AutoShapes.ChangeState(new AddPolyLine2State3(AutoShapes));
}
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
};
}
function AddPolyLine2State3(AutoShapes)
{
this.minSize = AutoShapes.DrawingDocument.GetMMPerDot(1);
this.OnMouseDown = function(AutoShapes, e, X, Y)
{
AutoShapes.PolyLine.arrPoint.push({x: X, y: Y});
if(e.ClickCount > 1)
{
if(AutoShapes.PolyLine.arrPoint.length > 1)
{
History.Create_NewPoint();
var shape = AutoShapes.PolyLine.createShape(AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
var historyData = {};
historyData.num = AutoShapes.ArrGlyph.length;
historyData.shape = shape;
historyData.undo_function = function(data)
{
this.ArrGlyph.splice(data.num, 1);
};
historyData.redo_function = function(data)
{
this.ArrGlyph.splice(data.num, 0, data.shape);
};
History.Add(AutoShapes, historyData);
AutoShapes.Document.Document_UpdateUndoRedoState();
AutoShapes.Add(shape);
shape.Container = AutoShapes;
AutoShapes.ArrTrackObj.length=0;
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.DrawingDocument.EndTrackAutoShape();
AutoShapes.DrawingDocument.OnRecalculatePage(AutoShapes.SlideNum, AutoShapes.Document.Slides[ AutoShapes.SlideNum ]);
AutoShapes.obj=shape;
}
AutoShapes.PolyLine = null;
editor.sync_EndAddShape();
}
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
if(!e.IsLocked)
{
AutoShapes.PolyLine.arrPoint[AutoShapes.PolyLine.arrPoint.length - 1] = {x: X, y: Y};
}
else
{
var _last_point = AutoShapes.PolyLine.arrPoint[AutoShapes.PolyLine.arrPoint.length - 1];
var dx = X - _last_point.x;
var dy = Y - _last_point.y;
if(Math.sqrt(dx*dx + dy*dy) >= this.minSize)
{
AutoShapes.PolyLine.arrPoint.push({x: X, y: Y});
}
}
AutoShapes.Document.DrawingDocument.m_oWordControl.OnUpdateOverlay(false);
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{};
}
function AddPolyLine2State4()
{
this.OnMouseDown = function(AutoShapes, e, X, Y)
{
if(e.ClickCount > 1)
{
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.DrawingDocument.EndTrackAutoShape();
AutoShapes.PolyLine = null;
editor.sync_EndAddShape();
}
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
AutoShapes.PolyLine.arrPoint.push({x : X, y: Y});
AutoShapes.ChangeState(new AddPolyLine2State3());
};
}
//состояния для работы сфигурами внутри групппы----------------------------------------------------------------------------------------------
function GroupState()
{
this.id = 20;
this.OnMouseDown =function(AutoShapes, e, X, Y)
{
AutoShapes.group.OnMouseDown( e, X, Y);
AutoShapes.obj = AutoShapes.group.obj;
if( AutoShapes.group.State.id == 0 )
{
AutoShapes.ChangeState(new NullShapeState());
AutoShapes.State.OnMouseDown(AutoShapes, e, X, Y);
}
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{
if(!e.IsLocked && (e.bStop === undefined || !e.bStop))
{
var glyph = AutoShapes.group;
var hit;
hit=glyph.HitHandle(X, Y);
var bStop = false;
if(hit.hit)
{
if(hit.num != 8)
{
AutoShapes.DrawingDocument.SetCursorType(glyph.cursorTypes[hit.num]);
}
else
{
AutoShapes.DrawingDocument.SetCursorType("crosshair");
}
bStop = true;
}
var glyphs = AutoShapes.ArrGlyph;
for(var i = glyphs.length-1; i > -1; --i)
{
glyph = glyphs[i];
var bHit = glyph.Hit(X, Y);
var bInTextRect = glyph.InTextRect(X, Y);
var bInBox = glyph.HitInBox(X, Y);
if(bHit ||(/*glyph.text_flag&& TODO:*/ bInTextRect) ||(glyph.selected && bInBox))
{
break;
}
}
if(i>-1)
{
if( glyph.text_flag && bInTextRect && !glyph.HitInPath(X, Y) && !( glyph.selected && bInBox) )
{
if(glyph instanceof CGraphicFrame && glyph.graphicObject !== null && typeof glyph.graphicObject === "object"
&& typeof glyph.graphicObject.Update_CursorType === "function")
{
glyph.graphicObject.Update_CursorType(X - glyph.pH, Y - glyph.pV, AutoShapes.SlideNum)
}
else
{
AutoShapes.DrawingDocument.SetCursorType("text");
}
}
AutoShapes.DrawingDocument.SetCursorType("move");
bStop = true;
}
if(!bStop)
{
if( glyph.HitInBox(X, Y))
{
AutoShapes.DrawingDocument.SetCursorType("move");
}
else
{
AutoShapes.DrawingDocument.SetCursorType("default");
}
}
e.bStop = bStop;
}
AutoShapes.group.OnMouseMove( e, X, Y);
};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
AutoShapes.group.OnMouseUp(e, X, Y);
var historyData = {};
historyData.old_pH = AutoShapes.group.pH;
historyData.old_pV = AutoShapes.group.pV;
historyData.old_ext = clonePrototype(AutoShapes.group.ext);
historyData.old_off = clonePrototype(AutoShapes.group.off);
AutoShapes.group.RecalculateAfterResize();
historyData.new_pH = AutoShapes.group.pH;
historyData.new_pV = AutoShapes.group.pV;
historyData.new_ext = clonePrototype(AutoShapes.group.ext);
historyData.new_off = clonePrototype(AutoShapes.group.off);
historyData.undo_function = function(data)
{
this.pH = data.old_pH;
this.pV = data.old_pV;
this.ext = clonePrototype(data.old_ext);
this.off = clonePrototype(data.old_off);
this.RecalculateTransformMatrix();
};
historyData.redo_function = function(data)
{
this.pH = data.new_pH;
this.pV = data.new_pV;
this.ext = clonePrototype(data.new_ext);
this.off = clonePrototype(data.new_off);
this.RecalculateTransformMatrix();
};
History.Add(AutoShapes.group, historyData);
AutoShapes.obj = AutoShapes.group.obj;
if(AutoShapes.group.NumSelected==0)
{
AutoShapes.ChangeState(new NullShapeState());
}
};
}
function NullStateGroup()
{
this.OnMouseDown = function(AutoShapes, e, X, Y)
{};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{};
this.OnMouseUp = function(AutoShapes, e, X, Y)
{};
}
\ No newline at end of file
// Содержимое параграфа должно иметь:
//
// 1. Type - тип
// 2. Draw - рисуем на контексте
// 3. Measure - измеряем
// 4. Is_RealContent - является ли данный элемент реальным элементом параграфа
//---- после использования Measure -----
// 1. Width - ширина (для рассчетов)
// 2. Height - высота
// 3. WidthVisible - видимая ширина
var para_Unknown = -1; //
var para_Empty = 0x0000; // Пустой элемент (таким элементом должен заканчиваться каждый параграф)
var para_Text = 0x0001; // Текст
var para_Space = 0x0002; // Пробелы
var para_TextPr = 0x0003; // Свойства текста
var para_End = 0x0004; // Конец параграфа
var para_NewLine = 0x0010; // Новая строка
var para_NewLineRendered = 0x0011; // Рассчитанный перенос строки
var para_InlineBreak = 0x0012; // Перенос внутри строки (для обтекания)
var para_PageBreakRendered = 0x0013; // Рассчитанный перенос страницы
var para_Numbering = 0x0014; // Элемент, обозначающий нумерацию для списков
var para_Tab = 0x0015; // Табуляция
var para_Drawing = 0x0016; // Графика (картинки, автофигуры, диаграммы, графики)
var para_PageNum = 0x0017; // Нумерация страницы
var para_FlowObjectAnchor = 0x0018; // Привязка для "плавающих" объектов
var para_HyperlinkStart = 0x0019; // Начало гиперссылки
var para_HyperlinkEnd = 0x0020; // Конец гиперссылки
var para_CollaborativeChangesStart = 0x0021; // Начало изменений другого редактора
var para_CollaborativeChangesEnd = 0x0022; // Конец изменений другого редактора
var para_CommentStart = 0x0023; // Начало комментария
var para_CommentEnd = 0x0024; // Начало комментария
var para_PresentationNumbering = 0x0025;// Элемент, обозначающий нумерацию для списков в презентациях
var break_Line = 0x01;
var break_Page = 0x02;
var nbsp_string = String.fromCharCode( 0x00A0 );
var sp_string = String.fromCharCode( 0x0032 );
var g_aPunctuation =
[
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0
];
// Класс ParaText
function ParaText(value)
{
this.Value = value;
this.Type = para_Text;
this.SpaceAfter = false;
if ( "-" === this.Value )
this.SpaceAfter = true;
this.createDuplicate = function()
{
var d = new ParaText(this.Value);
d.SpaceAfter = this.SpaceAfter;
return d;
}
}
ParaText.prototype =
{
Draw : function(X,Y,Context, Height)
{
try
{
if(Context.IsNoSupportTextDraw !== true)
{
if ( true === this.Is_NBSP() && editor.ShowParaMarks )
Context.FillText( X, Y, String.fromCharCode( 0x00B0 ) );
else
Context.FillText( X, Y, this.Value );
}
else
{
Context.rect(X, Y, this.Width, Height);
}
}
catch(e)
{
}
},
Measure : function(Context)
{
try
{
var Temp = Context.Measure( this.Value );
this.Width = Temp.Width;
this.Height = Temp.Height;
this.WidthVisible = Temp.Width;
}
catch(e)
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
}
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
Is_NBSP : function()
{
return (this.Value === nbsp_string ? true : false);
},
Is_Punctuation : function()
{
var CharCode = this.Value.charCodeAt(0);
if ( 1 === this.Value.length && 1 === g_aPunctuation[this.Value.charCodeAt(0)] )
return true;
return false;
},
Write_ToBinary : function(Writer)
{
// Long : Type
// Long : Value
// Bool : SpaceAfter
Writer.WriteLong( this.Type );
Writer.WriteString2( this.Value );
Writer.WriteBool( this.SpaceAfter );
},
Read_FromBinary : function(Reader)
{
this.Value = Reader.GetString2();
this.SpaceAfter = Reader.GetBool();
}
};
// Класс ParaSpace
function ParaSpace(Count)
{
if ( "number" != typeof(Count) )
this.Value = 1;
else
this.Value = Count;
this.Type = para_Space;
this.createDuplicate = function()
{
return new ParaSpace(this.Value);
}
}
ParaSpace.prototype =
{
Draw : function(X,Y, Context, Height)
{
var sString = "";
if ( 1 == this.Value )
sString = String.fromCharCode( 0x00B7 );
else
{
for ( var Index = 0; Index < this.Value; Index++ )
{
sString += String.fromCharCode( 0x00B7 );
}
}
if(Context.IsNoSupportTextDraw !== true)
{
try
{
if ( editor.ShowParaMarks )
Context.FillText( X, Y, sString );
}
catch(e)
{
}
}
else
{
Context.rect(X, Y, this.Width, Height);
}
},
Measure : function(Context)
{
var sString = "";
if ( 1 == this.Value )
sString = " ";
else
{
for ( var Index = 0; Index < this.Value; Index++ )
{
sString += " ";
}
}
try
{
var Temp = Context.Measure( sString );
this.Width = Temp.Width;
this.Height = Temp.Height;
this.WidthVisible = Temp.Width;
}
catch(e)
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
}
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
Write_ToBinary : function(Writer)
{
// Long : Type
// Long : Value
Writer.WriteLong( this.Type );
Writer.WriteLong( this.Value );
},
Read_FromBinary : function(Reader)
{
this.Value = Reader.GetLong();
}
};
// Класс ParaTextPr
function ParaTextPr(Props)
{
this.Id = g_oIdCounter.Get_NewId();
this.Type = para_TextPr;
this.Value = new CTextPr();
this.Parent = null;
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id );
if ( Props !== null && "object" === typeof Props )
{
this.Apply_TextPr(Props)
}
this.createDuplicate = function()
{
return new ParaTextPr(this.Value);
}
}
ParaTextPr.prototype =
{
Draw : function()//(X,Y,Context)
{
// Ничего не делаем
},
Measure : function()//(Context)
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
Copy : function()
{
return new ParaTextPr( this.Value );
},
Set_Id : function(newId)
{
g_oTableId.Reset_Id( this, newId, this.Id );
this.Id = newId;
},
Get_Id : function()
{
return this.Id;
},
//-----------------------------------------------------------------------------------
// Функции для изменения свойств
//-----------------------------------------------------------------------------------
Apply_TextPr : function(TextPr)
{
if ( undefined != TextPr.Bold )
this.Set_Bold( TextPr.Bold );
if ( undefined != TextPr.Italic )
this.Set_Italic( TextPr.Italic );
if ( undefined != TextPr.Strikeout )
this.Set_Strikeout( TextPr.Strikeout );
if ( undefined != TextPr.Underline )
this.Set_Underline( TextPr.Underline );
if ( undefined != TextPr.FontFamily )
this.Set_FontFamily( TextPr.FontFamily );
if ( undefined != TextPr.FontSize )
this.Set_FontSize( TextPr.FontSize );
if ( undefined != TextPr.Color )
this.Set_Color( TextPr.Color );
if ( undefined != TextPr.VertAlign )
this.Set_VertAlign( TextPr.VertAlign );
if ( undefined != TextPr.HighLight )
this.Set_HighLight( TextPr.HighLight );
if ( undefined != TextPr.RStyle )
this.Set_RStyle( TextPr.RStyle );
if ( undefined != TextPr.unifill )
this.Set_Unifill( TextPr.unifill );
},
Set_VertAlign : function(Value)
{
var OldValue = ( undefined != this.Value.VertAlign ? this.Value.VertAlign : undefined );
if ( undefined != Value )
this.Value.VertAlign = Value;
else
this.Value.VertAlign = undefined;
History.Add( this, { Type : historyitem_TextPr_VertAlign, New : Value, Old : OldValue } );
},
Set_Prop : function(Prop, Value)
{
var OldValue = ( undefined != this.Value[Prop] ? this.Value[Prop] : undefined );
this.Value[Prop] = Value;
History.Add( this, { Type : historyitem_TextPr_Change, Prop : Prop, New : Value, Old : OldValue } );
},
Set_Unifill : function(unifill)
{
var oldUnifill = this.Value.unifill;
var newUnifill = unifill;
this.Value.unifill = unifill;
History.Add( this, { Type : historyitem_TextPr_Unifill, New : newUnifill, Old : oldUnifill } );
},
Delete_Prop : function(Prop)
{
if ( undefined === this.Value[Prop] )
return;
var OldValue = this.Value[Prop];
this.Value[Prop] = undefined;
History.Add( this, { Type : historyitem_TextPr_Change, Prop : Prop, New : null, Old : OldValue } );
},
Set_Bold : function(Value)
{
var OldValue = ( undefined != this.Value.Bold ? this.Value.Bold : undefined );
if ( undefined != Value )
this.Value.Bold = Value;
else
this.Value.Bold = undefined;
History.Add( this, { Type : historyitem_TextPr_Bold, New : Value, Old : OldValue } );
},
Set_Italic : function(Value)
{
var OldValue = ( undefined != this.Value.Italic ? this.Value.Italic : undefined );
if ( undefined != Value )
this.Value.Italic = Value;
else
this.Value.Italic = undefined;
History.Add( this, { Type : historyitem_TextPr_Italic, New : Value, Old : OldValue } );
},
Set_Strikeout : function(Value)
{
var OldValue = ( undefined != this.Value.Strikeout ? this.Value.Strikeout : undefined );
if ( undefined != Value )
this.Value.Strikeout = Value;
else
this.Value.Strikeout = undefined;
History.Add( this, { Type : historyitem_TextPr_Strikeout, New : Value, Old : OldValue } );
},
Set_Underline : function(Value)
{
var OldValue = ( undefined != this.Value.Underline ? this.Value.Underline : undefined );
if ( undefined != Value )
this.Value.Underline = Value;
else
this.Value.Underline = undefined;
History.Add( this, { Type : historyitem_TextPr_Underline, New : Value, Old : OldValue } );
},
Set_FontFamily : function(Value)
{
var OldValue = ( undefined != this.Value.FontFamily ? this.Value.FontFamily : undefined );
if ( undefined != Value )
this.Value.FontFamily = Value;
else
this.Value.FontFamily = undefined;
History.Add( this, { Type : historyitem_TextPr_FontFamily, New : Value, Old : OldValue } );
},
Set_FontSize : function(Value)
{
var OldValue = ( undefined != this.Value.FontSize ? this.Value.FontSize : undefined );
if ( undefined != Value )
this.Value.FontSize = Value;
else
this.Value.FontSize = undefined;
History.Add( this, { Type : historyitem_TextPr_FontSize, New : Value, Old : OldValue } );
},
Set_Color : function(Value)
{
var OldValue = ( undefined != this.Value.Color ? this.Value.Color : undefined );
if ( undefined != Value )
this.Value.Color = Value;
else
this.Value.Color = undefined;
History.Add( this, { Type : historyitem_TextPr_Color, New : Value, Old : OldValue } );
},
Set_HighLight : function(Value)
{
var OldValue = ( undefined != this.Value.HighLight ? this.Value.HighLight : undefined );
if ( undefined != Value )
this.Value.HighLight = Value;
else
this.Value.HighLight = undefined;
History.Add( this, { Type : historyitem_TextPr_HighLight, New : Value, Old : OldValue } );
},
Set_RStyle : function(Value)
{
var OldValue = ( undefined != this.Value.RStyle ? this.Value.RStyle : undefined );
if ( undefined != Value )
this.Value.RStyle = Value;
else
this.Value.RStyle = undefined;
History.Add( this, { Type : historyitem_TextPr_RStyle, New : Value, Old : OldValue } );
},
//-----------------------------------------------------------------------------------
// Undo/Redo функции
//-----------------------------------------------------------------------------------
Undo : function(Data)
{
var Type = Data.Type;
switch ( Type )
{
case historyitem_TextPr_Unifill:
{
if ( undefined != Data.Old )
this.Value.unifill = Data.Old;
else
this.Value.unifill = undefined;
break;
}
case historyitem_TextPr_Change:
{
if ( undefined != Data.Old )
this.Value[Data.Prop] = Data.Old;
else
this.Value[Data.Prop] = undefined;
break;
}
case historyitem_TextPr_Bold:
{
if ( undefined != Data.Old )
this.Value.Bold = Data.Old;
else
this.Value.Bold = undefined;
break;
}
case historyitem_TextPr_Italic:
{
if ( undefined != Data.Old )
this.Value.Italic = Data.Old;
else
this.Value.Italic = undefined;
break;
}
case historyitem_TextPr_Strikeout:
{
if ( undefined != Data.Old )
this.Value.Strikeout = Data.Old;
else
this.Value.Strikeout = undefined;
break;
}
case historyitem_TextPr_Underline:
{
if ( undefined != Data.Old )
this.Value.Underline = Data.Old;
else
this.Value.Underline = undefined;
break;
}
case historyitem_TextPr_FontFamily:
{
if ( undefined != Data.Old )
this.Value.FontFamily = Data.Old;
else
this.Value.FontFamily = undefined;
break;
}
case historyitem_TextPr_FontSize:
{
if ( undefined != Data.Old )
this.Value.FontSize = Data.Old;
else
this.Value.FontSize = undefined;
break;
}
case historyitem_TextPr_Color:
{
if ( undefined != Data.Old )
this.Value.Color = Data.Old;
else
this.Value.Color = undefined;
break;
}
case historyitem_TextPr_VertAlign:
{
if ( undefined != Data.Old )
this.Value.VertAlign = Data.Old;
else
this.Value.VertAlign = undefined;
break;
}
case historyitem_TextPr_HighLight:
{
if ( undefined != Data.Old )
this.Value.HighLight = Data.Old;
else
this.Value.HighLight = undefined;
break;
}
case historyitem_TextPr_RStyle:
{
if ( undefined != Data.Old )
this.Value.RStyle = Data.Old;
else
this.Value.RStyle = undefined;
break;
}
}
History.RecalcData_Add( this.Get_ParentObject_or_DocumentPos() );
},
Redo : function(Data)
{
var Type = Data.Type;
switch ( Type )
{
case historyitem_TextPr_Unifill:
{
if ( undefined != Data.New )
this.Value.unifill = Data.New;
else
this.Value.unifill = undefined;
break;
}
case historyitem_TextPr_Change:
{
if ( null != Data.New )
this.Value[Data.Prop] = Data.New;
else
delete this.Value[Data.Prop];
break;
}
case historyitem_TextPr_Bold:
{
if ( undefined != Data.New )
this.Value.Bold = Data.New;
else
this.Value.Bold = undefined;
break;
}
case historyitem_TextPr_Italic:
{
if ( undefined != Data.New )
this.Value.Italic = Data.New;
else
this.Value.Italic = undefined;
break;
}
case historyitem_TextPr_Strikeout:
{
if ( undefined != Data.New )
this.Value.Strikeout = Data.New;
else
this.Value.Strikeout = undefined;
break;
}
case historyitem_TextPr_Underline:
{
if ( undefined != Data.New )
this.Value.Underline = Data.New;
else
this.Value.Underline = undefined;
break;
}
case historyitem_TextPr_FontFamily:
{
if ( undefined != Data.New )
this.Value.FontFamily = Data.New;
else
this.Value.FontFamily = undefined;
break;
}
case historyitem_TextPr_FontSize:
{
if ( undefined != Data.New )
this.Value.FontSize = Data.New;
else
this.Value.FontSize = undefined;
break;
}
case historyitem_TextPr_Color:
{
if ( undefined != Data.New )
this.Value.Color = Data.New;
else
this.Value.Color = undefined;
break;
}
case historyitem_TextPr_VertAlign:
{
if ( undefined != Data.New )
this.Value.VertAlign = Data.New;
else
this.Value.VertAlign = undefined;
break;
}
case historyitem_TextPr_HighLight:
{
if ( undefined != Data.New )
this.Value.HighLight = Data.New;
else
this.Value.HighLight = undefined;
break;
}
case historyitem_TextPr_RStyle:
{
if ( undefined != Data.New )
this.Value.RStyle = Data.New;
else
this.Value.RStyle = undefined;
break;
}
}
History.RecalcData_Add( this.Get_ParentObject_or_DocumentPos() );
},
Get_ParentObject_or_DocumentPos : function()
{
if ( null != this.Parent )
return this.Parent.Get_ParentObject_or_DocumentPos();
},
//-----------------------------------------------------------------------------------
// Функции для работы с совместным редактирования
//-----------------------------------------------------------------------------------
Write_ToBinary : function(Writer)
{
// Long : Type
// String : Id
Writer.WriteLong( this.Type );
Writer.WriteString2( this.Id );
},
Write_ToBinary2 : function(Writer)
{
Writer.WriteLong( historyitem_type_TextPr );
// Long : Type
// String : Id
// Long : Value
Writer.WriteLong( this.Type );
Writer.WriteString2( this.Id );
Styles_Write_TextPr_ToBinary( this.Value, Writer );
},
Read_FromBinary2 : function(Reader)
{
this.Type = Reader.GetLong();
this.Id = Reader.GetString2();
this.Value = new Object();
Styles_Read_TextPr_FromBinary( this.Value, Reader );
},
Save_Changes : function(Data, Writer)
{
// Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл.
// Long : тип класса
// Long : тип изменений
Writer.WriteLong( historyitem_type_TextPr );
var Type = Data.Type;
// Пишем тип
Writer.WriteLong( Type );
switch ( Type )
{
case historyitem_TextPr_Unifill:
{
if ( undefined != Data.New )
{
Writer.WriteBool( false );
Data.New.Write_ToBinary2(Writer);
}
else
Writer.WriteBool( true );
break;
}
case historyitem_TextPr_Change:
{
// Variable : TextPr
var TextPr = new CTextPr();
TextPr[Data.Prop] = Data.New;
TextPr.Write_ToBinary( Writer );
break;
}
case historyitem_TextPr_Bold:
case historyitem_TextPr_Italic:
case historyitem_TextPr_Strikeout:
case historyitem_TextPr_Underline:
{
// Bool : IsUndefined
// Bool : Value
if ( undefined != Data.New )
{
Writer.WriteBool( false );
Writer.WriteBool( Data.New );
}
else
Writer.WriteBool( true );
break;
}
case historyitem_TextPr_FontFamily:
{
// Bool : IsUndefined
// String : FontName
if ( undefined != Data.New )
{
Writer.WriteBool(false);
Writer.WriteString2( Data.New.Name );
}
else
Writer.WriteBool(true);
break;
}
case historyitem_TextPr_FontSize:
{
// Bool : IsUndefined
// Double : FontSize
if ( undefined != Data.New )
{
Writer.WriteBool(false);
Writer.WriteDouble( Data.New );
}
else
Writer.WriteBool(true);
break;
}
case historyitem_TextPr_Color:
{
// Bool : IsUndefined
// Variable : Color (CDocumentColor)
if ( undefined != Data.New )
{
Writer.WriteBool(false);
Data.New.Write_ToBinary( Writer );
}
else
Writer.WriteBool(true);
break;
}
case historyitem_TextPr_VertAlign:
{
// Bool : IsUndefined
// Long : VertAlign
if ( undefined != Data.New )
{
Writer.WriteBool(false);
Writer.WriteLong(Data.New);
}
else
Writer.WriteBool(true);
break;
}
case historyitem_TextPr_HighLight:
{
// Bool : IsUndefined
// Если false
// Bool : IsNone
// Если false
// Variable : Color (CDocumentColor)
if ( undefined != Data.New )
{
Writer.WriteBool(false);
if ( highlight_None != Data.New )
{
Writer.WriteBool( false );
Data.New.Write_ToBinary( Writer );
}
else
Writer.WriteBool( true );
}
else
Writer.WriteBool(true);
break;
}
case historyitem_TextPr_RStyle:
{
// Bool : IsUndefined
// Если false
// String : RStyle
if ( undefined != Data.New )
{
Writer.WriteBool( false );
Writer.WriteString2( Data.New );
}
else
Writer.WriteBool( true );
break;
}
case historyitem_TextPr_Spacing:
case historyitem_TextPr_Position:
{
// Bool : IsUndefined
// Если false
// Double : Spacing
if ( undefined != Data.New )
{
Writer.WriteBool( false );
Writer.WriteDouble( Data.New );
}
else
Writer.WriteBool( true );
break;
}
case historyitem_TextPr_DStrikeout:
case historyitem_TextPr_Caps:
case historyitem_TextPr_SmallCaps:
{
// Bool : IsUndefined
// Если false
// Bool : value
if ( undefined != Data.New )
{
Writer.WriteBool( false );
Writer.WriteBool( Data.New );
}
else
Writer.WriteBool( true );
break;
}
case historyitem_TextPr_Value:
{
// CTextPr
Data.New.Write_ToBinary(Writer)
break;
}
case historyitem_TextPr_RFonts:
{
// Bool : undefined ?
// false -> CRFonts
if ( undefined != Data.Old )
{
Writer.WriteBool( false );
Data.New.Write_ToBinary( Writer );
}
else
Writer.WriteBool( true );
break;
}
case historyitem_TextPr_Lang:
{
// Bool : undefined ?
// false -> CLang
if ( undefined != Data.Old )
{
Writer.WriteBool( false );
Data.New.Write_ToBinary( Writer );
}
else
Writer.WriteBool( true );
break;
}
case historyitem_TextPr_RFonts_Ascii:
case historyitem_TextPr_RFonts_HAnsi:
case historyitem_TextPr_RFonts_CS:
case historyitem_TextPr_RFonts_EastAsia:
{
// Bool : undefined?
// false -> String
if ( undefined != Data.Old )
{
Writer.WriteBool( false );
Writer.WriteString2( Data.Old.Name );
}
else
Writer.WriteBool( true );
break;
}
case historyitem_TextPr_RFonts_Hint:
{
// Bool : undefined?
// false -> Long
if ( undefined != Data.Old )
{
Writer.WriteBool( false );
Writer.WriteLong( Data.Old );
}
else
Writer.WriteBool( true );
break;
}
case historyitem_TextPr_Lang_Bidi:
case historyitem_TextPr_Lang_EastAsia:
case historyitem_TextPr_Lang_Val:
{
// Bool : undefined ?
// false -> Long
if ( undefined != Data.Old )
{
Writer.WriteBool( false );
Writer.WriteLong( Data.Old );
}
else
Writer.WriteBool( true );
break;
}
}
return Writer;
},
Load_Changes : function(Reader)
{
// Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл.
// Long : тип класса
// Long : тип изменений
var ClassType = Reader.GetLong();
if ( historyitem_type_TextPr != ClassType )
return;
var Type = Reader.GetLong();
switch ( Type )
{
case historyitem_TextPr_Unifill:
{
if ( true === Reader.GetBool() )
this.Value.unifill = undefined;
else
{
this.Value.unifill = new CUniFill();
this.Value.unifill.Read_FromBinary2(Reader);
}
break;
}
case historyitem_TextPr_Change:
{
// Variable : TextPr
var TextPr = new CTextPr();
TextPr.Read_FromBinary( Reader );
this.Value.Merge( TextPr );
break;
}
case historyitem_TextPr_Bold:
{
// Bool : IsUndefined
// Bool : Bold
if ( true === Reader.GetBool() )
this.Value.Bold = undefined;
else
this.Value.Bold = Reader.GetBool();
break;
}
case historyitem_TextPr_Italic:
{
// Bool : IsUndefined
// Bool : Italic
if ( true === Reader.GetBool() )
this.Value.Italic = undefined;
else
this.Value.Italic = Reader.GetBool();
break;
}
case historyitem_TextPr_Strikeout:
{
// Bool : IsUndefined
// Bool : Strikeout
if ( true === Reader.GetBool() )
this.Value.Strikeout = undefined;
else
this.Value.Strikeout = Reader.GetBool();
break;
}
case historyitem_TextPr_Underline:
{
// Bool : IsUndefined?
// Bool : Underline
if ( true != Reader.GetBool() )
this.Value.Underline = Reader.GetBool();
else
this.Value.Underline = undefined;
break;
}
case historyitem_TextPr_FontFamily:
{
// Bool : IsUndefined
// String : FontName
if ( true != Reader.GetBool() )
{
this.Value.FontFamily =
{
Name : Reader.GetString2(),
Index : -1
};
}
else
this.Value.FontFamily = undefined;
break;
}
case historyitem_TextPr_FontSize:
{
// Bool : IsUndefined
// Double : FontSize
if ( true != Reader.GetBool() )
this.Value.FontSize = Reader.GetDouble();
else
this.Value.FontSize = undefined;
break;
}
case historyitem_TextPr_Color:
{
// Bool : IsUndefined
// Variable : Color (CDocumentColor)
if ( true != Reader.GetBool() )
{
var r = Reader.GetByte();
var g = Reader.GetByte();
var b = Reader.GetByte();
this.Value.Color = new CDocumentColor( r, g, b );
}
else
this.Value.Color = undefined;
break;
}
case historyitem_TextPr_VertAlign:
{
// Bool : IsUndefined
// Long : VertAlign
if ( true != Reader.GetBool() )
this.Value.VertAlign = Reader.GetLong();
else
this.Value.VertAlign = undefined;
break;
}
case historyitem_TextPr_HighLight:
{
// Bool : IsUndefined
// Если false
// Bool : IsNull
// Если false
// Variable : Color (CDocumentColor)
if ( true != Reader.GetBool() )
{
if ( true != Reader.GetBool() )
{
this.Value.HighLight = new CDocumentColor(0,0,0);
this.Value.HighLight.Read_FromBinary(Reader);
}
else
this.Value.HighLight = highlight_None;
}
else
this.Value.HighLight = undefined;
break;
}
case historyitem_TextPr_RStyle:
{
// Bool : IsUndefined
// Если false
// String : RStyle
if ( true != Reader.GetBool() )
this.Value.RStyle = Reader.GetString2();
else
this.Value.RStyle = undefined;
break;
}
case historyitem_TextPr_Spacing:
{
// Bool : IsUndefined
// Если false
// Double : Spacing
if ( true != Reader.GetBool() )
this.Value.Spacing = Reader.GetDouble();
else
this.Value.Spacing = undefined;
break;
}
case historyitem_TextPr_DStrikeout:
{
// Bool : IsUndefined
// Если false
// Bool : DStrikeout
if ( true != Reader.GetBool() )
this.Value.DStrikeout = Reader.GetBool();
else
this.Value.DStrikeout = undefined;
break;
}
case historyitem_TextPr_Caps:
{
// Bool : IsUndefined
// Если false
// Bool : Caps
if ( true != Reader.GetBool() )
this.Value.Caps = Reader.GetBool();
else
this.Value.Caps = undefined;
break;
}
case historyitem_TextPr_SmallCaps:
{
// Bool : IsUndefined
// Если false
// Bool : SmallCaps
if ( true != Reader.GetBool() )
this.Value.SmallCaps = Reader.GetBool();
else
this.Value.SmallCaps = undefined;
break;
}
case historyitem_TextPr_Position:
{
// Bool : IsUndefined
// Если false
// Double : Position
if ( true != Reader.GetBool() )
this.Value.Position = Reader.GetDouble();
else
this.Value.Position = undefined;
break;
}
case historyitem_TextPr_Value:
{
// CTextPr
this.Value = new CTextPr();
this.Value.Read_FromBinary( Reader );
break;
}
case historyitem_TextPr_RFonts:
{
// Bool : undefined ?
// false -> CRFonts
if ( false === Reader.GetBool() )
{
this.Value.RFonts = new CRFonts();
this.Value.RFonts.Read_FromBinary( Reader );
}
else
this.Value.RFonts = new CRFonts();
break;
}
case historyitem_TextPr_Lang:
{
// Bool : undefined ?
// false -> Lang
if ( false === Reader.GetBool() )
{
this.Value.Lang = new CLang();
this.Value.Lang.Read_FromBinary( Reader );
}
else
this.Value.Lang = new CLang();
break;
}
case historyitem_TextPr_RFonts_Ascii:
{
// Bool : undefined ?
// false -> String
if ( false === Reader.GetBool() )
{
this.Value.RFonts.Ascii =
{
Name : Reader.GetString2(),
Index : -1
};
}
else
this.Value.RFonts.Ascii = undefined;
break;
}
case historyitem_TextPr_RFonts_HAnsi:
{
// Bool : undefined ?
// false -> String
if ( false === Reader.GetBool() )
{
this.Value.RFonts.HAnsi =
{
Name : Reader.GetString2(),
Index : -1
};
}
else
this.Value.RFonts.HAnsi = undefined;
break;
}
case historyitem_TextPr_RFonts_CS:
{
// Bool : undefined ?
// false -> String
if ( false === Reader.GetBool() )
{
this.Value.RFonts.CS =
{
Name : Reader.GetString2(),
Index : -1
};
}
else
this.Value.RFonts.CS = undefined;
break;
}
case historyitem_TextPr_RFonts_EastAsia:
{
// Bool : undefined ?
// false -> String
if ( false === Reader.GetBool() )
{
this.Value.RFonts.EastAsia =
{
Name : Reader.GetString2(),
Index : -1
};
}
else
this.Value.RFonts.Ascii = undefined;
break;
}
case historyitem_TextPr_RFonts_Hint:
{
// Bool : undefined ?
// false -> Long
if ( false === Reader.GetBool() )
this.Value.RFonts.Hint = Reader.GetLong();
else
this.Value.RFonts.Hint = undefined;
break;
}
case historyitem_TextPr_Lang_Bidi:
{
// Bool : undefined ?
// false -> Long
if ( false === Reader.GetBool() )
this.Value.Lang.Bidi = Reader.GetLong();
else
this.Value.Lang.Bidi = undefined;
break;
}
case historyitem_TextPr_Lang_EastAsia:
{
// Bool : undefined ?
// false -> Long
if ( false === Reader.GetBool() )
this.Value.Lang.EastAsia = Reader.GetLong();
else
this.Value.Lang.EastAsia = undefined;
break;
}
case historyitem_TextPr_Lang_Val:
{
// Bool : undefined ?
// false -> Long
if ( false === Reader.GetBool() )
this.Value.Lang.Val = Reader.GetLong();
else
this.Value.Lang.Val = undefined;
break;
}
}
}
};
// Класс окончание параграфа ParaEnd
function ParaEnd()
{
this.Type = para_End;
this.createDuplicate = function()
{
return new ParaEnd();
}
}
ParaEnd.prototype =
{
Draw : function(X,Y,Context, bEndCell, Height)
{
if(Context.IsNoSupportTextDraw !== true)
{
if ( editor.ShowParaMarks )
{
if ( true === bEndCell )
Context.FillText( X, Y, String.fromCharCode( 0x00A4 ) );
else
Context.FillText( X, Y, String.fromCharCode( 0x00B6 ) );
}
}
else
{
Context.rect( X, Y, this.WidthVisible, Height);
}
},
Measure : function(Context, bEndCell)
{
this.Width = 0;
this.Height = 0;
if ( true === bEndCell )
this.WidthVisible = Context.Measure( String.fromCharCode( 0x00A4 ) ).Width;
else
this.WidthVisible = Context.Measure( String.fromCharCode( 0x00B6 ) ).Width;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
}
};
// Класс ParaNewLine
function ParaNewLine(BreakType)
{
this.Type = para_NewLine;
this.BreakType = BreakType;
this.Flags = new Object(); // специальные флаги для разных break
if ( break_Page === this.BreakType )
this.Flags.NewLine = true;
this.createDuplicate = function()
{
var d = new ParaNewLine(this.BreakType);
d.Flags = clone(this.Flags);
return d;
}
}
ParaNewLine.prototype =
{
Draw : function(X,Y,Context, Height)
{
if(Context.IsNoSupportTextDraw !== true)
{
if ( editor.ShowParaMarks )
{
switch( this.BreakType )
{
case break_Line:
{
var oldFont = Context.GetFont();
Context.SetFont( {FontFamily: { Name : "Wingdings 3", Index : -1 }, FontSize: 10, Italic: false, Bold : false} );
Context.FillText( X, Y, String.fromCharCode( 0x0038/*0x21B5*/ ) );
Context.SetFont( oldFont );
break;
}
case break_Page:
{
var PageBreak_String = "";
for ( var Index = 0; Index < 41; Index++ )
{
if ( 20 != Index )
PageBreak_String += String.fromCharCode("0x00B7");
else
PageBreak_String += "PageBreak";
}
var oldFont = Context.GetFont();
var OldColor = Common_CopyObj( Context.m_oBrush.Color1 );
Context.b_color1( 0, 0 , 0, 255);
g_oTextMeasurer.SetFont( {FontFamily: { Name : "Arial", Index : -1 }, FontSize: 10, Italic: false, Bold : false} );
Context.SetFont( {FontFamily: { Name : "Arial", Index : -1 }, FontSize: 10, Italic: false, Bold : false} );
for ( var Index = 0; Index < PageBreak_String.length; Index++ )
{
Context.FillText( X, Y, PageBreak_String[Index] );
X += g_oTextMeasurer.Measure( PageBreak_String[Index] ).Width;
}
Context.SetFont( oldFont );
Context.b_color1( OldColor.R, OldColor.G, OldColor.B, OldColor.A);
g_oTextMeasurer.SetFont( oldFont );
break;
}
}
}
}
else
{
Context.rect(X, Y, this.WidthVisible, Height);
}
},
Measure : function(Context)
{
switch( this.BreakType )
{
case break_Line:
{
this.Width = 0;
this.Height = 0;
var oldFont = Context.GetFont();
Context.SetFont( {FontFamily: { Name : "Wingdings 3", Index : -1 }, FontSize: 10, Italic: false, Bold : false} );
var Temp = Context.Measure( String.fromCharCode( 0x0038 ) );
Context.SetFont( oldFont );
// Почему-то в шрифте Wingding 3 символ 0x0038 имеет неправильную ширину
this.WidthVisible = Temp.Width * 1.7;
break;
}
case break_Page:
{
this.Width = 0;
this.Height = 0;
var PageBreak_String = "";
for ( var Index = 0; Index < 41; Index++ )
{
if ( 20 != Index )
PageBreak_String += String.fromCharCode("0x00B7");
else
PageBreak_String += "PageBreak";
}
var oldFont = g_oTextMeasurer.GetFont();
g_oTextMeasurer.SetFont( {FontFamily: { Name : "Arial", Index : -1 }, FontSize: 10, Italic: false, Bold : false} );
var W = 0;
for ( var Index = 0; Index < PageBreak_String.length; Index++ )
W += g_oTextMeasurer.Measure( PageBreak_String[Index] ).Width;
g_oTextMeasurer.SetFont( oldFont );
this.WidthVisible = W;
break;
}
}
return { Width : this.Width, Height : this.Height , WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
// Функция проверяет особый случай, когда у нас PageBreak, после которого в параграфе ничего не идет
Is_NewLine : function()
{
if ( break_Line === this.BreakType || ( break_Page === this.BreakType && true === this.Flags.NewLine ) )
return true;
return false;
},
Write_ToBinary : function(Writer)
{
// Long : Type
// Long : BreakType
// Optional :
// Long : Flags (breakPage)
Writer.WriteLong( this.Type );
Writer.WriteLong( this.BreakType );
if ( break_Page === this.BreakType )
{
Writer.WriteBool( this.Flags.NewLine );
}
},
Read_FromBinary : function(Reader)
{
this.BreakType = Reader.GetLong();
if ( break_Page === this.BreakType )
this.Flags = { NewLine : Reader.GetBool() };
}
};
// Класс ParaNewLineRendered
function ParaNewLineRendered()
{
this.Type = para_NewLineRendered;
this.createDuplicate = function()
{
return new ParaNewLineRendered();
}
}
ParaNewLineRendered.prototype =
{
Draw : function()//(X,Y,Context)
{
// Ничего не делаем
},
Measure : function()//(Context)
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return false;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
}
};
// Класс ParaInlineBreak
function ParaInlineBreak()
{
this.Type = para_InlineBreak;
this.createDuplicate = function()
{
return new ParaInlineBreak();
}
}
ParaInlineBreak.prototype =
{
Draw : function()
{
// Ничего не делаем
},
Measure : function()
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return false;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
}
};
// Класс ParaPageBreakRenderer
function ParaPageBreakRenderer()
{
this.Type = para_PageBreakRendered;
this.createDuplicate = function()
{
return new ParaPageBreakRenderer();
}
}
ParaPageBreakRenderer.prototype =
{
Draw : function()
{
},
Measure : function()
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return false;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
}
};
// Класс ParaEmpty
function ParaEmpty(bDelete)
{
this.Type = para_Empty;
this.NeedToDelete = false; // Нужно ли удалить данный элемент при пересчете параграфа
if ( "undefined" != typeof(bDelete) && null != bDelete )
this.NeedToDelete = bDelete;
this.createDuplicate = function()
{
return new ParaEmpty(this.NeedToDelete);
}
}
ParaEmpty.prototype =
{
Draw : function()
{
},
Measure : function()
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
Check_Delete : function()
{
return this.NeedToDelete;
},
Write_ToBinary : function(Writer)
{
// Long : Type
// Bool : NeedToDelete
Writer.WriteLong( this.Type );
Writer.WriteBool( this.NeedToDelete );
},
Read_FromBinary : function(Reader)
{
this.NeedToDelete = Reader.GetBool();
}
};
// Класс ParaNumbering
function ParaNumbering(NumPr)
{
this.Type = para_Numbering;
this.NumPr =
{
NumId : 0,
Lvl : 0
};
if ( NumPr && NumPr.NumId )
this.NumPr.NumId = NumPr.NumId;
if ( NumPr && NumPr.Lvl )
this.NumPr.Lvl = NumPr.Lvl;
this.createDuplicate = function()
{
return new ParaNumbering(this.NumPr);
}
}
ParaNumbering.prototype =
{
Draw : function(X,Y,Context, Numbering, NumInfo, TextPr)
{
Numbering.Draw( this.NumPr.NumId, this.NumPr.Lvl, X, Y, Context, NumInfo, TextPr );
},
Measure : function (Context, Numbering, NumInfo, TextPr)
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
this.WidthNum = 0;
this.WidthSuff = 0;
if ( "undefined" === typeof(Numbering) )
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
var Temp = Numbering.Measure( this.NumPr.NumId, this.NumPr.Lvl, Context, NumInfo, TextPr );
this.Width = Temp.Width;
this.WidthVisible = Temp.Width;
this.WidthNum = Temp.Width;
this.WidthSuff = 0;
this.Height = Temp.Ascent; // Это не вся высота, а только высота над BaseLine
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
Write_ToBinary : function(Writer)
{
// Long : Type
// String : NumId
// Long : NumLvl
Writer.WriteLong( this.Type );
Writer.WriteString2( this.NumPr.NumId );
Writer.WriteLong( this.NumPr.Lvl );
},
Read_FromBinary : function(Reader)
{
this.NumPr.NumId = Reader.GetString2();
this.NumPr.Lvl = Reader.GetLong();
}
};
// TODO: Реализовать табы правые, центральные, по точке и с чертой.
var tab_Left = 0x01;
var tab_Right = 0x02;
var tab_Center = 0x03;
var tab_Symbol = 0x0022;//0x2192;
// Класс ParaTab
function ParaTab()
{
this.Type = para_Tab;
this.TabType = tab_Left;
this.createDuplicate = function()
{
var d = new ParaTab();
d.TabType = this.TabType;
return d;
}
}
ParaTab.prototype =
{
Draw : function(X,Y,Context, H)
{
if(Context.IsNoSupportTextDraw !== true)
{
if ( editor.ShowParaMarks )
{
var X0 = this.Width / 2 - this.RealWidth / 2;
var oldFont = Context.GetFont();
Context.SetFont( {FontFamily: { Name : "Wingdings 3", Index : -1 }, FontSize: 10, Italic: false, Bold : false} );
if ( X0 > 0 )
Context.FillText2( X + X0, Y, String.fromCharCode( tab_Symbol ), 0, this.Width );
else
Context.FillText2( X, Y, String.fromCharCode( tab_Symbol ), this.RealWidth - this.Width, this.Width );
Context.SetFont( oldFont );
}
}
else
{
Context.rect(X, Y, this.WidthVisible, H);
}
},
Measure : function (Context)
{
var oldFont = Context.GetFont();
Context.SetFont( {FontFamily: { Name : "Wingdings 3", Index : -1 }, FontSize: 10, Italic: false, Bold : false} );
this.RealWidth = Context.Measure( String.fromCharCode( tab_Symbol ) ).Width;
Context.SetFont( oldFont );
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
Write_ToBinary : function(Writer)
{
// Long : Type
// Long : TabType
Writer.WriteLong( this.Type );
Writer.WriteLong( this.TabType );
},
Read_FromBinary : function(Reader)
{
this.TabType = Reader.GetLong();
}
};
var drawing_Inline = 0x01;
var drawing_Anchor = 0x02;
// Класс ParaDrawing
function ParaDrawing(W, H, GraphicObj, DrawingDocument, DocumentContent, Parent)
{
this.Id = g_oIdCounter.Get_NewId();
this.Type = para_Drawing;
this.Distance =
{
T : 0,
B : 0,
L : 0,
R : 0
};
this.Lock = new CLock();
if ( false === g_oIdCounter.m_bLoad )
{
this.Lock.Set_Type( locktype_Mine, false );
CollaborativeEditing.Add_Unlock2( this );
}
this.DrawingType = drawing_Inline;
this.GraphicObj = GraphicObj;
this.X = 0;
this.Y = 0;
this.W = W;
this.H = H;
this.PageNum = 0;
this.DocumentContent = DocumentContent;
this.DrawingDocument = DrawingDocument;
this.Parent = Parent;
this.Focused = false;
this.ImageTrackType = 1;
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id );
this.createDuplicate = function()
{
return new ParaDrawing(0, 0, this.GraphicObj, this.DrawingDocument, this.DocumentContent, this.Parent);
}
}
ParaDrawing.prototype =
{
Draw : function(X,Y,Context)
{
// координаты графического объекта должны обновляться через функцию
// Update_Position, а приходящие здесь координаты мы не учитываем
this.GraphicObj.Draw( Context, this.X, this.Y, this.W, this.H );
},
Measure : function(Context)
{
this.Width = this.W;
this.Height = this.H;
this.WidthVisible = this.W;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
//--------------------------------------------
Set_Id : function(newId)
{
g_oTableId.Reset_Id( this, newId, this.Id );
this.Id = newId;
},
Get_Id : function()
{
return this.Id;
},
Update_Position : function(X,Y, PageNum)
{
this.X = X;
this.Y = Y;
this.PageNum = PageNum;
if ( true === this.Focused )
this.DrawingDocument.StartTrackImage( this, this.X, this.Y, this.W, this.H, this.ImageTrackType, this.PageNum );
},
Update_Size : function(W,H)
{
History.Add( this, { Type : historyitem_Drawing_Size, New : { W : W, H : H }, Old : { W : this.W, H : this.H } } );
this.W = W;
this.H = H;
},
Set_Url : function(Img)
{
History.Add( this, { Type : historyitem_Drawing_Url, New : Img, Old : this.GraphicObj.Img } );
this.GraphicObj.Img = Img;
},
IsPointIn : function(X, Y, PageIndex)
{
if ( X >= this.X && X <= this.X + this.W && Y >= this.Y && Y <= this.Y + this.H && PageIndex === this.Parent.Get_DrawingObject_Page( this.Id ) )
return true;
return false;
},
Get_DrawingType : function()
{
return this.DrawingType;
},
// Устанавливаем фокус на данном объекте
Focus : function()
{
this.Focused = true;
this.DrawingDocument.StartTrackImage( this, this.X, this.Y, this.W, this.H, this.ImageTrackType );
},
// Убираем фокус с данного объекта
Blur : function()
{
if ( true === this.Focused )
{
this.Focused = false;
this.DrawingDocument.EndTrack();
}
},
// Интерфейс для треков
Track_Draw : function(Left, Top, Right, Bottom)
{
this.DrawingDocument.m_oTrackObject.DrawImageInTrack( this.GraphicObj.Img, Left, Top, Right, Bottom );
},
// Трек закончил работу на странице PageNum, c новыми координатами X, Y, W, H
Track_End : function(PageNum, X, Y, W, H)
{
var LogicDocument = editor.WordControl.m_oLogicDocument;
if ( W < 0 || H < 0 )
{
if ( false === LogicDocument.Document_Is_SelectionLocked(changestype_Image_Properties, { Type : changestype_2_InlineObjectMove, PageNum : PageNum, X : X, Y : Y } ) )
{
LogicDocument.Create_NewHistoryPoint();
this.DocumentContent.InlineObject_Move( this.Id, X, Y, PageNum );
}
else
{
LogicDocument.Document_UpdateSelectionState();
}
}
else
{
// Проверяем, залочено ли данное изображение
if ( false === editor.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(changestype_Image_Properties) )
{
LogicDocument.Create_NewHistoryPoint();
this.DocumentContent.InlineObject_Resize( this.Id, W, H );
}
else
{
LogicDocument.Document_UpdateSelectionState();
}
}
},
Update_CursorType : function(X, Y, PageIndex)
{
this.DrawingDocument.SetCursorType( "move", new CMouseMoveData() );
if ( null != this.Parent )
{
var Lock = this.Parent.Lock;
if ( true === Lock.Is_Locked() )
{
var PNum = Math.max( 0, Math.min( PageIndex - this.Parent.PageNum, this.Parent.Pages.length - 1 ) );
var _X = this.Parent.Pages[PNum].X;
var _Y = this.Parent.Pages[PNum].Y;
var MMData = new CMouseMoveData();
var Coords = this.DrawingDocument.ConvertCoordsToCursorWR( _X, _Y, this.Parent.Get_StartPage_Absolute() + ( PageIndex - this.Parent.PageNum ) );
MMData.X_abs = Coords.X - 5;
MMData.Y_abs = Coords.Y;
MMData.Type = c_oAscMouseMoveDataTypes.LockedObject;
MMData.UserId = Lock.Get_UserId();
MMData.HaveChanges = Lock.Have_Changes();
editor.sync_MouseMoveCallback( MMData );
}
}
},
//-----------------------------------------------------------------------------------
// Undo/Redo функции
//-----------------------------------------------------------------------------------
Undo : function(Data)
{
var Type = Data.Type;
switch ( Type )
{
case historyitem_Drawing_Size:
{
this.W = Data.Old.W;
this.H = Data.Old.H;
break;
}
case historyitem_Drawing_Url:
{
this.GraphicObj.Img = Data.Old;
break;
}
}
History.RecalcData_Add( this.Get_ParentObject_or_DocumentPos() );
},
Redo : function(Data)
{
var Type = Data.Type;
switch ( Type )
{
case historyitem_Drawing_Size:
{
this.W = Data.New.W;
this.H = Data.New.H;
break;
}
case historyitem_Drawing_Url:
{
this.GraphicObj.Img = Data.New;
break;
}
}
History.RecalcData_Add( this.Get_ParentObject_or_DocumentPos() );
},
Get_ParentObject_or_DocumentPos : function()
{
return this.Parent.Get_ParentObject_or_DocumentPos();
},
//-----------------------------------------------------------------------------------
// Функции для совместного редактирования
//-----------------------------------------------------------------------------------
Document_Is_SelectionLocked : function(CheckType)
{
},
Save_Changes : function(Data, Writer)
{
// Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл.
// Long : тип класса
// Long : тип изменений
Writer.WriteLong( historyitem_type_Drawing );
var Type = Data.Type;
// Пишем тип
Writer.WriteLong( Type );
switch ( Type )
{
case historyitem_Drawing_Size:
{
// Double : W
// Double : H
Writer.WriteDouble( Data.New.W );
Writer.WriteDouble( Data.New.H );
break;
}
case historyitem_Drawing_Url:
{
// String : указатель на картинку
Writer.WriteString2( Data.New );
break;
}
}
return Writer;
},
Load_Changes : function(Reader)
{
// Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл.
// Long : тип класса
// Long : тип изменений
var ClassType = Reader.GetLong();
if ( historyitem_type_Drawing != ClassType )
return;
var Type = Reader.GetLong();
switch ( Type )
{
case historyitem_Drawing_Size:
{
// Double : W
// Double : H
this.W = Reader.GetDouble();
this.H = Reader.GetDouble();
break;
}
case historyitem_Drawing_Url:
{
// String : указатель на картинку
this.GraphicObj.Img = Reader.GetString2();
break;
}
}
},
//-----------------------------------------------------------------------------------
// Функции для записи/чтения в поток
//-----------------------------------------------------------------------------------
Write_ToBinary : function(Writer)
{
// Long : Type
// String : Id
Writer.WriteLong( this.Type );
Writer.WriteString2( this.Id );
},
Write_ToBinary2 : function(Writer)
{
Writer.WriteLong( historyitem_type_Drawing );
// Long : Type
// String : Id
// Byte : DrawingType
// Long : W
// Long : H
// Long : Distance.T
// Long : Distance.B
// Long : Distance.L
// Long : Distance.R
// String : Указатель на картинку
Writer.WriteLong( this.Type );
Writer.WriteString2( this.Id );
Writer.WriteByte( this.DrawingType );
Writer.WriteDouble( this.W );
Writer.WriteDouble( this.H );
Writer.WriteDouble( this.Distance.T );
Writer.WriteDouble( this.Distance.B );
Writer.WriteDouble( this.Distance.L );
Writer.WriteDouble( this.Distance.R );
Writer.WriteString2( this.GraphicObj.Img );
},
Read_FromBinary2 : function(Reader)
{
this.DrawingDocument = editor.WordControl.m_oLogicDocument.DrawingDocument;
this.Type = Reader.GetLong();
this.Id = Reader.GetString2();
this.DrawingType = Reader.GetByte();
this.W = Reader.GetDouble();
this.H = Reader.GetDouble();
this.Distance.T = Reader.GetDouble();
this.Distance.B = Reader.GetDouble();
this.Distance.L = Reader.GetDouble();
this.Distance.R = Reader.GetDouble();
this.GraphicObj = new GraphicPicture( Reader.GetString2() );
CollaborativeEditing.Add_NewImage( this.GraphicObj.Img );
},
Load_LinkData : function(LinkData)
{
}
};
// Класс GraphicPicture
function GraphicPicture(Img)
{
this.Img = Img;
this.createDuplicate = function()
{
return new GraphicPicture(this.Img);
}
}
GraphicPicture.prototype =
{
Draw : function(Context, X, Y, W, H)
{
Context.drawImage( this.Img, X, Y, W, H );
}
};
// Класс ParaPageNum
function ParaPageNum()
{
this.Type = para_PageNum;
this.createDuplicate = function()
{
return new ParaPageNum();
}
}
ParaPageNum.prototype =
{
Draw : function(X,Y,Context, Value, Align)
{
// Value - реальное значение, которое должно быть отрисовано.
// Align - прилегание параграфа, в котором лежит данный номер страницы.
var sValue = "" + (Value + 1);
var oldFont = g_oTextMeasurer.GetFont();
g_oTextMeasurer.SetFont( Context.GetFont() );
var RealWidth = 0;
for ( var Index = 0; Index < sValue.length; Index++ )
{
var Char = sValue.charAt(Index);
RealWidth += g_oTextMeasurer.Measure( Char ).Width;
}
var _X = X;
var _Y = Y;
switch(Align)
{
case align_Left:
{
_X = X;
break;
}
case align_Right:
{
_X = X + this.Width - RealWidth;
break;
}
case align_Center:
{
_X = X + (this.Width - RealWidth) / 2;
break;
}
}
for ( var Index = 0; Index < sValue.length; Index++ )
{
var Char = sValue.charAt(Index);
Context.FillText( _X, _Y, Char );
_X += g_oTextMeasurer.Measure( Char ).Width;
}
g_oTextMeasurer.SetFont( oldFont );
},
Measure : function (Context)
{
var Width = 0;
for ( var Index = 0; Index < 10; Index++ )
{
var TempW = Context.Measure( "" + Index ).Width;
if ( Width < TempW )
Width = TempW;
}
// Выделяем место под 4 знака
Width *= 4;
this.Width = Width;
this.Height = 0;
this.WidthVisible = Width;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
}
};
// Класс ParaFlowObjectAnchor
function ParaFlowObjectAnchor(FlowObject)
{
this.Type = para_FlowObjectAnchor;
this.FlowObject = FlowObject;
this.createDuplicate = function()
{
return new ParaFlowObjectAnchor(this.FlowObject);
}
}
ParaFlowObjectAnchor.prototype =
{
Draw : function(X,Y,Context, Value, Align)
{
},
Measure : function (Context)
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : 0, Height : 0, WidthVisible : 0 };
},
Is_RealContent : function()
{
return false;
},
Set_FlowObject : function(Object)
{
this.FlowObject = Object;
},
Get_FlowObject : function()
{
return this.FlowObject;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
}
};
// Класс начало гиперссылки
function ParaHyperlinkStart()
{
this.Type = para_HyperlinkStart;
this.Value = "";
this.Visited = false;
this.ToolTip = null;
this.createDuplicate = function()
{
var d = new ParaHyperlinkStart();
d.Value = this.Value;
d.Visited = this.Visited;
d.ToolTip = this.ToolTip;
return d;
}
}
ParaHyperlinkStart.prototype =
{
Draw : function(X, Y, Context)
{
},
Measure : function(Context)
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : 0, Height : 0, WidthVisible : 0 };
},
Is_RealContent : function()
{
return true;
},
Set_Visited : function(Value)
{
this.Visited = Value;
},
Get_Visited : function()
{
return this.Visited;
},
Set_ToolTip : function(ToolTip)
{
this.ToolTip = ToolTip;
},
Get_ToolTip : function()
{
if ( null === this.ToolTip )
{
if ( "string" === typeof(this.Value) )
return this.Value;
else
return "";
}
else
return this.ToolTip;
},
Get_Value : function()
{
return this.Value;
},
Set_Value : function(Value)
{
this.Value = Value;
},
Copy : function()
{
var Hyperlink_new = new ParaHyperlinkStart();
Hyperlink_new.Value = this.Value;
Hyperlink_new.Visited = this.Visited;
Hyperlink_new.ToolTip = this.ToolTip;
return Hyperlink_new;
},
Write_ToBinary : function(Writer)
{
// Long : Type
// String : Value
// String : ToolTip
Writer.WriteLong( this.Type );
Writer.WriteString2( this.Value );
Writer.WriteString2( this.ToolTip == null ? "" : this.ToolTip );
},
Read_FromBinary : function(Reader)
{
this.Value = Reader.GetString2();
this.ToolTip = Reader.GetString2();
if ( "" == this.ToolTip )
this.ToolTip = null;
}
};
// Класс конец гиперссылки
function ParaHyperlinkEnd()
{
this.Type = para_HyperlinkEnd;
this.createDuplicate = function()
{
return new ParaHyperlinkEnd();
}
}
ParaHyperlinkEnd.prototype =
{
Draw : function(X, Y, Context)
{
},
Measure : function(Context)
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : 0, Height : 0, WidthVisible : 0 };
},
Is_RealContent : function()
{
return true;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
}
};
// Класс ParaCollaborativeChangesStart
function ParaCollaborativeChangesStart()
{
this.Type = para_CollaborativeChangesStart;
this.createDuplicate = function()
{
return new ParaCollaborativeChangesStart();
}
}
ParaCollaborativeChangesStart.prototype =
{
Draw : function()
{
},
Measure : function()
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return false;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
}
};
// Класс ParaCollaborativeChangesEnd
function ParaCollaborativeChangesEnd()
{
this.Type = para_CollaborativeChangesEnd;
this.createDuplicate = function()
{
return new ParaCollaborativeChangesEnd();
}
}
ParaCollaborativeChangesEnd.prototype =
{
Draw : function()
{
},
Measure : function()
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return false;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
}
};
// Класс ParaPresentationNumbering
function ParaPresentationNumbering(Bullet)
{
this.Type = para_PresentationNumbering;
// Эти данные заполняются во время пересчета, перед вызовом Measure
this.Bullet = Bullet == undefined ? null : Bullet;
this.BulletNum = null;
this.createDuplicate = function()
{
var _duplicate = new ParaPresentationNumbering();
if(this.Bullet !== null)
{
_duplicate.Bullet = this.Bullet.Copy();
}
if(this.BulletNum!==null)
{
_duplicate.BulletNum = this.BulletNum;
}
return _duplicate;
};
}
ParaPresentationNumbering.prototype =
{
Draw : function(X, Y, Context, FirstTextPr, Heght)
{
this.Bullet.Draw( X, Y, Context, FirstTextPr, Heght );
},
Measure : function (Context, FirstTextPr)
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
var Temp = this.Bullet.Measure( Context, FirstTextPr, this.BulletNum );
this.Width = Temp.Width;
this.WidthVisible = Temp.Width;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
}
};
function ParagraphContent_Read_FromBinary(Reader)
{
var ElementType = Reader.GetLong();
var Element = null;
switch ( ElementType )
{
case para_TextPr :
case para_Drawing :
{
var ElementId = Reader.GetString2();
Element = g_oTableId.Get_ById( ElementId );
return Element;
}
case para_Text : Element = new ParaText(); break;
case para_Space : Element = new ParaSpace(); break;
case para_End : Element = new ParaEnd(); break;
case para_NewLine : Element = new ParaNewLine(); break;
case para_NewLineRendered : Element = new ParaNewLineRendered(); break;
case para_InlineBreak : Element = new ParaInlineBreak(); break;
case para_PageBreakRendered : Element = new ParaPageBreakRenderer(); break;
case para_Empty : Element = new ParaEmpty(); break;
case para_Numbering : Element = new ParaNumbering(); break;
case para_Tab : Element = new ParaTab(); break;
case para_PageNum : Element = new ParaPageNum(); break;
case para_FlowObjectAnchor : Element = new ParaFlowObjectAnchor(); break;
case para_HyperlinkStart : Element = new ParaHyperlinkStart(); break;
case para_HyperlinkEnd : Element = new ParaHyperlinkEnd(); break;
case para_CommentStart : Element = new ParaCommentStart(); break;
case para_CommentEnd : Element = new ParaCommentEnd(); break;
case para_PresentationNumbering : Element = new ParaPresentationNumbering(); break;
}
if ( null != Element )
Element.Read_FromBinary(Reader);
return Element;
}
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