
    nh;                        d Z ddlZddlmZ ddlmZmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZ ddl dZeee	eeeee
eeiZdZedd Zd	Zeeeeeeeed
Zg dZd ZddZ G d d      Z  G d dee       Z!d Z"d Z# G d dee       Z$i ddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3dd4i d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYZ%ddefdd.efd0d?efdZd[efdAdOefdQdUefd\d\efd]d]efd^d_efd`daefdbdcefdddeefgZ&i Z'e&D ]  \  Z(Z)Z* e+e(e)dz         D ]  Z,e*e'e,<   	  [([)[*[,dfZ-i Z.e-e-j_                         z   D ]  Z0de.e0<   	 [0[-i Z1dgD ]  Z0de1e0<   	 ddddhZ2dddddddiZ3 ejh                  dj      jj                  Z6dk Z7efdlZ8dm Z9dn Z:do Z;dp Z<dq Z=dr Z>ds Z?dt Z@ G du dvee       ZA G dw dxee       ZB G dy dzee       ZC G d{ d|ee       ZD G d} d~e      ZEy)z$
Module for formatting information.
    N)unpack   )FDTFGEFNUFTXFUNXL_CELL_DATEXL_CELL_NUMBERXL_CELL_TEXT	XL_FORMAT
XL_FORMAT2
BaseObject	XLRDErrorfprintfunpack_stringunpack_unicodeupkbitsupkbitsL)*)8r   r   r      r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      r   r   r   r!   r   r   r   r!   r!   r!   r   r!   r   r!   r   r!   r!      r(   r(   r!   r!   r!      r+   r   r+   3   f   r   r      r0   r   r   r.   r   r.   r   r!   r!   r   r.   r0   r0   r0   r   r#   r   r   r   r%   r    r&   r   r   r0   r   r1   r0   r   r0   r   r   r+   r+   r0   r   r   r+   r0   r0   r+   r   )   r<   r<   r-   r.   r   r-   r0   r0   r+   r0   r   r   r0   r   r   r+   r   r   r.   r   r.   r.   r+      rE   rE   r   r-   r.   r-   r+   r.   r   r-   r   r-   r-   r   r+   r-   r   r,   r-   r-   r+   r-   r-   r-      )8r   r   r   r   r   r   r   r   r    r"   r#   r$   r%   r&   r'   r)   r*   r,   r/   r1   r2   r3   r4   r5   r#   r   r   r   r%   r    r&   r   r6   r1   r7   r8   r9   r:   r;   )r   r0   r+   r=   r>   r?   r@   rA   rB   rC   rD   rF   rG   rH   rI   rJ   r,   rK   rL   )P   F   2   -   (            )
Normal	RowLevel_	ColLevel_CommaCurrencyPercentz	Comma [0]zCurrency [0]	HyperlinkzFollowed Hyperlinkc                    i | _         i | _        | j                  sy t        d      D ]  }t        |   | j                   |<    t
        | j                     }t        |      }t        |      D ]  }||   | j                   |dz   <    d | j                   |dz   <   d | j                   |dz   dz   <   d | j                   d<   d | j                   d<   y )N   r   Q     )
colour_mapcolour_indexes_usedformatting_inforangeexcel_default_palette_b8default_palettebiff_versionlen)bookidpalndpals       x/var/www/html/SchoolMeal/SchoolMeal/pds_admin_SchoolMeal/Backend/venv/lib/python3.12/site-packages/excelrd/formatting.pyinitialise_colour_maprn      s    DO!D1X 95a89 4,,-DIE5\ )!%aA) "&DOOEAI%)DOOEAIM" DOOD"DOOF    c                     d}d}| j                         D ]=  \  }}|	d}t        ||      D ]  \  }}	|||	z
  ||	z
  z  z  } ||k  s3|}|}|dk(  s= n 	 |S )z
    General purpose function. Uses Euclidean distance.
    So far used only for pre-BIFF8 ``WINDOW2`` record.
    Doesn't have to be fast.
    Doesn't have to be fancy.
    i   r   )itemszipprint)
ra   rgbdebugbest_metricbest_colourxcolourxcand_rgbmetricv1v2s
             rm   nearest_colour_indexr}      s      KL'--/ 
#x( 	,FBrBw27++F	,K K"L{
 	
 ro   c                       e Zd ZdZd Zd Zy)	EqNeAttrsz
    This mixin class exists solely so that :class:`Format`, :class:`Font`, and
    :class:`XF` objects can be compared by value of their attributes.
    c                 4    | j                   |j                   k(  S N__dict__selfothers     rm   __eq__zEqNeAttrs.__eq__      }}..ro   c                 4    | j                   |j                   k7  S r   r   r   s     rm   __ne__zEqNeAttrs.__ne__  r   ro   N)__name__
__module____qualname____doc__r   r    ro   rm   r   r      s    
//ro   r   c                   L    e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZdZdZdZdZdZdZy)Fontz
    An Excel "font" contains the details of not only what is normally
    considered a font, but also several other display attributes.
    Items correspond to those in the Excel UI's Format -> Cells -> Font tab.

    .. versionadded:: 0.6.1
    r      N)r   r   r   r   boldcharacter_setcolour_index
escapementfamily
font_indexheightitalicname
struck_outunderline_type
underlinedweightoutlineshadowr   ro   rm   r   r     sp     D. M L J F J F F D J N J F G Fro   r   c                 `    | j                   sy t        d|      d   | j                  d   _        y )N<Hr   )rc   r   	font_listr   )ri   datas     rm   handle_efontr   e  s+    &,T4&8&;DNN2#ro   c           	      |   | j                   sy | j                  s| j                          t        xs | j                  dk\  }| j
                  }t        | j                        }|dk(  r8t               }d|_	        ||_
        | j                  j                  |       |dz  }t               }||_
        | j                  j                  |       |dk\  rt        d|dd       \  |_        }|_        |_        |_        |_        |_        |_        |dz  |_        |dz  dz	  |_        |dz  dz	  |_        |d	z  d
z	  |_        |dz  dz	  |_        |dz  dz	  |_        |dk\  rt5        |dd      |_	        nt7        |d| j                  d      |_	        n|dk\  rt        d|dd       \  |_        }|_        |dz  |_        |dz  dz	  |_        |dz  dz	  |_        |d	z  d
z	  |_        |dz  dz	  |_        |dz  dz	  |_        t7        |d| j                  d      |_	        ddg|j(                     |_        d|_        |j,                  |_        d|_        d|_        nt        d|dd       \  |_        }d|_        |dz  |_        |dz  dz	  |_        |dz  dz	  |_        |d	z  d
z	  |_        d|_        d|_        t7        |d| j                  d      |_	        ddg|j(                     |_        d|_        |j,                  |_        d|_        d|_        |r,|j9                  | j:                  d|j                  z  d       y y )N      z
Dummy Fontr   rP   z	<HHHHHBBBr      r^      rM          rN      lenlenrS   z<HHH   r   i  z<HHr`   z--- handle_font: font[%d] ---z-------------------headerfooter)rc   encodingderive_encodingDEBUG	verbosityrg   rh   r   r   r   r   appendr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   dumplogfile)ri   r   blahbvkfoption_flagss          rm   handle_fontr   k  s.   =='DNNa'D			BDNNAAvFa 	QAALNN!	Rx ;Qr
+		
HNHLHO! 1$*$q(Q.$q(Q.!B&1,	 2%!+8#D"Q7AF"4T]]1EAF	r17Qq	1J.,! 1$*$q(Q.$q(Q.!B&1,	 2%!+tQa@:aff%<<!'tAay!9,! 1$*$q(Q.$q(Q.	tQa@:aff%<<	LL2Q\\A( 	 	
 ro   c                   "    e Zd ZdZdZeZdZd Zy)Formatz\
    "Number format" information from a ``FORMAT`` record.

    .. versionadded:: 0.6.1
    r   r   c                 .    || _         || _        || _        y r   )
format_keytype
format_str)r   r   tyr   s       rm   __init__zFormat.__init__  s    $	$ro   N)	r   r   r   r   r   r	   r   r   r   r   ro   rm   r   r     s!     J D J%ro   r   General0r   z0.00r   z#,##0r   z#,##0.00r   z$#,##0_);($#,##0)r   z$#,##0_);[Red]($#,##0)   z$#,##0.00_);($#,##0.00)r^   z$#,##0.00_);[Red]($#,##0.00)	   z0%
   z0.00%   0.00E+00   z# ?/?r   z# ??/??r   zm/d/yy   zd-mmm-yyzd-mmm   zmmm-yy   z
h:mm AM/PM   zh:mm:ss AM/PMrU   zh:mmrT   zh:mm:ss   zm/d/yy h:mm%   z#,##0_);(#,##0)&   z#,##0_);[Red](#,##0)'   z#,##0.00_);(#,##0.00)rR   z#,##0.00_);[Red](#,##0.00))   z'_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)*   z*_($* #,##0_);_($* (#,##0);_($* "-"_);_(@_)+   z/_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_),   z2_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)rQ   zmm:ss.   z	[h]:mm:ss/   zmm:ss.0##0.0E+0@)0   1      $   r   r   rP   :   ;   >   C   rO   G   r_   ymdhsz$-+/(): )r   #?)r   r   r   GENERALgeneralr   z	\[[^]]*\]c                 z   d}d}|D ]I  }|dk(  r|dk(  rd}n*|dv rd}n#|t         v rn||z  }n|dk(  r|dk(  r
d}n|dk(  rd}d|cxk  rdk  rFJ  J  | j                  dk\  r#t        dt        |      z  | j                  	       t        d|      }|t        v ry
d}d}d}dx}}|D ]4  }|t        v r|t        |   z  }|t        v r|t        |   z  }-||k(  s3d}6 |r|sy|r|sy
|r*| j                  rt        | j                  d|||       ||kD  S |s#| j                  rt        | j                  d|       ||kD  S )Nr   r   "r   z\_*r   r   z+is_date_format_string: reduced format is %sfileF;Tz7WARNING *** is_date_format: ambiguous d=%d n=%d fmt=%r
z/WARNING *** format %r produces constant result
)
skip_char_dictr   rs   REPRr   fmt_bracketed_subnon_date_formatsdate_char_dictnum_char_dictr   )	ri   fmtstatesc	separatorgot_sep
date_count	num_counts	            rm   is_date_format_stringr  <  s    E
A A:Cxfn$QaZCxaZEEQ!" ~~;d1gEDLLY"a AEIGJ .++J-q))I)^G )>>J 	!! >>DLL"TVYZ	!!ro   c                    d}| j                   }|t        k(  rt        |d      }| j                  s| j	                          d}|dk\  rt        d|dd       d   }n| j                  }|dk  rd}| xj                  dz  c_        |dk\  rt        |d      }nt        ||| j                  d      }|xs | j                  d	k\  }|r$t        | j                  d
| j                  |||       | j                  |      }	t        t        g|	   }
|dkD  sa|dk  s\t        j!                  |t"              }|t        k(  }| j                  r-d|cxk  rdk  r"n n||	z  rd}t        | j                  d||       |dk(  rt        | j                  d|
|	|       t%        ||
|      }|r.|j'                  | j                  d| j                  dz
  fz         || j(                  |<   | j*                  j-                  |       y )Nr   rS   r   rP   r   r   rN   r   r   z)FORMAT: count=%d fmtkey=0x%04x (%d) s=%r
   zHWARNING *** Conflict between std format key %d and its format string %r
z2ty: %d; is_date_c: %r; is_date_s: %r; fmt_strg: %rz--- handle_format [%d] ---)r   )rg   r   minr   r   r   actualfmtcountr   r   r   r   r   r  r   r   std_format_code_typesgetr	   r   r   
format_mapformat_listr   )r   r   rectyper   r   strposfmtkeyunistrgr   	is_date_sr   std_ty	is_date_cfmtobjs                 rm   handle_formatr  ~  s   E			B*R[==F	Rxd1Qi(+$$8F1	Rx q)fdmmAF'DNNa'DLL8	
 **73I
sI	BSLBG '**637cM	>>a&o2o9y3HE^	 zLL@	
 FB(FDLL)EI\I\_`I`Hb)bc$DOOFF#ro   c                    | j                   sy t        xs | j                  dk\  }t        d|d d       \  }d| j                  dk\     }t        s| j                  dk\  r||k7  rt        | j                  d||       n|rt        | j                  d|       d|z  }d	|z  dz   }t        |      }d	}||cxk  r||z   k  sn t        d
||fz        t        ||d |       }	| j                  g k(  sJ t        |      D ]  }
|	|
   }|dz  }|dz	  dz  }|dz	  dz  }| j                  d|
z      }|||f}| j                  j                  |       || j                  d|
z   <   |sd||k7  sjt        d|
||fz  | j                          y )Nr   r   )rM   8   rP   r   z9NOTE *** Expected %d colours in PALETTE record, found %d
zPALETTE record with %d colours
z<xx%dir   z0PALETTE record: expected size %d, actual size %dr   r^   rM   z%2d: %r -> %rr   )rc   r   r   r   rg   r   r   rh   r   palette_recordrd   ra   r   rs   )ri   r   r   	n_coloursexpected_n_coloursr   expected_sizeactual_size	tolerancecoloursrj   r   redgreenblueold_rgbnew_rgbs                    rm   handle_paletter%    s   'DNNa'D$Ra)LY!$"3"3r"9:1$)7I*ILLH		
 
@)L
Y
C	MA%Md)KIKD=9+DD>-Q\A]]
 	
 S$~./G"$$$ 9 RAJ$ha4R4//!a%(t$""7+!(A'!oGW(==DLLQRro   c                 
   | j                   D ]  }|j                  dk(  r|j                  }|dk(  r%|| j                  v rd| j                  |<   C| j
                  sPt        dt        | j                        | j                         t        | j                  d|j                  |j                  |        | j
                  dk\  r>t        | j                  j                               }t        d|z  | j                         y y )Nr   r`   r   zSize of colour table:r   z2*** Font #%d (%r): colour index 0x%04x is unknown
z
Colour indexes used:
%r
)r   r   r   ra   rb   r   rs   rh   r   r   r   sortedkeys)ri   fontcxuseds       rm   palette_epiloguer,    s      ??a< +,D$$R(^^)3t+?dllSE		" ~~d..3356,t3$,,G ro   c           	         | j                   sy t        xs | j                  dk\  }| j                  }t	        d|d d       \  }}}|dz  }|dk(  rd| j
                  vrd}d}d}d}	d	}n|d
z  r+d}t        |   }	d|cxk  rdk  rdn na|	t        |dz         z  }	nOd}d}d}|dk\  r	 t        |dd      }	nt        |d| j                  d      }	|r|	st        d| j                         ||f| j
                  |	<   |rt        | j                  d|||||	       y y # t        $ rD t        d||||fz  | j                         t        dt        |dd        | j                          w xY w)Nr   z<HBBr     s       rV   r   r   r   i   rN   r   z6STYLE: built_in=%d xf_index=%d built_in_id=%d level=%dr   z
raw bytes:z7WARNING *** A user-defined style has a zero-length namez?STYLE: built_in=%d xf_index=%d built_in_id=%d level=%d name=%r
)rc   r   r   rg   r   style_name_mapbuilt_in_style_namesstrr   UnicodeDecodeErrorrs   r   reprr   r   r   )
ri   r   r   r   flag_and_xfxbuilt_in_idlevelxf_indexbuilt_inr   s
             rm   handle_styler9    s   'DNNa'D			B'-fd2Ah'?$L+uf$H{xt/B/BB 		#K0 q C	N"D 8	%dAa8 !q$--BDKRVR^R^_!)8 4DLLN	
  & L;>?
 lDabNFs   #D AE#c                 `   t        |j                  j                               }|D ]  \  }}t        |d      rt	        | ||        |j                  d      dk\  s5|| j                  v rd| j                  |<   S|j                  j                  }t        d||||fz  | j                          y )Nr   r   r   r   z&*** xf #%d : %s.%s =  0x%04x (unknown)r   )r'  r   rq   hasattrcheck_colour_indexes_in_objfindra   rb   	__class__r   rs   r   )ri   obj
orig_indexalistattrnobjonames          rm   r<  r<  8  s    3<<%%'(E 
d4 'dJ?YY~&!+t&12((.MM**E8JtUY;ZZ\\ro   c                     t         j                         D ]K  }|| j                  vst         |   }t        j	                  |      }t        |||      }|| j                  |<   M y r   )r
  r(  r  std_format_stringsr  r   )ri   xr   fmt_strr  s        rm   fill_in_standard_formatsrI  H  s^    "'') (DOO#&q)B ),,Q/GAr7+F!'DOOA(ro   c                 X   t         xs | j                  dk\  }| j                  }t               }t	               |_        d|j
                  _        d|j
                  _        d|j
                  _        t               |_
        d|j                  _        d|j                  _        d|j                  _        d|j                  _        t               |_        t#               |_        |dk\  r| j&                  st)        |        |dk\  rd}t+        ||dd       \
  |_        |_        }}|j
                  _        }}	}
}}t3        |j$                  |d       t3        ||d       t3        |j
                  |d	       t3        |j
                  |d
       |	dz	  }g d}|D ]  }d|z   dz   }t5        |||dz         |dz  }! t7        |j                  |
d       t3        |j                  |d       t7        |j                   |d       t3        |j                   |d       n|dk\  rd}t+        ||dd       \  |_        |_        }}}}
}t3        |j$                  |d       t3        ||d       t3        |j
                  |d	       |dz  }g d|   |j
                  _        |dz	  }g d}|D ]  }d|z   dz   }t5        |||dz         |dz  }! t7        |j                   |
d       t7        |j                  |
d       t3        |j                  |d       n|dk\  rd}t+        ||dd       \  |_        |_        }}}	}}t3        |j$                  |d       t3        ||d       t3        |j
                  |d       |dz  dz	  }g d|   |j
                  _        |	dz	  }g d}|D ]  }d|z   dz   }t5        |||dz         |dz  }! t3        |j                   |d        t7        |j                  |d!       n|d"k(  rd#}t+        ||dd       \  |_        |_        }}	}}}t3        |j$                  |d       t3        ||d$       t3        |j
                  |d%       t3        ||d&       |	dz	  }g d}|D ]  }d|z   dz   }t5        |||dz         |dz  }! t3        |j                   |d        t7        |j                  |d!       d|j
                  _        d|j
                  _        n'|d'k(  rt+        d(|      \  |_        }}|d)z  |_        t3        |j$                  |d*       t3        |j
                  |d+       d,D ]I  \  }}||z  rd-\  }}nd.\  }}t5        |j                  |d/z   |       t5        |j                  |d0z   |       K |j                   }|d1z  rd2|_        nd|_        d3|_        d4|_        d|_         d|j
                  _        d|j
                  _        g d}|D ]  }d|z   dz   }t5        ||d        ntC        d5|z        tE        | jF                        |_$        | jF                  jK                  |       | xj&                  dz  c_        |r+|jM                  | jN                  d6|jH                  z  d78       	 | jP                  |j.                     }tR        |jT                     } | | jZ                  |jH                  <   | j\                  rl| j                  rI|j^                  r=|j@                  d9k7  r.d:}!ta        | jN                  |!|jH                  |j@                         tc        | ||jH                         |j.                  | jP                  vrMd;}!| j                  r7ta        | jN                  |!|jH                  |j.                  |j.                         d|_        y y # tV        $ r
 tX        } Y 	w xY w)<Nr   r   rP   rN   z<HHHBBBBIiHrU   ))r   r   cell_locked)r   r   formula_hidden)r   r   is_styler   r^   lotus_123_prefixr   i  parent_style_index)r   r   	hor_alignr   r^   text_wrapped)r   p   
vert_align))r   r   indent_level)r   rM   shrink_to_fit)r   r(   text_directionr   )formatr)  	alignmentborder
background
protection__flagr   ))r   r   left_line_style)r      right_line_style)r^   i   top_line_style)r   i   bottom_line_stylerM   i   left_colour_index   i  ?right_colour_index)rS   i   @	diag_down)   l        diag_up))r      top_colour_index)r   ?  bottom_colour_index)r   i  diag_colour_index)rT   i  diag_line_style))   l      x fill_pattern)r   rp  pattern_colour_indexr   rr  background_colour_indexz<HHHBBIirM   )r   r   Z      )rx  rz  )rM   i  ? rw  ))r   i  rg  )   l      | rs  )r   r   rf  )r   r  rc  )r   i  re  )r   i   rq  rh  rj  rR   z<BBHBBHIr   )rS  rU  )r   r   rX  r(   r   ))r   ?   rw  )r   i  ry  )r      r{  )r  )r      rq  )r^   i   rc  )r   r  ri  )rM   i   rg  )r   i   rs  )   i   re  )r   l      p rl  rS   z<BBBBHHI)rM  rO  )rS  rU  )rQ  rT   z<BxBBr  ))r   @   rK  )r   r!   rL  )rS  ))r^   left)rM   right)r   top)r  bottom)r^   r   )r   r   _colour_index_line_styler!   r   r   r^   zprogrammer stuff-up: bv=%dz--- handle_xf: xf[%d] --- r   r.  zNWARNING *** XF[%d] is a style XF but parent_style_index is 0x%04x, not 0x0fff
z9WARNING *** XF[%d] unknown (raw) format key (%d, 0x%04x)
)2r   r   rg   XFXFAlignmentr]  rY  rZ  r[  XFBorderr^  ro  rm  rt  ru  XFBackgroundr_  XFProtectionr`  xfcountrI  r   r   r   rotationr   setattrr   rX  rw  r{  ry  rR  r   rh   xf_listr7  r   r   r   r  _cellty_from_fmttyr   KeyErrorr   _xf_index_to_xl_type_maprc   rN  r   r<  )"r   r   r   r   xf
unpack_fmtpkd_type_par
pkd_align1
pkd_align2pkd_usedpkd_brdbkg1pkd_brdbkg2pkd_brdbkg3reg
attr_stems	attr_stemrB  pkd_orient_usedorientationpkd_align_orient
pkd_bkg_34
pkd_brd_34pkd_type_protpkd_align_par
format_etc
halign_etcmasksider   
line_stylebgr   celltymsgs"                                     rm   	handle_xfr  T  s    'DNNa'D			B	B=BL !BLL!"BLL"#BLL
BIBIIBII"#BII !BII NBM NBM	Rx &	Rx"
 :tAbz*	
MMLL!MM	
 		
 	LL	
 	LL	
 !m

 $ 	I?W,DBcAg&AIC	 	II		
 	II		
 	-PQMM	
 
r
 :tAbz*	
MMMM	
 		
 	LL	
 &, 1+ >"

 $ 	I?W,DBcAg&AIC	 	MM	
 	II	
 	II	
 
r
 :tAbz*	
MMMM	
 		
 	LL	
 ($.14 1+ >!m

 $ 	I?W,DBcAg&AIC	 	MM	
 	II		
 
r
 :tAbz*	
MMMM	
 		
 	LL	
 	M#GH!m

 $ 	I?W,DBcAg&AIC	 	MM	
 	II		
 #$ !	r
 39$2G/
J"T)MM	
 	j*CD\ 	AJD$D +/(j+/(jBIIto5|DBIItm3Z@	A ]] BOBO%&""# !"# !

 $ 	!I?W,DBa 	! 4r9::dll#BKLLLLAL
LL.< 	 	

 oobmm,#CHH- 28D!!"++. >>bkkb.C.Cv.McCDLL#r{{B4I4IJ#D"bkk:	}}DOO+J>>DLL#r{{BMM2==Q	 ,    s   3,^ ^)(^)c                 L   d| _         t        | j                        }t        xs | j                  dk\  }t        xs | j                  dk\  }|rt        | j                  d       d }t        |      D ]  }| j                  |   }	 | j                  |j                     }t        |j                     }|| j                  |j                  <   | j                   sf|j"                  rsd|j$                  cxk  r|k  sBn |r7t        | j                  d|j                  |j"                  |j$                         d|_        | j&                  dk\  s|r|j$                  |j                  k(  r-t        | j                  d|j                  |j$                         nO| j                  |j$                     j"                  s,t        | j                  d	|j                  |j$                         |rE|j$                  |j                  kD  r,t        | j                  d
|j                  |j$                         | j                  |j$                     }	|j(                  s|	j(                  s|r || ||	d       |j*                  s|	j*                  s|r || ||	d       |j,                  s|	j,                  s|r || ||	d       |j.                  s|	j.                  s|r || ||	d       |j0                  s|	j0                  s|r|j                  |	j                  k7  rt        | j                  d|j                  |j                  |	j                  |	j                  | j                  |j                     j2                  | j                  |	j                     j2                         |j4                  r,|	j4                  r:|s>|j6                  |	j6                  k7  sYt        | j                  d|j                  |j6                  |	j                  |	j6                          y # t        $ r
 t        }Y qw xY w)Nr   r   zxf_epilogue called ...
c                     t        ||      t        ||      k7  r.t        | j                  d|j                  |j                  |       y y )Nz(NOTE !!! XF[%d] parent[%d] %s different
)getattrr   r   r7  )book_argxf_arg
parent_argrB  s       rm   
check_samezxf_epilogue.<locals>.check_same  sD    64 GJ$==  ;## >ro   r   z:WARNING *** XF[%d]: is_style=%d but parent_style_index=%d
rS   z/NOTE !!! XF[%d]: parent_style_index is also %d
z>NOTE !!! XF[%d]: parent_style_index is %d; style flag not set
z9NOTE !!! XF[%d]: parent_style_index is %d; out of order?
r]  r_  r^  r`  z4NOTE !!! XF[%d] fmtk=%d, parent[%d] fmtk=%r
%r / %r
z.NOTE !!! XF[%d] fontx=%d, parent[%d] fontx=%r
)_xf_epilogue_donerh   r  r   r   r   r   rd   r  r   r  r   r  r   r  r7  rc   rN  rR  rg   _alignment_flag_background_flag_border_flag_protection_flag_format_flagr   
_font_flagr   )
r   num_xfsr   blah1r  xfxr  r   r  parents
             rm   xf_epiloguer    sV   D$,,G'DNNa'D(T^^q(E89	 W~ R\\#	"//"--0C'1F 6<%%bkk2##;;R**4W4LLQKKKK)) %&B!"((BKK7J--	 b&;&;<EEY--	 ..<LLPKK))	 \\""7"78F%%f.D.DtR=&&v/F/FtR>??6+>+>tR:&&v/F/FtR>??6+>+>R]]f.?.??P))6AA(9(9:EE	 ==):):R]]f.?.??I))WR  	"!F	"s   ,PP#"P#c           	          t        |        d| _        t        t        t        t
        t        t        t        t        t        f	}|D ]#  }t        | j                  |j                  |       % y )Nr   )rn   r  r   r   r  r  r%  r,  r9  r  r  r  r>  r   )ri   methodsmethods      rm   initialise_bookr  f  sY    $D
G  989ro   c                   @    e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZdZdZdZy)r  ao  
    A collection of the border-related attributes of an ``XF`` record.
    Items correspond to those in the Excel UI's Format -> Cells -> Border tab.

    An explanations of "colour index" is given in :ref:`palette`.

    There are five line style attributes; possible values and the
    associated meanings are::

      0 = No line,
      1 = Thin,
      2 = Medium,
      3 = Dashed,
      4 = Dotted,
      5 = Thick,
      6 = Double,
      7 = Hair,
      8 = Medium dashed,
      9 = Thin dash-dotted,
      10 = Medium dash-dotted,
      11 = Thin dash-dot-dotted,
      12 = Medium dash-dot-dotted,
      13 = Slanted medium dash-dotted.

    The line styles 8 to 13 appear in BIFF8 files (Excel 97 and later) only.
    For pictures of the line styles, refer to OOo docs s3.10 (p22)
    "Line Styles for Cell Borders (BIFF3-BIFF8)".</p>

    .. versionadded:: 0.6.1
    r   N)r   r   r   r   rq  rs  ri  rl  rt  rf  rg  rc  re  ru  rm  ro  r   ro   rm   r  r  x  sa    @     N  O  O I Gro   r  c                       e Zd ZdZdZdZdZy)r  a  
    A collection of the background-related attributes of an ``XF`` record.
    Items correspond to those in the Excel UI's Format -> Cells -> Patterns tab.

    An explanations of "colour index" is given in :ref:`palette`.

    .. versionadded:: 0.6.1
    r   N)r   r   r   r   rw  r{  ry  r   ro   rm   r  r    s     L   ro   r  c                   ,    e Zd ZdZdZdZdZdZdZdZ	dZ
y)r  z
    A collection of the alignment and similar attributes of an ``XF`` record.
    Items correspond to those in the Excel UI's Format -> Cells -> Alignment tab.

    .. versionadded:: 0.6.1
    r   N)r   r   r   r   rT  rX  r  rV  rY  rZ  r[  r   ro   rm   r  r    s8     I J H L L M Nro   r  c                       e Zd ZdZdZdZy)r  ad  
    A collection of the protection-related attributes of an ``XF`` record.
    Items correspond to those in the Excel UI's Format -> Cells -> Protection tab.
    Note the OOo docs include the "cell or style" bit in this bundle of
    attributes. This is incorrect; the bit is used in determining which bundles
    to use.

    .. versionadded:: 0.6.1
    r   N)r   r   r   r   rK  rL  r   ro   rm   r  r    s     K Nro   r  c                   L    e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZdZdZdZdZdZdZy)r  a  
    eXtended Formatting information for cells, rows, columns and styles.

    Each of the 6 flags below describes the validity of
    a specific group of attributes.

    In cell XFs:

    - ``flag==0`` means the attributes of the parent style ``XF`` are
      used, (but only if the attributes are valid there);

    - ``flag==1`` means the attributes of this ``XF`` are used.

    In style XFs:

    - ``flag==0`` means the attribute setting is valid;
    - ``flag==1`` means the attribute should be ignored.

    .. note::
      the API provides both "raw" XFs and "computed" XFs. In the latter case,
      cell XFs have had the above inheritance mechanism applied.

    .. versionadded:: 0.6.1
    r   N)r   r   r   r   rN  rR  r  r  r  r  r  r  r7  r   r   r`  r_  r]  r^  r   ro   rm   r  r    sq    4 H
  L J O L  H J J J J I Fro   r  )r   )Fr   restructr   biffhr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   timemachiner   r  excel_default_palette_b5excel_default_palette_b2re   rf   r0  rn   r}   r   r   r   r   r   rF  fmt_code_rangesr
  lohir   rd   rG  
date_charsr   upper_cr   r   r   compilesubr   r  r  r%  r,  r9  r<  rI  r  r  r  r  r  r  r  r  r   ro   rm   <module>r     s  
 
     &  	
  9 v 4CR8 9 x 	!       	* #08
/ 
/V:y Vr<J
`%Z %<( 	)	(
 	#( 	&( 	'( 	*( 	
( 	
"( 	
#( 	
(( 	$( 	'( 	*(  	'!(" 	)#($ 	(%(& 	*'(( 	')(* 	(+(, 	,-(. 	//(0 	&1(2 	)3(4 	-5(6 	
7(8 	
 9(: 	
!;(< 	
&=(> 	
3?(@ 	
6A(B 	
;C(D 	
>E(F 	'G(H 	+I(J 	)K(L 
O( Z 3KCLSMSMSMSMSMSMSMSMSMSM$  ! &JBB2rAv &#%a && B

z'')
) BN2

 BN2 
	
	
 	
  BJJ|,00 ?"D '0 ;$B&RRH43
l 	(fRfR9$Az9 AH:y ( *i  F:y (N Nro   