Commit 49bfcabe authored by Sergey.Luzyanin's avatar Sergey.Luzyanin Committed by Alexander.Trofimov

селект текста в автофигурах

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47824 954022d7-b5bf-4e40-9824-e11837661b57
parent ebd2d1ea
......@@ -1114,15 +1114,6 @@ CDocumentContent.prototype =
Is_TableBorder : function(X,Y, PageNum_Abs)
{
var TempPNum = PageNum_Abs - this.Get_StartPage_Absolute();
if ( TempPNum < 0 || TempPNum >= this.Pages.length )
TempPNum = 0;
var ContentPos = this.Internal_GetContentPosByXY( X, Y, TempPNum );
var Item = this.Content[ContentPos];
if ( type_Table == Item.GetType() )
return Item.Is_TableBorder( X, Y, PageNum_Abs );
return null;
},
......@@ -5828,49 +5819,9 @@ CDocumentContent.prototype =
return;
this.CurPage = PageIndex - this.StartPage;
// Сначала проверим, не попали ли мы в один из "плавающих" объектов
var bInText = (null === this.Is_InText(X, Y, this.CurPage) ? false : true);
var bTableBorder = (null === this.Is_TableBorder(X, Y, this.CurPage) ? false : true);
var nInDrawing = this.LogicDocument.DrawingObjects.isPointInDrawingObjects( X, Y, this.CurPage + this.Get_StartPage_Absolute(), this );
if ( this.Parent instanceof CHeaderFooter && ( nInDrawing === DRAWING_ARRAY_TYPE_BEFORE || nInDrawing === DRAWING_ARRAY_TYPE_INLINE || ( false === bTableBorder && false === bInText && nInDrawing >= 0 ) ) )
{
if ( docpostype_DrawingObjects != this.CurPos.Type )
this.Selection_Remove();
// Прячем курсор
this.DrawingDocument.TargetEnd();
this.DrawingDocument.SetCurrentPage( this.CurPage + this.Get_StartPage_Absolute() );
var HdrFtr = this.Is_HdrFtr( true );
if ( null === HdrFtr )
{
this.LogicDocument.Selection.Use = true;
this.LogicDocument.Selection.Start = true;
this.LogicDocument.Selection.Flag = selectionflag_Common;
this.LogicDocument.CurPos.Type = docpostype_DrawingObjects;
}
else
{
HdrFtr.Content.Selection.Use = true;
HdrFtr.Content.Selection.Start = true;
HdrFtr.Content.Selection.Flag = selectionflag_Common;
HdrFtr.Content.CurPos.Type = docpostype_DrawingObjects;
}
this.LogicDocument.DrawingObjects.OnMouseDown(MouseEvent, X, Y, this.CurPage + this.Get_StartPage_Absolute());
}
else
{
var bOldSelectionIsCommon = true;
if ( docpostype_DrawingObjects === this.CurPos.Type && true != this.Is_InDrawing( X, Y, this.CurPage + this.Get_StartPage_Absolute() ) )
{
this.LogicDocument.DrawingObjects.resetSelection();
bOldSelectionIsCommon = false;
}
var ContentPos = this.Internal_GetContentPosByXY(X,Y);
......@@ -5885,8 +5836,6 @@ CDocumentContent.prototype =
var Item = this.Content[ContentPos];
var bTableBorder = false;
if ( type_Table == Item.GetType() )
bTableBorder = ( null != Item.Is_TableBorder( X, Y, this.CurPage ) ? true : false );
// Убираем селект, кроме случаев либо текущего параграфа, либо при движении границ внутри таблицы
if ( !(true === SelectionUse_old && true === MouseEvent.ShiftKey && true === bOldSelectionIsCommon) )
......@@ -5912,7 +5861,7 @@ CDocumentContent.prototype =
Item.Selection_SetStart( X, Y, this.CurPage, MouseEvent );
Item.Selection_SetEnd( X, Y, this.CurPage, {Type : g_mouse_event_type_move, ClickCount : 1} );
if ( !(type_Table == Item.GetType() && true == bTableBorder) )
{
this.Selection.Use = true;
this.Selection.StartPos = ContentPos;
......@@ -5934,15 +5883,7 @@ CDocumentContent.prototype =
}
}
}
else
{
this.Selection.Data =
{
TableBorder : true,
Pos : ContentPos,
Selection : SelectionUse_old
};
}
}
}
},
......@@ -6642,53 +6583,10 @@ CDocumentContent.prototype =
// TODO: изенить здесь
PageNum = Math.min( PageNum, this.Pages.length - 1 );
// Сначала проверим Flow-таблицы
var FlowTable = this.LogicDocument.DrawingObjects.getTableByXY( X, Y, PageNum + this.Get_StartPage_Absolute(), this );
if ( null != FlowTable )
return FlowTable.Table.Index;
var StartPos = this.Pages[PageNum].Pos;
var EndPos = this.Content.length - 1;
if ( PageNum < this.Pages.length - 1 )
EndPos = Math.min( this.Pages[PageNum + 1].Pos, EndPos );
// Сохраним позиции всех Inline элементов на данной странице
var InlineElements = new Array();
for ( var Index = StartPos; Index <= EndPos; Index++ )
{
var Item = this.Content[Index];
if ( type_Table != Item.GetType() || false != Item.Is_Inline() )
InlineElements.push( Index );
}
var Count = InlineElements.length;
if ( Count <= 0 )
return StartPos;
for ( var Pos = 0; Pos < Count - 1; Pos++ )
{
var Item = this.Content[InlineElements[Pos + 1]];
if ( Y < Item.Pages[0].Bounds.Top )
return InlineElements[Pos];
if ( Item.Pages.length > 1 )
{
if ( ( type_Paragraph === Item.GetType() && Item.Pages[0].FirstLine != Item.Pages[1].FirstLine ) || ( type_Table === Item.GetType() && true === Item.RowsInfo[0].FirstPage ) )
return InlineElements[Pos + 1];
return InlineElements[Pos];
}
if ( Pos === Count - 2 )
{
// Такое возможно, если страница заканчивается Flow-таблицей
return InlineElements[Count - 1];
}
}
return InlineElements[0];
var StartPos = this.Pages[PageNum].Pos;
return StartPos;
},
Internal_Content_Find : function(Id)
......
......@@ -5,6 +5,124 @@
* Time: 6:09 PM
* To change this template use File | Settings | File Templates.
*/
var g_mouse_event_type_down = 0;
var g_mouse_event_type_move = 1;
var g_mouse_event_type_up = 2;
var g_mouse_event_type_wheel = 3;
var g_mouse_button_left = 0;
var g_mouse_button_center = 1;
var g_mouse_button_right = 2;
var g_o_event_map =
{
"mousedown": g_mouse_event_type_down,
"mousemove": g_mouse_event_type_move,
"mouseup": g_mouse_event_type_up
};
function CMouseEventHandler()
{
this.X = 0; // ������� ������� X
this.Y = 0; // ������� ������� Y
this.Button = g_mouse_button_left; // ������ ����
this.Type = g_mouse_event_type_move; // ��� ������
this.AltKey = false; // ������ �� ������ alt
this.CtrlKey = false; // ������ �� ������ ctrl
this.ShiftKey = false; // ������ �� ������ shift
this.Sender = null; // �� ������ html �������� ������ �����
this.LastClickTime = -1; // ����� ���������� mousedown
this.ClickCount = 0; // ���������� ������
this.WheelDelta = 0;
// ���������� ����� ��� ���������� mousedown (��� mousemove)
this.IsPressed = false; // ���� �� ������ ������
this.LastX = 0;
this.LastY = 0;
this.KoefPixToMM = 1;
this.IsLocked = false;
this.IsLockedEvent = false;
this.buttonObject = null;
this.LockMouse = function()
{
if (!this.IsLocked)
{
this.IsLocked = true;
if (window.captureEvents)
window.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP);
/*
var parent = window;
while (true)
{
if (!parent)
break;
if (parent.captureEvents)
parent.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP);
if (parent == parent.parent)
break;
parent = parent.parent;
}
*/
return true;
}
return false;
};
this.UnLockMouse = function()
{
if (this.IsLocked)
{
this.IsLocked = false;
if (window.releaseEvents)
window.releaseEvents(Event.MOUSEMOVE);
/*
var parent = window;
while (true)
{
if (!parent)
break;
if (parent.releaseEvents)
parent.releaseEvents(Event.MOUSEMOVE);
if (parent == parent.parent)
break;
parent = parent.parent;
}
*/
return true;
}
return false;
};
this.fromJQueryEvent = function(e)
{
this.ClickCount = e.ClickCount;
this.Type = g_o_event_map[e.type];
this.ShiftKey = e.shiftKey;
};
}
function CShape(drawingBase, drawingObjects)
{
this.drawingBase = drawingBase;
......@@ -116,6 +234,11 @@ CShape.prototype =
this.drawingBase.setGraphicObjectCoords()
},
updateSelectionState: function(drawingDocument)
{
this.txBody.updateSelectionState(drawingDocument);
},
setExtents: function(extX, extY)
{
var model_id = this.drawingObjects.getWorksheet().model.getId();
......@@ -547,7 +670,7 @@ CShape.prototype =
h: this.contentHeight + (b_ins + t_ins)
};
}
this.invertTextMatrix = global_MatrixTransformer.Invert(this.transformText);
this.invertTransformText = global_MatrixTransformer.Invert(this.transformText);
},
......@@ -591,6 +714,26 @@ CShape.prototype =
}
},
selectionSetStart: function(e, x, y)
{
var t_x, t_y;
t_x = this.invertTransformText.TransformPointX(x, y);
t_y = this.invertTransformText.TransformPointY(x, y);
var event = new CMouseEventHandler();
event.fromJQueryEvent(e);
this.txBody.selectionSetStart(e, t_x, t_y);
},
selectionSetEnd: function(e, x, y)
{
var t_x, t_y;
t_x = this.invertTransformText.TransformPointX(x, y);
t_y = this.invertTransformText.TransformPointY(x, y);
var event = new CMouseEventHandler();
event.fromJQueryEvent(e);
this.txBody.selectionSetEnd(e, t_x, t_y);
},
recalculateTransform: function()
{
var xfrm = this.spPr.xfrm;
......@@ -1127,6 +1270,13 @@ CShape.prototype =
hitInTextRect: function(x, y)
{
if(isRealObject(this.txBody))
{
var t_x, t_y;
t_x = this.invertTransformText.TransformPointX(x, y);
t_y = this.invertTransformText.TransformPointY(x, y);
return t_x > 0 && t_x < this.txBody.contentWidth && t_y > 0 && t_y < this.txBody.contentHeight;
}
return false;
},
......
......@@ -151,5 +151,39 @@ CTxBody.prototype =
Is_Cell: function()
{
return false;
},
Get_StartPage_Absolute: function()
{
return 0;
},
selectionSetStart: function(e, x, y)
{
MouseEvent = new CMouseEventHandler();
this.content.Selection_SetStart(x, y, 0, e);
},
selectionSetEnd: function(e, x, y)
{
this.content.Selection_SetEnd(x, y, 0, e);
},
updateSelectionState: function(drawingDocument)
{
var Doc = this.content;
if ( true === Doc.Is_SelectionUse() && !Doc.Selection_IsEmpty()) {
drawingDocument.UpdateTargetTransform(this.shape.transformText);
drawingDocument.TargetEnd();
drawingDocument.SelectEnabled(true);
drawingDocument.SelectClear();
drawingDocument.SelectShow();
}
else
{
drawingDocument.UpdateTargetTransform(this.shape.transformText);
drawingDocument.TargetShow();
drawingDocument.SelectEnabled(false);
}
}
};
\ No newline at end of file
......@@ -157,7 +157,11 @@ function NullState(drawingObjectsController, drawingObjects)
}
else if(hit_in_text_rect)
{
//TODO
cur_drawing.selectionSetStart(e, x, y);
this.drawingObjectsController.changeCurrentState(new TextAddState(this.drawingObjectsController, this.drawingObjects, cur_drawing));
if(e.ClickCount < 2)
this.drawingObjects.selectGraphicObject();
return;
}
}
else
......@@ -304,7 +308,7 @@ function NullState(drawingObjectsController, drawingObjects)
}
else if(hit_in_text_rect)
{
//TODO
return {objectId: cur_drawing_base.id, cursorType: "move"};
}
}
else
......@@ -339,16 +343,25 @@ function TextAddState(drawingObjectsController, drawingObjects, textObject)
this.drawingObjectsController = drawingObjectsController;
this.drawingObjects = drawingObjects;
this.textObject = textObject;
this.nullState = new NullState(drawingObjectsController, drawingObjects);
this.onMouseDown = function(e, x, y)
{
this.nullState.onMouseDown(e, x, y);
};
this.onMouseMove = function(e, x, y)
{};
{
this.textObject.selectionSetEnd(e, x, y);
this.drawingObjects.selectGraphicObject();
};
this.onMouseUp = function(e, x, y)
{};
{
this.textObject.selectionSetEnd(e, x, y);
this.drawingObjects.selectGraphicObject();
};
this.onKeyDown = function(e)
{
......@@ -367,109 +380,18 @@ function TextAddState(drawingObjectsController, drawingObjects, textObject)
this.onKeyPress = function(e)
{
this.textObject.paragraphAdd(new ParaText(String.fromCharCode(e.charCode)));
//this.drawingObjects.showDrawingObjects(true);
this.drawingObjects.showDrawingObjects(true);
};
this.drawSelection = function(drawingDocument)
{
DrawDefaultSelection(this.drawingObjectsController, drawingDocument);
this.textObject.updateSelectionState(drawingDocument);
};
this.isPointInDrawingObjects = function(x, y)
{
var selected_objects = this.drawingObjectsController.selectedObjects;
if(selected_objects.length === 1)
{
var hit_to_adj = selected_objects[0].hitToAdjustment(x, y);
if(hit_to_adj.hit)
{
if(selected_objects[0].canChangeAdjustments())
{
return {objectId: selected_objects[0].drawingBase.id, cursorType: "crosshair"};
}
}
}
for(var i = selected_objects.length - 1; i > -1; --i)
{
var hit_to_handles = selected_objects[i].hitToHandles(x, y);
if(hit_to_handles > -1)
{
if(hit_to_handles === 8)
{
if(!selected_objects[i].canRotate())
return null;
return {objectId: selected_objects[i].drawingBase.id, cursorType: "crosshair"};
}
else
{
if(!selected_objects[i].canResize())
return null;
this.drawingObjectsController.clearPreTrackObjects();
var card_direction = selected_objects[i].getCardDirectionByNum(hit_to_handles);
for(var j = 0; j < selected_objects.length; ++j)
{
if(selected_objects[j].canResize())
this.drawingObjectsController.addPreTrackObject(selected_objects[j].createResizeTrack(card_direction));
}
return {objectId: selected_objects[i].drawingBase.id, cursorType: CURSOR_TYPES_BY_CARD_DIRECTION[card_direction]};
}
}
}
for(i = selected_objects.length - 1; i > -1; --i)
{
if(selected_objects[i].hitInBoundingRect(x, y))
{
if(!selected_objects[i].canMove())
return null;
return {objectId: selected_objects[i].drawingBase.id, cursorType: "move"};
}
}
var arr_drawing_objects = this.drawingObjects.getDrawingObjects();
for(i = arr_drawing_objects.length-1; i > -1; --i)
{
var cur_drawing_base = arr_drawing_objects[i];
if(cur_drawing_base.isGraphicObject())
{
var cur_drawing = cur_drawing_base.graphicObject;
if(cur_drawing.isSimpleObject())
{
var hit_in_inner_area = cur_drawing.hitInInnerArea(x, y);
var hit_in_path = cur_drawing.hitInPath(x, y);
var hit_in_text_rect = cur_drawing.hitInTextRect(x, y);
if(hit_in_inner_area && !hit_in_text_rect || hit_in_path)
{
return {objectId: cur_drawing_base.id, cursorType: "move"};
}
else if(hit_in_text_rect)
{
//TODO
}
}
else
{
var grouped_objects = cur_drawing.getArrGraphicObjects();
for(var j = grouped_objects.length - 1; j > -1; --j)
{
var cur_grouped_object = grouped_objects[j];
var hit_in_inner_area = cur_grouped_object.hitInInnerArea(x, y);
var hit_in_path = cur_grouped_object.hitInPath(x, y);
var hit_in_text_rect = cur_grouped_object.hitInTextRect(x, y);
if(hit_in_inner_area && !hit_in_text_rect || hit_in_path)
{
return {objectId: cur_drawing_base.id, cursorType: "move"};
}
else if(hit_in_text_rect)
{
//TODO
}
}
}
}
}
return null;
return this.nullState.isPointInDrawingObjects(x, y);
};
}
......
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