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 #ifndef ACCESSIBILITY_ELEMENT_INFO_PARCEL_H 17 #define ACCESSIBILITY_ELEMENT_INFO_PARCEL_H 18 19 #include "accessibility_element_info.h" 20 #include "parcel.h" 21 22 namespace OHOS { 23 namespace Accessibility { 24 /* 25 * class define the action on Accessibility info 26 */ 27 class AccessibleActionParcel : public AccessibleAction, public Parcelable { 28 public: 29 /** 30 * @brief Construct 31 */ 32 AccessibleActionParcel() = default; 33 34 /** 35 * @brief Construct 36 * @param action The object of AccessibleAction 37 */ 38 AccessibleActionParcel(const AccessibleAction &action); 39 40 /** 41 * @brief Used for IPC communication 42 * @param parcel 43 * @return true: Read parcel date successfully; otherwise is not 44 */ 45 bool ReadFromParcel(Parcel &parcel); 46 47 /** 48 * @brief Used for IPC communication 49 * @param parcel 50 */ 51 virtual bool Marshalling(Parcel &parcel) const override; 52 53 /** 54 * @brief Used for IPC communication 55 * @param parcel 56 * @return Read AccessibleActionParcel from parcel data 57 */ 58 static sptr<AccessibleActionParcel> Unmarshalling(Parcel &parcel); 59 }; 60 61 /** 62 * @brief Define the RangInfo for progress bar 63 * @note 64 * @retval None 65 */ 66 class RangeInfoParcel : public RangeInfo, public Parcelable { 67 public: 68 /** 69 * @brief Construct 70 */ 71 RangeInfoParcel() = default; 72 73 /** 74 * @brief Construct 75 * @param rangeInfo The object of RangeInfo. 76 */ 77 RangeInfoParcel(const RangeInfo &rangeInfo); 78 79 /** 80 * @brief Used for IPC communication 81 * @param parcel 82 */ 83 bool ReadFromParcel(Parcel &parcel); 84 85 /** 86 * @brief Used for IPC communication 87 * @param parcel 88 */ 89 virtual bool Marshalling(Parcel &parcel) const override; 90 91 /** 92 * @brief Used for IPC communication 93 * @param parcel 94 */ 95 static sptr<RangeInfoParcel> Unmarshalling(Parcel &parcel); 96 }; 97 98 /** 99 * @brief Define the list/grid component 100 * @note 101 * @retval None 102 */ 103 class GridInfoParcel : public GridInfo, public Parcelable { 104 public: 105 /** 106 * @brief Construct 107 * @since 3 108 * @sysCap Accessibility 109 */ 110 GridInfoParcel() = default; 111 112 /** 113 * @brief Construct 114 * @param gridInfo The object of GridInfo. 115 * @since 3 116 * @sysCap Accessibility 117 */ 118 GridInfoParcel(const GridInfo &gridInfo); 119 120 /** 121 * @brief Used for IPC communication 122 * @param parcel 123 * @since 3 124 * @sysCap Accessibility 125 */ 126 bool ReadFromParcel(Parcel &parcel); 127 128 /** 129 * @brief Used for IPC communication 130 * @param parcel 131 * @since 3 132 * @sysCap Accessibility 133 */ 134 virtual bool Marshalling(Parcel &parcel) const override; 135 136 /** 137 * @brief Used for IPC communication 138 * @param parcel 139 * @since 3 140 * @sysCap Accessibility 141 */ 142 static sptr<GridInfoParcel> Unmarshalling(Parcel &parcel); 143 }; 144 145 class GridItemInfoParcel : public GridItemInfo, public Parcelable { 146 public: 147 /** 148 * @brief Construct 149 * @since 3 150 * @sysCap Accessibility 151 */ 152 GridItemInfoParcel() = default; 153 154 /** 155 * @brief Construct 156 * @param itemInfo The object of GridItemInfo. 157 * @since 3 158 * @sysCap Accessibility 159 */ 160 GridItemInfoParcel(const GridItemInfo &itemInfo); 161 162 /** 163 * @brief Used for IPC communication 164 * @param parcel 165 * @since 3 166 * @sysCap Accessibility 167 */ 168 bool ReadFromParcel(Parcel &parcel); 169 170 /** 171 * @brief Used for IPC communication 172 * @param parcel 173 * @since 3 174 * @sysCap Accessibility 175 */ 176 virtual bool Marshalling(Parcel &parcel) const override; 177 178 /** 179 * @brief Used for IPC communication 180 * @param parcel 181 * @since 3 182 * @sysCap Accessibility 183 */ 184 static sptr<GridItemInfoParcel> Unmarshalling(Parcel &parcel); 185 }; 186 187 class RectParcel : public Rect, public Parcelable { 188 public: 189 /** 190 * @brief Construct 191 * @since 3 192 * @sysCap Accessibility 193 */ 194 RectParcel() = default; 195 196 /** 197 * @brief Construct 198 * @param rect The object of Rect. 199 * @since 3 200 * @sysCap Accessibility 201 */ 202 RectParcel(const Rect &rect); 203 204 /** 205 * @brief Used for IPC communication 206 * @param parcel 207 * @since 3 208 * @sysCap Accessibility 209 */ 210 bool ReadFromParcel(Parcel &parcel); 211 212 /** 213 * @brief Used for IPC communication 214 * @param parcel 215 * @since 3 216 * @sysCap Accessibility 217 */ 218 virtual bool Marshalling(Parcel &parcel) const override; 219 220 /** 221 * @brief Used for IPC communication 222 * @param parcel 223 * @since 3 224 * @sysCap Accessibility 225 */ 226 static sptr<RectParcel> Unmarshalling(Parcel &parcel); 227 }; 228 229 /* 230 * The class supply the api to set/get ui component property 231 */ 232 class AccessibilityElementInfoParcel : public AccessibilityElementInfo, public Parcelable { 233 public: 234 /** 235 * @brief Construct 236 * @since 3 237 * @sysCap Accessibility 238 */ 239 AccessibilityElementInfoParcel() = default; 240 241 /** 242 * @brief Construct 243 * @param elementInfo The object of AccessibilityElementInfo. 244 * @since 3 245 * @sysCap Accessibility 246 */ 247 AccessibilityElementInfoParcel(const AccessibilityElementInfo &elementInfo); 248 249 /** 250 * @brief Used for IPC communication 251 * @param parcel 252 * @return true: Read parcel data successfully; ohterwise is not. 253 * @since 3 254 * @sysCap Accessibility 255 */ 256 bool ReadFromParcel(Parcel &parcel); 257 258 /** 259 * @brief Used for IPC communication 260 * @param parcel 261 * @return true: Write parcel data successfully; ohterwise is not. 262 * @since 3 263 * @sysCap Accessibility 264 */ 265 virtual bool Marshalling(Parcel &parcel) const override; 266 267 /** 268 * @brief Used for IPC communication 269 * @param parcel 270 * @return Read AccessibilityElementInfoParcel from parcel data 271 * @since 3 272 * @sysCap Accessibility 273 */ 274 static sptr<AccessibilityElementInfoParcel> Unmarshalling(Parcel &parcel); 275 276 private: 277 /** 278 * @brief Used for IPC communication first part 279 * @param parcel 280 * @sysCap Accessibility 281 */ 282 bool ReadFromParcelFirstPart(Parcel &parcel); 283 284 /** 285 * @brief Used for IPC communication second part 286 * @param parcel 287 * @sysCap Accessibility 288 */ 289 bool ReadFromParcelSecondPart(Parcel &parcel); 290 291 /** 292 * @brief Used for IPC communication third part 293 * @param parcel 294 * @sysCap Accessibility 295 */ 296 bool ReadFromParcelThirdPart(Parcel &parcel); 297 298 /** 299 * @brief Used for IPC communication first part 300 * @param parcel 301 * @sysCap Accessibility 302 */ 303 bool MarshallingFirstPart(Parcel &parcel) const; 304 305 /** 306 * @brief Used for IPC communication second part 307 * @param parcel 308 * @sysCap Accessibility 309 */ 310 bool MarshallingSecondPart(Parcel &parcel) const; 311 }; 312 } // namespace Accessibility 313 } // namespace OHOS 314 #endif