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
555a4d1d
Commit
555a4d1d
authored
Jun 21, 2017
by
Alexander.Trofimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
formatting
parent
ad9a304e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
127 additions
and
122 deletions
+127
-122
cell/utils/utils.js
cell/utils/utils.js
+127
-122
No files found.
cell/utils/utils.js
View file @
555a4d1d
...
...
@@ -1989,36 +1989,37 @@
this
.
styleThumbnailWidthWithRetina
=
this
.
styleThumbnailWidth
;
this
.
styleThumbnailHeightWithRetina
=
this
.
styleThumbnailHeight
;
if
(
AscCommon
.
AscBrowser
.
isRetina
)
{
this
.
styleThumbnailWidthWithRetina
=
AscCommon
.
AscBrowser
.
convertToRetinaValue
(
this
.
styleThumbnailWidthWithRetina
,
true
);
this
.
styleThumbnailHeightWithRetina
=
AscCommon
.
AscBrowser
.
convertToRetinaValue
(
this
.
styleThumbnailHeightWithRetina
,
true
);
this
.
styleThumbnailWidthWithRetina
=
AscCommon
.
AscBrowser
.
convertToRetinaValue
(
this
.
styleThumbnailWidthWithRetina
,
true
);
this
.
styleThumbnailHeightWithRetina
=
AscCommon
.
AscBrowser
.
convertToRetinaValue
(
this
.
styleThumbnailHeightWithRetina
,
true
);
}
}
asc_CStylesPainter
.
prototype
=
{
constructor
:
asc_CStylesPainter
,
asc_getStyleThumbnailWidth
:
function
()
{
asc_CStylesPainter
.
prototype
.
asc_getStyleThumbnailWidth
=
function
()
{
return
this
.
styleThumbnailWidthWithRetina
;
},
asc_getStyleThumbnailHeight
:
function
()
{
};
asc_CStylesPainter
.
prototype
.
asc_getStyleThumbnailHeight
=
function
()
{
return
this
.
styleThumbnailHeightWithRetina
;
},
asc_getDefaultStyles
:
function
()
{
};
asc_CStylesPainter
.
prototype
.
asc_getDefaultStyles
=
function
()
{
return
this
.
defaultStyles
;
},
asc_getDocStyles
:
function
()
{
};
asc_CStylesPainter
.
prototype
.
asc_getDocStyles
=
function
()
{
return
this
.
docStyles
;
},
generateStylesAll
:
function
(
cellStylesAll
,
fmgrGraphics
,
oFont
,
stringRendere
r
)
{
this
.
generateDefaultStyles
(
cellStylesAll
,
fmgrGraphics
,
oFont
,
stringRendere
r
);
this
.
generateDocumentStyles
(
cellStylesAll
,
fmgrGraphics
,
oFont
,
stringRendere
r
);
},
generateDefaultStyles
:
function
(
cellStylesAll
,
fmgrGraphics
,
oFont
,
stringRendere
r
)
{
};
asc_CStylesPainter
.
prototype
.
generateStylesAll
=
function
(
cellStylesAll
,
fmgrGraphics
,
oFont
,
s
r
)
{
this
.
generateDefaultStyles
(
cellStylesAll
,
fmgrGraphics
,
oFont
,
s
r
);
this
.
generateDocumentStyles
(
cellStylesAll
,
fmgrGraphics
,
oFont
,
s
r
);
};
asc_CStylesPainter
.
prototype
.
generateDefaultStyles
=
function
(
cellStylesAll
,
fmgrGraphics
,
oFont
,
s
r
)
{
var
cellStyles
=
cellStylesAll
.
DefaultStyles
;
var
oCanvas
=
document
.
createElement
(
'
canvas
'
);
oCanvas
.
width
=
this
.
styleThumbnailWidthWithRetina
;
oCanvas
.
height
=
this
.
styleThumbnailHeightWithRetina
;
var
oGraphics
=
new
Asc
.
DrawingContext
({
canvas
:
oCanvas
,
units
:
1
/*pt*/
,
fmgrGraphics
:
fmgrGraphics
,
font
:
oFont
});
var
oGraphics
=
new
Asc
.
DrawingContext
(
{
canvas
:
oCanvas
,
units
:
1
/*pt*/
,
fmgrGraphics
:
fmgrGraphics
,
font
:
oFont
});
var
oStyle
,
oCustomStyle
;
this
.
defaultStyles
=
[];
...
...
@@ -2030,17 +2031,19 @@
// ToDo Возможно стоит переписать немного, чтобы не пробегать каждый раз по массиву custom-стилей (нужно генерировать AllStyles)
oCustomStyle
=
cellStylesAll
.
getCustomStyleByBuiltinId
(
oStyle
.
BuiltinId
);
this
.
drawStyle
(
oGraphics
,
stringRenderer
,
oCustomStyle
||
oStyle
,
oStyle
.
Name
);
this
.
defaultStyles
.
push
(
new
AscCommon
.
CStyleImage
(
oStyle
.
Name
,
AscCommon
.
c_oAscStyleImage
.
Default
,
oCanvas
.
toDataURL
(
"
image/png
"
)));
this
.
drawStyle
(
oGraphics
,
sr
,
oCustomStyle
||
oStyle
,
oStyle
.
Name
);
this
.
defaultStyles
.
push
(
new
AscCommon
.
CStyleImage
(
oStyle
.
Name
,
AscCommon
.
c_oAscStyleImage
.
Default
,
oCanvas
.
toDataURL
(
"
image/png
"
)));
}
},
generateDocumentStyles
:
function
(
cellStylesAll
,
fmgrGraphics
,
oFont
,
stringRendere
r
)
{
};
asc_CStylesPainter
.
prototype
.
generateDocumentStyles
=
function
(
cellStylesAll
,
fmgrGraphics
,
oFont
,
s
r
)
{
var
cellStyles
=
cellStylesAll
.
CustomStyles
;
var
oCanvas
=
document
.
createElement
(
'
canvas
'
);
oCanvas
.
width
=
this
.
styleThumbnailWidthWithRetina
;
oCanvas
.
height
=
this
.
styleThumbnailHeightWithRetina
;
var
oGraphics
=
new
Asc
.
DrawingContext
({
canvas
:
oCanvas
,
units
:
1
/*pt*/
,
fmgrGraphics
:
fmgrGraphics
,
font
:
oFont
});
var
oGraphics
=
new
Asc
.
DrawingContext
(
{
canvas
:
oCanvas
,
units
:
1
/*pt*/
,
fmgrGraphics
:
fmgrGraphics
,
font
:
oFont
});
var
oStyle
;
this
.
docStyles
=
[];
...
...
@@ -2050,11 +2053,12 @@
continue
;
}
this
.
drawStyle
(
oGraphics
,
stringRenderer
,
oStyle
,
oStyle
.
Name
);
this
.
docStyles
.
push
(
new
AscCommon
.
CStyleImage
(
oStyle
.
Name
,
AscCommon
.
c_oAscStyleImage
.
Document
,
oCanvas
.
toDataURL
(
"
image/png
"
)));
this
.
drawStyle
(
oGraphics
,
sr
,
oStyle
,
oStyle
.
Name
);
this
.
docStyles
.
push
(
new
AscCommon
.
CStyleImage
(
oStyle
.
Name
,
AscCommon
.
c_oAscStyleImage
.
Document
,
oCanvas
.
toDataURL
(
"
image/png
"
)));
}
},
drawStyle
:
function
(
oGraphics
,
stringRendere
r
,
oStyle
,
sStyleName
)
{
};
asc_CStylesPainter
.
prototype
.
drawStyle
=
function
(
oGraphics
,
s
r
,
oStyle
,
sStyleName
)
{
oGraphics
.
clear
();
// Fill cell
var
oColor
=
oStyle
.
getFill
();
...
...
@@ -2063,8 +2067,8 @@
oGraphics
.
fillRect
(
0
,
0
,
this
.
styleThumbnailWidthPt
,
this
.
styleThumbnailHeightPt
);
}
var
drawBorder
=
function
(
b
,
x1
,
y1
,
x2
,
y2
)
{
if
(
null
!=
b
&&
AscCommon
.
c_oAscBorderStyles
.
None
!==
b
.
s
)
{
var
drawBorder
=
function
(
b
,
x1
,
y1
,
x2
,
y2
)
{
if
(
b
&&
AscCommon
.
c_oAscBorderStyles
.
None
!==
b
.
s
)
{
oGraphics
.
setStrokeStyle
(
b
.
c
);
// ToDo поправить
...
...
@@ -2075,9 +2079,11 @@
// borders
var
oBorders
=
oStyle
.
getBorder
();
drawBorder
(
oBorders
.
l
,
0
,
0
,
0
,
this
.
styleThumbnailHeightPt
);
drawBorder
(
oBorders
.
r
,
this
.
styleThumbnailWidthPt
,
0
,
this
.
styleThumbnailWidthPt
,
this
.
styleThumbnailHeightPt
);
drawBorder
(
oBorders
.
r
,
this
.
styleThumbnailWidthPt
,
0
,
this
.
styleThumbnailWidthPt
,
this
.
styleThumbnailHeightPt
);
drawBorder
(
oBorders
.
t
,
0
,
0
,
this
.
styleThumbnailWidthPt
,
0
);
drawBorder
(
oBorders
.
b
,
0
,
this
.
styleThumbnailHeightPt
,
this
.
styleThumbnailWidthPt
,
this
.
styleThumbnailHeightPt
);
drawBorder
(
oBorders
.
b
,
0
,
this
.
styleThumbnailHeightPt
,
this
.
styleThumbnailWidthPt
,
this
.
styleThumbnailHeightPt
);
// Draw text
var
fc
=
oStyle
.
getFontColor
();
...
...
@@ -2085,18 +2091,17 @@
var
format
=
oStyle
.
getFont
();
var
fs
=
format
.
getSize
();
// Для размера шрифта делаем ограничение для превью в 16pt (у Excel 18pt, но и высота превью больше 22px)
var
oFont
=
new
Asc
.
FontProperties
(
format
.
getName
(),
(
16
<
fs
)
?
16
:
fs
,
format
.
getBold
(),
format
.
getItalic
(),
format
.
getUnderline
(),
format
.
getStrikeout
());
var
oFont
=
new
Asc
.
FontProperties
(
format
.
getName
(),
(
16
<
fs
)
?
16
:
fs
,
format
.
getBold
()
,
format
.
getItalic
(),
format
.
getUnderline
(),
format
.
getStrikeout
());
var
width_padding
=
3
;
// 4 * 72 / 96
var
tm
=
stringRendere
r
.
measureString
(
sStyleName
);
var
tm
=
s
r
.
measureString
(
sStyleName
);
// Текст будем рисовать по центру (в Excel чуть по другому реализовано, у них постоянный отступ снизу)
var
textY
=
0.5
*
(
this
.
styleThumbnailHeightPt
-
tm
.
height
);
oGraphics
.
setFont
(
oFont
);
oGraphics
.
setFillStyle
(
oFontColor
);
oGraphics
.
fillText
(
sStyleName
,
width_padding
,
textY
+
tm
.
baseline
);
}
};
/** @constructor */
...
...
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