Commit 24b0c34e authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Commit Julien work on the 3.02 branch, it may still have problems but it IS an...

Commit Julien work on the 3.02 branch, it may still have problems but it IS an advance, so get it in.
parent d709ab5a
......@@ -169,7 +169,7 @@ GooString::GooString(const char *sA, int lengthA) {
GooString::GooString(GooString *str, int idx, int lengthA) {
s = NULL;
length = 0;
assert(idx + lengthA < str->length);
assert(idx + lengthA <= str->length);
Set(str->getCString() + idx, lengthA);
}
......
This diff is collapsed.
......@@ -18,7 +18,7 @@ class Gfx;
class Catalog;
class CharCodeToUnicode;
class GfxFont;
class FormWidget;
class GfxFontDict;
//------------------------------------------------------------------------
// AnnotBorderStyle
......@@ -68,30 +68,57 @@ public:
~Annot();
GBool isOk() { return ok; }
void draw(Gfx *gfx);
void draw(Gfx *gfx, GBool printing);
// Get appearance object.
Object *getAppearance(Object *obj) { return appearance.fetch(xref, obj); }
GBool textField() { return isTextField; }
AnnotBorderStyle *getBorderStyle () { return borderStyle; }
GBool match(Ref *refA)
{ return ref.num == refA->num && ref.gen == refA->gen; }
void generateFieldAppearance(Dict *field, Dict *annot, Dict *acroForm);
double getXMin() { return xMin; }
double getYMin() { return yMin; }
double getFontSize() { return fontSize; }
private:
void writeTextString (GooString* vStr, CharCodeToUnicode* ccToUnicode, GooString* appearBuf, GfxFont* font);
void generateAppearance(Dict *acroForm, Dict *dict);
// void writeTextString (GooString* vStr, CharCodeToUnicode* ccToUnicode, GooString* appearBuf, GfxFont* font);
// void generateAppearance(Dict *acroForm, Dict *dict);
void setColor(Array *a, GBool fill, int adjust);
void drawText(GooString *text, GooString *da, GfxFontDict *fontDict,
GBool multiline, int comb, int quadding,
GBool txField, GBool forceZapfDingbats);
void drawListBox(GooString **text, GBool *selection,
int nOptions, int topIdx,
GooString *da, GfxFontDict *fontDict, GBool quadding);
void getNextLine(GooString *text, int start,
GfxFont *font, double fontSize, double wMax,
int *end, double *width, int *next);
void drawCircle(double cx, double cy, double r, GBool fill);
void drawCircleTopLeft(double cx, double cy, double r);
void drawCircleBottomRight(double cx, double cy, double r);
Object *fieldLookup(Dict *field, char *key, Object *obj);
void readArrayNum(Object *pdfArray, int key, double *value);
// write vStr[i:j[ in appearBuf
void writeTextString (GooString *text, GooString *appearBuf, int *i, int j, CharCodeToUnicode *ccToUnicode);
void initialize (XRef *xrefA, Dict *acroForm, Dict *dict, Catalog *catalog);
XRef *xref; // the xref table for this PDF file
Ref ref; // object ref identifying this annotation
GooString *type; // annotation type
Object appearance; // a reference to the Form XObject stream
// for the normal appearance
GooString *appearBuf;
Guint flags;
double xMin, yMin, // annotation rectangle
xMax, yMax;
AnnotBorderStyle *borderStyle;
double fontSize;
GBool ok;
GBool regen, isTextField;
......@@ -99,8 +126,6 @@ private:
bool hasRef;
bool hidden;
Ref ref;
FormWidget* widget;
};
//------------------------------------------------------------------------
......@@ -110,7 +135,7 @@ private:
class Annots {
public:
// Extract non-link annotations from array of annotations.
// Build a list of Annot objects.
Annots(XRef *xref, Catalog *catalog, Object *annotsObj);
~Annots();
......@@ -119,7 +144,15 @@ public:
int getNumAnnots() { return nAnnots; }
Annot *getAnnot(int i) { return annots[i]; }
// (Re)generate the appearance streams for all annotations belonging
// to a form field.
void generateAppearances(Dict *acroForm);
private:
void scanFieldAppearances(Dict *node, Ref *ref, Dict *parent,
Dict *acroForm);
Annot *findAnnot(Ref *ref);
Annot **annots;
int nAnnots;
......
......@@ -1065,7 +1065,7 @@ Form::Form(XRef *xrefA, Object* acroForm)
oref.free();
}
checkForNeedAppearances();
checkForNeedAppearances(acroForm);
}
Form::~Form() {
......@@ -1075,21 +1075,19 @@ Form::~Form() {
delete [] rootFields;
}
void Form::checkForNeedAppearances ()
void Form::checkForNeedAppearances (Object *acroForm)
{
//NeedAppearances needs to be set to 'true' in the AcroForm entry of the Catalog to enable dynamic appearance generation
Object* catalog = new Object();
Object acroForm;
Ref catRef;
catRef.gen = xref->getRootGen();
catRef.num = xref->getRootNum();
catalog = xref->getCatalog(catalog);
catalog->dictLookup("AcroForm", &acroForm);
catalog->dictLookup("AcroForm", acroForm);
Object obj1;
obj1.initBool(true);
acroForm.dictSet("NeedAppearances", &obj1);
obj1.free();
catalog->dictSet("AcroForm", &acroForm);
acroForm->dictSet("NeedAppearances", &obj1);
catalog->dictSet("AcroForm", acroForm);
xref->setModifiedObject(catalog, catRef);
}
......
......@@ -436,7 +436,7 @@ public:
void createFieldFromDict (Object* obj, FormField** ptr, XRef *xref, const Ref& aref);
void postWidgetsLoad();
void checkForNeedAppearances ();
void checkForNeedAppearances (Object *acroForm);
private:
FormField** rootFields;
int numFields;
......
......@@ -416,8 +416,7 @@ void Page::displaySlice(OutputDev *out, double hDPI, double vDPI,
if (acroForm) {
if (acroForm->lookup("NeedAppearances", &obj)) {
if (obj.isBool() && obj.getBool()) {
#warning Annot is broken FIXME!
// annotList->generateAppearances(acroForm);
annotList->generateAppearances(acroForm);
}
}
obj.free();
......@@ -431,8 +430,7 @@ void Page::displaySlice(OutputDev *out, double hDPI, double vDPI,
if ((annotDisplayDecideCbk &&
(*annotDisplayDecideCbk)(annot, annotDisplayDecideCbkData)) ||
!annotDisplayDecideCbk) {
#warning Annot is broken FIXME!
// annotList->getAnnot(i)->draw(gfx, printing);
annotList->getAnnot(i)->draw(gfx, printing);
}
}
out->dump();
......
Supports Markdown
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