1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 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 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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. 15 */ 16 17 #ifndef MEDIAPROVIDER_PDF_JNI_PDFCLIENT_FORM_WIDGET_INFO_H_ 18 #define MEDIAPROVIDER_PDF_JNI_PDFCLIENT_FORM_WIDGET_INFO_H_ 19 20 #include <string> 21 #include <vector> 22 23 #include "rect.h" 24 25 namespace pdfClient { 26 27 struct Option { 28 int index; 29 std::string label; 30 bool selected; 31 }; 32 33 // Value class of relevant information about a single form widget. 34 class FormWidgetInfo { 35 public: 36 FormWidgetInfo(); 37 ~FormWidgetInfo(); 38 39 // True if action found widget. 40 bool FoundWidget(); 41 int OptionCount() const; 42 bool HasOptions() const; 43 44 int widget_type() const; 45 void set_widget_type(int widget_type); 46 int widget_index() const; 47 void set_widget_index(int widget_index); 48 Rectangle_i widget_rect() const; 49 void set_widget_rect(Rectangle_i widget_rect); 50 bool read_only() const; 51 void set_read_only(bool read_only); 52 std::string text_value() const; 53 void set_text_value(std::string_view text_value); 54 std::string accessibility_label() const; 55 void set_accessibility_label(std::string_view accessibility_label); 56 bool editable_text() const; 57 void set_editable_text(bool editable_text); 58 bool multiselect() const; 59 void set_multiselect(bool multiselect); 60 bool multi_line_text() const; 61 void set_multi_line_text(bool multi_line_text); 62 int max_length() const; 63 void set_max_length(int max_length); 64 float font_size() const; 65 void set_font_size(float font_size); 66 const std::vector<Option>& options() const; 67 void set_options(const std::vector<Option>& options); 68 69 private: 70 int widget_type_; 71 int widget_index_; 72 Rectangle_i widget_rect_; 73 bool read_only_; 74 std::string text_value_; 75 std::string accessibility_label_; 76 // Text/combo only, true if user can set text manually. 77 bool editable_text_; 78 // Listboxes only. 79 bool multiselect_; 80 // Text field only. 81 bool multi_line_text_; 82 // Text field only. 83 int max_length_; 84 // Editable Text fields only. 85 float font_size_; 86 // Combo/listboxes only. 87 std::vector<Option> options_; 88 }; 89 90 } // namespace pdfClient 91 92 #endif // MEDIAPROVIDER_PDF_JNI_PDFCLIENT_FORM_WIDGET_INFO_H_