bring back error checking removed by https://codereview.scilab.org/#/c/16673/
[scilab.git] / scilab / modules / graphics / src / c / getHandleProperty / get_mark_foreground_property.c
1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2004-2006 - INRIA - Fabrice Leray
4  * Copyright (C) 2006 - INRIA - Allan Cornet
5  * Copyright (C) 2006 - INRIA - Jean-Baptiste Silvy
6  * Copyright (C) 2010 - DIGITEO - Manuel Juliachs
7  * Copyright (C) 2011 - DIGITEO - Vincent Couvert
8  *
9  * This file must be used under the terms of the CeCILL.
10  * This source file is licensed as described in the file COPYING, which
11  * you should have received as part of this distribution.  The terms
12  * are also available at
13  * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
14  *
15  */
16
17 /*------------------------------------------------------------------------*/
18 /* file: get_mark_foreground_property.c                                   */
19 /* desc : function to retrieve in Scilab the mark_foreground field of a   */
20 /*        handle                                                          */
21 /*------------------------------------------------------------------------*/
22
23 #include <stdlib.h>
24
25 #include "getHandleProperty.h"
26 #include "GetProperty.h"
27 #include "returnProperty.h"
28 #include "Scierror.h"
29 #include "localization.h"
30
31 #include "getGraphicObjectProperty.h"
32 #include "graphicObjectProperties.h"
33
34 /*------------------------------------------------------------------------*/
35 int get_mark_foreground_property(void* _pvCtx, int iObjUID)
36 {
37     int iMarkForeground = 0;
38     int* piMarkForeground = &iMarkForeground;
39
40     int * markForegrounds = NULL;
41     int numMarkForegrounds = 0;
42     int * piNumMarkForegrounds = &numMarkForegrounds;
43
44     getGraphicObjectProperty(iObjUID, __GO_NUM_MARK_FOREGROUNDS__, jni_int, (void**)&piNumMarkForegrounds);
45
46     if (piNumMarkForegrounds == NULL)
47     {
48         Scierror(999, _("'%s' property does not exist for this handle.\n"), "mark_foreground");
49         return -1;
50     }
51
52     if (numMarkForegrounds == 0)
53     {
54         getGraphicObjectProperty(iObjUID, __GO_MARK_FOREGROUND__, jni_int, &piMarkForeground);
55         return sciReturnDouble(_pvCtx, iMarkForeground);
56     }
57     else
58     {
59         getGraphicObjectProperty(iObjUID, __GO_MARK_FOREGROUNDS__, jni_int_vector, &markForegrounds);
60         return sciReturnRowVectorFromInt(_pvCtx, markForegrounds, numMarkForegrounds);
61     }
62 }
63 /*------------------------------------------------------------------------*/