
    	h                         S SK r S SKJr  S SKJrJr  S SKJr  S SKJ	r	  SSK
Jr   " S S	\5      r " S
 S\5      r " S S\5      rg)    N)Serialisable)IntegerSequence)
MergedCell)Border   )	CellRangec                   T   ^  \ rS rSrSr\R                  rSr SU 4S jjr	S r
SrU =r$ )	MergeCell   	mergeCell)refc                 $   > [         TU ]  U5        g N)super__init__)selfr   	__class__s     J/var/www/html/env/lib/python3.13/site-packages/openpyxl/worksheet/merge.pyr   MergeCell.__init__   s     	    c                 8    U R                  U R                  5      $ r   )r   r   r   s    r   __copy__MergeCell.__copy__   s    ~~dhh''r    r   )__name__
__module____qualname____firstlineno__tagnamer	   coordr   	__attrs__r   r   __static_attributes____classcell__r   s   @r   r   r      s*    G
//CI ( (r   r   c                   V    \ rS rSrSr\" SS9r\" \S9r	Sr
Sr  SS	 jr\S
 5       rSrg)
MergeCells#   
mergeCellsT)
allow_none)expected_typer   )countNc                     X l         g r   r-   )r   r.   r   s      r   r   MergeCells.__init__-   s	     #r   c                 ,    [        U R                  5      $ r   )lenr   r   s    r   r.   MergeCells.count4   s    4>>""r   )Nr   )r   r   r   r    r!   r   r.   r   r   r   __elements__r#   r   propertyr$   r   r   r   r(   r(   #   sF    Gt$Ey3I!LI # # #r   r(   c                   D   ^  \ rS rSrSrU 4S jrS rS rS rS r	Sr
U =r$ )	MergedCellRange9   z
MergedCellRange stores the border information of a merged cell in the top
left cell of the merged cell.
The remaining cells in the merged cell are stored as MergedCell objects and
get their border information from the upper left cell.
c                 Z   > Xl         [        TU ]	  US9  S U l        U R	                  5         g )N)range_string)wsr   r   
start_cell_get_borders)r   	worksheetr"   r   s      r   r   MergedCellRange.__init__B   s+    e,r   c                     U R                   R                  R                  U R                  U R                  45      U l        U R
                  c3  U R                   R                  U R                  U R                  S9U l        U R                   R                  R                  U R                  U R                  45      nUbP  U R
                  =R                  [        UR                  R                  UR                  R                  S9-  sl	        gg)z
If the upper left cell of the merged cell does not yet exist, it is
created.
The upper left cell gets the border information of the bottom and right
border from the bottom right cell of the merged cell, if available.
Nrowcolumn)rightbottom)r;   _cellsgetmin_rowmin_colr<   cellmax_rowmax_colborderr   rD   rE   )r   end_cells     r   r=   MergedCellRange._get_bordersI   s     ''..,,dllDLL-IJ??""ggllt||DLLlQDO 77>>%%t||T\\&BCOO""f8??3H3H4<OO4J4J'L L"  r   c                    / SQnU H  n[        U R                  R                  U5      nU(       a  UR                  c  M9  [	        S0 X#0D6n[        X5       H  nU R
                  R                  R                  U5      nUcF  Uu  px[        U R
                  XxS9nX`R
                  R                  UR                  UR                  4'   U=R                  U-  sl        M     M     U R                  R                  SLn	U	(       a*  [        R                  " U R                  R                  5      n
U R                   H  nU R
                  R                  R                  U5      nUcF  Uu  px[        U R
                  XxS9nX`R
                  R                  UR                  UR                  4'   U	(       d  Mz  W
Ul        M     g)a  
Each cell of the merged cell is created as MergedCell if it does not
already exist.

The MergedCells at the edge of the merged cell gets its borders from
the upper left cell.

 - The top MergedCells get the top border from the top left cell.
 - The bottom MergedCells get the bottom border from the top left cell.
 - The left MergedCells get the left border from the top left cell.
 - The right MergedCells get the right border from the top left cell.
)topleftrD   rE   NrA   r   )getattrr<   rM   styler   r;   rF   rG   r   rB   rC   
protectioncopycells)r   namesnamesiderM   r"   rJ   rB   col	protectedrU   s              r   formatMergedCellRange.format]   sQ    3D4??1148D

**tk*F ,ww~~))%0<$HC%dgg3CD>BGGNNDHHdkk#:;v% -  OO..d:	4??#=#=>JZZE77>>%%e,D| !$''s?:>$++67y",  r   c                 2    U[        U R                  5      ;   $ r   )r	   r"   )r   r"   s     r   __contains__MergedCellRange.__contains__   s    	$**---r   c                 N    U R                  U R                  U R                  5      $ r   )r   r;   r"   r   s    r   r   MergedCellRange.__copy__   s    ~~dggtzz22r   )r<   r;   )r   r   r   r    __doc__r   r=   r]   r`   r   r$   r%   r&   s   @r   r7   r7   9   s(    L((-V.3 3r   r7   )rV   !openpyxl.descriptors.serialisabler   openpyxl.descriptorsr   r   openpyxl.cell.cellr   openpyxl.styles.bordersr   
cell_ranger	   r   r(   r7   r   r   r   <module>rj      sC     :
 * * !(	 ($# #,T3i T3r   