Commit 39dc9943 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos

[annots] Create appearance stream for Sound Annotations when not defined

See bug #23108.
parent e4f5a78a
......@@ -5092,6 +5092,118 @@ void AnnotSound::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
obj1.free();
}
#define ANNOT_SOUND_AP_SPEAKER \
"4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \
"2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \
"l 1 21.523 2.477 23 4.301 23 c h\n" \
"4.301 23 m f\n" \
"0.533333 0.541176 0.521569 RG 2 w\n" \
"0 J\n" \
"1 j\n" \
"[] 0.0 d\n" \
"4 M 4 14 m 4.086 8.043 l 7 8 l 11 4 l 11 18 l 7 14 l 4 14 l h\n" \
"4 14 m S\n" \
"1 w\n" \
"1 J\n" \
"0 j\n" \
"13.699 15.398 m 14.699 13.398 14.699 9.398 13.699 7.398 c S\n" \
"18.199 19.398 m 21.199 17.398 21.199 5.398 18.199 3.398 c S\n" \
"16 17.398 m 18 16.398 18 7.398 16 5.398 c S\n" \
"0.729412 0.741176 0.713725 RG 2 w\n" \
"0 J\n" \
"1 j\n" \
"4 15 m 4.086 9.043 l 7 9 l 11 5 l 11 19 l 7 15 l 4 15 l h\n" \
"4 15 m S\n" \
"1 w\n" \
"1 J\n" \
"0 j\n" \
"13.699 16 m 14.699 14 14.699 10 13.699 8 c S\n" \
"18.199 20 m 21.199 18 21.199 6 18.199 4 c S\n" \
"16 18 m 18 17 18 8 16 6 c S\n"
#define ANNOT_SOUND_AP_MIC \
"4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \
"2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \
"l 1 21.523 2.477 23 4.301 23 c h\n" \
"4.301 23 m f\n" \
"0.533333 0.541176 0.521569 RG 2 w\n" \
"1 J\n" \
"0 j\n" \
"[] 0.0 d\n" \
"4 M 12 20 m 12 20 l 13.656 20 15 18.656 15 17 c 15 13 l 15 11.344 13.656 10\n" \
"12 10 c 12 10 l 10.344 10 9 11.344 9 13 c 9 17 l 9 18.656 10.344 20 12\n" \
"20 c h\n" \
"12 20 m S\n" \
"1 w\n" \
"17.5 14.5 m 17.5 11.973 l 17.5 8.941 15.047 6.5 12 6.5 c 8.953 6.5 6.5\n" \
"8.941 6.5 11.973 c 6.5 14.5 l S\n" \
"2 w\n" \
"0 J\n" \
"12 6.52 m 12 3 l S\n" \
"1 J\n" \
"8 3 m 16 3 l S\n" \
"0.729412 0.741176 0.713725 RG 12 21 m 12 21 l 13.656 21 15 19.656 15 18 c\n" \
"15 14 l 15 12.344 13.656 11 12 11 c 12 11 l 10.344 11 9 12.344 9 14 c\n" \
"9 18 l 9 19.656 10.344 21 12 21 c h\n" \
"12 21 m S\n" \
"1 w\n" \
"17.5 15.5 m 17.5 12.973 l 17.5 9.941 15.047 7.5 12 7.5 c 8.953 7.5 6.5\n" \
"9.941 6.5 12.973 c 6.5 15.5 l S\n" \
"2 w\n" \
"0 J\n" \
"12 7.52 m 12 4 l S\n" \
"1 J\n" \
"8 4 m 16 4 l S\n"
void AnnotSound::draw(Gfx *gfx, GBool printing) {
Object obj;
double ca = 1;
if (!isVisible (printing))
return;
if (appearance.isNull()) {
ca = opacity;
appearBuf = new GooString ();
appearBuf->append ("q\n");
if (color)
setColor(color, gTrue);
else
appearBuf->append ("1 1 1 rg\n");
if (!name->cmp("Speaker"))
appearBuf->append (ANNOT_SOUND_AP_SPEAKER);
else if (!name->cmp("Mic"))
appearBuf->append (ANNOT_SOUND_AP_MIC);
appearBuf->append ("Q\n");
Object appearDict, obj1, obj2;
appearDict.initDict(xref);
appearDict.dictSet("Length", obj1.initInt(appearBuf->getLength()));
appearDict.dictSet("Subtype", obj1.initName("Form"));
obj1.initArray(xref);
obj1.arrayAdd(obj2.initReal(0));
obj1.arrayAdd(obj2.initReal(0));
obj1.arrayAdd(obj2.initReal(24));
obj1.arrayAdd(obj2.initReal(24));
appearDict.dictSet("BBox", &obj1);
MemStream *appearStream = new MemStream(copyString(appearBuf->getCString()), 0,
appearBuf->getLength(), &appearDict);
appearStream->setNeedFree(gTrue);
appearance.initStream(appearStream);
delete appearBuf;
}
// draw the appearance stream
appearance.fetch(xref, &obj);
gfx->drawAnnot(&obj, border, color, ca,
rect->x1, rect->y1, rect->x2, rect->y2);
obj.free();
}
//------------------------------------------------------------------------
// Annot3D
//------------------------------------------------------------------------
......
......@@ -1182,6 +1182,8 @@ public:
AnnotSound(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
~AnnotSound();
virtual void draw(Gfx *gfx, GBool printing);
// getters
Sound *getSound() { return sound; }
GooString *getName() const { return name; }
......
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