• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
78 
SetFontFamily(std::string family)79 void CaptionProperty::SetFontFamily(std::string family)
80 {
81     fontFamily_ = family;
82 }
83 
GetFontFamily() const84 std::string CaptionProperty::GetFontFamily() const
85 {
86     return fontFamily_;
87 }
88 
ReadFromParcel(Parcel & parcel)89 bool CaptionProperty::ReadFromParcel(Parcel& parcel)
90 {
91     HILOG_DEBUG("start");
92     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, fontFamily_);
93     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, fontScale_);
94     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, fontColor_);
95     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, fontEdgeType_);
96     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, backgroundColor_);
97     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, windowColor_);
98 
99     return true;
100 }
101 
Marshalling(Parcel & parcel) const102 bool CaptionProperty::Marshalling(Parcel& parcel) const
103 {
104     HILOG_DEBUG("start");
105     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, fontFamily_);
106     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, fontScale_);
107     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, fontColor_);
108     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, fontEdgeType_);
109     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, backgroundColor_);
110     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, windowColor_);
111 
112     return true;
113 }
114 
Unmarshalling(Parcel & parcel)115 CaptionProperty* CaptionProperty::Unmarshalling(Parcel& parcel)
116 {
117     HILOG_DEBUG("start");
118     CaptionProperty* captionProperty = new CaptionProperty();
119     if (!captionProperty->ReadFromParcel(parcel)) {
120         HILOG_ERROR("read from parcel failed");
121         delete captionProperty;
122         captionProperty = nullptr;
123     }
124     return captionProperty;
125 }
126 } // namespace Accessibility
127 } // namespace OHOS