@ -12269,212 +12269,212 @@ null;this.clrSchemeMap=null;this.CellStyles=new AscCommonExcel.CCellStyles;this.
0 ) this . nActive = 0 ; if ( this . nActive >= this . aWorksheets . length ) this . nActive = this . aWorksheets . length - 1 ; var self = this ; this . wsHandlers = new AscCommonExcel . asc _CHandlersList ( { "changeRefTablePart" : function ( table ) { self . dependencyFormulas . changeTableRef ( table ) } , "changeColumnTablePart" : function ( tableName ) { self . dependencyFormulas . renameTableColumn ( tableName ) } , "deleteColumnTablePart" : function ( tableName , deleted ) { self . dependencyFormulas . delColumnTable ( tableName , deleted ) } , "onFilterInfo" : function ( ) { self . handlers . trigger ( "asc_onFilterInfo" ) } } ) ;
for ( var i = 0 , length = tableCustomFunc . length ; i < length ; ++ i ) { var elem = tableCustomFunc [ i ] ; elem . column . applyTotalRowFormula ( elem . formula , elem . ws , ! bNoBuildDep ) } this . forEach ( function ( ws ) { ws . initPostOpen ( self . wsHandlers ) } ) ; var wsActive = this . getActiveWs ( ) ; if ( wsActive && wsActive . getHidden ( ) ) wsActive . setHidden ( false ) ; if ( ! bNoBuildDep ) { this . dependencyFormulas . initOpen ( ) ; this . dependencyFormulas . calcTree ( ) } if ( bSnapshot ) this . snapshot = this . _getSnapshot ( ) } ; Workbook . prototype . forEach = function ( callback , isCopyPaste ) { if ( isCopyPaste ) callback ( this . getActiveWs ( ) ,
this . getActive ( ) ) ; else for ( var i = 0 , l = this . aWorksheets . length ; i < l ; ++ i ) callback ( this . aWorksheets [ i ] , i ) } ; Workbook . prototype . rebuildColors = function ( ) { AscCommonExcel . g _oColorManager . rebuildColors ( ) ; this . forEach ( function ( ws ) { ws . rebuildColors ( ) } ) } ; Workbook . prototype . getDefaultFont = function ( ) { return g _oDefaultFormat . Font . getName ( ) } ; Workbook . prototype . getDefaultSize = function ( ) { return g _oDefaultFormat . Font . getSize ( ) } ; Workbook . prototype . getActive = function ( ) { return this . nActive } ; Workbook . prototype . getActiveWs =
function ( ) { return this . getWorksheet ( this . nActive ) } ; Workbook . prototype . setActive = function ( index ) { if ( index >= 0 && index < this . aWorksheets . length ) { this . nActive = index ; this . cleanFindResults ( ) ; return true } return false } ; Workbook . prototype . setActiveById = function ( sheetId ) { var ws = this . getWorksheetById ( sheetId ) ; return this . setActive ( ws . getIndex ( ) ) } ; Workbook . prototype . getSheetIdByIndex = function ( index ) { var ws = this . getWorksheet ( index ) ; return ws ? ws . getId ( ) : null } ; Workbook . prototype . getWorksheet = function ( index ) { if ( index >=
0 && index < this . aWorksheets . length ) return this . aWorksheets [ index ] ; return null } ; Workbook . prototype . getWorksheetById = function ( id ) { return this . aWorksheetsById [ id ] } ; Workbook . prototype . getWorksheetByName = function ( name ) { for ( var i = 0 ; i < this . aWorksheets . length ; i ++ ) if ( this . aWorksheets [ i ] . getName ( ) == name ) return this . aWorksheets [ i ] ; return null } ; Workbook . prototype . getWorksheetIndexByName = function ( name ) { for ( var i = 0 ; i < this . aWorksheets . length ; i ++ ) if ( this . aWorksheets [ i ] . getName ( ) == name ) return i ; return null } ; Workbook . prototype . getWorksheetCount =
function ( ) { return this . aWorksheets . length } ; Workbook . prototype . createWorksheet = function ( indexBefore , sName , sId ) { this . dependencyFormulas . lockRecal ( ) ; History . Create _NewPoint ( ) ; History . TurnOff ( ) ; var wsActive = this . getActiveWs ( ) ; var oNewWorksheet = new Worksheet ( this , this . aWorksheets . length , sId ) ; if ( this . checkValidSheetName ( sName ) ) oNewWorksheet . sName = sName ; oNewWorksheet . initPostOpen ( this . wsHandlers ) ; if ( null != indexBefore && indexBefore >= 0 && indexBefore < this . aWorksheets . length ) this . aWorksheets . splice ( indexBefore ,
0 , oNewWorksheet ) ; else { indexBefore = this . aWorksheets . length ; this . aWorksheets . push ( oNewWorksheet ) } this . aWorksheetsById [ oNewWorksheet . getId ( ) ] = oNewWorksheet ; this . _updateWorksheetIndexes ( wsActive ) ; History . TurnOn ( ) ; this . _insertWorksheetFormula ( oNewWorksheet . index ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorkbook , AscCH . historyitem _Workbook _SheetAdd , null , null , new UndoRedoData _SheetAdd ( indexBefore , oNewWorksheet . getName ( ) , null , oNewWorksheet . getId ( ) ) ) ; History . SetSheetUndo ( wsActive . getId ( ) ) ; History . SetSheetRedo ( oNewWorksheet . getId ( ) ) ;
this . dependencyFormulas . unlockRecal ( ) ; return oNewWorksheet . index } ; Workbook . prototype . copyWorksheet = function ( index , insertBefore , sName , sId , bFromRedo , tableNames ) { if ( index >= 0 && index < this . aWorksheets . length ) { this . dependencyFormulas . buildDependency ( ) ; History . TurnOff ( ) ; var wsActive = this . getActiveWs ( ) ; var wsFrom = this . aWorksheets [ index ] ; var newSheet = new Worksheet ( this , - 1 , sId ) ; if ( null != insertBefore && insertBefore >= 0 && insertBefore < this . aWorksheets . length ) this . aWorksheets . splice ( insertBefore , 0 , newSheet ) ; else this . aWorksheets . push ( newSheet ) ;
this . aWorksheetsById [ newSheet . getId ( ) ] = newSheet ; this . _updateWorksheetIndexes ( wsActive ) ; var renameParams = newSheet . copyFrom ( wsFrom , sName , tableNames ) ; newSheet . initPostOpen ( this . wsHandlers ) ; History . TurnOn ( ) ; this . dependencyFormulas . copyDefNameByWorksheet ( wsFrom , newSheet , renameParams ) ; this . _insertWorksheetFormula ( insertBefore ) ; if ( ! tableNames ) tableNames = newSheet . getTableNames ( ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorkbook , AscCH . historyitem _Workbook _SheetAdd , null , null , new UndoRedoData _SheetAdd ( insertBefore ,
newSheet . getName ( ) , wsFrom . getId ( ) , newSheet . getId ( ) , tableNames ) ) ; History . SetSheetUndo ( wsActive . getId ( ) ) ; History . SetSheetRedo ( newSheet . getId ( ) ) ; if ( ! ( bFromRedo === true ) ) wsFrom . copyObjects ( newSheet , wsFrom ) ; this . sortDependency ( ) } } ; Workbook . prototype . insertWorksheet = function ( index , sheet ) { var wsActive = this . getActiveWs ( ) ; if ( null != index && index >= 0 && index < this . aWorksheets . length ) this . aWorksheets . splice ( index , 0 , sheet ) ; else this . aWorksheets . push ( sheet ) ; this . aWorksheetsById [ sheet . getId ( ) ] = sheet ; this . _updateWorksheetIndexes ( wsActive ) ;
this . _insertWorksheetFormula ( index ) ; this . _insertTablePartsName ( sheet ) ; sheet . _BuildDependencies ( sheet . getCwf ( ) ) ; this . sortDependency ( ) } ; Workbook . prototype . _insertTablePartsName = function ( sheet ) { if ( sheet && sheet . TableParts && sheet . TableParts . length ) for ( var i = 0 ; i < sheet . TableParts . length ; i ++ ) { var tablePart = sheet . TableParts [ i ] ; this . dependencyFormulas . addTableName ( sheet , tablePart ) ; tablePart . buildDependencies ( ) } } ; Workbook . prototype . _insertWorksheetFormula = function ( index ) { if ( index > 0 && index < this . aWorksheets . length ) { var oWsBefore =
this . aWorksheets [ index - 1 ] ; this . dependencyFormulas . changeSheet ( this . dependencyFormulas . prepareChangeSheet ( oWsBefore . getId ( ) , { insert : index } ) ) } } ; Workbook . prototype . replaceWorksheet = function ( indexFrom , indexTo ) { if ( indexFrom >= 0 && indexFrom < this . aWorksheets . length && indexTo >= 0 && indexTo < this . aWorksheets . length ) { var wsActive = this . getActiveWs ( ) ; var oWsFrom = this . aWorksheets [ indexFrom ] ; var tempW = { wF : oWsFrom , wFI : indexFrom , wTI : indexTo } ; if ( tempW . wFI < tempW . wTI ) tempW . wTI ++ ; this . dependencyFormulas . lockRecal ( ) ; var prepared =
this . dependencyFormulas . prepareChangeSheet ( oWsFrom . getId ( ) , { replace : tempW } , null ) ; var movedSheet = this . aWorksheets . splice ( indexFrom , 1 ) ; this . aWorksheets . splice ( indexTo , 0 , movedSheet [ 0 ] ) ; this . _updateWorksheetIndexes ( wsActive ) ; this . dependencyFormulas . changeSheet ( prepared ) ; this . _insertWorksheetFormula ( indexTo ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorkbook , AscCH . historyitem _Workbook _SheetMove , null , null , new UndoRedoData _FromTo ( indexFrom , indexTo ) ) ; this . dependencyFormulas . unlockRecal ( ) } } ; Workbook . prototype . findSheetNoHidden =
function ( nIndex ) { var i , ws , oRes = null , bFound = false , countWorksheets = this . getWorksheetCount ( ) ; for ( i = nIndex ; i < countWorksheets ; ++ i ) { ws = this . getWorksheet ( i ) ; if ( false === ws . getHidden ( ) ) { oRes = ws ; bFound = true ; break } } if ( ! bFound ) for ( i = nIndex - 1 ; i >= 0 ; -- i ) { ws = this . getWorksheet ( i ) ; if ( false === ws . getHidden ( ) ) { oRes = ws ; break } } return oRes } ; Workbook . prototype . removeWorksheet = function ( nIndex , outputParams ) { var bEmpty = true ; for ( var i = 0 , length = this . aWorksheets . length ; i < length ; ++ i ) { var worksheet = this . aWorksheets [ i ] ; if ( false ==
worksheet . getHidden ( ) && i != nIndex ) { bEmpty = false ; break } } if ( bEmpty ) return - 1 ; var removedSheet = this . getWorksheet ( nIndex ) ; if ( removedSheet ) { var removedSheetId = removedSheet . getId ( ) ; this . dependencyFormulas . lockRecal ( ) ; var prepared = this . dependencyFormulas . prepareRemoveSheet ( removedSheetId , removedSheet . getTableNames ( ) ) ; var wsActive = this . getActiveWs ( ) ; var oVisibleWs = null ; this . aWorksheets . splice ( nIndex , 1 ) ; delete this . aWorksheetsById [ removedSheetId ] ; if ( nIndex == this . getActive ( ) ) { oVisibleWs = this . findSheetNoHidden ( nIndex ) ;
if ( null != oVisibleWs ) wsActive = oVisibleWs } History . Add ( AscCommonExcel . g _oUndoRedoWorkbook , AscCH . historyitem _Workbook _SheetRemove , null , null , new AscCommonExcel . UndoRedoData _SheetRemove ( nIndex , removedSheetId , removedSheet ) ) ; if ( null != oVisibleWs ) { History . SetSheetUndo ( removedSheetId ) ; History . SetSheetRedo ( wsActive . getId ( ) ) } if ( null != outputParams ) outputParams . sheet = removedSheet ; this . _updateWorksheetIndexes ( wsActive ) ; this . dependencyFormulas . removeSheet ( prepared ) ; this . dependencyFormulas . unlockRecal ( ) ; return wsActive . getIndex ( ) } return - 1 } ;
Workbook . prototype . _updateWorksheetIndexes = function ( wsActive ) { this . forEach ( function ( ws , index ) { ws . _setIndex ( index ) } ) ; if ( null != wsActive ) this . setActive ( wsActive . getIndex ( ) ) } ; Workbook . prototype . checkUniqueSheetName = function ( name ) { var workbookSheetCount = this . getWorksheetCount ( ) ; for ( var i = 0 ; i < workbookSheetCount ; i ++ ) if ( this . getWorksheet ( i ) . getName ( ) == name ) return i ; return - 1 } ; Workbook . prototype . checkValidSheetName = function ( name ) { return name && name . length < g _nSheetNameMaxLength } ; Workbook . prototype . getUniqueSheetNameFrom =
function ( name , bCopy ) { var nIndex = 1 ; var sNewName = "" ; var fGetPostfix = null ; if ( bCopy ) { var result = /^(.*)\((\d)\)$/ . exec ( name ) ; if ( result ) { fGetPostfix = function ( nIndex ) { return "(" + nIndex + ")" } ; name = result [ 1 ] } else { fGetPostfix = function ( nIndex ) { return " (" + nIndex + ")" } ; name = name } } else fGetPostfix = function ( nIndex ) { return nIndex . toString ( ) } ; var workbookSheetCount = this . getWorksheetCount ( ) ; while ( nIndex < 1E4 ) { var sPosfix = fGetPostfix ( nIndex ) ; sNewName = name + sPosfix ; if ( sNewName . length > g _nSheetNameMaxLength ) { name = name . substring ( 0 ,
g _nSheetNameMaxLength - sPosfix . length ) ; sNewName = name + sPosfix } var bUniqueName = true ; for ( var i = 0 ; i < workbookSheetCount ; i ++ ) if ( this . getWorksheet ( i ) . getName ( ) == sNewName ) { bUniqueName = false ; break } if ( bUniqueName ) break ; nIndex ++ } return sNewName } ; Workbook . prototype . _generateFontMap = function ( ) { var oFontMap = { "Arial" : 1 } ; var i ; oFontMap [ g _oDefaultFormat . Font . getName ( ) ] = 1 ; if ( null != this . theme ) AscFormat . checkThemeFonts ( oFontMap , this . theme . themeElements . fontScheme ) ; for ( i = 1 ; i <= g _StyleCache . getXfCount ( ) ; ++ i ) { var xf = g _StyleCache . getXf ( i ) ;
if ( xf . font ) oFontMap [ xf . font . getName ( ) ] = 1 } this . sharedStrings . generateFontMap ( oFontMap ) ; this . forEach ( function ( ws ) { ws . generateFontMap ( oFontMap ) } ) ; this . CellStyles . generateFontMap ( oFontMap ) ; return oFontMap } ; Workbook . prototype . generateFontMap = function ( ) { var oFontMap = this . _generateFontMap ( ) ; var aRes = [ ] ; for ( var i in oFontMap ) aRes . push ( i ) ; return aRes } ; Workbook . prototype . generateFontMap2 = function ( ) { var oFontMap = this . _generateFontMap ( ) ; var aRes = [ ] ; for ( var i in oFontMap ) aRes . push ( new AscFonts . CFont ( i , 0 , "" , 0 ) ) ;
AscFonts . FontPickerByCharacter . extendFonts ( aRes ) ; return aRes } ; Workbook . prototype . getAllImageUrls = function ( ) { var aImageUrls = [ ] ; this . forEach ( function ( ws ) { ws . getAllImageUrls ( aImageUrls ) } ) ; return aImageUrls } ; Workbook . prototype . reassignImageUrls = function ( oImages ) { this . forEach ( function ( ws ) { ws . reassignImageUrls ( oImages ) } ) } ; Workbook . prototype . recalcWB = function ( rebuild , opt _sheetId ) { var formulas ; if ( rebuild ) { formulas = this . getAllFormulas ( ) ; for ( var i = 0 ; i < formulas . length ; ++ i ) { var formula = formulas [ i ] ; formula . removeDependencies ( ) ;
formula . setFormula ( formula . getFormula ( ) ) ; formula . parse ( ) ; formula . buildDependencies ( ) } } else if ( opt _sheetId ) { formulas = [ ] ; var ws = this . getWorksheetById ( opt _sheetId ) ; ws . getAllFormulas ( formulas ) } else formulas = this . getAllFormulas ( ) ; this . dependencyFormulas . notifyChanged ( formulas ) ; this . dependencyFormulas . calcTree ( ) } ; Workbook . prototype . checkDefName = function ( checkName , scope ) { return this . dependencyFormulas . checkDefName ( checkName , scope ) } ; Workbook . prototype . getDefinedNamesWB = function ( defNameListId , bLocale ) { return this . dependencyFormulas . getDefinedNamesWB ( defNameListId ,
bLocale ) } ; Workbook . prototype . getDefinedNamesWS = function ( sheetId ) { return this . dependencyFormulas . getDefinedNamesWS ( sheetId ) } ; Workbook . prototype . addDefName = function ( name , ref , sheetId , hidden , isTable ) { return this . dependencyFormulas . addDefName ( name , ref , sheetId , hidden , isTable ) } ; Workbook . prototype . getDefinesNames = function ( name , sheetId ) { return this . dependencyFormulas . getDefNameByName ( name , sheetId ) } ; Workbook . prototype . getDefinedName = function ( name ) { var sheetId = this . getSheetIdByIndex ( name . LocalSheetId ) ; return this . dependencyFormulas . getDefNameByName ( name . Name ,
sheetId ) } ; Workbook . prototype . delDefinesNames = function ( defName ) { this . delDefinesNamesUndoRedo ( this . getUndoDefName ( defName ) ) } ; Workbook . prototype . delDefinesNamesUndoRedo = function ( defName ) { this . dependencyFormulas . removeDefName ( defName . sheetId , defName . name ) ; this . dependencyFormulas . calcTree ( ) } ; Workbook . prototype . editDefinesNames = function ( oldName , newName ) { return this . editDefinesNamesUndoRedo ( this . getUndoDefName ( oldName ) , this . getUndoDefName ( newName ) ) } ; Workbook . prototype . editDefinesNamesUndoRedo = function ( oldName ,
newName ) { var res = this . dependencyFormulas . editDefinesNames ( oldName , newName ) ; this . dependencyFormulas . calcTree ( ) ; return res } ; Workbook . prototype . findDefinesNames = function ( ref , sheetId , bLocale ) { return this . dependencyFormulas . getDefNameByRef ( ref , sheetId , bLocale ) } ; Workbook . prototype . unlockDefName = function ( ) { this . dependencyFormulas . unlockDefName ( ) } ; Workbook . prototype . unlockCurrentDefName = function ( name , sheetId ) { this . dependencyFormulas . unlockCurrentDefName ( name , sheetId ) } ; Workbook . prototype . checkDefNameLock =
function ( ) { return this . dependencyFormulas . checkDefNameLock ( ) } ; Workbook . prototype . _SerializeHistoryBase64 = function ( oMemory , item , aPointChangesBase64 ) { if ( ! item . LocalChange ) { var nPosStart = oMemory . GetCurPosition ( ) ; item . Serialize ( oMemory , this . oApi . collaborativeEditing ) ; var nPosEnd = oMemory . GetCurPosition ( ) ; var nLen = nPosEnd - nPosStart ; if ( nLen > 0 ) aPointChangesBase64 . push ( nLen + ";" + oMemory . GetBase64Memory2 ( nPosStart , nLen ) ) } } ; Workbook . prototype . SerializeHistory = function ( ) { var aRes = [ ] ; var t , j , length2 ; AscCommon . CollaborativeEditing . Refresh _DCChanges ( ) ;
var aActions = this . aCollaborativeActions . concat ( History . GetSerializeArray ( ) ) ; if ( aActions . length > 0 ) { var oMemory = new AscCommon . CMemory ; for ( var i = 0 , length = aActions . length ; i < length ; ++ i ) { var aPointChanges = aActions [ i ] ; for ( j = 0 , length2 = aPointChanges . length ; j < length2 ; ++ j ) { var item = aPointChanges [ j ] ; this . _SerializeHistoryBase64 ( oMemory , item , aRes ) } } this . aCollaborativeActions = [ ] ; this . snapshot = this . _getSnapshot ( ) } return aRes } ; Workbook . prototype . _getSnapshot = function ( ) { var wb = new Workbook ( new AscCommonExcel . asc _CHandlersList ,
this . oApi ) ; wb . dependencyFormulas = this . dependencyFormulas . getSnapshot ( wb ) ; this . forEach ( function ( ws ) { ws = ws . getSnapshot ( wb ) ; wb . aWorksheets . push ( ws ) ; wb . aWorksheetsById [ ws . getId ( ) ] = ws } ) ; wb . init ( { } , true , false ) ; return wb } ; Workbook . prototype . getAllFormulas = function ( ) { var res = [ ] ; this . dependencyFormulas . getAllFormulas ( res ) ; this . forEach ( function ( ws ) { ws . getAllFormulas ( res ) } ) ; return res } ; Workbook . prototype . _forwardTransformation = function ( wbSnapshot , changesMine , changesTheir ) { History . TurnOff ( ) ; var res1 = this . _forwardTransformationGetTransform ( wbSnapshot ,
changesTheir , changesMine ) ; var res2 = this . _forwardTransformationGetTransform ( wbSnapshot , changesMine , changesTheir ) ; var i , elem , elemWrap ; for ( i = 0 ; i < res1 . modify . length ; ++ i ) { elemWrap = res1 . modify [ i ] ; elem = elemWrap . elem ; elem . oClass . forwardTransformationSet ( elem . nActionType , elem . oData , elem . nSheetId , elemWrap ) } for ( i = 0 ; i < res2 . modify . length ; ++ i ) { elemWrap = res2 . modify [ i ] ; elem = elemWrap . elem ; elem . oClass . forwardTransformationSet ( elem . nActionType , elem . oData , elem . nSheetId , elemWrap ) } for ( var oldName in res1 . renameSheet ) { var ws =
this . getWorksheetByName ( oldName ) ; if ( ws ) ws . setName ( res1 . renameSheet [ oldName ] ) } History . TurnOn ( ) } ; Workbook . prototype . _forwardTransformationGetTransform = function ( wbSnapshot , changesMaster , changesModify ) { var res = { modify : [ ] , renameSheet : { } } ; var changesMasterSelected = [ ] ; var i , elem ; if ( changesModify . length > 0 ) for ( i = 0 ; i < changesMaster . length ; ++ i ) { elem = changesMaster [ i ] ; if ( elem . oClass && elem . oClass . forwardTransformationIsAffect && elem . oClass . forwardTransformationIsAffect ( elem . nActionType ) ) changesMasterSelected . push ( elem ) } if ( changesMasterSelected . length >
0 && changesModify . length > 0 ) { var wbSnapshotCur = wbSnapshot . _getSnapshot ( ) ; var formulas = [ ] ; for ( i = 0 ; i < changesModify . length ; ++ i ) { elem = changesModify [ i ] ; var renameRes = null ; if ( elem . oClass && elem . oClass . forwardTransformationGet ) { var getRes = elem . oClass . forwardTransformationGet ( elem . nActionType , elem . oData , elem . nSheetId ) ; if ( getRes && getRes . formula ) formulas . push ( new ForwardTransformationFormula ( elem , getRes . formula , null ) ) ; if ( getRes && getRes . name ) renameRes = this . _forwardTransformationRenameStart ( wbSnapshotCur . _getSnapshot ( ) ,
changesMasterSelected , getRes ) } if ( elem . oClass && elem . oClass . forwardTransformationIsAffect && elem . oClass . forwardTransformationIsAffect ( elem . nActionType ) ) { if ( formulas . length > 0 ) { this . _forwardTransformationFormula ( wbSnapshotCur . _getSnapshot ( ) , formulas , changesMasterSelected , res ) ; formulas = [ ] } elem . oClass . Redo ( elem . nActionType , elem . oData , elem . nSheetId , wbSnapshotCur ) } if ( renameRes ) this . _forwardTransformationRenameEnd ( renameRes , res . renameSheet , getRes , elem ) } this . _forwardTransformationFormula ( wbSnapshotCur , formulas ,
changesMasterSelected , res ) } return res } ; Workbook . prototype . _forwardTransformationRenameStart = function ( wbSnapshot , changes , getRes ) { var res = { newName : null } ; for ( var i = 0 ; i < changes . length ; ++ i ) { var elem = changes [ i ] ; elem . oClass . Redo ( elem . nActionType , elem . oData , elem . nSheetId , wbSnapshot ) } if ( - 1 != wbSnapshot . checkUniqueSheetName ( getRes . name ) ) res . newName = wbSnapshot . getUniqueSheetNameFrom ( getRes . name , true ) ; return res } ; Workbook . prototype . _forwardTransformationRenameEnd = function ( renameRes , renameSheet , getRes , elemCur ) { var isChange =
false ; if ( getRes . from ) { var renameCur = renameSheet [ getRes . from ] ; if ( renameCur ) { delete renameSheet [ getRes . from ] ; getRes . from = renameCur ; isChange = true } } if ( renameRes && renameRes . newName ) { renameSheet [ getRes . name ] = renameRes . newName ; getRes . name = renameRes . newName ; isChange = true } if ( isChange && elemCur . oClass . forwardTransformationSet ) elemCur . oClass . forwardTransformationSet ( elemCur . nActionType , elemCur . oData , elemCur . nSheetId , getRes ) } ; Workbook . prototype . _forwardTransformationFormula = function ( wbSnapshot , formulas , changes ,
res ) { if ( formulas . length > 0 ) { var i , elem , ftFormula , ws ; for ( i = 0 ; i < formulas . length ; ++ i ) { ftFormula = formulas [ i ] ; ws = wbSnapshot . getWorksheetById ( ftFormula . elem . nSheetId ) ; if ( ws ) { ftFormula . parsed = new parserFormula ( ftFormula . formula , ftFormula , ws ) ; ftFormula . parsed . parse ( ) ; ftFormula . parsed . buildDependencies ( ) } } for ( var oldName in res . renameSheet ) { ws = wbSnapshot . getWorksheetByName ( oldName ) ; if ( ws ) ws . setName ( res . renameSheet [ oldName ] ) } for ( i = 0 ; i < changes . length ; ++ i ) { elem = changes [ i ] ; elem . oClass . Redo ( elem . nActionType , elem . oData ,
elem . nSheetId , wbSnapshot ) } for ( i = 0 ; i < formulas . length ; ++ i ) { ftFormula = formulas [ i ] ; if ( ftFormula . parsed ) { ftFormula . parsed . removeDependencies ( ) ; res . modify . push ( ftFormula ) } } } } ; Workbook . prototype . DeserializeHistory = function ( aChanges , fCallback ) { var oThis = this ; this . aCollaborativeActions = this . aCollaborativeActions . concat ( History . GetSerializeArray ( ) ) ; if ( aChanges . length > 0 ) { this . bCollaborativeChanges = true ; var dstLen = 0 ; var aIndexes = [ ] , i , length = aChanges . length , sChange ; for ( i = 0 ; i < length ; ++ i ) { sChange = aChanges [ i ] ; var nIndex =
sChange . indexOf ( ";" ) ; if ( - 1 != nIndex ) { dstLen += parseInt ( sChange . substring ( 0 , nIndex ) ) ; nIndex ++ } aIndexes . push ( nIndex ) } var pointer = g _memory . Alloc ( dstLen ) ; var stream = new AscCommon . FT _Stream2 ( pointer . data , dstLen ) ; stream . obj = pointer . obj ; var nCurOffset = 0 ; var aUndoRedoElems = [ ] ; for ( i = 0 ; i < length ; ++ i ) { sChange = aChanges [ i ] ; var oBinaryFileReader = new AscCommonExcel . BinaryFileReader ; nCurOffset = oBinaryFileReader . getbase64DecodedData2 ( sChange , aIndexes [ i ] , stream , nCurOffset ) ; var item = new UndoRedoItemSerializable ; item . Deserialize ( stream ) ;
aUndoRedoElems . push ( item ) } var wsViews = window [ "Asc" ] [ "editor" ] . wb . wsViews ; if ( oThis . oApi . collaborativeEditing . getFast ( ) ) AscCommon . CollaborativeEditing . Clear _DocumentPositions ( ) ; for ( var i in wsViews ) if ( isRealObject ( wsViews [ i ] ) && isRealObject ( wsViews [ i ] . objectRender ) && isRealObject ( wsViews [ i ] . objectRender . controller ) ) { wsViews [ i ] . endEditChart ( ) ; if ( oThis . oApi . collaborativeEditing . getFast ( ) ) { var oState = wsViews [ i ] . objectRender . saveStateBeforeLoadChanges ( ) ; if ( oState ) { if ( oState . Pos ) AscCommon . CollaborativeEditing . Add _DocumentPosition ( oState . Pos ) ;
if ( oState . StartPos ) AscCommon . CollaborativeEditing . Add _DocumentPosition ( oState . StartPos ) ; if ( oState . EndPos ) AscCommon . CollaborativeEditing . Add _DocumentPosition ( oState . EndPos ) } } wsViews [ i ] . objectRender . controller . resetSelection ( ) } oFormulaLocaleInfo . Parse = false ; oFormulaLocaleInfo . DigitSep = false ; AscFonts . IsCheckSymbols = true ; History . Clear ( ) ; History . TurnOff ( ) ; var history = new AscCommon . CHistory ; history . init ( this ) ; history . Create _NewPoint ( ) ; history . SetSelection ( null ) ; history . SetSelectionRedo ( null ) ; var oRedoObjectParam =
new AscCommonExcel . RedoObjectParam ; history . UndoRedoPrepare ( oRedoObjectParam , false ) ; var changesMine = [ ] . concat . apply ( [ ] , oThis . aCollaborativeActions ) ; oThis . _forwardTransformation ( oThis . snapshot , changesMine , aUndoRedoElems ) ; for ( var i = 0 , length = aUndoRedoElems . length ; i < length ; ++ i ) { var item = aUndoRedoElems [ i ] ; if ( ( null != item . oClass || item . oData && typeof item . oData . sChangedObjectId === "string" ) && null != item . nActionType ) { if ( window [ "NATIVE_EDITOR_ENJINE" ] === true && window [ "native" ] [ "CheckNextChange" ] ) if ( ! window [ "native" ] [ "CheckNextChange" ] ( ) ) break ;
history . RedoAdd ( oRedoObjectParam , item . oClass , item . nActionType , item . nSheetId , item . oRange , item . oData ) } } AscFonts . IsCheckSymbols = false ; var oFontMap = this . _generateFontMap ( ) ; window [ "Asc" ] [ "editor" ] . _loadFonts ( oFontMap , function ( ) { if ( oThis . oApi . collaborativeEditing . getFast ( ) ) for ( var i in wsViews ) if ( isRealObject ( wsViews [ i ] ) && isRealObject ( wsViews [ i ] . objectRender ) && isRealObject ( wsViews [ i ] . objectRender . controller ) ) { var oState = wsViews [ i ] . objectRender . getStateBeforeLoadChanges ( ) ; if ( oState ) { if ( oState . Pos ) AscCommon . CollaborativeEditing . Update _DocumentPosition ( oState . Pos ) ;
if ( oState . StartPos ) AscCommon . CollaborativeEditing . Update _DocumentPosition ( oState . StartPos ) ; if ( oState . EndPos ) AscCommon . CollaborativeEditing . Update _DocumentPosition ( oState . EndPos ) } wsViews [ i ] . objectRender . loadStateAfterLoadChanges ( ) } oFormulaLocaleInfo . Parse = true ; oFormulaLocaleInfo . DigitSep = true ; history . UndoRedoEnd ( null , oRedoObjectParam , false ) ; History . TurnOn ( ) ; oThis . bCollaborativeChanges = false ; oThis . snapshot = oThis . _getSnapshot ( ) ; if ( null != fCallback ) fCallback ( ) } ) } else if ( null != fCallback ) fCallback ( ) } ; Workbook . prototype . DeserializeHistoryNative =
function ( oRedoObjectParam , data , isFull ) { if ( null != data ) { this . bCollaborativeChanges = true ; if ( null == oRedoObjectParam ) { var wsViews = window [ "Asc" ] [ "editor" ] . wb . wsViews ; for ( var i in wsViews ) if ( isRealObject ( wsViews [ i ] ) && isRealObject ( wsViews [ i ] . objectRender ) && isRealObject ( wsViews [ i ] . objectRender . controller ) ) { wsViews [ i ] . endEditChart ( ) ; wsViews [ i ] . objectRender . controller . resetSelection ( ) } History . Clear ( ) ; History . Create _NewPoint ( ) ; History . SetSelection ( null ) ; History . SetSelectionRedo ( null ) ; oRedoObjectParam = new AscCommonExcel . RedoObjectParam ;
History . UndoRedoPrepare ( oRedoObjectParam , false ) } var stream = new AscCommon . FT _Stream2 ( data , data . length ) ; stream . obj = null ; var _count = stream . GetLong ( ) ; var _pos = 4 ; for ( var i = 0 ; i < _count ; i ++ ) { if ( window [ "NATIVE_EDITOR_ENJINE" ] === true && window [ "native" ] [ "CheckNextChange" ] ) if ( ! window [ "native" ] [ "CheckNextChange" ] ( ) ) break ; var _len = stream . GetLong ( ) ; _pos += 4 ; stream . size = _pos + _len ; stream . Seek ( _pos ) ; stream . Seek2 ( _pos ) ; var item = new UndoRedoItemSerializable ; item . Deserialize ( stream ) ; if ( ( null != item . oClass || item . oData && typeof item . oData . sChangedObjectId ===
"string" ) && null != item . nActionType ) History . RedoAdd ( oRedoObjectParam , item . oClass , item . nActionType , item . nSheetId , item . oRange , item . oData ) ; _pos += _len ; stream . Seek2 ( _pos ) ; stream . size = data . length } if ( isFull ) { History . UndoRedoEnd ( null , oRedoObjectParam , false ) ; History . Clear ( ) ; oRedoObjectParam = null } this . bCollaborativeChanges = false } return oRedoObjectParam } ; Workbook . prototype . getTableRangeForFormula = function ( name , objectParam ) { var res = null ; for ( var i = 0 , length = this . aWorksheets . length ; i < length ; ++ i ) { var ws = this . aWorksheets [ i ] ;
res = ws . getTableRangeForFormula ( name , objectParam ) ; if ( res !== null ) { res = { wsID : ws . getId ( ) , range : res } ; break } } return res } ; Workbook . prototype . getTableIndexColumnByName = function ( tableName , columnName ) { var res = null ; for ( var i = 0 , length = this . aWorksheets . length ; i < length ; ++ i ) { var ws = this . aWorksheets [ i ] ; res = ws . getTableIndexColumnByName ( tableName , columnName ) ; if ( res !== null ) { res = { wsID : ws . getId ( ) , index : res , name : ws . getTableNameColumnByIndex ( tableName , res ) } ; break } } return res } ; Workbook . prototype . getTableNameColumnByIndex =
function ( tableName , columnIndex ) { var res = null ; for ( var i = 0 , length = this . aWorksheets . length ; i < length ; ++ i ) { var ws = this . aWorksheets [ i ] ; res = ws . getTableNameColumnByIndex ( tableName , columnIndex ) ; if ( res !== null ) { res = { wsID : ws . getId ( ) , columnName : res } ; break } } return res } ; Workbook . prototype . getTableByName = function ( tableName , wsID ) { var res = null ; var ws = this . getWorksheetById ( wsID ) ; return ws . getTableByName ( tableName ) } ; Workbook . prototype . updateSparklineCache = function ( sheet , ranges ) { this . forEach ( function ( ws ) { ws . updateSparklineCache ( sheet ,
ranges ) } ) } ; Workbook . prototype . sortDependency = function ( ) { this . dependencyFormulas . calcTree ( ) } ; Workbook . prototype . charCountToModelColWidth = function ( count ) { if ( count <= 0 ) return 0 ; return Asc . floor ( ( count * this . maxDigitWidth + this . paddingPlusBorder ) / this . maxDigitWidth * 256 ) / 256 } ; Workbook . prototype . modelColWidthToColWidth = function ( mcw ) { return Asc . floor ( ( 256 * mcw + Asc . floor ( 128 / this . maxDigitWidth ) ) / 256 * this . maxDigitWidth ) } ; Workbook . prototype . colWidthToCharCount = function ( w ) { var pxInOneCharacter = this . maxDigitWidth +
this . paddingPlusBorder ; return w < pxInOneCharacter ? 1 - Asc . floor ( 100 * ( pxInOneCharacter - w ) / pxInOneCharacter + . 49999 ) / 100 : Asc . floor ( ( w - this . paddingPlusBorder ) / this . maxDigitWidth * 100 + . 5 ) / 100 } ; Workbook . prototype . getUndoDefName = function ( ascName ) { if ( ! ascName ) return ascName ; var sheetId = this . getSheetIdByIndex ( ascName . LocalSheetId ) ; return new UndoRedoData _DefinedNames ( ascName . Name , ascName . Ref , sheetId , ascName . isTable , ascName . isXLNM ) } ; Workbook . prototype . changeColorScheme = function ( sSchemeName ) { var scheme = AscCommon . getColorSchemeByName ( sSchemeName ) ;
if ( ! scheme ) scheme = this . theme . getExtraClrScheme ( sSchemeName ) ; if ( ! scheme ) return ; History . Create _NewPoint ( ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorkbook , AscCH . historyitem _Workbook _ChangeColorScheme , null , null , new AscCommonExcel . UndoRedoData _ClrScheme ( this . theme . themeElements . clrScheme , scheme ) ) ; this . theme . themeElements . clrScheme = scheme ; this . rebuildColors ( ) ; return true } ; Workbook . prototype . cleanFindResults = function ( ) { this . lastFindOptions = null ; this . lastFindCells = { } } ; Workbook . prototype . findCellText = function ( options ) { var ws =
this . getActiveWs ( ) ; var result = ws . findCellText ( options ) , result2 = null ; if ( ! options . scanOnOnlySheet ) { var key = result && result . col + "-" + result . row ; if ( ! key || options . isEqual ( this . lastFindOptions ) && this . lastFindCells [ key ] ) { var i , active = this . getActive ( ) , start = 0 , end = this . getWorksheetCount ( ) ; var inc = options . scanForward ? + 1 : - 1 ; for ( i = active + inc ; i < end && i >= start ; i += inc ) { ws = this . getWorksheet ( i ) ; if ( ws . getHidden ( ) ) continue ; result2 = ws . findCellText ( options ) ; if ( result2 ) break } if ( ! result2 ) { if ( options . scanForward ) { i = 0 ; end = active } else { i =
end - 1 ; start = active + 1 } inc *= - 1 ; for ( ; i < end && i >= start ; i += inc ) { ws = this . getWorksheet ( i ) ; if ( ws . getHidden ( ) ) continue ; result2 = ws . findCellText ( options ) ; if ( result2 ) break } } if ( result2 ) { this . handlers . trigger ( "undoRedoHideSheet" , i ) ; key = result2 . col + "-" + result2 . row } } if ( key ) { this . lastFindOptions = options . clone ( ) ; this . lastFindCells [ key ] = true } } if ( ! result2 && ! result ) this . cleanFindResults ( ) ; return result2 || result } ; Workbook . prototype . getComment = function ( id ) { if ( id ) { var sheet ; for ( var i = 0 ; i < this . aWorksheets . length ; ++ i ) { sheet =
this . aWorksheets [ i ] ; for ( var j = 0 ; j < sheet . aComments . length ; ++ j ) if ( id === sheet . aComments [ j ] . asc _getGuid ( ) ) return sheet . aComments [ j ] } } return null } ; var tempHelp = new ArrayBuffer ( 8 ) ; var tempHelpUnit = new Uint8Array ( tempHelp ) ; var tempHelpFloat = new Float64Array ( tempHelp ) ; function SheetMemory ( structSize , maxIndex ) { this . data = null ; this . count = 0 ; this . structSize = structSize ; this . maxIndex = maxIndex } SheetMemory . prototype . checkSize = function ( index ) { var allocatedCount = this . data ? this . data . length / this . structSize : 0 ; if ( allocatedCount <
index + 1 ) { var newAllocatedCount = Math . min ( Math . max ( 1.5 * this . count >> 0 , index + 1 ) , this . maxIndex + 1 ) ; if ( newAllocatedCount > allocatedCount ) { var oldData = this . data ; this . data = new Uint8Array ( newAllocatedCount * this . structSize ) ; if ( oldData ) this . data . set ( oldData ) } } this . count = Math . min ( Math . max ( this . count , index + 1 ) , this . maxIndex + 1 ) } ; SheetMemory . prototype . hasSize = function ( index ) { return index + 1 <= this . count } ; SheetMemory . prototype . getSize = function ( ) { return this . count } ; SheetMemory . prototype . clone = function ( ) { var sheetMemory =
new SheetMemory ( this . structSize , this . maxIndex ) ; sheetMemory . data = this . data ? new Uint8Array ( this . data ) : null ; sheetMemory . count = this . count ; return sheetMemory } ; SheetMemory . prototype . deleteRange = function ( start , deleteCount ) { if ( start < this . count ) { var startOffset = start * this . structSize ; if ( start + deleteCount < this . count ) { var endOffset = ( start + deleteCount ) * this . structSize ; this . data . set ( this . data . subarray ( endOffset ) , startOffset ) ; this . data . fill ( 0 , ( this . count - deleteCount ) * this . structSize ) ; this . count -= deleteCount } else { this . data . fill ( 0 ,
startOffset ) ; this . count = start } } } ; SheetMemory . prototype . insertRange = function ( start , insertCount ) { if ( start < this . count ) { this . checkSize ( this . count - 1 + insertCount ) ; var startOffset = start * this . structSize ; if ( start + insertCount < this . count ) { var endOffset = ( start + insertCount ) * this . structSize ; var endData = ( this . count - insertCount ) * this . structSize ; this . data . set ( this . data . subarray ( startOffset , endData ) , endOffset ) ; this . data . fill ( 0 , startOffset , endOffset ) } else this . data . fill ( 0 , startOffset ) } } ; SheetMemory . prototype . copyRange =
function ( sheetMemory , startFrom , startTo , count ) { var countCopied = 0 ; if ( startFrom < sheetMemory . count ) { countCopied = Math . min ( count , sheetMemory . count - startFrom ) ; this . checkSize ( startTo + countCopied ) ; countCopied = Math . min ( countCopied , this . count - startTo ) ; if ( countCopied > 0 ) { var startOffsetFrom = startFrom * this . structSize ; var endOffsetFrom = ( startFrom + countCopied ) * this . structSize ; var startOffsetTo = startTo * this . structSize ; this . data . set ( sheetMemory . data . subarray ( startOffsetFrom , endOffsetFrom ) , startOffsetTo ) } } var countErase =
Math . min ( count - countCopied , this . count - ( startTo + countCopied ) ) ; if ( countErase > 0 ) { var startOffsetErase = ( startTo + countCopied ) * this . structSize ; var endOffsetErase = ( startTo + countCopied + countErase ) * this . structSize ; this . data . fill ( 0 , startOffsetErase , endOffsetErase ) } } ; SheetMemory . prototype . copyRangeByChunk = function ( from , fromCount , to , toCount ) { if ( from < this . count ) { this . checkSize ( to + toCount - 1 ) ; var fromStartOffset = from * this . structSize ; var fromEndOffset = Math . min ( from + fromCount , this . count ) * this . structSize ; var fromSubArray =
this . data . subarray ( fromStartOffset , fromEndOffset ) ; for ( var i = to ; i < to + toCount && i < this . count ; i += fromCount ) this . data . set ( fromSubArray , i * this . structSize ) } } ; SheetMemory . prototype . clear = function ( start , end ) { end = Math . min ( end , this . count ) ; if ( start < end ) this . data . fill ( 0 , start * this . structSize , end * this . structSize ) } ; SheetMemory . prototype . getUint8 = function ( index , offset ) { offset += index * this . structSize ; return this . data [ offset ] } ; SheetMemory . prototype . setUint8 = function ( index , offset , val ) { offset += index * this . structSize ; this . data [ offset ] =
val } ; SheetMemory . prototype . getUint16 = function ( index , offset ) { offset += index * this . structSize ; return AscFonts . FT _Common . IntToUInt ( this . data [ offset ] | this . data [ offset + 1 ] << 8 ) } ; SheetMemory . prototype . setUint16 = function ( index , offset , val ) { offset += index * this . structSize ; this . data [ offset ] = val & 255 ; this . data [ offset + 1 ] = val >>> 8 & 255 } ; SheetMemory . prototype . getUint32 = function ( index , offset ) { offset += index * this . structSize ; return AscFonts . FT _Common . IntToUInt ( this . data [ offset ] | this . data [ offset + 1 ] << 8 | this . data [ offset + 2 ] << 16 |
this . data [ offset + 3 ] << 24 ) } ; SheetMemory . prototype . setUint32 = function ( index , offset , val ) { offset += index * this . structSize ; this . data [ offset ] = val & 255 ; this . data [ offset + 1 ] = val >>> 8 & 255 ; this . data [ offset + 2 ] = val >>> 16 & 255 ; this . data [ offset + 3 ] = val >>> 24 & 255 } ; SheetMemory . prototype . getFloat64 = function ( index , offset ) { offset += index * this . structSize ; tempHelpUnit [ 0 ] = this . data [ offset ] ; tempHelpUnit [ 1 ] = this . data [ offset + 1 ] ; tempHelpUnit [ 2 ] = this . data [ offset + 2 ] ; tempHelpUnit [ 3 ] = this . data [ offset + 3 ] ; tempHelpUnit [ 4 ] = this . data [ offset +
4 ] ; tempHelpUnit [ 5 ] = this . data [ offset + 5 ] ; tempHelpUnit [ 6 ] = this . data [ offset + 6 ] ; tempHelpUnit [ 7 ] = this . data [ offset + 7 ] ; return tempHelpFloat [ 0 ] } ; SheetMemory . prototype . setFloat64 = function ( index , offset , val ) { offset += index * this . structSize ; tempHelpFloat [ 0 ] = val ; this . data [ offset ] = tempHelpUnit [ 0 ] ; this . data [ offset + 1 ] = tempHelpUnit [ 1 ] ; this . data [ offset + 2 ] = tempHelpUnit [ 2 ] ; this . data [ offset + 3 ] = tempHelpUnit [ 3 ] ; this . data [ offset + 4 ] = tempHelpUnit [ 4 ] ; this . data [ offset + 5 ] = tempHelpUnit [ 5 ] ; this . data [ offset + 6 ] = tempHelpUnit [ 6 ] ; this . data [ offset +
7 ] = tempHelpUnit [ 7 ] } ; function Worksheet ( wb , _index , sId ) { this . workbook = wb ; this . sName = this . workbook . getUniqueSheetNameFrom ( g _sNewSheetNamePattern , false ) ; this . bHidden = false ; this . oSheetFormatPr = new AscCommonExcel . SheetFormatPr ; this . index = _index ; this . Id = null != sId ? sId : AscCommon . g _oIdCounter . Get _NewId ( ) ; this . nRowsCount = 0 ; this . nColsCount = 0 ; this . rowsData = new SheetMemory ( AscCommonExcel . g _nRowStructSize , gc _nMaxRow0 ) ; this . cellsByCol = [ ] ; this . cellsByColRowsCount = 0 ; this . aCols = [ ] ; this . hiddenManager = new HiddenManager ( this ) ;
this . Drawings = [ ] ; this . TableParts = [ ] ; this . AutoFilter = null ; this . oAllCol = null ; this . aComments = [ ] ; var oThis = this ; this . bExcludeHiddenRows = false ; this . bIgnoreWriteFormulas = false ; this . mergeManager = new RangeDataManager ( function ( data , from , to ) { if ( History . Is _On ( ) && ( null != from || null != to ) ) { if ( null != from ) from = from . clone ( ) ; if ( null != to ) to = to . clone ( ) ; var oHistoryRange = from ; if ( null == oHistoryRange ) oHistoryRange = to ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _ChangeMerge , oThis . getId ( ) , oHistoryRange ,
new UndoRedoData _FromTo ( new UndoRedoData _BBox ( from ) , new UndoRedoData _BBox ( to ) ) ) } if ( null != to ) { var maxRow = gc _nMaxRow0 !== to . r2 ? to . r2 : to . r1 ; var maxCol = gc _nMaxCol0 !== to . c2 ? to . c2 : to . c1 ; if ( maxRow >= oThis . nRowsCount ) oThis . nRowsCount = maxRow + 1 ; if ( maxCol >= oThis . nColsCount ) oThis . nColsCount = maxCol + 1 } } ) ; this . mergeManager . worksheet = this ; this . hyperlinkManager = new RangeDataManager ( function ( data , from , to , oChangeParam ) { if ( History . Is _On ( ) && ( null != from || null != to ) ) { if ( null != from ) from = from . clone ( ) ; if ( null != to ) to = to . clone ( ) ;
var oHistoryRange = from ; if ( null == oHistoryRange ) oHistoryRange = to ; var oHistoryData = null ; if ( null == from || null == to ) oHistoryData = data . clone ( ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _ChangeHyperlink , oThis . getId ( ) , oHistoryRange , new AscCommonExcel . UndoRedoData _FromToHyperlink ( from , to , oHistoryData ) ) } if ( null != to ) data . Ref = oThis . getRange3 ( to . r1 , to . c1 , to . r2 , to . c2 ) ; else if ( oChangeParam && oChangeParam . removeStyle && null != data . Ref ) data . Ref . cleanFormat ( ) ; if ( null != to ) { var maxRow = gc _nMaxRow0 !==
to . r2 ? to . r2 : to . r1 ; var maxCol = gc _nMaxCol0 !== to . c2 ? to . c2 : to . c1 ; if ( maxRow >= oThis . nRowsCount ) oThis . nRowsCount = maxRow + 1 ; if ( maxCol >= oThis . nColsCount ) oThis . nColsCount = maxCol + 1 } } ) ; this . hyperlinkManager . setDependenceManager ( this . mergeManager ) ; this . DrawingDocument = new AscCommon . CDrawingDocument ; this . sheetViews = [ ] ; this . aConditionalFormattingRules = [ ] ; this . updateConditionalFormattingRange = null ; this . dataValidations = null ; this . sheetPr = null ; this . aFormulaExt = null ; this . autoFilters = AscCommonExcel . AutoFilters !== undefined ?
new AscCommonExcel . AutoFilters ( this ) : null ; this . oDrawingOjectsManager = new DrawingObjectsManager ( this ) ; this . contentChanges = new AscCommon . CContentChanges ; this . aSparklineGroups = [ ] ; this . selectionRange = new AscCommonExcel . SelectionRange ( this ) ; this . sheetMergedStyles = new AscCommonExcel . SheetMergedStyles ; this . pivotTables = [ ] ; this . headerFooter = new Asc . CHeaderFooter ( this ) ; this . rowBreaks = null ; this . colBreaks = null ; this . legacyDrawingHF = null ; this . picture = null ; this . PagePrintOptions = new Asc . asc _CPageOptions ( this ) ; this . formulaArrayLink =
null ; this . lastFindOptions = null ; this . bExcludeCollapsed = false ; this . handlers = null } Worksheet . prototype . getCompiledStyle = function ( row , col , opt _cell , opt _styleComponents ) { return getCompiledStyle ( this . sheetMergedStyles , this . hiddenManager , row , col , opt _cell , this , opt _styleComponents ) } ; Worksheet . prototype . getCompiledStyleCustom = function ( row , col , needTable , needCell , needConditional , opt _cell ) { var res ; var styleComponents = this . sheetMergedStyles . getStyle ( this . hiddenManager , row , col , this ) ; var ws = this ; if ( ! needTable ) styleComponents . table =
[ ] ; if ( ! needConditional ) styleComponents . conditional = [ ] ; if ( ! needCell ) res = getCompiledStyle ( undefined , undefined , row , col , undefined , undefined , styleComponents ) ; else if ( opt _cell ) res = getCompiledStyle ( undefined , undefined , row , col , opt _cell , ws , styleComponents ) ; else this . _getCellNoEmpty ( row , col , function ( cell ) { res = getCompiledStyle ( undefined , undefined , row , col , cell , ws , styleComponents ) } ) ; return res } ; Worksheet . prototype . getColData = function ( index ) { var sheetMemory = this . cellsByCol [ index ] ; if ( ! sheetMemory ) { sheetMemory = new SheetMemory ( g _nCellStructSize ,
gc _nMaxRow0 ) ; this . cellsByCol [ index ] = sheetMemory } return sheetMemory } ; Worksheet . prototype . getColDataNoEmpty = function ( index ) { return this . cellsByCol [ index ] } ; Worksheet . prototype . getColDataLength = function ( ) { return this . cellsByCol . length } ; Worksheet . prototype . getSnapshot = function ( wb ) { var ws = new Worksheet ( wb , this . index , this . Id ) ; ws . sName = this . sName ; for ( var i = 0 ; i < this . TableParts . length ; ++ i ) { var table = this . TableParts [ i ] ; ws . addTablePart ( table . clone ( null ) , false ) } for ( i = 0 ; i < this . sheetViews . length ; ++ i ) ws . sheetViews . push ( this . sheetViews [ i ] . clone ( ) ) ;
return ws } ; Worksheet . prototype . addContentChanges = function ( changes ) { this . contentChanges . Add ( changes ) } ; Worksheet . prototype . refreshContentChanges = function ( ) { this . contentChanges . Refresh ( ) ; this . contentChanges . Clear ( ) } ; Worksheet . prototype . rebuildColors = function ( ) { this . rebuildTabColor ( ) ; for ( var i = 0 ; i < this . aSparklineGroups . length ; ++ i ) this . aSparklineGroups [ i ] . cleanCache ( ) } ; Worksheet . prototype . generateFontMap = function ( oFontMap ) { for ( var i = 0 , length = this . Drawings . length ; i < length ; ++ i ) { var drawing = this . Drawings [ i ] ;
if ( drawing ) drawing . getAllFonts ( oFontMap ) } if ( this . headerFooter ) this . headerFooter . getAllFonts ( oFontMap ) } ; Worksheet . prototype . getAllImageUrls = function ( aImages ) { for ( var i = 0 ; i < this . Drawings . length ; ++ i ) this . Drawings [ i ] . graphicObject . getAllRasterImages ( aImages ) } ; Worksheet . prototype . reassignImageUrls = function ( oImages ) { for ( var i = 0 ; i < this . Drawings . length ; ++ i ) this . Drawings [ i ] . graphicObject . Reassign _ImageUrls ( oImages ) } ; Worksheet . prototype . copyFrom = function ( wsFrom , sName , tableNames ) { var i , elem , range ; var t = this ;
this . sName = this . workbook . checkValidSheetName ( sName ) ? sName : this . workbook . getUniqueSheetNameFrom ( wsFrom . sName , true ) ; this . bHidden = wsFrom . bHidden ; this . oSheetFormatPr = wsFrom . oSheetFormatPr . clone ( ) ; this . nRowsCount = wsFrom . nRowsCount ; this . nColsCount = wsFrom . nColsCount ; var renameParams = { lastName : wsFrom . getName ( ) , newName : this . getName ( ) , tableNameMap : { } } ; for ( i = 0 ; i < wsFrom . TableParts . length ; ++ i ) { var tableFrom = wsFrom . TableParts [ i ] ; var tableTo = tableFrom . clone ( null ) ; if ( tableNames && tableNames . length ) tableTo . changeDisplayName ( tableNames [ i ] ) ;
else tableTo . changeDisplayName ( this . workbook . dependencyFormulas . getNextTableName ( ) ) ; this . addTablePart ( tableTo , true ) ; renameParams . tableNameMap [ tableFrom . DisplayName ] = tableTo . DisplayName } for ( i = 0 ; i < this . TableParts . length ; ++ i ) this . TableParts [ i ] . renameSheetCopy ( this , renameParams ) ; if ( wsFrom . AutoFilter ) this . AutoFilter = wsFrom . AutoFilter . clone ( ) ; for ( i in wsFrom . aCols ) { var col = wsFrom . aCols [ i ] ; if ( null != col ) this . aCols [ i ] = col . clone ( this ) } if ( null != wsFrom . oAllCol ) this . oAllCol = wsFrom . oAllCol . clone ( this ) ; this . rowsData =
wsFrom . rowsData . clone ( ) ; wsFrom . _forEachColData ( function ( sheetMemory , index ) { t . cellsByCol [ index ] = sheetMemory . clone ( ) } ) ; this . cellsByColRowsCount = wsFrom . cellsByColRowsCount ; var aMerged = wsFrom . mergeManager . getAll ( ) ; for ( i in aMerged ) { elem = aMerged [ i ] ; range = this . getRange3 ( elem . bbox . r1 , elem . bbox . c1 , elem . bbox . r2 , elem . bbox . c2 ) ; range . mergeOpen ( ) } var aHyperlinks = wsFrom . hyperlinkManager . getAll ( ) ; for ( i in aHyperlinks ) { elem = aHyperlinks [ i ] ; range = this . getRange3 ( elem . bbox . r1 , elem . bbox . c1 , elem . bbox . r2 , elem . bbox . c2 ) ;
range . setHyperlinkOpen ( elem . data ) } if ( null != wsFrom . aComments ) for ( i = 0 ; i < wsFrom . aComments . length ; i ++ ) { var comment = wsFrom . aComments [ i ] . clone ( ) ; comment . wsId = this . getId ( ) ; comment . nId = "sheet" + comment . wsId + "_" + ( i + 1 ) ; this . aComments . push ( comment ) } for ( i = 0 ; i < wsFrom . sheetViews . length ; ++ i ) this . sheetViews . push ( wsFrom . sheetViews [ i ] . clone ( ) ) ; for ( i = 0 ; i < wsFrom . aConditionalFormattingRules . length ; ++ i ) this . aConditionalFormattingRules . push ( wsFrom . aConditionalFormattingRules [ i ] . clone ( ) ) ; if ( wsFrom . dataValidations ) this . dataValidations =
wsFrom . dataValidations . clone ( ) ; if ( wsFrom . sheetPr ) this . sheetPr = wsFrom . sheetPr . clone ( ) ; this . selectionRange = wsFrom . selectionRange . clone ( this ) ; var oldNewArrayFormulaMap = [ ] ; this . _forEachCell ( function ( cell ) { if ( cell . isFormula ( ) ) { var parsed , notMainArrayCell ; if ( cell . transformSharedFormula ( ) ) parsed = cell . getFormulaParsed ( ) ; else { parsed = cell . getFormulaParsed ( ) ; if ( parsed . getArrayFormulaRef ( ) ) { var listenerId = parsed . getListenerId ( ) ; if ( oldNewArrayFormulaMap [ listenerId ] ) { parsed = oldNewArrayFormulaMap [ listenerId ] ; notMainArrayCell =
true } else { parsed = parsed . clone ( null , new CCellWithFormula ( t , cell . nRow , cell . nCol ) , t ) ; oldNewArrayFormulaMap [ listenerId ] = parsed } } else parsed = parsed . clone ( null , new CCellWithFormula ( t , cell . nRow , cell . nCol ) , t ) } if ( ! notMainArrayCell ) { parsed . renameSheetCopy ( renameParams ) ; parsed . setFormulaString ( parsed . assemble ( true ) ) } cell . setFormulaInternal ( parsed , true ) ; t . workbook . dependencyFormulas . addToBuildDependencyCell ( cell ) } } ) ; if ( wsFrom . headerFooter ) this . headerFooter = wsFrom . headerFooter . clone ( this ) ; return renameParams } ;
Worksheet . prototype . copyObjects = function ( oNewWs , wsFrom ) { var i ; if ( null != this . Drawings && this . Drawings . length > 0 ) { var drawingObjects = new AscFormat . DrawingObjects ; oNewWs . Drawings = [ ] ; AscFormat . NEW _WORKSHEET _DRAWING _DOCUMENT = oNewWs . DrawingDocument ; for ( i = 0 ; i < this . Drawings . length ; ++ i ) { var drawingObject = drawingObjects . cloneDrawingObject ( this . Drawings [ i ] ) ; drawingObject . graphicObject = this . Drawings [ i ] . graphicObject . copy ( ) ; drawingObject . graphicObject . setWorksheet ( oNewWs ) ; drawingObject . graphicObject . addToDrawingObjects ( ) ;
var drawingBase = this . Drawings [ i ] ; drawingObject . graphicObject . setDrawingBaseCoords ( drawingBase . from . col , drawingBase . from . colOff , drawingBase . from . row , drawingBase . from . rowOff , drawingBase . to . col , drawingBase . to . colOff , drawingBase . to . row , drawingBase . to . rowOff , drawingBase . Pos . X , drawingBase . Pos . Y , drawingBase . ext . cx , drawingBase . ext . cy ) ; if ( drawingObject . graphicObject . setDrawingBaseType ) drawingObject . graphicObject . setDrawingBaseType ( drawingBase . Type ) ; oNewWs . Drawings [ oNewWs . Drawings . length - 1 ] = drawingObject } AscFormat . NEW _WORKSHEET _DRAWING _DOCUMENT =
null ; drawingObjects . pushToAObjects ( oNewWs . Drawings ) ; drawingObjects . updateChartReferences2 ( parserHelp . getEscapeSheetName ( wsFrom . sName ) , parserHelp . getEscapeSheetName ( oNewWs . sName ) ) } var newSparkline ; for ( i = 0 ; i < this . aSparklineGroups . length ; ++ i ) { newSparkline = this . aSparklineGroups [ i ] . clone ( ) ; newSparkline . setWorksheet ( oNewWs , wsFrom ) ; oNewWs . aSparklineGroups . push ( newSparkline ) } } ; Worksheet . prototype . initColumn = function ( column ) { if ( column ) if ( null !== column . width && 0 !== column . width ) { column . widthPx = this . modelColWidthToColWidth ( column . width ) ;
column . charCount = this . colWidthToCharCount ( column . widthPx ) } else column . widthPx = column . charCount = null } ; Worksheet . prototype . initColumns = function ( ) { this . initColumn ( this . oAllCol ) ; this . aCols . forEach ( this . initColumn , this ) } ; Worksheet . prototype . initPostOpen = function ( handlers ) { this . PagePrintOptions . init ( ) ; this . headerFooter . init ( ) ; if ( 0 === this . sheetViews . length ) this . sheetViews . push ( new AscCommonExcel . asc _CSheetViewSettings ) ; this . hiddenManager . initPostOpen ( ) ; this . oSheetFormatPr . correction ( ) ; this . handlers = handlers ;
this . _setHandlersTablePart ( ) } ; Worksheet . prototype . _getValuesForConditionalFormatting = function ( ranges , numbers ) { var res = [ ] ; for ( var i = 0 ; i < ranges . length ; ++ i ) { var elem = ranges [ i ] ; var range = this . getRange3 ( elem . r1 , elem . c1 , elem . r2 , elem . c2 ) ; res = res . concat ( range . _getValues ( numbers ) ) } return res } ; Worksheet . prototype . _isConditionalFormattingIntersect = function ( range , ranges ) { for ( var i = 0 ; i < ranges . length ; ++ i ) if ( range . isIntersect ( ranges [ i ] ) ) return true ; return false } ; Worksheet . prototype . setDirtyConditionalFormatting =
function ( range ) { if ( ! range ) range = new AscCommonExcel . MultiplyRange ( [ new Asc . Range ( 0 , 0 , gc _nMaxCol0 , gc _nMaxRow0 ) ] ) ; if ( this . updateConditionalFormattingRange ) this . updateConditionalFormattingRange . union2 ( range ) ; else this . updateConditionalFormattingRange = range . clone ( ) } ; Worksheet . prototype . _updateConditionalFormatting = function ( ) { if ( ! this . updateConditionalFormattingRange ) return ; var range = this . updateConditionalFormattingRange ; this . updateConditionalFormattingRange = null ; var t = this ; var aRules = this . aConditionalFormattingRules . sort ( function ( v1 ,
v2 ) { return v2 . priority - v1 . priority } ) ; var oGradient1 , oGradient2 , aWeights , oRule , multiplyRange , oRuleElement , bboxCf , formulaParent , parsed1 , parsed2 ; var o , l , cell , ranges , values , value , tmp , dxf , compareFunction , nc , sum ; this . sheetMergedStyles . clearConditionalStyle ( range ) ; var getCacheFunction = function ( rule , setFunc ) { var cache = { cache : { } , get : function ( row , col ) { var cacheVal ; var cacheRow = this . cache [ row ] ; if ( ! cacheRow ) { cacheRow = { } ; this . cache [ row ] = cacheRow } else cacheVal = cacheRow [ col ] ; if ( undefined === cacheVal ) { cacheVal = this . set ( row ,
col ) ; cacheRow [ col ] = cacheVal } return cacheVal } , set : function ( row , col ) { if ( rule ) return setFunc ( row , col ) ? rule . dxf : null ; else return setFunc ( row , col ) } } ; return function ( row , col ) { return cache . get ( row , col ) } } ; for ( var i = 0 ; i < aRules . length ; ++ i ) { oRule = aRules [ i ] ; ranges = oRule . ranges ; if ( this . _isConditionalFormattingIntersect ( range , ranges ) ) { multiplyRange = new AscCommonExcel . MultiplyRange ( ranges ) ; if ( AscCommonExcel . ECfType . colorScale === oRule . type ) { if ( 1 !== oRule . aRuleElements . length ) continue ; oRuleElement = oRule . aRuleElements [ 0 ] ;
if ( ! oRuleElement || oRule . type !== oRuleElement . type ) continue ; values = this . _getValuesForConditionalFormatting ( ranges , true ) ; l = oRuleElement . aColors . length ; if ( 0 < values . length && 2 <= l ) { aWeights = [ ] ; oGradient1 = new AscCommonExcel . CGradient ( oRuleElement . aColors [ 0 ] , oRuleElement . aColors [ 1 ] ) ; aWeights . push ( oRule . getMin ( values , t ) , oRule . getMax ( values , t ) ) ; if ( 2 < l ) { oGradient2 = new AscCommonExcel . CGradient ( oRuleElement . aColors [ 1 ] , oRuleElement . aColors [ 2 ] ) ; aWeights . push ( oRule . getMid ( values , t ) ) ; aWeights . sort ( AscCommon . fSortAscending ) ;
oGradient1 . init ( aWeights [ 0 ] , aWeights [ 1 ] ) ; oGradient2 . init ( aWeights [ 1 ] , aWeights [ 2 ] ) } else { oGradient2 = null ; aWeights . sort ( AscCommon . fSortAscending ) ; oGradient1 . init ( aWeights [ 0 ] , aWeights [ 1 ] ) } compareFunction = function ( oGradient1 , oGradient2 ) { return function ( row , col ) { var val , color , gradient ; t . _getCellNoEmpty ( row , col , function ( cell ) { val = cell && cell . getNumberValue ( ) } ) ; dxf = null ; if ( null !== val ) { dxf = new AscCommonExcel . CellXfs ; gradient = oGradient2 ? oGradient2 : oGradient1 ; if ( val >= gradient . max ) color = gradient . getMaxColor ( ) ;
else if ( val <= oGradient1 . min ) color = oGradient1 . getMinColor ( ) ; else { gradient = oGradient2 && val > oGradient1 . max ? oGradient2 : oGradient1 ; color = gradient . calculateColor ( val ) } dxf . fill = new AscCommonExcel . Fill ; dxf . fill . fromColor ( color ) ; dxf = g _StyleCache . addXf ( dxf , true ) } return dxf } } ( oGradient1 , oGradient2 ) } } else if ( AscCommonExcel . ECfType . dataBar === oRule . type ) continue ; else if ( AscCommonExcel . ECfType . top10 === oRule . type ) { if ( oRule . rank > 0 && oRule . dxf ) { nc = 0 ; values = this . _getValuesForConditionalFormatting ( ranges , false ) ; o = oRule . bottom ?
Number . MAX _VALUE : - Number . MAX _VALUE ; for ( cell = 0 ; cell < values . length ; ++ cell ) { value = values [ cell ] ; if ( CellValueType . Number === value . type && ! isNaN ( tmp = parseFloat ( value . v ) ) ) { ++ nc ; value . v = tmp } else value . v = o } values . sort ( function ( condition ) { return function ( v1 , v2 ) { return condition * ( v2 . v - v1 . v ) } } ( oRule . bottom ? - 1 : 1 ) ) ; nc = Math . max ( 1 , oRule . percent ? Math . floor ( nc * oRule . rank / 100 ) : oRule . rank ) ; var threshold = values . length >= nc ? values [ nc - 1 ] . v : o ; compareFunction = function ( rule , threshold ) { return function ( row , col ) { var val ; t . _getCellNoEmpty ( row ,
col , function ( cell ) { val = cell ? cell . getNumberValue ( ) : null } ) ; return null !== val && ( rule . bottom ? val <= threshold : val >= threshold ) ? rule . dxf : null } } ( oRule , threshold ) } } else if ( AscCommonExcel . ECfType . aboveAverage === oRule . type ) { if ( ! oRule . dxf ) continue ; values = this . _getValuesForConditionalFormatting ( ranges , false ) ; sum = 0 ; nc = 0 ; for ( cell = 0 ; cell < values . length ; ++ cell ) { value = values [ cell ] ; if ( CellValueType . Number === value . type && ! isNaN ( tmp = parseFloat ( value . v ) ) ) { ++ nc ; value . v = tmp ; sum += tmp } else value . v = null } tmp = sum / nc ; compareFunction =
function ( rule , average , stdDev ) { return function ( row , col ) { var val ; t . _getCellNoEmpty ( row , col , function ( cell ) { val = cell ? cell . getNumberValue ( ) : null } ) ; return null !== val && rule . getAverage ( val , average , stdDev ) ? rule . dxf : null } } ( oRule , tmp , sum ) } else { if ( ! oRule . dxf ) continue ; switch ( oRule . type ) { case AscCommonExcel . ECfType . duplicateValues : case AscCommonExcel . ECfType . uniqueValues : o = getUniqueKeys ( this . _getValuesForConditionalFormatting ( ranges , false ) ) ; compareFunction = function ( rule , obj , condition ) { return function ( row , col ) { var val ;
t . _getCellNoEmpty ( row , col , function ( cell ) { val = cell ? cell . getValueWithoutFormat ( ) : "" } ) ; return ( val . length > 0 ? condition === obj [ val ] : false ) ? rule . dxf : null } } ( oRule , o , oRule . type === AscCommonExcel . ECfType . duplicateValues ) ; break ; case AscCommonExcel . ECfType . containsText : case AscCommonExcel . ECfType . notContainsText : case AscCommonExcel . ECfType . beginsWith : case AscCommonExcel . ECfType . endsWith : var operator ; switch ( oRule . type ) { case AscCommonExcel . ECfType . containsText : operator = AscCommonExcel . ECfOperator . Operator _containsText ;
break ; case AscCommonExcel . ECfType . notContainsText : operator = AscCommonExcel . ECfOperator . Operator _notContains ; break ; case AscCommonExcel . ECfType . beginsWith : operator = AscCommonExcel . ECfOperator . Operator _beginsWith ; break ; case AscCommonExcel . ECfType . endsWith : operator = AscCommonExcel . ECfOperator . Operator _endsWith ; break } formulaParent = new AscCommonExcel . CConditionalFormattingFormulaParent ( this , oRule , true ) ; oRuleElement = oRule . getFormulaCellIs ( ) ; parsed1 = oRuleElement && oRuleElement . getFormula && oRuleElement . getFormula ( this ,
formulaParent ) ; if ( parsed1 && parsed1 . hasRelativeRefs ( ) ) { bboxCf = oRule . getBBox ( ) ; compareFunction = getCacheFunction ( oRule , function ( rule , operator , formulaParent , rowLT , colLT ) { return function ( row , col ) { var offset = new AscCommon . CellBase ( row - rowLT , col - colLT ) ; var bboxCell = new Asc . Range ( col , row , col , row ) ; var v1 = rule . getValueCellIs ( t , formulaParent , bboxCell , offset , false ) ; var res ; t . _getCellNoEmpty ( row , col , function ( cell ) { res = rule . cellIs ( operator , cell , v1 ) ? rule . dxf : null } ) ; return res } } ( oRule , operator , new AscCommonExcel . CConditionalFormattingFormulaParent ( this ,
oRule , true ) , bboxCf ? bboxCf . r1 : 0 , bboxCf ? bboxCf . c1 : 0 ) ) } else compareFunction = function ( rule , operator , v1 ) { return function ( row , col ) { var res ; t . _getCellNoEmpty ( row , col , function ( cell ) { res = rule . cellIs ( operator , cell , v1 ) ? rule . dxf : null } ) ; return res } } ( oRule , operator , oRule . getValueCellIs ( this ) ) ; break ; case AscCommonExcel . ECfType . containsErrors : compareFunction = function ( rule ) { return function ( row , col ) { var val ; t . _getCellNoEmpty ( row , col , function ( cell ) { val = cell ? CellValueType . Error === cell . getType ( ) : false } ) ; return val ? rule . dxf :
null } } ( oRule ) ; break ; case AscCommonExcel . ECfType . notContainsErrors : compareFunction = function ( rule ) { return function ( row , col ) { var val ; t . _getCellNoEmpty ( row , col , function ( cell ) { val = cell ? CellValueType . Error !== cell . getType ( ) : true } ) ; return val ? rule . dxf : null } } ( oRule ) ; break ; case AscCommonExcel . ECfType . containsBlanks : compareFunction = function ( rule ) { return function ( row , col ) { var val ; t . _getCellNoEmpty ( row , col , function ( cell ) { if ( cell ) val = "" === cell . getValueWithoutFormat ( ) . replace ( /^ +| +$/g , "" ) ; else val = true } ) ; return val ?
rule . dxf : null } } ( oRule ) ; break ; case AscCommonExcel . ECfType . notContainsBlanks : compareFunction = function ( rule ) { return function ( row , col ) { var val ; t . _getCellNoEmpty ( row , col , function ( cell ) { if ( cell ) val = "" !== cell . getValueWithoutFormat ( ) . replace ( /^ +| +$/g , "" ) ; else val = false } ) ; return val ? rule . dxf : null } } ( oRule ) ; break ; case AscCommonExcel . ECfType . timePeriod : if ( oRule . timePeriod ) compareFunction = function ( rule , period ) { return function ( row , col ) { var val ; t . _getCellNoEmpty ( row , col , function ( cell ) { val = cell ? cell . getValueWithoutFormat ( ) :
"" } ) ; var n = parseFloat ( val ) ; return period . start <= n && n < period . end ? rule . dxf : null } } ( oRule , oRule . getTimePeriod ( ) ) ; else continue ; break ; case AscCommonExcel . ECfType . cellIs : formulaParent = new AscCommonExcel . CConditionalFormattingFormulaParent ( this , oRule , true ) ; oRuleElement = oRule . aRuleElements [ 0 ] ; parsed1 = oRuleElement && oRuleElement . getFormula && oRuleElement . getFormula ( this , formulaParent ) ; oRuleElement = oRule . aRuleElements [ 1 ] ; parsed2 = oRuleElement && oRuleElement . getFormula && oRuleElement . getFormula ( this , formulaParent ) ;
if ( parsed1 && parsed1 . hasRelativeRefs ( ) || parsed2 && parsed2 . hasRelativeRefs ( ) ) { bboxCf = oRule . getBBox ( ) ; compareFunction = getCacheFunction ( oRule , function ( rule , ruleElem1 , ruleElem2 , formulaParent , rowLT , colLT ) { return function ( row , col ) { var offset = new AscCommon . CellBase ( row - rowLT , col - colLT ) ; var bboxCell = new Asc . Range ( col , row , col , row ) ; var v1 = ruleElem1 && ruleElem1 . getValue ( t , formulaParent , bboxCell , offset , false ) ; var v2 = ruleElem2 && ruleElem2 . getValue ( t , formulaParent , bboxCell , offset , false ) ; var res ; t . _getCellNoEmpty ( row ,
col , function ( cell ) { res = rule . cellIs ( rule . operator , cell , v1 , v2 ) ? rule . dxf : null } ) ; return res } } ( oRule , oRule . aRuleElements [ 0 ] , oRule . aRuleElements [ 1 ] , new AscCommonExcel . CConditionalFormattingFormulaParent ( this , oRule , true ) , bboxCf ? bboxCf . r1 : 0 , bboxCf ? bboxCf . c1 : 0 ) ) } else compareFunction = function ( rule , v1 , v2 ) { return function ( row , col ) { var res ; t . _getCellNoEmpty ( row , col , function ( cell ) { res = rule . cellIs ( rule . operator , cell , v1 , v2 ) ? rule . dxf : null } ) ; return res } } ( oRule , oRule . aRuleElements [ 0 ] && oRule . aRuleElements [ 0 ] . getValue ( this ) ,
oRule . aRuleElements [ 1 ] && oRule . aRuleElements [ 1 ] . getValue ( this ) ) ; break ; case AscCommonExcel . ECfType . expression : bboxCf = oRule . getBBox ( ) ; compareFunction = getCacheFunction ( oRule , function ( rule , formulaCF , formulaParent , rowLT , colLT ) { return function ( row , col ) { var offset = new AscCommon . CellBase ( row - rowLT , col - colLT ) ; var bboxCell = new Asc . Range ( col , row , col , row ) ; var res = formulaCF && formulaCF . getValue ( t , formulaParent , bboxCell , offset , true ) ; if ( res && res . tocBool ) { res = res . tocBool ( ) ; if ( res && res . toBool ) return res . toBool ( ) } return false } } ( oRule ,
oRule . aRuleElements [ 0 ] , new AscCommonExcel . CConditionalFormattingFormulaParent ( this , oRule , true ) , bboxCf ? bboxCf . r1 : 0 , bboxCf ? bboxCf . c1 : 0 ) ) ; break ; default : continue ; break } } if ( compareFunction ) this . sheetMergedStyles . setConditionalStyle ( multiplyRange , compareFunction ) } } } ; Worksheet . prototype . _forEachRow = function ( fAction ) { this . getRange3 ( 0 , 0 , gc _nMaxRow0 , 0 ) . _foreachRowNoEmpty ( fAction ) } ; Worksheet . prototype . _forEachCol = function ( fAction ) { this . getRange3 ( 0 , 0 , 0 , gc _nMaxCol0 ) . _foreachColNoEmpty ( fAction ) } ; Worksheet . prototype . _forEachColData =
function ( fAction ) { for ( var i = 0 ; i < this . cellsByCol . length ; ++ i ) { var sheetMemory = this . cellsByCol [ i ] ; if ( sheetMemory ) fAction ( sheetMemory , i ) } } ; Worksheet . prototype . _forEachCell = function ( fAction ) { this . getRange3 ( 0 , 0 , gc _nMaxRow0 , gc _nMaxCol0 ) . _foreachNoEmpty ( fAction ) } ; Worksheet . prototype . getId = function ( ) { return this . Id } ; Worksheet . prototype . getIndex = function ( ) { return this . index } ; Worksheet . prototype . getName = function ( ) { return this . sName !== undefined && this . sName . length > 0 ? this . sName : "" } ; Worksheet . prototype . setName =
function ( name , bFromUndoRedo ) { if ( name . length <= g _nSheetNameMaxLength ) { var lastName = this . sName ; History . Create _NewPoint ( ) ; var prepared = this . workbook . dependencyFormulas . prepareChangeSheet ( this . getId ( ) , { rename : { from : lastName , to : name } } ) ; this . sName = name ; this . workbook . dependencyFormulas . changeSheet ( prepared ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _Rename , this . getId ( ) , null , new UndoRedoData _FromTo ( lastName , name ) ) ; if ( ! bFromUndoRedo ) { var _lastName = parserHelp . getEscapeSheetName ( lastName ) ;
var _newName = parserHelp . getEscapeSheetName ( this . sName ) ; for ( var key in this . workbook . aWorksheets ) { var wsModel = this . workbook . aWorksheets [ key ] ; if ( wsModel ) wsModel . oDrawingOjectsManager . updateChartReferencesWidthHistory ( _lastName , _newName , true ) } } this . workbook . dependencyFormulas . calcTree ( ) } else console . log ( new Error ( "The sheet name must be less than 31 characters." ) ) } ; Worksheet . prototype . getTabColor = function ( ) { return this . sheetPr && this . sheetPr . TabColor ? Asc . colorObjToAscColor ( this . sheetPr . TabColor ) : null } ;
Worksheet . prototype . setTabColor = function ( color ) { if ( ! this . sheetPr ) this . sheetPr = new AscCommonExcel . asc _CSheetPr ; History . Create _NewPoint ( ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _SetTabColor , this . getId ( ) , null , new UndoRedoData _FromTo ( this . sheetPr . TabColor ? this . sheetPr . TabColor . clone ( ) : null , color ? color . clone ( ) : null ) ) ; this . sheetPr . TabColor = color ; if ( ! this . workbook . bUndoChanges && ! this . workbook . bRedoChanges ) this . workbook . handlers . trigger ( "asc_onUpdateTabColor" , this . getIndex ( ) ) } ;
Worksheet . prototype . rebuildTabColor = function ( ) { if ( this . sheetPr && this . sheetPr . TabColor ) this . workbook . handlers . trigger ( "asc_onUpdateTabColor" , this . getIndex ( ) ) } ; Worksheet . prototype . getHidden = function ( ) { return true === this . bHidden } ; Worksheet . prototype . setHidden = function ( hidden ) { var bOldHidden = this . bHidden , wb = this . workbook , wsActive = wb . getActiveWs ( ) , oVisibleWs = null ; this . bHidden = hidden ; if ( true == this . bHidden && this . getIndex ( ) == wsActive . getIndex ( ) ) { oVisibleWs = wb . findSheetNoHidden ( this . getIndex ( ) ) ; if ( null != oVisibleWs ) { var nNewIndex =
oVisibleWs . getIndex ( ) ; wb . setActive ( nNewIndex ) ; if ( ! wb . bUndoChanges && ! wb . bRedoChanges ) wb . handlers . trigger ( "undoRedoHideSheet" , nNewIndex ) } } if ( bOldHidden != hidden ) { History . Create _NewPoint ( ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _Hide , this . getId ( ) , null , new UndoRedoData _FromTo ( bOldHidden , hidden ) ) ; if ( null != oVisibleWs ) { History . SetSheetUndo ( wsActive . getId ( ) ) ; History . SetSheetRedo ( oVisibleWs . getId ( ) ) } } } ; Worksheet . prototype . getSheetView = function ( ) { return this . sheetViews [ 0 ] } ;
Worksheet . prototype . getSheetViewSettings = function ( ) { return this . sheetViews [ 0 ] . clone ( ) } ; Worksheet . prototype . setDisplayGridlines = function ( value ) { var view = this . sheetViews [ 0 ] ; if ( value !== view . showGridLines ) { History . Create _NewPoint ( ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _SetDisplayGridlines , this . getId ( ) , null , new UndoRedoData _FromTo ( view . showGridLines , value ) ) ; view . showGridLines = value ; if ( ! this . workbook . bUndoChanges && ! this . workbook . bRedoChanges ) this . workbook . handlers . trigger ( "asc_onUpdateSheetViewSettings" ) } } ;
Worksheet . prototype . setDisplayHeadings = function ( value ) { var view = this . sheetViews [ 0 ] ; if ( value !== view . showRowColHeaders ) { History . Create _NewPoint ( ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _SetDisplayHeadings , this . getId ( ) , null , new UndoRedoData _FromTo ( view . showRowColHeaders , value ) ) ; view . showRowColHeaders = value ; if ( ! this . workbook . bUndoChanges && ! this . workbook . bRedoChanges ) this . workbook . handlers . trigger ( "asc_onUpdateSheetViewSettings" ) } } ; Worksheet . prototype . getRowsCount = function ( ) { var result =
this . nRowsCount ; var pane = this . sheetViews . length && this . sheetViews [ 0 ] . pane ; if ( pane && pane . topLeftFrozenCell ) result = Math . max ( result , pane . topLeftFrozenCell . getRow0 ( ) ) ; return result } ; Worksheet . prototype . removeRows = function ( start , stop , bExcludeHiddenRows ) { var removeRowsArr = bExcludeHiddenRows ? this . _getNoHiddenRowsArr ( start , stop ) : [ { start : start , stop : stop } ] ; for ( var i = removeRowsArr . length - 1 ; i >= 0 ; i -- ) { var oRange = this . getRange ( new CellAddress ( removeRowsArr [ i ] . start , 0 , 0 ) , new CellAddress ( removeRowsArr [ i ] . stop , gc _nMaxCol0 ,
0 ) ) ; oRange . deleteCellsShiftUp ( ) } } ; Worksheet . prototype . _getNoHiddenRowsArr = function ( start , stop ) { var res = [ ] ; var elem = null ; for ( var i = start ; i <= stop ; i ++ ) if ( this . getRowHidden ( i ) ) { if ( elem ) { res . push ( elem ) ; elem = null } } else { if ( ! elem ) { elem = { } ; elem . start = i ; elem . stop = i } else elem . stop ++ ; if ( i === stop ) res . push ( elem ) } return res } ; Worksheet . prototype . _updateFormulasParents = function ( r1 , c1 , r2 , c2 , bbox , offset , shiftedShared ) { var t = this ; var cellWithFormula ; var shiftedArrayFormula = { } ; this . getRange3 ( r1 , c1 , r2 , c2 ) . _foreachNoEmpty ( function ( cell ) { var newNRow =
cell . nRow + offset . row ; var newNCol = cell . nCol + offset . col ; var bHor = 0 !== offset . col ; var toDelete = offset . col < 0 || offset . row < 0 ; if ( cell . isFormula ( ) ) { var processed = c _oSharedShiftType . NeedTransform ; var parsed = cell . getFormulaParsed ( ) ; var shared = parsed . getShared ( ) ; var arrayFormula = parsed . getArrayFormulaRef ( ) ; var formulaRefObj = null ; if ( shared ) { processed = shiftedShared [ parsed . getListenerId ( ) ] ; var isPreProcessed = c _oSharedShiftType . PreProcessed === processed ; if ( ! processed || isPreProcessed ) { if ( ! processed ) { var bboxShift =
AscCommonExcel . shiftGetBBox ( bbox , bHor ) ; if ( bboxShift . containsRange ( shared . ref ) && ( ! toDelete || ! bbox . isIntersect ( shared . ref ) ) ) processed = c _oSharedShiftType . Processed ; else processed = c _oSharedShiftType . NeedTransform } else if ( isPreProcessed ) processed = c _oSharedShiftType . Processed ; if ( c _oSharedShiftType . Processed === processed ) { var newRef = shared . ref . clone ( ) ; newRef . forShift ( bbox , offset , t . workbook . bUndoChanges ) ; parsed . setSharedRef ( newRef , ! isPreProcessed ) ; t . workbook . dependencyFormulas . addToChangedRange2 ( t . getId ( ) ,
newRef ) } shiftedShared [ parsed . getListenerId ( ) ] = processed } } else if ( arrayFormula ) if ( ! shiftedArrayFormula [ parsed . getListenerId ( ) ] && parsed . checkFirstCellArray ( cell ) ) { shiftedArrayFormula [ parsed . getListenerId ( ) ] = 1 ; var newArrayRef = arrayFormula . clone ( ) ; newArrayRef . setOffset ( offset ) ; parsed . setArrayFormulaRef ( newArrayRef ) } else processed = c _oSharedShiftType . Processed ; if ( c _oSharedShiftType . NeedTransform === processed ) { var isTransform = cell . transformSharedFormula ( ) ; parsed = cell . getFormulaParsed ( ) ; if ( isTransform ) parsed . buildDependencies ( ) ;
cellWithFormula = parsed . getParent ( ) ; cellWithFormula . nRow = newNRow ; cellWithFormula . nCol = newNCol ; t . workbook . dependencyFormulas . addToChangedCell ( cellWithFormula ) } } t . cellsByColRowsCount = Math . max ( t . cellsByColRowsCount , newNRow + 1 ) ; t . nRowsCount = Math . max ( t . nRowsCount , t . cellsByColRowsCount ) ; t . nColsCount = Math . max ( t . nColsCount , newNCol + 1 ) } ) } ; Worksheet . prototype . _removeRows = function ( start , stop ) { var t = this ; this . workbook . dependencyFormulas . lockRecal ( ) ; History . Create _NewPoint ( ) ; var nDif = - ( stop - start + 1 ) ; var oActualRange =
new Asc . Range ( 0 , start , gc _nMaxCol0 , stop ) ; var offset = new AscCommon . CellBase ( nDif , 0 ) ; var renameRes = this . renameDependencyNodes ( offset , oActualRange ) ; var redrawTablesArr = this . autoFilters . insertRows ( "delCell" , oActualRange , c _oAscDeleteOptions . DeleteRows ) ; this . updatePivotOffset ( oActualRange , offset ) ; var collapsedInfo = null , lastRowIndex ; var oDefRowPr = new AscCommonExcel . UndoRedoData _RowProp ; this . getRange3 ( start , 0 , stop , gc _nMaxCol0 ) . _foreachRowNoEmpty ( function ( row ) { var oOldProps = row . getHeightProp ( ) ; lastRowIndex =
row . index ; if ( false === oOldProps . isEqual ( oDefRowPr ) ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _RowProp , t . getId ( ) , row . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( row . getIndex ( ) , true , oOldProps , oDefRowPr ) ) ; row . setStyle ( null ) ; if ( ! t . workbook . bRedoChanges ) { if ( collapsedInfo !== null && collapsedInfo < row . getOutlineLevel ( ) ) collapsedInfo = null ; if ( row . getCollapsed ( ) ) { collapsedInfo = row . getOutlineLevel ( ) ; t . setCollapsedRow ( false , null , row ) } } } , function ( cell ) { t . _removeCell ( null , null ,
cell ) } ) ; if ( collapsedInfo !== null && lastRowIndex === stop ) this . _getRow ( stop + 1 , function ( row ) { t . setCollapsedRow ( true , null , row ) } ) ; this . _updateFormulasParents ( start , 0 , gc _nMaxRow0 , gc _nMaxCol0 , oActualRange , offset , renameRes . shiftedShared ) ; this . rowsData . deleteRange ( start , - nDif ) ; this . _forEachColData ( function ( sheetMemory ) { sheetMemory . deleteRange ( start , - nDif ) } ) ; this . workbook . dependencyFormulas . notifyChanged ( renameRes . changed ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _RemoveRows ,
this . getId ( ) , new Asc . Range ( 0 , start , gc _nMaxCol0 , gc _nMaxRow0 ) , new UndoRedoData _FromToRowCol ( true , start , stop ) ) ; this . autoFilters . redrawStylesTables ( redrawTablesArr ) ; this . workbook . dependencyFormulas . unlockRecal ( ) ; return true } ; Worksheet . prototype . insertRowsBefore = function ( index , count ) { var oRange = this . getRange ( new CellAddress ( index , 0 , 0 ) , new CellAddress ( index + count - 1 , gc _nMaxCol0 , 0 ) ) ; oRange . addCellsShiftBottom ( ) } ; Worksheet . prototype . _getBordersForInsert = function ( bbox , bRow ) { var t = this ; var borders = { } ; var offsetRow =
bRow && bbox . r1 > 0 ? - 1 : 0 ; var offsetCol = ! bRow && bbox . c1 > 0 ? - 1 : 0 ; var r2 = bRow ? bbox . r1 : bbox . r2 ; var c2 = ! bRow ? bbox . c1 : bbox . c2 ; if ( 0 !== offsetRow || 0 !== offsetCol ) this . getRange3 ( bbox . r1 , bbox . c1 , r2 , c2 ) . _foreachNoEmpty ( function ( cell ) { if ( cell . xfs && cell . xfs . border ) t . _getCellNoEmpty ( cell . nRow + offsetRow , cell . nCol + offsetCol , function ( neighbor ) { if ( neighbor && neighbor . xfs && neighbor . xfs . border ) { var newBorder = neighbor . xfs . border . clone ( ) ; newBorder . intersect ( cell . xfs . border , g _oDefaultFormat . BorderAbs , true ) ; borders [ bRow ? cell . nCol :
cell . nRow ] = newBorder } } ) } ) ; return borders } ; Worksheet . prototype . _insertRowsBefore = function ( index , count ) { var t = this ; this . workbook . dependencyFormulas . lockRecal ( ) ; var oActualRange = new Asc . Range ( 0 , index , gc _nMaxCol0 , index + count - 1 ) ; History . Create _NewPoint ( ) ; var offset = new AscCommon . CellBase ( count , 0 ) ; var renameRes = this . renameDependencyNodes ( offset , oActualRange ) ; var redrawTablesArr = this . autoFilters . insertRows ( "insCell" , oActualRange , c _oAscInsertOptions . InsertColumns ) ; this . updatePivotOffset ( oActualRange , offset ) ;
this . _updateFormulasParents ( index , 0 , gc _nMaxRow0 , gc _nMaxCol0 , oActualRange , offset , renameRes . shiftedShared ) ; var borders ; if ( index > 0 && ! this . workbook . bUndoChanges ) borders = this . _getBordersForInsert ( oActualRange , true ) ; this . rowsData . insertRange ( index , count ) ; this . nRowsCount = Math . max ( this . nRowsCount , this . rowsData . getSize ( ) ) ; this . _forEachColData ( function ( sheetMemory ) { sheetMemory . insertRange ( index , count ) ; t . cellsByColRowsCount = Math . max ( t . cellsByColRowsCount , sheetMemory . getSize ( ) ) } ) ; this . nRowsCount = Math . max ( this . nRowsCount ,
this . cellsByColRowsCount ) ; if ( index > 0 && ! this . workbook . bUndoChanges ) { this . rowsData . copyRangeByChunk ( index - 1 , 1 , index , count ) ; this . nRowsCount = Math . max ( this . nRowsCount , this . rowsData . getSize ( ) ) ; this . _forEachColData ( function ( sheetMemory ) { sheetMemory . copyRangeByChunk ( index - 1 , 1 , index , count ) ; t . cellsByColRowsCount = Math . max ( t . cellsByColRowsCount , sheetMemory . getSize ( ) ) } ) ; this . nRowsCount = Math . max ( this . nRowsCount , this . cellsByColRowsCount ) ; this . getRange3 ( index , 0 , index + count - 1 , gc _nMaxCol0 ) . _foreachRowNoEmpty ( function ( row ) { row . setHidden ( false ) } ,
function ( cell ) { cell . clearDataKeepXf ( borders [ cell . nCol ] ) } ) } this . workbook . dependencyFormulas . notifyChanged ( renameRes . changed ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _AddRows , this . getId ( ) , new Asc . Range ( 0 , index , gc _nMaxCol0 , gc _nMaxRow0 ) , new UndoRedoData _FromToRowCol ( true , index , index + count - 1 ) ) ; this . autoFilters . redrawStylesTables ( redrawTablesArr ) ; this . workbook . dependencyFormulas . unlockRecal ( ) ; return true } ; Worksheet . prototype . insertRowsAfter = function ( index , count ) { return this . insertRowsBefore ( index +
1 , count ) } ; Worksheet . prototype . getColsCount = function ( ) { var result = this . nColsCount ; var pane = this . sheetViews . length && this . sheetViews [ 0 ] . pane ; if ( pane && pane . topLeftFrozenCell ) result = Math . max ( result , pane . topLeftFrozenCell . getCol0 ( ) ) ; return result } ; Worksheet . prototype . removeCols = function ( start , stop ) { var oRange = this . getRange ( new CellAddress ( 0 , start , 0 ) , new CellAddress ( gc _nMaxRow0 , stop , 0 ) ) ; oRange . deleteCellsShiftLeft ( ) } ; Worksheet . prototype . _removeCols = function ( start , stop ) { var t = this ; this . workbook . dependencyFormulas . lockRecal ( ) ;
History . Create _NewPoint ( ) ; var nDif = - ( stop - start + 1 ) , i , j , length ; var oActualRange = new Asc . Range ( start , 0 , stop , gc _nMaxRow0 ) ; var offset = new AscCommon . CellBase ( 0 , nDif ) ; var renameRes = this . renameDependencyNodes ( offset , oActualRange ) ; var redrawTablesArr = this . autoFilters . insertColumn ( oActualRange , nDif ) ; this . updatePivotOffset ( oActualRange , offset ) ; var collapsedInfo = null , lastRowIndex ; var oDefColPr = new AscCommonExcel . UndoRedoData _ColProp ; this . getRange3 ( 0 , start , gc _nMaxRow0 , stop ) . _foreachColNoEmpty ( function ( col ) { var nIndex =
col . getIndex ( ) ; var oOldProps = col . getWidthProp ( ) ; if ( false === oOldProps . isEqual ( oDefColPr ) ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _ColProp , t . getId ( ) , new Asc . Range ( nIndex , 0 , nIndex , gc _nMaxRow0 ) , new UndoRedoData _IndexSimpleProp ( nIndex , false , oOldProps , oDefColPr ) ) ; col . setStyle ( null ) ; lastRowIndex = col . index ; if ( ! t . workbook . bRedoChanges ) { if ( collapsedInfo !== null && collapsedInfo < col . getOutlineLevel ( ) ) collapsedInfo = null ; if ( col . getCollapsed ( ) ) { collapsedInfo = col . getOutlineLevel ( ) ;
t . setCollapsedCol ( false , null , col ) } } } , function ( cell ) { t . _removeCell ( null , null , cell ) } ) ; if ( collapsedInfo !== null && lastRowIndex === stop ) { var curCol = this . _getCol ( stop + 1 ) ; if ( curCol ) t . setCollapsedCol ( true , null , curCol ) } this . _updateFormulasParents ( 0 , start , gc _nMaxRow0 , gc _nMaxCol0 , oActualRange , offset , renameRes . shiftedShared ) ; this . cellsByCol . splice ( start , stop - start + 1 ) ; this . aCols . splice ( start , stop - start + 1 ) ; for ( i = start , length = this . aCols . length ; i < length ; ++ i ) { var elem = this . aCols [ i ] ; if ( null != elem ) elem . moveHor ( nDif ) } this . workbook . dependencyFormulas . notifyChanged ( renameRes . changed ) ;
History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _RemoveCols , this . getId ( ) , new Asc . Range ( start , 0 , gc _nMaxCol0 , gc _nMaxRow0 ) , new UndoRedoData _FromToRowCol ( false , start , stop ) ) ; this . autoFilters . redrawStylesTables ( redrawTablesArr ) ; this . workbook . dependencyFormulas . unlockRecal ( ) ; return true } ; Worksheet . prototype . insertColsBefore = function ( index , count ) { var oRange = this . getRange3 ( 0 , index , gc _nMaxRow0 , index + count - 1 ) ; oRange . addCellsShiftRight ( ) } ; Worksheet . prototype . _insertColsBefore = function ( index ,
count ) { this . workbook . dependencyFormulas . lockRecal ( ) ; var oActualRange = new Asc . Range ( index , 0 , index + count - 1 , gc _nMaxRow0 ) ; History . Create _NewPoint ( ) ; var offset = new AscCommon . CellBase ( 0 , count ) ; var renameRes = this . renameDependencyNodes ( offset , oActualRange ) ; var redrawTablesArr = this . autoFilters . insertColumn ( oActualRange , count ) ; this . updatePivotOffset ( oActualRange , offset ) ; this . _updateFormulasParents ( 0 , index , gc _nMaxRow0 , gc _nMaxCol0 , oActualRange , offset , renameRes . shiftedShared ) ; var borders ; if ( index > 0 && ! this . workbook . bUndoChanges ) borders =
this . _getBordersForInsert ( oActualRange , false ) ; this . cellsByCol . splice ( gc _nMaxCol0 - count + 1 , count ) ; for ( var i = this . cellsByCol . length - 1 ; i >= index ; -- i ) { this . cellsByCol [ i + count ] = this . cellsByCol [ i ] ; this . cellsByCol [ i ] = undefined } this . nColsCount = Math . max ( this . nColsCount , this . getColDataLength ( ) ) ; this . aCols . splice ( gc _nMaxCol0 - count + 1 , count ) ; for ( var i = this . aCols . length - 1 ; i >= index ; -- i ) { this . aCols [ i + count ] = this . aCols [ i ] ; this . aCols [ i ] = undefined ; if ( this . aCols [ i + count ] ) this . aCols [ i + count ] . moveHor ( count ) } this . nColsCount =
Math . max ( this . nColsCount , this . aCols . length ) ; if ( ! this . workbook . bUndoChanges ) { var oPrevCol = null ; if ( index > 0 ) oPrevCol = this . aCols [ index - 1 ] ; if ( null == oPrevCol && null != this . oAllCol ) oPrevCol = this . oAllCol ; if ( null != oPrevCol ) { History . LocalChange = true ; for ( var i = index ; i < index + count ; ++ i ) { var oNewCol = oPrevCol . clone ( ) ; oNewCol . setHidden ( null ) ; oNewCol . BestFit = null ; oNewCol . index = i ; this . aCols [ i ] = oNewCol } History . LocalChange = false } var prevCellsByCol = index > 0 ? this . cellsByCol [ index - 1 ] : null ; if ( prevCellsByCol ) { for ( var i = index ; i <
index + count ; ++ i ) this . cellsByCol [ i ] = prevCellsByCol . clone ( ) ; this . nColsCount = Math . max ( this . nColsCount , this . getColDataLength ( ) ) ; this . getRange3 ( 0 , index , gc _nMaxRow0 , index + count - 1 ) . _foreachNoEmpty ( function ( cell ) { cell . clearDataKeepXf ( borders [ cell . nRow ] ) } ) } } this . workbook . dependencyFormulas . notifyChanged ( renameRes . changed ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _AddCols , this . getId ( ) , new Asc . Range ( index , 0 , gc _nMaxCol0 , gc _nMaxRow0 ) , new UndoRedoData _FromToRowCol ( false , index ,
index + count - 1 ) ) ; this . autoFilters . redrawStylesTables ( redrawTablesArr ) ; this . workbook . dependencyFormulas . unlockRecal ( ) ; return true } ; Worksheet . prototype . insertColsAfter = function ( index , count ) { return this . insertColsBefore ( index + 1 , count ) } ; Worksheet . prototype . getDefaultWidth = function ( ) { return this . oSheetFormatPr . dDefaultColWidth } ; Worksheet . prototype . getDefaultFontName = function ( ) { return this . workbook . getDefaultFont ( ) } ; Worksheet . prototype . getDefaultFontSize = function ( ) { return this . workbook . getDefaultSize ( ) } ;
Worksheet . prototype . getBaseColWidth = function ( ) { return this . oSheetFormatPr . nBaseColWidth || 8 } ; Worksheet . prototype . charCountToModelColWidth = function ( count ) { return this . workbook . charCountToModelColWidth ( count ) } ; Worksheet . prototype . modelColWidthToColWidth = function ( mcw ) { return this . workbook . modelColWidthToColWidth ( mcw ) } ; Worksheet . prototype . colWidthToCharCount = function ( w ) { return this . workbook . colWidthToCharCount ( w ) } ; Worksheet . prototype . getColWidth = function ( index ) { var col = this . _getColNoEmptyWithAll ( index ) ;
if ( null != col && null != col . width ) return col . width ; var dResult = this . oSheetFormatPr . dDefaultColWidth ; if ( dResult === undefined || dResult === null || dResult == 0 ) dResult = - 1 ; return dResult } ; Worksheet . prototype . setColWidth = function ( width , start , stop ) { width = this . charCountToModelColWidth ( width ) ; if ( 0 == width ) return this . setColHidden ( true , start , stop ) ; if ( null == start ) return ; if ( null == stop ) stop = start ; History . Create _NewPoint ( ) ; var oSelection = History . GetSelection ( ) ; if ( null != oSelection ) { oSelection = oSelection . clone ( ) ; oSelection . assign ( start ,
0 , stop , gc _nMaxRow0 ) ; History . SetSelection ( oSelection ) ; History . SetSelectionRedo ( oSelection ) } var bNotAddCollapsed = true == this . workbook . bUndoChanges || true == this . workbook . bRedoChanges || this . bExcludeCollapsed ; var _summaryRight = this . sheetPr ? this . sheetPr . SummaryRight : true ; var oThis = this , prevCol ; var fProcessCol = function ( col ) { if ( col . width != width ) { if ( _summaryRight && ! bNotAddCollapsed && col . getCollapsed ( ) ) oThis . setCollapsedCol ( false , null , col ) ; else if ( ! _summaryRight && ! bNotAddCollapsed && prevCol && prevCol . getCollapsed ( ) ) oThis . setCollapsedCol ( false ,
null , prevCol ) ; prevCol = col ; var oOldProps = col . getWidthProp ( ) ; col . width = width ; col . CustomWidth = true ; col . BestFit = null ; col . setHidden ( null ) ; oThis . initColumn ( col ) ; var oNewProps = col . getWidthProp ( ) ; if ( false == oOldProps . isEqual ( oNewProps ) ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _ColProp , oThis . getId ( ) , col . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( col . index , false , oOldProps , oNewProps ) ) } } ; if ( 0 == start && gc _nMaxCol0 == stop ) { var col = this . getAllCol ( ) ; fProcessCol ( col ) ; for ( var i in this . aCols ) { var col =
this . aCols [ i ] ; if ( null != col ) fProcessCol ( col ) } } else { if ( ! _summaryRight ) if ( ! bNotAddCollapsed && start > 0 ) prevCol = this . _getCol ( start - 1 ) ; for ( var i = start ; i <= stop ; i ++ ) { var col = this . _getCol ( i ) ; fProcessCol ( col ) } if ( _summaryRight && ! bNotAddCollapsed && prevCol ) { col = this . _getCol ( stop + 1 ) ; if ( col . getCollapsed ( ) ) this . setCollapsedCol ( false , null , col ) } } } ; Worksheet . prototype . getColHidden = function ( index ) { var col = this . _getColNoEmptyWithAll ( index ) ; return col ? col . getHidden ( ) : false } ; Worksheet . prototype . setColHidden = function ( bHidden ,
start , stop ) { if ( null == start ) return ; if ( null == stop ) stop = start ; History . Create _NewPoint ( ) ; var oThis = this , outlineLevel ; var bNotAddCollapsed = true == this . workbook . bUndoChanges || true == this . workbook . bRedoChanges || this . bExcludeCollapsed ; var _summaryRight = this . sheetPr ? this . sheetPr . SummaryRight : true ; var fProcessCol = function ( col ) { if ( col && ! bNotAddCollapsed && outlineLevel !== undefined && outlineLevel !== col . getOutlineLevel ( ) ) if ( ! _summaryRight ) oThis . setCollapsedCol ( bHidden , col . index - 1 ) ; else oThis . setCollapsedCol ( bHidden ,
null , col ) ; outlineLevel = col ? col . getOutlineLevel ( ) : null ; if ( col . getHidden ( ) != bHidden ) { var oOldProps = col . getWidthProp ( ) ; if ( bHidden ) { col . setHidden ( bHidden ) ; if ( null == col . width || true != col . CustomWidth ) col . width = 0 ; col . CustomWidth = true ; col . BestFit = null } else { col . setHidden ( null ) ; if ( 0 >= col . width ) col . width = null } var oNewProps = col . getWidthProp ( ) ; if ( false == oOldProps . isEqual ( oNewProps ) ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _ColProp , oThis . getId ( ) , col . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( col . index ,
false , oOldProps , oNewProps ) ) } } ; if ( ! bNotAddCollapsed && ! _summaryRight && start > 0 ) { col = this . _getCol ( start - 1 ) ; outlineLevel = col . getOutlineLevel ( ) } if ( 0 != start && gc _nMaxCol0 == stop ) { var col = null ; if ( false == bHidden ) col = this . oAllCol ; else col = this . getAllCol ( ) ; if ( null != col ) fProcessCol ( col ) ; for ( var i in this . aCols ) { var col = this . aCols [ i ] ; if ( null != col ) fProcessCol ( col ) } } else for ( var i = start ; i <= stop ; i ++ ) { var col = null ; if ( false == bHidden ) col = this . _getColNoEmpty ( i ) ; else col = this . _getCol ( i ) ; if ( null != col ) fProcessCol ( col ) } if ( ! bNotAddCollapsed &&
outlineLevel && _summaryRight ) { col = this . _getCol ( stop + 1 ) ; if ( col && outlineLevel !== col . getOutlineLevel ( ) ) oThis . setCollapsedCol ( bHidden , null , col ) } } ; Worksheet . prototype . setCollapsedCol = function ( bCollapse , colIndex , curCol ) { var oThis = this ; var fProcessCol = function ( col ) { var oOldProps = col . getCollapsed ( ) ; col . setCollapsed ( bCollapse ) ; var oNewProps = col . getCollapsed ( ) ; if ( oOldProps !== oNewProps ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _CollapsedCol , oThis . getId ( ) , col . _getUpdateRange ( ) ,
new UndoRedoData _IndexSimpleProp ( col . index , true , oOldProps , oNewProps ) ) } ; if ( curCol ) fProcessCol ( curCol ) ; else this . getRange3 ( 0 , colIndex , 0 , colIndex ) . _foreachCol ( fProcessCol ) } ; Worksheet . prototype . setSummaryRight = function ( val ) { if ( ! this . sheetPr ) this . sheetPr = new AscCommonExcel . asc _CSheetPr ; History . Create _NewPoint ( ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _SetSummaryRight , this . getId ( ) , null , new UndoRedoData _FromTo ( this . sheetPr . SummaryRight , val ) ) ; this . sheetPr . SummaryRight = val } ;
Worksheet . prototype . setSummaryBelow = function ( val ) { if ( ! this . sheetPr ) this . sheetPr = new AscCommonExcel . asc _CSheetPr ; History . Create _NewPoint ( ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _SetSummaryBelow , this . getId ( ) , null , new UndoRedoData _FromTo ( this . sheetPr . SummaryBelow , val ) ) ; this . sheetPr . SummaryBelow = val } ; Worksheet . prototype . setGroupCol = function ( bDel , start , stop ) { var oThis = this ; var fProcessCol = function ( col ) { var oOldProps = col . getOutlineLevel ( ) ; col . setOutlineLevel ( null , bDel ) ;
var oNewProps = col . getOutlineLevel ( ) ; if ( oOldProps !== oNewProps ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _GroupCol , oThis . getId ( ) , col . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( col . index , true , oOldProps , oNewProps ) ) } ; this . getRange3 ( 0 , start , 0 , stop ) . _foreachCol ( fProcessCol ) } ; Worksheet . prototype . setOutlineCol = function ( val , start , stop ) { var oThis = this ; var fProcessCol = function ( col ) { var oOldProps = col . getOutlineLevel ( ) ; col . setOutlineLevel ( val ) ; var oNewProps = col . getOutlineLevel ( ) ;
if ( oOldProps !== oNewProps ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _GroupCol , oThis . getId ( ) , col . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( col . index , true , oOldProps , oNewProps ) ) } ; this . getRange3 ( 0 , start , 0 , stop ) . _foreachCol ( fProcessCol ) } ; Worksheet . prototype . getColCustomWidth = function ( index ) { var isBestFit ; var column = this . _getColNoEmptyWithAll ( index ) ; if ( ! column ) isBestFit = true ; else if ( column . getHidden ( ) ) isBestFit = false ; else isBestFit = ! ! ( column . BestFit || null === column . BestFit &&
null === column . CustomWidth ) ; return ! isBestFit } ; Worksheet . prototype . setColBestFit = function ( bBestFit , width , start , stop ) { if ( null == start ) return ; if ( null == stop ) stop = start ; History . Create _NewPoint ( ) ; var oThis = this ; var fProcessCol = function ( col ) { var oOldProps = col . getWidthProp ( ) ; if ( bBestFit ) { col . BestFit = bBestFit ; col . setHidden ( null ) } else col . BestFit = null ; col . width = width ; oThis . initColumn ( col ) ; var oNewProps = col . getWidthProp ( ) ; if ( false == oOldProps . isEqual ( oNewProps ) ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _ColProp ,
oThis . getId ( ) , col . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( col . index , false , oOldProps , oNewProps ) ) } ; if ( 0 != start && gc _nMaxCol0 == stop ) { var col = null ; if ( bBestFit && oDefaultMetrics . ColWidthChars == width ) col = this . oAllCol ; else col = this . getAllCol ( ) ; if ( null != col ) fProcessCol ( col ) ; for ( var i in this . aCols ) { var col = this . aCols [ i ] ; if ( null != col ) fProcessCol ( col ) } } else for ( var i = start ; i <= stop ; i ++ ) { var col = null ; if ( bBestFit && oDefaultMetrics . ColWidthChars == width ) col = this . _getColNoEmpty ( i ) ; else col = this . _getCol ( i ) ;
if ( null != col ) fProcessCol ( col ) } } ; Worksheet . prototype . isDefaultHeightHidden = function ( ) { return null != this . oSheetFormatPr . oAllRow && this . oSheetFormatPr . oAllRow . getHidden ( ) } ; Worksheet . prototype . isDefaultWidthHidden = function ( ) { return null != this . oAllCol && this . oAllCol . getHidden ( ) } ; Worksheet . prototype . setDefaultHeight = function ( h ) { if ( this . oSheetFormatPr . oAllRow && ! this . oSheetFormatPr . oAllRow . getCustomHeight ( ) ) this . oSheetFormatPr . oAllRow . h = h } ; Worksheet . prototype . getDefaultHeight = function ( ) { var dRes = null ; if ( null !=
this . oSheetFormatPr . oAllRow && this . oSheetFormatPr . oAllRow . getCustomHeight ( ) ) dRes = this . oSheetFormatPr . oAllRow . h ; return dRes } ; Worksheet . prototype . getRowHeight = function ( index ) { var res ; this . _getRowNoEmptyWithAll ( index , function ( row ) { res = row ? row . getHeight ( ) : - 1 } ) ; return res } ; Worksheet . prototype . setRowHeight = function ( height , start , stop , isCustom ) { if ( 0 == height ) return this . setRowHidden ( true , start , stop ) ; if ( null == start ) return ; if ( null == stop ) stop = start ; History . Create _NewPoint ( ) ; var oThis = this , i ; var oSelection = History . GetSelection ( ) ;
if ( null != oSelection ) { oSelection = oSelection . clone ( ) ; oSelection . assign ( 0 , start , gc _nMaxCol0 , stop ) ; History . SetSelection ( oSelection ) ; History . SetSelectionRedo ( oSelection ) } var prevRow ; var bNotAddCollapsed = true == this . workbook . bUndoChanges || true == this . workbook . bRedoChanges || this . bExcludeCollapsed ; var _summaryBelow = this . sheetPr ? this . sheetPr . SummaryBelow : true ; var fProcessRow = function ( row ) { if ( row ) { if ( _summaryBelow && ! bNotAddCollapsed && row . getCollapsed ( ) ) oThis . setCollapsedRow ( false , null , row ) ; else if ( ! _summaryBelow &&
! bNotAddCollapsed && prevRow && prevRow . getCollapsed ( ) ) oThis . setCollapsedRow ( false , null , prevRow ) ; prevRow = row ; var oOldProps = row . getHeightProp ( ) ; row . setHeight ( height ) ; if ( isCustom ) row . setCustomHeight ( true ) ; row . setCalcHeight ( true ) ; row . setHidden ( false ) ; var oNewProps = row . getHeightProp ( ) ; if ( false === oOldProps . isEqual ( oNewProps ) ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _RowProp , oThis . getId ( ) , row . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( row . index , true , oOldProps , oNewProps ) ) } } ;
if ( 0 == start && gc _nMaxRow0 == stop ) { fProcessRow ( this . getAllRow ( ) ) ; this . _forEachRow ( fProcessRow ) } else { if ( ! _summaryBelow ) if ( ! bNotAddCollapsed && start > 0 ) this . _getRow ( start - 1 , function ( row ) { prevRow = row } ) ; this . getRange3 ( start , 0 , stop , 0 ) . _foreachRow ( fProcessRow ) ; if ( _summaryBelow ) if ( ! bNotAddCollapsed && prevRow ) this . _getRow ( stop + 1 , function ( row ) { if ( row . getCollapsed ( ) ) oThis . setCollapsedRow ( false , null , row ) } ) } if ( this . needRecalFormulas ( start , stop ) ) this . workbook . dependencyFormulas . calcTree ( ) } ; Worksheet . prototype . getRowHidden =
function ( index ) { var res ; this . _getRowNoEmptyWithAll ( index , function ( row ) { res = row ? row . getHidden ( ) : false } ) ; return res } ; Worksheet . prototype . setRowHidden = function ( bHidden , start , stop ) { if ( null == start ) return ; if ( null == stop ) stop = start ; History . Create _NewPoint ( ) ; var oThis = this , i ; var startIndex = null , endIndex = null , updateRange , outlineLevel ; var bNotAddCollapsed = true == this . workbook . bUndoChanges || true == this . workbook . bRedoChanges || this . bExcludeCollapsed ; var _summaryBelow = this . sheetPr ? this . sheetPr . SummaryBelow : true ; var fProcessRow =
function ( row ) { if ( row && ! bNotAddCollapsed && outlineLevel !== undefined && outlineLevel !== row . getOutlineLevel ( ) ) if ( ! _summaryBelow ) oThis . setCollapsedRow ( bHidden , row . index - 1 ) ; else oThis . setCollapsedRow ( bHidden , null , row ) ; outlineLevel = row ? row . getOutlineLevel ( ) : null ; if ( row && bHidden != row . getHidden ( ) ) { row . setHidden ( bHidden ) ; if ( row . index === endIndex + 1 && startIndex !== null ) endIndex ++ ; else { if ( startIndex !== null ) { updateRange = new Asc . Range ( 0 , startIndex , gc _nMaxCol0 , endIndex ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet ,
AscCH . historyitem _Worksheet _RowHide , oThis . getId ( ) , updateRange , new UndoRedoData _FromToRowCol ( bHidden , startIndex , endIndex ) ) } startIndex = row . index ; endIndex = row . index } } } ; if ( 0 == start && gc _nMaxRow0 == stop ) ; else { if ( ! _summaryBelow && start > 0 && ! bNotAddCollapsed ) this . _getRow ( start - 1 , function ( row ) { if ( row ) outlineLevel = row . getOutlineLevel ( ) } ) ; for ( i = start ; i <= stop ; ++ i ) false == bHidden ? this . _getRowNoEmpty ( i , fProcessRow ) : this . _getRow ( i , fProcessRow ) ; if ( _summaryBelow && outlineLevel && ! bNotAddCollapsed ) this . _getRow ( stop + 1 , function ( row ) { if ( row &&
outlineLevel !== row . getOutlineLevel ( ) ) oThis . setCollapsedRow ( bHidden , null , row ) } ) ; if ( startIndex !== null ) { updateRange = new Asc . Range ( 0 , startIndex , gc _nMaxCol0 , endIndex ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _RowHide , oThis . getId ( ) , updateRange , new UndoRedoData _FromToRowCol ( bHidden , startIndex , endIndex ) ) } } if ( this . needRecalFormulas ( start , stop ) ) this . workbook . dependencyFormulas . calcTree ( ) } ; Worksheet . prototype . setCollapsedRow = function ( bCollapse , rowIndex , curRow ) { var oThis = this ;
var fProcessRow = function ( row , bSave ) { var oOldProps = row . getCollapsed ( ) ; row . setCollapsed ( bCollapse ) ; var oNewProps = row . getCollapsed ( ) ; if ( oOldProps !== oNewProps ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _CollapsedRow , oThis . getId ( ) , row . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( row . index , true , oOldProps , oNewProps ) ) ; if ( bSave ) row . saveContent ( true ) } ; if ( curRow ) fProcessRow ( curRow , true ) ; else this . getRange3 ( rowIndex , 0 , rowIndex , 0 ) . _foreachRow ( fProcessRow ) } ; Worksheet . prototype . setGroupRow =
function ( bDel , start , stop ) { var oThis = this ; var fProcessRow = function ( row ) { var oOldProps = row . getOutlineLevel ( ) ; row . setOutlineLevel ( null , bDel ) ; var oNewProps = row . getOutlineLevel ( ) ; if ( oOldProps !== oNewProps ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _GroupRow , oThis . getId ( ) , row . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( row . index , true , oOldProps , oNewProps ) ) } ; this . getRange3 ( start , 0 , stop , 0 ) . _foreachRow ( fProcessRow ) } ; Worksheet . prototype . setOutlineRow = function ( val , start ,
stop ) { var oThis = this ; var fProcessRow = function ( row ) { var oOldProps = row . getOutlineLevel ( ) ; row . setOutlineLevel ( val ) ; var oNewProps = row . getOutlineLevel ( ) ; if ( oOldProps !== oNewProps ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _GroupRow , oThis . getId ( ) , row . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( row . index , true , oOldProps , oNewProps ) ) } ; this . getRange3 ( start , 0 , stop , 0 ) . _foreachRow ( fProcessRow ) } ; Worksheet . prototype . getRowCustomHeight = function ( index ) { var isCustomHeight = false ;
this . _getRowNoEmptyWithAll ( index , function ( row ) { if ( ! row ) isCustomHeight = false ; else if ( row . getHidden ( ) ) isCustomHeight = true ; else isCustomHeight = row . getCustomHeight ( ) } ) ; return isCustomHeight } ; Worksheet . prototype . setRowBestFit = function ( bBestFit , height , start , stop ) { if ( null == start ) return ; if ( null == stop ) stop = start ; History . Create _NewPoint ( ) ; var oThis = this , i ; var isDefaultProp = true == bBestFit && oDefaultMetrics . RowHeight == height ; var fProcessRow = function ( row ) { if ( row ) { var oOldProps = row . getHeightProp ( ) ; row . setCustomHeight ( ! bBestFit ) ;
row . setCalcHeight ( true ) ; row . setHeight ( height ) ; var oNewProps = row . getHeightProp ( ) ; if ( false == oOldProps . isEqual ( oNewProps ) ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _RowProp , oThis . getId ( ) , row . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( row . index , true , oOldProps , oNewProps ) ) } } ; if ( 0 == start && gc _nMaxRow0 == stop ) { fProcessRow ( isDefaultProp ? this . oSheetFormatPr . oAllRow : this . getAllRow ( ) ) ; this . _forEachRow ( fProcessRow ) } else { var range = this . getRange3 ( start , 0 , stop , 0 ) ; if ( isDefaultProp ) range . _foreachRowNoEmpty ( fProcessRow ) ;
else range . _foreachRow ( fProcessRow ) } this . workbook . dependencyFormulas . calcTree ( ) } ; Worksheet . prototype . getCell = function ( oCellAdd ) { return this . getRange ( oCellAdd , oCellAdd ) } ; Worksheet . prototype . getCell2 = function ( sCellAdd ) { if ( sCellAdd . indexOf ( "$" ) > - 1 ) sCellAdd = sCellAdd . replace ( /\$/g , "" ) ; return this . getRange2 ( sCellAdd ) } ; Worksheet . prototype . getCell3 = function ( r1 , c1 ) { return this . getRange3 ( r1 , c1 , r1 , c1 ) } ; Worksheet . prototype . getRange = function ( cellAdd1 , cellAdd2 ) { var nRow1 = cellAdd1 . getRow0 ( ) ; var nCol1 = cellAdd1 . getCol0 ( ) ;
var nRow2 = cellAdd2 . getRow0 ( ) ; var nCol2 = cellAdd2 . getCol0 ( ) ; return this . getRange3 ( nRow1 , nCol1 , nRow2 , nCol2 ) } ; Worksheet . prototype . getRange2 = function ( sRange ) { var bbox = AscCommonExcel . g _oRangeCache . getAscRange ( sRange ) ; if ( null != bbox ) return Range . prototype . createFromBBox ( this , bbox ) ; return null } ; Worksheet . prototype . getRange3 = function ( r1 , c1 , r2 , c2 ) { var nRowMin = r1 ; var nRowMax = r2 ; var nColMin = c1 ; var nColMax = c2 ; if ( r1 > r2 ) { nRowMax = r1 ; nRowMin = r2 } if ( c1 > c2 ) { nColMax = c1 ; nColMin = c2 } return new Range ( this , nRowMin , nColMin ,
nRowMax , nColMax ) } ; Worksheet . prototype . getRange4 = function ( r , c ) { return new Range ( this , r , c , r , c ) } ; Worksheet . prototype . getRowIterator = function ( r1 , c1 , c2 , callback ) { var it = new RowIterator ; it . init ( this , r1 , c1 , c2 ) ; callback ( it ) ; it . release ( ) } ; Worksheet . prototype . _removeCell = function ( nRow , nCol , cell ) { var t = this ; var processCell = function ( cell ) { if ( null != cell ) { var sheetId = t . getId ( ) ; if ( false == cell . isEmpty ( ) ) { var oUndoRedoData _CellData = new AscCommonExcel . UndoRedoData _CellData ( cell . getValueData ( ) , null ) ; if ( null != cell . xfs ) oUndoRedoData _CellData . style =
cell . xfs . clone ( ) ; cell . setFormulaInternal ( null ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _RemoveCell , sheetId , new Asc . Range ( nCol , nRow , nCol , nRow ) , new UndoRedoData _CellSimpleData ( nRow , nCol , oUndoRedoData _CellData , null ) ) } t . workbook . dependencyFormulas . addToChangedCell ( cell ) ; cell . clearData ( ) ; cell . saveContent ( true ) } } ; if ( null != cell ) { nRow = cell . nRow ; nCol = cell . nCol ; processCell ( cell ) } else this . _getCellNoEmpty ( nRow , nCol , processCell ) } ; Worksheet . prototype . _getCell = function ( row , col ,
fAction ) { var wb = this . workbook ; var targetCell = null ; for ( var k = 0 ; k < wb . loadCells . length ; ++ k ) { var elem = wb . loadCells [ k ] ; if ( elem . nRow == row && elem . nCol == col && this === elem . ws ) { targetCell = elem ; break } } if ( null === targetCell ) { var cell = new Cell ( this ) ; wb . loadCells . push ( cell ) ; if ( ! cell . loadContent ( row , col ) ) this . _initCell ( cell , row , col ) ; fAction ( cell ) ; cell . saveContent ( true ) ; wb . loadCells . pop ( ) } else fAction ( targetCell ) } ; Worksheet . prototype . _initRow = function ( row , index ) { var t = this ; row . setChanged ( true ) ; if ( null != this . oSheetFormatPr . oAllRow ) { row . copyFrom ( this . oSheetFormatPr . oAllRow ) ;
row . setIndex ( index ) } this . nRowsCount = index >= this . nRowsCount ? index + 1 : this . nRowsCount } ; Worksheet . prototype . _initCell = function ( cell , nRow , nCol ) { var t = this ; cell . setChanged ( true ) ; this . _getRowNoEmpty ( nRow , function ( row ) { var oCol = t . _getColNoEmptyWithAll ( nCol ) ; var xfs = null ; if ( row && null != row . xfs ) xfs = row . xfs . clone ( ) ; else if ( null != oCol && null != oCol . xfs ) xfs = oCol . xfs . clone ( ) ; cell . setStyleInternal ( xfs ) ; t . cellsByColRowsCount = Math . max ( t . cellsByColRowsCount , nRow + 1 ) ; t . nRowsCount = Math . max ( t . nRowsCount , t . cellsByColRowsCount ) ;
if ( nCol >= t . nColsCount ) t . nColsCount = nCol + 1 } ) ; var sheetMemory = this . getColData ( nCol ) ; sheetMemory . checkSize ( nRow ) } ; Worksheet . prototype . _getCellNoEmpty = function ( row , col , fAction ) { var wb = this . workbook ; var targetCell = null ; for ( var k = 0 ; k < wb . loadCells . length ; ++ k ) { var elem = wb . loadCells [ k ] ; if ( elem . nRow == row && elem . nCol == col && this === elem . ws ) { targetCell = elem ; break } } if ( null === targetCell ) { var cell = new Cell ( this ) ; var res = cell . loadContent ( row , col ) ? cell : null ; if ( res && fAction ) wb . loadCells . push ( cell ) ; fAction ( res ) ; cell . saveContent ( true ) ;
if ( res ) wb . loadCells . pop ( ) } else fAction ( targetCell ) } ; Worksheet . prototype . _getRowNoEmpty = function ( nRow , fAction ) { var row = new AscCommonExcel . Row ( this ) ; if ( row . loadContent ( nRow ) ) { fAction ( row ) ; row . saveContent ( true ) } else fAction ( null ) } ; Worksheet . prototype . _getRowNoEmptyWithAll = function ( nRow , fAction ) { var t = this ; this . _getRowNoEmpty ( nRow , function ( row ) { if ( ! row ) row = t . oSheetFormatPr . oAllRow ; fAction ( row ) } ) } ; Worksheet . prototype . _getColNoEmpty = function ( col ) { return this . aCols [ col ] || null } ; Worksheet . prototype . _getColNoEmptyWithAll =
function ( col ) { return this . _getColNoEmpty ( col ) || this . oAllCol } ; Worksheet . prototype . _getRow = function ( index , fAction ) { var row = null ; if ( g _nAllRowIndex == index ) row = this . getAllRow ( ) ; else { row = new AscCommonExcel . Row ( this ) ; if ( ! row . loadContent ( index ) ) this . _initRow ( row , index ) } fAction ( row ) ; row . saveContent ( true ) } ; Worksheet . prototype . _getCol = function ( index ) { var oCurCol ; if ( g _nAllColIndex == index ) oCurCol = this . getAllCol ( ) ; else { oCurCol = this . aCols [ index ] ; if ( null == oCurCol ) { if ( null != this . oAllCol ) { oCurCol = this . oAllCol . clone ( ) ;
oCurCol . index = index } else oCurCol = new AscCommonExcel . Col ( this , index ) ; this . aCols [ index ] = oCurCol ; this . nColsCount = index >= this . nColsCount ? index + 1 : this . nColsCount } } return oCurCol } ; Worksheet . prototype . _prepareMoveRangeGetCleanRanges = function ( oBBoxFrom , oBBoxTo , wsTo ) { var intersection = oBBoxFrom . intersectionSimple ( oBBoxTo ) ; var aRangesToCheck = [ ] ; if ( null != intersection && this === wsTo ) { var oThis = this ; var fAddToRangesToCheck = function ( aRangesToCheck , r1 , c1 , r2 , c2 ) { if ( r1 <= r2 && c1 <= c2 ) aRangesToCheck . push ( oThis . getRange3 ( r1 ,
c1 , r2 , c2 ) ) } ; if ( intersection . r1 == oBBoxTo . r1 && intersection . c1 == oBBoxTo . c1 ) { fAddToRangesToCheck ( aRangesToCheck , oBBoxTo . r1 , intersection . c2 + 1 , intersection . r2 , oBBoxTo . c2 ) ; fAddToRangesToCheck ( aRangesToCheck , intersection . r2 + 1 , oBBoxTo . c1 , oBBoxTo . r2 , oBBoxTo . c2 ) } else if ( intersection . r2 == oBBoxTo . r2 && intersection . c1 == oBBoxTo . c1 ) { fAddToRangesToCheck ( aRangesToCheck , oBBoxTo . r1 , oBBoxTo . c1 , intersection . r1 - 1 , oBBoxTo . c2 ) ; fAddToRangesToCheck ( aRangesToCheck , intersection . r1 , intersection . c2 + 1 , oBBoxTo . r2 , oBBoxTo . c2 ) } else if ( intersection . r1 ==
oBBoxTo . r1 && intersection . c2 == oBBoxTo . c2 ) { fAddToRangesToCheck ( aRangesToCheck , oBBoxTo . r1 , oBBoxTo . c1 , intersection . r2 , intersection . c1 - 1 ) ; fAddToRangesToCheck ( aRangesToCheck , intersection . r2 + 1 , oBBoxTo . c1 , oBBoxTo . r2 , oBBoxTo . c2 ) } else if ( intersection . r2 == oBBoxTo . r2 && intersection . c2 == oBBoxTo . c2 ) { fAddToRangesToCheck ( aRangesToCheck , oBBoxTo . r1 , oBBoxTo . c1 , intersection . r1 - 1 , oBBoxTo . c2 ) ; fAddToRangesToCheck ( aRangesToCheck , intersection . r1 , oBBoxTo . c1 , oBBoxTo . r2 , intersection . c1 - 1 ) } } else aRangesToCheck . push ( wsTo . getRange3 ( oBBoxTo . r1 ,
oBBoxTo . c1 , oBBoxTo . r2 , oBBoxTo . c2 ) ) ; return aRangesToCheck } ; Worksheet . prototype . _prepareMoveRange = function ( oBBoxFrom , oBBoxTo , wsTo ) { var res = 0 ; if ( ! wsTo ) wsTo = this ; if ( oBBoxFrom . isEqual ( oBBoxTo ) && this === wsTo ) return res ; var range = wsTo . getRange3 ( oBBoxTo . r1 , oBBoxTo . c1 , oBBoxTo . r2 , oBBoxTo . c2 ) ; var aMerged = wsTo . mergeManager . get ( range . getBBox0 ( ) ) ; if ( aMerged . outer . length > 0 ) return - 2 ; var aRangesToCheck = this . _prepareMoveRangeGetCleanRanges ( oBBoxFrom , oBBoxTo , wsTo ) ; for ( var i = 0 , length = aRangesToCheck . length ; i < length ; i ++ ) { range =
aRangesToCheck [ i ] ; range . _foreachNoEmpty ( function ( cell ) { if ( ! cell . isNullTextString ( ) ) { res = - 1 ; return res } } ) ; if ( 0 != res ) return res } return res } ; Worksheet . prototype . _moveMergedAndHyperlinksPrepare = function ( oBBoxFrom , oBBoxTo , copyRange , wsTo , offset ) { var res = { merged : [ ] , hyperlinks : [ ] } ; if ( ! ( false == this . workbook . bUndoChanges && ( false == this . workbook . bRedoChanges || this . workbook . bCollaborativeChanges ) ) ) return res ; var i , elem , bbox , data , wsFrom = this ; var intersection = oBBoxFrom . intersectionSimple ( oBBoxTo ) ; History . LocalChange =
true ; var merged = wsFrom . mergeManager . get ( oBBoxFrom ) . inner ; var mergedToRemove ; if ( ! copyRange ) mergedToRemove = merged ; else if ( null !== intersection ) mergedToRemove = wsFrom . mergeManager . get ( intersection ) . all ; if ( mergedToRemove ) for ( i = 0 ; i < mergedToRemove . length ; i ++ ) wsFrom . mergeManager . removeElement ( mergedToRemove [ i ] ) ; var hyperlinks = wsFrom . hyperlinkManager . get ( oBBoxFrom ) . inner ; if ( ! copyRange ) for ( i = 0 ; i < hyperlinks . length ; i ++ ) wsFrom . hyperlinkManager . removeElement ( hyperlinks [ i ] ) ; History . LocalChange = false ; res . merged = merged ;
res . hyperlinks = hyperlinks ; return res } ; Worksheet . prototype . _moveMergedAndHyperlinks = function ( prepared , oBBoxFrom , oBBoxTo , copyRange , wsTo , offset ) { var i , elem , bbox , data ; var intersection = oBBoxFrom . intersectionSimple ( oBBoxTo ) ; History . LocalChange = true ; for ( i = 0 ; i < prepared . merged . length ; i ++ ) { elem = prepared . merged [ i ] ; bbox = copyRange ? elem . bbox . clone ( ) : elem . bbox ; bbox . setOffset ( offset ) ; wsTo . mergeManager . add ( bbox , elem . data ) } if ( ! copyRange || null === intersection ) for ( i = 0 ; i < prepared . hyperlinks . length ; i ++ ) { elem = prepared . hyperlinks [ i ] ;
if ( copyRange ) { bbox = elem . bbox . clone ( ) ; data = elem . data . clone ( ) } else { bbox = elem . bbox ; data = elem . data } bbox . setOffset ( offset ) ; wsTo . hyperlinkManager . add ( bbox , data ) } History . LocalChange = false } ; Worksheet . prototype . _moveCleanRanges = function ( oBBoxFrom , oBBoxTo , copyRange , wsTo ) { var cleanRanges = this . _prepareMoveRangeGetCleanRanges ( oBBoxFrom , oBBoxTo , wsTo ) ; for ( var i = 0 ; i < cleanRanges . length ; i ++ ) { var range = cleanRanges [ i ] ; range . cleanAll ( ) ; if ( ! copyRange ) this . workbook . dependencyFormulas . deleteNodes ( wsTo . getId ( ) , range . getBBox0 ( ) ) } } ;
Worksheet . prototype . _moveFormulas = function ( oBBoxFrom , oBBoxTo , copyRange , wsTo , offset ) { if ( ! copyRange ) this . workbook . dependencyFormulas . move ( this . Id , oBBoxFrom , offset , wsTo . getId ( ) ) ; this . getRange3 ( oBBoxFrom . r1 , oBBoxFrom . c1 , oBBoxFrom . r2 , oBBoxFrom . c2 ) . _foreachNoEmpty ( function ( cell ) { if ( cell . transformSharedFormula ( ) ) { var parsed = cell . getFormulaParsed ( ) ; parsed . buildDependencies ( ) } } ) } ; Worksheet . prototype . _moveCells = function ( oBBoxFrom , oBBoxTo , copyRange , wsTo , offset ) { var oThis = this ; var nRowsCountNew = 0 ; var nColsCountNew =
0 ; var dependencyFormulas = oThis . workbook . dependencyFormulas ; var moveToOtherSheet = this !== wsTo ; var isClearFromArea = ! copyRange || copyRange && oThis . workbook . bUndoChanges ; var moveCells = function ( copyRange , from , to , r1From , r1To , count ) { var fromData = oThis . getColDataNoEmpty ( from ) ; var toData ; if ( fromData ) { toData = wsTo . getColData ( to ) ; toData . copyRange ( fromData , r1From , r1To , count ) ; if ( isClearFromArea ) if ( from !== to || moveToOtherSheet ) fromData . clear ( r1From , r1From + count ) ; else if ( r1From < r1To ) fromData . clear ( r1From , Math . min ( r1From +
count , r1To ) ) ; else fromData . clear ( Math . max ( r1From , r1To + count ) , r1From + count ) } else { toData = wsTo . getColDataNoEmpty ( to ) ; if ( toData ) toData . clear ( r1To , r1To + count ) } if ( toData ) { nRowsCountNew = Math . max ( nRowsCountNew , toData . getSize ( ) ) ; nColsCountNew = Math . max ( nColsCountNew , to + 1 ) } } ; if ( oBBoxFrom . c1 < oBBoxTo . c1 ) for ( var i = 0 ; i < oBBoxFrom . c2 - oBBoxFrom . c1 + 1 ; ++ i ) moveCells ( copyRange , oBBoxFrom . c2 - i , oBBoxTo . c2 - i , oBBoxFrom . r1 , oBBoxTo . r1 , oBBoxFrom . r2 - oBBoxFrom . r1 + 1 ) ; else for ( var i = 0 ; i < oBBoxFrom . c2 - oBBoxFrom . c1 + 1 ; ++ i ) moveCells ( copyRange ,
oBBoxFrom . c1 + i , oBBoxTo . c1 + i , oBBoxFrom . r1 , oBBoxTo . r1 , oBBoxFrom . r2 - oBBoxFrom . r1 + 1 ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _MoveRange , this . getId ( ) , new Asc . Range ( 0 , 0 , gc _nMaxCol0 , gc _nMaxRow0 ) , new UndoRedoData _FromTo ( new UndoRedoData _BBox ( oBBoxFrom ) , new UndoRedoData _BBox ( oBBoxTo ) , copyRange , wsTo . getId ( ) ) ) ; if ( moveToOtherSheet ) History . AddToUpdatesRegions ( oBBoxTo , wsTo . getId ( ) ) ; var shiftedArrayFormula = { } ; var oldNewArrayFormulaMap = { } ; wsTo . cellsByColRowsCount = Math . max ( wsTo . cellsByColRowsCount ,
nRowsCountNew ) ; wsTo . nRowsCount = Math . max ( wsTo . nRowsCount , wsTo . cellsByColRowsCount ) ; wsTo . nColsCount = Math . max ( wsTo . nColsCount , nColsCountNew ) ; wsTo . getRange3 ( oBBoxTo . r1 , oBBoxTo . c1 , oBBoxTo . r2 , oBBoxTo . c2 ) . _foreachNoEmpty ( function ( cell ) { var formula = cell . getFormulaParsed ( ) ; if ( formula ) { var cellWithFormula = formula . getParent ( ) ; var arrayFormula = formula . getArrayFormulaRef ( ) ; var newArrayRef , newFormula ; var preMoveCell = { nRow : cell . nRow - offset . row , nCol : cell . nCol - offset . col } ; var isFirstCellArray = formula . checkFirstCellArray ( preMoveCell ) &&
! shiftedArrayFormula [ formula . getListenerId ( ) ] ; if ( copyRange ) { History . TurnOff ( ) ; if ( ! arrayFormula || arrayFormula && isFirstCellArray ) { newFormula = oThis . _moveCellsFormula ( cell , formula , cellWithFormula , copyRange , oBBoxFrom , wsTo ) ; cellWithFormula = newFormula . getParent ( ) ; cellWithFormula = new CCellWithFormula ( wsTo , cell . nRow , cell . nCol ) ; newFormula = newFormula . clone ( null , cellWithFormula , wsTo ) ; newFormula . changeOffset ( offset , false , true ) ; newFormula . setFormulaString ( newFormula . assemble ( true ) ) ; cell . setFormulaInternal ( newFormula ,
! isClearFromArea ) ; if ( isFirstCellArray ) { newArrayRef = arrayFormula . clone ( ) ; newArrayRef . setOffset ( offset ) ; newFormula . setArrayFormulaRef ( newArrayRef ) ; shiftedArrayFormula [ newFormula . getListenerId ( ) ] = 1 ; oldNewArrayFormulaMap [ formula . getListenerId ( ) ] = newFormula } } else if ( arrayFormula && oldNewArrayFormulaMap [ formula . getListenerId ( ) ] ) cell . setFormulaInternal ( oldNewArrayFormulaMap [ formula . getListenerId ( ) ] , ! isClearFromArea ) ; History . TurnOn ( ) } else if ( arrayFormula ) { if ( isFirstCellArray ) { newFormula = oThis . _moveCellsFormula ( cell ,
formula , cellWithFormula , copyRange , oBBoxFrom , wsTo ) ; cellWithFormula = newFormula . getParent ( ) ; shiftedArrayFormula [ formula . getListenerId ( ) ] = 1 ; newArrayRef = arrayFormula . clone ( ) ; newArrayRef . setOffset ( offset ) ; newFormula . setArrayFormulaRef ( newArrayRef ) ; cellWithFormula . ws = wsTo ; cellWithFormula . nRow = cell . nRow ; cellWithFormula . nCol = cell . nCol } } else { newFormula = oThis . _moveCellsFormula ( cell , formula , cellWithFormula , copyRange , oBBoxFrom , wsTo ) ; cellWithFormula = newFormula . getParent ( ) ; cellWithFormula . ws = wsTo ; cellWithFormula . nRow =
cell . nRow ; cellWithFormula . nCol = cell . nCol } if ( arrayFormula ) { if ( isFirstCellArray ) { dependencyFormulas . addToBuildDependencyArray ( formula ) ; if ( newFormula ) dependencyFormulas . addToBuildDependencyArray ( newFormula ) } } else dependencyFormulas . addToBuildDependencyCell ( cell ) } } ) } ; Worksheet . prototype . _moveCellsFormula = function ( cell , formula , cellWithFormula , copyRange , oBBoxFrom , wsTo ) { if ( this !== wsTo ) if ( copyRange || ! this . workbook . bUndoChanges ) { cellWithFormula = new CCellWithFormula ( wsTo , cell . nRow , cell . nCol ) ; formula = formula . clone ( null ,
cellWithFormula , wsTo ) ; if ( ! copyRange ) formula . convertTo3DRefs ( oBBoxFrom ) ; formula . moveToSheet ( this , wsTo ) ; formula . setFormulaString ( formula . assemble ( true ) ) ; cell . setFormulaParsed ( formula ) } else { formula . moveToSheet ( this , wsTo ) ; formula . setFormulaString ( formula . assemble ( true ) ) } return formula } ; Worksheet . prototype . _moveRange = function ( oBBoxFrom , oBBoxTo , copyRange , wsTo ) { if ( ! wsTo ) wsTo = this ; if ( oBBoxFrom . isEqual ( oBBoxTo ) && this === wsTo ) return ; History . Create _NewPoint ( ) ; History . StartTransaction ( ) ; this . workbook . dependencyFormulas . lockRecal ( ) ;
var offset = new AscCommon . CellBase ( oBBoxTo . r1 - oBBoxFrom . r1 , oBBoxTo . c1 - oBBoxFrom . c1 ) ; var prepared = this . _moveMergedAndHyperlinksPrepare ( oBBoxFrom , oBBoxTo , copyRange , wsTo , offset ) ; this . _moveCleanRanges ( oBBoxFrom , oBBoxTo , copyRange , wsTo ) ; this . _moveFormulas ( oBBoxFrom , oBBoxTo , copyRange , wsTo , offset ) ; this . _moveCells ( oBBoxFrom , oBBoxTo , copyRange , wsTo , offset ) ; this . _moveMergedAndHyperlinks ( prepared , oBBoxFrom , oBBoxTo , copyRange , wsTo , offset ) ; if ( true == this . workbook . bUndoChanges || true == this . workbook . bRedoChanges ) wsTo . autoFilters . unmergeTablesAfterMove ( oBBoxTo ) ;
if ( false == this . workbook . bUndoChanges && false == this . workbook . bRedoChanges ) this . autoFilters . _moveAutoFilters ( oBBoxTo , oBBoxFrom , null , copyRange , true , oBBoxFrom , wsTo ) ; this . workbook . dependencyFormulas . unlockRecal ( ) ; History . EndTransaction ( ) ; return true } ; Worksheet . prototype . _shiftCellsLeft = function ( oBBox ) { var t = this ; var nLeft = oBBox . c1 ; var nRight = oBBox . c2 ; var dif = nLeft - nRight - 1 ; var oActualRange = new Asc . Range ( nLeft , oBBox . r1 , gc _nMaxCol0 , oBBox . r2 ) ; var offset = new AscCommon . CellBase ( 0 , dif ) ; var renameRes = this . renameDependencyNodes ( offset ,
oBBox ) ; var redrawTablesArr = this . autoFilters . insertColumn ( oBBox , dif ) ; this . getRange3 ( oBBox . r1 , oBBox . c1 , oBBox . r2 , oBBox . c2 ) . _foreachNoEmpty ( function ( cell ) { t . _removeCell ( null , null , cell ) } ) ; this . _updateFormulasParents ( oActualRange . r1 , oActualRange . c1 , oActualRange . r2 , oActualRange . c2 , oBBox , offset , renameRes . shiftedShared ) ; var cellsByColLength = this . getColDataLength ( ) ; for ( var i = nRight + 1 ; i < cellsByColLength ; ++ i ) { var sheetMemoryFrom = this . getColDataNoEmpty ( i ) ; if ( sheetMemoryFrom ) { this . getColData ( i + dif ) . copyRange ( sheetMemoryFrom ,
oBBox . r1 , oBBox . r1 , oBBox . r2 - oBBox . r1 + 1 ) ; sheetMemoryFrom . clear ( oBBox . r1 , oBBox . r2 + 1 ) } } this . workbook . dependencyFormulas . notifyChanged ( renameRes . changed ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _ShiftCellsLeft , this . getId ( ) , oActualRange , new UndoRedoData _BBox ( oBBox ) ) ; this . autoFilters . redrawStylesTables ( redrawTablesArr ) } ; Worksheet . prototype . _shiftCellsUp = function ( oBBox ) { var t = this ; var nTop = oBBox . r1 ; var nBottom = oBBox . r2 ; var dif = nTop - nBottom - 1 ; var oActualRange = new Asc . Range ( oBBox . c1 ,
oBBox . r1 , oBBox . c2 , gc _nMaxRow0 ) ; var offset = new AscCommon . CellBase ( dif , 0 ) ; var renameRes = this . renameDependencyNodes ( offset , oBBox ) ; var redrawTablesArr = this . autoFilters . insertRows ( "delCell" , oBBox , c _oAscDeleteOptions . DeleteCellsAndShiftTop ) ; this . getRange3 ( oBBox . r1 , oBBox . c1 , oBBox . r2 , oBBox . c2 ) . _foreachNoEmpty ( function ( cell ) { t . _removeCell ( null , null , cell ) } ) ; this . _updateFormulasParents ( oActualRange . r1 , oActualRange . c1 , oActualRange . r2 , oActualRange . c2 , oBBox , offset , renameRes . shiftedShared ) ; for ( var i = oBBox . c1 ; i <=
oBBox . c2 ; ++ i ) { var sheetMemory = this . getColDataNoEmpty ( i ) ; if ( sheetMemory ) sheetMemory . deleteRange ( nTop , - dif ) } this . workbook . dependencyFormulas . notifyChanged ( renameRes . changed ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _ShiftCellsTop , this . getId ( ) , oActualRange , new UndoRedoData _BBox ( oBBox ) ) ; this . autoFilters . redrawStylesTables ( redrawTablesArr ) } ; Worksheet . prototype . _shiftCellsRight = function ( oBBox , displayNameFormatTable ) { var nLeft = oBBox . c1 ; var nRight = oBBox . c2 ; var dif = nRight -
nLeft + 1 ; var oActualRange = new Asc . Range ( oBBox . c1 , oBBox . r1 , gc _nMaxCol0 , oBBox . r2 ) ; var offset = new AscCommon . CellBase ( 0 , dif ) ; var renameRes = this . renameDependencyNodes ( offset , oBBox ) ; var redrawTablesArr = this . autoFilters . insertColumn ( oBBox , dif , displayNameFormatTable ) ; this . _updateFormulasParents ( oActualRange . r1 , oActualRange . c1 , oActualRange . r2 , oActualRange . c2 , oBBox , offset , renameRes . shiftedShared ) ; var borders ; if ( nLeft > 0 && ! this . workbook . bUndoChanges ) borders = this . _getBordersForInsert ( oBBox , false ) ; var cellsByColLength =
this . getColDataLength ( ) ; for ( var i = cellsByColLength - 1 ; i >= nLeft ; -- i ) { var sheetMemoryFrom = this . getColDataNoEmpty ( i ) ; if ( sheetMemoryFrom ) { if ( i + dif <= gc _nMaxCol0 ) this . getColData ( i + dif ) . copyRange ( sheetMemoryFrom , oBBox . r1 , oBBox . r1 , oBBox . r2 - oBBox . r1 + 1 ) ; sheetMemoryFrom . clear ( oBBox . r1 , oBBox . r2 + 1 ) } } this . nColsCount = Math . max ( this . nColsCount , this . getColDataLength ( ) ) ; if ( nLeft > 0 && ! this . workbook . bUndoChanges ) { var prevSheetMemory = this . getColDataNoEmpty ( nLeft - 1 ) ; if ( prevSheetMemory ) { for ( var i = nLeft ; i <= nRight ; ++ i ) this . getColData ( i ) . copyRange ( prevSheetMemory ,
oBBox . r1 , oBBox . r1 , oBBox . r2 - oBBox . r1 + 1 ) ; this . nColsCount = Math . max ( this . nColsCount , this . getColDataLength ( ) ) ; this . getRange3 ( oBBox . r1 , oBBox . c1 , oBBox . r2 , oBBox . c2 ) . _foreachNoEmpty ( function ( cell ) { cell . clearDataKeepXf ( borders [ cell . nRow ] ) } ) } } this . workbook . dependencyFormulas . notifyChanged ( renameRes . changed ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _ShiftCellsRight , this . getId ( ) , oActualRange , new UndoRedoData _BBox ( oBBox ) ) ; this . autoFilters . redrawStylesTables ( redrawTablesArr ) } ; Worksheet . prototype . _shiftCellsBottom =
function ( oBBox , displayNameFormatTable ) { var t = this ; var nTop = oBBox . r1 ; var nBottom = oBBox . r2 ; var dif = nBottom - nTop + 1 ; var oActualRange = new Asc . Range ( oBBox . c1 , oBBox . r1 , oBBox . c2 , gc _nMaxRow0 ) ; var offset = new AscCommon . CellBase ( dif , 0 ) ; var renameRes = this . renameDependencyNodes ( offset , oBBox ) ; var redrawTablesArr ; if ( ! this . workbook . bUndoChanges && undefined === displayNameFormatTable ) redrawTablesArr = this . autoFilters . insertRows ( "insCell" , oBBox , c _oAscInsertOptions . InsertCellsAndShiftDown , displayNameFormatTable ) ; this . _updateFormulasParents ( oActualRange . r1 ,
oActualRange . c1 , oActualRange . r2 , oActualRange . c2 , oBBox , offset , renameRes . shiftedShared ) ; var borders ; if ( nTop > 0 && ! this . workbook . bUndoChanges ) borders = this . _getBordersForInsert ( oBBox , true ) ; for ( var i = oBBox . c1 ; i <= oBBox . c2 ; ++ i ) { var sheetMemory = this . getColDataNoEmpty ( i ) ; if ( sheetMemory ) { sheetMemory . insertRange ( nTop , dif ) ; t . cellsByColRowsCount = Math . max ( t . cellsByColRowsCount , sheetMemory . getSize ( ) ) } } this . nRowsCount = Math . max ( this . nRowsCount , this . cellsByColRowsCount ) ; if ( nTop > 0 && ! this . workbook . bUndoChanges ) { for ( var i =
oBBox . c1 ; i <= oBBox . c2 ; ++ i ) { var sheetMemory = this . getColDataNoEmpty ( i ) ; if ( sheetMemory ) { sheetMemory . copyRangeByChunk ( nTop - 1 , 1 , nTop , dif ) ; t . cellsByColRowsCount = Math . max ( t . cellsByColRowsCount , sheetMemory . getSize ( ) ) } } this . nRowsCount = Math . max ( this . nRowsCount , this . cellsByColRowsCount ) ; this . getRange3 ( oBBox . r1 , oBBox . c1 , oBBox . r2 , oBBox . c2 ) . _foreachNoEmpty ( function ( cell ) { cell . clearDataKeepXf ( borders [ cell . nCol ] ) } ) } this . workbook . dependencyFormulas . notifyChanged ( renameRes . changed ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet ,
AscCH . historyitem _Worksheet _ShiftCellsBottom , this . getId ( ) , oActualRange , new UndoRedoData _BBox ( oBBox ) ) ; if ( ! this . workbook . bUndoChanges && undefined !== displayNameFormatTable ) redrawTablesArr = this . autoFilters . insertRows ( "insCell" , oBBox , c _oAscInsertOptions . InsertCellsAndShiftDown , displayNameFormatTable ) ; if ( ! this . workbook . bUndoChanges ) this . autoFilters . redrawStylesTables ( redrawTablesArr ) } ; Worksheet . prototype . _setIndex = function ( ind ) { this . index = ind } ; Worksheet . prototype . _BuildDependencies = function ( cellRange ) { var ca ;
for ( var i in cellRange ) { if ( null === cellRange [ i ] ) { cellRange [ i ] = i ; continue } ca = g _oCellAddressUtils . getCellAddress ( i ) ; this . _getCellNoEmpty ( ca . getRow0 ( ) , ca . getCol0 ( ) , function ( c ) { if ( c ) c . _BuildDependencies ( true ) } ) } } ; Worksheet . prototype . _setHandlersTablePart = function ( ) { if ( ! this . TableParts ) return ; for ( var i = 0 ; i < this . TableParts . length ; i ++ ) this . TableParts [ i ] . setHandlers ( this . handlers ) } ; Worksheet . prototype . getTableRangeForFormula = function ( name , objectParam ) { var res = null ; if ( ! this . TableParts || ! name ) return res ; for ( var i =
0 ; i < this . TableParts . length ; i ++ ) if ( this . TableParts [ i ] . DisplayName . toLowerCase ( ) === name . toLowerCase ( ) ) { res = this . TableParts [ i ] . getTableRangeForFormula ( objectParam ) ; break } return res } ; Worksheet . prototype . getTableIndexColumnByName = function ( tableName , columnName ) { var res = null ; if ( ! this . TableParts || ! tableName ) return res ; for ( var i = 0 ; i < this . TableParts . length ; i ++ ) if ( this . TableParts [ i ] . DisplayName . toLowerCase ( ) === tableName . toLowerCase ( ) ) { res = this . TableParts [ i ] . getTableIndexColumnByName ( columnName ) ; break } return res } ;
Worksheet . prototype . getTableNameColumnByIndex = function ( tableName , columnIndex ) { var res = null ; if ( ! this . TableParts || ! tableName ) return res ; for ( var i = 0 ; i < this . TableParts . length ; i ++ ) if ( this . TableParts [ i ] . DisplayName . toLowerCase ( ) === tableName . toLowerCase ( ) ) { res = this . TableParts [ i ] . getTableNameColumnByIndex ( columnIndex ) ; break } return res } ; Worksheet . prototype . getTableByName = function ( tableName ) { var res = null ; if ( ! this . TableParts || ! tableName ) return res ; for ( var i = 0 ; i < this . TableParts . length ; i ++ ) if ( this . TableParts [ i ] . DisplayName . toLowerCase ( ) ===
function ( ) { return this . getWorksheet ( this . nActive ) } ; Workbook . prototype . setActive = function ( index ) { if ( index >= 0 && index < this . aWorksheets . length ) { this . nActive = index ; this . cleanFindResults ( ) ; return true } return false } ; Workbook . prototype . setActiveById = function ( sheetId ) { var ws = this . getWorksheetById ( sheetId ) ; if( ! ws && Array . isArray ( this . aWorksheets ) ) ws = this . aWorksheets [ this . aWorksheets . length - 1 ] ; return this . setActive ( ws . getIndex ( ) ) } ; Workbook . prototype . getSheetIdByIndex = function ( index ) { var ws = this . getWorksheet ( index ) ;
return ws ? ws . getId ( ) : null } ; Workbook . prototype . getWorksheet = function ( index ) { if ( index >= 0 && index < this . aWorksheets . length ) return this . aWorksheets [ index ] ; return null } ; Workbook . prototype . getWorksheetById = function ( id ) { return this . aWorksheetsById [ id ] } ; Workbook . prototype . getWorksheetByName = function ( name ) { for ( var i = 0 ; i < this . aWorksheets . length ; i ++ ) if ( this . aWorksheets [ i ] . getName ( ) == name ) return this . aWorksheets [ i ] ; return null } ; Workbook . prototype . getWorksheetIndexByName = function ( name ) { for ( var i = 0 ; i < this . aWorksheets . length ; i ++ ) if ( this . aWorksheets [ i ] . getName ( ) ==
name ) return i ; return null } ; Workbook . prototype . getWorksheetCount = function ( ) { return this . aWorksheets . length } ; Workbook . prototype . createWorksheet = function ( indexBefore , sName , sId ) { this . dependencyFormulas . lockRecal ( ) ; History . Create _NewPoint ( ) ; History . TurnOff ( ) ; var wsActive = this . getActiveWs ( ) ; var oNewWorksheet = new Worksheet ( this , this . aWorksheets . length , sId ) ; if ( this . checkValidSheetName ( sName ) ) oNewWorksheet . sName = sName ; oNewWorksheet . initPostOpen ( this . wsHandlers ) ; if ( null != indexBefore && indexBefore >= 0 && indexBefore <
this . aWorksheets . length ) this . aWorksheets . splice ( indexBefore , 0 , oNewWorksheet ) ; else { indexBefore = this . aWorksheets . length ; this . aWorksheets . push ( oNewWorksheet ) } this . aWorksheetsById [ oNewWorksheet . getId ( ) ] = oNewWorksheet ; this . _updateWorksheetIndexes ( wsActive ) ; History . TurnOn ( ) ; this . _insertWorksheetFormula ( oNewWorksheet . index ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorkbook , AscCH . historyitem _Workbook _SheetAdd , null , null , new UndoRedoData _SheetAdd ( indexBefore , oNewWorksheet . getName ( ) , null , oNewWorksheet . getId ( ) ) ) ;
History . SetSheetUndo ( wsActive . getId ( ) ) ; History . SetSheetRedo ( oNewWorksheet . getId ( ) ) ; this . dependencyFormulas . unlockRecal ( ) ; return oNewWorksheet . index } ; Workbook . prototype . copyWorksheet = function ( index , insertBefore , sName , sId , bFromRedo , tableNames ) { if ( index >= 0 && index < this . aWorksheets . length ) { this . dependencyFormulas . buildDependency ( ) ; History . TurnOff ( ) ; var wsActive = this . getActiveWs ( ) ; var wsFrom = this . aWorksheets [ index ] ; var newSheet = new Worksheet ( this , - 1 , sId ) ; if ( null != insertBefore && insertBefore >= 0 && insertBefore <
this . aWorksheets . length ) this . aWorksheets . splice ( insertBefore , 0 , newSheet ) ; else this . aWorksheets . push ( newSheet ) ; this . aWorksheetsById [ newSheet . getId ( ) ] = newSheet ; this . _updateWorksheetIndexes ( wsActive ) ; var renameParams = newSheet . copyFrom ( wsFrom , sName , tableNames ) ; newSheet . initPostOpen ( this . wsHandlers ) ; History . TurnOn ( ) ; this . dependencyFormulas . copyDefNameByWorksheet ( wsFrom , newSheet , renameParams ) ; this . _insertWorksheetFormula ( insertBefore ) ; if ( ! tableNames ) tableNames = newSheet . getTableNames ( ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorkbook ,
AscCH . historyitem _Workbook _SheetAdd , null , null , new UndoRedoData _SheetAdd ( insertBefore , newSheet . getName ( ) , wsFrom . getId ( ) , newSheet . getId ( ) , tableNames ) ) ; History . SetSheetUndo ( wsActive . getId ( ) ) ; History . SetSheetRedo ( newSheet . getId ( ) ) ; if ( ! ( bFromRedo === true ) ) wsFrom . copyObjects ( newSheet , wsFrom ) ; this . sortDependency ( ) } } ; Workbook . prototype . insertWorksheet = function ( index , sheet ) { var wsActive = this . getActiveWs ( ) ; if ( null != index && index >= 0 && index < this . aWorksheets . length ) this . aWorksheets . splice ( index , 0 , sheet ) ; else this . aWorksheets . push ( sheet ) ;
this . aWorksheetsById [ sheet . getId ( ) ] = sheet ; this . _updateWorksheetIndexes ( wsActive ) ; this . _insertWorksheetFormula ( index ) ; this . _insertTablePartsName ( sheet ) ; sheet . _BuildDependencies ( sheet . getCwf ( ) ) ; this . sortDependency ( ) } ; Workbook . prototype . _insertTablePartsName = function ( sheet ) { if ( sheet && sheet . TableParts && sheet . TableParts . length ) for ( var i = 0 ; i < sheet . TableParts . length ; i ++ ) { var tablePart = sheet . TableParts [ i ] ; this . dependencyFormulas . addTableName ( sheet , tablePart ) ; tablePart . buildDependencies ( ) } } ; Workbook . prototype . _insertWorksheetFormula =
function ( index ) { if ( index > 0 && index < this . aWorksheets . length ) { var oWsBefore = this . aWorksheets [ index - 1 ] ; this . dependencyFormulas . changeSheet ( this . dependencyFormulas . prepareChangeSheet ( oWsBefore . getId ( ) , { insert : index } ) ) } } ; Workbook . prototype . replaceWorksheet = function ( indexFrom , indexTo ) { if ( indexFrom >= 0 && indexFrom < this . aWorksheets . length && indexTo >= 0 && indexTo < this . aWorksheets . length ) { var wsActive = this . getActiveWs ( ) ; var oWsFrom = this . aWorksheets [ indexFrom ] ; var tempW = { wF : oWsFrom , wFI : indexFrom , wTI : indexTo } ; if ( tempW . wFI <
tempW . wTI ) tempW . wTI ++ ; this . dependencyFormulas . lockRecal ( ) ; var prepared = this . dependencyFormulas . prepareChangeSheet ( oWsFrom . getId ( ) , { replace : tempW } , null ) ; var movedSheet = this . aWorksheets . splice ( indexFrom , 1 ) ; this . aWorksheets . splice ( indexTo , 0 , movedSheet [ 0 ] ) ; this . _updateWorksheetIndexes ( wsActive ) ; this . dependencyFormulas . changeSheet ( prepared ) ; this . _insertWorksheetFormula ( indexTo ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorkbook , AscCH . historyitem _Workbook _SheetMove , null , null , new UndoRedoData _FromTo ( indexFrom ,
indexTo ) ) ; this . dependencyFormulas . unlockRecal ( ) } } ; Workbook . prototype . findSheetNoHidden = function ( nIndex ) { var i , ws , oRes = null , bFound = false , countWorksheets = this . getWorksheetCount ( ) ; for ( i = nIndex ; i < countWorksheets ; ++ i ) { ws = this . getWorksheet ( i ) ; if ( false === ws . getHidden ( ) ) { oRes = ws ; bFound = true ; break } } if ( ! bFound ) for ( i = nIndex - 1 ; i >= 0 ; -- i ) { ws = this . getWorksheet ( i ) ; if ( false === ws . getHidden ( ) ) { oRes = ws ; break } } return oRes } ; Workbook . prototype . removeWorksheet = function ( nIndex , outputParams ) { var bEmpty = true ; for ( var i = 0 , length =
this . aWorksheets . length ; i < length ; ++ i ) { var worksheet = this . aWorksheets [ i ] ; if ( false == worksheet . getHidden ( ) && i != nIndex ) { bEmpty = false ; break } } if ( bEmpty ) return - 1 ; var removedSheet = this . getWorksheet ( nIndex ) ; if ( removedSheet ) { var removedSheetId = removedSheet . getId ( ) ; this . dependencyFormulas . lockRecal ( ) ; var prepared = this . dependencyFormulas . prepareRemoveSheet ( removedSheetId , removedSheet . getTableNames ( ) ) ; var wsActive = this . getActiveWs ( ) ; var oVisibleWs = null ; this . aWorksheets . splice ( nIndex , 1 ) ; delete this . aWorksheetsById [ removedSheetId ] ;
if ( nIndex == this . getActive ( ) ) { oVisibleWs = this . findSheetNoHidden ( nIndex ) ; if ( null != oVisibleWs ) wsActive = oVisibleWs } History . Add ( AscCommonExcel . g _oUndoRedoWorkbook , AscCH . historyitem _Workbook _SheetRemove , null , null , new AscCommonExcel . UndoRedoData _SheetRemove ( nIndex , removedSheetId , removedSheet ) ) ; if ( null != oVisibleWs ) { History . SetSheetUndo ( removedSheetId ) ; History . SetSheetRedo ( wsActive . getId ( ) ) } if ( null != outputParams ) outputParams . sheet = removedSheet ; this . _updateWorksheetIndexes ( wsActive ) ; this . dependencyFormulas . removeSheet ( prepared ) ;
this . dependencyFormulas . unlockRecal ( ) ; return wsActive . getIndex ( ) } return - 1 } ; Workbook . prototype . _updateWorksheetIndexes = function ( wsActive ) { this . forEach ( function ( ws , index ) { ws . _setIndex ( index ) } ) ; if ( null != wsActive ) this . setActive ( wsActive . getIndex ( ) ) } ; Workbook . prototype . checkUniqueSheetName = function ( name ) { var workbookSheetCount = this . getWorksheetCount ( ) ; for ( var i = 0 ; i < workbookSheetCount ; i ++ ) if ( this . getWorksheet ( i ) . getName ( ) == name ) return i ; return - 1 } ; Workbook . prototype . checkValidSheetName = function ( name ) { return name &&
name . length < g _nSheetNameMaxLength } ; Workbook . prototype . getUniqueSheetNameFrom = function ( name , bCopy ) { var nIndex = 1 ; var sNewName = "" ; var fGetPostfix = null ; if ( bCopy ) { var result = /^(.*)\((\d)\)$/ . exec ( name ) ; if ( result ) { fGetPostfix = function ( nIndex ) { return "(" + nIndex + ")" } ; name = result [ 1 ] } else { fGetPostfix = function ( nIndex ) { return " (" + nIndex + ")" } ; name = name } } else fGetPostfix = function ( nIndex ) { return nIndex . toString ( ) } ; var workbookSheetCount = this . getWorksheetCount ( ) ; while ( nIndex < 1E4 ) { var sPosfix = fGetPostfix ( nIndex ) ; sNewName =
name + sPosfix ; if ( sNewName . length > g _nSheetNameMaxLength ) { name = name . substring ( 0 , g _nSheetNameMaxLength - sPosfix . length ) ; sNewName = name + sPosfix } var bUniqueName = true ; for ( var i = 0 ; i < workbookSheetCount ; i ++ ) if ( this . getWorksheet ( i ) . getName ( ) == sNewName ) { bUniqueName = false ; break } if ( bUniqueName ) break ; nIndex ++ } return sNewName } ; Workbook . prototype . _generateFontMap = function ( ) { var oFontMap = { "Arial" : 1 } ; var i ; oFontMap [ g _oDefaultFormat . Font . getName ( ) ] = 1 ; if ( null != this . theme ) AscFormat . checkThemeFonts ( oFontMap , this . theme . themeElements . fontScheme ) ;
for ( i = 1 ; i <= g _StyleCache . getXfCount ( ) ; ++ i ) { var xf = g _StyleCache . getXf ( i ) ; if ( xf . font ) oFontMap [ xf . font . getName ( ) ] = 1 } this . sharedStrings . generateFontMap ( oFontMap ) ; this . forEach ( function ( ws ) { ws . generateFontMap ( oFontMap ) } ) ; this . CellStyles . generateFontMap ( oFontMap ) ; return oFontMap } ; Workbook . prototype . generateFontMap = function ( ) { var oFontMap = this . _generateFontMap ( ) ; var aRes = [ ] ; for ( var i in oFontMap ) aRes . push ( i ) ; return aRes } ; Workbook . prototype . generateFontMap2 = function ( ) { var oFontMap = this . _generateFontMap ( ) ; var aRes =
[ ] ; for ( var i in oFontMap ) aRes . push ( new AscFonts . CFont ( i , 0 , "" , 0 ) ) ; AscFonts . FontPickerByCharacter . extendFonts ( aRes ) ; return aRes } ; Workbook . prototype . getAllImageUrls = function ( ) { var aImageUrls = [ ] ; this . forEach ( function ( ws ) { ws . getAllImageUrls ( aImageUrls ) } ) ; return aImageUrls } ; Workbook . prototype . reassignImageUrls = function ( oImages ) { this . forEach ( function ( ws ) { ws . reassignImageUrls ( oImages ) } ) } ; Workbook . prototype . recalcWB = function ( rebuild , opt _sheetId ) { var formulas ; if ( rebuild ) { formulas = this . getAllFormulas ( ) ; for ( var i =
0 ; i < formulas . length ; ++ i ) { var formula = formulas [ i ] ; formula . removeDependencies ( ) ; formula . setFormula ( formula . getFormula ( ) ) ; formula . parse ( ) ; formula . buildDependencies ( ) } } else if ( opt _sheetId ) { formulas = [ ] ; var ws = this . getWorksheetById ( opt _sheetId ) ; ws . getAllFormulas ( formulas ) } else formulas = this . getAllFormulas ( ) ; this . dependencyFormulas . notifyChanged ( formulas ) ; this . dependencyFormulas . calcTree ( ) } ; Workbook . prototype . checkDefName = function ( checkName , scope ) { return this . dependencyFormulas . checkDefName ( checkName , scope ) } ;
Workbook . prototype . getDefinedNamesWB = function ( defNameListId , bLocale ) { return this . dependencyFormulas . getDefinedNamesWB ( defNameListId , bLocale ) } ; Workbook . prototype . getDefinedNamesWS = function ( sheetId ) { return this . dependencyFormulas . getDefinedNamesWS ( sheetId ) } ; Workbook . prototype . addDefName = function ( name , ref , sheetId , hidden , isTable ) { return this . dependencyFormulas . addDefName ( name , ref , sheetId , hidden , isTable ) } ; Workbook . prototype . getDefinesNames = function ( name , sheetId ) { return this . dependencyFormulas . getDefNameByName ( name ,
sheetId ) } ; Workbook . prototype . getDefinedName = function ( name ) { var sheetId = this . getSheetIdByIndex ( name . LocalSheetId ) ; return this . dependencyFormulas . getDefNameByName ( name . Name , sheetId ) } ; Workbook . prototype . delDefinesNames = function ( defName ) { this . delDefinesNamesUndoRedo ( this . getUndoDefName ( defName ) ) } ; Workbook . prototype . delDefinesNamesUndoRedo = function ( defName ) { this . dependencyFormulas . removeDefName ( defName . sheetId , defName . name ) ; this . dependencyFormulas . calcTree ( ) } ; Workbook . prototype . editDefinesNames = function ( oldName ,
newName ) { return this . editDefinesNamesUndoRedo ( this . getUndoDefName ( oldName ) , this . getUndoDefName ( newName ) ) } ; Workbook . prototype . editDefinesNamesUndoRedo = function ( oldName , newName ) { var res = this . dependencyFormulas . editDefinesNames ( oldName , newName ) ; this . dependencyFormulas . calcTree ( ) ; return res } ; Workbook . prototype . findDefinesNames = function ( ref , sheetId , bLocale ) { return this . dependencyFormulas . getDefNameByRef ( ref , sheetId , bLocale ) } ; Workbook . prototype . unlockDefName = function ( ) { this . dependencyFormulas . unlockDefName ( ) } ;
Workbook . prototype . unlockCurrentDefName = function ( name , sheetId ) { this . dependencyFormulas . unlockCurrentDefName ( name , sheetId ) } ; Workbook . prototype . checkDefNameLock = function ( ) { return this . dependencyFormulas . checkDefNameLock ( ) } ; Workbook . prototype . _SerializeHistoryBase64 = function ( oMemory , item , aPointChangesBase64 ) { if ( ! item . LocalChange ) { var nPosStart = oMemory . GetCurPosition ( ) ; item . Serialize ( oMemory , this . oApi . collaborativeEditing ) ; var nPosEnd = oMemory . GetCurPosition ( ) ; var nLen = nPosEnd - nPosStart ; if ( nLen > 0 ) aPointChangesBase64 . push ( nLen +
";" + oMemory . GetBase64Memory2 ( nPosStart , nLen ) ) } } ; Workbook . prototype . SerializeHistory = function ( ) { var aRes = [ ] ; var t , j , length2 ; AscCommon . CollaborativeEditing . Refresh _DCChanges ( ) ; var aActions = this . aCollaborativeActions . concat ( History . GetSerializeArray ( ) ) ; if ( aActions . length > 0 ) { var oMemory = new AscCommon . CMemory ; for ( var i = 0 , length = aActions . length ; i < length ; ++ i ) { var aPointChanges = aActions [ i ] ; for ( j = 0 , length2 = aPointChanges . length ; j < length2 ; ++ j ) { var item = aPointChanges [ j ] ; this . _SerializeHistoryBase64 ( oMemory , item ,
aRes ) } } this . aCollaborativeActions = [ ] ; this . snapshot = this . _getSnapshot ( ) } return aRes } ; Workbook . prototype . _getSnapshot = function ( ) { var wb = new Workbook ( new AscCommonExcel . asc _CHandlersList , this . oApi ) ; wb . dependencyFormulas = this . dependencyFormulas . getSnapshot ( wb ) ; this . forEach ( function ( ws ) { ws = ws . getSnapshot ( wb ) ; wb . aWorksheets . push ( ws ) ; wb . aWorksheetsById [ ws . getId ( ) ] = ws } ) ; wb . init ( { } , true , false ) ; return wb } ; Workbook . prototype . getAllFormulas = function ( ) { var res = [ ] ; this . dependencyFormulas . getAllFormulas ( res ) ; this . forEach ( function ( ws ) { ws . getAllFormulas ( res ) } ) ;
return res } ; Workbook . prototype . _forwardTransformation = function ( wbSnapshot , changesMine , changesTheir ) { History . TurnOff ( ) ; var res1 = this . _forwardTransformationGetTransform ( wbSnapshot , changesTheir , changesMine ) ; var res2 = this . _forwardTransformationGetTransform ( wbSnapshot , changesMine , changesTheir ) ; var i , elem , elemWrap ; for ( i = 0 ; i < res1 . modify . length ; ++ i ) { elemWrap = res1 . modify [ i ] ; elem = elemWrap . elem ; elem . oClass . forwardTransformationSet ( elem . nActionType , elem . oData , elem . nSheetId , elemWrap ) } for ( i = 0 ; i < res2 . modify . length ; ++ i ) { elemWrap =
res2 . modify [ i ] ; elem = elemWrap . elem ; elem . oClass . forwardTransformationSet ( elem . nActionType , elem . oData , elem . nSheetId , elemWrap ) } for ( var oldName in res1 . renameSheet ) { var ws = this . getWorksheetByName ( oldName ) ; if ( ws ) ws . setName ( res1 . renameSheet [ oldName ] ) } History . TurnOn ( ) } ; Workbook . prototype . _forwardTransformationGetTransform = function ( wbSnapshot , changesMaster , changesModify ) { var res = { modify : [ ] , renameSheet : { } } ; var changesMasterSelected = [ ] ; var i , elem ; if ( changesModify . length > 0 ) for ( i = 0 ; i < changesMaster . length ; ++ i ) { elem =
changesMaster [ i ] ; if ( elem . oClass && elem . oClass . forwardTransformationIsAffect && elem . oClass . forwardTransformationIsAffect ( elem . nActionType ) ) changesMasterSelected . push ( elem ) } if ( changesMasterSelected . length > 0 && changesModify . length > 0 ) { var wbSnapshotCur = wbSnapshot . _getSnapshot ( ) ; var formulas = [ ] ; for ( i = 0 ; i < changesModify . length ; ++ i ) { elem = changesModify [ i ] ; var renameRes = null ; if ( elem . oClass && elem . oClass . forwardTransformationGet ) { var getRes = elem . oClass . forwardTransformationGet ( elem . nActionType , elem . oData , elem . nSheetId ) ;
if ( getRes && getRes . formula ) formulas . push ( new ForwardTransformationFormula ( elem , getRes . formula , null ) ) ; if ( getRes && getRes . name ) renameRes = this . _forwardTransformationRenameStart ( wbSnapshotCur . _getSnapshot ( ) , changesMasterSelected , getRes ) } if ( elem . oClass && elem . oClass . forwardTransformationIsAffect && elem . oClass . forwardTransformationIsAffect ( elem . nActionType ) ) { if ( formulas . length > 0 ) { this . _forwardTransformationFormula ( wbSnapshotCur . _getSnapshot ( ) , formulas , changesMasterSelected , res ) ; formulas = [ ] } elem . oClass . Redo ( elem . nActionType ,
elem . oData , elem . nSheetId , wbSnapshotCur ) } if ( renameRes ) this . _forwardTransformationRenameEnd ( renameRes , res . renameSheet , getRes , elem ) } this . _forwardTransformationFormula ( wbSnapshotCur , formulas , changesMasterSelected , res ) } return res } ; Workbook . prototype . _forwardTransformationRenameStart = function ( wbSnapshot , changes , getRes ) { var res = { newName : null } ; for ( var i = 0 ; i < changes . length ; ++ i ) { var elem = changes [ i ] ; elem . oClass . Redo ( elem . nActionType , elem . oData , elem . nSheetId , wbSnapshot ) } if ( - 1 != wbSnapshot . checkUniqueSheetName ( getRes . name ) ) res . newName =
wbSnapshot . getUniqueSheetNameFrom ( getRes . name , true ) ; return res } ; Workbook . prototype . _forwardTransformationRenameEnd = function ( renameRes , renameSheet , getRes , elemCur ) { var isChange = false ; if ( getRes . from ) { var renameCur = renameSheet [ getRes . from ] ; if ( renameCur ) { delete renameSheet [ getRes . from ] ; getRes . from = renameCur ; isChange = true } } if ( renameRes && renameRes . newName ) { renameSheet [ getRes . name ] = renameRes . newName ; getRes . name = renameRes . newName ; isChange = true } if ( isChange && elemCur . oClass . forwardTransformationSet ) elemCur . oClass . forwardTransformationSet ( elemCur . nActionType ,
elemCur . oData , elemCur . nSheetId , getRes ) } ; Workbook . prototype . _forwardTransformationFormula = function ( wbSnapshot , formulas , changes , res ) { if ( formulas . length > 0 ) { var i , elem , ftFormula , ws ; for ( i = 0 ; i < formulas . length ; ++ i ) { ftFormula = formulas [ i ] ; ws = wbSnapshot . getWorksheetById ( ftFormula . elem . nSheetId ) ; if ( ws ) { ftFormula . parsed = new parserFormula ( ftFormula . formula , ftFormula , ws ) ; ftFormula . parsed . parse ( ) ; ftFormula . parsed . buildDependencies ( ) } } for ( var oldName in res . renameSheet ) { ws = wbSnapshot . getWorksheetByName ( oldName ) ;
if ( ws ) ws . setName ( res . renameSheet [ oldName ] ) } for ( i = 0 ; i < changes . length ; ++ i ) { elem = changes [ i ] ; elem . oClass . Redo ( elem . nActionType , elem . oData , elem . nSheetId , wbSnapshot ) } for ( i = 0 ; i < formulas . length ; ++ i ) { ftFormula = formulas [ i ] ; if ( ftFormula . parsed ) { ftFormula . parsed . removeDependencies ( ) ; res . modify . push ( ftFormula ) } } } } ; Workbook . prototype . DeserializeHistory = function ( aChanges , fCallback ) { var oThis = this ; this . aCollaborativeActions = this . aCollaborativeActions . concat ( History . GetSerializeArray ( ) ) ; if ( aChanges . length > 0 ) { this . bCollaborativeChanges =
true ; var dstLen = 0 ; var aIndexes = [ ] , i , length = aChanges . length , sChange ; for ( i = 0 ; i < length ; ++ i ) { sChange = aChanges [ i ] ; var nIndex = sChange . indexOf ( ";" ) ; if ( - 1 != nIndex ) { dstLen += parseInt ( sChange . substring ( 0 , nIndex ) ) ; nIndex ++ } aIndexes . push ( nIndex ) } var pointer = g _memory . Alloc ( dstLen ) ; var stream = new AscCommon . FT _Stream2 ( pointer . data , dstLen ) ; stream . obj = pointer . obj ; var nCurOffset = 0 ; var aUndoRedoElems = [ ] ; for ( i = 0 ; i < length ; ++ i ) { sChange = aChanges [ i ] ; var oBinaryFileReader = new AscCommonExcel . BinaryFileReader ; nCurOffset = oBinaryFileReader . getbase64DecodedData2 ( sChange ,
aIndexes [ i ] , stream , nCurOffset ) ; var item = new UndoRedoItemSerializable ; item . Deserialize ( stream ) ; aUndoRedoElems . push ( item ) } var wsViews = window [ "Asc" ] [ "editor" ] . wb . wsViews ; if ( oThis . oApi . collaborativeEditing . getFast ( ) ) AscCommon . CollaborativeEditing . Clear _DocumentPositions ( ) ; for ( var i in wsViews ) if ( isRealObject ( wsViews [ i ] ) && isRealObject ( wsViews [ i ] . objectRender ) && isRealObject ( wsViews [ i ] . objectRender . controller ) ) { wsViews [ i ] . endEditChart ( ) ; if ( oThis . oApi . collaborativeEditing . getFast ( ) ) { var oState = wsViews [ i ] . objectRender . saveStateBeforeLoadChanges ( ) ;
if ( oState ) { if ( oState . Pos ) AscCommon . CollaborativeEditing . Add _DocumentPosition ( oState . Pos ) ; if ( oState . StartPos ) AscCommon . CollaborativeEditing . Add _DocumentPosition ( oState . StartPos ) ; if ( oState . EndPos ) AscCommon . CollaborativeEditing . Add _DocumentPosition ( oState . EndPos ) } } wsViews [ i ] . objectRender . controller . resetSelection ( ) } oFormulaLocaleInfo . Parse = false ; oFormulaLocaleInfo . DigitSep = false ; AscFonts . IsCheckSymbols = true ; History . Clear ( ) ; History . TurnOff ( ) ; var history = new AscCommon . CHistory ; history . init ( this ) ; history . Create _NewPoint ( ) ;
history . SetSelection ( null ) ; history . SetSelectionRedo ( null ) ; var oRedoObjectParam = new AscCommonExcel . RedoObjectParam ; history . UndoRedoPrepare ( oRedoObjectParam , false ) ; var changesMine = [ ] . concat . apply ( [ ] , oThis . aCollaborativeActions ) ; oThis . _forwardTransformation ( oThis . snapshot , changesMine , aUndoRedoElems ) ; for ( var i = 0 , length = aUndoRedoElems . length ; i < length ; ++ i ) { var item = aUndoRedoElems [ i ] ; if ( ( null != item . oClass || item . oData && typeof item . oData . sChangedObjectId === "string" ) && null != item . nActionType ) { if ( window [ "NATIVE_EDITOR_ENJINE" ] ===
true && window [ "native" ] [ "CheckNextChange" ] ) if ( ! window [ "native" ] [ "CheckNextChange" ] ( ) ) break ; history . RedoAdd ( oRedoObjectParam , item . oClass , item . nActionType , item . nSheetId , item . oRange , item . oData ) } } AscFonts . IsCheckSymbols = false ; var oFontMap = this . _generateFontMap ( ) ; window [ "Asc" ] [ "editor" ] . _loadFonts ( oFontMap , function ( ) { if ( oThis . oApi . collaborativeEditing . getFast ( ) ) for ( var i in wsViews ) if ( isRealObject ( wsViews [ i ] ) && isRealObject ( wsViews [ i ] . objectRender ) && isRealObject ( wsViews [ i ] . objectRender . controller ) ) { var oState =
wsViews [ i ] . objectRender . getStateBeforeLoadChanges ( ) ; if ( oState ) { if ( oState . Pos ) AscCommon . CollaborativeEditing . Update _DocumentPosition ( oState . Pos ) ; if ( oState . StartPos ) AscCommon . CollaborativeEditing . Update _DocumentPosition ( oState . StartPos ) ; if ( oState . EndPos ) AscCommon . CollaborativeEditing . Update _DocumentPosition ( oState . EndPos ) } wsViews [ i ] . objectRender . loadStateAfterLoadChanges ( ) } oFormulaLocaleInfo . Parse = true ; oFormulaLocaleInfo . DigitSep = true ; history . UndoRedoEnd ( null , oRedoObjectParam , false ) ; History . TurnOn ( ) ;
oThis . bCollaborativeChanges = false ; oThis . snapshot = oThis . _getSnapshot ( ) ; if ( null != fCallback ) fCallback ( ) } ) } else if ( null != fCallback ) fCallback ( ) } ; Workbook . prototype . DeserializeHistoryNative = function ( oRedoObjectParam , data , isFull ) { if ( null != data ) { this . bCollaborativeChanges = true ; if ( null == oRedoObjectParam ) { var wsViews = window [ "Asc" ] [ "editor" ] . wb . wsViews ; for ( var i in wsViews ) if ( isRealObject ( wsViews [ i ] ) && isRealObject ( wsViews [ i ] . objectRender ) && isRealObject ( wsViews [ i ] . objectRender . controller ) ) { wsViews [ i ] . endEditChart ( ) ;
wsViews [ i ] . objectRender . controller . resetSelection ( ) } History . Clear ( ) ; History . Create _NewPoint ( ) ; History . SetSelection ( null ) ; History . SetSelectionRedo ( null ) ; oRedoObjectParam = new AscCommonExcel . RedoObjectParam ; History . UndoRedoPrepare ( oRedoObjectParam , false ) } var stream = new AscCommon . FT _Stream2 ( data , data . length ) ; stream . obj = null ; var _count = stream . GetLong ( ) ; var _pos = 4 ; for ( var i = 0 ; i < _count ; i ++ ) { if ( window [ "NATIVE_EDITOR_ENJINE" ] === true && window [ "native" ] [ "CheckNextChange" ] ) if ( ! window [ "native" ] [ "CheckNextChange" ] ( ) ) break ;
var _len = stream . GetLong ( ) ; _pos += 4 ; stream . size = _pos + _len ; stream . Seek ( _pos ) ; stream . Seek2 ( _pos ) ; var item = new UndoRedoItemSerializable ; item . Deserialize ( stream ) ; if ( ( null != item . oClass || item . oData && typeof item . oData . sChangedObjectId === "string" ) && null != item . nActionType ) History . RedoAdd ( oRedoObjectParam , item . oClass , item . nActionType , item . nSheetId , item . oRange , item . oData ) ; _pos += _len ; stream . Seek2 ( _pos ) ; stream . size = data . length } if ( isFull ) { History . UndoRedoEnd ( null , oRedoObjectParam , false ) ; History . Clear ( ) ; oRedoObjectParam =
null } this . bCollaborativeChanges = false } return oRedoObjectParam } ; Workbook . prototype . getTableRangeForFormula = function ( name , objectParam ) { var res = null ; for ( var i = 0 , length = this . aWorksheets . length ; i < length ; ++ i ) { var ws = this . aWorksheets [ i ] ; res = ws . getTableRangeForFormula ( name , objectParam ) ; if ( res !== null ) { res = { wsID : ws . getId ( ) , range : res } ; break } } return res } ; Workbook . prototype . getTableIndexColumnByName = function ( tableName , columnName ) { var res = null ; for ( var i = 0 , length = this . aWorksheets . length ; i < length ; ++ i ) { var ws = this . aWorksheets [ i ] ;
res = ws . getTableIndexColumnByName ( tableName , columnName ) ; if ( res !== null ) { res = { wsID : ws . getId ( ) , index : res , name : ws . getTableNameColumnByIndex ( tableName , res ) } ; break } } return res } ; Workbook . prototype . getTableNameColumnByIndex = function ( tableName , columnIndex ) { var res = null ; for ( var i = 0 , length = this . aWorksheets . length ; i < length ; ++ i ) { var ws = this . aWorksheets [ i ] ; res = ws . getTableNameColumnByIndex ( tableName , columnIndex ) ; if ( res !== null ) { res = { wsID : ws . getId ( ) , columnName : res } ; break } } return res } ; Workbook . prototype . getTableByName =
function ( tableName , wsID ) { var res = null ; var ws = this . getWorksheetById ( wsID ) ; return ws . getTableByName ( tableName ) } ; Workbook . prototype . updateSparklineCache = function ( sheet , ranges ) { this . forEach ( function ( ws ) { ws . updateSparklineCache ( sheet , ranges ) } ) } ; Workbook . prototype . sortDependency = function ( ) { this . dependencyFormulas . calcTree ( ) } ; Workbook . prototype . charCountToModelColWidth = function ( count ) { if ( count <= 0 ) return 0 ; return Asc . floor ( ( count * this . maxDigitWidth + this . paddingPlusBorder ) / this . maxDigitWidth * 256 ) / 256 } ; Workbook . prototype . modelColWidthToColWidth =
function ( mcw ) { return Asc . floor ( ( 256 * mcw + Asc . floor ( 128 / this . maxDigitWidth ) ) / 256 * this . maxDigitWidth ) } ; Workbook . prototype . colWidthToCharCount = function ( w ) { var pxInOneCharacter = this . maxDigitWidth + this . paddingPlusBorder ; return w < pxInOneCharacter ? 1 - Asc . floor ( 100 * ( pxInOneCharacter - w ) / pxInOneCharacter + . 49999 ) / 100 : Asc . floor ( ( w - this . paddingPlusBorder ) / this . maxDigitWidth * 100 + . 5 ) / 100 } ; Workbook . prototype . getUndoDefName = function ( ascName ) { if ( ! ascName ) return ascName ; var sheetId = this . getSheetIdByIndex ( ascName . LocalSheetId ) ;
return new UndoRedoData _DefinedNames ( ascName . Name , ascName . Ref , sheetId , ascName . isTable , ascName . isXLNM ) } ; Workbook . prototype . changeColorScheme = function ( sSchemeName ) { var scheme = AscCommon . getColorSchemeByName ( sSchemeName ) ; if ( ! scheme ) scheme = this . theme . getExtraClrScheme ( sSchemeName ) ; if ( ! scheme ) return ; History . Create _NewPoint ( ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorkbook , AscCH . historyitem _Workbook _ChangeColorScheme , null , null , new AscCommonExcel . UndoRedoData _ClrScheme ( this . theme . themeElements . clrScheme , scheme ) ) ;
this . theme . themeElements . clrScheme = scheme ; this . rebuildColors ( ) ; return true } ; Workbook . prototype . cleanFindResults = function ( ) { this . lastFindOptions = null ; this . lastFindCells = { } } ; Workbook . prototype . findCellText = function ( options ) { var ws = this . getActiveWs ( ) ; var result = ws . findCellText ( options ) , result2 = null ; if ( ! options . scanOnOnlySheet ) { var key = result && result . col + "-" + result . row ; if ( ! key || options . isEqual ( this . lastFindOptions ) && this . lastFindCells [ key ] ) { var i , active = this . getActive ( ) , start = 0 , end = this . getWorksheetCount ( ) ;
var inc = options . scanForward ? + 1 : - 1 ; for ( i = active + inc ; i < end && i >= start ; i += inc ) { ws = this . getWorksheet ( i ) ; if ( ws . getHidden ( ) ) continue ; result2 = ws . findCellText ( options ) ; if ( result2 ) break } if ( ! result2 ) { if ( options . scanForward ) { i = 0 ; end = active } else { i = end - 1 ; start = active + 1 } inc *= - 1 ; for ( ; i < end && i >= start ; i += inc ) { ws = this . getWorksheet ( i ) ; if ( ws . getHidden ( ) ) continue ; result2 = ws . findCellText ( options ) ; if ( result2 ) break } } if ( result2 ) { this . handlers . trigger ( "undoRedoHideSheet" , i ) ; key = result2 . col + "-" + result2 . row } } if ( key ) { this . lastFindOptions =
options . clone ( ) ; this . lastFindCells [ key ] = true } } if ( ! result2 && ! result ) this . cleanFindResults ( ) ; return result2 || result } ; Workbook . prototype . getComment = function ( id ) { if ( id ) { var sheet ; for ( var i = 0 ; i < this . aWorksheets . length ; ++ i ) { sheet = this . aWorksheets [ i ] ; for ( var j = 0 ; j < sheet . aComments . length ; ++ j ) if ( id === sheet . aComments [ j ] . asc _getGuid ( ) ) return sheet . aComments [ j ] } } return null } ; var tempHelp = new ArrayBuffer ( 8 ) ; var tempHelpUnit = new Uint8Array ( tempHelp ) ; var tempHelpFloat = new Float64Array ( tempHelp ) ; function SheetMemory ( structSize ,
maxIndex ) { this . data = null ; this . count = 0 ; this . structSize = structSize ; this . maxIndex = maxIndex } SheetMemory . prototype . checkSize = function ( index ) { var allocatedCount = this . data ? this . data . length / this . structSize : 0 ; if ( allocatedCount < index + 1 ) { var newAllocatedCount = Math . min ( Math . max ( 1.5 * this . count >> 0 , index + 1 ) , this . maxIndex + 1 ) ; if ( newAllocatedCount > allocatedCount ) { var oldData = this . data ; this . data = new Uint8Array ( newAllocatedCount * this . structSize ) ; if ( oldData ) this . data . set ( oldData ) } } this . count = Math . min ( Math . max ( this . count ,
index + 1 ) , this . maxIndex + 1 ) } ; SheetMemory . prototype . hasSize = function ( index ) { return index + 1 <= this . count } ; SheetMemory . prototype . getSize = function ( ) { return this . count } ; SheetMemory . prototype . clone = function ( ) { var sheetMemory = new SheetMemory ( this . structSize , this . maxIndex ) ; sheetMemory . data = this . data ? new Uint8Array ( this . data ) : null ; sheetMemory . count = this . count ; return sheetMemory } ; SheetMemory . prototype . deleteRange = function ( start , deleteCount ) { if ( start < this . count ) { var startOffset = start * this . structSize ; if ( start + deleteCount <
this . count ) { var endOffset = ( start + deleteCount ) * this . structSize ; this . data . set ( this . data . subarray ( endOffset ) , startOffset ) ; this . data . fill ( 0 , ( this . count - deleteCount ) * this . structSize ) ; this . count -= deleteCount } else { this . data . fill ( 0 , startOffset ) ; this . count = start } } } ; SheetMemory . prototype . insertRange = function ( start , insertCount ) { if ( start < this . count ) { this . checkSize ( this . count - 1 + insertCount ) ; var startOffset = start * this . structSize ; if ( start + insertCount < this . count ) { var endOffset = ( start + insertCount ) * this . structSize ;
var endData = ( this . count - insertCount ) * this . structSize ; this . data . set ( this . data . subarray ( startOffset , endData ) , endOffset ) ; this . data . fill ( 0 , startOffset , endOffset ) } else this . data . fill ( 0 , startOffset ) } } ; SheetMemory . prototype . copyRange = function ( sheetMemory , startFrom , startTo , count ) { var countCopied = 0 ; if ( startFrom < sheetMemory . count ) { countCopied = Math . min ( count , sheetMemory . count - startFrom ) ; this . checkSize ( startTo + countCopied ) ; countCopied = Math . min ( countCopied , this . count - startTo ) ; if ( countCopied > 0 ) { var startOffsetFrom =
startFrom * this . structSize ; var endOffsetFrom = ( startFrom + countCopied ) * this . structSize ; var startOffsetTo = startTo * this . structSize ; this . data . set ( sheetMemory . data . subarray ( startOffsetFrom , endOffsetFrom ) , startOffsetTo ) } } var countErase = Math . min ( count - countCopied , this . count - ( startTo + countCopied ) ) ; if ( countErase > 0 ) { var startOffsetErase = ( startTo + countCopied ) * this . structSize ; var endOffsetErase = ( startTo + countCopied + countErase ) * this . structSize ; this . data . fill ( 0 , startOffsetErase , endOffsetErase ) } } ; SheetMemory . prototype . copyRangeByChunk =
function ( from , fromCount , to , toCount ) { if ( from < this . count ) { this . checkSize ( to + toCount - 1 ) ; var fromStartOffset = from * this . structSize ; var fromEndOffset = Math . min ( from + fromCount , this . count ) * this . structSize ; var fromSubArray = this . data . subarray ( fromStartOffset , fromEndOffset ) ; for ( var i = to ; i < to + toCount && i < this . count ; i += fromCount ) this . data . set ( fromSubArray , i * this . structSize ) } } ; SheetMemory . prototype . clear = function ( start , end ) { end = Math . min ( end , this . count ) ; if ( start < end ) this . data . fill ( 0 , start * this . structSize , end * this . structSize ) } ;
SheetMemory . prototype . getUint8 = function ( index , offset ) { offset += index * this . structSize ; return this . data [ offset ] } ; SheetMemory . prototype . setUint8 = function ( index , offset , val ) { offset += index * this . structSize ; this . data [ offset ] = val } ; SheetMemory . prototype . getUint16 = function ( index , offset ) { offset += index * this . structSize ; return AscFonts . FT _Common . IntToUInt ( this . data [ offset ] | this . data [ offset + 1 ] << 8 ) } ; SheetMemory . prototype . setUint16 = function ( index , offset , val ) { offset += index * this . structSize ; this . data [ offset ] = val & 255 ; this . data [ offset +
1 ] = val >>> 8 & 255 } ; SheetMemory . prototype . getUint32 = function ( index , offset ) { offset += index * this . structSize ; return AscFonts . FT _Common . IntToUInt ( this . data [ offset ] | this . data [ offset + 1 ] << 8 | this . data [ offset + 2 ] << 16 | this . data [ offset + 3 ] << 24 ) } ; SheetMemory . prototype . setUint32 = function ( index , offset , val ) { offset += index * this . structSize ; this . data [ offset ] = val & 255 ; this . data [ offset + 1 ] = val >>> 8 & 255 ; this . data [ offset + 2 ] = val >>> 16 & 255 ; this . data [ offset + 3 ] = val >>> 24 & 255 } ; SheetMemory . prototype . getFloat64 = function ( index , offset ) { offset +=
index * this . structSize ; tempHelpUnit [ 0 ] = this . data [ offset ] ; tempHelpUnit [ 1 ] = this . data [ offset + 1 ] ; tempHelpUnit [ 2 ] = this . data [ offset + 2 ] ; tempHelpUnit [ 3 ] = this . data [ offset + 3 ] ; tempHelpUnit [ 4 ] = this . data [ offset + 4 ] ; tempHelpUnit [ 5 ] = this . data [ offset + 5 ] ; tempHelpUnit [ 6 ] = this . data [ offset + 6 ] ; tempHelpUnit [ 7 ] = this . data [ offset + 7 ] ; return tempHelpFloat [ 0 ] } ; SheetMemory . prototype . setFloat64 = function ( index , offset , val ) { offset += index * this . structSize ; tempHelpFloat [ 0 ] = val ; this . data [ offset ] = tempHelpUnit [ 0 ] ; this . data [ offset + 1 ] = tempHelpUnit [ 1 ] ;
this . data [ offset + 2 ] = tempHelpUnit [ 2 ] ; this . data [ offset + 3 ] = tempHelpUnit [ 3 ] ; this . data [ offset + 4 ] = tempHelpUnit [ 4 ] ; this . data [ offset + 5 ] = tempHelpUnit [ 5 ] ; this . data [ offset + 6 ] = tempHelpUnit [ 6 ] ; this . data [ offset + 7 ] = tempHelpUnit [ 7 ] } ; function Worksheet ( wb , _index , sId ) { this . workbook = wb ; this . sName = this . workbook . getUniqueSheetNameFrom ( g _sNewSheetNamePattern , false ) ; this . bHidden = false ; this . oSheetFormatPr = new AscCommonExcel . SheetFormatPr ; this . index = _index ; this . Id = null != sId ? sId : AscCommon . g _oIdCounter . Get _NewId ( ) ; this . nRowsCount =
0 ; this . nColsCount = 0 ; this . rowsData = new SheetMemory ( AscCommonExcel . g _nRowStructSize , gc _nMaxRow0 ) ; this . cellsByCol = [ ] ; this . cellsByColRowsCount = 0 ; this . aCols = [ ] ; this . hiddenManager = new HiddenManager ( this ) ; this . Drawings = [ ] ; this . TableParts = [ ] ; this . AutoFilter = null ; this . oAllCol = null ; this . aComments = [ ] ; var oThis = this ; this . bExcludeHiddenRows = false ; this . bIgnoreWriteFormulas = false ; this . mergeManager = new RangeDataManager ( function ( data , from , to ) { if ( History . Is _On ( ) && ( null != from || null != to ) ) { if ( null != from ) from = from . clone ( ) ;
if ( null != to ) to = to . clone ( ) ; var oHistoryRange = from ; if ( null == oHistoryRange ) oHistoryRange = to ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _ChangeMerge , oThis . getId ( ) , oHistoryRange , new UndoRedoData _FromTo ( new UndoRedoData _BBox ( from ) , new UndoRedoData _BBox ( to ) ) ) } if ( null != to ) { var maxRow = gc _nMaxRow0 !== to . r2 ? to . r2 : to . r1 ; var maxCol = gc _nMaxCol0 !== to . c2 ? to . c2 : to . c1 ; if ( maxRow >= oThis . nRowsCount ) oThis . nRowsCount = maxRow + 1 ; if ( maxCol >= oThis . nColsCount ) oThis . nColsCount = maxCol + 1 } } ) ; this . mergeManager . worksheet =
this ; this . hyperlinkManager = new RangeDataManager ( function ( data , from , to , oChangeParam ) { if ( History . Is _On ( ) && ( null != from || null != to ) ) { if ( null != from ) from = from . clone ( ) ; if ( null != to ) to = to . clone ( ) ; var oHistoryRange = from ; if ( null == oHistoryRange ) oHistoryRange = to ; var oHistoryData = null ; if ( null == from || null == to ) oHistoryData = data . clone ( ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _ChangeHyperlink , oThis . getId ( ) , oHistoryRange , new AscCommonExcel . UndoRedoData _FromToHyperlink ( from , to , oHistoryData ) ) } if ( null !=
to ) data . Ref = oThis . getRange3 ( to . r1 , to . c1 , to . r2 , to . c2 ) ; else if ( oChangeParam && oChangeParam . removeStyle && null != data . Ref ) data . Ref . cleanFormat ( ) ; if ( null != to ) { var maxRow = gc _nMaxRow0 !== to . r2 ? to . r2 : to . r1 ; var maxCol = gc _nMaxCol0 !== to . c2 ? to . c2 : to . c1 ; if ( maxRow >= oThis . nRowsCount ) oThis . nRowsCount = maxRow + 1 ; if ( maxCol >= oThis . nColsCount ) oThis . nColsCount = maxCol + 1 } } ) ; this . hyperlinkManager . setDependenceManager ( this . mergeManager ) ; this . DrawingDocument = new AscCommon . CDrawingDocument ; this . sheetViews = [ ] ; this . aConditionalFormattingRules =
[ ] ; this . updateConditionalFormattingRange = null ; this . dataValidations = null ; this . sheetPr = null ; this . aFormulaExt = null ; this . autoFilters = AscCommonExcel . AutoFilters !== undefined ? new AscCommonExcel . AutoFilters ( this ) : null ; this . oDrawingOjectsManager = new DrawingObjectsManager ( this ) ; this . contentChanges = new AscCommon . CContentChanges ; this . aSparklineGroups = [ ] ; this . selectionRange = new AscCommonExcel . SelectionRange ( this ) ; this . sheetMergedStyles = new AscCommonExcel . SheetMergedStyles ; this . pivotTables = [ ] ; this . headerFooter =
new Asc . CHeaderFooter ( this ) ; this . rowBreaks = null ; this . colBreaks = null ; this . legacyDrawingHF = null ; this . picture = null ; this . PagePrintOptions = new Asc . asc _CPageOptions ( this ) ; this . formulaArrayLink = null ; this . lastFindOptions = null ; this . bExcludeCollapsed = false ; this . handlers = null } Worksheet . prototype . getCompiledStyle = function ( row , col , opt _cell , opt _styleComponents ) { return getCompiledStyle ( this . sheetMergedStyles , this . hiddenManager , row , col , opt _cell , this , opt _styleComponents ) } ; Worksheet . prototype . getCompiledStyleCustom =
function ( row , col , needTable , needCell , needConditional , opt _cell ) { var res ; var styleComponents = this . sheetMergedStyles . getStyle ( this . hiddenManager , row , col , this ) ; var ws = this ; if ( ! needTable ) styleComponents . table = [ ] ; if ( ! needConditional ) styleComponents . conditional = [ ] ; if ( ! needCell ) res = getCompiledStyle ( undefined , undefined , row , col , undefined , undefined , styleComponents ) ; else if ( opt _cell ) res = getCompiledStyle ( undefined , undefined , row , col , opt _cell , ws , styleComponents ) ; else this . _getCellNoEmpty ( row , col , function ( cell ) { res =
getCompiledStyle ( undefined , undefined , row , col , cell , ws , styleComponents ) } ) ; return res } ; Worksheet . prototype . getColData = function ( index ) { var sheetMemory = this . cellsByCol [ index ] ; if ( ! sheetMemory ) { sheetMemory = new SheetMemory ( g _nCellStructSize , gc _nMaxRow0 ) ; this . cellsByCol [ index ] = sheetMemory } return sheetMemory } ; Worksheet . prototype . getColDataNoEmpty = function ( index ) { return this . cellsByCol [ index ] } ; Worksheet . prototype . getColDataLength = function ( ) { return this . cellsByCol . length } ; Worksheet . prototype . getSnapshot = function ( wb ) { var ws =
new Worksheet ( wb , this . index , this . Id ) ; ws . sName = this . sName ; for ( var i = 0 ; i < this . TableParts . length ; ++ i ) { var table = this . TableParts [ i ] ; ws . addTablePart ( table . clone ( null ) , false ) } for ( i = 0 ; i < this . sheetViews . length ; ++ i ) ws . sheetViews . push ( this . sheetViews [ i ] . clone ( ) ) ; return ws } ; Worksheet . prototype . addContentChanges = function ( changes ) { this . contentChanges . Add ( changes ) } ; Worksheet . prototype . refreshContentChanges = function ( ) { this . contentChanges . Refresh ( ) ; this . contentChanges . Clear ( ) } ; Worksheet . prototype . rebuildColors = function ( ) { this . rebuildTabColor ( ) ;
for ( var i = 0 ; i < this . aSparklineGroups . length ; ++ i ) this . aSparklineGroups [ i ] . cleanCache ( ) } ; Worksheet . prototype . generateFontMap = function ( oFontMap ) { for ( var i = 0 , length = this . Drawings . length ; i < length ; ++ i ) { var drawing = this . Drawings [ i ] ; if ( drawing ) drawing . getAllFonts ( oFontMap ) } if ( this . headerFooter ) this . headerFooter . getAllFonts ( oFontMap ) } ; Worksheet . prototype . getAllImageUrls = function ( aImages ) { for ( var i = 0 ; i < this . Drawings . length ; ++ i ) this . Drawings [ i ] . graphicObject . getAllRasterImages ( aImages ) } ; Worksheet . prototype . reassignImageUrls =
function ( oImages ) { for ( var i = 0 ; i < this . Drawings . length ; ++ i ) this . Drawings [ i ] . graphicObject . Reassign _ImageUrls ( oImages ) } ; Worksheet . prototype . copyFrom = function ( wsFrom , sName , tableNames ) { var i , elem , range ; var t = this ; this . sName = this . workbook . checkValidSheetName ( sName ) ? sName : this . workbook . getUniqueSheetNameFrom ( wsFrom . sName , true ) ; this . bHidden = wsFrom . bHidden ; this . oSheetFormatPr = wsFrom . oSheetFormatPr . clone ( ) ; this . nRowsCount = wsFrom . nRowsCount ; this . nColsCount = wsFrom . nColsCount ; var renameParams = { lastName : wsFrom . getName ( ) ,
newName : this . getName ( ) , tableNameMap : { } } ; for ( i = 0 ; i < wsFrom . TableParts . length ; ++ i ) { var tableFrom = wsFrom . TableParts [ i ] ; var tableTo = tableFrom . clone ( null ) ; if ( tableNames && tableNames . length ) tableTo . changeDisplayName ( tableNames [ i ] ) ; else tableTo . changeDisplayName ( this . workbook . dependencyFormulas . getNextTableName ( ) ) ; this . addTablePart ( tableTo , true ) ; renameParams . tableNameMap [ tableFrom . DisplayName ] = tableTo . DisplayName } for ( i = 0 ; i < this . TableParts . length ; ++ i ) this . TableParts [ i ] . renameSheetCopy ( this , renameParams ) ; if ( wsFrom . AutoFilter ) this . AutoFilter =
wsFrom . AutoFilter . clone ( ) ; for ( i in wsFrom . aCols ) { var col = wsFrom . aCols [ i ] ; if ( null != col ) this . aCols [ i ] = col . clone ( this ) } if ( null != wsFrom . oAllCol ) this . oAllCol = wsFrom . oAllCol . clone ( this ) ; this . rowsData = wsFrom . rowsData . clone ( ) ; wsFrom . _forEachColData ( function ( sheetMemory , index ) { t . cellsByCol [ index ] = sheetMemory . clone ( ) } ) ; this . cellsByColRowsCount = wsFrom . cellsByColRowsCount ; var aMerged = wsFrom . mergeManager . getAll ( ) ; for ( i in aMerged ) { elem = aMerged [ i ] ; range = this . getRange3 ( elem . bbox . r1 , elem . bbox . c1 , elem . bbox . r2 , elem . bbox . c2 ) ;
range . mergeOpen ( ) } var aHyperlinks = wsFrom . hyperlinkManager . getAll ( ) ; for ( i in aHyperlinks ) { elem = aHyperlinks [ i ] ; range = this . getRange3 ( elem . bbox . r1 , elem . bbox . c1 , elem . bbox . r2 , elem . bbox . c2 ) ; range . setHyperlinkOpen ( elem . data ) } if ( null != wsFrom . aComments ) for ( i = 0 ; i < wsFrom . aComments . length ; i ++ ) { var comment = wsFrom . aComments [ i ] . clone ( ) ; comment . wsId = this . getId ( ) ; comment . nId = "sheet" + comment . wsId + "_" + ( i + 1 ) ; this . aComments . push ( comment ) } for ( i = 0 ; i < wsFrom . sheetViews . length ; ++ i ) this . sheetViews . push ( wsFrom . sheetViews [ i ] . clone ( ) ) ;
for ( i = 0 ; i < wsFrom . aConditionalFormattingRules . length ; ++ i ) this . aConditionalFormattingRules . push ( wsFrom . aConditionalFormattingRules [ i ] . clone ( ) ) ; if ( wsFrom . dataValidations ) this . dataValidations = wsFrom . dataValidations . clone ( ) ; if ( wsFrom . sheetPr ) this . sheetPr = wsFrom . sheetPr . clone ( ) ; this . selectionRange = wsFrom . selectionRange . clone ( this ) ; var oldNewArrayFormulaMap = [ ] ; this . _forEachCell ( function ( cell ) { if ( cell . isFormula ( ) ) { var parsed , notMainArrayCell ; if ( cell . transformSharedFormula ( ) ) parsed = cell . getFormulaParsed ( ) ;
else { parsed = cell . getFormulaParsed ( ) ; if ( parsed . getArrayFormulaRef ( ) ) { var listenerId = parsed . getListenerId ( ) ; if ( oldNewArrayFormulaMap [ listenerId ] ) { parsed = oldNewArrayFormulaMap [ listenerId ] ; notMainArrayCell = true } else { parsed = parsed . clone ( null , new CCellWithFormula ( t , cell . nRow , cell . nCol ) , t ) ; oldNewArrayFormulaMap [ listenerId ] = parsed } } else parsed = parsed . clone ( null , new CCellWithFormula ( t , cell . nRow , cell . nCol ) , t ) } if ( ! notMainArrayCell ) { parsed . renameSheetCopy ( renameParams ) ; parsed . setFormulaString ( parsed . assemble ( true ) ) } cell . setFormulaInternal ( parsed ,
true ) ; t . workbook . dependencyFormulas . addToBuildDependencyCell ( cell ) } } ) ; if ( wsFrom . headerFooter ) this . headerFooter = wsFrom . headerFooter . clone ( this ) ; return renameParams } ; Worksheet . prototype . copyObjects = function ( oNewWs , wsFrom ) { var i ; if ( null != this . Drawings && this . Drawings . length > 0 ) { var drawingObjects = new AscFormat . DrawingObjects ; oNewWs . Drawings = [ ] ; AscFormat . NEW _WORKSHEET _DRAWING _DOCUMENT = oNewWs . DrawingDocument ; for ( i = 0 ; i < this . Drawings . length ; ++ i ) { var drawingObject = drawingObjects . cloneDrawingObject ( this . Drawings [ i ] ) ;
drawingObject . graphicObject = this . Drawings [ i ] . graphicObject . copy ( ) ; drawingObject . graphicObject . setWorksheet ( oNewWs ) ; drawingObject . graphicObject . addToDrawingObjects ( ) ; var drawingBase = this . Drawings [ i ] ; drawingObject . graphicObject . setDrawingBaseCoords ( drawingBase . from . col , drawingBase . from . colOff , drawingBase . from . row , drawingBase . from . rowOff , drawingBase . to . col , drawingBase . to . colOff , drawingBase . to . row , drawingBase . to . rowOff , drawingBase . Pos . X , drawingBase . Pos . Y , drawingBase . ext . cx , drawingBase . ext . cy ) ; if ( drawingObject . graphicObject . setDrawingBaseType ) drawingObject . graphicObject . setDrawingBaseType ( drawingBase . Type ) ;
oNewWs . Drawings [ oNewWs . Drawings . length - 1 ] = drawingObject } AscFormat . NEW _WORKSHEET _DRAWING _DOCUMENT = null ; drawingObjects . pushToAObjects ( oNewWs . Drawings ) ; drawingObjects . updateChartReferences2 ( parserHelp . getEscapeSheetName ( wsFrom . sName ) , parserHelp . getEscapeSheetName ( oNewWs . sName ) ) } var newSparkline ; for ( i = 0 ; i < this . aSparklineGroups . length ; ++ i ) { newSparkline = this . aSparklineGroups [ i ] . clone ( ) ; newSparkline . setWorksheet ( oNewWs , wsFrom ) ; oNewWs . aSparklineGroups . push ( newSparkline ) } } ; Worksheet . prototype . initColumn = function ( column ) { if ( column ) if ( null !==
column . width && 0 !== column . width ) { column . widthPx = this . modelColWidthToColWidth ( column . width ) ; column . charCount = this . colWidthToCharCount ( column . widthPx ) } else column . widthPx = column . charCount = null } ; Worksheet . prototype . initColumns = function ( ) { this . initColumn ( this . oAllCol ) ; this . aCols . forEach ( this . initColumn , this ) } ; Worksheet . prototype . initPostOpen = function ( handlers ) { this . PagePrintOptions . init ( ) ; this . headerFooter . init ( ) ; if ( 0 === this . sheetViews . length ) this . sheetViews . push ( new AscCommonExcel . asc _CSheetViewSettings ) ;
this . hiddenManager . initPostOpen ( ) ; this . oSheetFormatPr . correction ( ) ; this . handlers = handlers ; this . _setHandlersTablePart ( ) } ; Worksheet . prototype . _getValuesForConditionalFormatting = function ( ranges , numbers ) { var res = [ ] ; for ( var i = 0 ; i < ranges . length ; ++ i ) { var elem = ranges [ i ] ; var range = this . getRange3 ( elem . r1 , elem . c1 , elem . r2 , elem . c2 ) ; res = res . concat ( range . _getValues ( numbers ) ) } return res } ; Worksheet . prototype . _isConditionalFormattingIntersect = function ( range , ranges ) { for ( var i = 0 ; i < ranges . length ; ++ i ) if ( range . isIntersect ( ranges [ i ] ) ) return true ;
return false } ; Worksheet . prototype . setDirtyConditionalFormatting = function ( range ) { if ( ! range ) range = new AscCommonExcel . MultiplyRange ( [ new Asc . Range ( 0 , 0 , gc _nMaxCol0 , gc _nMaxRow0 ) ] ) ; if ( this . updateConditionalFormattingRange ) this . updateConditionalFormattingRange . union2 ( range ) ; else this . updateConditionalFormattingRange = range . clone ( ) } ; Worksheet . prototype . _updateConditionalFormatting = function ( ) { if ( ! this . updateConditionalFormattingRange ) return ; var range = this . updateConditionalFormattingRange ; this . updateConditionalFormattingRange =
null ; var t = this ; var aRules = this . aConditionalFormattingRules . sort ( function ( v1 , v2 ) { return v2 . priority - v1 . priority } ) ; var oGradient1 , oGradient2 , aWeights , oRule , multiplyRange , oRuleElement , bboxCf , formulaParent , parsed1 , parsed2 ; var o , l , cell , ranges , values , value , tmp , dxf , compareFunction , nc , sum ; this . sheetMergedStyles . clearConditionalStyle ( range ) ; var getCacheFunction = function ( rule , setFunc ) { var cache = { cache : { } , get : function ( row , col ) { var cacheVal ; var cacheRow = this . cache [ row ] ; if ( ! cacheRow ) { cacheRow = { } ; this . cache [ row ] =
cacheRow } else cacheVal = cacheRow [ col ] ; if ( undefined === cacheVal ) { cacheVal = this . set ( row , col ) ; cacheRow [ col ] = cacheVal } return cacheVal } , set : function ( row , col ) { if ( rule ) return setFunc ( row , col ) ? rule . dxf : null ; else return setFunc ( row , col ) } } ; return function ( row , col ) { return cache . get ( row , col ) } } ; for ( var i = 0 ; i < aRules . length ; ++ i ) { oRule = aRules [ i ] ; ranges = oRule . ranges ; if ( this . _isConditionalFormattingIntersect ( range , ranges ) ) { multiplyRange = new AscCommonExcel . MultiplyRange ( ranges ) ; if ( AscCommonExcel . ECfType . colorScale ===
oRule . type ) { if ( 1 !== oRule . aRuleElements . length ) continue ; oRuleElement = oRule . aRuleElements [ 0 ] ; if ( ! oRuleElement || oRule . type !== oRuleElement . type ) continue ; values = this . _getValuesForConditionalFormatting ( ranges , true ) ; l = oRuleElement . aColors . length ; if ( 0 < values . length && 2 <= l ) { aWeights = [ ] ; oGradient1 = new AscCommonExcel . CGradient ( oRuleElement . aColors [ 0 ] , oRuleElement . aColors [ 1 ] ) ; aWeights . push ( oRule . getMin ( values , t ) , oRule . getMax ( values , t ) ) ; if ( 2 < l ) { oGradient2 = new AscCommonExcel . CGradient ( oRuleElement . aColors [ 1 ] , oRuleElement . aColors [ 2 ] ) ;
aWeights . push ( oRule . getMid ( values , t ) ) ; aWeights . sort ( AscCommon . fSortAscending ) ; oGradient1 . init ( aWeights [ 0 ] , aWeights [ 1 ] ) ; oGradient2 . init ( aWeights [ 1 ] , aWeights [ 2 ] ) } else { oGradient2 = null ; aWeights . sort ( AscCommon . fSortAscending ) ; oGradient1 . init ( aWeights [ 0 ] , aWeights [ 1 ] ) } compareFunction = function ( oGradient1 , oGradient2 ) { return function ( row , col ) { var val , color , gradient ; t . _getCellNoEmpty ( row , col , function ( cell ) { val = cell && cell . getNumberValue ( ) } ) ; dxf = null ; if ( null !== val ) { dxf = new AscCommonExcel . CellXfs ; gradient = oGradient2 ?
oGradient2 : oGradient1 ; if ( val >= gradient . max ) color = gradient . getMaxColor ( ) ; else if ( val <= oGradient1 . min ) color = oGradient1 . getMinColor ( ) ; else { gradient = oGradient2 && val > oGradient1 . max ? oGradient2 : oGradient1 ; color = gradient . calculateColor ( val ) } dxf . fill = new AscCommonExcel . Fill ; dxf . fill . fromColor ( color ) ; dxf = g _StyleCache . addXf ( dxf , true ) } return dxf } } ( oGradient1 , oGradient2 ) } } else if ( AscCommonExcel . ECfType . dataBar === oRule . type ) continue ; else if ( AscCommonExcel . ECfType . top10 === oRule . type ) { if ( oRule . rank > 0 && oRule . dxf ) { nc =
0 ; values = this . _getValuesForConditionalFormatting ( ranges , false ) ; o = oRule . bottom ? Number . MAX _VALUE : - Number . MAX _VALUE ; for ( cell = 0 ; cell < values . length ; ++ cell ) { value = values [ cell ] ; if ( CellValueType . Number === value . type && ! isNaN ( tmp = parseFloat ( value . v ) ) ) { ++ nc ; value . v = tmp } else value . v = o } values . sort ( function ( condition ) { return function ( v1 , v2 ) { return condition * ( v2 . v - v1 . v ) } } ( oRule . bottom ? - 1 : 1 ) ) ; nc = Math . max ( 1 , oRule . percent ? Math . floor ( nc * oRule . rank / 100 ) : oRule . rank ) ; var threshold = values . length >= nc ? values [ nc - 1 ] . v : o ; compareFunction =
function ( rule , threshold ) { return function ( row , col ) { var val ; t . _getCellNoEmpty ( row , col , function ( cell ) { val = cell ? cell . getNumberValue ( ) : null } ) ; return null !== val && ( rule . bottom ? val <= threshold : val >= threshold ) ? rule . dxf : null } } ( oRule , threshold ) } } else if ( AscCommonExcel . ECfType . aboveAverage === oRule . type ) { if ( ! oRule . dxf ) continue ; values = this . _getValuesForConditionalFormatting ( ranges , false ) ; sum = 0 ; nc = 0 ; for ( cell = 0 ; cell < values . length ; ++ cell ) { value = values [ cell ] ; if ( CellValueType . Number === value . type && ! isNaN ( tmp = parseFloat ( value . v ) ) ) { ++ nc ;
value . v = tmp ; sum += tmp } else value . v = null } tmp = sum / nc ; compareFunction = function ( rule , average , stdDev ) { return function ( row , col ) { var val ; t . _getCellNoEmpty ( row , col , function ( cell ) { val = cell ? cell . getNumberValue ( ) : null } ) ; return null !== val && rule . getAverage ( val , average , stdDev ) ? rule . dxf : null } } ( oRule , tmp , sum ) } else { if ( ! oRule . dxf ) continue ; switch ( oRule . type ) { case AscCommonExcel . ECfType . duplicateValues : case AscCommonExcel . ECfType . uniqueValues : o = getUniqueKeys ( this . _getValuesForConditionalFormatting ( ranges , false ) ) ; compareFunction =
function ( rule , obj , condition ) { return function ( row , col ) { var val ; t . _getCellNoEmpty ( row , col , function ( cell ) { val = cell ? cell . getValueWithoutFormat ( ) : "" } ) ; return ( val . length > 0 ? condition === obj [ val ] : false ) ? rule . dxf : null } } ( oRule , o , oRule . type === AscCommonExcel . ECfType . duplicateValues ) ; break ; case AscCommonExcel . ECfType . containsText : case AscCommonExcel . ECfType . notContainsText : case AscCommonExcel . ECfType . beginsWith : case AscCommonExcel . ECfType . endsWith : var operator ; switch ( oRule . type ) { case AscCommonExcel . ECfType . containsText : operator =
AscCommonExcel . ECfOperator . Operator _containsText ; break ; case AscCommonExcel . ECfType . notContainsText : operator = AscCommonExcel . ECfOperator . Operator _notContains ; break ; case AscCommonExcel . ECfType . beginsWith : operator = AscCommonExcel . ECfOperator . Operator _beginsWith ; break ; case AscCommonExcel . ECfType . endsWith : operator = AscCommonExcel . ECfOperator . Operator _endsWith ; break } formulaParent = new AscCommonExcel . CConditionalFormattingFormulaParent ( this , oRule , true ) ; oRuleElement = oRule . getFormulaCellIs ( ) ; parsed1 = oRuleElement &&
oRuleElement . getFormula && oRuleElement . getFormula ( this , formulaParent ) ; if ( parsed1 && parsed1 . hasRelativeRefs ( ) ) { bboxCf = oRule . getBBox ( ) ; compareFunction = getCacheFunction ( oRule , function ( rule , operator , formulaParent , rowLT , colLT ) { return function ( row , col ) { var offset = new AscCommon . CellBase ( row - rowLT , col - colLT ) ; var bboxCell = new Asc . Range ( col , row , col , row ) ; var v1 = rule . getValueCellIs ( t , formulaParent , bboxCell , offset , false ) ; var res ; t . _getCellNoEmpty ( row , col , function ( cell ) { res = rule . cellIs ( operator , cell , v1 ) ? rule . dxf :
null } ) ; return res } } ( oRule , operator , new AscCommonExcel . CConditionalFormattingFormulaParent ( this , oRule , true ) , bboxCf ? bboxCf . r1 : 0 , bboxCf ? bboxCf . c1 : 0 ) ) } else compareFunction = function ( rule , operator , v1 ) { return function ( row , col ) { var res ; t . _getCellNoEmpty ( row , col , function ( cell ) { res = rule . cellIs ( operator , cell , v1 ) ? rule . dxf : null } ) ; return res } } ( oRule , operator , oRule . getValueCellIs ( this ) ) ; break ; case AscCommonExcel . ECfType . containsErrors : compareFunction = function ( rule ) { return function ( row , col ) { var val ; t . _getCellNoEmpty ( row ,
col , function ( cell ) { val = cell ? CellValueType . Error === cell . getType ( ) : false } ) ; return val ? rule . dxf : null } } ( oRule ) ; break ; case AscCommonExcel . ECfType . notContainsErrors : compareFunction = function ( rule ) { return function ( row , col ) { var val ; t . _getCellNoEmpty ( row , col , function ( cell ) { val = cell ? CellValueType . Error !== cell . getType ( ) : true } ) ; return val ? rule . dxf : null } } ( oRule ) ; break ; case AscCommonExcel . ECfType . containsBlanks : compareFunction = function ( rule ) { return function ( row , col ) { var val ; t . _getCellNoEmpty ( row , col , function ( cell ) { if ( cell ) val =
"" === cell . getValueWithoutFormat ( ) . replace ( /^ +| +$/g , "" ) ; else val = true } ) ; return val ? rule . dxf : null } } ( oRule ) ; break ; case AscCommonExcel . ECfType . notContainsBlanks : compareFunction = function ( rule ) { return function ( row , col ) { var val ; t . _getCellNoEmpty ( row , col , function ( cell ) { if ( cell ) val = "" !== cell . getValueWithoutFormat ( ) . replace ( /^ +| +$/g , "" ) ; else val = false } ) ; return val ? rule . dxf : null } } ( oRule ) ; break ; case AscCommonExcel . ECfType . timePeriod : if ( oRule . timePeriod ) compareFunction = function ( rule , period ) { return function ( row ,
col ) { var val ; t . _getCellNoEmpty ( row , col , function ( cell ) { val = cell ? cell . getValueWithoutFormat ( ) : "" } ) ; var n = parseFloat ( val ) ; return period . start <= n && n < period . end ? rule . dxf : null } } ( oRule , oRule . getTimePeriod ( ) ) ; else continue ; break ; case AscCommonExcel . ECfType . cellIs : formulaParent = new AscCommonExcel . CConditionalFormattingFormulaParent ( this , oRule , true ) ; oRuleElement = oRule . aRuleElements [ 0 ] ; parsed1 = oRuleElement && oRuleElement . getFormula && oRuleElement . getFormula ( this , formulaParent ) ; oRuleElement = oRule . aRuleElements [ 1 ] ;
parsed2 = oRuleElement && oRuleElement . getFormula && oRuleElement . getFormula ( this , formulaParent ) ; if ( parsed1 && parsed1 . hasRelativeRefs ( ) || parsed2 && parsed2 . hasRelativeRefs ( ) ) { bboxCf = oRule . getBBox ( ) ; compareFunction = getCacheFunction ( oRule , function ( rule , ruleElem1 , ruleElem2 , formulaParent , rowLT , colLT ) { return function ( row , col ) { var offset = new AscCommon . CellBase ( row - rowLT , col - colLT ) ; var bboxCell = new Asc . Range ( col , row , col , row ) ; var v1 = ruleElem1 && ruleElem1 . getValue ( t , formulaParent , bboxCell , offset , false ) ; var v2 = ruleElem2 &&
ruleElem2 . getValue ( t , formulaParent , bboxCell , offset , false ) ; var res ; t . _getCellNoEmpty ( row , col , function ( cell ) { res = rule . cellIs ( rule . operator , cell , v1 , v2 ) ? rule . dxf : null } ) ; return res } } ( oRule , oRule . aRuleElements [ 0 ] , oRule . aRuleElements [ 1 ] , new AscCommonExcel . CConditionalFormattingFormulaParent ( this , oRule , true ) , bboxCf ? bboxCf . r1 : 0 , bboxCf ? bboxCf . c1 : 0 ) ) } else compareFunction = function ( rule , v1 , v2 ) { return function ( row , col ) { var res ; t . _getCellNoEmpty ( row , col , function ( cell ) { res = rule . cellIs ( rule . operator , cell , v1 , v2 ) ? rule . dxf :
null } ) ; return res } } ( oRule , oRule . aRuleElements [ 0 ] && oRule . aRuleElements [ 0 ] . getValue ( this ) , oRule . aRuleElements [ 1 ] && oRule . aRuleElements [ 1 ] . getValue ( this ) ) ; break ; case AscCommonExcel . ECfType . expression : bboxCf = oRule . getBBox ( ) ; compareFunction = getCacheFunction ( oRule , function ( rule , formulaCF , formulaParent , rowLT , colLT ) { return function ( row , col ) { var offset = new AscCommon . CellBase ( row - rowLT , col - colLT ) ; var bboxCell = new Asc . Range ( col , row , col , row ) ; var res = formulaCF && formulaCF . getValue ( t , formulaParent , bboxCell , offset ,
true ) ; if ( res && res . tocBool ) { res = res . tocBool ( ) ; if ( res && res . toBool ) return res . toBool ( ) } return false } } ( oRule , oRule . aRuleElements [ 0 ] , new AscCommonExcel . CConditionalFormattingFormulaParent ( this , oRule , true ) , bboxCf ? bboxCf . r1 : 0 , bboxCf ? bboxCf . c1 : 0 ) ) ; break ; default : continue ; break } } if ( compareFunction ) this . sheetMergedStyles . setConditionalStyle ( multiplyRange , compareFunction ) } } } ; Worksheet . prototype . _forEachRow = function ( fAction ) { this . getRange3 ( 0 , 0 , gc _nMaxRow0 , 0 ) . _foreachRowNoEmpty ( fAction ) } ; Worksheet . prototype . _forEachCol =
function ( fAction ) { this . getRange3 ( 0 , 0 , 0 , gc _nMaxCol0 ) . _foreachColNoEmpty ( fAction ) } ; Worksheet . prototype . _forEachColData = function ( fAction ) { for ( var i = 0 ; i < this . cellsByCol . length ; ++ i ) { var sheetMemory = this . cellsByCol [ i ] ; if ( sheetMemory ) fAction ( sheetMemory , i ) } } ; Worksheet . prototype . _forEachCell = function ( fAction ) { this . getRange3 ( 0 , 0 , gc _nMaxRow0 , gc _nMaxCol0 ) . _foreachNoEmpty ( fAction ) } ; Worksheet . prototype . getId = function ( ) { return this . Id } ; Worksheet . prototype . getIndex = function ( ) { return this . index } ; Worksheet . prototype . getName =
function ( ) { return this . sName !== undefined && this . sName . length > 0 ? this . sName : "" } ; Worksheet . prototype . setName = function ( name , bFromUndoRedo ) { if ( name . length <= g _nSheetNameMaxLength ) { var lastName = this . sName ; History . Create _NewPoint ( ) ; var prepared = this . workbook . dependencyFormulas . prepareChangeSheet ( this . getId ( ) , { rename : { from : lastName , to : name } } ) ; this . sName = name ; this . workbook . dependencyFormulas . changeSheet ( prepared ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _Rename , this . getId ( ) ,
null , new UndoRedoData _FromTo ( lastName , name ) ) ; if ( ! bFromUndoRedo ) { var _lastName = parserHelp . getEscapeSheetName ( lastName ) ; var _newName = parserHelp . getEscapeSheetName ( this . sName ) ; for ( var key in this . workbook . aWorksheets ) { var wsModel = this . workbook . aWorksheets [ key ] ; if ( wsModel ) wsModel . oDrawingOjectsManager . updateChartReferencesWidthHistory ( _lastName , _newName , true ) } } this . workbook . dependencyFormulas . calcTree ( ) } else console . log ( new Error ( "The sheet name must be less than 31 characters." ) ) } ; Worksheet . prototype . getTabColor =
function ( ) { return this . sheetPr && this . sheetPr . TabColor ? Asc . colorObjToAscColor ( this . sheetPr . TabColor ) : null } ; Worksheet . prototype . setTabColor = function ( color ) { if ( ! this . sheetPr ) this . sheetPr = new AscCommonExcel . asc _CSheetPr ; History . Create _NewPoint ( ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _SetTabColor , this . getId ( ) , null , new UndoRedoData _FromTo ( this . sheetPr . TabColor ? this . sheetPr . TabColor . clone ( ) : null , color ? color . clone ( ) : null ) ) ; this . sheetPr . TabColor = color ; if ( ! this . workbook . bUndoChanges &&
! this . workbook . bRedoChanges ) this . workbook . handlers . trigger ( "asc_onUpdateTabColor" , this . getIndex ( ) ) } ; Worksheet . prototype . rebuildTabColor = function ( ) { if ( this . sheetPr && this . sheetPr . TabColor ) this . workbook . handlers . trigger ( "asc_onUpdateTabColor" , this . getIndex ( ) ) } ; Worksheet . prototype . getHidden = function ( ) { return true === this . bHidden } ; Worksheet . prototype . setHidden = function ( hidden ) { var bOldHidden = this . bHidden , wb = this . workbook , wsActive = wb . getActiveWs ( ) , oVisibleWs = null ; this . bHidden = hidden ; if ( true == this . bHidden &&
this . getIndex ( ) == wsActive . getIndex ( ) ) { oVisibleWs = wb . findSheetNoHidden ( this . getIndex ( ) ) ; if ( null != oVisibleWs ) { var nNewIndex = oVisibleWs . getIndex ( ) ; wb . setActive ( nNewIndex ) ; if ( ! wb . bUndoChanges && ! wb . bRedoChanges ) wb . handlers . trigger ( "undoRedoHideSheet" , nNewIndex ) } } if ( bOldHidden != hidden ) { History . Create _NewPoint ( ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _Hide , this . getId ( ) , null , new UndoRedoData _FromTo ( bOldHidden , hidden ) ) ; if ( null != oVisibleWs ) { History . SetSheetUndo ( wsActive . getId ( ) ) ;
History . SetSheetRedo ( oVisibleWs . getId ( ) ) } } } ; Worksheet . prototype . getSheetView = function ( ) { return this . sheetViews [ 0 ] } ; Worksheet . prototype . getSheetViewSettings = function ( ) { return this . sheetViews [ 0 ] . clone ( ) } ; Worksheet . prototype . setDisplayGridlines = function ( value ) { var view = this . sheetViews [ 0 ] ; if ( value !== view . showGridLines ) { History . Create _NewPoint ( ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _SetDisplayGridlines , this . getId ( ) , null , new UndoRedoData _FromTo ( view . showGridLines , value ) ) ;
view . showGridLines = value ; if ( ! this . workbook . bUndoChanges && ! this . workbook . bRedoChanges ) this . workbook . handlers . trigger ( "asc_onUpdateSheetViewSettings" ) } } ; Worksheet . prototype . setDisplayHeadings = function ( value ) { var view = this . sheetViews [ 0 ] ; if ( value !== view . showRowColHeaders ) { History . Create _NewPoint ( ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _SetDisplayHeadings , this . getId ( ) , null , new UndoRedoData _FromTo ( view . showRowColHeaders , value ) ) ; view . showRowColHeaders = value ; if ( ! this . workbook . bUndoChanges &&
! this . workbook . bRedoChanges ) this . workbook . handlers . trigger ( "asc_onUpdateSheetViewSettings" ) } } ; Worksheet . prototype . getRowsCount = function ( ) { var result = this . nRowsCount ; var pane = this . sheetViews . length && this . sheetViews [ 0 ] . pane ; if ( pane && pane . topLeftFrozenCell ) result = Math . max ( result , pane . topLeftFrozenCell . getRow0 ( ) ) ; return result } ; Worksheet . prototype . removeRows = function ( start , stop , bExcludeHiddenRows ) { var removeRowsArr = bExcludeHiddenRows ? this . _getNoHiddenRowsArr ( start , stop ) : [ { start : start , stop : stop } ] ; for ( var i =
removeRowsArr . length - 1 ; i >= 0 ; i -- ) { var oRange = this . getRange ( new CellAddress ( removeRowsArr [ i ] . start , 0 , 0 ) , new CellAddress ( removeRowsArr [ i ] . stop , gc _nMaxCol0 , 0 ) ) ; oRange . deleteCellsShiftUp ( ) } } ; Worksheet . prototype . _getNoHiddenRowsArr = function ( start , stop ) { var res = [ ] ; var elem = null ; for ( var i = start ; i <= stop ; i ++ ) if ( this . getRowHidden ( i ) ) { if ( elem ) { res . push ( elem ) ; elem = null } } else { if ( ! elem ) { elem = { } ; elem . start = i ; elem . stop = i } else elem . stop ++ ; if ( i === stop ) res . push ( elem ) } return res } ; Worksheet . prototype . _updateFormulasParents =
function ( r1 , c1 , r2 , c2 , bbox , offset , shiftedShared ) { var t = this ; var cellWithFormula ; var shiftedArrayFormula = { } ; this . getRange3 ( r1 , c1 , r2 , c2 ) . _foreachNoEmpty ( function ( cell ) { var newNRow = cell . nRow + offset . row ; var newNCol = cell . nCol + offset . col ; var bHor = 0 !== offset . col ; var toDelete = offset . col < 0 || offset . row < 0 ; if ( cell . isFormula ( ) ) { var processed = c _oSharedShiftType . NeedTransform ; var parsed = cell . getFormulaParsed ( ) ; var shared = parsed . getShared ( ) ; var arrayFormula = parsed . getArrayFormulaRef ( ) ; var formulaRefObj = null ; if ( shared ) { processed =
shiftedShared [ parsed . getListenerId ( ) ] ; var isPreProcessed = c _oSharedShiftType . PreProcessed === processed ; if ( ! processed || isPreProcessed ) { if ( ! processed ) { var bboxShift = AscCommonExcel . shiftGetBBox ( bbox , bHor ) ; if ( bboxShift . containsRange ( shared . ref ) && ( ! toDelete || ! bbox . isIntersect ( shared . ref ) ) ) processed = c _oSharedShiftType . Processed ; else processed = c _oSharedShiftType . NeedTransform } else if ( isPreProcessed ) processed = c _oSharedShiftType . Processed ; if ( c _oSharedShiftType . Processed === processed ) { var newRef = shared . ref . clone ( ) ;
newRef . forShift ( bbox , offset , t . workbook . bUndoChanges ) ; parsed . setSharedRef ( newRef , ! isPreProcessed ) ; t . workbook . dependencyFormulas . addToChangedRange2 ( t . getId ( ) , newRef ) } shiftedShared [ parsed . getListenerId ( ) ] = processed } } else if ( arrayFormula ) if ( ! shiftedArrayFormula [ parsed . getListenerId ( ) ] && parsed . checkFirstCellArray ( cell ) ) { shiftedArrayFormula [ parsed . getListenerId ( ) ] = 1 ; var newArrayRef = arrayFormula . clone ( ) ; newArrayRef . setOffset ( offset ) ; parsed . setArrayFormulaRef ( newArrayRef ) } else processed = c _oSharedShiftType . Processed ;
if ( c _oSharedShiftType . NeedTransform === processed ) { var isTransform = cell . transformSharedFormula ( ) ; parsed = cell . getFormulaParsed ( ) ; if ( isTransform ) parsed . buildDependencies ( ) ; cellWithFormula = parsed . getParent ( ) ; cellWithFormula . nRow = newNRow ; cellWithFormula . nCol = newNCol ; t . workbook . dependencyFormulas . addToChangedCell ( cellWithFormula ) } } t . cellsByColRowsCount = Math . max ( t . cellsByColRowsCount , newNRow + 1 ) ; t . nRowsCount = Math . max ( t . nRowsCount , t . cellsByColRowsCount ) ; t . nColsCount = Math . max ( t . nColsCount , newNCol + 1 ) } ) } ; Worksheet . prototype . _removeRows =
function ( start , stop ) { var t = this ; this . workbook . dependencyFormulas . lockRecal ( ) ; History . Create _NewPoint ( ) ; var nDif = - ( stop - start + 1 ) ; var oActualRange = new Asc . Range ( 0 , start , gc _nMaxCol0 , stop ) ; var offset = new AscCommon . CellBase ( nDif , 0 ) ; var renameRes = this . renameDependencyNodes ( offset , oActualRange ) ; var redrawTablesArr = this . autoFilters . insertRows ( "delCell" , oActualRange , c _oAscDeleteOptions . DeleteRows ) ; this . updatePivotOffset ( oActualRange , offset ) ; var collapsedInfo = null , lastRowIndex ; var oDefRowPr = new AscCommonExcel . UndoRedoData _RowProp ;
this . getRange3 ( start , 0 , stop , gc _nMaxCol0 ) . _foreachRowNoEmpty ( function ( row ) { var oOldProps = row . getHeightProp ( ) ; lastRowIndex = row . index ; if ( false === oOldProps . isEqual ( oDefRowPr ) ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _RowProp , t . getId ( ) , row . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( row . getIndex ( ) , true , oOldProps , oDefRowPr ) ) ; row . setStyle ( null ) ; if ( ! t . workbook . bRedoChanges ) { if ( collapsedInfo !== null && collapsedInfo < row . getOutlineLevel ( ) ) collapsedInfo = null ; if ( row . getCollapsed ( ) ) { collapsedInfo =
row . getOutlineLevel ( ) ; t . setCollapsedRow ( false , null , row ) } } } , function ( cell ) { t . _removeCell ( null , null , cell ) } ) ; if ( collapsedInfo !== null && lastRowIndex === stop ) this . _getRow ( stop + 1 , function ( row ) { t . setCollapsedRow ( true , null , row ) } ) ; this . _updateFormulasParents ( start , 0 , gc _nMaxRow0 , gc _nMaxCol0 , oActualRange , offset , renameRes . shiftedShared ) ; this . rowsData . deleteRange ( start , - nDif ) ; this . _forEachColData ( function ( sheetMemory ) { sheetMemory . deleteRange ( start , - nDif ) } ) ; this . workbook . dependencyFormulas . notifyChanged ( renameRes . changed ) ;
History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _RemoveRows , this . getId ( ) , new Asc . Range ( 0 , start , gc _nMaxCol0 , gc _nMaxRow0 ) , new UndoRedoData _FromToRowCol ( true , start , stop ) ) ; this . autoFilters . redrawStylesTables ( redrawTablesArr ) ; this . workbook . dependencyFormulas . unlockRecal ( ) ; return true } ; Worksheet . prototype . insertRowsBefore = function ( index , count ) { var oRange = this . getRange ( new CellAddress ( index , 0 , 0 ) , new CellAddress ( index + count - 1 , gc _nMaxCol0 , 0 ) ) ; oRange . addCellsShiftBottom ( ) } ; Worksheet . prototype . _getBordersForInsert =
function ( bbox , bRow ) { var t = this ; var borders = { } ; var offsetRow = bRow && bbox . r1 > 0 ? - 1 : 0 ; var offsetCol = ! bRow && bbox . c1 > 0 ? - 1 : 0 ; var r2 = bRow ? bbox . r1 : bbox . r2 ; var c2 = ! bRow ? bbox . c1 : bbox . c2 ; if ( 0 !== offsetRow || 0 !== offsetCol ) this . getRange3 ( bbox . r1 , bbox . c1 , r2 , c2 ) . _foreachNoEmpty ( function ( cell ) { if ( cell . xfs && cell . xfs . border ) t . _getCellNoEmpty ( cell . nRow + offsetRow , cell . nCol + offsetCol , function ( neighbor ) { if ( neighbor && neighbor . xfs && neighbor . xfs . border ) { var newBorder = neighbor . xfs . border . clone ( ) ; newBorder . intersect ( cell . xfs . border ,
g _oDefaultFormat . BorderAbs , true ) ; borders [ bRow ? cell . nCol : cell . nRow ] = newBorder } } ) } ) ; return borders } ; Worksheet . prototype . _insertRowsBefore = function ( index , count ) { var t = this ; this . workbook . dependencyFormulas . lockRecal ( ) ; var oActualRange = new Asc . Range ( 0 , index , gc _nMaxCol0 , index + count - 1 ) ; History . Create _NewPoint ( ) ; var offset = new AscCommon . CellBase ( count , 0 ) ; var renameRes = this . renameDependencyNodes ( offset , oActualRange ) ; var redrawTablesArr = this . autoFilters . insertRows ( "insCell" , oActualRange , c _oAscInsertOptions . InsertColumns ) ;
this . updatePivotOffset ( oActualRange , offset ) ; this . _updateFormulasParents ( index , 0 , gc _nMaxRow0 , gc _nMaxCol0 , oActualRange , offset , renameRes . shiftedShared ) ; var borders ; if ( index > 0 && ! this . workbook . bUndoChanges ) borders = this . _getBordersForInsert ( oActualRange , true ) ; this . rowsData . insertRange ( index , count ) ; this . nRowsCount = Math . max ( this . nRowsCount , this . rowsData . getSize ( ) ) ; this . _forEachColData ( function ( sheetMemory ) { sheetMemory . insertRange ( index , count ) ; t . cellsByColRowsCount = Math . max ( t . cellsByColRowsCount , sheetMemory . getSize ( ) ) } ) ;
this . nRowsCount = Math . max ( this . nRowsCount , this . cellsByColRowsCount ) ; if ( index > 0 && ! this . workbook . bUndoChanges ) { this . rowsData . copyRangeByChunk ( index - 1 , 1 , index , count ) ; this . nRowsCount = Math . max ( this . nRowsCount , this . rowsData . getSize ( ) ) ; this . _forEachColData ( function ( sheetMemory ) { sheetMemory . copyRangeByChunk ( index - 1 , 1 , index , count ) ; t . cellsByColRowsCount = Math . max ( t . cellsByColRowsCount , sheetMemory . getSize ( ) ) } ) ; this . nRowsCount = Math . max ( this . nRowsCount , this . cellsByColRowsCount ) ; this . getRange3 ( index , 0 , index + count -
1 , gc _nMaxCol0 ) . _foreachRowNoEmpty ( function ( row ) { row . setHidden ( false ) } , function ( cell ) { cell . clearDataKeepXf ( borders [ cell . nCol ] ) } ) } this . workbook . dependencyFormulas . notifyChanged ( renameRes . changed ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _AddRows , this . getId ( ) , new Asc . Range ( 0 , index , gc _nMaxCol0 , gc _nMaxRow0 ) , new UndoRedoData _FromToRowCol ( true , index , index + count - 1 ) ) ; this . autoFilters . redrawStylesTables ( redrawTablesArr ) ; this . workbook . dependencyFormulas . unlockRecal ( ) ; return true } ;
Worksheet . prototype . insertRowsAfter = function ( index , count ) { return this . insertRowsBefore ( index + 1 , count ) } ; Worksheet . prototype . getColsCount = function ( ) { var result = this . nColsCount ; var pane = this . sheetViews . length && this . sheetViews [ 0 ] . pane ; if ( pane && pane . topLeftFrozenCell ) result = Math . max ( result , pane . topLeftFrozenCell . getCol0 ( ) ) ; return result } ; Worksheet . prototype . removeCols = function ( start , stop ) { var oRange = this . getRange ( new CellAddress ( 0 , start , 0 ) , new CellAddress ( gc _nMaxRow0 , stop , 0 ) ) ; oRange . deleteCellsShiftLeft ( ) } ;
Worksheet . prototype . _removeCols = function ( start , stop ) { var t = this ; this . workbook . dependencyFormulas . lockRecal ( ) ; History . Create _NewPoint ( ) ; var nDif = - ( stop - start + 1 ) , i , j , length ; var oActualRange = new Asc . Range ( start , 0 , stop , gc _nMaxRow0 ) ; var offset = new AscCommon . CellBase ( 0 , nDif ) ; var renameRes = this . renameDependencyNodes ( offset , oActualRange ) ; var redrawTablesArr = this . autoFilters . insertColumn ( oActualRange , nDif ) ; this . updatePivotOffset ( oActualRange , offset ) ; var collapsedInfo = null , lastRowIndex ; var oDefColPr = new AscCommonExcel . UndoRedoData _ColProp ;
this . getRange3 ( 0 , start , gc _nMaxRow0 , stop ) . _foreachColNoEmpty ( function ( col ) { var nIndex = col . getIndex ( ) ; var oOldProps = col . getWidthProp ( ) ; if ( false === oOldProps . isEqual ( oDefColPr ) ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _ColProp , t . getId ( ) , new Asc . Range ( nIndex , 0 , nIndex , gc _nMaxRow0 ) , new UndoRedoData _IndexSimpleProp ( nIndex , false , oOldProps , oDefColPr ) ) ; col . setStyle ( null ) ; lastRowIndex = col . index ; if ( ! t . workbook . bRedoChanges ) { if ( collapsedInfo !== null && collapsedInfo < col . getOutlineLevel ( ) ) collapsedInfo =
null ; if ( col . getCollapsed ( ) ) { collapsedInfo = col . getOutlineLevel ( ) ; t . setCollapsedCol ( false , null , col ) } } } , function ( cell ) { t . _removeCell ( null , null , cell ) } ) ; if ( collapsedInfo !== null && lastRowIndex === stop ) { var curCol = this . _getCol ( stop + 1 ) ; if ( curCol ) t . setCollapsedCol ( true , null , curCol ) } this . _updateFormulasParents ( 0 , start , gc _nMaxRow0 , gc _nMaxCol0 , oActualRange , offset , renameRes . shiftedShared ) ; this . cellsByCol . splice ( start , stop - start + 1 ) ; this . aCols . splice ( start , stop - start + 1 ) ; for ( i = start , length = this . aCols . length ; i < length ; ++ i ) { var elem =
this . aCols [ i ] ; if ( null != elem ) elem . moveHor ( nDif ) } this . workbook . dependencyFormulas . notifyChanged ( renameRes . changed ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _RemoveCols , this . getId ( ) , new Asc . Range ( start , 0 , gc _nMaxCol0 , gc _nMaxRow0 ) , new UndoRedoData _FromToRowCol ( false , start , stop ) ) ; this . autoFilters . redrawStylesTables ( redrawTablesArr ) ; this . workbook . dependencyFormulas . unlockRecal ( ) ; return true } ; Worksheet . prototype . insertColsBefore = function ( index , count ) { var oRange = this . getRange3 ( 0 ,
index , gc _nMaxRow0 , index + count - 1 ) ; oRange . addCellsShiftRight ( ) } ; Worksheet . prototype . _insertColsBefore = function ( index , count ) { this . workbook . dependencyFormulas . lockRecal ( ) ; var oActualRange = new Asc . Range ( index , 0 , index + count - 1 , gc _nMaxRow0 ) ; History . Create _NewPoint ( ) ; var offset = new AscCommon . CellBase ( 0 , count ) ; var renameRes = this . renameDependencyNodes ( offset , oActualRange ) ; var redrawTablesArr = this . autoFilters . insertColumn ( oActualRange , count ) ; this . updatePivotOffset ( oActualRange , offset ) ; this . _updateFormulasParents ( 0 ,
index , gc _nMaxRow0 , gc _nMaxCol0 , oActualRange , offset , renameRes . shiftedShared ) ; var borders ; if ( index > 0 && ! this . workbook . bUndoChanges ) borders = this . _getBordersForInsert ( oActualRange , false ) ; this . cellsByCol . splice ( gc _nMaxCol0 - count + 1 , count ) ; for ( var i = this . cellsByCol . length - 1 ; i >= index ; -- i ) { this . cellsByCol [ i + count ] = this . cellsByCol [ i ] ; this . cellsByCol [ i ] = undefined } this . nColsCount = Math . max ( this . nColsCount , this . getColDataLength ( ) ) ; this . aCols . splice ( gc _nMaxCol0 - count + 1 , count ) ; for ( var i = this . aCols . length - 1 ; i >= index ; -- i ) { this . aCols [ i +
count ] = this . aCols [ i ] ; this . aCols [ i ] = undefined ; if ( this . aCols [ i + count ] ) this . aCols [ i + count ] . moveHor ( count ) } this . nColsCount = Math . max ( this . nColsCount , this . aCols . length ) ; if ( ! this . workbook . bUndoChanges ) { var oPrevCol = null ; if ( index > 0 ) oPrevCol = this . aCols [ index - 1 ] ; if ( null == oPrevCol && null != this . oAllCol ) oPrevCol = this . oAllCol ; if ( null != oPrevCol ) { History . LocalChange = true ; for ( var i = index ; i < index + count ; ++ i ) { var oNewCol = oPrevCol . clone ( ) ; oNewCol . setHidden ( null ) ; oNewCol . BestFit = null ; oNewCol . index = i ; this . aCols [ i ] = oNewCol } History . LocalChange =
false } var prevCellsByCol = index > 0 ? this . cellsByCol [ index - 1 ] : null ; if ( prevCellsByCol ) { for ( var i = index ; i < index + count ; ++ i ) this . cellsByCol [ i ] = prevCellsByCol . clone ( ) ; this . nColsCount = Math . max ( this . nColsCount , this . getColDataLength ( ) ) ; this . getRange3 ( 0 , index , gc _nMaxRow0 , index + count - 1 ) . _foreachNoEmpty ( function ( cell ) { cell . clearDataKeepXf ( borders [ cell . nRow ] ) } ) } } this . workbook . dependencyFormulas . notifyChanged ( renameRes . changed ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _AddCols , this . getId ( ) ,
new Asc . Range ( index , 0 , gc _nMaxCol0 , gc _nMaxRow0 ) , new UndoRedoData _FromToRowCol ( false , index , index + count - 1 ) ) ; this . autoFilters . redrawStylesTables ( redrawTablesArr ) ; this . workbook . dependencyFormulas . unlockRecal ( ) ; return true } ; Worksheet . prototype . insertColsAfter = function ( index , count ) { return this . insertColsBefore ( index + 1 , count ) } ; Worksheet . prototype . getDefaultWidth = function ( ) { return this . oSheetFormatPr . dDefaultColWidth } ; Worksheet . prototype . getDefaultFontName = function ( ) { return this . workbook . getDefaultFont ( ) } ;
Worksheet . prototype . getDefaultFontSize = function ( ) { return this . workbook . getDefaultSize ( ) } ; Worksheet . prototype . getBaseColWidth = function ( ) { return this . oSheetFormatPr . nBaseColWidth || 8 } ; Worksheet . prototype . charCountToModelColWidth = function ( count ) { return this . workbook . charCountToModelColWidth ( count ) } ; Worksheet . prototype . modelColWidthToColWidth = function ( mcw ) { return this . workbook . modelColWidthToColWidth ( mcw ) } ; Worksheet . prototype . colWidthToCharCount = function ( w ) { return this . workbook . colWidthToCharCount ( w ) } ;
Worksheet . prototype . getColWidth = function ( index ) { var col = this . _getColNoEmptyWithAll ( index ) ; if ( null != col && null != col . width ) return col . width ; var dResult = this . oSheetFormatPr . dDefaultColWidth ; if ( dResult === undefined || dResult === null || dResult == 0 ) dResult = - 1 ; return dResult } ; Worksheet . prototype . setColWidth = function ( width , start , stop ) { width = this . charCountToModelColWidth ( width ) ; if ( 0 == width ) return this . setColHidden ( true , start , stop ) ; if ( null == start ) return ; if ( null == stop ) stop = start ; History . Create _NewPoint ( ) ; var oSelection =
History . GetSelection ( ) ; if ( null != oSelection ) { oSelection = oSelection . clone ( ) ; oSelection . assign ( start , 0 , stop , gc _nMaxRow0 ) ; History . SetSelection ( oSelection ) ; History . SetSelectionRedo ( oSelection ) } var bNotAddCollapsed = true == this . workbook . bUndoChanges || true == this . workbook . bRedoChanges || this . bExcludeCollapsed ; var _summaryRight = this . sheetPr ? this . sheetPr . SummaryRight : true ; var oThis = this , prevCol ; var fProcessCol = function ( col ) { if ( col . width != width ) { if ( _summaryRight && ! bNotAddCollapsed && col . getCollapsed ( ) ) oThis . setCollapsedCol ( false ,
null , col ) ; else if ( ! _summaryRight && ! bNotAddCollapsed && prevCol && prevCol . getCollapsed ( ) ) oThis . setCollapsedCol ( false , null , prevCol ) ; prevCol = col ; var oOldProps = col . getWidthProp ( ) ; col . width = width ; col . CustomWidth = true ; col . BestFit = null ; col . setHidden ( null ) ; oThis . initColumn ( col ) ; var oNewProps = col . getWidthProp ( ) ; if ( false == oOldProps . isEqual ( oNewProps ) ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _ColProp , oThis . getId ( ) , col . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( col . index ,
false , oOldProps , oNewProps ) ) } } ; if ( 0 == start && gc _nMaxCol0 == stop ) { var col = this . getAllCol ( ) ; fProcessCol ( col ) ; for ( var i in this . aCols ) { var col = this . aCols [ i ] ; if ( null != col ) fProcessCol ( col ) } } else { if ( ! _summaryRight ) if ( ! bNotAddCollapsed && start > 0 ) prevCol = this . _getCol ( start - 1 ) ; for ( var i = start ; i <= stop ; i ++ ) { var col = this . _getCol ( i ) ; fProcessCol ( col ) } if ( _summaryRight && ! bNotAddCollapsed && prevCol ) { col = this . _getCol ( stop + 1 ) ; if ( col . getCollapsed ( ) ) this . setCollapsedCol ( false , null , col ) } } } ; Worksheet . prototype . getColHidden =
function ( index ) { var col = this . _getColNoEmptyWithAll ( index ) ; return col ? col . getHidden ( ) : false } ; Worksheet . prototype . setColHidden = function ( bHidden , start , stop ) { if ( null == start ) return ; if ( null == stop ) stop = start ; History . Create _NewPoint ( ) ; var oThis = this , outlineLevel ; var bNotAddCollapsed = true == this . workbook . bUndoChanges || true == this . workbook . bRedoChanges || this . bExcludeCollapsed ; var _summaryRight = this . sheetPr ? this . sheetPr . SummaryRight : true ; var fProcessCol = function ( col ) { if ( col && ! bNotAddCollapsed && outlineLevel !==
undefined && outlineLevel !== col . getOutlineLevel ( ) ) if ( ! _summaryRight ) oThis . setCollapsedCol ( bHidden , col . index - 1 ) ; else oThis . setCollapsedCol ( bHidden , null , col ) ; outlineLevel = col ? col . getOutlineLevel ( ) : null ; if ( col . getHidden ( ) != bHidden ) { var oOldProps = col . getWidthProp ( ) ; if ( bHidden ) { col . setHidden ( bHidden ) ; if ( null == col . width || true != col . CustomWidth ) col . width = 0 ; col . CustomWidth = true ; col . BestFit = null } else { col . setHidden ( null ) ; if ( 0 >= col . width ) col . width = null } var oNewProps = col . getWidthProp ( ) ; if ( false == oOldProps . isEqual ( oNewProps ) ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet ,
AscCH . historyitem _Worksheet _ColProp , oThis . getId ( ) , col . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( col . index , false , oOldProps , oNewProps ) ) } } ; if ( ! bNotAddCollapsed && ! _summaryRight && start > 0 ) { col = this . _getCol ( start - 1 ) ; outlineLevel = col . getOutlineLevel ( ) } if ( 0 != start && gc _nMaxCol0 == stop ) { var col = null ; if ( false == bHidden ) col = this . oAllCol ; else col = this . getAllCol ( ) ; if ( null != col ) fProcessCol ( col ) ; for ( var i in this . aCols ) { var col = this . aCols [ i ] ; if ( null != col ) fProcessCol ( col ) } } else for ( var i = start ; i <= stop ; i ++ ) { var col =
null ; if ( false == bHidden ) col = this . _getColNoEmpty ( i ) ; else col = this . _getCol ( i ) ; if ( null != col ) fProcessCol ( col ) } if ( ! bNotAddCollapsed && outlineLevel && _summaryRight ) { col = this . _getCol ( stop + 1 ) ; if ( col && outlineLevel !== col . getOutlineLevel ( ) ) oThis . setCollapsedCol ( bHidden , null , col ) } } ; Worksheet . prototype . setCollapsedCol = function ( bCollapse , colIndex , curCol ) { var oThis = this ; var fProcessCol = function ( col ) { var oOldProps = col . getCollapsed ( ) ; col . setCollapsed ( bCollapse ) ; var oNewProps = col . getCollapsed ( ) ; if ( oOldProps !== oNewProps ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet ,
AscCH . historyitem _Worksheet _CollapsedCol , oThis . getId ( ) , col . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( col . index , true , oOldProps , oNewProps ) ) } ; if ( curCol ) fProcessCol ( curCol ) ; else this . getRange3 ( 0 , colIndex , 0 , colIndex ) . _foreachCol ( fProcessCol ) } ; Worksheet . prototype . setSummaryRight = function ( val ) { if ( ! this . sheetPr ) this . sheetPr = new AscCommonExcel . asc _CSheetPr ; History . Create _NewPoint ( ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _SetSummaryRight , this . getId ( ) , null , new UndoRedoData _FromTo ( this . sheetPr . SummaryRight ,
val ) ) ; this . sheetPr . SummaryRight = val } ; Worksheet . prototype . setSummaryBelow = function ( val ) { if ( ! this . sheetPr ) this . sheetPr = new AscCommonExcel . asc _CSheetPr ; History . Create _NewPoint ( ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _SetSummaryBelow , this . getId ( ) , null , new UndoRedoData _FromTo ( this . sheetPr . SummaryBelow , val ) ) ; this . sheetPr . SummaryBelow = val } ; Worksheet . prototype . setGroupCol = function ( bDel , start , stop ) { var oThis = this ; var fProcessCol = function ( col ) { var oOldProps = col . getOutlineLevel ( ) ;
col . setOutlineLevel ( null , bDel ) ; var oNewProps = col . getOutlineLevel ( ) ; if ( oOldProps !== oNewProps ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _GroupCol , oThis . getId ( ) , col . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( col . index , true , oOldProps , oNewProps ) ) } ; this . getRange3 ( 0 , start , 0 , stop ) . _foreachCol ( fProcessCol ) } ; Worksheet . prototype . setOutlineCol = function ( val , start , stop ) { var oThis = this ; var fProcessCol = function ( col ) { var oOldProps = col . getOutlineLevel ( ) ; col . setOutlineLevel ( val ) ;
var oNewProps = col . getOutlineLevel ( ) ; if ( oOldProps !== oNewProps ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _GroupCol , oThis . getId ( ) , col . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( col . index , true , oOldProps , oNewProps ) ) } ; this . getRange3 ( 0 , start , 0 , stop ) . _foreachCol ( fProcessCol ) } ; Worksheet . prototype . getColCustomWidth = function ( index ) { var isBestFit ; var column = this . _getColNoEmptyWithAll ( index ) ; if ( ! column ) isBestFit = true ; else if ( column . getHidden ( ) ) isBestFit = false ; else isBestFit =
! ! ( column . BestFit || null === column . BestFit && null === column . CustomWidth ) ; return ! isBestFit } ; Worksheet . prototype . setColBestFit = function ( bBestFit , width , start , stop ) { if ( null == start ) return ; if ( null == stop ) stop = start ; History . Create _NewPoint ( ) ; var oThis = this ; var fProcessCol = function ( col ) { var oOldProps = col . getWidthProp ( ) ; if ( bBestFit ) { col . BestFit = bBestFit ; col . setHidden ( null ) } else col . BestFit = null ; col . width = width ; oThis . initColumn ( col ) ; var oNewProps = col . getWidthProp ( ) ; if ( false == oOldProps . isEqual ( oNewProps ) ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet ,
AscCH . historyitem _Worksheet _ColProp , oThis . getId ( ) , col . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( col . index , false , oOldProps , oNewProps ) ) } ; if ( 0 != start && gc _nMaxCol0 == stop ) { var col = null ; if ( bBestFit && oDefaultMetrics . ColWidthChars == width ) col = this . oAllCol ; else col = this . getAllCol ( ) ; if ( null != col ) fProcessCol ( col ) ; for ( var i in this . aCols ) { var col = this . aCols [ i ] ; if ( null != col ) fProcessCol ( col ) } } else for ( var i = start ; i <= stop ; i ++ ) { var col = null ; if ( bBestFit && oDefaultMetrics . ColWidthChars == width ) col = this . _getColNoEmpty ( i ) ;
else col = this . _getCol ( i ) ; if ( null != col ) fProcessCol ( col ) } } ; Worksheet . prototype . isDefaultHeightHidden = function ( ) { return null != this . oSheetFormatPr . oAllRow && this . oSheetFormatPr . oAllRow . getHidden ( ) } ; Worksheet . prototype . isDefaultWidthHidden = function ( ) { return null != this . oAllCol && this . oAllCol . getHidden ( ) } ; Worksheet . prototype . setDefaultHeight = function ( h ) { if ( this . oSheetFormatPr . oAllRow && ! this . oSheetFormatPr . oAllRow . getCustomHeight ( ) ) this . oSheetFormatPr . oAllRow . h = h } ; Worksheet . prototype . getDefaultHeight = function ( ) { var dRes =
null ; if ( null != this . oSheetFormatPr . oAllRow && this . oSheetFormatPr . oAllRow . getCustomHeight ( ) ) dRes = this . oSheetFormatPr . oAllRow . h ; return dRes } ; Worksheet . prototype . getRowHeight = function ( index ) { var res ; this . _getRowNoEmptyWithAll ( index , function ( row ) { res = row ? row . getHeight ( ) : - 1 } ) ; return res } ; Worksheet . prototype . setRowHeight = function ( height , start , stop , isCustom ) { if ( 0 == height ) return this . setRowHidden ( true , start , stop ) ; if ( null == start ) return ; if ( null == stop ) stop = start ; History . Create _NewPoint ( ) ; var oThis = this , i ; var oSelection =
History . GetSelection ( ) ; if ( null != oSelection ) { oSelection = oSelection . clone ( ) ; oSelection . assign ( 0 , start , gc _nMaxCol0 , stop ) ; History . SetSelection ( oSelection ) ; History . SetSelectionRedo ( oSelection ) } var prevRow ; var bNotAddCollapsed = true == this . workbook . bUndoChanges || true == this . workbook . bRedoChanges || this . bExcludeCollapsed ; var _summaryBelow = this . sheetPr ? this . sheetPr . SummaryBelow : true ; var fProcessRow = function ( row ) { if ( row ) { if ( _summaryBelow && ! bNotAddCollapsed && row . getCollapsed ( ) ) oThis . setCollapsedRow ( false , null ,
row ) ; else if ( ! _summaryBelow && ! bNotAddCollapsed && prevRow && prevRow . getCollapsed ( ) ) oThis . setCollapsedRow ( false , null , prevRow ) ; prevRow = row ; var oOldProps = row . getHeightProp ( ) ; row . setHeight ( height ) ; if ( isCustom ) row . setCustomHeight ( true ) ; row . setCalcHeight ( true ) ; row . setHidden ( false ) ; var oNewProps = row . getHeightProp ( ) ; if ( false === oOldProps . isEqual ( oNewProps ) ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _RowProp , oThis . getId ( ) , row . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( row . index ,
true , oOldProps , oNewProps ) ) } } ; if ( 0 == start && gc _nMaxRow0 == stop ) { fProcessRow ( this . getAllRow ( ) ) ; this . _forEachRow ( fProcessRow ) } else { if ( ! _summaryBelow ) if ( ! bNotAddCollapsed && start > 0 ) this . _getRow ( start - 1 , function ( row ) { prevRow = row } ) ; this . getRange3 ( start , 0 , stop , 0 ) . _foreachRow ( fProcessRow ) ; if ( _summaryBelow ) if ( ! bNotAddCollapsed && prevRow ) this . _getRow ( stop + 1 , function ( row ) { if ( row . getCollapsed ( ) ) oThis . setCollapsedRow ( false , null , row ) } ) } if ( this . needRecalFormulas ( start , stop ) ) this . workbook . dependencyFormulas . calcTree ( ) } ;
Worksheet . prototype . getRowHidden = function ( index ) { var res ; this . _getRowNoEmptyWithAll ( index , function ( row ) { res = row ? row . getHidden ( ) : false } ) ; return res } ; Worksheet . prototype . setRowHidden = function ( bHidden , start , stop ) { if ( null == start ) return ; if ( null == stop ) stop = start ; History . Create _NewPoint ( ) ; var oThis = this , i ; var startIndex = null , endIndex = null , updateRange , outlineLevel ; var bNotAddCollapsed = true == this . workbook . bUndoChanges || true == this . workbook . bRedoChanges || this . bExcludeCollapsed ; var _summaryBelow = this . sheetPr ?
this . sheetPr . SummaryBelow : true ; var fProcessRow = function ( row ) { if ( row && ! bNotAddCollapsed && outlineLevel !== undefined && outlineLevel !== row . getOutlineLevel ( ) ) if ( ! _summaryBelow ) oThis . setCollapsedRow ( bHidden , row . index - 1 ) ; else oThis . setCollapsedRow ( bHidden , null , row ) ; outlineLevel = row ? row . getOutlineLevel ( ) : null ; if ( row && bHidden != row . getHidden ( ) ) { row . setHidden ( bHidden ) ; if ( row . index === endIndex + 1 && startIndex !== null ) endIndex ++ ; else { if ( startIndex !== null ) { updateRange = new Asc . Range ( 0 , startIndex , gc _nMaxCol0 , endIndex ) ;
History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _RowHide , oThis . getId ( ) , updateRange , new UndoRedoData _FromToRowCol ( bHidden , startIndex , endIndex ) ) } startIndex = row . index ; endIndex = row . index } } } ; if ( 0 == start && gc _nMaxRow0 == stop ) ; else { if ( ! _summaryBelow && start > 0 && ! bNotAddCollapsed ) this . _getRow ( start - 1 , function ( row ) { if ( row ) outlineLevel = row . getOutlineLevel ( ) } ) ; for ( i = start ; i <= stop ; ++ i ) false == bHidden ? this . _getRowNoEmpty ( i , fProcessRow ) : this . _getRow ( i , fProcessRow ) ; if ( _summaryBelow && outlineLevel &&
! bNotAddCollapsed ) this . _getRow ( stop + 1 , function ( row ) { if ( row && outlineLevel !== row . getOutlineLevel ( ) ) oThis . setCollapsedRow ( bHidden , null , row ) } ) ; if ( startIndex !== null ) { updateRange = new Asc . Range ( 0 , startIndex , gc _nMaxCol0 , endIndex ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _RowHide , oThis . getId ( ) , updateRange , new UndoRedoData _FromToRowCol ( bHidden , startIndex , endIndex ) ) } } if ( this . needRecalFormulas ( start , stop ) ) this . workbook . dependencyFormulas . calcTree ( ) } ; Worksheet . prototype . setCollapsedRow =
function ( bCollapse , rowIndex , curRow ) { var oThis = this ; var fProcessRow = function ( row , bSave ) { var oOldProps = row . getCollapsed ( ) ; row . setCollapsed ( bCollapse ) ; var oNewProps = row . getCollapsed ( ) ; if ( oOldProps !== oNewProps ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _CollapsedRow , oThis . getId ( ) , row . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( row . index , true , oOldProps , oNewProps ) ) ; if ( bSave ) row . saveContent ( true ) } ; if ( curRow ) fProcessRow ( curRow , true ) ; else this . getRange3 ( rowIndex , 0 , rowIndex ,
0 ) . _foreachRow ( fProcessRow ) } ; Worksheet . prototype . setGroupRow = function ( bDel , start , stop ) { var oThis = this ; var fProcessRow = function ( row ) { var oOldProps = row . getOutlineLevel ( ) ; row . setOutlineLevel ( null , bDel ) ; var oNewProps = row . getOutlineLevel ( ) ; if ( oOldProps !== oNewProps ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _GroupRow , oThis . getId ( ) , row . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( row . index , true , oOldProps , oNewProps ) ) } ; this . getRange3 ( start , 0 , stop , 0 ) . _foreachRow ( fProcessRow ) } ;
Worksheet . prototype . setOutlineRow = function ( val , start , stop ) { var oThis = this ; var fProcessRow = function ( row ) { var oOldProps = row . getOutlineLevel ( ) ; row . setOutlineLevel ( val ) ; var oNewProps = row . getOutlineLevel ( ) ; if ( oOldProps !== oNewProps ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _GroupRow , oThis . getId ( ) , row . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( row . index , true , oOldProps , oNewProps ) ) } ; this . getRange3 ( start , 0 , stop , 0 ) . _foreachRow ( fProcessRow ) } ; Worksheet . prototype . getRowCustomHeight =
function ( index ) { var isCustomHeight = false ; this . _getRowNoEmptyWithAll ( index , function ( row ) { if ( ! row ) isCustomHeight = false ; else if ( row . getHidden ( ) ) isCustomHeight = true ; else isCustomHeight = row . getCustomHeight ( ) } ) ; return isCustomHeight } ; Worksheet . prototype . setRowBestFit = function ( bBestFit , height , start , stop ) { if ( null == start ) return ; if ( null == stop ) stop = start ; History . Create _NewPoint ( ) ; var oThis = this , i ; var isDefaultProp = true == bBestFit && oDefaultMetrics . RowHeight == height ; var fProcessRow = function ( row ) { if ( row ) { var oOldProps =
row . getHeightProp ( ) ; row . setCustomHeight ( ! bBestFit ) ; row . setCalcHeight ( true ) ; row . setHeight ( height ) ; var oNewProps = row . getHeightProp ( ) ; if ( false == oOldProps . isEqual ( oNewProps ) ) History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _RowProp , oThis . getId ( ) , row . _getUpdateRange ( ) , new UndoRedoData _IndexSimpleProp ( row . index , true , oOldProps , oNewProps ) ) } } ; if ( 0 == start && gc _nMaxRow0 == stop ) { fProcessRow ( isDefaultProp ? this . oSheetFormatPr . oAllRow : this . getAllRow ( ) ) ; this . _forEachRow ( fProcessRow ) } else { var range =
this . getRange3 ( start , 0 , stop , 0 ) ; if ( isDefaultProp ) range . _foreachRowNoEmpty ( fProcessRow ) ; else range . _foreachRow ( fProcessRow ) } this . workbook . dependencyFormulas . calcTree ( ) } ; Worksheet . prototype . getCell = function ( oCellAdd ) { return this . getRange ( oCellAdd , oCellAdd ) } ; Worksheet . prototype . getCell2 = function ( sCellAdd ) { if ( sCellAdd . indexOf ( "$" ) > - 1 ) sCellAdd = sCellAdd . replace ( /\$/g , "" ) ; return this . getRange2 ( sCellAdd ) } ; Worksheet . prototype . getCell3 = function ( r1 , c1 ) { return this . getRange3 ( r1 , c1 , r1 , c1 ) } ; Worksheet . prototype . getRange =
function ( cellAdd1 , cellAdd2 ) { var nRow1 = cellAdd1 . getRow0 ( ) ; var nCol1 = cellAdd1 . getCol0 ( ) ; var nRow2 = cellAdd2 . getRow0 ( ) ; var nCol2 = cellAdd2 . getCol0 ( ) ; return this . getRange3 ( nRow1 , nCol1 , nRow2 , nCol2 ) } ; Worksheet . prototype . getRange2 = function ( sRange ) { var bbox = AscCommonExcel . g _oRangeCache . getAscRange ( sRange ) ; if ( null != bbox ) return Range . prototype . createFromBBox ( this , bbox ) ; return null } ; Worksheet . prototype . getRange3 = function ( r1 , c1 , r2 , c2 ) { var nRowMin = r1 ; var nRowMax = r2 ; var nColMin = c1 ; var nColMax = c2 ; if ( r1 > r2 ) { nRowMax =
r1 ; nRowMin = r2 } if ( c1 > c2 ) { nColMax = c1 ; nColMin = c2 } return new Range ( this , nRowMin , nColMin , nRowMax , nColMax ) } ; Worksheet . prototype . getRange4 = function ( r , c ) { return new Range ( this , r , c , r , c ) } ; Worksheet . prototype . getRowIterator = function ( r1 , c1 , c2 , callback ) { var it = new RowIterator ; it . init ( this , r1 , c1 , c2 ) ; callback ( it ) ; it . release ( ) } ; Worksheet . prototype . _removeCell = function ( nRow , nCol , cell ) { var t = this ; var processCell = function ( cell ) { if ( null != cell ) { var sheetId = t . getId ( ) ; if ( false == cell . isEmpty ( ) ) { var oUndoRedoData _CellData =
new AscCommonExcel . UndoRedoData _CellData ( cell . getValueData ( ) , null ) ; if ( null != cell . xfs ) oUndoRedoData _CellData . style = cell . xfs . clone ( ) ; cell . setFormulaInternal ( null ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _RemoveCell , sheetId , new Asc . Range ( nCol , nRow , nCol , nRow ) , new UndoRedoData _CellSimpleData ( nRow , nCol , oUndoRedoData _CellData , null ) ) } t . workbook . dependencyFormulas . addToChangedCell ( cell ) ; cell . clearData ( ) ; cell . saveContent ( true ) } } ; if ( null != cell ) { nRow = cell . nRow ; nCol = cell . nCol ;
processCell ( cell ) } else this . _getCellNoEmpty ( nRow , nCol , processCell ) } ; Worksheet . prototype . _getCell = function ( row , col , fAction ) { var wb = this . workbook ; var targetCell = null ; for ( var k = 0 ; k < wb . loadCells . length ; ++ k ) { var elem = wb . loadCells [ k ] ; if ( elem . nRow == row && elem . nCol == col && this === elem . ws ) { targetCell = elem ; break } } if ( null === targetCell ) { var cell = new Cell ( this ) ; wb . loadCells . push ( cell ) ; if ( ! cell . loadContent ( row , col ) ) this . _initCell ( cell , row , col ) ; fAction ( cell ) ; cell . saveContent ( true ) ; wb . loadCells . pop ( ) } else fAction ( targetCell ) } ;
Worksheet . prototype . _initRow = function ( row , index ) { var t = this ; row . setChanged ( true ) ; if ( null != this . oSheetFormatPr . oAllRow ) { row . copyFrom ( this . oSheetFormatPr . oAllRow ) ; row . setIndex ( index ) } this . nRowsCount = index >= this . nRowsCount ? index + 1 : this . nRowsCount } ; Worksheet . prototype . _initCell = function ( cell , nRow , nCol ) { var t = this ; cell . setChanged ( true ) ; this . _getRowNoEmpty ( nRow , function ( row ) { var oCol = t . _getColNoEmptyWithAll ( nCol ) ; var xfs = null ; if ( row && null != row . xfs ) xfs = row . xfs . clone ( ) ; else if ( null != oCol && null != oCol . xfs ) xfs =
oCol . xfs . clone ( ) ; cell . setStyleInternal ( xfs ) ; t . cellsByColRowsCount = Math . max ( t . cellsByColRowsCount , nRow + 1 ) ; t . nRowsCount = Math . max ( t . nRowsCount , t . cellsByColRowsCount ) ; if ( nCol >= t . nColsCount ) t . nColsCount = nCol + 1 } ) ; var sheetMemory = this . getColData ( nCol ) ; sheetMemory . checkSize ( nRow ) } ; Worksheet . prototype . _getCellNoEmpty = function ( row , col , fAction ) { var wb = this . workbook ; var targetCell = null ; for ( var k = 0 ; k < wb . loadCells . length ; ++ k ) { var elem = wb . loadCells [ k ] ; if ( elem . nRow == row && elem . nCol == col && this === elem . ws ) { targetCell =
elem ; break } } if ( null === targetCell ) { var cell = new Cell ( this ) ; var res = cell . loadContent ( row , col ) ? cell : null ; if ( res && fAction ) wb . loadCells . push ( cell ) ; fAction ( res ) ; cell . saveContent ( true ) ; if ( res ) wb . loadCells . pop ( ) } else fAction ( targetCell ) } ; Worksheet . prototype . _getRowNoEmpty = function ( nRow , fAction ) { var row = new AscCommonExcel . Row ( this ) ; if ( row . loadContent ( nRow ) ) { fAction ( row ) ; row . saveContent ( true ) } else fAction ( null ) } ; Worksheet . prototype . _getRowNoEmptyWithAll = function ( nRow , fAction ) { var t = this ; this . _getRowNoEmpty ( nRow ,
function ( row ) { if ( ! row ) row = t . oSheetFormatPr . oAllRow ; fAction ( row ) } ) } ; Worksheet . prototype . _getColNoEmpty = function ( col ) { return this . aCols [ col ] || null } ; Worksheet . prototype . _getColNoEmptyWithAll = function ( col ) { return this . _getColNoEmpty ( col ) || this . oAllCol } ; Worksheet . prototype . _getRow = function ( index , fAction ) { var row = null ; if ( g _nAllRowIndex == index ) row = this . getAllRow ( ) ; else { row = new AscCommonExcel . Row ( this ) ; if ( ! row . loadContent ( index ) ) this . _initRow ( row , index ) } fAction ( row ) ; row . saveContent ( true ) } ; Worksheet . prototype . _getCol =
function ( index ) { var oCurCol ; if ( g _nAllColIndex == index ) oCurCol = this . getAllCol ( ) ; else { oCurCol = this . aCols [ index ] ; if ( null == oCurCol ) { if ( null != this . oAllCol ) { oCurCol = this . oAllCol . clone ( ) ; oCurCol . index = index } else oCurCol = new AscCommonExcel . Col ( this , index ) ; this . aCols [ index ] = oCurCol ; this . nColsCount = index >= this . nColsCount ? index + 1 : this . nColsCount } } return oCurCol } ; Worksheet . prototype . _prepareMoveRangeGetCleanRanges = function ( oBBoxFrom , oBBoxTo , wsTo ) { var intersection = oBBoxFrom . intersectionSimple ( oBBoxTo ) ; var aRangesToCheck =
[ ] ; if ( null != intersection && this === wsTo ) { var oThis = this ; var fAddToRangesToCheck = function ( aRangesToCheck , r1 , c1 , r2 , c2 ) { if ( r1 <= r2 && c1 <= c2 ) aRangesToCheck . push ( oThis . getRange3 ( r1 , c1 , r2 , c2 ) ) } ; if ( intersection . r1 == oBBoxTo . r1 && intersection . c1 == oBBoxTo . c1 ) { fAddToRangesToCheck ( aRangesToCheck , oBBoxTo . r1 , intersection . c2 + 1 , intersection . r2 , oBBoxTo . c2 ) ; fAddToRangesToCheck ( aRangesToCheck , intersection . r2 + 1 , oBBoxTo . c1 , oBBoxTo . r2 , oBBoxTo . c2 ) } else if ( intersection . r2 == oBBoxTo . r2 && intersection . c1 == oBBoxTo . c1 ) { fAddToRangesToCheck ( aRangesToCheck ,
oBBoxTo . r1 , oBBoxTo . c1 , intersection . r1 - 1 , oBBoxTo . c2 ) ; fAddToRangesToCheck ( aRangesToCheck , intersection . r1 , intersection . c2 + 1 , oBBoxTo . r2 , oBBoxTo . c2 ) } else if ( intersection . r1 == oBBoxTo . r1 && intersection . c2 == oBBoxTo . c2 ) { fAddToRangesToCheck ( aRangesToCheck , oBBoxTo . r1 , oBBoxTo . c1 , intersection . r2 , intersection . c1 - 1 ) ; fAddToRangesToCheck ( aRangesToCheck , intersection . r2 + 1 , oBBoxTo . c1 , oBBoxTo . r2 , oBBoxTo . c2 ) } else if ( intersection . r2 == oBBoxTo . r2 && intersection . c2 == oBBoxTo . c2 ) { fAddToRangesToCheck ( aRangesToCheck , oBBoxTo . r1 ,
oBBoxTo . c1 , intersection . r1 - 1 , oBBoxTo . c2 ) ; fAddToRangesToCheck ( aRangesToCheck , intersection . r1 , oBBoxTo . c1 , oBBoxTo . r2 , intersection . c1 - 1 ) } } else aRangesToCheck . push ( wsTo . getRange3 ( oBBoxTo . r1 , oBBoxTo . c1 , oBBoxTo . r2 , oBBoxTo . c2 ) ) ; return aRangesToCheck } ; Worksheet . prototype . _prepareMoveRange = function ( oBBoxFrom , oBBoxTo , wsTo ) { var res = 0 ; if ( ! wsTo ) wsTo = this ; if ( oBBoxFrom . isEqual ( oBBoxTo ) && this === wsTo ) return res ; var range = wsTo . getRange3 ( oBBoxTo . r1 , oBBoxTo . c1 , oBBoxTo . r2 , oBBoxTo . c2 ) ; var aMerged = wsTo . mergeManager . get ( range . getBBox0 ( ) ) ;
if ( aMerged . outer . length > 0 ) return - 2 ; var aRangesToCheck = this . _prepareMoveRangeGetCleanRanges ( oBBoxFrom , oBBoxTo , wsTo ) ; for ( var i = 0 , length = aRangesToCheck . length ; i < length ; i ++ ) { range = aRangesToCheck [ i ] ; range . _foreachNoEmpty ( function ( cell ) { if ( ! cell . isNullTextString ( ) ) { res = - 1 ; return res } } ) ; if ( 0 != res ) return res } return res } ; Worksheet . prototype . _moveMergedAndHyperlinksPrepare = function ( oBBoxFrom , oBBoxTo , copyRange , wsTo , offset ) { var res = { merged : [ ] , hyperlinks : [ ] } ; if ( ! ( false == this . workbook . bUndoChanges && ( false == this . workbook . bRedoChanges ||
this . workbook . bCollaborativeChanges ) ) ) return res ; var i , elem , bbox , data , wsFrom = this ; var intersection = oBBoxFrom . intersectionSimple ( oBBoxTo ) ; History . LocalChange = true ; var merged = wsFrom . mergeManager . get ( oBBoxFrom ) . inner ; var mergedToRemove ; if ( ! copyRange ) mergedToRemove = merged ; else if ( null !== intersection ) mergedToRemove = wsFrom . mergeManager . get ( intersection ) . all ; if ( mergedToRemove ) for ( i = 0 ; i < mergedToRemove . length ; i ++ ) wsFrom . mergeManager . removeElement ( mergedToRemove [ i ] ) ; var hyperlinks = wsFrom . hyperlinkManager . get ( oBBoxFrom ) . inner ;
if ( ! copyRange ) for ( i = 0 ; i < hyperlinks . length ; i ++ ) wsFrom . hyperlinkManager . removeElement ( hyperlinks [ i ] ) ; History . LocalChange = false ; res . merged = merged ; res . hyperlinks = hyperlinks ; return res } ; Worksheet . prototype . _moveMergedAndHyperlinks = function ( prepared , oBBoxFrom , oBBoxTo , copyRange , wsTo , offset ) { var i , elem , bbox , data ; var intersection = oBBoxFrom . intersectionSimple ( oBBoxTo ) ; History . LocalChange = true ; for ( i = 0 ; i < prepared . merged . length ; i ++ ) { elem = prepared . merged [ i ] ; bbox = copyRange ? elem . bbox . clone ( ) : elem . bbox ; bbox . setOffset ( offset ) ;
wsTo . mergeManager . add ( bbox , elem . data ) } if ( ! copyRange || null === intersection ) for ( i = 0 ; i < prepared . hyperlinks . length ; i ++ ) { elem = prepared . hyperlinks [ i ] ; if ( copyRange ) { bbox = elem . bbox . clone ( ) ; data = elem . data . clone ( ) } else { bbox = elem . bbox ; data = elem . data } bbox . setOffset ( offset ) ; wsTo . hyperlinkManager . add ( bbox , data ) } History . LocalChange = false } ; Worksheet . prototype . _moveCleanRanges = function ( oBBoxFrom , oBBoxTo , copyRange , wsTo ) { var cleanRanges = this . _prepareMoveRangeGetCleanRanges ( oBBoxFrom , oBBoxTo , wsTo ) ; for ( var i = 0 ; i < cleanRanges . length ; i ++ ) { var range =
cleanRanges [ i ] ; range . cleanAll ( ) ; if ( ! copyRange ) this . workbook . dependencyFormulas . deleteNodes ( wsTo . getId ( ) , range . getBBox0 ( ) ) } } ; Worksheet . prototype . _moveFormulas = function ( oBBoxFrom , oBBoxTo , copyRange , wsTo , offset ) { if ( ! copyRange ) this . workbook . dependencyFormulas . move ( this . Id , oBBoxFrom , offset , wsTo . getId ( ) ) ; this . getRange3 ( oBBoxFrom . r1 , oBBoxFrom . c1 , oBBoxFrom . r2 , oBBoxFrom . c2 ) . _foreachNoEmpty ( function ( cell ) { if ( cell . transformSharedFormula ( ) ) { var parsed = cell . getFormulaParsed ( ) ; parsed . buildDependencies ( ) } } ) } ; Worksheet . prototype . _moveCells =
function ( oBBoxFrom , oBBoxTo , copyRange , wsTo , offset ) { var oThis = this ; var nRowsCountNew = 0 ; var nColsCountNew = 0 ; var dependencyFormulas = oThis . workbook . dependencyFormulas ; var moveToOtherSheet = this !== wsTo ; var isClearFromArea = ! copyRange || copyRange && oThis . workbook . bUndoChanges ; var moveCells = function ( copyRange , from , to , r1From , r1To , count ) { var fromData = oThis . getColDataNoEmpty ( from ) ; var toData ; if ( fromData ) { toData = wsTo . getColData ( to ) ; toData . copyRange ( fromData , r1From , r1To , count ) ; if ( isClearFromArea ) if ( from !== to || moveToOtherSheet ) fromData . clear ( r1From ,
r1From + count ) ; else if ( r1From < r1To ) fromData . clear ( r1From , Math . min ( r1From + count , r1To ) ) ; else fromData . clear ( Math . max ( r1From , r1To + count ) , r1From + count ) } else { toData = wsTo . getColDataNoEmpty ( to ) ; if ( toData ) toData . clear ( r1To , r1To + count ) } if ( toData ) { nRowsCountNew = Math . max ( nRowsCountNew , toData . getSize ( ) ) ; nColsCountNew = Math . max ( nColsCountNew , to + 1 ) } } ; if ( oBBoxFrom . c1 < oBBoxTo . c1 ) for ( var i = 0 ; i < oBBoxFrom . c2 - oBBoxFrom . c1 + 1 ; ++ i ) moveCells ( copyRange , oBBoxFrom . c2 - i , oBBoxTo . c2 - i , oBBoxFrom . r1 , oBBoxTo . r1 , oBBoxFrom . r2 - oBBoxFrom . r1 +
1 ) ; else for ( var i = 0 ; i < oBBoxFrom . c2 - oBBoxFrom . c1 + 1 ; ++ i ) moveCells ( copyRange , oBBoxFrom . c1 + i , oBBoxTo . c1 + i , oBBoxFrom . r1 , oBBoxTo . r1 , oBBoxFrom . r2 - oBBoxFrom . r1 + 1 ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _MoveRange , this . getId ( ) , new Asc . Range ( 0 , 0 , gc _nMaxCol0 , gc _nMaxRow0 ) , new UndoRedoData _FromTo ( new UndoRedoData _BBox ( oBBoxFrom ) , new UndoRedoData _BBox ( oBBoxTo ) , copyRange , wsTo . getId ( ) ) ) ; if ( moveToOtherSheet ) History . AddToUpdatesRegions ( oBBoxTo , wsTo . getId ( ) ) ; var shiftedArrayFormula =
{ } ; var oldNewArrayFormulaMap = { } ; wsTo . cellsByColRowsCount = Math . max ( wsTo . cellsByColRowsCount , nRowsCountNew ) ; wsTo . nRowsCount = Math . max ( wsTo . nRowsCount , wsTo . cellsByColRowsCount ) ; wsTo . nColsCount = Math . max ( wsTo . nColsCount , nColsCountNew ) ; wsTo . getRange3 ( oBBoxTo . r1 , oBBoxTo . c1 , oBBoxTo . r2 , oBBoxTo . c2 ) . _foreachNoEmpty ( function ( cell ) { var formula = cell . getFormulaParsed ( ) ; if ( formula ) { var cellWithFormula = formula . getParent ( ) ; var arrayFormula = formula . getArrayFormulaRef ( ) ; var newArrayRef , newFormula ; var preMoveCell = { nRow : cell . nRow -
offset . row , nCol : cell . nCol - offset . col } ; var isFirstCellArray = formula . checkFirstCellArray ( preMoveCell ) && ! shiftedArrayFormula [ formula . getListenerId ( ) ] ; if ( copyRange ) { History . TurnOff ( ) ; if ( ! arrayFormula || arrayFormula && isFirstCellArray ) { newFormula = oThis . _moveCellsFormula ( cell , formula , cellWithFormula , copyRange , oBBoxFrom , wsTo ) ; cellWithFormula = newFormula . getParent ( ) ; cellWithFormula = new CCellWithFormula ( wsTo , cell . nRow , cell . nCol ) ; newFormula = newFormula . clone ( null , cellWithFormula , wsTo ) ; newFormula . changeOffset ( offset ,
false , true ) ; newFormula . setFormulaString ( newFormula . assemble ( true ) ) ; cell . setFormulaInternal ( newFormula , ! isClearFromArea ) ; if ( isFirstCellArray ) { newArrayRef = arrayFormula . clone ( ) ; newArrayRef . setOffset ( offset ) ; newFormula . setArrayFormulaRef ( newArrayRef ) ; shiftedArrayFormula [ newFormula . getListenerId ( ) ] = 1 ; oldNewArrayFormulaMap [ formula . getListenerId ( ) ] = newFormula } } else if ( arrayFormula && oldNewArrayFormulaMap [ formula . getListenerId ( ) ] ) cell . setFormulaInternal ( oldNewArrayFormulaMap [ formula . getListenerId ( ) ] , ! isClearFromArea ) ;
History . TurnOn ( ) } else if ( arrayFormula ) { if ( isFirstCellArray ) { newFormula = oThis . _moveCellsFormula ( cell , formula , cellWithFormula , copyRange , oBBoxFrom , wsTo ) ; cellWithFormula = newFormula . getParent ( ) ; shiftedArrayFormula [ formula . getListenerId ( ) ] = 1 ; newArrayRef = arrayFormula . clone ( ) ; newArrayRef . setOffset ( offset ) ; newFormula . setArrayFormulaRef ( newArrayRef ) ; cellWithFormula . ws = wsTo ; cellWithFormula . nRow = cell . nRow ; cellWithFormula . nCol = cell . nCol } } else { newFormula = oThis . _moveCellsFormula ( cell , formula , cellWithFormula , copyRange ,
oBBoxFrom , wsTo ) ; cellWithFormula = newFormula . getParent ( ) ; cellWithFormula . ws = wsTo ; cellWithFormula . nRow = cell . nRow ; cellWithFormula . nCol = cell . nCol } if ( arrayFormula ) { if ( isFirstCellArray ) { dependencyFormulas . addToBuildDependencyArray ( formula ) ; if ( newFormula ) dependencyFormulas . addToBuildDependencyArray ( newFormula ) } } else dependencyFormulas . addToBuildDependencyCell ( cell ) } } ) } ; Worksheet . prototype . _moveCellsFormula = function ( cell , formula , cellWithFormula , copyRange , oBBoxFrom , wsTo ) { if ( this !== wsTo ) if ( copyRange || ! this . workbook . bUndoChanges ) { cellWithFormula =
new CCellWithFormula ( wsTo , cell . nRow , cell . nCol ) ; formula = formula . clone ( null , cellWithFormula , wsTo ) ; if ( ! copyRange ) formula . convertTo3DRefs ( oBBoxFrom ) ; formula . moveToSheet ( this , wsTo ) ; formula . setFormulaString ( formula . assemble ( true ) ) ; cell . setFormulaParsed ( formula ) } else { formula . moveToSheet ( this , wsTo ) ; formula . setFormulaString ( formula . assemble ( true ) ) } return formula } ; Worksheet . prototype . _moveRange = function ( oBBoxFrom , oBBoxTo , copyRange , wsTo ) { if ( ! wsTo ) wsTo = this ; if ( oBBoxFrom . isEqual ( oBBoxTo ) && this === wsTo ) return ; History . Create _NewPoint ( ) ;
History . StartTransaction ( ) ; this . workbook . dependencyFormulas . lockRecal ( ) ; var offset = new AscCommon . CellBase ( oBBoxTo . r1 - oBBoxFrom . r1 , oBBoxTo . c1 - oBBoxFrom . c1 ) ; var prepared = this . _moveMergedAndHyperlinksPrepare ( oBBoxFrom , oBBoxTo , copyRange , wsTo , offset ) ; this . _moveCleanRanges ( oBBoxFrom , oBBoxTo , copyRange , wsTo ) ; this . _moveFormulas ( oBBoxFrom , oBBoxTo , copyRange , wsTo , offset ) ; this . _moveCells ( oBBoxFrom , oBBoxTo , copyRange , wsTo , offset ) ; this . _moveMergedAndHyperlinks ( prepared , oBBoxFrom , oBBoxTo , copyRange , wsTo , offset ) ; if ( true ==
this . workbook . bUndoChanges || true == this . workbook . bRedoChanges ) wsTo . autoFilters . unmergeTablesAfterMove ( oBBoxTo ) ; if ( false == this . workbook . bUndoChanges && false == this . workbook . bRedoChanges ) this . autoFilters . _moveAutoFilters ( oBBoxTo , oBBoxFrom , null , copyRange , true , oBBoxFrom , wsTo ) ; this . workbook . dependencyFormulas . unlockRecal ( ) ; History . EndTransaction ( ) ; return true } ; Worksheet . prototype . _shiftCellsLeft = function ( oBBox ) { var t = this ; var nLeft = oBBox . c1 ; var nRight = oBBox . c2 ; var dif = nLeft - nRight - 1 ; var oActualRange = new Asc . Range ( nLeft ,
oBBox . r1 , gc _nMaxCol0 , oBBox . r2 ) ; var offset = new AscCommon . CellBase ( 0 , dif ) ; var renameRes = this . renameDependencyNodes ( offset , oBBox ) ; var redrawTablesArr = this . autoFilters . insertColumn ( oBBox , dif ) ; this . getRange3 ( oBBox . r1 , oBBox . c1 , oBBox . r2 , oBBox . c2 ) . _foreachNoEmpty ( function ( cell ) { t . _removeCell ( null , null , cell ) } ) ; this . _updateFormulasParents ( oActualRange . r1 , oActualRange . c1 , oActualRange . r2 , oActualRange . c2 , oBBox , offset , renameRes . shiftedShared ) ; var cellsByColLength = this . getColDataLength ( ) ; for ( var i = nRight + 1 ; i < cellsByColLength ; ++ i ) { var sheetMemoryFrom =
this . getColDataNoEmpty ( i ) ; if ( sheetMemoryFrom ) { this . getColData ( i + dif ) . copyRange ( sheetMemoryFrom , oBBox . r1 , oBBox . r1 , oBBox . r2 - oBBox . r1 + 1 ) ; sheetMemoryFrom . clear ( oBBox . r1 , oBBox . r2 + 1 ) } } this . workbook . dependencyFormulas . notifyChanged ( renameRes . changed ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _ShiftCellsLeft , this . getId ( ) , oActualRange , new UndoRedoData _BBox ( oBBox ) ) ; this . autoFilters . redrawStylesTables ( redrawTablesArr ) } ; Worksheet . prototype . _shiftCellsUp = function ( oBBox ) { var t =
this ; var nTop = oBBox . r1 ; var nBottom = oBBox . r2 ; var dif = nTop - nBottom - 1 ; var oActualRange = new Asc . Range ( oBBox . c1 , oBBox . r1 , oBBox . c2 , gc _nMaxRow0 ) ; var offset = new AscCommon . CellBase ( dif , 0 ) ; var renameRes = this . renameDependencyNodes ( offset , oBBox ) ; var redrawTablesArr = this . autoFilters . insertRows ( "delCell" , oBBox , c _oAscDeleteOptions . DeleteCellsAndShiftTop ) ; this . getRange3 ( oBBox . r1 , oBBox . c1 , oBBox . r2 , oBBox . c2 ) . _foreachNoEmpty ( function ( cell ) { t . _removeCell ( null , null , cell ) } ) ; this . _updateFormulasParents ( oActualRange . r1 ,
oActualRange . c1 , oActualRange . r2 , oActualRange . c2 , oBBox , offset , renameRes . shiftedShared ) ; for ( var i = oBBox . c1 ; i <= oBBox . c2 ; ++ i ) { var sheetMemory = this . getColDataNoEmpty ( i ) ; if ( sheetMemory ) sheetMemory . deleteRange ( nTop , - dif ) } this . workbook . dependencyFormulas . notifyChanged ( renameRes . changed ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _ShiftCellsTop , this . getId ( ) , oActualRange , new UndoRedoData _BBox ( oBBox ) ) ; this . autoFilters . redrawStylesTables ( redrawTablesArr ) } ; Worksheet . prototype . _shiftCellsRight =
function ( oBBox , displayNameFormatTable ) { var nLeft = oBBox . c1 ; var nRight = oBBox . c2 ; var dif = nRight - nLeft + 1 ; var oActualRange = new Asc . Range ( oBBox . c1 , oBBox . r1 , gc _nMaxCol0 , oBBox . r2 ) ; var offset = new AscCommon . CellBase ( 0 , dif ) ; var renameRes = this . renameDependencyNodes ( offset , oBBox ) ; var redrawTablesArr = this . autoFilters . insertColumn ( oBBox , dif , displayNameFormatTable ) ; this . _updateFormulasParents ( oActualRange . r1 , oActualRange . c1 , oActualRange . r2 , oActualRange . c2 , oBBox , offset , renameRes . shiftedShared ) ; var borders ; if ( nLeft >
0 && ! this . workbook . bUndoChanges ) borders = this . _getBordersForInsert ( oBBox , false ) ; var cellsByColLength = this . getColDataLength ( ) ; for ( var i = cellsByColLength - 1 ; i >= nLeft ; -- i ) { var sheetMemoryFrom = this . getColDataNoEmpty ( i ) ; if ( sheetMemoryFrom ) { if ( i + dif <= gc _nMaxCol0 ) this . getColData ( i + dif ) . copyRange ( sheetMemoryFrom , oBBox . r1 , oBBox . r1 , oBBox . r2 - oBBox . r1 + 1 ) ; sheetMemoryFrom . clear ( oBBox . r1 , oBBox . r2 + 1 ) } } this . nColsCount = Math . max ( this . nColsCount , this . getColDataLength ( ) ) ; if ( nLeft > 0 && ! this . workbook . bUndoChanges ) { var prevSheetMemory =
this . getColDataNoEmpty ( nLeft - 1 ) ; if ( prevSheetMemory ) { for ( var i = nLeft ; i <= nRight ; ++ i ) this . getColData ( i ) . copyRange ( prevSheetMemory , oBBox . r1 , oBBox . r1 , oBBox . r2 - oBBox . r1 + 1 ) ; this . nColsCount = Math . max ( this . nColsCount , this . getColDataLength ( ) ) ; this . getRange3 ( oBBox . r1 , oBBox . c1 , oBBox . r2 , oBBox . c2 ) . _foreachNoEmpty ( function ( cell ) { cell . clearDataKeepXf ( borders [ cell . nRow ] ) } ) } } this . workbook . dependencyFormulas . notifyChanged ( renameRes . changed ) ; History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _ShiftCellsRight ,
this . getId ( ) , oActualRange , new UndoRedoData _BBox ( oBBox ) ) ; this . autoFilters . redrawStylesTables ( redrawTablesArr ) } ; Worksheet . prototype . _shiftCellsBottom = function ( oBBox , displayNameFormatTable ) { var t = this ; var nTop = oBBox . r1 ; var nBottom = oBBox . r2 ; var dif = nBottom - nTop + 1 ; var oActualRange = new Asc . Range ( oBBox . c1 , oBBox . r1 , oBBox . c2 , gc _nMaxRow0 ) ; var offset = new AscCommon . CellBase ( dif , 0 ) ; var renameRes = this . renameDependencyNodes ( offset , oBBox ) ; var redrawTablesArr ; if ( ! this . workbook . bUndoChanges && undefined === displayNameFormatTable ) redrawTablesArr =
this . autoFilters . insertRows ( "insCell" , oBBox , c _oAscInsertOptions . InsertCellsAndShiftDown , displayNameFormatTable ) ; this . _updateFormulasParents ( oActualRange . r1 , oActualRange . c1 , oActualRange . r2 , oActualRange . c2 , oBBox , offset , renameRes . shiftedShared ) ; var borders ; if ( nTop > 0 && ! this . workbook . bUndoChanges ) borders = this . _getBordersForInsert ( oBBox , true ) ; for ( var i = oBBox . c1 ; i <= oBBox . c2 ; ++ i ) { var sheetMemory = this . getColDataNoEmpty ( i ) ; if ( sheetMemory ) { sheetMemory . insertRange ( nTop , dif ) ; t . cellsByColRowsCount = Math . max ( t . cellsByColRowsCount ,
sheetMemory . getSize ( ) ) } } this . nRowsCount = Math . max ( this . nRowsCount , this . cellsByColRowsCount ) ; if ( nTop > 0 && ! this . workbook . bUndoChanges ) { for ( var i = oBBox . c1 ; i <= oBBox . c2 ; ++ i ) { var sheetMemory = this . getColDataNoEmpty ( i ) ; if ( sheetMemory ) { sheetMemory . copyRangeByChunk ( nTop - 1 , 1 , nTop , dif ) ; t . cellsByColRowsCount = Math . max ( t . cellsByColRowsCount , sheetMemory . getSize ( ) ) } } this . nRowsCount = Math . max ( this . nRowsCount , this . cellsByColRowsCount ) ; this . getRange3 ( oBBox . r1 , oBBox . c1 , oBBox . r2 , oBBox . c2 ) . _foreachNoEmpty ( function ( cell ) { cell . clearDataKeepXf ( borders [ cell . nCol ] ) } ) } this . workbook . dependencyFormulas . notifyChanged ( renameRes . changed ) ;
History . Add ( AscCommonExcel . g _oUndoRedoWorksheet , AscCH . historyitem _Worksheet _ShiftCellsBottom , this . getId ( ) , oActualRange , new UndoRedoData _BBox ( oBBox ) ) ; if ( ! this . workbook . bUndoChanges && undefined !== displayNameFormatTable ) redrawTablesArr = this . autoFilters . insertRows ( "insCell" , oBBox , c _oAscInsertOptions . InsertCellsAndShiftDown , displayNameFormatTable ) ; if ( ! this . workbook . bUndoChanges ) this . autoFilters . redrawStylesTables ( redrawTablesArr ) } ; Worksheet . prototype . _setIndex = function ( ind ) { this . index = ind } ; Worksheet . prototype . _BuildDependencies =
function ( cellRange ) { var ca ; for ( var i in cellRange ) { if ( null === cellRange [ i ] ) { cellRange [ i ] = i ; continue } ca = g _oCellAddressUtils . getCellAddress ( i ) ; this . _getCellNoEmpty ( ca . getRow0 ( ) , ca . getCol0 ( ) , function ( c ) { if ( c ) c . _BuildDependencies ( true ) } ) } } ; Worksheet . prototype . _setHandlersTablePart = function ( ) { if ( ! this . TableParts ) return ; for ( var i = 0 ; i < this . TableParts . length ; i ++ ) this . TableParts [ i ] . setHandlers ( this . handlers ) } ; Worksheet . prototype . getTableRangeForFormula = function ( name , objectParam ) { var res = null ; if ( ! this . TableParts ||
! name ) return res ; for ( var i = 0 ; i < this . TableParts . length ; i ++ ) if ( this . TableParts [ i ] . DisplayName . toLowerCase ( ) === name . toLowerCase ( ) ) { res = this . TableParts [ i ] . getTableRangeForFormula ( objectParam ) ; break } return res } ; Worksheet . prototype . getTableIndexColumnByName = function ( tableName , columnName ) { var res = null ; if ( ! this . TableParts || ! tableName ) return res ; for ( var i = 0 ; i < this . TableParts . length ; i ++ ) if ( this . TableParts [ i ] . DisplayName . toLowerCase ( ) === tableName . toLowerCase ( ) ) { res = this . TableParts [ i ] . getTableIndexColumnByName ( columnName ) ;
break } return res } ; Worksheet . prototype . getTableNameColumnByIndex = function ( tableName , columnIndex ) { var res = null ; if ( ! this . TableParts || ! tableName ) return res ; for ( var i = 0 ; i < this . TableParts . length ; i ++ ) if ( this . TableParts [ i ] . DisplayName . toLowerCase ( ) === tableName . toLowerCase ( ) ) { res = this . TableParts [ i ] . getTableNameColumnByIndex ( columnIndex ) ; break } return res } ; Worksheet . prototype . getTableByName = function ( tableName ) { var res = null ; if ( ! this . TableParts || ! tableName ) return res ; for ( var i = 0 ; i < this . TableParts . length ; i ++ ) if ( this . TableParts [ i ] . DisplayName . toLowerCase ( ) ===
tableName . toLowerCase ( ) ) { res = this . TableParts [ i ] ; break } return res } ; Worksheet . prototype . isApplyFilterBySheet = function ( ) { var res = false ; if ( this . AutoFilter && this . AutoFilter . isApplyAutoFilter ( ) ) res = true ; if ( false === res && this . TableParts ) for ( var i = 0 ; i < this . TableParts . length ; i ++ ) if ( true === this . TableParts [ i ] . isApplyAutoFilter ( ) ) { res = true ; break } return res } ; Worksheet . prototype . getTableNames = function ( ) { var res = [ ] ; if ( this . TableParts ) for ( var i = 0 ; i < this . TableParts . length ; i ++ ) res . push ( this . TableParts [ i ] . DisplayName ) ;
return res } ; Worksheet . prototype . renameDependencyNodes = function ( offset , oBBox ) { return this . workbook . dependencyFormulas . shift ( this . Id , oBBox , offset ) } ; Worksheet . prototype . getAllCol = function ( ) { if ( null == this . oAllCol ) this . oAllCol = new AscCommonExcel . Col ( this , g _nAllColIndex ) ; return this . oAllCol } ; Worksheet . prototype . getAllRow = function ( ) { if ( null == this . oSheetFormatPr . oAllRow ) { this . oSheetFormatPr . oAllRow = new AscCommonExcel . Row ( this ) ; this . oSheetFormatPr . oAllRow . setIndex ( g _nAllRowIndex ) } return this . oSheetFormatPr . oAllRow } ;
Worksheet . prototype . getAllRowNoEmpty = function ( ) { return this . oSheetFormatPr . oAllRow } ; Worksheet . prototype . getHyperlinkByCell = function ( row , col ) { var oHyperlink = this . hyperlinkManager . getByCell ( row , col ) ; return oHyperlink ? oHyperlink . data : null } ; Worksheet . prototype . getMergedByCell = function ( row , col ) { var oMergeInfo = this . mergeManager . getByCell ( row , col ) ; return oMergeInfo ? oMergeInfo . bbox : null } ; Worksheet . prototype . getMergedByRange = function ( bbox ) { return this . mergeManager . get ( bbox ) } ; Worksheet . prototype . _expandRangeByMergedAddToOuter =