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
9cca4eb0
Commit
9cca4eb0
authored
Aug 29, 2016
by
Sergey Luzyanin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inserting ole objects in cell editor
parent
e9e0e625
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
146 additions
and
41 deletions
+146
-41
cell/api.js
cell/api.js
+23
-0
cell/view/DrawingObjectsController.js
cell/view/DrawingObjectsController.js
+41
-0
common/Charts/DrawingObjects.js
common/Charts/DrawingObjects.js
+82
-41
No files found.
cell/api.js
View file @
9cca4eb0
...
...
@@ -2357,6 +2357,29 @@ var editor;
this
.
handlers
.
trigger
(
"
asc_onEndAddShape
"
);
};
spreadsheet_api
.
prototype
.
asc_addOleObjectAction
=
function
(
sLocalUrl
,
sData
,
sApplicationId
,
fWidth
,
fHeight
,
nWidthPix
,
nHeightPix
)
{
var
_image
=
this
.
ImageLoader
.
LoadImage
(
AscCommon
.
getFullImageSrc2
(
sLocalUrl
),
1
);
if
(
null
!=
_image
){
var
ws
=
this
.
wb
.
getWorksheet
();
if
(
ws
.
objectRender
){
ws
.
objectRender
.
addOleObject
(
fWidth
,
fHeight
,
nWidthPix
,
nHeightPix
,
sLocalUrl
,
sData
,
sApplicationId
);
}
}
};
spreadsheet_api
.
prototype
.
asc_editOleObjectAction
=
function
(
bResize
,
oOleObject
,
sImageUrl
,
sData
,
nPixWidth
,
nPixHeight
)
{
if
(
oOleObject
)
{
var
ws
=
this
.
wb
.
getWorksheet
();
if
(
ws
.
objectRender
){
ws
.
objectRender
.
editOleObject
(
oOleObject
,
sData
,
sImageUrl
,
nPixWidth
,
nPixHeight
,
bResize
);
}
}
};
spreadsheet_api
.
prototype
.
asc_isAddAutoshape
=
function
()
{
return
this
.
isStartAddShape
;
};
...
...
cell/view/DrawingObjectsController.js
View file @
9cca4eb0
...
...
@@ -306,6 +306,22 @@ DrawingObjectsController.prototype.handleChartDoubleClick = function()
this
.
checkSelectedObjectsAndFireCallback
(
function
(){
drawingObjects
.
showChartSettings
();
},
[]);
}
DrawingObjectsController
.
prototype
.
handleOleObjectDoubleClick
=
function
(
drawing
,
oleObject
,
e
,
x
,
y
,
pageIndex
)
{
var
drawingObjects
=
this
.
drawingObjects
;
this
.
checkSelectedObjectsAndFireCallback
(
function
(){
var
pluginData
=
new
Asc
.
CPluginData
();
pluginData
.
setAttribute
(
"
data
"
,
oleObject
.
m_sData
);
pluginData
.
setAttribute
(
"
guid
"
,
oleObject
.
m_sApplicationId
);
pluginData
.
setAttribute
(
"
width
"
,
oleObject
.
extX
);
pluginData
.
setAttribute
(
"
height
"
,
oleObject
.
extY
);
pluginData
.
setAttribute
(
"
widthPix
"
,
oleObject
.
m_nPixWidth
);
pluginData
.
setAttribute
(
"
heightPix
"
,
oleObject
.
m_nPixHeight
);
pluginData
.
setAttribute
(
"
objectId
"
,
oleObject
.
Id
);
window
[
"
Asc
"
][
"
editor
"
].
asc_pluginRun
(
oleObject
.
m_sApplicationId
,
0
,
pluginData
);
this
.
onMouseUp
(
e
,
x
,
y
);
},
[]);
};
DrawingObjectsController
.
prototype
.
addChartDrawingObject
=
function
(
options
)
...
...
@@ -406,6 +422,31 @@ DrawingObjectsController.prototype.addImageFromParams = function(rasterImageId,
this
.
startRecalculate
();
};
DrawingObjectsController
.
prototype
.
addOleObjectFromParams
=
function
(
fPosX
,
fPosY
,
fWidth
,
fHeight
,
nWidthPix
,
nHeightPix
,
sLocalUrl
,
sData
,
sApplicationId
){
History
.
Create_NewPoint
();
var
oOleObject
=
this
.
createOleObject
(
sData
,
sApplicationId
,
sLocalUrl
,
fPosX
,
fPosY
,
fWidth
,
fHeight
,
nWidthPix
,
nHeightPix
);
this
.
resetSelection
();
oOleObject
.
setWorksheet
(
this
.
drawingObjects
.
getWorksheetModel
());
oOleObject
.
setDrawingObjects
(
this
.
drawingObjects
);
oOleObject
.
addToDrawingObjects
();
oOleObject
.
checkDrawingBaseCoords
();
this
.
selectObject
(
oOleObject
,
0
);
oOleObject
.
addToRecalculate
();
this
.
startRecalculate
();
};
DrawingObjectsController
.
prototype
.
editOleObjectFromParams
=
function
(
oOleObject
,
sData
,
sImageUrl
,
nPixWidth
,
nPixHeight
,
bResize
){
if
(
!
bResize
){
History
.
Create_NewPoint
();
}
oOleObject
.
setData
(
sData
);
var
_blipFill
=
new
AscFormat
.
CBlipFill
();
_blipFill
.
RasterImageId
=
sImageUrl
;
oOleObject
.
setBlipFill
(
_blipFill
);
oOleObject
.
setPixSizes
(
nPixWidth
,
nPixHeight
);
this
.
startRecalculate
();
};
DrawingObjectsController
.
prototype
.
addTextArtFromParams
=
function
(
nStyle
,
dRectX
,
dRectY
,
dRectW
,
dRectH
,
wsmodel
)
{
...
...
common/Charts/DrawingObjects.js
View file @
9cca4eb0
...
...
@@ -1890,56 +1890,59 @@ function DrawingObjects() {
// For object type
//-----------------------------------------------------------------------------------
_this
.
addImageDrawingObject
=
function
(
imageUrl
,
options
)
{
if
(
imageUrl
&&
!
_this
.
isViewerMode
())
{
var
_image
=
api
.
ImageLoader
.
LoadImage
(
imageUrl
,
1
);
var
isOption
=
options
&&
options
.
cell
;
_this
.
calculateObjectMetrics
=
function
(
object
,
width
,
height
)
{
// Обработка картинок большого разрешения
var
metricCoeff
=
1
;
var
calculateObjectMetrics
=
function
(
object
,
width
,
height
)
{
// Обработка картинок большого разрешения
var
metricCoeff
=
1
;
var
coordsFrom
=
_this
.
coordsManager
.
calculateCoords
(
object
.
from
);
var
realTopOffset
=
coordsFrom
.
y
;
var
realLeftOffset
=
coordsFrom
.
x
;
var
coordsFrom
=
_this
.
coordsManager
.
calculateCoords
(
object
.
from
);
var
realTopOffset
=
coordsFrom
.
y
;
var
realLeftOffset
=
coordsFrom
.
x
;
var
areaWidth
=
worksheet
.
getCellLeft
(
worksheet
.
getLastVisibleCol
(),
0
)
-
worksheet
.
getCellLeft
(
worksheet
.
getFirstVisibleCol
(
true
),
0
);
// по ширине
if
(
areaWidth
<
width
)
{
metricCoeff
=
width
/
areaWidth
;
var
areaWidth
=
worksheet
.
getCellLeft
(
worksheet
.
getLastVisibleCol
(),
0
)
-
worksheet
.
getCellLeft
(
worksheet
.
getFirstVisibleCol
(
true
),
0
);
// по ширине
if
(
areaWidth
<
width
)
{
metricCoeff
=
width
/
areaWidth
;
width
=
areaWidth
;
height
/=
metricCoeff
;
}
width
=
areaWidth
;
height
/=
metricCoeff
;
}
var
areaHeight
=
worksheet
.
getCellTop
(
worksheet
.
getLastVisibleRow
(),
0
)
-
worksheet
.
getCellTop
(
worksheet
.
getFirstVisibleRow
(
true
),
0
);
// по высоте
if
(
areaHeight
<
height
)
{
metricCoeff
=
height
/
areaHeight
;
var
areaHeight
=
worksheet
.
getCellTop
(
worksheet
.
getLastVisibleRow
(),
0
)
-
worksheet
.
getCellTop
(
worksheet
.
getFirstVisibleRow
(
true
),
0
);
// по высоте
if
(
areaHeight
<
height
)
{
metricCoeff
=
height
/
areaHeight
;
height
=
areaHeight
;
width
/=
metricCoeff
;
}
height
=
areaHeight
;
width
/=
metricCoeff
;
}
var
findVal
=
pxToPt
(
realLeftOffset
+
width
);
var
toCell
=
worksheet
.
findCellByXY
(
findVal
,
0
,
true
,
false
,
true
);
while
(
toCell
.
col
===
null
&&
worksheet
.
cols
.
length
<
gc_nMaxCol
)
{
worksheet
.
expandColsOnScroll
(
true
);
toCell
=
worksheet
.
findCellByXY
(
findVal
,
0
,
true
,
false
,
true
);
}
object
.
to
.
col
=
toCell
.
col
;
object
.
to
.
colOff
=
ptToMm
(
toCell
.
colOff
);
var
findVal
=
pxToPt
(
realLeftOffset
+
width
);
var
toCell
=
worksheet
.
findCellByXY
(
findVal
,
0
,
true
,
false
,
true
);
while
(
toCell
.
col
===
null
&&
worksheet
.
cols
.
length
<
gc_nMaxCol
)
{
worksheet
.
expandColsOnScroll
(
true
);
toCell
=
worksheet
.
findCellByXY
(
findVal
,
0
,
true
,
false
,
true
);
}
object
.
to
.
col
=
toCell
.
col
;
object
.
to
.
colOff
=
ptToMm
(
toCell
.
colOff
);
findVal
=
pxToPt
(
realTopOffset
+
height
);
toCell
=
worksheet
.
findCellByXY
(
0
,
findVal
,
true
,
true
,
false
);
while
(
toCell
.
row
===
null
&&
worksheet
.
rows
.
length
<
gc_nMaxRow
)
{
worksheet
.
expandRowsOnScroll
(
true
);
toCell
=
worksheet
.
findCellByXY
(
0
,
findVal
,
true
,
true
,
false
);
}
object
.
to
.
row
=
toCell
.
row
;
object
.
to
.
rowOff
=
ptToMm
(
toCell
.
rowOff
);
worksheet
.
handlers
.
trigger
(
"
reinitializeScroll
"
);
};
_this
.
addImageDrawingObject
=
function
(
imageUrl
,
options
)
{
if
(
imageUrl
&&
!
_this
.
isViewerMode
())
{
var
_image
=
api
.
ImageLoader
.
LoadImage
(
imageUrl
,
1
);
var
isOption
=
options
&&
options
.
cell
;
findVal
=
pxToPt
(
realTopOffset
+
height
);
toCell
=
worksheet
.
findCellByXY
(
0
,
findVal
,
true
,
true
,
false
);
while
(
toCell
.
row
===
null
&&
worksheet
.
rows
.
length
<
gc_nMaxRow
)
{
worksheet
.
expandRowsOnScroll
(
true
);
toCell
=
worksheet
.
findCellByXY
(
0
,
findVal
,
true
,
true
,
false
);
}
object
.
to
.
row
=
toCell
.
row
;
object
.
to
.
rowOff
=
ptToMm
(
toCell
.
rowOff
);
worksheet
.
handlers
.
trigger
(
"
reinitializeScroll
"
);
};
var
addImageObject
=
function
(
_image
)
{
...
...
@@ -1964,7 +1967,7 @@ function DrawingObjects() {
}
worksheet
.
expandRowsOnScroll
(
true
);
// для rowOff
calculateObjectMetrics
(
drawingObject
,
isOption
?
options
.
width
:
_image
.
Image
.
width
,
isOption
?
options
.
height
:
_image
.
Image
.
height
);
_this
.
calculateObjectMetrics
(
drawingObject
,
isOption
?
options
.
width
:
_image
.
Image
.
width
,
isOption
?
options
.
height
:
_image
.
Image
.
height
);
var
coordsFrom
=
_this
.
coordsManager
.
calculateCoords
(
drawingObject
.
from
);
var
coordsTo
=
_this
.
coordsManager
.
calculateCoords
(
drawingObject
.
to
);
...
...
@@ -3065,6 +3068,44 @@ function DrawingObjects() {
return
ret
;
};
_this
.
addOleObject
=
function
(
fWidth
,
fHeight
,
nWidthPix
,
nHeightPix
,
sLocalUrl
,
sData
,
sApplicationId
){
var
drawingObject
=
_this
.
createDrawingObject
();
drawingObject
.
worksheet
=
worksheet
;
drawingObject
.
from
.
col
=
worksheet
.
getSelectedColumnIndex
();
drawingObject
.
from
.
row
=
worksheet
.
getSelectedRowIndex
();
// Проверяем начальные координаты при вставке
while
(
!
worksheet
.
cols
[
drawingObject
.
from
.
col
])
{
worksheet
.
expandColsOnScroll
(
true
);
}
worksheet
.
expandColsOnScroll
(
true
);
// для colOff
while
(
!
worksheet
.
rows
[
drawingObject
.
from
.
row
])
{
worksheet
.
expandRowsOnScroll
(
true
);
}
worksheet
.
expandRowsOnScroll
(
true
);
// для rowOff
_this
.
calculateObjectMetrics
(
drawingObject
,
nWidthPix
,
nHeightPix
);
var
coordsFrom
=
_this
.
coordsManager
.
calculateCoords
(
drawingObject
.
from
);
_this
.
objectLocker
.
reset
();
_this
.
objectLocker
.
addObjectId
(
AscCommon
.
g_oIdCounter
.
Get_NewId
());
_this
.
objectLocker
.
checkObjects
(
function
(
bLock
)
{
if
(
bLock
!==
true
)
return
;
_this
.
controller
.
resetSelection
();
_this
.
controller
.
addOleObjectFromParams
(
pxToMm
(
coordsFrom
.
x
),
pxToMm
(
coordsFrom
.
y
),
fWidth
,
fHeight
,
nWidthPix
,
nHeightPix
,
sLocalUrl
,
sData
,
sApplicationId
);
worksheet
.
setSelectionShape
(
true
);
});
};
_this
.
editOleObject
=
function
(
oOleObject
,
sData
,
sImageUrl
,
nPixWidth
,
nPixHeight
,
bResize
){
this
.
controller
.
editOleObjectFromParams
(
oOleObject
,
sData
,
sImageUrl
,
nPixWidth
,
nPixHeight
,
bResize
);
};
_this
.
groupGraphicObjects
=
function
()
{
if
(
_this
.
controller
.
canGroup
()
)
{
...
...
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