Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
4748321f
Commit
4748321f
authored
Mar 20, 2017
by
Alexey.Musinov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ios collaboration
parent
e07a86fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
358 additions
and
4 deletions
+358
-4
common/Native/Wrappers/DrawingDocument.js
common/Native/Wrappers/DrawingDocument.js
+271
-4
common/Native/Wrappers/api.js
common/Native/Wrappers/api.js
+87
-0
No files found.
common/Native/Wrappers/DrawingDocument.js
View file @
4748321f
...
...
@@ -538,6 +538,205 @@ function CTableOutlineDr()
}
}
function
CDrawingCollaborativeTarget
()
{
this
.
Id
=
""
;
this
.
ShortId
=
""
;
this
.
X
=
0
;
this
.
Y
=
0
;
this
.
Size
=
0
;
this
.
Page
=
-
1
;
this
.
Color
=
null
;
this
.
Transform
=
null
;
this
.
HtmlElement
=
null
;
this
.
HtmlElementX
=
0
;
this
.
HtmlElementY
=
0
;
this
.
Color
=
null
;
this
.
Style
=
""
;
}
CDrawingCollaborativeTarget
.
prototype
=
{
CheckPosition
:
function
(
_drawing_doc
,
_x
,
_y
,
_size
,
_page
,
_transform
)
{
// 1) создаем новый элемент, если еще его не было
// var bIsHtmlElementCreate = false;
// if (this.HtmlElement == null)
// {
// bIsHtmlElementCreate = true;
// this.HtmlElement = document.createElement('canvas');
// this.HtmlElement.style.cssText = "pointer-events: none;position:absolute;padding:0;margin:0;-webkit-user-select:none;width:1px;height:1px;display:block;z-index:3;";
// this.HtmlElement.width = 1;
// this.HtmlElement.height = 1;
//
// this.Color = AscCommon.getUserColorById(this.ShortId, null, true);
// this.Style = "rgb(" + this.Color.r + "," + this.Color.g + "," + this.Color.b + ")";
// }
//
// 2) определяем размер
this
.
Transform
=
_transform
;
this
.
Size
=
_size
;
var
_old_x
=
this
.
X
;
var
_old_y
=
this
.
Y
;
var
_old_page
=
this
.
Page
;
this
.
X
=
_x
;
this
.
Y
=
_y
;
this
.
Page
=
_page
;
// var _oldW = this.HtmlElement.width;
// var _oldH = this.HtmlElement.height;
//
// var _newW = 2;
// var _newH = (this.Size * _drawing_doc.m_oWordControl.m_nZoomValue * g_dKoef_mm_to_pix / 100) >> 0;
//
// if (null != this.Transform && !global_MatrixTransformer.IsIdentity2(this.Transform))
// {
// var _x1 = this.Transform.TransformPointX(_x, _y);
// var _y1 = this.Transform.TransformPointY(_x, _y);
//
// var _x2 = this.Transform.TransformPointX(_x, _y + this.Size);
// var _y2 = this.Transform.TransformPointY(_x, _y + this.Size);
//
// var pos1 = _drawing_doc.ConvertCoordsToCursor2(_x1, _y1, this.Page);
// var pos2 = _drawing_doc.ConvertCoordsToCursor2(_x2, _y2, this.Page);
//
// _newW = (Math.abs(pos1.X - pos2.X) >> 0) + 1;
// _newH = (Math.abs(pos1.Y - pos2.Y) >> 0) + 1;
//
// if (2 > _newW)
// _newW = 2;
// if (2 > _newH)
// _newH = 2;
//
// if (_oldW == _newW && _oldH == _newH)
// {
// if (_newW != 2 && _newH != 2)
// {
// // просто очищаем
// this.HtmlElement.width = _newW;
// }
// }
// else
// {
// this.HtmlElement.style.width = _newW + "px";
// this.HtmlElement.style.height = _newH + "px";
//
// this.HtmlElement.width = _newW;
// this.HtmlElement.height = _newH;
// }
// var ctx = this.HtmlElement.getContext('2d');
//
// if (_newW == 2 || _newH == 2)
// {
// ctx.fillStyle = this.Style;
// ctx.fillRect(0, 0, _newW, _newH);
// }
// else
// {
// ctx.beginPath();
// ctx.strokeStyle = this.Style;
// ctx.lineWidth = 2;
//
// if (((pos1.X - pos2.X) * (pos1.Y - pos2.Y)) >= 0)
// {
// ctx.moveTo(0, 0);
// ctx.lineTo(_newW, _newH);
// }
// else
// {
// ctx.moveTo(0, _newH);
// ctx.lineTo(_newW, 0);
// }
//
// ctx.stroke();
// }
//
// this.HtmlElementX = Math.min(pos1.X, pos2.X) >> 0;
// this.HtmlElementY = Math.min(pos1.Y, pos2.Y) >> 0;
// if ((!_drawing_doc.m_oWordControl.MobileTouchManager && !AscCommon.AscBrowser.isSafariMacOs) || !AscCommon.AscBrowser.isWebkit)
// {
// this.HtmlElement.style.left = this.HtmlElementX + "px";
// this.HtmlElement.style.top = this.HtmlElementY + "px";
// }
// else
// {
// this.HtmlElement.style.left = "0px";
// this.HtmlElement.style.top = "0px";
// this.HtmlElement.style["webkitTransform"] = "matrix(1, 0, 0, 1, " + this.HtmlElementX + "," + this.HtmlElementY + ")";
// }
// }
// else
// {
// if (_oldW == _newW && _oldH == _newH)
// {
// // просто очищаем
// this.HtmlElement.width = _newW;
// }
// else
// {
// this.HtmlElement.style.width = _newW + "px";
// this.HtmlElement.style.height = _newH + "px";
//
// this.HtmlElement.width = _newW;
// this.HtmlElement.height = _newH;
// }
//
// var ctx = this.HtmlElement.getContext('2d');
//
// ctx.fillStyle = this.Style;
// ctx.fillRect(0, 0, _newW, _newH);
//
// if (null != this.Transform)
// {
// _x += this.Transform.tx;
// _y += this.Transform.ty;
// }
//
// var pos = _drawing_doc.ConvertCoordsToCursor2(_x, _y, this.Page);
//
// this.HtmlElementX = pos.X >> 0;
// this.HtmlElementY = pos.Y >> 0;
//
// if ((!_drawing_doc.m_oWordControl.MobileTouchManager && !AscCommon.AscBrowser.isSafariMacOs) || !AscCommon.AscBrowser.isWebkit)
// {
// this.HtmlElement.style.left = this.HtmlElementX + "px";
// this.HtmlElement.style.top = this.HtmlElementY + "px";
// }
// else
// {
// this.HtmlElement.style.left = "0px";
// this.HtmlElement.style.top = "0px";
// this.HtmlElement.style["webkitTransform"] = "matrix(1, 0, 0, 1, " + this.HtmlElementX + "," + this.HtmlElementY + ")";
// }
// }
//
// if (AscCommon.CollaborativeEditing)
// AscCommon.CollaborativeEditing.Update_ForeignCursorLabelPosition(this.Id, this.HtmlElementX, this.HtmlElementY, this.Color);
//
// // 3) добавить, если нужно
// if (bIsHtmlElementCreate)
// {
// _drawing_doc.m_oWordControl.m_oMainView.HtmlElement.appendChild(this.HtmlElement);
// }
},
Remove
:
function
(
_drawing_doc
)
{
//_drawing_doc.m_oWordControl.m_oMainView.HtmlElement.removeChild(this.HtmlElement);
},
Update
:
function
(
_drawing_doc
)
{
//this.CheckPosition(_drawing_doc, this.X, this.Y, this.Size, this.Page, this.Transform);
}
};
function
CDrawingDocument
()
{
this
.
Native
=
window
[
"
native
"
];
...
...
@@ -590,8 +789,8 @@ function CDrawingDocument()
this
.
FrameRect
=
{
IsActive
:
false
,
Rect
:
{
X
:
0
,
Y
:
0
,
R
:
0
,
B
:
0
},
Frame
:
null
,
Track
:
{
X
:
0
,
Y
:
0
,
L
:
0
,
T
:
0
,
R
:
0
,
B
:
0
,
PageIndex
:
0
,
Type
:
-
1
},
IsTracked
:
false
,
PageIndex
:
0
};
// math rect
this
.
MathRect
=
{
IsActive
:
false
,
Rect
:
{
X
:
0
,
Y
:
0
,
R
:
0
,
B
:
0
,
PageIndex
:
0
}
};
// math rect
this
.
MathRect
=
{
IsActive
:
false
,
Rect
:
{
X
:
0
,
Y
:
0
,
R
:
0
,
B
:
0
,
PageIndex
:
0
}
};
// table track
this
.
TableOutlineDr
=
new
CTableOutlineDr
();
...
...
@@ -612,6 +811,9 @@ function CDrawingDocument()
this
.
UpdateRulerStateFlag
=
false
;
this
.
UpdateRulerStateParams
=
[];
this
.
CollaborativeTargets
=
[];
this
.
CollaborativeTargetsUpdateTasks
=
[];
}
var
_table_styles
=
null
;
...
...
@@ -1250,7 +1452,7 @@ CDrawingDocument.prototype =
{
},
BeginDrawTracking
:
function
()
BeginDrawTracking
:
function
()
{
if
(
this
.
AutoShapesTrack
.
BeginDrawTracking
)
{
this
.
AutoShapesTrack
.
BeginDrawTracking
();
...
...
@@ -2826,7 +3028,72 @@ CDrawingDocument.prototype =
var
ret
=
Renderer
.
Memory
.
GetBase64Memory
();
//console.log(ret);
return
ret
;
}
},
// collaborative targets
Collaborative_UpdateTarget
:
function
(
_id
,
_shortId
,
_x
,
_y
,
_size
,
_page
,
_transform
,
is_from_paint
)
{
if
(
is_from_paint
!==
true
)
{
this
.
CollaborativeTargetsUpdateTasks
.
push
([
_id
,
_shortId
,
_x
,
_y
,
_size
,
_page
,
_transform
]);
return
;
}
for
(
var
i
=
0
;
i
<
this
.
CollaborativeTargets
.
length
;
i
++
)
{
if
(
_id
==
this
.
CollaborativeTargets
[
i
].
Id
)
{
this
.
CollaborativeTargets
[
i
].
CheckPosition
(
this
,
_x
,
_y
,
_size
,
_page
,
_transform
);
return
;
}
}
var
_target
=
new
CDrawingCollaborativeTarget
();
_target
.
Id
=
_id
;
_target
.
ShortId
=
_shortId
;
_target
.
CheckPosition
(
this
,
_x
,
_y
,
_size
,
_page
,
_transform
);
this
.
CollaborativeTargets
[
this
.
CollaborativeTargets
.
length
]
=
_target
;
},
Collaborative_RemoveTarget
:
function
(
_id
)
{
for
(
var
i
=
0
;
i
<
this
.
CollaborativeTargets
.
length
;
i
++
)
{
if
(
_id
==
this
.
CollaborativeTargets
[
i
].
Id
)
{
this
.
CollaborativeTargets
[
i
].
Remove
(
this
);
this
.
CollaborativeTargets
.
splice
(
i
,
1
);
}
}
},
Collaborative_TargetsUpdate
:
function
(
bIsChangePosition
)
{
var
_len_tasks
=
this
.
CollaborativeTargetsUpdateTasks
.
length
;
var
i
=
0
;
for
(
i
=
0
;
i
<
_len_tasks
;
i
++
)
{
var
_tmp
=
this
.
CollaborativeTargetsUpdateTasks
[
i
];
this
.
Collaborative_UpdateTarget
(
_tmp
[
0
],
_tmp
[
1
],
_tmp
[
2
],
_tmp
[
3
],
_tmp
[
4
],
_tmp
[
5
],
_tmp
[
6
],
true
);
}
if
(
_len_tasks
!=
0
)
this
.
CollaborativeTargetsUpdateTasks
.
splice
(
0
,
_len_tasks
);
if
(
bIsChangePosition
)
{
for
(
i
=
0
;
i
<
this
.
CollaborativeTargets
.
length
;
i
++
)
{
this
.
CollaborativeTargets
[
i
].
Update
(
this
);
}
}
},
Collaborative_GetTargetPosition
:
function
(
UserId
)
{
for
(
var
i
=
0
;
i
<
this
.
CollaborativeTargets
.
length
;
i
++
)
{
if
(
UserId
==
this
.
CollaborativeTargets
[
i
].
Id
)
return
{
X
:
this
.
CollaborativeTargets
[
i
].
HtmlElementX
,
Y
:
this
.
CollaborativeTargets
[
i
].
HtmlElementY
};
}
return
null
;
}
};
function
check_KeyboardEvent
(
e
)
...
...
common/Native/Wrappers/api.js
View file @
4748321f
...
...
@@ -30,6 +30,8 @@
*
*/
window
.
IS_NATIVE_EDITOR
=
true
;
window
[
'
SockJS
'
]
=
createSockJS
();
Asc
[
'
asc_docs_api
'
].
prototype
.
Update_ParaInd
=
function
(
Ind
)
...
...
@@ -5857,3 +5859,88 @@ Asc['asc_docs_api'].prototype.__SendThemeColorScheme = function()
this.WordControl.m_oApi.sync_SendThemeColorSchemes(infos);
};
*/
function
NativeOpenFile3
(
_params
,
documentInfo
)
{
window
[
"
CreateMainTextMeasurerWrapper
"
]();
window
.
g_file_path
=
"
native_open_file
"
;
window
.
NATIVE_DOCUMENT_TYPE
=
window
.
native
.
GetEditorType
();
var
doc_bin
=
window
.
native
.
GetFileString
(
window
.
g_file_path
);
if
(
window
.
NATIVE_DOCUMENT_TYPE
==
"
presentation
"
||
window
.
NATIVE_DOCUMENT_TYPE
==
"
document
"
)
{
_api
=
new
window
[
"
Asc
"
][
"
asc_docs_api
"
](
""
);
if
(
undefined
!==
_api
.
Native_Editor_Initialize_Settings
)
{
_api
.
Native_Editor_Initialize_Settings
(
_params
);
}
window
.
documentInfo
=
documentInfo
;
var
userInfo
=
new
Asc
.
asc_CUserInfo
();
userInfo
.
asc_putId
(
window
.
documentInfo
[
"
docUserId
"
]);
userInfo
.
asc_putFullName
(
window
.
documentInfo
[
"
docUserName
"
]);
userInfo
.
asc_putFirstName
(
window
.
documentInfo
[
"
docUserFirstName
"
]);
userInfo
.
asc_putLastName
(
window
.
documentInfo
[
"
docUserLastName
"
]);
var
docInfo
=
new
Asc
.
asc_CDocInfo
();
docInfo
.
put_Id
(
window
.
documentInfo
[
"
docKey
"
]);
docInfo
.
put_UserInfo
(
userInfo
);
_api
.
asc_setDocInfo
(
docInfo
);
if
(
window
.
documentInfo
[
"
iscoauthoring
"
])
{
_api
.
isSpellCheckEnable
=
false
;
_api
.
asc_setAutoSaveGap
(
1
);
_api
.
_coAuthoringInit
();
_api
.
asc_SetFastCollaborative
(
true
);
_api
.
asc_registerCallback
(
"
asc_onAuthParticipantsChanged
"
,
function
(
users
)
{
var
stream
=
global_memory_stream_menu
;
stream
[
"
ClearNoAttack
"
]();
asc_WriteUsers
(
users
,
stream
);
window
[
"
native
"
][
"
OnCallMenuEvent
"
](
20101
,
stream
);
// ASC_COAUTH_EVENT_TYPE_PARTICIPANTS_CHANGED
});
_api
.
asc_registerCallback
(
"
asc_onParticipantsChanged
"
,
function
(
users
)
{
var
stream
=
global_memory_stream_menu
;
stream
[
"
ClearNoAttack
"
]();
asc_WriteUsers
(
users
,
stream
);
window
[
"
native
"
][
"
OnCallMenuEvent
"
](
20101
,
stream
);
// ASC_COAUTH_EVENT_TYPE_PARTICIPANTS_CHANGED
});
_api
.
asc_registerCallback
(
"
asc_onGetEditorPermissions
"
,
function
(
state
)
{
var
rData
=
{
"
c
"
:
"
open
"
,
"
id
"
:
window
.
documentInfo
[
"
docKey
"
],
"
userid
"
:
window
.
documentInfo
[
"
docUserId
"
],
"
format
"
:
"
docx
"
,
"
vkey
"
:
undefined
,
"
url
"
:
window
.
documentInfo
[
"
docURL
"
],
"
title
"
:
this
.
documentTitle
,
"
embeddedfonts
"
:
false
};
_api
.
CoAuthoringApi
.
auth
(
window
.
documentInfo
[
"
viewmode
"
],
rData
);
});
_api
.
asc_registerCallback
(
"
asc_onDocumentUpdateVersion
"
,
function
(
callback
)
{
var
me
=
this
;
me
.
needToUpdateVersion
=
true
;
if
(
callback
)
callback
.
call
(
me
);
});
}
else
{
var
doc_bin
=
window
.
native
.
GetFileString
(
window
.
g_file_path
);
_api
.
asc_nativeOpenFile
(
doc_bin
);
if
(
_api
.
NativeAfterLoad
)
_api
.
NativeAfterLoad
();
}
}
Api
=
_api
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment