2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
15 #include "api_scilab.h"
17 #include "localization.h"
18 #include "createGraphicObject.h"
19 #include "getGraphicObjectProperty.h"
20 #include "graphicObjectProperties.h"
21 #include "HandleManagement.h"
23 #include "expandPathVariable.h"
26 int sci_saveGui(char *fname, unsigned long fname_len)
37 char* pstFullFile = NULL;
42 int iRhs = nbInputArgument(pvApiCtx);
44 CheckInputArgument(pvApiCtx, 2, 3);
45 CheckOutputArgument(pvApiCtx, 1, 1);
47 sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr1);
50 printError(&sciErr, 0);
54 if (isHandleType(pvApiCtx, piAddr1) == 0 || isScalar(pvApiCtx, piAddr1) == 0)
56 Scierror(999, _("%s: Wrong size for input argument #%d: A single handle expected.\n"), fname, 1);
60 if (getScalarHandle(pvApiCtx, piAddr1, &hFig))
62 Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
66 iFig = getObjectFromHandle((long)hFig);
69 Scierror(999, _("%s: The handle is not or no more valid.\n"), fname);
73 getGraphicObjectProperty(iFig, __GO_TYPE__, jni_int, (void**)&piType);
74 if (piType == NULL || iType != __GO_FIGURE__)
76 Scierror(999, _("%s: Wrong type for input argument #%d: Figure handle expected.\n"), fname, 1);
80 sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddr2);
83 printError(&sciErr, 0);
87 if (isStringType(pvApiCtx, piAddr2) == 0 || isScalar(pvApiCtx, piAddr2) == 0)
89 Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, 2);
93 if (getAllocatedSingleString(pvApiCtx, piAddr2, &pstFile))
97 freeAllocatedSingleString(pstFile);
100 Scierror(202, _("%s: Wrong type for argument #%d: A string expected.\n"), fname, 2);
107 sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddr3);
110 printError(&sciErr, 0);
114 if (isBooleanType(pvApiCtx, piAddr3) == 0 || isScalar(pvApiCtx, piAddr3) == 0)
116 Scierror(999, _("%s: Wrong size for input argument #%d: A boolean expected.\n"), fname, 3);
120 if (getScalarBoolean(pvApiCtx, piAddr3, &bReserve))
122 Scierror(202, _("%s: Wrong type for argument #%d: A string expected.\n"), fname, 3);
127 pstFullFile = expandPathVariable(pstFile);
129 char* ret = xmlsave(iFig, pstFullFile, (BOOL) bReserve);
130 freeAllocatedSingleString(pstFile);
131 freeAllocatedSingleString(pstFullFile);
135 Scierror(202, _("%s: %s.\n"), fname, ret);
141 createScalarBoolean(pvApiCtx, iRhs + 1, 1);
142 AssignOutputVariable(pvApiCtx, 1) = iRhs + 1;
143 ReturnArguments(pvApiCtx);