0cd8a301a38524de14eb6f195f103c77d15bbae6
[scilab.git] / scilab / modules / graphic_export / sci_gateway / c / gw_graphic_export.c
1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2008 - INRIA - Allan CORNET
4  * Copyright (C) 2008 - INRIA - Jean-Baptiste SILVY
5  *
6  * 
7  * This file must be used under the terms of the CeCILL.
8  * This source file is licensed as described in the file COPYING, which
9  * you should have received as part of this distribution.  The terms
10  * are also available at    
11  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
12  *
13  */
14
15 #include <string.h>
16 #include "gw_graphic_export.h"
17 #include "api_scilab.h"
18 #include "MALLOC.h"
19 #include "scilabmode.h"
20 #include "callFunctionFromGateway.h"
21 #include "localization.h"
22 #include "Scierror.h"
23 #include "BOOL.h"
24 #include "loadOnUseClassPath.h"
25 /*--------------------------------------------------------------------------*/
26 static BOOL loadedDep = FALSE;
27 static BOOL loadedDepVectorialExport = FALSE;
28 /*--------------------------------------------------------------------------*/
29 static gw_generic_table Tab[] = 
30 {
31   {sci_xs2bmp,"xs2bmp"},
32   {sci_xs2gif,"xs2gif"},
33   {sci_xs2jpg,"xs2jpg"},
34   {sci_xs2png,"xs2png"},
35   {sci_xs2ppm,"xs2ppm"},
36   {sci_xs2eps,"xs2eps"},
37   {sci_xs2pdf,"xs2pdf"},
38   {sci_xs2svg,"xs2svg"},
39   {sci_xs2ps,"xs2ps"}
40 };
41 /*--------------------------------------------------------------------------*/
42 int gw_graphic_export(void)
43 {  
44         Rhs = Max(0, Rhs);
45
46         if(pvApiCtx == NULL)
47         {
48                 pvApiCtx = (StrCtx*)MALLOC(sizeof(StrCtx));
49         }
50
51         pvApiCtx->pstName = (char*)Tab[Fin-1].name;
52
53     if ( getScilabMode() != SCILAB_NWNI )
54         {
55                 if (!loadedDep) 
56                 {
57                         loadOnUseClassPath("graphics");
58                         loadedDep=TRUE;
59                 }
60                 if (!loadedDepVectorialExport && (strcmp(Tab[Fin-1].name, "xs2eps")==0
61                            || strcmp(Tab[Fin-1].name, "xs2pdf")==0
62                            || strcmp(Tab[Fin-1].name, "xs2svg")==0
63                            || strcmp(Tab[Fin-1].name, "xs2ps")==0))
64           {
65             loadOnUseClassPath("pdf_ps_eps_graphic_export");
66             loadedDepVectorialExport = TRUE;
67           }
68
69                 callFunctionFromGateway(Tab, SIZE_CURRENT_GENERIC_TABLE(Tab));
70         }
71         else
72         {
73                 Scierror(999,_("Scilab graphic module disabled -nogui or -nwni mode.\n"));
74         }
75         return 0;
76 }
77 /*--------------------------------------------------------------------------*/