Skip to content

Commit

Permalink
PDFBOX-5225: refactor
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1922024 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Nov 22, 2024
1 parent e49649a commit 112948a
Showing 1 changed file with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -798,16 +798,7 @@ private Map<COSDictionary,Set<COSDictionary>> buildPagesWidgetsMap(
// If there is a widget with a missing page reference we need to build the map reverse i.e.
// from the annotations to the widget.
LOG.warn("There has been a widget with a missing page reference, will check all page annotations");
Set<COSDictionary> widgetDictionarySet = new HashSet<>();
for (PDField field : fields)
{
List<PDAnnotationWidget> widgets = field.getWidgets();
for (PDAnnotationWidget widget : widgets)
{
widgetDictionarySet.add(widget.getCOSObject());
}
}

Set<COSDictionary> widgetDictionarySet = createWidgetDictionarySet(fields);
for (PDPage page : pages)
{
for (PDAnnotation annotation : page.getAnnotations())
Expand All @@ -822,6 +813,26 @@ private Map<COSDictionary,Set<COSDictionary>> buildPagesWidgetsMap(
return pagesAnnotationsMap;
}

/**
* Return a set of all annotation widget dictionaries related to the fields to be flattened.
*
* @param fields
* @return
*/
private Set<COSDictionary> createWidgetDictionarySet(List<PDField> fields)
{
Set<COSDictionary> widgetDictionarySet = new HashSet<>();
for (PDField field : fields)
{
List<PDAnnotationWidget> widgets = field.getWidgets();
for (PDAnnotationWidget widget : widgets)
{
widgetDictionarySet.add(widget.getCOSObject());
}
}
return widgetDictionarySet;
}

private void fillPagesAnnotationMap(Map<COSDictionary, Set<COSDictionary>> pagesAnnotationsMap,
PDPage page, PDAnnotationWidget widget)
{
Expand Down

0 comments on commit 112948a

Please sign in to comment.