Esempio n. 1
0
    def test_colorpattern_gradation_5017(self):
        fixturename = '5017-shapecomponent-with-colorpattern-and-gradation.bin'
        f = self.open_fixture(fixturename, 'rb')
        try:
            records = list(read_records(f))
        finally:
            f.close()

        context = dict(version=(5, 0, 1, 7))
        models = parse_models(context, records)
        models = list(models)
        self.assertEqual(1280, models[-1]['content']['fill_flags'])
        colorpattern = models[-1]['content']['fill_colorpattern']
        gradation = models[-1]['content']['fill_gradation']
        self.assertEqual(32768, colorpattern['background_color'])
        self.assertEqual(0, colorpattern['pattern_color'])
        self.assertEqual(0xffffffff, colorpattern['pattern_type_flags'])

        self.assertEqual(50, gradation['blur'])
        self.assertEqual(dict(x=0, y=100), gradation['center'])
        self.assertEqual([64512, 13171936], gradation['colors'])
        self.assertEqual(180, gradation['shear'])
        self.assertEqual(1, gradation['type'])
        self.assertEqual(1, models[-1]['content']['fill_shape'])
        self.assertEqual(50, models[-1]['content']['fill_blur_center'])
Esempio n. 2
0
    def test_colorpattern_gradation_5017(self):
        from hwp5.recordstream import read_records
        from hwp5.binmodel import parse_models
        fixturename = '5017-shapecomponent-with-colorpattern-and-gradation.bin'
        f = self.open_fixture(fixturename, 'rb')
        try:
            records = list(read_records(f))
        finally:
            f.close()

        context = dict(version=(5, 0, 1, 7))
        models = parse_models(context, records)
        models = list(models)
        self.assertEquals(1280, models[-1]['content']['fill_flags'])
        colorpattern = models[-1]['content']['fill_colorpattern']
        gradation = models[-1]['content']['fill_gradation']
        self.assertEquals(32768, colorpattern['background_color'])
        self.assertEquals(0, colorpattern['pattern_color'])
        self.assertEquals(0xffffffff, colorpattern['pattern_type_flags'])

        self.assertEquals(50, gradation['blur'])
        self.assertEquals(dict(x=0, y=100), gradation['center'])
        self.assertEquals([64512, 13171936], gradation['colors'])
        self.assertEquals(180, gradation['shear'])
        self.assertEquals(1, gradation['type'])
        self.assertEquals(1, models[-1]['content']['fill_shape'])
        self.assertEquals(50, models[-1]['content']['fill_blur_center'])
Esempio n. 3
0
    def testParse(self):
        record = next(read_records(self.stream))
        context = init_record_parsing_context(testcontext, record)
        model = record
        parse_model(context, model)

        self.assertEqual(ListHeader, model['type'])
        self.assertEqual(1, model['content']['paragraphs'])
        self.assertEqual(0x20, model['content']['listflags'])
        self.assertEqual(0, model['content']['unknown1'])
        self.assertEqual(8, context['stream'].tell())
Esempio n. 4
0
    def testParse(self):
        record = next(read_records(self.stream))
        context = init_record_parsing_context(testcontext, record)
        model = record
        parse_model(context, model)

        self.assertEqual(ListHeader, model['type'])
        self.assertEqual(1, model['content']['paragraphs'])
        self.assertEqual(0x20, model['content']['listflags'])
        self.assertEqual(0, model['content']['unknown1'])
        self.assertEqual(8, context['stream'].tell())
Esempio n. 5
0
    def testParse(self):
        record = next(read_records(self.stream))
        context = init_record_parsing_context(testcontext, record)
        model = record
        parse_model(context, model)

        self.assertTrue(BinData, model['type'])
        self.assertEqual(BinData.StorageType.EMBEDDING,
                         BinData.Flags(model['content']['flags']).storage)
        self.assertEqual(2, model['content']['bindata']['storage_id'])
        self.assertEqual('jpg', model['content']['bindata']['ext'])
Esempio n. 6
0
    def testParse(self):
        record = next(read_records(self.stream))
        context = init_record_parsing_context(testcontext, record)
        model = record
        parse_model(context, model)

        self.assertTrue(BinData, model['type'])
        self.assertEqual(BinData.StorageType.EMBEDDING,
                         BinData.Flags(model['content']['flags']).storage)
        self.assertEqual(2, model['content']['bindata']['storage_id'])
        self.assertEqual('jpg', model['content']['bindata']['ext'])
Esempio n. 7
0
    def testParse(self):
        from hwp5.binmodel import BinData
        from hwp5.binmodel import init_record_parsing_context
        from hwp5.binmodel import parse_model
        record = read_records(self.stream).next()
        context = init_record_parsing_context(testcontext, record)
        model = record
        parse_model(context, model)

        self.assertTrue(BinData, model['type'])
        self.assertEquals(BinData.StorageType.EMBEDDING,
                          BinData.Flags(model['content']['flags']).storage)
        self.assertEquals(2, model['content']['bindata']['storage_id'])
        self.assertEquals('jpg', model['content']['bindata']['ext'])
Esempio n. 8
0
    def testParsePass1(self):
        from hwp5.binmodel import TableCaption, TableCell
        from hwp5.binmodel import parse_models_intern
        stream = StringIO(self.records_bytes)
        records = list(read_records(stream))
        result = list(parse_models_intern(self.ctx, records))

        tablecaption = result[1]
        context, model = tablecaption
        model_type = model['type']
        model_content = model['content']
        stream = context['stream']

        self.assertEquals(TableCaption, model_type)
        self.assertEquals(22, stream.tell())
        # ListHeader attributes
        self.assertEquals(2, model_content['paragraphs'])
        self.assertEquals(0x0L, model_content['listflags'])
        self.assertEquals(0, model_content['unknown1'])
        # TableCaption model_content
        self.assertEquals(3, model_content['flags'])
        self.assertEquals(8504L, model_content['width'])
        self.assertEquals(850, model_content['separation'])
        self.assertEquals(40454L, model_content['maxsize'])

        tablecell = result[3]
        context, model = tablecell
        model_type = model['type']
        model_content = model['content']
        stream = context['stream']
        self.assertEquals(TableCell, model_type)
        self.assertEquals(38, stream.tell())
        # ListHeader model_content
        self.assertEquals(1, model_content['paragraphs'])
        self.assertEquals(0x20L, model_content['listflags'])
        self.assertEquals(0, model_content['unknown1'])
        # TableCell model_content
        self.assertEquals(0, model_content['col'])
        self.assertEquals(0, model_content['row'])
        self.assertEquals(1, model_content['colspan'])
        self.assertEquals(1, model_content['rowspan'])
        self.assertEquals(0x4f03, model_content['width'])
        self.assertEquals(0x11a, model_content['height'])
        self.assertEquals(dict(left=141, right=141, top=141, bottom=141),
                          model_content['padding'])
        self.assertEquals(
            1,
            model_content['borderfill_id'],
        )
        self.assertEquals(0x4f03, model_content['unknown_width'])
Esempio n. 9
0
    def testParse(self):
        from hwp5.binmodel import ListHeader
        from hwp5.binmodel import init_record_parsing_context
        from hwp5.binmodel import parse_model
        record = read_records(self.stream).next()
        context = init_record_parsing_context(testcontext, record)
        model = record
        parse_model(context, model)

        self.assertEquals(ListHeader, model['type'])
        self.assertEquals(1, model['content']['paragraphs'])
        self.assertEquals(0x20L, model['content']['listflags'])
        self.assertEquals(0, model['content']['unknown1'])
        self.assertEquals(8, context['stream'].tell())
Esempio n. 10
0
    def testParse(self):
        from hwp5.binmodel import BinData
        from hwp5.binmodel import init_record_parsing_context
        from hwp5.binmodel import parse_model
        record = read_records(self.stream).next()
        context = init_record_parsing_context(testcontext, record)
        model = record
        parse_model(context, model)

        self.assertTrue(BinData, model['type'])
        self.assertEquals(BinData.StorageType.EMBEDDING,
                          BinData.Flags(model['content']['flags']).storage)
        self.assertEquals(2, model['content']['bindata']['storage_id'])
        self.assertEquals('jpg', model['content']['bindata']['ext'])
Esempio n. 11
0
    def testParse(self):
        from hwp5.binmodel import ListHeader
        from hwp5.binmodel import init_record_parsing_context
        from hwp5.binmodel import parse_model
        record = read_records(self.stream).next()
        context = init_record_parsing_context(testcontext, record)
        model = record
        parse_model(context, model)

        self.assertEquals(ListHeader, model['type'])
        self.assertEquals(1, model['content']['paragraphs'])
        self.assertEquals(0x20L, model['content']['listflags'])
        self.assertEquals(0, model['content']['unknown1'])
        self.assertEquals(8, context['stream'].tell())
Esempio n. 12
0
    def testParsePass1(self):
        from hwp5.binmodel import TableCaption, TableCell
        from hwp5.binmodel import parse_models_intern
        stream = StringIO(self.records_bytes)
        records = list(read_records(stream))
        result = list(parse_models_intern(self.ctx, records))

        tablecaption = result[1]
        context, model = tablecaption
        model_type = model['type']
        model_content = model['content']
        stream = context['stream']

        self.assertEquals(TableCaption, model_type)
        self.assertEquals(22, stream.tell())
        # ListHeader attributes
        self.assertEquals(2, model_content['paragraphs'])
        self.assertEquals(0x0L, model_content['listflags'])
        self.assertEquals(0, model_content['unknown1'])
        # TableCaption model_content
        self.assertEquals(3, model_content['flags'])
        self.assertEquals(8504L, model_content['width'])
        self.assertEquals(850, model_content['separation'])
        self.assertEquals(40454L, model_content['max_width'])

        tablecell = result[3]
        context, model = tablecell
        model_type = model['type']
        model_content = model['content']
        stream = context['stream']
        self.assertEquals(TableCell, model_type)
        self.assertEquals(38, stream.tell())
        # ListHeader model_content
        self.assertEquals(1, model_content['paragraphs'])
        self.assertEquals(0x20L, model_content['listflags'])
        self.assertEquals(0, model_content['unknown1'])
        # TableCell model_content
        self.assertEquals(0, model_content['col'])
        self.assertEquals(0, model_content['row'])
        self.assertEquals(1, model_content['colspan'])
        self.assertEquals(1, model_content['rowspan'])
        self.assertEquals(0x4f03, model_content['width'])
        self.assertEquals(0x11a, model_content['height'])
        self.assertEquals(dict(left=141, right=141, top=141, bottom=141),
                          model_content['padding'])
        self.assertEquals(1, model_content['borderfill_id'],)
        self.assertEquals(0x4f03, model_content['unknown_width'])
Esempio n. 13
0
    def testParsePass1(self):
        record = next(read_records(self.stream))
        context = init_record_parsing_context(testcontext, record)
        model = record
        parse_model(context, model)

        self.assertTrue(TableControl, model['type'])
        self.assertEqual(1453501933, model['content']['instance_id'])
        self.assertEqual(0x0, model['content']['x'])
        self.assertEqual(0x0, model['content']['y'])
        self.assertEqual(0x1044, model['content']['height'])
        self.assertEqual(0x9e06, model['content']['width'])
        self.assertEqual(0, model['content']['unknown1'])
        self.assertEqual(0x82a2311, model['content']['flags'])
        self.assertEqual(0, model['content']['z_order'])
        self.assertEqual(dict(left=283, right=283, top=283, bottom=283),
                         model['content']['margin'])
        self.assertEqual('tbl ', model['content']['chid'])
Esempio n. 14
0
    def testParsePass1(self):
        record = next(read_records(self.stream))
        context = init_record_parsing_context(testcontext, record)
        model = record
        parse_model(context, model)

        self.assertTrue(TableControl, model['type'])
        self.assertEqual(1453501933, model['content']['instance_id'])
        self.assertEqual(0x0, model['content']['x'])
        self.assertEqual(0x0, model['content']['y'])
        self.assertEqual(0x1044, model['content']['height'])
        self.assertEqual(0x9e06, model['content']['width'])
        self.assertEqual(0, model['content']['unknown1'])
        self.assertEqual(0x82a2311, model['content']['flags'])
        self.assertEqual(0, model['content']['z_order'])
        self.assertEqual(dict(left=283, right=283, top=283, bottom=283),
                         model['content']['margin'])
        self.assertEqual('tbl ', model['content']['chid'])
Esempio n. 15
0
    def test_parse_model(self):
        record = next(read_records(self.stream))
        context = init_record_parsing_context(self.ctx, record)
        model = record

        parse_model(context, model)
        model_type = model['type']
        model_content = model['content']

        self.assertEqual(TableBody, model_type)
        self.assertEqual(dict(left=141, right=141, top=141, bottom=141),
                         model_content['padding'])
        self.assertEqual(0x4000006, model_content['flags'])
        self.assertEqual(2, model_content['cols'])
        self.assertEqual(2, model_content['rows'])
        self.assertEqual(1, model_content['borderfill_id'])
        self.assertEqual([2, 2], model_content['rowcols'])
        self.assertEqual(0, model_content['cellspacing'])
        self.assertEqual([], model_content['validZones'])
Esempio n. 16
0
    def test_parse_model(self):
        record = next(read_records(self.stream))
        context = init_record_parsing_context(self.ctx, record)
        model = record

        parse_model(context, model)
        model_type = model['type']
        model_content = model['content']

        self.assertEqual(TableBody, model_type)
        self.assertEqual(dict(left=141, right=141, top=141, bottom=141),
                         model_content['padding'])
        self.assertEqual(0x4000006, model_content['flags'])
        self.assertEqual(2, model_content['cols'])
        self.assertEqual(2, model_content['rows'])
        self.assertEqual(1, model_content['borderfill_id'])
        self.assertEqual([2, 2], model_content['rowcols'])
        self.assertEqual(0, model_content['cellspacing'])
        self.assertEqual([], model_content['validZones'])
Esempio n. 17
0
    def test_parse_model(self):
        from hwp5.binmodel import TableBody
        from hwp5.binmodel import init_record_parsing_context
        from hwp5.binmodel import parse_model
        record = read_records(self.stream).next()
        context = init_record_parsing_context(self.ctx, record)
        model = record

        parse_model(context, model)
        model_type = model['type']
        model_content = model['content']

        self.assertEquals(TableBody, model_type)
        self.assertEquals(dict(left=141, right=141, top=141, bottom=141),
                          model_content['padding'])
        self.assertEquals(0x4000006L, model_content['flags'])
        self.assertEquals(2, model_content['cols'])
        self.assertEquals(2, model_content['rows'])
        self.assertEquals(1, model_content['borderfill_id'])
        self.assertEquals([2, 2], model_content['rowcols'])
        self.assertEquals(0, model_content['cellspacing'])
        self.assertEquals([], model_content['validZones'])
Esempio n. 18
0
    def test_parse_model(self):
        from hwp5.binmodel import TableBody
        from hwp5.binmodel import init_record_parsing_context
        from hwp5.binmodel import parse_model
        record = read_records(self.stream).next()
        context = init_record_parsing_context(self.ctx, record)
        model = record

        parse_model(context, model)
        model_type = model['type']
        model_content = model['content']

        self.assertEquals(TableBody, model_type)
        self.assertEquals(dict(left=141, right=141, top=141, bottom=141),
                          model_content['padding'])
        self.assertEquals(0x4000006L, model_content['flags'])
        self.assertEquals(2, model_content['cols'])
        self.assertEquals(2, model_content['rows'])
        self.assertEquals(1, model_content['borderfill_id'])
        self.assertEquals([2, 2], model_content['rowcols'])
        self.assertEquals(0, model_content['cellspacing'])
        self.assertEquals([], model_content['validZones'])