예제 #1
0
 def index_ixtl(self, ixlrs):
     kwargs = {'table_id': 3, 'rec_sz': 4, 'records': []}
     ixlrs = [] + ixlrs
     ixlrs.reverse()
     for item in ixlrs:
         kwargs['records'].append(item.get_offset())
     indx = self.cmx_model.chunk_map['indx']
     ixtl = cmx_model.make_cmx_chunk(self.cmx_cfg,
                                     identifier=cmx_const.IXTL_ID,
                                     **kwargs)
     indx.add(ixtl)
     return ixtl
예제 #2
0
    def parse(self, chunk_size):
        position = self.fileptr.tell()
        while self.fileptr.tell() - position < chunk_size:
            dwords, size = self.read_header()

            if not dwords[2]:
                dwords.append(self.fileptr.read(size))

            node = cmx_model.make_cmx_chunk(self.config, ''.join(dwords))
            self.parent_stack[-1].add(node)

            if dwords[2]:
                self.parent_stack.append(node)
                self.parse(size)
                self.parent_stack = self.parent_stack[:-1]
예제 #3
0
 def index_ixpg(self, ixlrs):
     kwargs = {'rec_sz': 16, 'records': []}
     cmx_pages = self.cmx_model.chunk_map['pages']
     index = 0
     for page in cmx_pages:
         page_offset = page[0].get_offset()
         ixl_offset = ixlrs[index].get_offset()
         thmb_offset = 0xffffffff
         ref_offset = page[1].get_offset()
         kwargs['records'].append(
             (page_offset, ixl_offset, thmb_offset, ref_offset))
     indx = self.cmx_model.chunk_map['indx']
     ixpg = cmx_model.make_cmx_chunk(self.cmx_cfg,
                                     identifier=cmx_const.IXPG_ID,
                                     **kwargs)
     indx.add(ixpg)
     return ixpg
예제 #4
0
    def parse(self, chunk_size):
        position = self.fileptr.tell()
        while self.fileptr.tell() - position < chunk_size:
            offset = self.fileptr.tell()
            dwords, size = self.read_header()

            if not dwords[2]:
                dwords.append(self.fileptr.read(size))

            chunk = ''.join(dwords)
            node = cmx_model.make_cmx_chunk(self.config, chunk, offset=offset)
            self.parent_stack[-1].add(node)

            if dwords[2]:
                self.parent_stack.append(node)
                self.parse(size)
                self.parent_stack = self.parent_stack[:-1]

            if dwords[2] == cmx_const.INFO_ID:
                break
예제 #5
0
 def index_ixlr(self):
     index = 1
     ixlrs = []
     cmx_pages = self.cmx_model.chunk_map['pages']
     indx = self.cmx_model.chunk_map['indx']
     for item in cmx_pages:
         kwargs = {'page': index, 'layers': []}
         recs = kwargs['layers']
         page = item[0]
         for layer in page.childs[0].childs:
             if not layer.is_layer:
                 continue
             recs.append((layer.get_offset(), layer.data['layer_name']))
         ixlr = cmx_model.make_cmx_chunk(self.cmx_cfg,
                                         identifier=cmx_const.IXLR_ID,
                                         **kwargs)
         ixlrs.append(ixlr)
         indx.add(ixlr)
         index += 1
     return ixlrs
예제 #6
0
 def make_el(self, cmx_id, **kwargs):
     kwargs['identifier'] = cmx_id
     return cmx_model.make_cmx_chunk(self.cmx_cfg, **kwargs)
예제 #7
0
    def index_ixmr(self, ixpg, ixtl):
        kwargs = {'records': []}
        recs = kwargs['records']

        # Master Index Table
        offset = ixpg.get_offset() + ixpg.get_chunk_size()
        recs.append((cmx_const.MASTER_INDEX_TABLE, offset))

        # Page Index Table
        offset = ixpg.get_offset()
        recs.append((cmx_const.PAGE_INDEX_TABLE, offset))

        # Master Layer Table
        offset = ixtl.get_offset()
        recs.append((cmx_const.MASTER_LAYER_TABLE, offset))

        # Outline Description Section
        if 'rotl' in self.cmx_model.chunk_map:
            offset = self.cmx_model.chunk_map['rotl'].get_offset()
            recs.append((cmx_const.OUTLINE_DESCRIPTION_SECTION, offset))

        # Line Style Description Section
        if 'rott' in self.cmx_model.chunk_map:
            offset = self.cmx_model.chunk_map['rott'].get_offset()
            recs.append((cmx_const.LINE_STYLE_DESCRIPTION_SECTION, offset))

        # Arrowheads Description Section
        if 'rota' in self.cmx_model.chunk_map:
            offset = self.cmx_model.chunk_map['rota'].get_offset()
            recs.append((cmx_const.ARROWHEADS_DESCRIPTION_SECTION, offset))

        # Screen Description Section
        if 'rscr' in self.cmx_model.chunk_map:
            offset = self.cmx_model.chunk_map['rscr'].get_offset()
            recs.append((cmx_const.SCREEN_DESCRIPTION_SECTION, offset))

        # Pen Description Section
        if 'rpen' in self.cmx_model.chunk_map:
            offset = self.cmx_model.chunk_map['rpen'].get_offset()
            recs.append((cmx_const.PEN_DESCRIPTION_SECTION, offset))

        # Dot-Dash Description Section
        if 'rdot' in self.cmx_model.chunk_map:
            offset = self.cmx_model.chunk_map['rdot'].get_offset()
            recs.append((cmx_const.DOTDASH_DESCRIPTION_SECTION, offset))

        # Color Description Section
        if 'rclr' in self.cmx_model.chunk_map:
            offset = self.cmx_model.chunk_map['rclr'].get_offset()
            recs.append((cmx_const.COLOR_DESCRIPTION_SECTION, offset))

        # Color Correction Section
        if 'ccmm' in self.cmx_model.chunk_map:
            offset = self.cmx_model.chunk_map['ccmm'].get_offset()
            recs.append((cmx_const.COLOR_CORRECTION_SECTION, offset))

        indx = self.cmx_model.chunk_map['indx']
        ixmr = cmx_model.make_cmx_chunk(self.cmx_cfg,
                                        identifier=cmx_const.IXMR_ID,
                                        **kwargs)
        indx.add(ixmr)
        self.cmx_model.do_update()

        cont = self.cmx_model.chunk_map['cont']
        offset = ixpg.get_offset() + ixpg.get_chunk_size()
        cont.data['IndexSection'] = offset
        cont.data['InfoSection'] = offset + ixmr.get_chunk_size()

        if 'DISP' in self.cmx_model.chunk_map:
            offset = self.cmx_model.chunk_map['DISP'].get_offset()
            cont.data['Thumbnail'] = offset