
    f j2                        d Z dZd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 ddlmZ ddlmZ d Zd	 Zd
 Zd Z G d de          Z G d de          Zedk    rsddlZd Zd Zd ZddlmZmZ  e            Z e d         Z! ede!          Z"de"_#        dde"dddfdde"dddfdde d          dd!d"ffD ]\  Z$Z%Z&Z'Z(Z)e)r ee$e&e%e'e(           dS dS )#)XPreformattedPythonPreformattedz3.5.20z:A 'rich preformatted text' widget allowing internal markup    )	PyFontify)	Paragraph_handleBulletWidth	ParaLines_getFragWordsstringWidthgetAscentDescent	imgVRangeimgNormV)isSeq)	_dedenterc                     g }g }| d d          }|g k    r|d         }|j         }|d= |                    d          }|dk    r||dz   d          }|                    |                    |d |                              |                    |           g }|dk    r*|                    d|                    |                     n|                    |           |g k    |g k    r|                    |           |S )Nr   
   text )r   findappendcloneinsert)fragslinesclineWwtitlefts           tC:\Users\Terasoftware\OneDrive\Desktop\faahhh\fyndo\fyndo\venv\Lib\site-packages\reportlab/platypus/xpreformatted.py_getFragLinesr#      s   EEaaaA
r' aDFaDFF4LLa4 	acddGELLae,,---LLEby 01777..///LLOOO r'  by UL    c                     |                                  }dD ]"}t          ||          rt          ||           #| j        ||         |_        |gS )N)r   r   )r   hasattrdelattrr   )blParastartstopfas        r"   _split_blParar-   &   sR    A & &1Q<<%1l5:&AG3Jr$   c                 ,    |                      d          S )N )countr   s    r"   _countSpacesr1   .   s    ::c??r$   c                 P   g }d}d}| D ]}|j         dd         }|                    ||f           t          |dd          }|r(t          |dd          }t          |d          r||_        |t          ||j        |j                  z  }||                    d          z  }|||fS )z given a fragment list return a list of lists
        [size, spaces, (f00,w00), ..., (f0n,w0n)]
        each pair f,w represents a style and some string
    r   NcbDefnwidthnormalizedValuer/   )	r   r   getattrr&   _normalizerr
   fontNamefontSizer0   )	r   maxWidthr   nsr+   r   cb_ws	            r"   _getFragWordr?   8   s    
 	A	A	A  vaaay	!DQx%% 	*GA&&Br+,, *!)	[qz1:666 	
TZZ__ a7Nr$   c                   &    e Zd ZddZd ZeZd ZdS )r   Nr   r   c                 P    || _         |fd}|                     |||||           d S )Nc                 L    d                     t          | pd|                    S )Nr   r   )joinr   )r   dedents     r"   <lambda>z(XPreformatted.__init__.<locals>.<lambda>T   s     dii	$*"V8T8T.U.U r$   )caseSensitive_setup)selfr   style
bulletTextr   rF   rD   cleaners           r"   __init__zXPreformatted.__init__R   s8    *&,UUUD%UG<<<<<r$   c                    d| _         t          |          s|g}n|}g }d}||         }| j        }t          |j                  }d}t          | j        ||           d| _        t          | dt          |dd                    }	|	dv}
| j	        }t          |          }|dk    rl|d         }t          |d          r|j        }|j        }t          ||          \  }}d}|j                            d          }|D ]}t!          |||          }|| j         k    r|| _         t#          ||          }||z
  }|                    ||                    d          |f           |dz   }|t          |          k     r||         p|d	         }|                    |||||
          }nP|j        }|j        }|D ](}|dk    r	|d         }n|j        }t#          ||          })|                    ||          }t#          | j        |          | _        |S |dk    r2t1          d|j        |j        |j        |j        d|j        z  g           S t5          |          D ]}t7          ||          \  }}}|d         d         }|j        }t          |j        |          \  }}|                                g}|d         d         |d	         _        |dd         D ]}|d                                         }|d         |_        |                    |           |j        }|j        }|
rct          |dd          }t          |dd          r-t9          t;          |j        |          |j        |          \  }}n't          ||          \  }}nt          ||          \  }}t#          ||          }t#          ||          }t?          ||          }|dz  }|t          |          k     r||         p|d	         }t#          ||          }||z
  }|| j         k    r|| _         |                    t1          |||||||d                     t#          | j        |          | _        t1          d|          S )a/  
        Returns a broken line structure. There are two cases

        A) For the simple case of a single formatting input fragment the output is
            A fragment specifier with
                - kind = 0
                - fontName, fontSize, leading, textColor
                - lines=  A list of lines
                
                    Each line has two items:
                    
                    1. unused width in points
                    2. a list of words

        B) When there is more than one input formatting fragment the out put is
            A fragment specifier with
                - kind = 1
                - lines =  A list of fragments each having fields:
                
                    - extraspace (needed for justified)
                    - fontSize
                    - words=word list
                    - each word is itself a fragment with
                    - various settings

        This structure can be used to easily draw paragraphs with the various alignments.
        You can supply either a single width or a list of widths; the latter will have its
        last item repeated until necessary. A 2-element list is useful when there is a
        different first line indent; a longer list could be created to facilitate custom wraps
        around irregular objects.r   autoLeadingr   )r   offr   r   r   r/   )kindr   ascentdescentr9      )rQ   r   gɿ)rQ   r9   r8   	textColorrR   rS   r   Nr3   r4   T)
extraSpace	wordCountwordsr9   rR   rS   currentWidthpreformatted) 
_width_maxr   rI   floatr9   r   rJ   heightr6   r   lenr&   r8   r   r   splitr
   maxr   r   rQ   r   rY   r4   r   rU   r#   r?   r   r   valignmin) rH   r4   	maxWidthsr   linenor:   rI   	fFontSizerequiredWidthrN   
calcBoundsr   nFragsr+   r9   r8   rR   rS   rQ   LlrY   rV   r(   r;   r   maxSize	maxAscent
minDescentrX   r    r3   s                                    r"   
breakLineszXPreformatted.breakLinesW   s   @ U|| 	 %YYiV$
%.))	 	4?5;;;d=}R1P1PQQ 
2

E

19 D	2aAq   9::"28H"E"E&,,t$$ \ \A#.q(#C#CL#do5Ut$']$C$CM!),!6JLL*QWWS\\,!GHHH#AXF%c)nn4J69J[iXZmHHd%vg_ghhv D DAQw 6'(t'(~$']$C$CMMd%88TZ66DJMQY &	2!enu~&+oenUYZ_ZhUh"$& & & & #5)) { {%1!H%=%="aaDG*(8G(L(L%	:!"1ab	122 9 9A!

AQ4AFLLOOO zH zH! N!(8D!9!9"6'!44 R-6xh7W7WX^Xefn-o-oNGFF.>x.Q.QOFGG*:8H*M*M!'(33G #If 5 5I!$Z!8!8JJ!!#i..0FYv5FW)TV- #L ? ?%4
$/1Q\4?Y*qPU`gpy  CM  [g  uy  z  z  z  {  {  {  {TZ66DJ!51111r$   c                     t           S )N)r-   )rH   s    r"   _get_split_blParaFuncz#XPreformatted._get_split_blParaFunc   s    r$   )NNr   r   )__name__
__module____qualname__rL   rn   breakLinesCJKrp    r$   r"   r   r   Q   sQ        = = = =
x x xt M    r$   r   c                   8    e Zd ZdZdddddddZddZd Zd Zd	S )r   zGUsed for syntax-colored Python code, otherwise like XPreformatted.
    )r   r   )z<font color="green"></font>)z<font color="blue"><b>z</b></font>)z<font color="black">rw   )z<font color="red">rw   )z<font color="gray">rw   )restcommentkeyword	parameter
identifierstringNr   c                     |r(|                      |                     |                    }t                              | |||||           d S )N)rJ   rD   r   )fontify
escapeHtmlr   rL   )rH   r   rI   rJ   rD   r   s         r"   rL   zPythonPreformatted.__init__   sO     	7<< 5 566DtT5Jf[`aaaaar$   c                     |                     dd          }|                     dd          }|                     dd          }|S )N&z&amp;<z&lt;>z&gt;)replace)rH   r   r<   s      r"   r   zPythonPreformatted.escapeHtml   s@    LLg&&IIc6""IIc6""r$   c                     |d         dk    r
|dd         }t          j        |          }d}d}|D ]9\  }}}}||||         z   }| j        |         \  }	}
||	z   |||         z   |
z   }|}:|||d         z   }|S )z/Return a fontified version of some Python code.r   r   r   Nr   )r   r   formats)rH   codetagsfontifiedCodeposkr    jdummyr<   es              r"   r   zPythonPreformatted.fontify   s     7d? 	8D &&" 	 	NAq!U)DQK7M<?DAq)A-QqS	9A=MCC%STT
2r$   )Nr   N)rq   rr   rs   __doc__r   rL   r   r   ru   r$   r"   r   r      st           :@:89< <Gb b b b
      r$   r   __main__Nc                    t          dt          |           z             | j        j        }t	          |          }t
          j        j        }t          |          D ]q}||         }|j	        }t	          |          } |d|||j
        fz             t          |          D ]} |d|||         j        fz             t                       rd S )Nz(
############dumpXPreforemattedLines(%s)zline%d: %d(%d)
  z %d:'%s')printstrr(   r   r^   sysstdoutwriterangerX   rW   r   )	Pr   r;   outwrj   linerX   nwordsr   s	            r"   dumpXPreformattedLinesr     s    9CFFBCCCu::Zq 	 	A8DJEZZFD%6$.(AABBB6]] 3 3Z58= 112222GGGG	 	r$   c           	         t          dt          |           z             | j        }t          |          }t	          |          D ]!}t          d|||         j        fz             "t          j        j        }d}t          |          D ]g}d}t          |d          D ]M} |d|||d         fz             |dz   }|dd          D ]} |d|d         z             t                       N|dz   }hd S )Nz(
############dumpXPreforemattedFrags(%s)zfrag%d: '%s'r   ih  zfrag%d.%d: size=%dr   z '%s')r   r   r   r^   r   r   r   r   r   r#   r	   )r   r   r;   rj   r   ri   r   r   s           r"   dumpXPreformattedFragsr     s#   9CFFBCCCu::q 	7 	7A.AuQx}#556666Zu%% 	 	AA"1S))  )Q1Q4L8999E122 ) )AD1Q4((((AAA	 	r$   c                 :   t          | ||          }t          |           |                    ||          \  }}t          |           |                    ||          }t          |           |D ])}	|	                    ||           t          |	           d}*d S )N)rD   i  )r   r   wrapr   r_   )
r   rI   rD   aWaHr   r   hSr<   s
             r"   try_itr   #  s    
U&
1
1
1q!!!ffRnn!q!!!GGBrNNq!!! 	 	AFF2bMMM"1%%%BB	 	r$   )getSampleStyleSheetParagraphStyleBodyTextdiscussiontext)parent	Helveticaa?  


The <font name=courier color=green>CMYK</font> or subtractive

method follows the way a printer
mixes three pigments (cyan, magenta, and yellow) to form colors.
Because mixing chemicals is more difficult than combining light there
is a fourth parameter for darkness.  For example a chemical
combination of the <font name=courier color=green>CMY</font> pigments generally never makes a perfect

black -- instead producing a muddy color -- so, to get black printers
don't use the <font name=courier color=green>CMY</font> pigments but use a direct black ink.  Because
<font name=courier color=green>CMYK</font> maps more directly to the way printer hardware works it may
be the case that &amp;| &amp; | colors specified in <font name=courier color=green>CMYK</font> will provide better fidelity
and better control when printed.


g     |@gffffffE@av  

   This is a non rearranging form of the <b>Paragraph</b> class;
   <b><font color=red>XML</font></b> tags are allowed in <i>text</i> and have the same

      meanings as for the <b>Paragraph</b> class.
   As for <b>Preformatted</b>, if dedent is non zero <font color=red size=+1>dedent</font>
       common leading spaces will be removed from the
   front of each line.

   z    <font color=blue>class </font><font color=red>FastXMLParser</font>:
        # Nonsense method
        def nonsense(self):
            self.foo = 'bar'
Codeg333333@r   )*__all____version__r   reportlab.libr   reportlab.platypus.paragraphr   r   r   r	   r
   r   r   r   reportlab.lib.utilsr   reportlab.platypus.flowablesr   r#   r-   r1   r?   r   r   rq   r   r   r   r   reportlab.lib.stylesr   r   
styleSheetBDTstyler8   r   rD   rI   r   r   activeru   r$   r"   <module>r      s   H # # # # # #R R R R R R R R R R R R R R R R R R R R % % % % % % 2 2 2 2 2 2  ,      2D D D D DI D D DL' ' ' ' ' ' ' 'R Z Y3JJJ    &
 
 
 IHHHHHHH$$&&J:An-a888G!G2$ gudA%1&
 wtQ
 
 z&5#q*=$0 %3 %3+fUBFJ 266$uVBr222sY3 Y3h%3 %3r$   