<pathelement path="../starter/build/jars"/>
<fileset dir="../core/lib" includes="*.jar"/>
<pathelement path="../core/build/classes"/>
+ <pathelement path="../xml-marshall/build/classes"/>
</classpath>
</javac>
<copy todir="build/classes">
xsi:noNamespaceSchemaLocation="../../defs/technical-component-definition.xsd">
<name>cg-etat</name>
<description>Configuration Compte de Gestion Etat</description>
- <release>5.0.0.5</release>
+ <release>5.0.0.6</release>
<url>http://xemelios.org/updatesV5/cg-etat</url>
<type>CONFIG</type>
<destination>
<component-ref url="http://xemelios.org/updatesV5/core" release="5.0.0.6"/>
</requires>
<release-notes>
+ <release v="5.0.0.6">
+ <note visibility="public">Génération PDF à la volée</note>
+ </release>
<release v="5.0.0.5">
<note visibility="public">Correction de feuilles de style</note>
</release>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.xemelios.org/namespaces#cge" xmlns:n="http://www.xemelios.org/namespaces#cge" version="2.0">
<xsl:template name="style">
<style type="text/css" media="all">
- body {font-family: verdana, sans-serif; font-size: 12px; }
-
- .numPage {font-family: verdana, sans-serif; font-size: 12px; }
- /*.numCompte { position:absolute; left: 10em; font-size: 14px; font-weight: bold;}*/
-
- h1 { font-size: 20px; color: #003535; font-weight: bold; }
- h2 { font-size: 14px; color: #004545; text-align: center;}
- h3 { font-size: 12px; color: #005555; text-align: center;}
-
- span {font-size: 18px; font-weight: bold;}
-
- span a:link {color: #0000FF; font-size: 18px; font-weight: bold; font-style: underline;}
- span a:visited {color: #0000FF; font-size: 18px; font-weight: bold; font-style: underline;}
-
table#main {border-spacing: 0px; background-color: white; border: #000000 solid 2px;border-collapse: collapse; }
table#mainBorderedNot {border-spacing: 0px; background-color: white; border: #000000 none 2px; border-collapse: collapse; }
-
.bordered { border: #000000 solid 1px;}
.borderedBold { border: #000000 solid 2px;}
.borderedNotBottom { border-top: #000000 solid 1px ; border-left: #000000 solid 1px ; border-right: #000000 solid 1px ;}
.borderedNotLeft { border-top: #000000 solid 1px ; border-bottom: #000000 solid 1px ; border-right: #000000 solid 1px ;}
.borderedNotRight { border-top: #000000 solid 1px ; border-bottom: #000000 solid 1px ; border-left: #000000 solid 1px ;}
-
b.negative { color: red;}
tr#highlighted td a { font-weight: bold; }
tr#highlighted td a:hover { color: #FF4000; }
- tr.paddingLeft td { padding-left: 20px;}
-
- tr.total td { font-weight:bold; font-size: 12px;}
- tr.total td a { font-weight: bold; font-size: 12px;}
- tr.total td a:hover { color: #FF4000; font-size: 12px;}
-
- tr.Total td { font-weight:bold; font-size: 12px;}
- tr.Total td a { font-weight: bold; font-size: 12px;}
- tr.Total td a:hover { color: #FF4000; font-size: 12px;}
-
- td.totalAnnexeII1 { background-color: #FFFF9A; font-size: 13px;}
- td.totalAnnexeII { color: navy; background-color: #FFFFBB; font-size: 12px;}
-
- tr.NotTotal td{ font-size: 12.5px;}
-
a:link { color: #0000FF; background: transparent; }
a:visited { color: #FF3ABA; background: transparent; }
td#padding70 { padding-left: 200px;}
td#padding77 { padding-left: 220px;}
- a {font-size: 12.5px;}
a.precsuiv { color: #0000FF; background: transparent; font-style: normal; text-decoration: none;}
a.sommaire:visited { color: #0000FF; background: transparent; font-style: normal;}
td.bold { font-weight:bold; }
td.montant { white-space: nowrap;text-align: right;}
- td.titre { font-size: 12px;}
- td.titre2 { font-size: 11px;}
- td.titre3 { font-size: 10px;}
-
- td.libelleLigne { text-align: right; font-size: 12px; }
- td.libelleLigne2 { text-align: right; font-size: 10px; }
td.font { background-color: #FFFFFF; }
td#message { border: red solid 2px; text-align: center; v-align: middle; color: red; width: 50%;}
- caption { color: navy; font-size: 12px; font-weight: bold;}
- label { font-size: 11px; font-weight: bold;}
+ /* ici */
img {border: none;}
.navigate {display: block;}
.showPrint { display: none;}
</style>
+ <style type="text/css" media="screen">
+ .numPage {font-family: verdana, sans-serif; font-size: 12px; }
+ /*.numCompte { position:absolute; left: 10em; font-size: 14px; font-weight: bold;}*/
+
+ h1 { font-size: 20px; color: #003535; font-weight: bold; }
+ h2 { font-size: 14px; color: #004545; text-align: center;}
+ h3 { font-size: 12px; color: #005555; text-align: center;}
+
+ span {font-size: 18px; font-weight: bold;}
+
+ span a:link {color: #0000FF; font-size: 18px; font-weight: bold; font-style: underline;}
+ span a:visited {color: #0000FF; font-size: 18px; font-weight: bold; font-style: underline;}
+ tr.paddingLeft td { padding-left: 20px;}
+
+ tr.total td { font-weight:bold; font-size: 12px;}
+ tr.total td a { font-weight: bold; font-size: 12px;}
+ tr.total td a:hover { color: #FF4000; font-size: 12px;}
+
+ tr.Total td { font-weight:bold; font-size: 12px;}
+ tr.Total td a { font-weight: bold; font-size: 12px;}
+ tr.Total td a:hover { color: #FF4000; font-size: 12px;}
+
+ td.totalAnnexeII1 { background-color: #FFFF9A; font-size: 13px;}
+ td.totalAnnexeII { color: navy; background-color: #FFFFBB; font-size: 12px;}
+
+ tr.NotTotal td{ font-size: 12.5px;}
+
+ a {font-size: 12.5px;}
+
+ td.titre { font-size: 12px;}
+ td.titre2 { font-size: 11px;}
+ td.titre3 { font-size: 10px;}
+
+ td.libelleLigne { text-align: right; font-size: 12px; }
+ td.libelleLigne2 { text-align: right; font-size: 10px; }
+
+ caption { color: navy; font-size: 12px; font-weight: bold;}
+ label { font-size: 11px; font-weight: bold;}
+ </style>
<style type="text/css" media="print">
- /*@page { size: 297mm 210mm; @bottom-center { content: "Page " counter(page) " / " counter(pages); } }*/
- /*@page { font-family: verdana; font-size: 10px; size: 445mm 315mm; @bottom-right { content: counter(page) " / " counter(pages); } }*/
+ body {font-family: verdana, sans-serif; font-size: 8px; }
+ .numPage {font-family: verdana, sans-serif; font-size: 12px; }
+ /*.numCompte { position:absolute; left: 10em; font-size: 14px; font-weight: bold;}*/
+
+ h1 { font-size: 18px; color: #003535; font-weight: bold; }
+ h2 { font-size: 12px; color: #004545; text-align: center;}
+ h3 { font-size: 10px; color: #005555; text-align: center;}
+
+ span {font-size: 16px; font-weight: bold;}
+
+ span a:link {color: #0000FF; font-size: 16px; font-weight: bold; font-style: underline;}
+ span a:visited {color: #0000FF; font-size: 16px; font-weight: bold; font-style: underline;}
+
+ tr.paddingLeft td { padding-left: 18px;}
+
+ tr.total td { font-weight:bold; font-size: 10px;}
+ tr.total td a { font-weight: bold; font-size: 10px;}
+ tr.total td a:hover { color: #FF4000; font-size: 10px;}
+
+ tr.Total td { font-weight:bold; font-size: 10px;}
+ tr.Total td a { font-weight: bold; font-size: 10px;}
+ tr.Total td a:hover { color: #FF4000; font-size: 10px;}
+
+ td.totalAnnexeII1 { background-color: #FFFF9A; font-size: 11px;}
+ td.totalAnnexeII { color: navy; background-color: #FFFFBB; font-size: 10px;}
+
+ tr.NotTotal td { font-size: 7px;}
+
+ a {font-size: 10px;}
+
+ td.titre { font-size: 10px;}
+ td.titre2 { font-size: 9px;}
+ td.titre3 { font-size: 8px;}
+
+ td.libelleLigne { text-align: right; font-size: 10px; }
+ td.libelleLigne2 { text-align: right; font-size: 8px; }
+
+ caption { color: navy; font-size: 10px; font-weight: bold;}
+ label { font-size: 9px; font-weight: bold;}
.formulaire {display: none;}
.navigate {display: none;}
a {text-decoration: none;color: black;}
- body {font-size: 10px;}
-
table#main {width=100%; border-spacing: 0px; background-color: white; border: #000000 solid 2px;border-collapse: collapse; -fs-table-paginate: paginate;}
table#mainBorderedNot {border-spacing: 0px; background-color: white; border: #000000 none 2px; border-collapse: collapse; -fs-table-paginate: paginate;}
<head>
<title><xsl:text>Compte de Gestion Etat : Comptable </xsl:text><xsl:value-of select="/n:CompteGestionEtat/n:Entete/n:Infos/n:Collectivite/@Libelle"/> (<xsl:value-of select="/n:CompteGestionEtat/n:Entete/n:Infos/n:Collectivite/@Siret"/>)</title>
<style type="text/css" media="all">
- body { font-family: verdana; font-size: 10px; width: 99%; }
-
h1 { font-family: verdana, sans-serif; font-size: 24px; color: black; text-align: center; }
h2 { font-family: verdana, sans-serif; font-size: 21px; text-align: center; }
h3 { font-family: verdana, sans-serif; font-size: 16px; text-align: center; }
tr { page-break-inside: avoid; }
img {border: none;}
</style>
+ <style type="text/css" media="screen">
+ body { font-family: verdana; font-size: 10px; width: 99%; }
+ </style>
<style type="text/css" media="print">
@page { font-family: verdana; font-size: 10px; size: 375mm 270mm; @bottom-right { content: counter(page) " / " counter(pages); } }
a {text-decoration: none;color: black;}
+ body { font-family: verdana; font-size: 8px; width; 99%; }
</style>
-
-
-
- <!--xsl:call-template name="Error"/-->
<script>
function hideDialog() {
var dialogBox = document.getElementById("dialogBox");
dialogBox.style.visibility = "visible";
}
</script>
+ <script type="text/javascript" src="xemelios:js/js/getPdf.js"></script>
<div id="dialogBox" style="visibility: hidden; position: absolute; left: 10px; top: 10px; width: 800px; height: 100px; border-style: solid; border-width: 1px; border-color: #00006A; background-color: white; z-index: 1000;">
<table border="0" width="100%">
<tr>
</div>
</head>
<body>
- <xsl:if test="$error.message!='nomessage'">
- <xsl:attribute name="onload">javascript:showDialog('<xsl:value-of select="$error.message"/>');</xsl:attribute>
- </xsl:if>
- <!--h1>Table des matières</h1-->
+ <xsl:if test="$error.message!='nomessage'">
+ <xsl:attribute name="onload">javascript:showDialog('<xsl:value-of select="$error.message"/>');</xsl:attribute>
+ </xsl:if>
<xsl:apply-templates/>
</body>
</html>
<xsl:when test="@Etat='BalanceGenerale'">
<tr>
<td class="c1">
- <a class="nopadding"><xsl:variable name="collectivite" select="/n:CompteGestionEtat/n:Entete/n:Infos/n:Collectivite/@Siret"/>
+ <xsl:variable name="collectivite" select="/n:CompteGestionEtat/n:Entete/n:Infos/n:Collectivite/@Siret"/>
<xsl:variable name="budget" select="/n:CompteGestionEtat/n:Entete/n:Infos/n:Collectivite/@CodeBudget"/>
<xsl:variable name="exercice" select="/n:CompteGestionEtat/n:Entete/n:Infos/n:Collectivite/@Exercice"/>
- <xsl:attribute name="href">xemelios:/attachment?pjId=<xsl:value-of select="concat('CompteGestionEtat-BalanceGenerale-',$collectivite,'-',$budget,'-',$exercice,'.pdf')"/>&collectivite=<xsl:value-of select="$collectivite"/></xsl:attribute>
- <img src="xemelios:/resource?pdf-compteGestionEtat-BalanceGenerale.png"/></a></td>
+ <a class="nopadding" href="javascript:getPdf('xemelios:/generatePdf?docId=cg-etat&etatId=BalanceGenerale&collectivite={$collectivite}&budget={$budget}&sp1={$exercice}',{/n:CompteGestionEtat/n:Entete/n:Infos/n:Sommaire/n:LigneSommaire[@Code='BalanceGenerale']/(@LastPage - @FirstPage)})">
+ <img src="xemelios:/resource?pdf-compteGestionEtat-BalanceGenerale.png"/>
+ </a>
+ </td>
<td class="c2">
<xsl:text disable-output-escaping="yes"><![CDATA[<a href="xemelios:/query?docId=]]></xsl:text><xsl:choose>
<xsl:when test="name(/child::node()[1])='CompteGestionEtat'">cg-etat</xsl:when>
</xsl:when>
<xsl:otherwise>
<tr>
- <td class="c1"> </td>
+ <td class="c1">
+ <xsl:variable name="collectivite" select="/n:CompteGestionEtat/n:Entete/n:Infos/n:Collectivite/@Siret"/>
+ <xsl:variable name="budget" select="/n:CompteGestionEtat/n:Entete/n:Infos/n:Collectivite/@CodeBudget"/>
+ <xsl:variable name="exercice" select="/n:CompteGestionEtat/n:Entete/n:Infos/n:Collectivite/@Exercice"/>
+ <a class="nopadding" href="javascript:getPdf('xemelios:/generatePdf?docId=cg-etat&etatId={$Etat}&collectivite={$collectivite}&budget={$budget}&sp1={$exercice}',{/n:CompteGestionEtat/n:Entete/n:Infos/n:Sommaire/n:LigneSommaire[@Code=$Etat]/(@LastPage - @FirstPage)})">
+ <img src="xemelios:/resource?pdf-compteGestionEtat-BalanceGenerale.png"/>
+ </a>
+ </td>
<td class="c2">
<xsl:text disable-output-escaping="yes"><![CDATA[<a href="xemelios:/query?docId=]]></xsl:text><xsl:choose>
<xsl:when test="name(/child::node()[1])='CompteGestionEtat'">cg-etat</xsl:when>
--- /dev/null
+/*
+ * Copyright
+ * 2011 axYus - http://www.axyus.com
+ * 2011 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS_NB.
+ *
+ * XEMELIOS_NB is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * XEMELIOS_NB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with XEMELIOS_NB; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+package fr.gouv.finances.dgfip.xemelios.cge.generators;
+
+import fr.gouv.finances.dgfip.utils.IoUtils;
+import fr.gouv.finances.dgfip.utils.Xslt;
+import fr.gouv.finances.dgfip.utils.xml.FactoryProvider;
+import fr.gouv.finances.dgfip.utils.xml.transform.CustomURIResolver;
+import fr.gouv.finances.dgfip.xemelios.auth.XemeliosUser;
+import fr.gouv.finances.dgfip.xemelios.common.config.DocumentModel;
+import fr.gouv.finances.dgfip.xemelios.common.config.ElementModel;
+import fr.gouv.finances.dgfip.xemelios.common.config.EtatModel;
+import fr.gouv.finances.dgfip.xemelios.common.generators.AbstractPdfGenerator;
+import fr.gouv.finances.dgfip.xemelios.common.generators.GeneratingError;
+import fr.gouv.finances.dgfip.xemelios.data.DataLayerManager;
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathFactory;
+import org.apache.log4j.Logger;
+import org.w3c.dom.Document;
+import org.xhtmlrenderer.context.StyleReference;
+import org.xhtmlrenderer.pdf.ITextRenderer;
+
+/**
+ *
+ * @author cmarchand
+ */
+public class GenericGenerator extends AbstractPdfGenerator {
+ private static final Logger logger = Logger.getLogger(GenericGenerator.class);
+ private XPathFactory xpf = null;
+
+
+ public GenericGenerator(XemeliosUser user, DocumentModel dm, EtatModel em, ElementModel elm, String coll, String budg, String exer) {
+ super(user, dm, elm, em, coll, budg, exer);
+ xpf = FactoryProvider.getXPathFactory();
+ }
+
+ @Override
+ public void run(OutputStream os) throws GeneratingError {
+ String xpath=getGenerationRequest().getEtatModel().getImportableElement().getPath().getPath()+"[n:Pied/@NumPage='1']";
+ XPath xp = xpf.newXPath();
+ xp.setNamespaceContext(getGenerationRequest().getDocumentModel().getNamespaces());
+ try {
+ ArrayList<String> documents = DataLayerManager.getImplementation().getDocumentListFromXPath(getGenerationRequest().getElementModel(), getGenerationRequest().getCollectivite(), getGenerationRequest().getBudget(), getGenerationRequest().getExercice(), null, null, xpath, getGenerationRequest().getUser());
+ if(documents.size()==1) {
+ Document dom = DataLayerManager.getImplementation().getDocumentAsDom(getGenerationRequest().getEtatModel(), getGenerationRequest().getpCollectivite(), getGenerationRequest().getpBudget(), documents.get(0), getGenerationRequest().getUser());
+ int first = 1;
+ ITextRenderer renderer = new ITextRenderer();
+ PdfGeneratorAgentCallback callback = new PdfGeneratorAgentCallback(renderer.getOutputDevice());
+ callback.setSharedContext(renderer.getSharedContext());
+ renderer.getSharedContext().setUserAgentCallback(callback);
+ StyleReference css = new StyleReference(callback);
+ renderer.getSharedContext().setCss(css);
+ File xslFile = Xslt.getFile(getGenerationRequest().getDocumentModel(), getGenerationRequest().getEtatModel(), getGenerationRequest().getElementModel(), dom);
+ InputStream is = IoUtils.getInputStream(xslFile.getPath());
+
+ TransformerFactory tFactory = FactoryProvider.getTransformerFactory();
+ tFactory.setURIResolver(new CustomURIResolver(tFactory.getURIResolver(),xslFile.getParentFile().toURI().toURL().toExternalForm()));
+ Transformer tr = tFactory.newTransformer(new StreamSource(is));
+ tr.setParameter("browser-destination", getGenerationRequest().getEtatModel().useExternalBrowser() ? "external" : "internal");
+ // on passe la nomenclature en parametre
+ // on recupere l'ID de la nomenclature
+ String idRepository = null;
+ if (getGenerationRequest().getDocumentModel().getReferenceNomenclaturePath() != null && getGenerationRequest().getDocumentModel().getReferenceNomenclaturePath().getCodePath() != null) {
+ idRepository = (String) xp.evaluate(getGenerationRequest().getDocumentModel().getReferenceNomenclaturePath().getCodePath().getPath(), dom.getDocumentElement(), XPathConstants.STRING);
+ }
+ if (idRepository != null && idRepository.length() == 0) {
+ idRepository = null;
+ }
+ Document repository = DataLayerManager.getImplementation().getRepositoryAsDom(getGenerationRequest().getDocumentModel(), getGenerationRequest().getpCollectivite(), idRepository, getGenerationRequest().getUser());
+ if (repository != null) {
+ tr.setParameter("repository", repository);
+ }
+ // on passe la config
+ tr.setParameter("config", getGenerationRequest().getDocumentModel().getParent().getSmallDOM());
+ tr.setParameter("collectivite", getGenerationRequest().getCollectivite());
+ tr.setParameter("budget", getGenerationRequest().getBudget());
+
+ boolean isFirstPage = true;
+ while(true) {
+ xpath=getGenerationRequest().getElementModel().getPath().getPath()+"[n:Pied/@NumPage='"+first+"']";
+ first++;
+ documents = DataLayerManager.getImplementation().getDocumentListFromXPath(getGenerationRequest().getElementModel(), getGenerationRequest().getCollectivite(), getGenerationRequest().getBudget(), getGenerationRequest().getExercice(), null, null, xpath, getGenerationRequest().getUser());
+ if(documents.isEmpty()) break;
+ Document doc = DataLayerManager.getImplementation().getDocumentAsDom(getGenerationRequest().getEtatModel(), getGenerationRequest().getpCollectivite(), getGenerationRequest().getpBudget(), documents.get(0), getGenerationRequest().getUser());
+ DOMResult result = new DOMResult();
+ tr.transform(new DOMSource(doc), result);
+ Document xhtml = (Document) result.getNode();
+ renderer.setDocument(xhtml, "doc.xhtml");
+ renderer.layout();
+ if (isFirstPage) {
+ renderer.createPDF(os, false);
+ isFirstPage = false;
+ } else {
+ renderer.writeNextDocument();
+ }
+ }
+ renderer.finishPDF();
+ os.flush(); os.close();
+ } else {
+ logger.error("ai trouvé "+documents.size()+" page 1");
+ throw new GeneratingError("ai trouvé "+documents.size()+" page 1");
+ }
+ } catch(Exception ex) {
+ throw new GeneratingError(ex);
+ }
+ }
+
+}