
    (ph                         S r SSKJr  SSKJr  SSKJrJr  SSKJrJ	r	J
r
  SSKJrJr   " S S\5      r " S	 S
\5      rg)z
RichText definition
    )copy)NUMERIC_TYPES)
InlineFontText)StrictStringTyped)Element
whitespacec                   P    \ rS rSrSr\" \S9r\" 5       r	S r
S rS rS rS rS	rg
)	TextBlock   zmRepresents text string in a specific format

This class is used as part of constructing a rich text strings.
)expected_typec                     Xl         X l        g Nfonttext)selfr   r   s      J/var/www/html/venv/lib/python3.13/site-packages/openpyxl/cell/rich_text.py__init__TextBlock.__init__   s    		    c                 t    U R                   UR                   :H  =(       a    U R                  UR                  :H  $ r   )r   r   )r   others     r   __eq__TextBlock.__eq__   s'    yyEJJ&B499

+BBr   c                     U R                   $ )zJust retun the text)r   r   s    r   __str__TextBlock.__str__"   s    yyr   c                     U R                   [        5       :g  =(       a    U R                   =(       d    SnU R                  R                   SU R                   SU 3$ )Ndefaultz text=z, font=)r   r   	__class____name__r   )r   r   s     r   __repr__TextBlock.__repr__'   sF    yyJL(6TYYC)..))*&74&IIr   c                     [        S5      nUR                  U R                  R                  SS95        [        S5      nU R                  Ul        [        U5        UR                  U5        U$ )NrrPr)tagnamet)r
   appendr   to_treer   r   )r   elr,   s      r   r.   TextBlock.to_tree,   sT    S\
		$))##E#23CL1
		!	r   r   N)r%   
__module____qualname____firstlineno____doc__r	   r   r   r   r   r   r   r    r&   r.   __static_attributes__ r   r   r   r      s5     z*D8D
C
J
r   r   c                      ^  \ rS rSrSrU 4S jr\S 5       r\S 5       r\S 5       r	U 4S jr
U 4S jrS	 rU 4S
 jrU 4S jrU 4S jrS rS rS rS rSrU =r$ )CellRichText<   a  Represents a rich text string.

Initialize with a list made of pure strings or :class:`TextBlock` elements
Can index object to access or modify individual rich text elements
it also supports the + and += operators between rich text strings
There are no user methods for this class

operations which modify the string will generally call an optimization pass afterwards,
that merges text blocks with identical formats, consecutive pure text strings,
and remove empty strings and empty text blocks
c                 
  > [        U5      S:X  aO  US   n[        U[        [        45      (       a  [        R                  U5        O.[        R                  U5        U/nO[        R                  U5        [        TU ]!  U5        g )N   r   )	len
isinstancelisttupler8   _check_rich_text_check_elementsuperr   )r   argsr$   s     r   r   CellRichText.__init__I   sf    t9>7D$u..--d3++D1v))$/r   c                 `    [        U[        [        [        45      (       d  [	        SU 35      eg )NzIllegal CellRichText element )r=   strr   r   	TypeError)clsvalues     r   rA   CellRichText._check_elementV   s/    %#y-!@AA;E7CDD Br   c                 @    U H  n[         R                  U5        M     g r   )r8   rA   )rH   	rich_textr,   s      r   r@   CellRichText._check_rich_text\   s    A''* r   c                    [         R                  " U5      nUR                  (       a  UR                  R                  SS5      4$ / nUR                   H{  nSnUR                  (       a  UR                  R                  SS5      nUR
                  (       a'  UR                  [        UR
                  U5      5        Mj  UR                  U5        M}     U " U5      $ )Nx005F_ )r   	from_treer,   replacer)   r*   r-   r   )rH   noder   sr)   r,   s         r   rQ   CellRichText.from_treea   s    ~~d#66FFNN8R022AAssCCKK"-uu155!,-  1vr   c                   > S n[        [        5       5      nU  H  n[        U[        5      (       a
  U(       d  M!  OUR                  (       d  M5  [        U5      [        U5      :X  aV  [        U[        5      (       a  X-  nMh  UR                  UR                  :X  a!  U=R                  UR                  -  sl        M  U(       a  UR                  U5        UnM     U(       a  UR                  U5        [        TU ]%  [        S 5      U5        U $ r   )r8   r?   r=   rF   r   typer   r-   rB   __setitem__slice)r   last_tlr,   r$   s       r   _optCellRichText._opts   s    !A!S!! VVF|tAw&a%%KF[[AFF*KK166)K F   HHVE$K+r   c                    > [         R                  U5        [        TU ]  [	        U5       Vs/ s H  n[        U5      PM     sn5        U R                  5       $ s  snf r   )r8   r@   rB   __iadd__r>   r   r\   )r   arger$   s      r   r_   CellRichText.__iadd__   sF    %%c*4959a$q'956yy{ 6s   Ac                     [        [        U 5      [        U5      -    Vs/ s H  n[        U5      PM     sn5      R                  5       $ s  snf r   )r8   r>   r   r\   )r   r`   ra   s      r   __add__CellRichText.__add__   s;    d4j49.DE.DT!W.DEFKKMMEs   A	c                 n   > [         R                  U5        [        TU ]  X5        U R	                  5         g r   )r8   rA   rB   rX   r\   )r   indxvalr$   s      r   rX   CellRichText.__setitem__   s'    ##C(D&		r   c                 N   > [         R                  U5        [        TU ]  U5        g r   )r8   rA   rB   r-   r   r`   r$   s     r   r-   CellRichText.append   s    ##C(sr   c                 N   > [         R                  U5        [        TU ]  U5        g r   )r8   r@   rB   extendrk   s     r   rn   CellRichText.extend   s    %%c*sr   c                 P    SR                  SR                  S U  5       5      5      $ )NzCellRichText([{}])z, c              3   8   #    U  H  n[        U5      v   M     g 7fr   )repr).0rT   s     r   	<genexpr>(CellRichText.__repr__.<locals>.<genexpr>   s     5Lt!d1ggts   )formatjoinr   s    r   r&   CellRichText.__repr__   s"    #**4995Lt5L+MNNr   c                 b    SR                  U  Vs/ s H  n[        U5      PM     sn5      $ s  snf )NrP   )rw   rF   r   rT   s     r   r    CellRichText.__str__   s'    ww-1A-..-s   ,c                 D    U  Vs/ s H  n[        U5      PM     sn$ s  snf )z^
Returns a list of the strings contained.
The main reason for this is to make editing easier.
)rF   rz   s     r   as_listCellRichText.as_list   s     
 !%%1A%%%s   c                 ,   [        S5      nU  H  n[        U[        5      (       a!  UR                  UR	                  5       5        M9  [        S5      n[        S5      nX$l        [        U5        UR                  U5        UR                  U5        M     U$ )z$
Return the full XML representation
isr)   r,   )r
   r=   r   r-   r.   r   r   )r   	containerobjr/   r,   s        r   r.   CellRichText.to_tree   sy     DM	C#y))  / S\CL1		!  $  r   r6   )r%   r1   r2   r3   r4   r   classmethodrA   r@   rQ   r\   r_   rd   rX   r-   rn   r&   r    r}   r.   r5   __classcell__)r$   s   @r   r8   r8   <   s    

 E E
 + +  "4N

O/& r   r8   N)r4   r   openpyxl.compatr   openpyxl.cell.textr   r   openpyxl.descriptorsr   r   r	   openpyxl.xml.functionsr
   r   r   r>   r8   r6   r   r   <module>r      s?     ) /  7" "VM4 Mr   