make sure retval is not used uninitialized
[AROS-Contrib.git] / vpdf / mcc / outlineview_class.c
blob2c91c2e049a384bccfea57e3ee6c979a453d74f4
2 /// System includes
3 #define AROS_ALMOST_COMPATIBLE
4 #include <proto/muimaster.h>
5 #include <libraries/mui.h>
7 #include <libraries/asl.h>
8 #include <workbench/workbench.h>
10 #include <proto/exec.h>
11 #include <intuition/intuition.h>
12 #include <graphics/gfx.h>
13 #include <exec/libraries.h>
14 #include <proto/graphics.h>
15 #include <proto/intuition.h>
16 #include <proto/icon.h>
17 #include <dos/dos.h>
18 #include <proto/dos.h>
20 #include <stdlib.h>
21 #include <stdio.h>
22 #include <string.h>
23 #include <math.h>
25 #include <proto/alib.h>
26 #include <proto/utility.h>
28 #include <proto/datatypes.h>
29 #include <proto/dtclass.h>
30 #include <datatypes/pictureclass.h>
31 #include <devices/rawkeycodes.h>
33 #include <libraries/gadtools.h>
35 #if defined(__MORPHOS__)
36 #include <emul/emulregs.h>
37 #include <emul/emulinterface.h>
38 #endif
39 ////
41 #include <private/vapor/vapor.h>
42 #include <mui/Listtree_mcc.h>
44 #include "util.h"
45 #include "poppler.h"
46 #include "pageview_class.h"
47 #include "outlineview_class.h"
49 struct Data
51 void *doc;
52 struct MinList *outlineitems;
55 static void buildlist(Object *obj, struct MinList *outlineitems, APTR parentnode)
57 struct MinNode *n;
58 ITERATELIST(n, outlineitems)
60 APTR newparentnode = (APTR)DoMethod(obj, MUIM_Listtree_Insert,
61 "foo",
63 parentnode,
64 MUIV_Listtree_Insert_PrevNode_Tail,
65 outlineHasChildren(n) ? TNF_LIST : 0
68 if (outlineHasChildren(n))
69 buildlist(obj, outlineGetChildren(n), newparentnode);
73 MUI_HOOK(outline_displayfunc, STRPTR *array, struct MUIS_Listtree_TreeNode *tn)
75 if (tn != NULL)
77 struct MinNode *td = (struct MinNode*)tn->tn_User;
78 char *name = outlineGetTitle(td);
80 array[ 0 ] = name != NULL ? name : "---";
82 if ((ULONG)array[ -1 ] % 2)
83 array[-9] = (STRPTR)10;
85 else
87 array[ 0 ] = "";
90 return (0);
93 DEFNEW
95 obj = DoSuperNew(cl, obj,
96 MUIA_Listtree_DisplayHook, &outline_displayfunc_hook,
97 MUIA_Frame, MUIV_Frame_InputList,
98 TAG_MORE, INITTAGS);
100 if (obj != NULL)
102 GETDATA;
104 memset(data, 0, sizeof(struct Data));
105 data->doc = (void*)GetTagData(MUIA_OutlineView_Document, NULL, INITTAGS);
107 if (data->doc != NULL)
109 data->outlineitems = pdfGetOutlines(data->doc);
110 buildlist(obj, data->outlineitems, MUIV_Listtree_Insert_ListNode_Root);
112 else
116 /* notifications */
118 DoMethod(obj, MUIM_Notify, MUIA_Listtree_Active, MUIV_EveryTime, obj, 2, MUIM_OutlineView_NewEntrySelected, MUIV_TriggerValue);
122 return (ULONG)obj;
125 DEFDISP
127 return DOSUPER;
130 METHOD outlineviewNewEntrySelected(struct IClass *cl, Object *obj, struct MUIP_OutlineView_NewEntrySelected *msg)
132 GETDATA;
134 struct MUIS_Listtree_TreeNode *tn = msg->entry;
135 struct MinNode *td = (struct MinNode*)tn->tn_User;
136 int page = msg->entry > 0 ? outlineGetPage(td) : 0;
138 if (page != 0)
139 set(obj, MUIA_OutlineView_Page, page);
141 return 0;
144 DEFGET
146 GETDATA;
148 switch (msg->opg_AttrID)
150 case MUIA_OutlineView_Page:
151 return TRUE;
153 case MUIA_OutlineView_IsEmpty:
154 *(ULONG*)msg->opg_Storage = data->outlineitems == NULL || ISLISTEMPTY(data->outlineitems);
155 return TRUE;
159 return(DOSUPER);
162 BEGINMTABLE
163 DECNEW
164 DECDISP
165 DECGET
166 case MUIM_OutlineView_NewEntrySelected: return outlineviewNewEntrySelected(cl,obj,(APTR)msg);
167 ENDMTABLE
169 DECSUBCLASS_NC(MUIC_Listtree, OutlineViewClass)