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 "encode_modifier_decoration.h"
19 #include "xmlresource.h"
20 #include "resource_storage_impl.h"
21 #include "put_record.h"
22 #include "_auto_metadata.h"
25 using namespace xmlresource;
27 encode_modifier_decoration_record(ResourceStorage& storage, const PSclModifierDecoration cur, const Modifier_decoration_width& record_width) {
28 storage.put<sint_t>(cur->extract_background, record_width.extract_background);
29 storage.encode_string(cur->name, record_width.name);
30 for (int i = 0; i < DISPLAYMODE_MAX; ++i) {
31 for (int j = 0; j < KEY_MODIFIER_MAX; ++j) {
32 storage.encode_string(cur->bg_image_path[i][j], record_width.bg_image_path);
38 encode_modifier_decoration_file(ResourceStorage& storage, IMetaData_Helper& md_helper) {
40 int init_size = storage.get_size();
42 XMLResource *xmlresource = XMLResource::get_instance();
43 PSclModifierDecoration modifierDecorationTable = xmlresource->get_modifier_decoration_table();
44 if (modifierDecorationTable == NULL) {
45 LOGW("Error. modifier decoration table is NULL");
49 #ifdef __SCL_TXT_DEBUG
50 put_modifier_decoration(ENCODE, modifierDecorationTable);
53 Modifier_decoration_width record_width;
54 set_modifier_decoration_width(md_helper, record_width);
58 storage.put<sint_t>(MAX_SCL_MODIFIER_DECORATION_NUM, 4);
59 PSclModifierDecoration cur = modifierDecorationTable;
60 for (int i = 0; i < MAX_SCL_MODIFIER_DECORATION_NUM; ++i) {
61 encode_modifier_decoration_record(storage, cur, record_width);
65 int advance_size = storage.get_size() - init_size;
66 storage.random_put<sint_t>(advance_size, 8, init_size);
68 return storage.get_size();
72 encode_modifier_decoration_file(const char* file, IMetaData_Helper& md_helper) {
75 ResourceStorage storage;
77 encode_modifier_decoration_file(storage, md_helper);
80 return storage.get_size();
84 encode_modifier_decoration_file(const char* file, int& offset, IMetaData_Helper& md_helper) {
87 ResourceStorage storage;
89 encode_modifier_decoration_file(storage, md_helper);
90 storage.toFile(file, offset);
92 return storage.get_size();