Project

General

Profile

root / branches / sc50-v2.0 / sources2-0-011 / academic / gen / paper / transf / binaries / latex / getPng.odwidget @ 322

1
<?xml version="1.0"?>
2
<sm:freeOdWidget xmlns:sm="http://www.utc.fr/ics/scenari/v3/modeling" code="mathTexInline">
3
	<sm:widgetBsFragment contentFormat="od">&lt;source type="xslOnSrc-dynamique"&gt;
4
&lt;xsl:stylesheet version="1.0"
5
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
6
	xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
7
	xmlns:sp="http://www.utc.fr/ics/scenari/v3/primitive"
8
	xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
9
	xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
10
	xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
11
	xmlns:sl="http://www.utc.fr/ics/scenari/v3/library"
12
	xmlns:fo="http://www.w3.org/1999/XSL/Format"
13
	xmlns:xlink="http://www.w3.org/1999/xlink"
14
	xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
15
	xmlns:java="http://xml.apache.org/xslt/java"
16
	xmlns:scodPp="scenari.eu:openDocumentExtension.postprocessing:1.0"
17
	xmlns:scod="scenari.eu:openDocumentExtension:1.0"
18
	xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
19
	xmlns:sc="http://www.utc.fr/ics/scenari/v3/core"
20
	exclude-result-prefixes="table sp office draw style svg sl fo xlink java scodPp scod text sc "&gt;
21
	&lt;xsl:output omit-xml-declaration="yes" indent="no" method="xml" /&gt;
22
	&lt;xsl:param name="vAgent" /&gt;
23
	&lt;xsl:param name="vDialog" /&gt;
24
	&lt;xsl:variable select="getIdNode(.)" name="idRootAgt" /&gt;
25
	&lt;xsl:template match="*"&gt;
26
		&lt;xsl:variable name="vInfosRes" select="computeStrAgent('viewResource/genResSize')"/&gt;
27
        &lt;xsl:variable name="vWidth" select="substring-before(substring-after($vInfosRes, 'w='), ';')"/&gt;
28
        &lt;xsl:variable name="vHeight" select="substring-before(substring-after($vInfosRes, 'h='), ';')"/&gt;
29
        &lt;xsl:variable name="vExistRes" select="boolean($vInfosRes)"/&gt;
30
        
31
        &lt;xsl:comment&gt; ### IMAGE ### infores : &lt;xsl:copy-of select="$vInfosRes"/&gt;&lt;/xsl:comment&gt;
32
        &lt;xsl:choose&gt;
33
            &lt;xsl:when test="$vExistRes"&gt;
34
                &lt;draw:frame 
35
                    svg:height="{normalize-space($vHeight)}cm" 
36
                    svg:width="{normalize-space($vWidth)}cm"
37
                    svg:y="-{normalize-space(computeStrAgent('viewResource/Dep'))}cm"
38
                    svg:x="0cm"
39
                    draw:z-index="{getEntryBuffer('odStyleBlocks', '_globalsStyles_viewPicture')/text:p/draw:frame/@draw:z-index}"
40
                    text:anchor-type="as-char"
41
                    draw:style-name="{getEntryBuffer('odStyleBlocks', '_globalsStyles_viewPicture')/text:p/draw:frame/@draw:style-name}"
42
                    draw:name="{local-name()}"&gt;
43
                    &lt;draw:image&gt;
44
                        &lt;xsl:attribute name="scod:src"&gt;
45
                            &lt;xsl:value-of select="concat('dest:', computeStrAgent('viewResource/genResUri'))" /&gt;
46
                        &lt;/xsl:attribute&gt;
47
                        &lt;xsl:attribute name="xlink:type"&gt;simple&lt;/xsl:attribute&gt;
48
                        &lt;xsl:attribute name="xlink:show"&gt;embed&lt;/xsl:attribute&gt;
49
                        &lt;xsl:attribute name="xlink:actuate"&gt;onLoad&lt;/xsl:attribute&gt;
50
                    &lt;/draw:image&gt;
51
                &lt;/draw:frame&gt;
52
            &lt;/xsl:when&gt;
53
            &lt;xsl:otherwise&gt;
54
                &lt;scodPp:error text="Ressource manquante" phase="generation" type="error"&gt;La ressource '&lt;xsl:value-of select="computeStrAgent('viewResource/outFileName')"/&gt;' est introuvable.&lt;/scodPp:error&gt;
55
            &lt;/xsl:otherwise&gt;
56
        &lt;/xsl:choose&gt;
57
	&lt;/xsl:template&gt;
58
	
59
&lt;/xsl:stylesheet&gt;
60
&lt;/source&gt;
61

    
62
&lt;set code="viewResource"&gt;
63
	&lt;!-- parametres --&gt;
64
	&lt;valeur code="maxWidth"&gt;&lt;source&gt;10&lt;/source&gt;&lt;/valeur&gt;
65
	&lt;valeur code="maxHeight"&gt;&lt;source&gt;6&lt;/source&gt;&lt;/valeur&gt;
66
	&lt;valeur code="scale"&gt;&lt;source&gt;1.2&lt;/source&gt;&lt;/valeur&gt;
67

    
68
	&lt;valeur code="outFileName"&gt;
69
		&lt;source type="xpathOnSrc-dynamique"&gt;
70
				concat('agt',alphaHash(codeAgent('//')),'_',java:com.scenari.s.fw.utils.HCharSeqUtil.stringWithoutAccent(java:getSrcName(srcFileAgent())))
71
		&lt;/source&gt;
72
	&lt;/valeur&gt;
73
	&lt;valeur code="odResPath"&gt;
74
		&lt;source type="xpathOnSrc-dynamique"&gt;
75
			concat(computeStrAgent('/@@/pathBinaryInOdFile'), '/', extractFileNameFromPath(computeStrAgent('../genResUri')))
76
		&lt;/source&gt;
77
	&lt;/valeur&gt;
78
	&lt;valeur code="genResUri"&gt;
79
		&lt;source type="xpathOnSrc-dynamique"&gt;computeStrAgent('//', concat(
80
					'resUri:src=src:', java:getSrcUri(srcFileAgent()),
81
					';transform=latex2img&amp;amp;resolution=300&amp;amp;scale=',computeStrAgent('../scale'),
82
				'&amp;amp;;mutabledst=', computeStrAgent('/@@/destPathBinaryTmp'), '/', computeStrAgent('../outFileName'),
83
				''
84
				))
85
		&lt;/source&gt;
86
	&lt;/valeur&gt;
87
	&lt;valeur code="genResSize"&gt;
88
		&lt;source type="xpathOnSrc-dynamique"&gt;
89
				computeStrAgent('//', concat('get:src:',java:getSrcUri(srcFileAgent()), '?',
90
				'transform=latex2img&amp;amp;resolution=300&amp;amp;scale=',computeStrAgent('../scale'),'&amp;amp;transform=img2img&amp;amp;sizeRules=Dim(Sc(ratio''1''srcDpi''300'')Bounds(unit''cm''maxW''',computeStrAgent('../maxWidth'),'''maxH''',computeStrAgent('../maxHeight'),'''))&amp;amp;outType=DIMS&amp;amp;outRules='
91
				, "Str(pattern'w=!wcm;h=!hcm;r=!rot(y,n);')"))
92
		&lt;/source&gt;
93
	&lt;/valeur&gt;
94

    
95

    
96
      &lt;valeur code="Dep"&gt;
97
            &lt;source type="xpath-dynamique"&gt;( 1 - number(computeStrAgent('//', concat('get:src:', java:getSrcUri(srcFileAgent()), '?transform=latex2img&amp;amp;resolution=300&amp;amp;scale=',computeStrAgent('../scale'), '&amp;amp;outType=DIMS&amp;amp;outRules=Str(pattern''!dpc'')')))) * number(substring-before(substring-after(computeStrAgent('../genResSize'), 'h='), ';'))&lt;/source&gt;
98
      &lt;/valeur&gt;
99

    
100

    
101
&lt;/set&gt;
102
</sm:widgetBsFragment>
103
</sm:freeOdWidget>
(1-1/4)