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
09211907
Commit
09211907
authored
Nov 15, 2016
by
Alexander.Trofimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug 33415
add flag to show/hide comments in workbook view
parent
d4729a1d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
99 deletions
+99
-99
cell/api.js
cell/api.js
+4
-7
cell/model/CellComment.js
cell/model/CellComment.js
+80
-87
cell/view/WorkbookView.js
cell/view/WorkbookView.js
+15
-5
No files found.
cell/api.js
View file @
09211907
...
...
@@ -2361,14 +2361,11 @@ var editor;
return
this
.
wb
.
cellCommentator
.
getDocumentComments
();
};
spreadsheet_api
.
prototype
.
asc_showComments
=
function
()
{
var
ws
=
this
.
wb
.
getWorksheet
();
return
ws
.
cellCommentator
.
showComments
();
spreadsheet_api
.
prototype
.
asc_showComments
=
function
()
{
this
.
wb
.
showComments
(
true
);
};
spreadsheet_api
.
prototype
.
asc_hideComments
=
function
()
{
var
ws
=
this
.
wb
.
getWorksheet
();
return
ws
.
cellCommentator
.
hideComments
();
spreadsheet_api
.
prototype
.
asc_hideComments
=
function
()
{
this
.
wb
.
showComments
(
false
);
};
// Shapes
...
...
cell/model/CellComment.js
View file @
09211907
...
...
@@ -405,7 +405,6 @@ function CCellCommentator(currentSheet) {
this
.
drawingCtx
=
currentSheet
.
drawingCtx
;
// Drawing settings
this
.
bShow
=
true
;
this
.
commentIconColor
=
new
AscCommon
.
CColor
(
255
,
144
,
0
);
this
.
commentFillColor
=
new
AscCommon
.
CColor
(
255
,
255
,
0
);
this
.
commentPadding
=
4
;
// px
...
...
@@ -521,37 +520,39 @@ CCellCommentator.prototype.getCommentsXY = function(x, y) {
return
(
findCol
&&
findRow
)
?
this
.
getComments
(
findCol
.
col
,
findRow
.
row
)
:
[];
};
CCellCommentator
.
prototype
.
drawCommentCells
=
function
()
{
CCellCommentator
.
prototype
.
drawCommentCells
=
function
()
{
if
(
this
.
isViewerMode
()
||
!
this
.
bShow
)
return
;
if
(
this
.
isViewerMode
()
||
this
.
model
.
workbook
.
handlers
.
trigger
(
'
hiddenComments
'
))
{
return
;
}
this
.
drawingCtx
.
setFillStyle
(
this
.
commentIconColor
);
var
commentCell
,
mergedRange
,
nCol
,
nRow
,
x
,
y
,
metrics
;
var
aComments
=
this
.
model
.
aComments
;
for
(
var
i
=
0
;
i
<
aComments
.
length
;
++
i
)
{
commentCell
=
aComments
[
i
];
if
(
commentCell
.
asc_getDocumentFlag
()
||
commentCell
.
asc_getHiddenFlag
()
||
commentCell
.
asc_getSolved
())
continue
;
mergedRange
=
this
.
model
.
getMergedByCell
(
commentCell
.
nRow
,
commentCell
.
nCol
);
nCol
=
mergedRange
?
mergedRange
.
c2
:
commentCell
.
nCol
;
nRow
=
mergedRange
?
mergedRange
.
r1
:
commentCell
.
nRow
;
if
(
metrics
=
this
.
worksheet
.
getCellMetrics
(
nCol
,
nRow
))
{
if
(
0
===
metrics
.
width
||
0
===
metrics
.
height
)
{
continue
;
}
x
=
metrics
.
left
+
metrics
.
width
;
y
=
metrics
.
top
;
this
.
drawingCtx
.
beginPath
();
this
.
drawingCtx
.
moveTo
(
x
-
this
.
pxToPt
(
7
),
y
);
this
.
drawingCtx
.
lineTo
(
x
-
this
.
pxToPt
(
1
),
y
);
this
.
drawingCtx
.
lineTo
(
x
-
this
.
pxToPt
(
1
),
y
+
this
.
pxToPt
(
6
));
this
.
drawingCtx
.
fill
();
this
.
drawingCtx
.
setFillStyle
(
this
.
commentIconColor
);
var
commentCell
,
mergedRange
,
nCol
,
nRow
,
x
,
y
,
metrics
;
var
aComments
=
this
.
model
.
aComments
;
for
(
var
i
=
0
;
i
<
aComments
.
length
;
++
i
)
{
commentCell
=
aComments
[
i
];
if
(
commentCell
.
asc_getDocumentFlag
()
||
commentCell
.
asc_getHiddenFlag
()
||
commentCell
.
asc_getSolved
())
{
continue
;
}
mergedRange
=
this
.
model
.
getMergedByCell
(
commentCell
.
nRow
,
commentCell
.
nCol
);
nCol
=
mergedRange
?
mergedRange
.
c2
:
commentCell
.
nCol
;
nRow
=
mergedRange
?
mergedRange
.
r1
:
commentCell
.
nRow
;
if
(
metrics
=
this
.
worksheet
.
getCellMetrics
(
nCol
,
nRow
))
{
if
(
0
===
metrics
.
width
||
0
===
metrics
.
height
)
{
continue
;
}
x
=
metrics
.
left
+
metrics
.
width
;
y
=
metrics
.
top
;
this
.
drawingCtx
.
beginPath
();
this
.
drawingCtx
.
moveTo
(
x
-
this
.
pxToPt
(
7
),
y
);
this
.
drawingCtx
.
lineTo
(
x
-
this
.
pxToPt
(
1
),
y
);
this
.
drawingCtx
.
lineTo
(
x
-
this
.
pxToPt
(
1
),
y
+
this
.
pxToPt
(
6
));
this
.
drawingCtx
.
fill
();
}
}
}
};
};
CCellCommentator
.
prototype
.
getTextMetrics
=
function
(
text
,
units
)
{
var
metrics
=
{
width
:
0
,
height
:
0
};
...
...
@@ -977,20 +978,6 @@ CCellCommentator.prototype.ascCvtRatio = function(fromUnits, toUnits) {
return
Asc
.
getCvtRatio
(
fromUnits
,
toUnits
,
this
.
overlayCtx
.
getPPIX
());
};
// Show/Hide
CCellCommentator
.
prototype
.
showComments
=
function
()
{
if
(
!
this
.
bShow
)
{
this
.
bShow
=
true
;
this
.
drawCommentCells
();
}
};
CCellCommentator
.
prototype
.
hideComments
=
function
()
{
this
.
bShow
=
false
;
this
.
drawCommentCells
();
this
.
model
.
workbook
.
handlers
.
trigger
(
"
asc_onHideComment
"
);
};
// Main
CCellCommentator
.
prototype
.
showComment
=
function
(
id
,
bNew
)
{
...
...
@@ -1162,62 +1149,68 @@ CCellCommentator.prototype.removeComment = function(id, bNoEvent, bNoAscLock, bN
// Extra functions
CCellCommentator
.
prototype
.
getComments
=
function
(
col
,
row
)
{
CCellCommentator
.
prototype
.
getComments
=
function
(
col
,
row
)
{
// Array of root items
var
comments
=
[];
var
_col
=
col
,
_row
=
row
,
mergedRange
=
null
;
var
aComments
=
this
.
model
.
aComments
;
var
length
=
aComments
.
length
;
// Array of root items
var
comments
=
[];
var
_col
=
col
,
_row
=
row
,
mergedRange
=
null
;
var
aComments
=
this
.
model
.
aComments
;
var
length
=
aComments
.
length
;
if
(
!
this
.
bShow
)
return
comments
;
if
(
this
.
model
.
workbook
.
handlers
.
trigger
(
'
hiddenComments
'
))
{
return
comments
;
}
if
(
0
<
length
)
{
if
(
null
==
_col
||
null
==
_row
)
{
var
activeCell
=
this
.
model
.
selectionRange
.
activeCell
;
_col
=
activeCell
.
col
;
_row
=
activeCell
.
row
;
}
else
mergedRange
=
this
.
model
.
getMergedByCell
(
row
,
col
);
if
(
0
<
length
)
{
if
(
null
==
_col
||
null
==
_row
)
{
var
activeCell
=
this
.
model
.
selectionRange
.
activeCell
;
_col
=
activeCell
.
col
;
_row
=
activeCell
.
row
;
}
else
{
mergedRange
=
this
.
model
.
getMergedByCell
(
row
,
col
);
}
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
var
commentCell
=
aComments
[
i
];
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
var
commentCell
=
aComments
[
i
];
if
(
!
commentCell
.
asc_getDocumentFlag
()
/*&& !commentCell.asc_getSolved()*/
&&
!
commentCell
.
asc_getHiddenFlag
()
&&
(
commentCell
.
nLevel
==
0
)
)
{
if
(
!
mergedRange
)
{
if
(
(
_col
==
commentCell
.
nCol
)
&&
(
_row
==
commentCell
.
nRow
)
)
comments
.
push
(
commentCell
);
}
else
{
if
(
mergedRange
.
contains
(
commentCell
.
nCol
,
commentCell
.
nRow
))
comments
.
push
(
commentCell
);
if
(
!
commentCell
.
asc_getDocumentFlag
()
/*&& !commentCell.asc_getSolved()*/
&&
!
commentCell
.
asc_getHiddenFlag
()
&&
(
commentCell
.
nLevel
==
0
))
{
if
(
!
mergedRange
)
{
if
((
_col
==
commentCell
.
nCol
)
&&
(
_row
==
commentCell
.
nRow
))
{
comments
.
push
(
commentCell
);
}
}
else
{
if
(
mergedRange
.
contains
(
commentCell
.
nCol
,
commentCell
.
nRow
))
{
comments
.
push
(
commentCell
);
}
}
}
}
}
}
return
comments
;
};
return
comments
;
};
CCellCommentator
.
prototype
.
getRangeComments
=
function
(
range
)
{
var
oComments
=
{};
if
(
!
this
.
bShow
)
return
null
;
CCellCommentator
.
prototype
.
getRangeComments
=
function
(
range
)
{
var
oComments
=
{};
if
(
this
.
model
.
workbook
.
handlers
.
trigger
(
'
hiddenComments
'
))
{
return
null
;
}
var
aComments
=
this
.
model
.
aComments
;
var
i
,
length
,
comment
,
bEmpty
=
true
;
for
(
i
=
0
,
length
=
aComments
.
length
;
i
<
length
;
++
i
)
{
comment
=
aComments
[
i
];
if
(
range
.
contains
(
comment
.
nCol
,
comment
.
nRow
))
{
bEmpty
=
false
;
if
(
!
oComments
.
hasOwnProperty
(
comment
.
nRow
))
oComments
[
comment
.
nRow
]
=
[];
oComments
[
comment
.
nRow
].
push
(
comment
);
var
aComments
=
this
.
model
.
aComments
;
var
i
,
length
,
comment
,
bEmpty
=
true
;
for
(
i
=
0
,
length
=
aComments
.
length
;
i
<
length
;
++
i
)
{
comment
=
aComments
[
i
];
if
(
range
.
contains
(
comment
.
nCol
,
comment
.
nRow
))
{
bEmpty
=
false
;
if
(
!
oComments
.
hasOwnProperty
(
comment
.
nRow
))
{
oComments
[
comment
.
nRow
]
=
[];
}
oComments
[
comment
.
nRow
].
push
(
comment
);
}
}
}
return
bEmpty
?
null
:
oComments
;
};
return
bEmpty
?
null
:
oComments
;
};
CCellCommentator
.
prototype
.
getDocumentComments
=
function
()
{
...
...
cell/view/WorkbookView.js
View file @
09211907
...
...
@@ -174,6 +174,8 @@
this
.
isCellEditMode
=
false
;
this
.
isShowComments
=
true
;
this
.
formulasList
=
[];
// Список всех формул
this
.
lastFormulaPos
=
-
1
;
// Последняя позиция формулы
this
.
lastFormulaNameLength
=
''
;
// Последний кусок формулы
...
...
@@ -789,14 +791,17 @@
this
.
handlers
.
add
(
"
asc_onLockDefNameManager
"
,
function
(
reason
)
{
self
.
defNameAllowCreate
=
!
(
reason
==
Asc
.
c_oAscDefinedNameReason
.
LockDefNameManager
);
});
this
.
handlers
.
add
(
'
addComment
'
,
function
(
id
,
data
)
{
this
.
handlers
.
add
(
'
addComment
'
,
function
(
id
,
data
)
{
self
.
_onWSSelectionChanged
();
self
.
handlers
.
trigger
(
'
asc_onAddComment
'
,
id
,
data
);
});
this
.
handlers
.
add
(
'
removeComment
'
,
function
(
id
)
{
this
.
handlers
.
add
(
'
removeComment
'
,
function
(
id
)
{
self
.
_onWSSelectionChanged
();
self
.
handlers
.
trigger
(
'
asc_onRemoveComment
'
,
id
);
});
this
.
handlers
.
add
(
'
hiddenComments
'
,
function
()
{
return
!
self
.
isShowComments
;
});
this
.
cellCommentator
=
new
AscCommonExcel
.
CCellCommentator
({
model
:
new
WorkbookCommentsModel
(
this
.
handlers
,
this
.
model
.
aComments
),
...
...
@@ -2500,12 +2505,18 @@
this
.
isDocumentPlaceChangedEnabled
=
val
;
};
WorkbookView
.
prototype
.
showComments
=
function
(
val
)
{
if
(
this
.
isShowComments
!==
val
)
{
this
.
isShowComments
=
val
;
this
.
drawWS
();
}
};
/*
* @param {c_oAscRenderingModeType} mode Режим отрисовки
* @param {Boolean} isInit инициализация или нет
*/
WorkbookView
.
prototype
.
setFontRenderingMode
=
function
(
mode
,
isInit
)
{
var
ws
;
if
(
mode
!==
this
.
fontRenderingMode
)
{
this
.
fontRenderingMode
=
mode
;
if
(
c_oAscFontRenderingModeType
.
noHinting
===
mode
)
{
...
...
@@ -2517,8 +2528,7 @@
}
if
(
!
isInit
)
{
ws
=
this
.
getWorksheet
();
ws
.
draw
();
this
.
drawWS
();
this
.
cellEditor
.
setFontRenderingMode
(
mode
);
}
}
...
...
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