@@ -253,21 +253,18 @@ ByteString GenerateListBoxAP(const CPDF_Dictionary* annot_dict,
253253 return ByteString (body_stream);
254254}
255255
256- void GenerateTextFieldFormAP (fxcrt::ostringstream& app_stream,
257- const CPDF_Dictionary* annot_dict,
258- const CFX_FloatRect& bbox,
259- const DefaultAppearanceInfo& da_info,
260- CPDF_AnnotFontMap& map,
261- const CPDF_RichTextLayout::Options& options,
262- const WideString* value_override) {
263- const AppearanceCharacteristics mk =
264- GetAppearanceCharacteristics (annot_dict->GetDictFor (" MK" ));
256+ // A field's background and border, in isolated graphics state: what a text
257+ // field draws under its text, and all a signature field's box is. A solid
258+ // border is a stroked rectangle; the other styles draw as a combo box's and
259+ // a list box's do.
260+ void WriteFieldBox (fxcrt::ostringstream& app_stream,
261+ const AppearanceCharacteristics& mk,
262+ const BorderStyleInfo& bs,
263+ const CFX_FloatRect& bbox) {
265264 const bool has_bg =
266265 mk.background_color .nColorType != CFX_Color::Type::kTransparent ;
267266 const bool has_bc =
268267 mk.border_color .nColorType != CFX_Color::Type::kTransparent ;
269-
270- const BorderStyleInfo bs = GetBorderStyleInfo (annot_dict->GetDictFor (" BS" ));
271268 const float bw = bs.width ;
272269 const float half_bw = bw / 2 .0f ;
273270
@@ -276,12 +273,6 @@ void GenerateTextFieldFormAP(fxcrt::ostringstream& app_stream,
276273 stroke_rect.Deflate (half_bw, half_bw);
277274 }
278275
279- CFX_FloatRect body_rect = bbox;
280- body_rect.Deflate (2 .0f * bw, bw);
281-
282- // Background + border in isolated graphics state. A solid border is a
283- // stroked rectangle; the other styles draw as a combo box's and a list
284- // box's do.
285276 app_stream << " q\n " ;
286277 if (has_bg) {
287278 app_stream << GenerateColorAP (mk.background_color , PaintOperation::kFill );
@@ -297,6 +288,24 @@ void GenerateTextFieldFormAP(fxcrt::ostringstream& app_stream,
297288 app_stream << GenerateBorderAP (bbox, bs, mk.border_color );
298289 }
299290 app_stream << " Q\n " ;
291+ }
292+
293+ void GenerateTextFieldFormAP (fxcrt::ostringstream& app_stream,
294+ const CPDF_Dictionary* annot_dict,
295+ const CFX_FloatRect& bbox,
296+ const DefaultAppearanceInfo& da_info,
297+ CPDF_AnnotFontMap& map,
298+ const CPDF_RichTextLayout::Options& options,
299+ const WideString* value_override) {
300+ const AppearanceCharacteristics mk =
301+ GetAppearanceCharacteristics (annot_dict->GetDictFor (" MK" ));
302+ const BorderStyleInfo bs = GetBorderStyleInfo (annot_dict->GetDictFor (" BS" ));
303+ const float bw = bs.width ;
304+
305+ CFX_FloatRect body_rect = bbox;
306+ body_rect.Deflate (2 .0f * bw, bw);
307+
308+ WriteFieldBox (app_stream, mk, bs, bbox);
300309
301310 // Text content in isolated graphics state with proper clipping
302311 app_stream << " /Tx BMC\n q\n " ;
@@ -988,6 +997,25 @@ CPDF_AppearanceGenerator::GenerateEphemeralFormAP(
988997 std::move (target.normal_stream )};
989998}
990999
1000+ // static
1001+ void CPDF_AppearanceGenerator::GenerateBoxFormAP (CPDF_Document* doc,
1002+ CPDF_Dictionary* annot_dict) {
1003+ const AppearanceCharacteristics mk =
1004+ GetAppearanceCharacteristics (annot_dict->GetDictFor (" MK" ));
1005+ const BorderStyleInfo bs = GetBorderStyleInfo (annot_dict->GetDictFor (" BS" ));
1006+ const AnnotationDimensionsAndColor dims =
1007+ GetAnnotationDimensionsAndColor (annot_dict);
1008+
1009+ fxcrt::ostringstream content;
1010+ WriteFieldBox (content, mk, bs, dims.bbox );
1011+ // A new stream, as a check box's are: the old /N may be another widget's
1012+ // too, or a drawing someone placed in this one.
1013+ const uint32_t normal_obj_num =
1014+ CreateFormXObjectStream (doc, content, dims.bbox , dims.matrix );
1015+ annot_dict->GetOrCreateDictFor (pdfium::annotation::kAP )
1016+ ->SetNewFor <CPDF_Reference>(" N" , doc, normal_obj_num);
1017+ }
1018+
9911019// static
9921020void CPDF_AppearanceGenerator::GenerateCheckboxFormAP (
9931021 CPDF_Document* doc,
0 commit comments