1 /*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "accessibility_caption.h"
17 #include "hilog_wrapper.h"
18 #include "parcel_util.h"
19
20 namespace OHOS {
21 namespace Accessibility {
CheckProperty(const std::string & property)22 bool CaptionProperty::CheckProperty(const std::string& property)
23 {
24 bool result = true;
25 return result;
26 }
27
GetBackgroundColor() const28 uint32_t CaptionProperty::GetBackgroundColor() const
29 {
30 return backgroundColor_;
31 }
32
SetBackgroundColor(uint32_t color)33 void CaptionProperty::SetBackgroundColor(uint32_t color)
34 {
35 backgroundColor_ = color;
36 }
37
GetFontScale() const38 int CaptionProperty::GetFontScale() const
39 {
40 return fontScale_;
41 }
42
SetFontScale(int scale)43 void CaptionProperty::SetFontScale(int scale)
44 {
45 fontScale_ = scale;
46 }
47
GetFontColor() const48 uint32_t CaptionProperty::GetFontColor() const
49 {
50 return fontColor_;
51 }
52
SetFontColor(uint32_t color)53 void CaptionProperty::SetFontColor(uint32_t color)
54 {
55 fontColor_ = color;
56 }
57
GetFontEdgeType() const58 std::string CaptionProperty::GetFontEdgeType() const
59 {
60 return fontEdgeType_;
61 }
62
SetFontEdgeType(std::string type)63 void CaptionProperty::SetFontEdgeType(std::string type)
64 {
65 fontEdgeType_ = type;
66 }
67
GetWindowColor() const68 uint32_t CaptionProperty::GetWindowColor() const
69 {
70 return windowColor_;
71 }
72
SetWindowColor(uint32_t color)73 void CaptionProperty::SetWindowColor(uint32_t color)
74 {
75 windowColor_ = color;
76 }
77
SetFontFamily(std::string family)78 void CaptionProperty::SetFontFamily(std::string family)
79 {
80 fontFamily_ = family;
81 }
82
GetFontFamily() const83 std::string CaptionProperty::GetFontFamily() const
84 {
85 return fontFamily_;
86 }
87
ReadFromParcel(Parcel & parcel)88 bool CaptionProperty::ReadFromParcel(Parcel& parcel)
89 {
90 HILOG_DEBUG("start");
91 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, fontFamily_);
92 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, fontScale_);
93 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, fontColor_);
94 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, fontEdgeType_);
95 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, backgroundColor_);
96 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, windowColor_);
97
98 return true;
99 }
100
Marshalling(Parcel & parcel) const101 bool CaptionProperty::Marshalling(Parcel& parcel) const
102 {
103 HILOG_DEBUG("start");
104 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, fontFamily_);
105 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, fontScale_);
106 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, fontColor_);
107 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, fontEdgeType_);
108 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, backgroundColor_);
109 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, windowColor_);
110
111 return true;
112 }
113
Unmarshalling(Parcel & parcel)114 CaptionProperty* CaptionProperty::Unmarshalling(Parcel& parcel)
115 {
116 HILOG_DEBUG("start");
117 CaptionProperty* captionProperty = new CaptionProperty();
118 if (!captionProperty->ReadFromParcel(parcel)) {
119 HILOG_ERROR("read from parcel failed");
120 delete captionProperty;
121 captionProperty = nullptr;
122 }
123 return captionProperty;
124 }
125 } // namespace Accessibility
126 } // namespace OHOS