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) {
39 int init_size = storage.get_size();
41 XMLResource *xmlresource = XMLResource::get_instance();
42 PSclModifierDecoration modifierDecorationTable = xmlresource->get_modifier_decoration_table();
43 if (modifierDecorationTable == NULL) {
44 LOGW("Error. modifier decoration table is NULL\n");
48 #ifdef __SCL_TXT_DEBUG
49 put_modifier_decoration(ENCODE, modifierDecorationTable);
52 Modifier_decoration_width record_width;
53 set_modifier_decoration_width(md_helper, record_width);
57 storage.put<sint_t>(MAX_SCL_MODIFIER_DECORATION_NUM, 4);
58 PSclModifierDecoration cur = modifierDecorationTable;
59 for (int i = 0; i < MAX_SCL_MODIFIER_DECORATION_NUM; ++i) {
60 encode_modifier_decoration_record(storage, cur, record_width);
64 int advance_size = storage.get_size() - init_size;
65 storage.random_put<sint_t>(advance_size, 8, init_size);
67 return storage.get_size();
71 encode_modifier_decoration_file(const char* file, IMetaData_Helper& md_helper) {
74 ResourceStorage storage;
76 encode_modifier_decoration_file(storage, md_helper);
79 return storage.get_size();
83 encode_modifier_decoration_file(const char* file, int& offset, IMetaData_Helper& md_helper) {
86 ResourceStorage storage;
88 encode_modifier_decoration_file(storage, md_helper);
89 storage.toFile(file, offset);
91 return storage.get_size();