private long getFormatId ( String formatCode ) { long ret = 0L ; if ( formatCode != null && formatCode . length ( ) > 0 ) { if ( numFmts != null ) { Iterator it = numFmts . entrySet ( ) . iterator ( ) ; while ( it . hasNext ( ) && ret == 0L ) { java . util . Map . Entry entry = ( java . util . Map . Entry ) it . next ( ) ; Long id = ( Long ) entry . getKey ( ) ; String code = ( String ) entry . getValue ( ) ; if ( code != null && code . equals ( formatCode ) ) ret = id . longValue ( ) ; } } // If not found, also search // the built-in formats if ( ret == 0L ) { Long l = ( Long ) builtinNumFmts . get ( formatCode ) ; if ( l != null ) ret = l . longValue ( ) ; } // If still not found, // create a new format if ( ret == 0L ) { CTNumFmts numFmts = stylesheet . getNumFmts ( ) ; if ( numFmts == null ) { numFmts = new CTNumFmts ( ) ; stylesheet . setNumFmts ( numFmts ) ; } List list = numFmts . getNumFmt ( ) ; CTNumFmt numFmt = new CTNumFmt ( ) ; numFmt . setNumFmtId ( getMaxNumFmtId ( ) + 1 ) ; numFmt . setFormatCode ( formatCode ) ; list . add ( numFmt ) ; numFmts . setCount ( ( long ) list . size ( ) ) ; addFormatCode ( numFmt ) ; ret = numFmt . getNumFmtId ( ) ; } } return ret ; }
Returns the id for the given number format from the cache .