
    CPc#                         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	  edddd          Z
 ed	d
dd          Z G d dej                  Zedk    r e                                             dS dS )z
Merge text blocks together.
    N)KeyDict)	RectangleFlowRootFlowPara
FlowRegionTextElementTspanleftrightcenter_x)lrmtopbottomcenter_y)tbr   c                   *    e Zd ZdZd Zd Zd Zd ZdS )MergezMerge text blocks togetherc                 (   |                     dddd           |                     dddd	           |                     d
ddd           |                     ddt          j        d           |                     ddt          j        d           d S )Nz-dz--directionlrzdirection to merge text)defaulthelpz-xz	--xanchorr
   zhoriz point to comparez-yz	--yanchorr   zvertical point to comparez-kz--keepstylezkeep format)typer   z-tz
--flowtextz:use a flow text structure instead of a normal text element)add_argumentinkexBoolean)selfparss     ,/usr/share/inkscape/extensions/text_merge.pyadd_argumentszMerge.add_arguments)   s    -4M 	 	
 	
 	
 	+v4L 	 	
 	
 	
 	+u3N 	 	
 	
 	
 	$EMVVVM	 	 	
 	
 	
 	
 	
    c           
         | j         j        s?| j                             d          D ]$}|| j         j        |                    d          <   %| j         j        sd S | j                                         }| j        j        rt          }t          }nt          }t          }|                     |                      }|                    dd           ddddddd	d
dd	|_        t          | j         j                                        | j                  D ]}|                     |||           | j        j        r|                    t%                                }|                    dd           |                    t'                                }|                    dd           |                    dd           |                    dd           d S d S )Nz//svg:text | //svg:flowRootid	xml:spacepreserve20pxnormalz125%0pxz#000000   none)	z	font-sizez
font-stylezfont-weightzline-heightzletter-spacingzword-spacingfillzfill-opacitystroke)keyheight   width)svg	selectionxpathgetget_current_layeroptionsflowtextr   r   r   r	   addsetstylesortedvalues_sortrecurser   r   )r   node
parentnodetext_element	text_span	text_rootregionrects           r!   effectzMerge.effect;   s   x! 	:'DEE : :59"488D>>22x! 	FX//11
<  	#L II&LINN<<>>22	k:..."#!#!

 

	 48-4466DJGGG 	5 	5DLLD)4444<  	#]]:<<00FJJ{J///::ikk**DHH[*---HHXs###HHWc"""""	# 	#r#   c                     |                                                     | j        j        | j        j        | j        j                  S )N)bounding_box
get_anchorr8   xanchoryanchor	direction)r   rA   s     r!   r?   zMerge._sorte   s<      ""--L $,"68N
 
 	
r#   c                 6   t          |t                    s|                     |                      }|                    dd           |                    d|                    d                     t          |t
          t          f          r|                    dd           | j        j        r|j	        |_	        |j
        |j
        |_
        |D ]}|                     |||           |j        r%t          |t
                    s|j        |_        dS dS dS dS )z<Recursively go through each node self calling on child nodesr&   r'   zsodipodi:rolelineN)
isinstancer   r:   r;   r6   r   r   r8   	keepstyler<   textr@   tail)r   rD   rA   spannewspanchilds         r!   r@   zMerge.recursej   s   $
++ 	)hhyy{{++GKKZ000KK/)B)BCCC$h 788 5OV444|% + $
y$#y 8 8Yw7777y )D+!>!> )#y#	) 	) ) ) ) )r#   N)__name__
__module____qualname____doc__r"   rH   r?   r@    r#   r!   r   r   &   sW        $$
 
 
$(# (# (#T
 
 

) ) ) ) )r#   r   __main__)r[   r   inkex.utilsr   r   r   r   r   r   r	   XANYANEffectExtensionr   rX   runr\   r#   r!   <module>rc      s   2         O O O O O O O O O O O O O O O O gFz::;;gEz::;;W) W) W) W) W)E! W) W) W)t z	EGGKKMMMMM r#   