o
    e                    @   s  d dl Z d dlZe jeje d dlmZ d dl	m
Z
mZ d dlm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!m"Z"m#Z#m$Z$ G dd dZ%G d	d
 d
Z&dddddddddddddddZ'G dd dej(Z)G dd de)Z*dS )    N)handler)escape	quoteattr)Node)load)ANIMNSCHARTNSCONFIGNSDCNSDR3DNSDRAWNSFONSFORMNSMATHNSMETANSNUMBERNSOFFICENSPRESENTATIONNSSCRIPTNSSMILNSSTYLENSSVGNSTABLENSTEXTNSXLINKNSc                   @   s   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zd S )!
StyleToCSSz The purpose of the StyleToCSS class is to contain the rules to convert
        ODF styles to CSS2. Since it needs the generic fonts, it would probably
        make sense to also contain the Styles in a dict as well..
    c                 C   s  i | _ i | _i tdf| jtdf| jtdf| jtdf| jtdf| jtdf| jtdf| jtdf| jtd	f| jtd
f| jtdf| jtdf| jtdf| jtdf| jtdf| jtdf| jtdf| ji tdf| jtdf| jtdf| jtdf| jtdf| jtdf| jtdf| jtdf| jtdf| jtdf| jtdf| jtdf| jt	df| j
tdf| jtd f| jtd!f| jtd"f| jtd#f| jtd$f| jtd%f| ji| _d S )&Nzfill-image-namezbackground-colorborderzborder-bottomzborder-leftzborder-rightz
border-topcolorfont-family	font-sizez
font-stylezfont-variantzfont-weightzline-heightmarginzmargin-bottommargin-leftmargin-rightz
margin-top
min-heightpaddingzpadding-bottomzpadding-leftzpadding-rightzpadding-topz
page-widthzpage-height
text-alignztext-indentzborder-modelzcolumn-widthz	font-namezhorizontal-posztext-positionztext-line-through-styleztext-underline-stylewidth)fontdict
fillimagesr   c_drawfillimager   c_foc_page_widthc_page_heightc_text_alignr   c_border_modelr   c_widthc_fnc_hpc_text_positionc_text_line_through_stylec_text_underline_styleruleconversionsself r8   @/var/www/html/venv/lib/python3.10/site-packages/odf/odf2xhtml.py__init__?   s   








	























 
!
"
#

zStyleToCSS.__init__c                 C   sh   d}|dkr	d}n"|dkrd}n|dkrd}n|dkrd}n|dkr%d}n|d	kr+d}||f| j |< d
S )a   It is possible that the HTML browser doesn't know how to
            show a particular font. Fortunately ODF provides generic fallbacks.
            Unfortunately they are not the same as CSS2.
            CSS2: serif, sans-serif, cursive, fantasy, monospace
            ODF: roman, swiss, modern, decorative, script, system
            This method put the font and fallback into a dictionary
        z
sans-serifromanserifswissmodern	monospace
decorativescriptsystemN)r'   )r7   namefamilygenerichtmlgenericr8   r8   r9   	save_fonto   s   zStyleToCSS.save_fontc                 C   s   d| j |  |d< dS )z Fill a figure with an image. Since CSS doesn't let you resize images
            this should really be implemented as an absolutely position <img>
            with a width and a height
        z	url('%s')zbackground-imageN)r(   r7   rulesetsdictrulevalr8   r8   r9   r)      s   zStyleToCSS.c_drawfillimagec                 C   s   |d }|||< dS )z XSL formatting attributes    Nr8   )r7   rI   rJ   rK   rL   selectorr8   r8   r9   r*      s   zStyleToCSS.c_foc                 C   s    |dkr
d|d< dS d|d< dS )z Convert to CSS2 border model 
collapsingcollapsezborder-collapseseparateNr8   rH   r8   r8   r9   r.      s   zStyleToCSS.c_border_modelc                 C      ||d< dS )z Set width of box r&   Nr8   rH   r8   r8   r9   r/         zStyleToCSS.c_widthc                 C   s$   |dkrd}|dkrd}||d< dS )z Text align startleftendrightr%   Nr8   )r7   rI   rJ   rK   alignr8   r8   r9   r-      s   zStyleToCSS.c_text_alignc                 C   sN   | tdf}|dur| ||| | j ||df\}}d||f |d< dS )z Generate the CSS font family
            A generic font can be found in two ways. In a <style:font-face>
            element or as a font-family-generic attribute in text-properties.
        font-family-genericNr<   z%s, %sr   )getr   rG   r'   )r7   rI   rJ   rK   	fontstylerE   rD   rF   r8   r8   r9   r0      s
   zStyleToCSS.c_fnc                 C   sn   | d}t|dkr|d dkr|d |d< |d dkr#d|d	< dS |d d
kr/d|d	< dS |d |d	< dS )a   Text position. This is used e.g. to make superscript and subscript
            This attribute can have one or two values.

            The first value must be present and specifies the vertical
            text position as a percentage that relates to the current font
            height or it takes one of the values sub or super. Negative
            percentages or the sub value place the text below the
            baseline. Positive percentages or the super value place
            the text above the baseline. If sub or super is specified,
            the application can choose an appropriate text position.

            The second value is optional and specifies the font height
            as a percentage that relates to the current font-height. If
            this value is not specified, an appropriate font height is
            used. Although this value may change the font height that
            is displayed, it never changes the current font height that
            is used for additional calculations.
            r   z0%rM   r   superz33%zvertical-alignsubz-33%N)splitlen)r7   rI   rJ   rK   tptextposr8   r8   r9   r2      s   
zStyleToCSS.c_text_positionc                 C   s  | tdfd}|dkrd|d< d|d< |dv r>|dv r"d	|d
< d S |dkr4d|d< d|d< d|d	< d S d|d< d|d< d S |dv rh|dv rLd|d
< d S |dkr^d|d< d|d< d|d< d S d|d< d|d< d S |dv r|dv rvd|d
< d S d|d< tdf|v r|tdf |d< d S d S d S )Nwrapparallelcenterautor!   r"   )rW   outside)rU   re   dynamicrW   floatzrun-throughabsoluteposition0top0cm)rU   inside)rW   re   ri   rU   )z	from-leftzfrom-inside)rW   re   relativex)rZ   r   r   )r7   rI   rJ   rK   hposrd   r8   r8   r9   r1      s<   zStyleToCSS.c_hpc                 C   rR   )zt Set width of box
            HTML doesn't really have a page-width. It is always 100% of the browser width
        r&   Nr8   rH   r8   r8   r9   r+      s   zStyleToCSS.c_page_widthc                 C       |r|dkrd|d< dS dS dS )| Set underline decoration
            HTML doesn't really have a page-width. It is always 100% of the browser width
        none	underlinetext-decorationNr8   rH   r8   r8   r9   r4         z!StyleToCSS.c_text_underline_stylec                 C   rt   )ru   rv   zline-throughrx   Nr8   rH   r8   r8   r9   r3      ry   z$StyleToCSS.c_text_line_through_stylec                 C   rR   )z Set height of box heightNr8   rH   r8   r8   r9   r,     rS   zStyleToCSS.c_page_heightc                    s   i }g }|  D ]$\}}|d dkr|||d < q j|d}|r,||||||g qt fdd|D ]}|\}}}}}||||| q6t fdd|D ]}|\}}}}}||||| qP|S )zj Rule is a tuple of (namespace, name). If the namespace is '' then
            it is already CSS2
        r    rM   Nc                    s   | d  j kS Nr   r1   rr   r6   r8   r9   <lambda>      z+StyleToCSS.convert_styles.<locals>.<lambda>c                    s   | d  j kS r|   r}   r~   r6   r8   r9   r     r   )itemsr5   rZ   appendfilter)r7   rI   rJ   
proceduresrK   rL   methodpr8   r6   r9   convert_styles  s"   zStyleToCSS.convert_stylesN)__name__
__module____qualname____doc__r:   rG   r)   r*   r.   r/   r-   r0   r2   r1   r+   r4   r3   r,   r   r8   r8   r8   r9   r   9   s"    0*r   c                   @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )TagStackc                 C   
   g | _ d S Nstackr6   r8   r8   r9   r:   #     
zTagStack.__init__c                 C   s   | j ||f d S r   )r   r   r7   tagattrsr8   r8   r9   push&  s   zTagStack.pushc                 C   s   | j  }|S r   )r   popr7   itemr8   r8   r9   r   )  s   
zTagStack.popc                 C   s   | j d }|d S )NrM   r   r   r8   r8   r9   stackparent-  s   
zTagStack.stackparentc                 C   s(   | j D ]\}}||v r||   S qdS )z% Find a tag with the given attribute Nr   )r7   attrr   r   r8   r8   r9   	rfindattr1  s
   zTagStack.rfindattrc                 C   s(   d}| j D ]\}}||kr|d }q|S )Nr   rM   r   )r7   r   cttagtattrsr8   r8   r9   
count_tags7  s
   zTagStack.count_tagsN)	r   r   r   r:   r   r   r   r   r   r8   r8   r8   r9   r   "  s    r   emcitestrongvardfntth1h2h3h4h5h6addresspre)z
S-Emphasisz
S-CitationzS-Strong_20_Emphasisz
S-VariablezS-Definitionz
S-TeletypezP-Heading_20_1zP-Heading_20_2zP-Heading_20_3zP-Heading_20_4zP-Heading_20_5zP-Heading_20_6zP-AddresseezP-Preformatted_20_Textc                   @   s
  e Zd ZdZdddZdd Zdd	 ZdddZdd Zdd Z	dd Z
dd Zi dfddZdddZi fddZdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Zd=d> Z d?d@ Z!dAdB Z"dCdD Z#dEdF Z$dGdH Z%dIdJ Z&dKdL Z'dMdN Z(dOdP Z)dQdR Z*dSdT Z+dUdV Z,dWdX Z-dYZ.dZd[ Z/d\d] Z0d^d_ Z1d`da Z2dbdc Z3ddde Z4dfdg Z5dhdi Z6djdk Z7dldm Z8dndo Z9dpdq Z:drds Z;dtdu Z<dvdwdxdydzd{d|d}d~dd
Z=dd Z>dd Z?dd Z@dd ZAdd ZBdd ZCdd ZDdd ZEdd ZFdd ZGdd ZHdd ZIdd ZJddddddddddd
ZKdd ZLdd ZMdd ZNdd ZOdd ZPdd ZQdd ZRdd ZSdd ZTdd ZUdd ZVdd ZWdd ZXdd ZYddÄ ZZddń Z[ddǄ Z\ddɄ Z]dd˄ Z^dd̈́ Z_ddτ Z`ddф Zaddӄ ZbddՄ Zcddׄ Zdddل Zeddۄ Zfdd݄ Zgdd߄ Zhdd Zidd Zjdd Zkdd Zldd Zmdd Zndd Zodd Zpdd Zqdd Zrdd Zsdd Ztdd Zudd Zvdd Zwdd Zxd d ZydddZzd
S (  	ODF2XHTML4 The ODF2XHTML parses an ODF file and produces XHTMLTFc                 C   s  || _ i tdf| j| jftdf| j| jftdf| j| jftdf| j| jftdf| j| jftdf| j| j	ftdf| j
| jftdf| jd ftd	f| jd ftd
f| jd ftdf| jd ftdf| jd ftdf| j| jftdf| j| jftdf| j| jftdf| j| jftdf| j| jfi tdf| j| jftdf| jd ftdf| jd ftdf| jd ftdf| jd ftdf| jd ftdf| jd ftdf| jd ftdf| j| jftdf| j| jftdf| jd ftdf| jd ftdf| jd ftdf| j| jftd f| j| j ftd!f| j!d ftd"f| j"| j#fi td#f| jd ftd$f| jd ft$d%f| jd ft%d&f| jd ft%d'f| j&| j'ft%d(f| j(d ft%d)f| j)d ft%d*f| j(d ft%d+f| jd ft%d,f| j*d ft%d-f| j(d ft%d.f| j+| j,ft%d/f| j(d ft%d0f| j-| j.ft%d1f| j(d ft%d2f| j(d ft%d3f| j(d fi t%d4f| j(d ft/d5f| jd ft0d6f| jd ft0d7f| j1| j2ft0d8f| j3d ft0d9f| j4| j5ft0d:f| j6| j7ft8d;f| j9| j:ft8d<f| j;| j<ft8d=f| jd ft8d>f| j;| j<ft8d?f| j=d ft8d@f| j=d ft8dAf| j>| j:ft8dBf| j>d ft8dCf| j?| j@ft8dDf| j;| j<fi t8dEf| jAd ft8dFf| jd ft8dGf| jB| jCft8dHf| jD| jEft8dIf| jF| jGft8dJf| jH| jIft8dKfdLt8dMf| jJd ft8dNf| jK| jLft8dOfd | jMft8dPf| jd ft8dQf| j;| j<ft8dRf| jN| jOft8dSf| jPd ft8dTf| jQ| jRft8dUf| jSd ft8dVf| j;| j<ft8dWf| j;| j<ft8dXf| j;| j<fi| _T|r| U  | V  d S )YNtitlelanguagecreatordescriptiondatezcustom-shapeframeimage
fill-image	layer-setobject
object-olepagetext-boxzcreation-date	generatorzinitial-creatorkeywordboolean-stylecurrency-style
date-stylenumber-style
text-style
annotationzautomatic-stylesdocumentdocument-contentformszmaster-stylesmetapresentationspreadsheetstylestextscriptssettingsnoteszdefault-page-layoutzdefault-stylezdrawing-page-propertiesz	font-facezgraphic-propertieszhandout-masterzmaster-pagezpage-layout-propertieszpage-layoutzparagraph-propertiesstyleztable-cell-propertiesztable-column-propertiesztable-propertiesztext-propertiesdesccovered-table-cell
table-celltable-column	table-rowtableaalphabetical-index-sourcebibliography-configurationbibliography-sourcebookmarkzbookmark-startzbookmark-refzbookmark-ref-starthillustration-index-source
line-breaklinenumbering-configurationlist	list-itemlist-level-style-bulletlist-level-style-number
list-styleNNnote	note-bodynote-citationnotes-configurationobject-index-sourcer   sspantabtable-index-sourcetable-of-content-sourceuser-index-source)Wgenerate_cssr
   s_processcont
e_dc_titlee_dc_contentlanguagee_dc_creatore_dc_metatagr   s_custom_shapee_custom_shapes_draw_framee_draw_frames_draw_images_draw_fill_images_ignorexmls_draw_objects_draw_object_oles_draw_pagee_draw_pages_draw_textboxe_draw_textboxr   r   r   s_office_automatic_styless_office_document_contente_office_document_contents_office_master_styless_ignoreconts_office_presentatione_office_presentations_office_spreadsheete_office_spreadsheets_office_styless_office_texte_office_textr   r   s_style_default_stylee_style_default_styles_style_handle_propertiess_style_font_faces_style_master_pages_style_page_layoute_style_page_layouts_style_stylee_style_styler   r   s_table_table_celle_table_table_cells_table_table_columns_table_table_rowe_table_table_rows_table_tablee_table_tabler   s_text_ae_text_as_text_x_sourcee_text_x_sources_text_bookmarks_text_bookmark_refs_text_he_text_hs_text_line_breaks_text_liste_text_lists_text_list_iteme_text_list_items_text_list_level_style_bullete_text_list_level_style_bullets_text_list_level_style_numbere_text_list_level_style_numbers_text_notes_text_note_bodye_text_note_bodye_text_note_citations_text_pe_text_ps_text_ss_text_spane_text_span
s_text_tabelementsset_embedable_resetobject)r7   r   	embedabler8   r8   r9   r:   \  sd  	
 !"#$%'()*-.2346789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]`zODF2XHTML.__init__c                 C   
   d| _ dS )z% Tell the parser to not generate CSS FN)r   r6   r8   r8   r9   	set_plain     
zODF2XHTML.set_plainc                 C   s<   d| j tdf< d| j tdf< d| j tdf< d| j tdf< dS )z? Tells the converter to only output the parts inside the <body>r   r   r   r   r   N)r<  r   r6   r8   r8   r9   r=    s   zODF2XHTML.set_embedableNc                 C   s<   d| _ || _|r| jd||f  dS | jd|  dS )zm Add a link to an external style file.
            Also turns of the embedding of styles in the HTML
        Fz><link rel="stylesheet" type="text/css" href="%s" media="%s"/>
z3<link rel="stylesheet" type="text/css" href="%s"/>
N)use_internal_cssstylefilenamemetatagsr   )r7   rD  mediar8   r8   r9   add_style_file  s
   zODF2XHTML.add_style_filec                 C   s   i | _ d| _d| _d S )Nr   r{   )notedictcurrentnotenotebodyr6   r8   r8   r9   _resetfootnotes  s   
zODF2XHTML._resetfootnotesc                 C   s   g | _ | j| _d| _d| _d| _d| _g | _t | _	g | _
g | _d| _d| _i | _g d| _d| _t | _i | _g | _i | _d | _|   g | _d S )Nr{   T)r   r   r   r   r   r   r   r   r   r   r   )lines_wlines_wfuncxmlfiler   r   r   datar   tagstack	htmlstackpstackprocesselemprocesscont	listtypesheadinglevelsrC  r   csanchors
stylestack	styledictcurrentstylerK  rE  r6   r8   r8   r9   r>    s,   

zODF2XHTML._resetobjectc                 C   s   |dkr|  | d S d S Nr{   )rN  r7   r   r8   r8   r9   writeout  s   zODF2XHTML.writeoutc                 C   s*   d | j}|dkr| t| d S d S r]  )joinrP  r_  r   )r7   dr8   r8   r9   	writedata  s   zODF2XHTML.writedatac                 C   s   | j |||f g }| D ]\}}|d|t|f  qt|dkr-| d|  n| d|d|f  |dkrD| d dS dS )	z Create an open HTML tag %s=%sr   z<%s>z<%s %s>r\   T
N)rR  r   r   r   ra   r_  r`  )r7   r   r   blockr   keyrL   r8   r8   r9   opentag  s   zODF2XHTML.opentagc                 C   s2   | j   | d|  |dkr| d dS dS )z Close an open HTML tag z</%s>Trd  N)rR  r   r_  )r7   r   re  r8   r8   r9   closetag  s
   
zODF2XHTML.closetagc                 C   sH   g }|  D ]\}}|d|t|f  q| d|d|f  d S )Nrc  z	<%s %s/>
r\   )r   r   r   r_  r`  )r7   r   r   r   rf  rL   r8   r8   r9   emptytag  s   zODF2XHTML.emptytagc                 C   s$   | j r| jr| j| d S d S d S r   )rT  rU  rP  r   )r7   rP  r8   r8   r9   
characters$  s   zODF2XHTML.charactersc                 C   s^   | j | j| jf | jr&| j|dd }|r | ||| n| || | j	|| d S )Nr   r   )
rS  r   rT  rU  r<  rZ   handle_starttagunknown_starttagrQ  r   )r7   r   qnamer   r   r8   r8   r9   startElementNS(  s   zODF2XHTML.startElementNSc                 C   s\   | j  \}}| jr#| j|dd }|r| ||| n| || | j \| _| _d S )Nr   rM   )	rQ  r   rT  r<  rZ   handle_endtagunknown_endtagrS  rU  )r7   r   rm  stagr   r   r8   r8   r9   endElementNS2  s   zODF2XHTML.endElementNSc                 C   s   ||| d S r   r8   )r7   r   r   r   r8   r8   r9   rk  =     zODF2XHTML.handle_starttagc                 C   s   ||| d S r   r8   )r7   r   r   r   r8   r8   r9   ro  @  rs  zODF2XHTML.handle_endtagc                 C      d S r   r8   r   r8   r8   r9   rl  C     zODF2XHTML.unknown_starttagc                 C   rt  r   r8   r   r8   r8   r9   rp  F  ru  zODF2XHTML.unknown_endtagc                 C   r@  )zh Ignore this xml element and all children of it
            It will automatically stop ignoring
        FN)rT  r   r8   r8   r9   r   I  s   
zODF2XHTML.s_ignorexmlc                 C   r@  )z  Stop processing the text nodes FNrU  r   r8   r8   r9   r	  O  rB  zODF2XHTML.s_ignorecontc                 C   r@  )z! Start processing the text nodes TNrv  r   r8   r8   r9   r   S  rB  zODF2XHTML.s_processcontc                 C   s    | tdfd}|dd}|S )z) Generate a class name from a style name 
style-namer{   ._)rZ   r   replace)r7   r   r   r8   r8   r9   	classnameW  s   zODF2XHTML.classnamec                 C   s.   || j vrdt| j d  | j |< | j |S )z+ Create a unique anchor id for a href name z
anchor%03drM   )rY  ra   rZ   )r7   rC   r8   r8   r9   
get_anchor]  s   
zODF2XHTML.get_anchorc                 C   r   r   )rP  r6   r8   r8   r9   	purgedataf  r   zODF2XHTML.purgedatac                 C   s   d | j| _g | _dS )zD Get the title from the meta data and create a HTML <title>
        r{   N)r`  rP  r   r   r8   r8   r9   r   n  s   
zODF2XHTML.e_dc_titlec                 C   s.   | j d|d td| jf  g | _dS )z: Any other meta data is added as a <meta> element
        z<meta name="%s" content=%s/>
rM   r{   N)rE  r   r   r`  rP  r   r8   r8   r9   r   u  s   $
zODF2XHTML.e_dc_metatagc                 C   .   d | j| _| jdt| j  g | _dS )zD Set the content language. Identifies the targeted audience
        r{   z3<meta http-equiv="content-language" content="%s"/>
N)r`  rP  r   rE  r   r   r   r8   r8   r9   r   {     
zODF2XHTML.e_dc_contentlanguagec                 C   r~  )zC Set the content creator. Identifies the targeted audience
        r{   z*<meta http-equiv="creator" content="%s"/>
N)r`  rP  r   rE  r   r   r   r8   r8   r9   r     r  zODF2XHTML.e_dc_creatorc                 C   <  | tdfd}d}d| tdfd }|dkr"d| tdfd }|dd	}|d
kr/d}n|dkr6d}n|dkr?d}d}nd}tdf|v rS|d |tdf  d }tdf|v re|d |tdf  d }tdf|v rw|d |tdf  d }tdf|v r|d |tdf  d }| jr| |||d dS | | dS )zQ A <draw:custom-shape> is made into a <div> in HTML which is then styled
        anchor-typenotfounddivG-rw  r{   PR-rx  ry  	paragraphposition:absolute;charas-charzposition: absolute;r&   width:;rz   height:rr   left:ytop:classr   NrZ   r   r   r   rz  r   r   rg  r7   r   r   anchor_typehtmltagrC   r   r8   r8   r9   r     2   zODF2XHTML.s_custom_shapec                 C      |  d dS z End the <draw:frame>
        r  Nrh  r   r8   r8   r9   r        zODF2XHTML.e_custom_shapec                 C   r  )zJ A <draw:frame> is made into a <div> in HTML which is then styled
        r  r  r  r  rw  r{   r  rx  ry  r  zposition:relative;r  r  r  r&   r  r  rz   r  rr   r  r  r  r  Nr  r  r8   r8   r9   r     r  zODF2XHTML.s_draw_framec                 C   r  r  r  r   r8   r8   r9   r     r  zODF2XHTML.e_draw_framec                 C   s6   | tdfd}|tdf }| |}|| jj|< d S )NrC   NoNamehref)rZ   r   r   rewritelinkrX  r(   )r7   r   r   rC   imghrefr8   r8   r9   r     s   
zODF2XHTML.s_draw_fill_imagec                 C   s   |S )zh Intended to be overloaded if you don't store your pictures
            in a Pictures subfolder
        r8   )r7   r  r8   r8   r9   r    s   zODF2XHTML.rewritelinkc                 C   s^   | j  }|tdf}|tdf }| |}d|d}| jr'|dkr'd|d< | d| d	S )
z2 A <draw:image> becomes an <img/> element
        r  r  r{   )altsrcr  zdisplay: block;r   imgN)rQ  r   rZ   r   r   r  r   ri  )r7   r   r   parentr  r  	htmlattrsr8   r8   r9   r     s   


zODF2XHTML.s_draw_imagec                 C   s4   |t df }| jjD ]}|j|kr| |j q
dS )z` A <draw:object> is embedded object in the document (e.g. spreadsheet in presentation).
        r  N)r   r   childobjectsfolder	_walknodetopnode)r7   r   r   objhrefr   r8   r8   r9   r     s   

zODF2XHTML.s_draw_objectc                 C   sJ   |t df }|r!| dkr#ddd}| d| | d| dS dS dS )zU A <draw:object-ole> is embedded OLE object in the document (e.g. MS Graph).
        zclass-idz$00020803-0000-0000-c000-000000000046object_ole_graphz	ole-graph)rC   r  r   N)r   lowerrg  rh  )r7   r   r   class_idtagattrsr8   r8   r9   r     s   
zODF2XHTML.s_draw_object_olec                 C   s   | tdfd}| tdfd}|dd}| tdfd}|dd}| jr4| dd	d
||f i n| d | d | t| | d dS )z A <draw:page> is a slide in a presentation. We use a <fieldset> element in HTML.
            Therefore if you convert a ODP file, you get a series of <fieldset>s.
            Override this for your own purpose.
        rC   r  rw  r{   rx  ry  zmaster-page-namefieldsetr  zDP-%s MP-%slegendN)rZ   r   rz  r   rg  r_  r   rh  )r7   r   r   rC   	stylename
masterpager8   r8   r9   r    s   

zODF2XHTML.s_draw_pagec                 C   s   |  d d S )Nr  r  r   r8   r8   r9   r    rs  zODF2XHTML.e_draw_pagec                 C   s6   d}t df|v r|d |t df  d }| d d S )Nr{   r#   zmin-height:r  r  )r   rg  )r7   r   r   r   r8   r8   r9   r    s   zODF2XHTML.s_draw_textboxc                 C   r  )z! End the <draw:text-box>
        r  Nr  r   r8   r8   r9   r     r  zODF2XHTML.e_draw_textboxc                 C   sp   |    | jr&| jr&| dddid | d |   | d | d |   | d | jddd	 d S )
Nr   typeztext/cssTz/*<![CDATA[*/
z/*]]>*/
headbodyre  )rb  r   rC  rg  r_  generate_stylesheetrh  r}  r   r8   r8   r9   	html_body%  s   



zODF2XHTML.html_bodyz
img { width: 100%; height: 100%; }
* { padding: 0; margin: 0;  background-color:white; }
body { margin: 0 1em; }
ol, ul { padding-left: 2em; }
c                 C   s@  | j D ]d}| j|}d|v r1|d | jv r1| j|d   }|d= | D ]\}}|||< q&|}d|v rb|d | jv rb| j|d   }|d= | D ]\}}|||< qL|}d|v rb|d | jv s<|| j|< q| | j | j D ],}| j|}| j|}| d|  | D ]\}}| d||f  q| d qqd S )N__style-family__parent-style-namez%s {
z		%s: %s;
z}
)	rZ  r[  rZ   copyr   r_  default_stylesrX  r   )r7   rC   r   familystyler   rL   parentstylecss2r8   r8   r9   r  8  s2   



zODF2XHTML.generate_stylesheetc                 C   s   | j dkrd S | jr| dddid n| d td| j d D ]}| j| }| ddd	| i | |d
  | d q!| d d S )Nr   olr   zborder-top: 1px solid blackTrM   liidzfootnote-%dr  )rI  r   rg  rangerH  r_  rh  )r7   rf  r   r8   r8   r9   generate_footnotesT  s   


zODF2XHTML.generate_footnotesc                 C   s   | j dkr
d| _d S d| _d S )Nz
styles.xmlAr{   )rO  
autoprefixr   r8   r8   r9   r  f  s   


z#ODF2XHTML.s_office_automatic_stylesc                 C   st   |  d |  d | dddid | jddd | d	d
dd | jD ]}|  | q&|  dt| j  dS )z" First tag in the content.xml filez2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" z0"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
htmlxmlnszhttp://www.w3.org/1999/xhtmlTr  r  r   zContent-Typeztext/html;charset=UTF-8)z
http-equivcontentz<title>%s</title>
N)r_  rg  ri  rE  r   r   )r7   r   r   metaliner8   r8   r9   r  l  s   


z#ODF2XHTML.s_office_document_contentc                 C   r  )z
 Last tag r  Nr  r   r8   r8   r9   r  w  s   z#ODF2XHTML.e_office_document_contentc                 C   s   dS )r\   Nr8   r   r8   r8   r9   r  {  s    z ODF2XHTML.s_office_master_stylesc                 C   s4   t dfdi| jd< t dfdi| jd< | || dS )z For some odd reason, OpenOffice Impress doesn't define a default-style
            for the 'paragraph'. We therefore force a standard when we see
            it is a presentation
        r   24ptr   r   N)r   r[  r  r   r8   r8   r9   r
  ~  s   zODF2XHTML.s_office_presentationc                 C      |    | d d S Nr  r  rh  r   r8   r8   r9   r       zODF2XHTML.e_office_presentationc                 C   s   |  || d S r   )r  r   r8   r8   r9   r    s   zODF2XHTML.s_office_spreadsheetc                 C   r  r  r  r   r8   r8   r9   r    r  zODF2XHTML.e_office_spreadsheetc                 C   s
   d| _ d S r]  )r  r   r8   r8   r9   r    r   zODF2XHTML.s_office_stylesc                 C   s"   t dfdi| jd< | || dS )z OpenDocument text rd   re   r   N)r   r[  r  r   r8   r8   r9   r    s   zODF2XHTML.s_office_textc                 C   r  r  r  r   r8   r8   r9   r    r  zODF2XHTML.e_office_textc                 C   s&   |  D ]\}}|| j| j |< qdS )zY Copy all attributes to a struct.
            We will later convert them to CSS2
        N)r   r[  r\  )r7   r   r   rf  r   r8   r8   r9   r    s   z#ODF2XHTML.s_style_handle_propertiesr   r   r   r   r  r   tdcoltrgraphic)
r   r  r   r   sectionr   r   r   r   r  c                 C   s0   |t df }| j|d}|| _i | j| j< dS )z8 A default style is like a style on an HTML tag
        rD   unknownN)r   	familymaprZ   r\  r[  )r7   r   r   rD   
htmlfamilyr8   r8   r9   r    s   zODF2XHTML.s_style_default_stylec                 C   s
   d | _ d S r   r\  r   r8   r8   r9   r    r   zODF2XHTML.e_style_default_stylec                 C   s<   |t df }|tdf }|t dfd}| j||| dS )aI   It is possible that the HTML browser doesn't know how to
            show a particular font. Luckily ODF provides generic fallbacks
            Unfortunately they are not the same as CSS2.
            CSS2: serif, sans-serif, cursive, fantasy, monospace
            ODF: roman, swiss, modern, decorative, script, system
        rC   r   rY   r{   N)r   r   rZ   rX  rG   )r7   r   r   rC   rD   rE   r8   r8   r9   r    s   zODF2XHTML.s_style_font_facec                 C      |  dddi |   d S )Nr  r  footerrg  r}  r   r8   r8   r9   s_style_footer     zODF2XHTML.s_style_footerc                 C      |    | d |   d S Nr  rb  rh  r}  r   r8   r8   r9   e_style_footer     
zODF2XHTML.e_style_footerc                 C   $   d| _ | j| j  i | j| j < d S )Nz@print #footerr\  rZ  r   r[  r   r8   r8   r9   s_style_footer_style     zODF2XHTML.s_style_footer_stylec                 C   r  )Nr  r  headerr  r   r8   r8   r9   s_style_header  r  zODF2XHTML.s_style_headerc                 C   r  r  r  r   r8   r8   r9   e_style_header  r  zODF2XHTML.e_style_headerc                 C   r  )Nz@print #headerr  r   r8   r8   r9   s_style_header_style  r  zODF2XHTML.s_style_header_stylec                 C   s$   d| _ | j| j  i | j| j < dS )zC Collect the formatting for the default page layout style.
        z@pageNr  r   r8   r8   r9   s_style_default_page_layout  s   z%ODF2XHTML.s_style_default_page_layoutc                 C   s@   |t df }|dd}d| | _| j| j i | j| j< dS )z Collect the formatting for the page layout style.
            This won't work in CSS 2.1, as page identifiers are not allowed.
            It is legal in CSS3, but the rest of the application doesn't specify when to use what page layout
        rC   rx  ry  .PL-N)r   rz  r\  rZ  r   r[  )r7   r   r   rC   r8   r8   r9   r    s
   
zODF2XHTML.s_style_page_layoutc                 C   
   d| _ dS z End this style
        Nr  r   r8   r8   r9   r       
zODF2XHTML.e_style_page_layoutc                 C   s   |t df }|dd}d| | _| j| j ddi| j| j< |t dfd}|rRd	| }|| jv rJ| j| }| D ]\}}|| j| j |< q<n|| j| j d
< | || dS )z; Collect the formatting for the page layout style.
        rC   rx  ry  z.MP-)r{   rl   rq   zpage-layout-nameNr  r  )	r   rz  r\  rZ  r   r[  rZ   r   r   )r7   r   r   rC   
pagelayoutr   r   rL   r8   r8   r9   r    s   


zODF2XHTML.s_style_master_pageDPPPRSDTTDTCTRG)
zdrawing-pager  r   r   r  r   r   r   r   r  c                 C   s  |t df }|dd}|t df }| j|d}| j|d}d| j||f }|t df}t|d| | _| j	| j | j| j
vrKi | j
| j< || j
| j d	< |rd
||f }t|d| }|| j
v r| j
| }| D ]\}	}
|
| j
| j |	< qqdS || j
| j d< dS dS )au   Collect the formatting for the style.
            Styles have scope. The same name can be used for both paragraph and
            character styles Since CSS has no scope we use a prefix. (Not elegant)
            In ODF a style can have a parent, these parents can be chained.
            We may not have encountered the parent yet, but if we have, we resolve it.
        rC   rx  ry  rD   r  Xz%s%s-%szparent-style-namer  z%s-%sr  N)r   rz  r  rZ   _familyshortr  special_stylesr\  rZ  r   r[  r   )r7   r   r   rC   rD   r  sfamilyr  r   r   rL   r8   r8   r9   r    s,   

zODF2XHTML.s_style_stylec                 C   r  r  r  r   r8   r8   r9   r  1  r  zODF2XHTML.e_style_stylec                 C   sR   | tdfd}|r| jr|dd}| ddd| i n| d |   dS )z Start a table
        rw  Nrx  ry  r   r  zT-%s)rZ   r   r   rz  rg  r}  )r7   r   r   r   r8   r8   r9   r  6  s   

zODF2XHTML.s_table_tablec                 C      |    | d |   dS )z End a table
        r   Nr  r   r8   r8   r9   r   A     
zODF2XHTML.e_table_tablec                 C   sv   i }| tdf}|r||d< | tdf}|r||d< | tdf}|r/d|dd |d	< | d
| |   dS )z Start a table cell znumber-rows-spannedrowspanznumber-columns-spannedcolspanrw  zTD-%srx  ry  r  r  NrZ   r   rz  rg  r}  )r7   r   r   r  r  r   r   r8   r8   r9   r  H  s   zODF2XHTML.s_table_table_cellc                 C   r  )z End a table cell r  Nr  r   r8   r8   r9   r  Z     
zODF2XHTML.e_table_table_cellc                 C   sf   | tdfd}t| tdfd}i }|r d|dd |d< t|D ]}| d	| q$|   dS )
z Start a table column rw  Nznumber-columns-repeatedrM   zTC-%srx  ry  r  r  )rZ   r   intrz  r  ri  r}  )r7   r   r   r   repeatedr  rr   r8   r8   r9   r  `  s   zODF2XHTML.s_table_table_columnc                 C   sD   | tdfd}i }|rd|dd |d< | d| |   dS )z Start a table row rw  NzTR-%srx  ry  r  r  r  )r7   r   r   r   r  r8   r8   r9   r  k  s   zODF2XHTML.s_table_table_rowc                 C   r  )z End a table row r  Nr  r   r8   r8   r9   r  u  r  zODF2XHTML.e_table_table_rowc                 C   s\   |    |tdf dd }|d dkr d| |dd  }| dd|i |   dS )z Anchors start r  |r   #rM   Nr   )rb  r   r`   r|  rg  r}  )r7   r   r   r  r8   r8   r9   r!  {  s   zODF2XHTML.s_text_ac                 C       |    | dd |   dS )z% End an anchor or bookmark reference r   FNr  r   r8   r8   r9   r"       zODF2XHTML.e_text_ac                 C   sF   |t df }| |}|   | dd|i | dd |   dS )z Bookmark definition rC   r   r  FN)r   r|  rb  rg  rh  r}  r7   r   r   rC   html_idr8   r8   r9   r%    s   
zODF2XHTML.s_text_bookmarkc                 C   s>   |t df }d| | }|   | dd|i |   dS )z Bookmark reference zref-namer  r   r  N)r   r|  rb  rg  r}  r	  r8   r8   r9   r&    s
   zODF2XHTML.s_text_bookmark_refc                 C   s   t |tdf }|dkrd}|dk rd}| j| d | j|< | |}t|d dD ]}d| j|< q*td| }|s>| jsF| d|  n| d| dd	| i | 	  d
S )z Headings start outline-level   rM   
   r   P-h%sr  P-%sN)
r  r   rW  r{  r  r  rZ   r   rg  r}  )r7   r   r   levelrC   rr   specialr8   r8   r9   r'    s   

zODF2XHTML.s_text_hc                 C   s   |    t|tdf }|dkrd}|dk rd}| jd|d  }dtt|}d| j}| jdkr7|| _| 	d||f }| 
dd|i | dd	 | d
|  |   dS )z Headings end
            Side-effect: If there is no title in the metadata, then it is taken
            from the first heading of any level.
        r  r  rM   rx  r{   z%s.%sr   r  Fr  N)rb  r  r   rW  r`  mapstrrP  r   r|  rg  rh  r}  )r7   r   r   r  levoutlineheadinganchorr8   r8   r9   r(    s   zODF2XHTML.e_text_hc                 C   r  )z Force a line break (<br/>) brN)rb  ri  r}  r   r8   r8   r9   r)    r  zODF2XHTML.s_text_line_breakc                 C   s   | tdf}| j|d }|r|dd}n| jtdf}d||f }| jr9| d| j |d d|i n| d| j |d  | 	  d	S )
z Start a list (<ul> or <ol>)
            To know which level we're at, we have to count the number
            of <text:list> elements on the tagstack.
        rw  rM   rx  ry  %s_%dz%sulr  N)
rZ   r   rQ  r   rz  r   r   rg  rV  r}  r7   r   r   rC   r  
list_classr8   r8   r9   r*    s    zODF2XHTML.s_text_listc                 C   st   |    |tdf}| j|d }|r|dd}n| jtdf}d||f }| | j|d | 	  dS )z End a list rw  rM   rx  ry  r  r  N)
rb  rZ   r   rQ  r   rz  r   rh  rV  r}  r  r8   r8   r9   r+    s   zODF2XHTML.e_text_listc                 C   s   |  d |   dS )z Start list item r  Nr  r   r8   r8   r9   r,    s   
zODF2XHTML.s_text_list_itemc                 C   r  )z End list item r  Nr  r   r8   r8   r9   r-    r  zODF2XHTML.e_text_list_itemc                 C   s   | j tdf}|tdf }| j| _d||f }d| j|< d|dd|f | _| j	| j i | j
| j< t|}d|d	  }|| j
| j d
< dS )z CSS doesn't have the ability to set the glyph
            to a particular character, so we just go through
            the available glyphs
        rC   r  %s_%sr  .%s_%srx  ry  )squaredisccircle   r{   zlist-style-typeN)rQ  r   r   r   r\  	prevstylerV  rz  rZ  r   r[  r  )r7   r   r   rC   r  r  listtyper8   r8   r9   r.    s   
z(ODF2XHTML.s_text_list_level_style_bulletc                 C      | j | _| ` d S r   r%  r\  r   r8   r8   r9   r/       z(ODF2XHTML.e_text_list_level_style_bulletc                 C   s   | j  tdf }|tdf }|tdfd}d||f }| j| _d|dd|f | _d| j|< | j	
| j i | j| j< |dkrEd	}n|d
krLd}n|dkrSd}n|dkrZd}n	|dkrad}nd	}|| j| j d< d S )NrC   r  1r  r  rx  ry  r  decimalIzupper-romanizlower-romanr  zupper-alphar   zlower-alphar$  )rQ  r   r   r   rZ   r\  r%  rz  rV  rZ  r   r[  )r7   r   r   rC   r  
num_formatr  r&  r8   r8   r9   r0  
  s    
z(ODF2XHTML.s_text_list_level_style_numberc                 C   r'  r   r(  r   r8   r8   r9   r1    r)  z(ODF2XHTML.e_text_list_level_style_numberc                 C   s2   |    |   | jd | _i | j| j< g | _d S )NrM   )rb  r}  rI  rH  rJ  r   r8   r8   r9   r2     s
   
zODF2XHTML.s_text_notec                 C   rt  r   r8   r   r8   r8   r9   e_text_note'  ru  zODF2XHTML.e_text_notec                 C      |dkr| j | d S d S r]  )rJ  r   r^  r8   r8   r9   collectnote*  s   zODF2XHTML.collectnotec                 C   s   | j | _| j| _ d S r   )rN  	_orgwfuncr1  r   r8   r8   r9   r3  .  s   zODF2XHTML.s_text_note_bodyc                 C   s.   | j | _d| j| j| j d< d| _| ` d S )Nr{   r  )r2  rN  r`  rJ  rH  rI  r   r8   r8   r9   r4  2  s   zODF2XHTML.e_text_note_bodyc                 C   s   d | j}|| j| j d< | ddd| j i | d tjd dkr,| | j n| t| j | 	d | 	d d S )	Nr{   citationr   r  z#footnote-%ssupr   r#  )
r`  rP  rH  rI  rg  sysversion_infor_  unicoderh  )r7   r   r   markr8   r8   r9   r5  8  s   

zODF2XHTML.e_text_note_citationc                 C   sl   i }d}| tdfd}|r*|dd}t d| }|du r*d}| jr*d| |d< | || |   dS )	z Paragraph
        r   rw  Nrx  ry  r  r  r  )rZ   r   rz  r  r   rg  r}  )r7   r   r   r  
specialtagr   r8   r8   r9   r6  G  s   zODF2XHTML.s_text_pc                 C   s\   d}| tdfd}|r|dd}t d| }|du rd}|   | | |   dS )z End Paragraph
        r   rw  Nrx  ry  r  )rZ   r   rz  r  rb  rh  r}  )r7   r   r   r9  r   r8   r8   r9   r7  W  s   
zODF2XHTML.e_text_pc                 C   s0   | tdfd}tt|D ]}| d qdS )z Generate a number of spaces. ODF has an element; HTML uses &nbsp;
            We use &#160; so we can send the output through an XML parser if we desire to
        r   r*  z&#160;N)rZ   r   r  r  r_  )r7   r   r   r   rr   r8   r8   r9   r8  e  s   zODF2XHTML.s_text_sc                 C   sl   |    |tdfd}i }|r*|dd}td| }|du r*| jr*d| |d< | d| |   dS )	z The <text:span> element matches the <span> element in HTML. It is
            typically used to properties of the text.
        rw  Nrx  ry  zS-zS-%sr  r   )rb  rZ   r   rz  r  r   rg  r}  )r7   r   r   r   r  r  r8   r8   r9   r9  m  s   zODF2XHTML.s_text_spanc                 C   r  )z End the <text:span> r   FNr  r   r8   r8   r9   r:  |  r  zODF2XHTML.e_text_spanc                 C   r  )z: Move to the next tabstop. We ignore this in HTML
        r\   N)rb  r_  r}  r   r8   r8   r9   r;    r  zODF2XHTML.s_text_tabc                 C   s    |    |   | || dS zB Various indexes and tables of contents. We ignore those.
        N)rb  r}  r   r   r8   r8   r9   r#    s   zODF2XHTML.s_text_x_sourcec                 C   s   |    |   dS r:  )rb  r}  r   r8   r8   r9   r$    s   zODF2XHTML.e_text_x_sourcec                 C   sb   t |t dksdt|v sdt|v sdt|v sJ g | _| j| _t|| _| | jj dS )z
        Loads a document into the parser and parses it.
        The argument can either be a filename or a document in memory.
        @param odffile if the type is unicode string: name of a file; else
        it must be an open file type
        r{   rbBufferedReaderBytesION)	r  reprrL  rM  rN  r   r   r  r  )r7   odffiler8   r8   r9   r     s
   8
zODF2XHTML.loadc                 C   s   |j tjkr#| |j|j|j |jD ]}| | q| 	|j|j |j tj
ks/|j tjkrHtjd dkr?| t| d S | t| d S d S )Nr   r#  )nodeTyper   ELEMENT_NODErn  rm  tagName
attributes
childNodesr  rr  	TEXT_NODECDATA_SECTION_NODEr5  r6  rj  r  r7  )r7   noder   r8   r8   r9   r    s   
zODF2XHTML._walknodec                 C   sb   t |t dksdt|v sdt|v sdt|v sJ | | |  }t |t dks/J |S )z
        Load a file and return the XHTML
        @param odffile if the type is unicode string: name of a file; else
        it must be an open file type
        @return XHTML code as a a unicode string
        r{   r;  r<  r=  )r  r>  r   xhtml)r7   r?  resultr8   r8   r9   	odf2xhtml  s
   8
zODF2XHTML.odf2xhtmlc                 C   r0  r]  )rL  r   r^  r8   r8   r9   rM       zODF2XHTML._wlinesc                 C   s   d | jS )z Returns the xhtml
        r{   )r`  rL  r6   r8   r8   r9   rH    s   zODF2XHTML.xhtmlc                 C   r0  r]  )	_csslinesr   r^  r8   r8   r9   	_writecss  rK  zODF2XHTML._writecssc                 C   rt  r   r8   r^  r8   r8   r9   _writenothing  ru  zODF2XHTML._writenothingc                 C   s2   g | _ | j| _|   d| j }| j| _| ` |S )z Returns the CSS content r{   )rL  rM  rN  r  r`  rM  )r7   resr8   r8   r9   css  s   zODF2XHTML.cssc                 C   sH   |dkrt j}n|r|d }t|d}||  dd |  dS )z Save the HTML under the filename.
            If the filename is '-' then save to stdout
            We have the last style filename in self.stylefilename
        -z.htmlwzus-asciixmlcharrefreplaceN)r5  stdoutfilewriterH  encodeclose)r7   
outputfile	addsuffixoutputfpr8   r8   r9   save  s   
zODF2XHTML.saveTFr   )T)F){r   r   r   r   r:   rA  r=  rG  rK  r>  r_  rb  rg  rh  ri  rj  rn  rr  rk  ro  rl  rp  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  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/  r0  r1  r2  r/  r1  r3  r4  r5  r6  r7  r8  r9  r:  r;  r#  r$  r   r  rJ  rM  rH  rM  rN  rP  r\  r8   r8   r8   r9   r   Y  s   g	
				 
		
r   c                   @   s   e Zd ZdZdddZdS )ODF2XHTMLembeddedr   TFc                 C   s8  |    || _|| _i tdf| j| jftdf| jd ftdf| jd ftdf| jd ftdf| j	| j
ftdf| jd ftdf| jd ftdf| j| jftd	f| jd ftd
f| jd ftdf| jd ftdf| jd ftdf| jd ftdf| jd ftdf| jd ftdf| jd ftdf| jd fi tdf| jd ftdf| jd ftdf| j| jftdf| jd ftdf| j| jftdf| j| jftdf| j| jftdf| j| j ftdf| jd ftdf| j| j ftdf| j!| j"ftdf| j| j ftdf| j#d ftdf| jd ftd f| j$| j%ftd!f| j&| j'ftd"f| j(| j)ftd#f| j*| j+ftd$fd%td&f| j,d ftd'f| j-| j.ftd(fd | j/ftd)f| jd ftd*f| j| j ftd+f| j0| j1ftd,f| j2d ftd-f| j3| j4ftd.f| j5d ftd/f| j| j ftd0f| j| j ftd1f| j| j ftd2fd%i| _6d S )3Nr   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   zpage-number)7r>  rL  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/  r0  r1  r2  r3  r4  r5  r6  r7  r8  r9  r:  r;  r<  )r7   rL  r   r?  r8   r8   r9   r:     s   	
 !89:;<=>?@ABCDEFGHIzODF2XHTMLembedded.__init__Nr]  )r   r   r   r   r:   r8   r8   r8   r9   r^    s    r^  )+r5  os.pathospathr   dirname__file__xml.saxr   xml.sax.saxutilsr   r   xml.domr   opendocumentr   odf.namespacesr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  ContentHandlerr   r^  r8   r8   r8   r9   <module>   sH   X j         