Commit 17be8c5d authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Переработал работу с гиперссылками:

1) Убрал _updateHyperlinksCache
2) Переработал asc_CHyperlink (теперь там хранится объект Hyperlink из модели
3) В следствии убрал onStartTriggerAction и onEndTriggerAction (которые нужны были для обновления гиперссылок), а также флаги nActionNested и bUpdateHyperlinks
4) Поправил в Hyperlink выставление Location (теперь при выставлении сразу генерируются Sheet и Range)
5) Поправил получение Location (можно выставить Sheet и Range, а потом получить Location)
6) Убрал лишние методы из asc_CHyperlink - asc_getHyperlinkRange, asc_setHyperlinkRange, asc_clone, asc_clear

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@50186 954022d7-b5bf-4e40-9824-e11837661b57
parent 808b8b2a
...@@ -400,7 +400,6 @@ ...@@ -400,7 +400,6 @@
var api = new Asc.spreadsheet_api("wb-widget", "cv1"); var api = new Asc.spreadsheet_api("wb-widget", "cv1");
//api.asc_setViewerMode(true); //api.asc_setViewerMode(true);
var oTmpHyperlinkObj = null;
var aDialogNames = []; var aDialogNames = [];
var bIsUpdateChartProperties = false; var bIsUpdateChartProperties = false;
var bIsReopenDialog = false; var bIsReopenDialog = false;
...@@ -867,7 +866,7 @@ ...@@ -867,7 +866,7 @@
case "td_add_hyperlink": case "td_add_hyperlink":
{ {
var oCellInfo = api.asc_getCellInfo(); var oCellInfo = api.asc_getCellInfo();
oTmpHyperlinkObj = oCellInfo.asc_getHyperlink(); var oTmpHyperlinkObj = oCellInfo.asc_getHyperlink();
var oHyperText = $("#addHyperlink_text"); var oHyperText = $("#addHyperlink_text");
var oSelect = $("#addHyperlink_she"); var oSelect = $("#addHyperlink_she");
...@@ -879,17 +878,18 @@ ...@@ -879,17 +878,18 @@
toggleHyperlinkDialog(true); toggleHyperlinkDialog(true);
$("#addHyperlink_url").val(""); $("#addHyperlink_url").val("");
$("#addHyperlink_ran").val("A1"); $("#addHyperlink_ran").val("A1");
} } else {
else {
oHyperText.val(oTmpHyperlinkObj.asc_getText()); oHyperText.val(oTmpHyperlinkObj.asc_getText());
if (c_oAscHyperlinkType.WebLink === oTmpHyperlinkObj.asc_getType()) { switch (oTmpHyperlinkObj.asc_getType()) {
toggleHyperlinkDialog(true); case c_oAscHyperlinkType.WebLink:
$("#addHyperlink_url").val(oTmpHyperlinkObj.asc_getHyperlinkUrl()); toggleHyperlinkDialog(true);
} $("#addHyperlink_url").val(oTmpHyperlinkObj.asc_getHyperlinkUrl());
else if (c_oAscHyperlinkType.RangeLink === oTmpHyperlinkObj.asc_getType()) { break;
toggleHyperlinkDialog(false); case c_oAscHyperlinkType.RangeLink:
oSelect.val(oTmpHyperlinkObj.asc_getSheet()); toggleHyperlinkDialog(false);
$("#addHyperlink_ran").val(oTmpHyperlinkObj.asc_getRange()); oSelect.val(oTmpHyperlinkObj.asc_getSheet());
$("#addHyperlink_ran").val(oTmpHyperlinkObj.asc_getRange());
break;
} }
} }
api.asc_enableKeyEvents(false); api.asc_enableKeyEvents(false);
...@@ -897,7 +897,7 @@ ...@@ -897,7 +897,7 @@
break; break;
} }
case "td_auto_filter":{ case "td_auto_filter":{
api.asc_addAutoFilter() api.asc_addAutoFilter();
break; break;
} }
case "td_auto_filter_local":{ case "td_auto_filter_local":{
...@@ -1542,6 +1542,7 @@ ...@@ -1542,6 +1542,7 @@
var sUrl = $("#addHyperlink_url").val(); var sUrl = $("#addHyperlink_url").val();
var sSheet = $("#addHyperlink_she").val(); var sSheet = $("#addHyperlink_she").val();
var sRange = $("#addHyperlink_ran").val(); var sRange = $("#addHyperlink_ran").val();
var oTmpHyperlinkObj = null;
var bHyp = false; var bHyp = false;
if( document.getElementById('selectTypeLink').selectedIndex == 0) if( document.getElementById('selectTypeLink').selectedIndex == 0)
...@@ -1555,23 +1556,17 @@ ...@@ -1555,23 +1556,17 @@
$("#addHyperlink_err").text( "Error: Empty url" ) $("#addHyperlink_err").text( "Error: Empty url" )
;$("#addHyperlink_err").hide(); ;$("#addHyperlink_err").hide();
$("#addHyperlink_err").show("slow"); $("#addHyperlink_err").show("slow");
} } else {
else
{
$("#addHyperlink_err").hide(); $("#addHyperlink_err").hide();
$("#dialogAddHyperlink").dialog("close"); $("#dialogAddHyperlink").dialog("close");
oTmpHyperlinkObj.asc_clear(); oTmpHyperlinkObj = new Asc.asc_CHyperlink();
oTmpHyperlinkObj.asc_setText (sText); oTmpHyperlinkObj.asc_setText (sText);
if( true == bHyp ) if (true == bHyp) {
{ if (0 != sUrl.indexOf("http://"))
oTmpHyperlinkObj.asc_setType (c_oAscHyperlinkType.WebLink);
if( 0 != sUrl.indexOf("http://") )
sUrl = "http://" + sUrl; sUrl = "http://" + sUrl;
oTmpHyperlinkObj.asc_setHyperlinkUrl(sUrl); oTmpHyperlinkObj.asc_setHyperlinkUrl(sUrl);
} } else {
else {
oTmpHyperlinkObj.asc_setType (c_oAscHyperlinkType.RangeLink);
oTmpHyperlinkObj.asc_setSheet(sSheet); oTmpHyperlinkObj.asc_setSheet(sSheet);
oTmpHyperlinkObj.asc_setRange(sRange); oTmpHyperlinkObj.asc_setRange(sRange);
} }
......
...@@ -365,23 +365,14 @@ CHistory.prototype = ...@@ -365,23 +365,14 @@ CHistory.prototype =
var oCurWorksheet = this.workbook.getWorksheet(this.workbook.getActive()); var oCurWorksheet = this.workbook.getWorksheet(this.workbook.getActive());
if(null != Point.nLastSheetId && Point.nLastSheetId != oCurWorksheet.getId()) if(null != Point.nLastSheetId && Point.nLastSheetId != oCurWorksheet.getId())
this.workbook.handlers.trigger("showWorksheet", Point.nLastSheetId); this.workbook.handlers.trigger("showWorksheet", Point.nLastSheetId);
var aStartTriggerAction = new Object();
// Откатываем все действия в обратном порядке (относительно их выполенения) // Откатываем все действия в обратном порядке (относительно их выполенения)
for ( var Index = Point.Items.length - 1; Index >= 0; Index-- ) for ( var Index = Point.Items.length - 1; Index >= 0; Index-- )
{ {
var Item = Point.Items[Index]; var Item = Point.Items[Index];
if(null != Item.SheetId && null == aStartTriggerAction[Item.SheetId])
{
var ws = this.workbook.getWorksheetById(Item.SheetId);
ws.onStartTriggerAction();
aStartTriggerAction[Item.SheetId] = ws;
}
Item.Class.Undo( Item.Type, Item.Data, Item.SheetId ); Item.Class.Undo( Item.Type, Item.Data, Item.SheetId );
if (g_oUndoRedoWorksheet === Item.Class && historyitem_Worksheet_SetViewSettings === Item.Type) if (g_oUndoRedoWorksheet === Item.Class && historyitem_Worksheet_SetViewSettings === Item.Type)
isReInit = true; isReInit = true;
} }
for(var i in aStartTriggerAction)
aStartTriggerAction[i].onEndTriggerAction();
var oSelectRange = null; var oSelectRange = null;
if(null != Point.SelectRange) if(null != Point.SelectRange)
oSelectRange = Point.SelectRange; oSelectRange = Point.SelectRange;
...@@ -434,12 +425,6 @@ CHistory.prototype = ...@@ -434,12 +425,6 @@ CHistory.prototype =
this.Add(Class, Type, sheetid, range, Data, LocalChange); this.Add(Class, Type, sheetid, range, Data, LocalChange);
if(bNeedOff) if(bNeedOff)
this.TurnOff(); this.TurnOff();
if(null != sheetid && null == oRedoObjectParam.aStartTriggerAction[sheetid])
{
var ws = this.workbook.getWorksheetById(sheetid);
ws.onStartTriggerAction();
oRedoObjectParam.aStartTriggerAction[sheetid] = ws;
}
Class.Redo( Type, Data, sheetid ); Class.Redo( Type, Data, sheetid );
if (g_oUndoRedoWorksheet === Class && historyitem_Worksheet_SetViewSettings === Type) if (g_oUndoRedoWorksheet === Class && historyitem_Worksheet_SetViewSettings === Type)
oRedoObjectParam.bIsReInit = true; oRedoObjectParam.bIsReInit = true;
...@@ -450,12 +435,6 @@ CHistory.prototype = ...@@ -450,12 +435,6 @@ CHistory.prototype =
for ( var Index = 0; Index < Point.Items.length; Index++ ) for ( var Index = 0; Index < Point.Items.length; Index++ )
{ {
var Item = Point.Items[Index]; var Item = Point.Items[Index];
if(null != Item.SheetId && null == oRedoObjectParam.aStartTriggerAction[Item.SheetId])
{
var ws = this.workbook.getWorksheetById(Item.SheetId);
ws.onStartTriggerAction();
oRedoObjectParam.aStartTriggerAction[Item.SheetId] = ws;
}
Item.Class.Redo( Item.Type, Item.Data, Item.SheetId ); Item.Class.Redo( Item.Type, Item.Data, Item.SheetId );
if (g_oUndoRedoWorksheet === Item.Class && historyitem_Worksheet_SetViewSettings === Item.Type) if (g_oUndoRedoWorksheet === Item.Class && historyitem_Worksheet_SetViewSettings === Item.Type)
oRedoObjectParam.bIsReInit = true; oRedoObjectParam.bIsReInit = true;
...@@ -472,8 +451,6 @@ CHistory.prototype = ...@@ -472,8 +451,6 @@ CHistory.prototype =
} }
if(null == Point) if(null == Point)
return; return;
for(var i in oRedoObjectParam.aStartTriggerAction)
oRedoObjectParam.aStartTriggerAction[i].onEndTriggerAction();
for(var i in Point.Triggers) for(var i in Point.Triggers)
this.workbook.handlers.trigger.apply(this.workbook.handlers, Point.Triggers[i]); this.workbook.handlers.trigger.apply(this.workbook.handlers, Point.Triggers[i]);
var oSelectRange = null; var oSelectRange = null;
......
...@@ -2597,25 +2597,20 @@ function BinaryWorksheetsTableWriter(memory, wb, oSharedStrings, oDrawings, aDxf ...@@ -2597,25 +2597,20 @@ function BinaryWorksheetsTableWriter(memory, wb, oSharedStrings, oDrawings, aDxf
this.bs.WriteItem(c_oSerWorksheetsTypes.Hyperlink, function(){oThis.WriteHyperlink(elem.data);}); this.bs.WriteItem(c_oSerWorksheetsTypes.Hyperlink, function(){oThis.WriteHyperlink(elem.data);});
} }
}; };
this.WriteHyperlink = function(oHyperlink) this.WriteHyperlink = function (oHyperlink) {
{ if (null != oHyperlink.Ref) {
if(null != oHyperlink.Ref)
{
this.memory.WriteByte(c_oSerHyperlinkTypes.Ref); this.memory.WriteByte(c_oSerHyperlinkTypes.Ref);
this.memory.WriteString2(oHyperlink.Ref.getName()); this.memory.WriteString2(oHyperlink.Ref.getName());
} }
if(null != oHyperlink.Hyperlink) if (null != oHyperlink.Hyperlink) {
{
this.memory.WriteByte(c_oSerHyperlinkTypes.Hyperlink); this.memory.WriteByte(c_oSerHyperlinkTypes.Hyperlink);
this.memory.WriteString2(oHyperlink.Hyperlink); this.memory.WriteString2(oHyperlink.Hyperlink);
} }
if(null != oHyperlink.Location) if (null !== oHyperlink.getLocation()) {
{
this.memory.WriteByte(c_oSerHyperlinkTypes.Location); this.memory.WriteByte(c_oSerHyperlinkTypes.Location);
this.memory.WriteString2(oHyperlink.Location); this.memory.WriteString2(oHyperlink.getLocation());
} }
if(null != oHyperlink.Tooltip) if (null != oHyperlink.Tooltip) {
{
this.memory.WriteByte(c_oSerHyperlinkTypes.Tooltip); this.memory.WriteByte(c_oSerHyperlinkTypes.Tooltip);
this.memory.WriteString2(oHyperlink.Tooltip); this.memory.WriteString2(oHyperlink.Tooltip);
} }
...@@ -5340,7 +5335,7 @@ function Binary_WorksheetTableReader(stream, wb, aSharedStrings, aCellXfs, Dxfs, ...@@ -5340,7 +5335,7 @@ function Binary_WorksheetTableReader(stream, wb, aSharedStrings, aCellXfs, Dxfs,
else if ( c_oSerHyperlinkTypes.Hyperlink == type ) else if ( c_oSerHyperlinkTypes.Hyperlink == type )
oHyperlink.Hyperlink = this.stream.GetString2LE(length); oHyperlink.Hyperlink = this.stream.GetString2LE(length);
else if ( c_oSerHyperlinkTypes.Location == type ) else if ( c_oSerHyperlinkTypes.Location == type )
oHyperlink.Location = this.stream.GetString2LE(length); oHyperlink.setLocation(this.stream.GetString2LE(length));
else if ( c_oSerHyperlinkTypes.Tooltip == type ) else if ( c_oSerHyperlinkTypes.Tooltip == type )
oHyperlink.Tooltip = this.stream.GetString2LE(length); oHyperlink.Tooltip = this.stream.GetString2LE(length);
else else
......
...@@ -2194,7 +2194,6 @@ function Woorksheet(wb, _index, bAddUserId, sId){ ...@@ -2194,7 +2194,6 @@ function Woorksheet(wb, _index, bAddUserId, sId){
//нужно добавлять в историю только когда обрезается с краев, потому что на undo будет произведена вставка и ячеек, а диапазон не расширится //нужно добавлять в историю только когда обрезается с краев, потому что на undo будет произведена вставка и ячеек, а диапазон не расширится
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_ChangeHyperlink, oThis.getId(), from, data); History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_ChangeHyperlink, oThis.getId(), from, data);
} }
oThis.addActionHyperlink(true);
} }
}); });
this.hyperlinkManager.setDependenceManager(this.mergeManager); this.hyperlinkManager.setDependenceManager(this.mergeManager);
...@@ -2203,9 +2202,6 @@ function Woorksheet(wb, _index, bAddUserId, sId){ ...@@ -2203,9 +2202,6 @@ function Woorksheet(wb, _index, bAddUserId, sId){
this.aConditionalFormatting = []; this.aConditionalFormatting = [];
this.sheetPr = null; this.sheetPr = null;
this.nActionNested = 0;
this.bUpdateHyperlinks = false;
this.nMaxRowId = 1; this.nMaxRowId = 1;
this.nMaxColId = 1; this.nMaxColId = 1;
}; };
...@@ -2438,25 +2434,6 @@ Woorksheet.prototype.initPostOpen = function(){ ...@@ -2438,25 +2434,6 @@ Woorksheet.prototype.initPostOpen = function(){
this.sheetViews[0] = new asc.asc_CSheetViewSettings(); this.sheetViews[0] = new asc.asc_CSheetViewSettings();
} }
}; };
Woorksheet.prototype.onStartTriggerAction=function(){
//начало действия, в конце которого могуть быть вызваны trigger(пока только hyperlink)
if(0 == this.nActionNested)
this.bUpdateHyperlinks = false;
this.nActionNested++;
};
Woorksheet.prototype.onEndTriggerAction=function(){
if(this.nActionNested > 0)
this.nActionNested--;
if(0 == this.nActionNested)
{
if(true == this.bUpdateHyperlinks)
this.workbook.handlers.trigger("updateHyperlinksCache", this.Id);
this.bUpdateHyperlinks = false;
}
};
Woorksheet.prototype.addActionHyperlink=function(bVal){
this.bUpdateHyperlinks = bVal;
}
Woorksheet.prototype._forEachCell=function(fAction){ Woorksheet.prototype._forEachCell=function(fAction){
for(var rowInd in this.aGCells){ for(var rowInd in this.aGCells){
var row = this.aGCells[rowInd]; var row = this.aGCells[rowInd];
...@@ -3628,7 +3605,6 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo){ ...@@ -3628,7 +3605,6 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo){
elem.data.Ref.setOffset(offset); elem.data.Ref.setOffset(offset);
this.hyperlinkManager.add(elem.bbox, elem.data); this.hyperlinkManager.add(elem.bbox, elem.data);
} }
this.addActionHyperlink(true);
} }
//расширяем границы //расширяем границы
if(oBBoxFrom.r2 > this.nRowsCount) if(oBBoxFrom.r2 > this.nRowsCount)
...@@ -4015,8 +3991,9 @@ Woorksheet.prototype.getAllCol = function(){ ...@@ -4015,8 +3991,9 @@ Woorksheet.prototype.getAllCol = function(){
return this.oAllCol; return this.oAllCol;
} }
Woorksheet.prototype.getHyperlinkByCell = function(row, col){ Woorksheet.prototype.getHyperlinkByCell = function(row, col){
return this.hyperlinkManager.getByCell(row, col); var oHyperlink = this.hyperlinkManager.getByCell(row, col);
} return oHyperlink ? oHyperlink.data : null;
};
Woorksheet.prototype.getMergedByCell = function(row, col){ Woorksheet.prototype.getMergedByCell = function(row, col){
return this.mergeManager.getByCell(row, col); return this.mergeManager.getByCell(row, col);
} }
...@@ -7233,7 +7210,6 @@ Range.prototype.setHyperlink=function(val, bWithoutStyle){ ...@@ -7233,7 +7210,6 @@ Range.prototype.setHyperlink=function(val, bWithoutStyle){
this.setFont(oHyperlinkFont); this.setFont(oHyperlinkFont);
} }
this.worksheet.hyperlinkManager.add(val.Ref.getBBox0(), val); this.worksheet.hyperlinkManager.add(val.Ref.getBBox0(), val);
this.worksheet.addActionHyperlink(true);
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_SetHyperlink, this.worksheet.getId(), this.bbox.clone(), val.clone()); History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_SetHyperlink, this.worksheet.getId(), this.bbox.clone(), val.clone());
History.EndTransaction(); History.EndTransaction();
} }
...@@ -7755,7 +7731,6 @@ Range.prototype._sortByArray=function(oBBox, aSortData, bUndo){ ...@@ -7755,7 +7731,6 @@ Range.prototype._sortByArray=function(oBBox, aSortData, bUndo){
var hyp = aSortedHyperlinks[i]; var hyp = aSortedHyperlinks[i];
this.worksheet.hyperlinkManager.add(hyp.Ref.getBBox0(), hyp); this.worksheet.hyperlinkManager.add(hyp.Ref.getBBox0(), hyp);
} }
this.worksheet.addActionHyperlink(true);
} }
}; };
Range.prototype.promote=function(bCtrl, bVertical, nIndex){ Range.prototype.promote=function(bCtrl, bVertical, nIndex){
......
...@@ -1791,8 +1791,7 @@ StyleManager.prototype = ...@@ -1791,8 +1791,7 @@ StyleManager.prototype =
} }
}; };
/** @constructor */ /** @constructor */
function Hyperlink() function Hyperlink () {
{
this.Properties = { this.Properties = {
Ref: 0, Ref: 0,
Location: 1, Location: 1,
...@@ -1800,63 +1799,98 @@ function Hyperlink() ...@@ -1800,63 +1799,98 @@ function Hyperlink()
Tooltip: 3 Tooltip: 3
}; };
this.Ref = null; this.Ref = null;
this.Location = null;
this.Hyperlink = null; this.Hyperlink = null;
this.Tooltip = null; this.Tooltip = null;
// Составные части Location
this.Location = null;
this.LocationSheet = null;
this.LocationRange = null;
this.bUpdateLocation = false;
this.bVisited = false; this.bVisited = false;
}; }
Hyperlink.prototype = Hyperlink.prototype = {
{ clone : function () {
clone : function()
{
var oNewHyp = new Hyperlink(); var oNewHyp = new Hyperlink();
if(null != this.Ref) if (null !== this.Ref)
oNewHyp.Ref = this.Ref.clone(); oNewHyp.Ref = this.Ref.clone();
if(null != this.Location) if (null !== this.getLocation())
oNewHyp.Location = this.Location; oNewHyp.Location = this.getLocation();
if(null != this.Hyperlink) if (null !== this.LocationSheet)
oNewHyp.LocationSheet = this.LocationSheet;
if (null !== this.LocationRange)
oNewHyp.LocationRange = this.LocationRange;
if (null !== this.Hyperlink)
oNewHyp.Hyperlink = this.Hyperlink; oNewHyp.Hyperlink = this.Hyperlink;
if(null != this.Tooltip) if (null !== this.Tooltip)
oNewHyp.Tooltip = this.Tooltip; oNewHyp.Tooltip = this.Tooltip;
return oNewHyp; return oNewHyp;
}, },
isEqual : function(obj) isEqual : function (obj) {
{ var bRes = (this.getLocation() == obj.getLocation() && this.Hyperlink == obj.Hyperlink && this.Tooltip == obj.Tooltip);
var bRes = (this.Location == obj.Location && this.Hyperlink == obj.Hyperlink && this.Tooltip == obj.Tooltip); if (bRes) {
if(bRes)
{
var oBBoxRef = this.Ref.getBBox0(); var oBBoxRef = this.Ref.getBBox0();
var oBBoxObj = obj.Ref.getBBox0(); var oBBoxObj = obj.Ref.getBBox0();
bRes = (oBBoxRef.r1 == oBBoxObj.r1 && oBBoxRef.c1 == oBBoxObj.c1 && oBBoxRef.r2 == oBBoxObj.r2 && oBBoxRef.c2 == oBBoxObj.c2); bRes = (oBBoxRef.r1 == oBBoxObj.r1 && oBBoxRef.c1 == oBBoxObj.c1 && oBBoxRef.r2 == oBBoxObj.r2 && oBBoxRef.c2 == oBBoxObj.c2);
} }
return bRes; return bRes;
}, },
isValid : function() isValid : function () {
{ return null != this.Ref && (null != this.getLocation() || null != this.Hyperlink);
return null != this.Ref && (null != this.Location || null != this.Hyperlink);
}, },
setVisited : function(bVisited) setLocationSheet : function (LocationSheet) {
{ this.LocationSheet = LocationSheet;
this.bUpdateLocation = true;
},
setLocationRange : function (LocationRange) {
this.LocationRange = LocationRange;
this.bUpdateLocation = true;
},
setLocation : function (Location) {
this.bUpdateLocation = false;
this.Location = Location;
this.LocationSheet = this.LocationRange = null;
if (null != this.Location) {
var result = parserHelp.parse3DRef(this.Location);
if (null !== result) {
this.LocationSheet = result.sheet;
this.LocationRange = result.range;
}
}
},
getLocation : function () {
if (this.bUpdateLocation)
this._updateLocation();
return this.Location;
},
_updateLocation : function () {
this.bUpdateLocation = false;
if (null === this.LocationSheet || null === this.LocationRange)
this.Location = null;
else {
this.Location = (false == rx_test_ws_name.test(this.LocationSheet)) ? "'" + this.LocationSheet + "'" : this.LocationSheet;
this.Location += "!" + this.LocationRange;
}
},
setVisited : function (bVisited) {
this.bVisited = bVisited; this.bVisited = bVisited;
this.Ref.cleanCache(); this.Ref.cleanCache();
}, },
getVisited : function(bVisited) getVisited : function () {
{
return this.bVisited; return this.bVisited;
}, },
getType : function() getHyperlinkType : function () {
{ return null !== this.Hyperlink ? c_oAscHyperlinkType.WebLink : c_oAscHyperlinkType.RangeLink;
},
getType : function () {
return UndoRedoDataTypes.Hyperlink; return UndoRedoDataTypes.Hyperlink;
}, },
getProperties : function() getProperties : function () {
{
return this.Properties; return this.Properties;
}, },
getProperty : function(nType) getProperty : function (nType) {
{ switch (nType) {
switch(nType)
{
case this.Properties.Ref: case this.Properties.Ref:
var sRes = this.Ref.worksheet.getName(); var sRes = this.Ref.worksheet.getName();
if(false == rx_test_ws_name.test(sRes)) if(false == rx_test_ws_name.test(sRes))
...@@ -1864,32 +1898,29 @@ Hyperlink.prototype = ...@@ -1864,32 +1898,29 @@ Hyperlink.prototype =
sRes += "!" + this.Ref.getName(); sRes += "!" + this.Ref.getName();
return sRes; return sRes;
break; break;
case this.Properties.Location: return this.Location;break; case this.Properties.Location: return this.getLocation();break;
case this.Properties.Hyperlink: return this.Hyperlink;break; case this.Properties.Hyperlink: return this.Hyperlink;break;
case this.Properties.Tooltip: return this.Tooltip;break; case this.Properties.Tooltip: return this.Tooltip;break;
} }
}, },
setProperty : function(nType, value) setProperty : function (nType, value) {
{ switch (nType) {
switch(nType)
{
case this.Properties.Ref: case this.Properties.Ref:
//todo обработать нули //todo обработать нули
var oRefParsed = parserHelp.parse3DRef(value); var oRefParsed = parserHelp.parse3DRef(value);
if (null !== oRefParsed) { if (null !== oRefParsed) {
// Получаем sheet по имени // Получаем sheet по имени
ws = window["Asc"]["editor"].wbModel.getWorksheetByName (oRefParsed.sheet); var ws = window["Asc"]["editor"].wbModel.getWorksheetByName (oRefParsed.sheet);
if (ws) if (ws)
this.Ref = ws.getRange2(oRefParsed.range); this.Ref = ws.getRange2(oRefParsed.range);
} }
break; break;
case this.Properties.Location: this.Location = value;break; case this.Properties.Location: this.setLocation(value);break;
case this.Properties.Hyperlink: this.Hyperlink = value;break; case this.Properties.Hyperlink: this.Hyperlink = value;break;
case this.Properties.Tooltip: this.Tooltip = value;break; case this.Properties.Tooltip: this.Tooltip = value;break;
} }
}, },
applyCollaborative : function(nSheetId, collaborativeEditing) applyCollaborative : function (nSheetId, collaborativeEditing) {
{
var bbox = this.Ref.getBBox0(); var bbox = this.Ref.getBBox0();
var OffsetFirst = {offsetCol:0, offsetRow:0}; var OffsetFirst = {offsetCol:0, offsetRow:0};
var OffsetLast = {offsetCol:0, offsetRow:0}; var OffsetLast = {offsetCol:0, offsetRow:0};
......
...@@ -1977,19 +1977,19 @@ ...@@ -1977,19 +1977,19 @@
} }
var hyperlink; var hyperlink;
if(cell) if(cell)
hyperlink = cell.getHyperlink() hyperlink = cell.getHyperlink();
for (res = [], i = 0; i < val.length; ++i) { for (res = [], i = 0; i < val.length; ++i) {
if(val[i] && val[i].format && val[i].format.skip) if(val[i] && val[i].format && val[i].format.skip)
continue; continue;
if(cell == undefined || (cell != undefined && (hyperlink == null || (hyperlink != null && hyperlink.Location != null)))) if(cell == undefined || (cell != undefined && (hyperlink == null || (hyperlink != null && hyperlink.getLocation() != null))))
span = doc.createElement("SPAN"); span = doc.createElement("SPAN");
else else
{ {
span = doc.createElement("A"); span = doc.createElement("A");
if(hyperlink.Hyperlink != null) if(hyperlink.Hyperlink != null)
span.href = hyperlink.Hyperlink; span.href = hyperlink.Hyperlink;
else if(hyperlink.Location != null) else if(hyperlink.getLocation() != null)
span.href = "#" + hyperlink.Location; span.href = "#" + hyperlink.getLocation();
if(hyperlink.Tooltip != null) if(hyperlink.Tooltip != null)
span.title = hyperlink.Tooltip; span.title = hyperlink.Tooltip;
} }
......
...@@ -482,65 +482,46 @@ ...@@ -482,65 +482,46 @@
}; };
// Гиперссылка // Гиперссылка
/** @constructor */
function asc_CHyperlink (obj) { function asc_CHyperlink (obj) {
if ( !(this instanceof asc_CHyperlink) ) { if (!(this instanceof asc_CHyperlink)) {
return new asc_CHyperlink(obj); return new asc_CHyperlink(obj);
} }
if (obj) { // Класс Hyperlink из модели
this.type = obj.type; this.hyperlinkModel = null != obj ? obj : new Hyperlink();
this.hyperlinkUrl = obj.hyperlinkUrl; // Используется только для выдачи наружу и выставлении обратно
this.tooltip = obj.tooltip; this.text = null;
this.location = obj.location;
this.sheet = obj.sheet;
this.range = obj.range;
this.hyperlinkRange = obj.hyperlinkRange;
this.text = obj.text;
this.col = obj.col;
this.row = obj.row;
}
else {
this.asc_clear();
}
return this; return this;
} }
asc_CHyperlink.prototype = { asc_CHyperlink.prototype = {
constructor: asc_CHyperlink, constructor: asc_CHyperlink,
asc_getType: function () { return this.type; }, asc_getType: function () { return this.hyperlinkModel.getHyperlinkType(); },
asc_getHyperlinkUrl: function () { return this.hyperlinkUrl; }, asc_getHyperlinkUrl: function () { return this.hyperlinkModel.Hyperlink; },
asc_getTooltip: function () { return this.tooltip; }, asc_getTooltip: function () { return this.hyperlinkModel.Tooltip; },
asc_getLocation: function () { return this.location; }, asc_getLocation: function () { return this.hyperlinkModel.getLocation(); },
asc_getSheet: function () { return this.sheet; }, asc_getSheet: function () { return this.hyperlinkModel.LocationSheet; },
asc_getRange: function () { return this.range; }, asc_getRange: function () { return this.hyperlinkModel.LocationRange; },
asc_getHyperlinkRange: function () { return this.hyperlinkRange; },
asc_getText: function () { return this.text; }, asc_getText: function () { return this.text; },
asc_getHyperlinkCol: function () {return this.col;},
asc_getHyperlinkRow: function () {return this.row;}, asc_setType: function (val) {
asc_setType: function (val) { this.type = val; }, // В принципе эта функция избыточна
asc_setHyperlinkUrl: function (val) { this.hyperlinkUrl = val; }, switch (val) {
asc_setTooltip: function (val) { this.tooltip = val; }, case c_oAscHyperlinkType.WebLink:
asc_setLocation: function (val) { this.location = val; }, this.hyperlinkModel.setLocation(null);
asc_setSheet: function (val) { this.sheet = val; }, break;
asc_setRange: function (val) { this.range = val; }, case c_oAscHyperlinkType.RangeLink:
asc_setHyperlinkRange: function (val) { this.hyperlinkRange = val; }, this.hyperlinkModel.Hyperlink = null;
asc_setText: function (val) { this.text = val; }, break;
asc_setHyperlinkCol: function (val) {this.col = val;}, }
asc_setHyperlinkRow: function (val) {this.row = val;},
asc_clear: function () {
this.type = null;
this.hyperlinkUrl = null;
this.tooltip = null;
this.location = null;
this.sheet = null;
this.range = null;
this.hyperlinkRange = null;
this.text = null;
}, },
asc_clone: function () { asc_setHyperlinkUrl: function (val) { this.hyperlinkModel.Hyperlink = val; },
return new asc_CHyperlink(this); asc_setTooltip: function (val) { this.hyperlinkModel.Tooltip = val; },
} asc_setLocation: function (val) { this.hyperlinkModel.setLocation(val); },
asc_setSheet: function (val) { this.hyperlinkModel.setLocationSheet(val); },
asc_setRange: function (val) { this.hyperlinkModel.setLocationRange(val); },
asc_setText: function (val) { this.text = val; }
}; };
function asc_CPageMargins (obj) { function asc_CPageMargins (obj) {
...@@ -756,7 +737,6 @@ ...@@ -756,7 +737,6 @@
} }
this.bIsOn = false; this.bIsOn = false;
this.aStartTriggerAction = {};
this.bIsReInit = false; this.bIsReInit = false;
} }
...@@ -1020,7 +1000,6 @@ ...@@ -1020,7 +1000,6 @@
prot["asc_getLocation"] = prot.asc_getLocation; prot["asc_getLocation"] = prot.asc_getLocation;
prot["asc_getSheet"] = prot.asc_getSheet; prot["asc_getSheet"] = prot.asc_getSheet;
prot["asc_getRange"] = prot.asc_getRange; prot["asc_getRange"] = prot.asc_getRange;
prot["asc_getHyperlinkRange"] = prot.asc_getHyperlinkRange;
prot["asc_getText"] = prot.asc_getText; prot["asc_getText"] = prot.asc_getText;
prot["asc_setType"] = prot.asc_setType; prot["asc_setType"] = prot.asc_setType;
prot["asc_setHyperlinkUrl"] = prot.asc_setHyperlinkUrl; prot["asc_setHyperlinkUrl"] = prot.asc_setHyperlinkUrl;
...@@ -1028,11 +1007,7 @@ ...@@ -1028,11 +1007,7 @@
prot["asc_setLocation"] = prot.asc_setLocation; prot["asc_setLocation"] = prot.asc_setLocation;
prot["asc_setSheet"] = prot.asc_setSheet; prot["asc_setSheet"] = prot.asc_setSheet;
prot["asc_setRange"] = prot.asc_setRange; prot["asc_setRange"] = prot.asc_setRange;
prot["asc_setHyperlinkRange"] = prot.asc_setHyperlinkRange;
prot["asc_setText"] = prot.asc_setText; prot["asc_setText"] = prot.asc_setText;
prot["asc_clear"] = prot.asc_clear;
prot["asc_clone"] = prot.asc_clone;
window["Asc"]["asc_CPageMargins"] = window["Asc"].asc_CPageMargins = asc_CPageMargins; window["Asc"]["asc_CPageMargins"] = window["Asc"].asc_CPageMargins = asc_CPageMargins;
prot = asc_CPageMargins.prototype; prot = asc_CPageMargins.prototype;
......
...@@ -238,9 +238,6 @@ ...@@ -238,9 +238,6 @@
this.model.handlers.add("deleteCell", function (wsId, val, range) { this.model.handlers.add("deleteCell", function (wsId, val, range) {
self.getWorksheetById(wsId).changeWorksheet("delCell", {val: val, range: range}); self.getWorksheetById(wsId).changeWorksheet("delCell", {val: val, range: range});
}); });
this.model.handlers.add("updateHyperlinksCache", function (wsId) {
self.getWorksheetById(wsId)._updateHyperlinksCache();
});
this.model.handlers.add("showWorksheet", function (wsId) { this.model.handlers.add("showWorksheet", function (wsId) {
self.showWorksheetById(wsId); self.showWorksheetById(wsId);
var ws = self.getWorksheetById(wsId); var ws = self.getWorksheetById(wsId);
...@@ -514,22 +511,19 @@ ...@@ -514,22 +511,19 @@
isHyperlinkClick = true; isHyperlinkClick = true;
} }
if (isHyperlinkClick) { if (isHyperlinkClick) {
var oRangeHyperlink = ws.model.getCell3(ct.hyperlink.row, ct.hyperlink.col); if (ct.hyperlink.hyperlinkModel.getVisited()) {
var hyp = oRangeHyperlink.getHyperlink(); ct.hyperlink.hyperlinkModel.setVisited(true);
if(null != hyp && false == hyp.getVisited()) ws.changeWorksheet("updateRange", {range: ct.hyperlink.hyperlinkModel.Ref.getBBox0(), isLockDraw: false, canChangeColWidth: false});
{
hyp.setVisited(true);
ws.changeWorksheet("updateRange", {range: ct.hyperlink.hyperlinkRange, isLockDraw: false, canChangeColWidth: false});
}
var t = this;
if (c_oAscHyperlinkType.WebLink === ct.hyperlink.asc_getType()) {
// Это ссылка на Url. Отправляем не сразу, т.к. хочется dblClick обработать...
t.handlers.trigger("asc_onHyperlinkClick", ct.hyperlink.asc_getHyperlinkUrl());
} }
else if (c_oAscHyperlinkType.RangeLink === ct.hyperlink.asc_getType()) { switch (ct.hyperlink.asc_getType()) {
// ToDo надо поправить отрисовку комментария для данной ячейки (с которой уходим) case c_oAscHyperlinkType.WebLink:
t.handlers.trigger("asc_onHideComment"); this.handlers.trigger("asc_onHyperlinkClick", ct.hyperlink.asc_getHyperlinkUrl());
t.Api._asc_setWorksheetRange(ct.hyperlink); break;
case c_oAscHyperlinkType.RangeLink:
// ToDo надо поправить отрисовку комментария для данной ячейки (с которой уходим)
this.handlers.trigger("asc_onHideComment");
this.Api._asc_setWorksheetRange(ct.hyperlink);
break;
} }
} }
} }
...@@ -594,7 +588,7 @@ ...@@ -594,7 +588,7 @@
ct.cursor = ct.cellCursor.cursor; ct.cursor = ct.cellCursor.cursor;
} }
arrMouseMoveObjects.push(asc_CMM({type: c_oAscMouseMoveType.Hyperlink, x: x, y: y, arrMouseMoveObjects.push(asc_CMM({type: c_oAscMouseMoveType.Hyperlink, x: x, y: y,
hyperlink: ct.hyperlink.asc_clone()})); hyperlink: ct.hyperlink}));
} }
/* Проверяем, может мы на никаком объекте (такая схема оказалась приемлимой /* Проверяем, может мы на никаком объекте (такая схема оказалась приемлимой
......
This diff is collapsed.
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