Commit 31431b38 authored by João Netto's avatar João Netto

Changed the way forms are named

parent 9bbecdec
Pipeline #52620 passed with stage
in 4 minutes and 37 seconds
......@@ -34,6 +34,7 @@
#include <set>
#include <limits>
#include <stddef.h>
#include <map>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
......@@ -636,8 +637,39 @@ FormField::FormField(PDFDoc *docA, Object &&aobj, const Ref aref, FormField *par
quadding = quaddingLeftJustified;
hasQuadding = false;
// Check the name first, because we use the parent name too
Object obj1 = dict->lookup("T");
if (obj1.isString()) {
partialName = obj1.getString()->copy();
if( parent )
{
GooString *str = parent->getPartialName()->copy();
partialName->insert( 0, str->append( "." ) );
}
} else {
if( parent )
{
partialName = parent->getPartialName()->copy();
}
else
partialName = nullptr;
}
// If this name has been used before, we need to identify the others with #k
static std::map< std::string , int > usedNames;
if( partialName )
{
if( usedNames[ partialName->toStr() ]++ )
{
const GooString *idNum = GooString::fromInt( usedNames[ partialName->toStr() ]-2 );
partialName->append( "#" );
partialName->append( idNum );
delete idNum;
}
}
//childs
Object obj1 = dict->lookup("Kids");
obj1 = dict->lookup("Kids");
if (obj1.isArray()) {
// Load children
for (int i = 0 ; i < obj1.arrayGetLength(); i++) {
......@@ -717,13 +749,6 @@ FormField::FormField(PDFDoc *docA, Object &&aobj, const Ref aref, FormField *par
hasQuadding = true;
}
obj1 = dict->lookup("T");
if (obj1.isString()) {
partialName = obj1.getString()->copy();
} else {
partialName = nullptr;
}
obj1 = dict->lookup("TU");
if (obj1.isString()) {
alternateUiName = obj1.getString()->copy();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment