a/src/filters/rclchm b/src/filters/rclchm
...
...
188
    one by one. The ipath is the node path"""
188
    one by one. The ipath is the node path"""
189
189
190
    def __init__(self, em):
190
    def __init__(self, em):
191
        self.contents = []
191
        self.contents = []
192
        self.chm = chm.CHMFile()
192
        self.chm = chm.CHMFile()
193
        self.currentindex = 0
194
        self.em = em
193
        self.em = em
195
        if rclchm_catenate:
194
        if rclchm_catenate:
196
            self.em.setmimetype("text/plain")
195
            self.em.setmimetype("text/plain")
197
        else:
196
        else:
198
            self.em.setmimetype(rclchm_html_mtype)
197
            self.em.setmimetype(rclchm_html_mtype)
...
...
238
237
239
    def openfile(self, params):
238
    def openfile(self, params):
240
        """Open the chm file and build the contents list by extracting and
239
        """Open the chm file and build the contents list by extracting and
241
        parsing the Topics object"""
240
        parsing the Topics object"""
242
241
243
        self.currentindex = 0
242
        self.currentindex = -1
244
        self.contents = []
243
        self.contents = []
245
        
244
        
246
        filename = params["filename:"]
245
        filename = params["filename:"]
247
        if not self.chm.LoadCHM(filename):
246
        if not self.chm.LoadCHM(filename):
248
            self.em.rclog("LoadCHM failed")
247
            self.em.rclog("LoadCHM failed")
249
            return False
248
            return False
250
251
        self.sfn = os.path.basename(filename)
252
249
253
        #self.em.rclog("home [%s] topics [%s] title [%s]" %
250
        #self.em.rclog("home [%s] topics [%s] title [%s]" %
254
        #              (self.chm.home, self.chm.topics, self.chm.title))
251
        #              (self.chm.home, self.chm.topics, self.chm.title))
255
252
256
        self.topics = self.chm.GetTopicsTree()
253
        self.topics = self.chm.GetTopicsTree()
...
...
291
            if alltxt:
288
            if alltxt:
292
                return (True, alltxt, "", rclexecm.RclExecM.eofnext)
289
                return (True, alltxt, "", rclexecm.RclExecM.eofnext)
293
            else:
290
            else:
294
                return (False, "", "", rclexecm.RclExecM.eofnow)
291
                return (False, "", "", rclexecm.RclExecM.eofnow)
295
292
293
        if self.currentindex == -1:
294
            # Return "self" doc
295
            self.currentindex = 0
296
            self.em.setmimetype('text/plain')
297
            if len(self.contents) == 0:
298
                eof = rclexecm.RclExecM.eofnext
299
            else:
300
                eof = rclexecm.RclExecM.noteof
301
            return (True, "", "", eof)
302
296
        if self.currentindex >= len(self.contents):
303
        if self.currentindex >= len(self.contents):
297
            return (False, "", "", rclexecm.RclExecM.eofnow)
304
            return (False, "", "", rclexecm.RclExecM.eofnow)
298
        else:
305
        else:
299
            ret= self.extractone(self.contents[self.currentindex])
306
            ret= self.extractone(self.contents[self.currentindex])
300
            self.currentindex += 1
307
            self.currentindex += 1