2 * Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "label_properties_bin_parser.h"
19 #include "simple_debug.h"
20 #include "put_record.h"
22 BinLabelPropertyParser::BinLabelPropertyParser() {
24 memset(m_label_properties_frame, 0, sizeof(SclLabelProperties) * MAX_SCL_LABEL_PROPERTIES * MAX_SIZE_OF_LABEL_FOR_ONE);
25 parser_info_provider = NULL;
28 BinLabelPropertyParser::~BinLabelPropertyParser() {
32 BinLabelPropertyParser* BinLabelPropertyParser::get_instance() {
33 static BinLabelPropertyParser instance;
36 void BinLabelPropertyParser::init(const FileStorage& storage, int offset, int size, IParserInfo_Provider* provider) {
37 m_storage.set_str_provider(parser_info_provider);
38 m_storage.get_storage(storage, offset, size);
39 this->parser_info_provider = provider;
40 parsing_label_properties_frame();
43 BinLabelPropertyParser::get_size() {
47 //recompute_layout will change the table
48 PSclLabelPropertiesTable BinLabelPropertyParser::get_label_properties_frame() {
49 return m_label_properties_frame;
52 void BinLabelPropertyParser::parsing_label_properties_frame() {
56 m_size = m_storage.get<sint_t>(4);
57 int maxj = m_storage.get<sint_t>(4);
59 if (parser_info_provider == NULL) {
60 SCLLOG(SclLog::ERROR, "Error parser_info_provider is NULL\n");
64 Label_properties_record_width record_width;
65 set_label_properties_record_width(*parser_info_provider, record_width);
66 for (int i = 0; i < m_size; ++i) {
67 for (int j = 0; j < maxj; ++j) {
68 SclLabelProperties &cur = m_label_properties_frame[i][j];
69 decode_label_properties_record(&cur, record_width);
72 #ifdef __SCL_TXT_DEBUG
73 put_label_properties_frame(DECODE, m_label_properties_frame);
78 BinLabelPropertyParser::decode_color(SclColor& color, int width) {
79 if (width <= 0) return;
81 color.r = m_storage.get<sint_t>(width);
82 color.g = m_storage.get<sint_t>(width);
83 color.b = m_storage.get<sint_t>(width);
84 color.a = m_storage.get<sint_t>(width);
87 BinLabelPropertyParser::decode_label_properties_record(const PSclLabelProperties cur, const Label_properties_record_width& record_width) {
88 cur->valid = (sclboolean)true;
91 m_storage.get_str(&(cur->label_type), record_width.label_type, m_string_collector);
93 m_storage.get_str(&(cur->font_name), record_width.font_name, m_string_collector);
96 cur->font_size = m_storage.get<sint_t>(record_width.font_size);
98 for (int i = 0; i < SCL_SHIFT_STATE_MAX; ++i) {
99 for (int j = 0; j < SCL_BUTTON_STATE_MAX; ++j) {
100 decode_color(cur->font_color[i][j], record_width.font_color);
105 cur->alignment = (SCLLabelAlignment)m_storage.get<sint_t>(record_width.alignment);
108 cur->padding_x = m_storage.get<sint_t>(record_width.padding_x);
111 cur->padding_y = m_storage.get<sint_t>(record_width.padding_y);
114 cur->inner_width = m_storage.get<sint_t>(record_width.inner_width);
117 cur->inner_height = m_storage.get<sint_t>(record_width.inner_height);
120 cur->shadow_distance = m_storage.get<sint_t>(record_width.shadow_distance);
123 cur->shadow_direction = (SCLShadowDirection)m_storage.get<sint_t>(record_width.shadow_direction);
126 for (int i = 0; i < SCL_SHIFT_STATE_MAX; ++i) {
127 for (int j = 0; j < SCL_BUTTON_STATE_MAX; ++j) {
128 decode_color(cur->shadow_color[i][j], record_width.shadow_color);