Rev 20011 | Rev 20260 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
19590 | jghali | 1 | /* |
2 | For general Scribus (>=1.3.2) copyright and licensing information please refer |
||
3 | to the COPYING file provided with the program. Following this notice may exist |
||
4 | a copyright and/or license notice that predates the release of Scribus 1.3.2 |
||
5 | for which a new license (GPL+exception) is in place. |
||
6 | */ |
||
7 | |||
8 | #include "slaoutput.h" |
||
9 | #include <poppler/GlobalParams.h> |
||
10 | #include <poppler/poppler-config.h> |
||
11 | #include <poppler/FileSpec.h> |
||
12 | #include <poppler/fofi/FoFiTrueType.h> |
||
13 | #include <QApplication> |
||
14 | #include <QFile> |
||
15 | #include "commonstrings.h" |
||
16 | #include "loadsaveplugin.h" |
||
17 | #include "sccolorengine.h" |
||
18 | #include "util.h" |
||
19 | #include "util_math.h" |
||
20 | #include <tiffio.h> |
||
21 | |||
22 | LinkSubmitForm::LinkSubmitForm(Object *actionObj) |
||
23 | { |
||
24 | Object obj1, obj2, obj3; |
||
25 | fileName = NULL; |
||
26 | m_flags = 0; |
||
27 | if (actionObj->isDict()) |
||
28 | { |
||
29 | if (!actionObj->dictLookup("F", &obj1)->isNull()) |
||
30 | { |
||
31 | if (obj1.isDict()) |
||
32 | { |
||
33 | if (!obj1.dictLookup("FS", &obj3)->isNull()) |
||
34 | { |
||
35 | if (obj3.isName()) |
||
36 | { |
||
37 | char *name = obj3.getName(); |
||
38 | if (!strcmp(name, "URL")) |
||
39 | { |
||
40 | if (!obj1.dictLookup("F", &obj2)->isNull()) |
||
41 | fileName = obj2.getString()->copy(); |
||
42 | } |
||
43 | obj2.free(); |
||
44 | } |
||
45 | } |
||
46 | obj3.free(); |
||
47 | } |
||
48 | } |
||
49 | obj1.free(); |
||
50 | if (!actionObj->dictLookup("Flags", &obj1)->isNull()) |
||
51 | { |
||
52 | if (obj1.isNum()) |
||
53 | m_flags = obj1.getInt(); |
||
54 | } |
||
55 | obj1.free(); |
||
56 | } |
||
57 | } |
||
58 | |||
59 | LinkSubmitForm::~LinkSubmitForm() |
||
60 | { |
||
61 | if (fileName) |
||
62 | delete fileName; |
||
63 | } |
||
64 | |||
65 | LinkImportData::LinkImportData(Object *actionObj) |
||
66 | { |
||
67 | Object obj1, obj3; |
||
68 | fileName = NULL; |
||
69 | if (actionObj->isDict()) |
||
70 | { |
||
71 | if (!actionObj->dictLookup("F", &obj1)->isNull()) |
||
72 | { |
||
73 | if (getFileSpecNameForPlatform (&obj1, &obj3)) |
||
74 | { |
||
75 | fileName = obj3.getString()->copy(); |
||
76 | obj3.free(); |
||
77 | } |
||
78 | } |
||
79 | obj1.free(); |
||
80 | } |
||
81 | } |
||
82 | |||
83 | LinkImportData::~LinkImportData() |
||
84 | { |
||
85 | if (fileName) |
||
86 | delete fileName; |
||
87 | } |
||
88 | |||
89 | AnoOutputDev::~AnoOutputDev() |
||
90 | { |
||
91 | if (m_fontName) |
||
92 | delete m_fontName; |
||
93 | if (m_itemText) |
||
94 | delete m_itemText; |
||
95 | } |
||
96 | |||
97 | AnoOutputDev::AnoOutputDev(ScribusDoc* doc, QStringList *importedColors) |
||
98 | { |
||
99 | m_doc = doc; |
||
100 | m_importedColors = importedColors; |
||
101 | CurrColorStroke = CommonStrings::None; |
||
102 | CurrColorFill = CommonStrings::None; |
||
103 | CurrColorText = "Black"; |
||
104 | m_fontSize = 12.0; |
||
105 | m_fontName = NULL; |
||
106 | m_itemText = NULL; |
||
107 | } |
||
108 | |||
109 | void AnoOutputDev::eoFill(GfxState *state) |
||
110 | { |
||
111 | int shade = 100; |
||
112 | CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &shade); |
||
113 | } |
||
114 | |||
115 | void AnoOutputDev::fill(GfxState *state) |
||
116 | { |
||
117 | int shade = 100; |
||
118 | CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &shade); |
||
119 | } |
||
120 | |||
121 | void AnoOutputDev::stroke(GfxState *state) |
||
122 | { |
||
123 | int shade = 100; |
||
124 | CurrColorStroke = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &shade); |
||
125 | } |
||
126 | |||
127 | void AnoOutputDev::drawString(GfxState *state, GooString *s) |
||
128 | { |
||
129 | int shade = 100; |
||
130 | CurrColorText = getColor(state->getFillColorSpace(), state->getFillColor(), &shade); |
||
131 | m_fontSize = state->getFontSize(); |
||
132 | if (state->getFont()) |
||
133 | m_fontName = state->getFont()->getName()->copy(); |
||
134 | m_itemText = s->copy(); |
||
135 | } |
||
136 | |||
137 | QString AnoOutputDev::getColor(GfxColorSpace *color_space, GfxColor *color, int *shade) |
||
138 | { |
||
139 | QString fNam; |
||
140 | QString namPrefix = "FromPDF"; |
||
141 | ScColor tmp; |
||
142 | tmp.setSpotColor(false); |
||
143 | tmp.setRegistrationColor(false); |
||
144 | *shade = 100; |
||
145 | if ((color_space->getMode() == csDeviceRGB) || (color_space->getMode() == csCalRGB)) |
||
146 | { |
||
147 | GfxRGB rgb; |
||
148 | color_space->getRGB(color, &rgb); |
||
149 | int Rc = qRound(colToDbl(rgb.r) * 255); |
||
150 | int Gc = qRound(colToDbl(rgb.g) * 255); |
||
151 | int Bc = qRound(colToDbl(rgb.b) * 255); |
||
152 | tmp.setColorRGB(Rc, Gc, Bc); |
||
153 | fNam = m_doc->PageColors.tryAddColor(namPrefix+tmp.name(), tmp); |
||
154 | } |
||
155 | else if (color_space->getMode() == csDeviceCMYK) |
||
156 | { |
||
157 | GfxCMYK cmyk; |
||
158 | color_space->getCMYK(color, &cmyk); |
||
159 | int Cc = qRound(colToDbl(cmyk.c) * 255); |
||
160 | int Mc = qRound(colToDbl(cmyk.m) * 255); |
||
161 | int Yc = qRound(colToDbl(cmyk.y) * 255); |
||
162 | int Kc = qRound(colToDbl(cmyk.k) * 255); |
||
163 | tmp.setColor(Cc, Mc, Yc, Kc); |
||
164 | fNam = m_doc->PageColors.tryAddColor(namPrefix+tmp.name(), tmp); |
||
165 | } |
||
166 | else if ((color_space->getMode() == csCalGray) || (color_space->getMode() == csDeviceGray)) |
||
167 | { |
||
168 | GfxGray gray; |
||
169 | color_space->getGray(color, &gray); |
||
170 | int Kc = 255 - qRound(colToDbl(gray) * 255); |
||
171 | tmp.setColor(0, 0, 0, Kc); |
||
172 | fNam = m_doc->PageColors.tryAddColor(namPrefix+tmp.name(), tmp); |
||
173 | } |
||
174 | else if (color_space->getMode() == csSeparation) |
||
175 | { |
||
176 | GfxCMYK cmyk; |
||
177 | color_space->getCMYK(color, &cmyk); |
||
178 | int Cc = qRound(colToDbl(cmyk.c) * 255); |
||
179 | int Mc = qRound(colToDbl(cmyk.m) * 255); |
||
180 | int Yc = qRound(colToDbl(cmyk.y) * 255); |
||
181 | int Kc = qRound(colToDbl(cmyk.k) * 255); |
||
182 | tmp.setColor(Cc, Mc, Yc, Kc); |
||
183 | tmp.setSpotColor(true); |
||
184 | QString nam = QString(((GfxSeparationColorSpace*)color_space)->getName()->getCString()); |
||
185 | fNam = m_doc->PageColors.tryAddColor(nam, tmp); |
||
186 | *shade = qRound(colToDbl(color->c[0]) * 100); |
||
187 | } |
||
188 | else |
||
189 | { |
||
190 | GfxRGB rgb; |
||
191 | color_space->getRGB(color, &rgb); |
||
192 | int Rc = qRound(colToDbl(rgb.r) * 255); |
||
193 | int Gc = qRound(colToDbl(rgb.g) * 255); |
||
194 | int Bc = qRound(colToDbl(rgb.b) * 255); |
||
195 | tmp.setColorRGB(Rc, Gc, Bc); |
||
196 | fNam = m_doc->PageColors.tryAddColor(namPrefix+tmp.name(), tmp); |
||
197 | // qDebug() << "update fill color other colorspace" << color_space->getMode() << "treating as rgb" << Rc << Gc << Bc; |
||
198 | } |
||
199 | if (fNam == namPrefix+tmp.name()) |
||
200 | m_importedColors->append(fNam); |
||
201 | return fNam; |
||
202 | } |
||
203 | |||
204 | SlaOutputDev::SlaOutputDev(ScribusDoc* doc, QList<PageItem*> *Elements, QStringList *importedColors, int flags) |
||
205 | { |
||
206 | m_doc = doc; |
||
207 | m_Elements = Elements; |
||
208 | m_groupStack.clear(); |
||
209 | pushGroup(); |
||
20011 | fschmid | 210 | m_clipPaths.clear(); |
19590 | jghali | 211 | m_currentMask = ""; |
212 | m_importedColors = importedColors; |
||
213 | CurrColorStroke = "Black"; |
||
214 | CurrColorFill = "Black"; |
||
215 | Coords = ""; |
||
216 | pathIsClosed = false; |
||
217 | tmpSel = new Selection(m_doc, false); |
||
218 | firstLayer = true; |
||
219 | layerNum = 1; |
||
220 | importerFlags = flags; |
||
221 | currentLayer = m_doc->activeLayer(); |
||
222 | xref = NULL; |
||
223 | m_fontEngine = 0; |
||
224 | m_font = 0; |
||
225 | m_formWidgets = 0; |
||
226 | updateGUICounter = 0; |
||
227 | layersSetByOCG = false; |
||
228 | cropOffsetX = 0; |
||
229 | cropOffsetY = 0; |
||
230 | } |
||
231 | |||
232 | SlaOutputDev::~SlaOutputDev() |
||
233 | { |
||
234 | m_groupStack.clear(); |
||
235 | tmpSel->clear(); |
||
236 | delete tmpSel; |
||
237 | delete m_fontEngine; |
||
238 | } |
||
239 | |||
240 | /* get Actions not implemented by Poppler */ |
||
241 | LinkAction* SlaOutputDev::SC_getAction(AnnotWidget *ano) |
||
242 | { |
||
243 | LinkAction *linkAction = NULL; |
||
244 | Object obj; |
||
245 | Ref refa = ano->getRef(); |
||
246 | Object additionalActions; |
||
247 | Object *act = xref->fetch(refa.num, refa.gen, &obj); |
||
248 | if (act) |
||
249 | { |
||
250 | if (act->isDict()) |
||
251 | { |
||
252 | Dict* adic = act->getDict(); |
||
253 | adic->lookupNF("A", &additionalActions); |
||
254 | Object additionalActionsObject; |
||
255 | if (additionalActions.fetch(pdfDoc->getXRef(), &additionalActionsObject)->isDict()) |
||
256 | { |
||
257 | Object actionObject; |
||
258 | additionalActionsObject.dictLookup("S", &actionObject); |
||
259 | if (actionObject.isName("ImportData")) |
||
260 | { |
||
261 | linkAction = new LinkImportData(&additionalActionsObject); |
||
262 | } |
||
263 | else if (actionObject.isName("SubmitForm")) |
||
264 | { |
||
265 | linkAction = new LinkSubmitForm(&additionalActionsObject); |
||
266 | } |
||
267 | actionObject.free(); |
||
268 | } |
||
269 | additionalActionsObject.free(); |
||
270 | additionalActions.free(); |
||
271 | } |
||
272 | } |
||
273 | obj.free(); |
||
274 | return linkAction; |
||
275 | } |
||
276 | |||
277 | /* Replacement for the crippled Poppler function LinkAction* AnnotWidget::getAdditionalAction(AdditionalActionsType type) */ |
||
278 | LinkAction* SlaOutputDev::SC_getAdditionalAction(const char *key, AnnotWidget *ano) |
||
279 | { |
||
280 | LinkAction *linkAction = NULL; |
||
281 | Object obj; |
||
282 | Ref refa = ano->getRef(); |
||
283 | Object additionalActions; |
||
284 | Object *act = xref->fetch(refa.num, refa.gen, &obj); |
||
285 | if (act) |
||
286 | { |
||
287 | if (act->isDict()) |
||
288 | { |
||
289 | Dict* adic = act->getDict(); |
||
290 | adic->lookupNF("AA", &additionalActions); |
||
291 | Object additionalActionsObject; |
||
292 | if (additionalActions.fetch(pdfDoc->getXRef(), &additionalActionsObject)->isDict()) |
||
293 | { |
||
294 | Object actionObject; |
||
295 | if (additionalActionsObject.dictLookup(key, &actionObject)->isDict()) |
||
296 | linkAction = LinkAction::parseAction(&actionObject, pdfDoc->getCatalog()->getBaseURI()); |
||
297 | actionObject.free(); |
||
298 | } |
||
299 | additionalActionsObject.free(); |
||
300 | additionalActions.free(); |
||
301 | } |
||
302 | } |
||
303 | obj.free(); |
||
304 | return linkAction; |
||
305 | } |
||
306 | |||
307 | GBool SlaOutputDev::annotations_callback(Annot *annota, void *user_data) |
||
308 | { |
||
309 | SlaOutputDev *dev = (SlaOutputDev*)user_data; |
||
310 | PDFRectangle *box = annota->getRect(); |
||
311 | double xCoor = dev->m_doc->currentPage()->xOffset() + box->x1 - dev->cropOffsetX; |
||
312 | double yCoor = dev->m_doc->currentPage()->yOffset() + dev->m_doc->currentPage()->height() - box->y2 + dev->cropOffsetY; |
||
313 | double width = box->x2 - box->x1; |
||
314 | double height = box->y2 - box->y1; |
||
315 | if (dev->rotate == 90) |
||
316 | { |
||
317 | xCoor = dev->m_doc->currentPage()->xOffset() - dev->cropOffsetX + box->y2; |
||
318 | yCoor = dev->m_doc->currentPage()->yOffset() + dev->cropOffsetY + box->x1; |
||
319 | } |
||
320 | else if (dev->rotate == 180) |
||
321 | { |
||
322 | xCoor = dev->m_doc->currentPage()->xOffset() - dev->cropOffsetX + dev->m_doc->currentPage()->width() - box->x1; |
||
323 | yCoor = dev->m_doc->currentPage()->yOffset() + dev->cropOffsetY + box->y2; |
||
324 | } |
||
325 | else if (dev->rotate == 270) |
||
326 | { |
||
327 | xCoor = dev->m_doc->currentPage()->xOffset() - dev->cropOffsetX + dev->m_doc->currentPage()->width() - box->y2; |
||
328 | yCoor = dev->m_doc->currentPage()->yOffset() + dev->cropOffsetY + dev->m_doc->currentPage()->height() - box->x1; |
||
329 | } |
||
330 | bool retVal = true; |
||
331 | if (annota->getType() == Annot::typeText) |
||
332 | retVal = !dev->handleTextAnnot(annota, xCoor, yCoor, width, height); |
||
333 | else if (annota->getType() == Annot::typeLink) |
||
334 | retVal = !dev->handleLinkAnnot(annota, xCoor, yCoor, width, height); |
||
335 | else if (annota->getType() == Annot::typeWidget) |
||
336 | retVal = !dev->handleWidgetAnnot(annota, xCoor, yCoor, width, height); |
||
337 | return retVal; |
||
338 | } |
||
339 | |||
340 | bool SlaOutputDev::handleTextAnnot(Annot* annota, double xCoor, double yCoor, double width, double height) |
||
341 | { |
||
342 | AnnotText *anl = (AnnotText*)annota; |
||
343 | int z = m_doc->itemAdd(PageItem::TextFrame, PageItem::Rectangle, xCoor, yCoor, width, height, 0, CommonStrings::None, CommonStrings::None, true); |
||
344 | PageItem *ite = m_doc->Items->at(z); |
||
345 | int flg = annota->getFlags(); |
||
346 | if (!(flg & 16)) |
||
347 | ite->setRotation(rotate, true); |
||
348 | ite->ClipEdited = true; |
||
349 | ite->FrameType = 3; |
||
350 | ite->setFillEvenOdd(false); |
||
351 | ite->Clip = FlattenPath(ite->PoLine, ite->Segments); |
||
352 | ite->ContourLine = ite->PoLine.copy(); |
||
353 | ite->setTextFlowMode(PageItem::TextFlowDisabled); |
||
354 | m_Elements->append(ite); |
||
355 | if (m_groupStack.count() != 0) |
||
356 | { |
||
357 | m_groupStack.top().Items.append(ite); |
||
358 | applyMask(ite); |
||
359 | } |
||
360 | ite->setIsAnnotation(true); |
||
361 | ite->AutoName = false; |
||
362 | ite->annotation().setType(Annotation::Text); |
||
363 | ite->annotation().setActionType(Annotation::Action_None); |
||
364 | ite->annotation().setAnOpen(anl->getOpen()); |
||
365 | QString iconName = UnicodeParsedString(anl->getIcon()); |
||
366 | if (iconName == "Note") |
||
367 | ite->annotation().setIcon(Annotation::Icon_Note); |
||
368 | else if (iconName == "Comment") |
||
369 | ite->annotation().setIcon(Annotation::Icon_Comment); |
||
370 | else if (iconName == "Key") |
||
371 | ite->annotation().setIcon(Annotation::Icon_Key); |
||
372 | else if (iconName == "Help") |
||
373 | ite->annotation().setIcon(Annotation::Icon_Help); |
||
374 | else if (iconName == "NewParagraph") |
||
375 | ite->annotation().setIcon(Annotation::Icon_NewParagraph); |
||
376 | else if (iconName == "Paragraph") |
||
377 | ite->annotation().setIcon(Annotation::Icon_Paragraph); |
||
378 | else if (iconName == "Insert") |
||
379 | ite->annotation().setIcon(Annotation::Icon_Insert); |
||
380 | else if (iconName == "Cross") |
||
381 | ite->annotation().setIcon(Annotation::Icon_Cross); |
||
382 | else if (iconName == "Circle") |
||
383 | ite->annotation().setIcon(Annotation::Icon_Circle); |
||
384 | else |
||
385 | ite->annotation().setIcon(Annotation::Icon_Note); |
||
386 | ite->setItemName( CommonStrings::itemName_TextAnnotation + QString("%1").arg(m_doc->TotalItems)); |
||
387 | ite->itemText.insertChars(UnicodeParsedString(annota->getContents())); |
||
388 | ite->itemText.trim(); |
||
389 | return true; |
||
390 | } |
||
391 | |||
392 | bool SlaOutputDev::handleLinkAnnot(Annot* annota, double xCoor, double yCoor, double width, double height) |
||
393 | { |
||
394 | AnnotLink *anl = (AnnotLink*)annota; |
||
395 | LinkAction *act = anl->getAction(); |
||
396 | if (!act) |
||
397 | return false; |
||
398 | bool validLink = false; |
||
399 | int pagNum = 0; |
||
400 | int xco = 0; |
||
401 | int yco = 0; |
||
402 | QString fileName = ""; |
||
403 | if (act->getKind() == actionGoTo) |
||
404 | { |
||
405 | LinkGoTo *gto = (LinkGoTo*)act; |
||
406 | LinkDest *dst = gto->getDest(); |
||
407 | if (dst) |
||
408 | { |
||
409 | if (dst->getKind() == destXYZ) |
||
410 | { |
||
411 | if (dst->isPageRef()) |
||
412 | { |
||
413 | Ref dstr = dst->getPageRef(); |
||
414 | pagNum = pdfDoc->findPage(dstr.num, dstr.gen); |
||
415 | } |
||
416 | else |
||
417 | pagNum = dst->getPageNum(); |
||
418 | xco = dst->getLeft(); |
||
419 | yco = dst->getTop(); |
||
420 | validLink = true; |
||
421 | } |
||
422 | } |
||
423 | else |
||
424 | { |
||
425 | GooString *ndst = gto->getNamedDest(); |
||
426 | if (ndst) |
||
427 | { |
||
428 | LinkDest *dstn = pdfDoc->findDest(ndst); |
||
429 | if (dstn) |
||
430 | { |
||
431 | if (dstn->getKind() == destXYZ) |
||
432 | { |
||
433 | if (dstn->isPageRef()) |
||
434 | { |
||
435 | Ref dstr = dstn->getPageRef(); |
||
436 | pagNum = pdfDoc->findPage(dstr.num, dstr.gen); |
||
437 | } |
||
438 | else |
||
439 | pagNum = dstn->getPageNum(); |
||
440 | xco = dstn->getLeft(); |
||
441 | yco = dstn->getTop(); |
||
442 | validLink = true; |
||
443 | } |
||
444 | } |
||
445 | } |
||
446 | } |
||
447 | } |
||
448 | else if (act->getKind() == actionGoToR) |
||
449 | { |
||
450 | LinkGoToR *gto = (LinkGoToR*)act; |
||
451 | fileName = UnicodeParsedString(gto->getFileName()); |
||
452 | LinkDest *dst = gto->getDest(); |
||
453 | if (dst) |
||
454 | { |
||
455 | if (dst->getKind() == destXYZ) |
||
456 | { |
||
457 | pagNum = dst->getPageNum(); |
||
458 | xco = dst->getLeft(); |
||
459 | yco = dst->getTop(); |
||
460 | validLink = true; |
||
461 | } |
||
462 | } |
||
463 | else |
||
464 | { |
||
465 | GooString *ndst = gto->getNamedDest(); |
||
466 | if (ndst) |
||
467 | { |
||
468 | LinkDest *dstn = pdfDoc->findDest(ndst); |
||
469 | if (dstn) |
||
470 | { |
||
471 | if (dstn->getKind() == destXYZ) |
||
472 | { |
||
473 | pagNum = dstn->getPageNum(); |
||
474 | xco = dstn->getLeft(); |
||
475 | yco = dstn->getTop(); |
||
476 | validLink = true; |
||
477 | } |
||
478 | } |
||
479 | } |
||
480 | } |
||
481 | } |
||
482 | else if (act->getKind() == actionURI) |
||
483 | { |
||
484 | LinkURI *gto = (LinkURI*)act; |
||
485 | validLink = true; |
||
486 | fileName = UnicodeParsedString(gto->getURI()); |
||
487 | } |
||
488 | if (validLink) |
||
489 | { |
||
490 | int z = m_doc->itemAdd(PageItem::TextFrame, PageItem::Rectangle, xCoor, yCoor, width, height, 0, CommonStrings::None, CommonStrings::None, true); |
||
491 | PageItem *ite = m_doc->Items->at(z); |
||
492 | int flg = annota->getFlags(); |
||
493 | if (!(flg & 16)) |
||
494 | ite->setRotation(rotate, true); |
||
495 | ite->ClipEdited = true; |
||
496 | ite->FrameType = 3; |
||
497 | ite->setFillEvenOdd(false); |
||
498 | ite->Clip = FlattenPath(ite->PoLine, ite->Segments); |
||
499 | ite->ContourLine = ite->PoLine.copy(); |
||
500 | ite->setTextFlowMode(PageItem::TextFlowDisabled); |
||
501 | m_Elements->append(ite); |
||
502 | if (m_groupStack.count() != 0) |
||
503 | { |
||
504 | m_groupStack.top().Items.append(ite); |
||
505 | applyMask(ite); |
||
506 | } |
||
507 | ite->setIsAnnotation(true); |
||
508 | ite->AutoName = false; |
||
509 | if (act->getKind() == actionGoTo) |
||
510 | { |
||
511 | ite->annotation().setZiel(pagNum - 1); |
||
512 | ite->annotation().setAction(QString("%1 %2").arg(xco).arg(yco)); |
||
513 | ite->annotation().setActionType(2); |
||
514 | } |
||
515 | else if (act->getKind() == actionGoToR) |
||
516 | { |
||
517 | ite->annotation().setZiel(pagNum - 1); |
||
518 | ite->annotation().setExtern(fileName); |
||
519 | ite->annotation().setAction(QString("%1 %2").arg(xco).arg(yco)); |
||
520 | ite->annotation().setActionType(9); |
||
521 | } |
||
522 | else if (act->getKind() == actionURI) |
||
523 | { |
||
524 | ite->annotation().setAction(""); |
||
525 | ite->annotation().setExtern(fileName); |
||
526 | ite->annotation().setActionType(8); |
||
527 | } |
||
528 | ite->annotation().setType(Annotation::Link); |
||
529 | ite->setItemName( CommonStrings::itemName_LinkAnnotation + QString("%1").arg(m_doc->TotalItems)); |
||
530 | } |
||
531 | return validLink; |
||
532 | } |
||
533 | |||
534 | bool SlaOutputDev::handleWidgetAnnot(Annot* annota, double xCoor, double yCoor, double width, double height) |
||
535 | { |
||
536 | bool retVal = false; |
||
537 | bool found = false; |
||
538 | |||
539 | if (!m_formWidgets) |
||
540 | return false; |
||
541 | |||
542 | int formcount = m_formWidgets->getNumWidgets(); |
||
543 | for (int i = 0; i < formcount; ++i) |
||
544 | { |
||
545 | FormWidget *fm = m_formWidgets->getWidget(i); |
||
546 | if (!fm) |
||
547 | continue; |
||
548 | AnnotWidget *ano = fm->getWidgetAnnotation(); |
||
549 | if (!ano) |
||
550 | continue; |
||
551 | if (ano != (AnnotWidget*) annota) |
||
552 | continue; |
||
553 | found = true; |
||
554 | int wtyp = -1; |
||
555 | if (fm->getType() == formButton) |
||
556 | { |
||
557 | FormWidgetButton *btn = (FormWidgetButton*)fm; |
||
558 | if (btn) |
||
559 | { |
||
560 | if (btn->getButtonType() == formButtonCheck) |
||
561 | { |
||
562 | wtyp = Annotation::Checkbox; |
||
563 | retVal = true; |
||
564 | } |
||
565 | else if (btn->getButtonType() == formButtonPush) |
||
566 | { |
||
567 | wtyp = Annotation::Button; |
||
568 | retVal = true; |
||
569 | } |
||
570 | else if (btn->getButtonType() == formButtonRadio) |
||
571 | { |
||
572 | wtyp = Annotation::RadioButton; |
||
573 | retVal = true; |
||
574 | } |
||
575 | } |
||
576 | } |
||
577 | else if (fm->getType() == formText) |
||
578 | { |
||
579 | wtyp = Annotation::Textfield; |
||
580 | retVal = true; |
||
581 | } |
||
582 | else if (fm->getType() == formChoice) |
||
583 | { |
||
584 | FormWidgetChoice *btn = (FormWidgetChoice*)fm; |
||
585 | if (btn) |
||
586 | { |
||
587 | if (btn->isCombo()) |
||
588 | { |
||
589 | wtyp = Annotation::Combobox; |
||
590 | retVal = true; |
||
591 | } |
||
592 | else if (btn->isListBox()) |
||
593 | { |
||
594 | wtyp = Annotation::Listbox; |
||
595 | retVal = true; |
||
596 | } |
||
597 | } |
||
598 | } |
||
599 | if (retVal) |
||
600 | { |
||
601 | AnnotAppearanceCharacs *achar = ano->getAppearCharacs(); |
||
602 | bool fgFound = false; |
||
603 | bool bgFound = false; |
||
604 | if (achar) |
||
605 | { |
||
606 | AnnotColor *bgCol = achar->getBackColor(); |
||
607 | if (bgCol) |
||
608 | { |
||
609 | bgFound = true; |
||
610 | CurrColorFill = getAnnotationColor(bgCol); |
||
611 | } |
||
612 | else |
||
613 | CurrColorFill = CommonStrings::None; |
||
614 | AnnotColor *fgCol = achar->getBorderColor(); |
||
615 | if (fgCol) |
||
616 | { |
||
617 | fgFound = true; |
||
618 | CurrColorStroke = getAnnotationColor(fgCol); |
||
619 | } |
||
620 | else |
||
621 | { |
||
622 | fgCol = achar->getBackColor(); |
||
623 | if (fgCol) |
||
624 | CurrColorStroke = getAnnotationColor(fgCol); |
||
625 | else |
||
626 | CurrColorStroke = CommonStrings::None; |
||
627 | } |
||
628 | } |
||
629 | QString CurrColorText = "Black"; |
||
630 | double fontSize = 12; |
||
631 | QString fontName = ""; |
||
632 | QString itemText = ""; |
||
633 | AnnotAppearance *apa = annota->getAppearStreams(); |
||
634 | if (apa || !achar) |
||
635 | { |
||
636 | AnoOutputDev *Adev = new AnoOutputDev(m_doc, m_importedColors); |
||
637 | Gfx *gfx; |
||
638 | #ifdef POPPLER_VERSION |
||
639 | gfx = new Gfx(pdfDoc, Adev, pdfDoc->getPage(m_actPage)->getResourceDict(), annota->getRect(), NULL); |
||
640 | #else |
||
641 | gfx = new Gfx(xref, Adev, pdfDoc->getPage(m_actPage)->getResourceDict(), catalog, annota->getRect(), NULL); |
||
642 | #endif |
||
643 | ano->draw(gfx, false); |
||
644 | if (!bgFound) |
||
645 | CurrColorFill = Adev->CurrColorFill; |
||
646 | if (!fgFound) |
||
647 | CurrColorStroke = Adev->CurrColorStroke; |
||
648 | CurrColorText = Adev->CurrColorText; |
||
649 | fontSize = Adev->m_fontSize; |
||
650 | fontName = UnicodeParsedString(Adev->m_fontName); |
||
651 | itemText = UnicodeParsedString(Adev->m_itemText); |
||
652 | delete gfx; |
||
653 | delete Adev; |
||
654 | } |
||
655 | int z = m_doc->itemAdd(PageItem::TextFrame, PageItem::Rectangle, xCoor, yCoor, width, height, 0, CurrColorFill, CommonStrings::None, true); |
||
656 | PageItem *ite = m_doc->Items->at(z); |
||
657 | int flg = annota->getFlags(); |
||
658 | if (!(flg & 16)) |
||
659 | ite->setRotation(rotate, true); |
||
660 | ite->ClipEdited = true; |
||
661 | ite->FrameType = 3; |
||
662 | ite->setFillEvenOdd(false); |
||
663 | ite->Clip = FlattenPath(ite->PoLine, ite->Segments); |
||
664 | ite->ContourLine = ite->PoLine.copy(); |
||
665 | ite->setTextFlowMode(PageItem::TextFlowDisabled); |
||
666 | m_Elements->append(ite); |
||
667 | if (m_groupStack.count() != 0) |
||
668 | { |
||
669 | m_groupStack.top().Items.append(ite); |
||
670 | applyMask(ite); |
||
671 | } |
||
672 | ite->setIsAnnotation(true); |
||
673 | ite->AutoName = false; |
||
674 | AnnotBorder *brd = annota->getBorder(); |
||
675 | if (brd) |
||
676 | { |
||
677 | int bsty = brd->getStyle(); |
||
678 | if (bsty == AnnotBorder::borderDashed) |
||
679 | bsty = 1; |
||
680 | else if (bsty == AnnotBorder::borderBeveled) |
||
681 | bsty = 3; |
||
682 | else if (bsty == AnnotBorder::borderInset) |
||
683 | bsty = 4; |
||
684 | else if (bsty == AnnotBorder::borderUnderlined) |
||
685 | bsty = 2; |
||
686 | ite->annotation().setBsty(bsty); |
||
687 | ite->annotation().setBorderColor(CurrColorStroke); |
||
688 | ite->annotation().setBwid(qRound(brd->getWidth())); |
||
689 | } |
||
690 | else |
||
691 | { |
||
692 | ite->annotation().setBsty(0); |
||
693 | ite->annotation().setBorderColor(CommonStrings::None); |
||
694 | ite->annotation().setBwid(0); |
||
695 | } |
||
696 | QString tmTxt = ""; |
||
697 | tmTxt = UnicodeParsedString(fm->getPartialName()); |
||
698 | if (!tmTxt.isEmpty()) |
||
699 | ite->setItemName(tmTxt); |
||
700 | tmTxt = ""; |
||
701 | tmTxt = UnicodeParsedString(fm->getAlternateUiName()); |
||
702 | if (!tmTxt.isEmpty()) |
||
703 | ite->annotation().setToolTip(tmTxt); |
||
704 | tmTxt = ""; |
||
705 | if (achar) |
||
706 | { |
||
707 | tmTxt = UnicodeParsedString(achar->getRolloverCaption()); |
||
708 | if (!tmTxt.isEmpty()) |
||
709 | ite->annotation().setRollOver(tmTxt); |
||
710 | tmTxt = ""; |
||
711 | tmTxt = UnicodeParsedString(achar->getAlternateCaption()); |
||
712 | if (!tmTxt.isEmpty()) |
||
713 | ite->annotation().setDown(tmTxt); |
||
714 | } |
||
715 | ite->annotation().setType(wtyp); |
||
716 | ite->annotation().setFlag(0); |
||
717 | if (flg & 2) |
||
718 | ite->annotation().setVis(1); |
||
719 | if (flg & 32) |
||
720 | ite->annotation().setVis(3); |
||
721 | if (wtyp == Annotation::Button) |
||
722 | { |
||
723 | ite->setFillColor(CurrColorFill); |
||
724 | if (achar) |
||
725 | ite->itemText.insertChars(UnicodeParsedString(achar->getNormalCaption())); |
||
726 | else |
||
727 | ite->itemText.insertChars(itemText); |
||
728 | applyTextStyle(ite, fontName, CurrColorText, fontSize); |
||
729 | ite->annotation().addToFlag(Annotation::Flag_PushButton); |
||
730 | FormWidgetButton *btn = (FormWidgetButton*)fm; |
||
731 | if (!btn->isReadOnly()) |
||
732 | ite->annotation().addToFlag(Annotation::Flag_Edit); |
||
733 | handleActions(ite, ano); |
||
734 | } |
||
735 | else if (wtyp == Annotation::Textfield) |
||
736 | { |
||
737 | FormWidgetText *btn = (FormWidgetText*)fm; |
||
738 | if (btn) |
||
739 | { |
||
740 | ite->itemText.insertChars(UnicodeParsedString(btn->getContent())); |
||
741 | applyTextStyle(ite, fontName, CurrColorText, fontSize); |
||
742 | ite->itemText.trim(); |
||
743 | if (btn->isMultiline()) |
||
744 | ite->annotation().addToFlag(Annotation::Flag_Multiline); |
||
745 | if (btn->isPassword()) |
||
746 | ite->annotation().addToFlag(Annotation::Flag_Password); |
||
747 | if (btn->noSpellCheck()) |
||
748 | ite->annotation().addToFlag(Annotation::Flag_DoNotSpellCheck); |
||
749 | if (btn->noScroll()) |
||
750 | ite->annotation().addToFlag(Annotation::Flag_DoNotScroll); |
||
751 | int mxLen = btn->getMaxLen(); |
||
752 | if (mxLen > 0) |
||
753 | ite->annotation().setMaxChar(mxLen); |
||
754 | else |
||
755 | ite->annotation().setMaxChar(-1); |
||
756 | if (!btn->isReadOnly()) |
||
757 | ite->annotation().addToFlag(Annotation::Flag_Edit); |
||
758 | handleActions(ite, ano); |
||
759 | } |
||
760 | } |
||
761 | else if (wtyp == Annotation::Checkbox) |
||
762 | { |
||
763 | FormWidgetButton *btn = (FormWidgetButton*)fm; |
||
764 | if (btn) |
||
765 | { |
||
766 | ite->annotation().setIsChk(btn->getState()); |
||
767 | ite->annotation().setCheckState(ite->annotation().IsChk()); |
||
768 | handleActions(ite, ano); |
||
769 | if (itemText == "4") |
||
770 | ite->annotation().setChkStil(0); |
||
771 | else if (itemText == "5") |
||
772 | ite->annotation().setChkStil(1); |
||
773 | else if (itemText == "F") |
||
774 | ite->annotation().setChkStil(2); |
||
775 | else if (itemText == "l") |
||
776 | ite->annotation().setChkStil(3); |
||
777 | else if (itemText == "H") |
||
778 | ite->annotation().setChkStil(4); |
||
779 | else if (itemText == "n") |
||
780 | ite->annotation().setChkStil(5); |
||
781 | else |
||
782 | ite->annotation().setChkStil(0); |
||
783 | if (!btn->isReadOnly()) |
||
784 | ite->annotation().addToFlag(Annotation::Flag_Edit); |
||
785 | } |
||
786 | } |
||
787 | else if ((wtyp == Annotation::Combobox) || (wtyp == Annotation::Listbox)) |
||
788 | { |
||
789 | FormWidgetChoice *btn = (FormWidgetChoice*)fm; |
||
790 | if (btn) |
||
791 | { |
||
792 | if (wtyp == 5) |
||
793 | ite->annotation().addToFlag(Annotation::Flag_Combo); |
||
794 | int co = btn->getNumChoices(); |
||
795 | if (co > 0) |
||
796 | { |
||
797 | QString inh = UnicodeParsedString(btn->getChoice(0)); |
||
798 | for (int a = 1; a < co; a++) |
||
799 | { |
||
800 | inh += "\n" + UnicodeParsedString(btn->getChoice(a)); |
||
801 | } |
||
802 | ite->itemText.insertChars(inh); |
||
803 | } |
||
804 | applyTextStyle(ite, fontName, CurrColorText, fontSize); |
||
805 | if (!btn->isReadOnly()) |
||
806 | ite->annotation().addToFlag(Annotation::Flag_Edit); |
||
807 | handleActions(ite, ano); |
||
808 | } |
||
809 | } |
||
810 | else if (wtyp == Annotation::RadioButton) |
||
811 | { |
||
812 | FormWidgetButton *btn = (FormWidgetButton*)fm; |
||
813 | if (btn) |
||
814 | { |
||
815 | ite->setItemName( CommonStrings::itemName_RadioButton + QString("%1").arg(m_doc->TotalItems)); |
||
816 | ite->annotation().setIsChk(btn->getState()); |
||
817 | ite->annotation().setCheckState(ite->annotation().IsChk()); |
||
818 | handleActions(ite, ano); |
||
819 | m_radioButtons.insert(annota->getRef().num, ite); |
||
820 | } |
||
821 | } |
||
822 | } |
||
823 | break; |
||
824 | } |
||
825 | if (!found) |
||
826 | { |
||
827 | Object obj1; |
||
828 | Ref refa = annota->getRef(); |
||
829 | Object *act = xref->fetch(refa.num, refa.gen, &obj1); |
||
830 | if (act && act->isDict()) |
||
831 | { |
||
832 | Dict* dict = act->getDict(); |
||
833 | Object obj2; |
||
834 | //childs |
||
835 | if (dict->lookup("Kids", &obj2)->isArray()) |
||
836 | { |
||
837 | // Load children |
||
838 | QList<int> radList; |
||
839 | for (int i = 0 ; i < obj2.arrayGetLength(); i++) |
||
840 | { |
||
841 | Object childRef, childObj; |
||
842 | if (!obj2.arrayGetNF(i, &childRef)->isRef()) |
||
843 | { |
||
844 | childRef.free(); |
||
845 | continue; |
||
846 | } |
||
847 | if (!obj2.arrayGet(i, &childObj)->isDict()) |
||
848 | { |
||
849 | childObj.free(); |
||
850 | childRef.free(); |
||
851 | continue; |
||
852 | } |
||
853 | const Ref ref = childRef.getRef(); |
||
854 | radList.append(ref.num); |
||
855 | childObj.free(); |
||
856 | childRef.free(); |
||
857 | } |
||
858 | QString tmTxt = UnicodeParsedString(annota->getName()); |
||
859 | m_radioMap.insert(tmTxt, radList); |
||
860 | } |
||
861 | obj2.free(); |
||
862 | } |
||
863 | obj1.free(); |
||
864 | } |
||
865 | return retVal; |
||
866 | } |
||
867 | |||
868 | void SlaOutputDev::applyTextStyle(PageItem* ite, QString fontName, QString textColor, double fontSize) |
||
869 | { |
||
870 | CharStyle newStyle; |
||
871 | newStyle.setFillColor(textColor); |
||
872 | newStyle.setFontSize(fontSize * 10); |
||
873 | if (!fontName.isEmpty()) |
||
874 | { |
||
875 | SCFontsIterator it(*m_doc->AllFonts); |
||
876 | for ( ; it.hasNext() ; it.next()) |
||
877 | { |
||
878 | ScFace& face(it.current()); |
||
879 | if ((face.psName() == fontName) && (face.usable()) && (face.type() == ScFace::TTF)) |
||
880 | { |
||
881 | newStyle.setFont(face); |
||
882 | break; |
||
883 | } |
||
884 | else if ((face.family() == fontName) && (face.usable()) && (face.type() == ScFace::TTF)) |
||
885 | { |
||
886 | newStyle.setFont(face); |
||
887 | break; |
||
888 | } |
||
889 | else if ((face.scName() == fontName) && (face.usable()) && (face.type() == ScFace::TTF)) |
||
890 | { |
||
891 | newStyle.setFont(face); |
||
892 | break; |
||
893 | } |
||
894 | } |
||
895 | } |
||
896 | ParagraphStyle dstyle(ite->itemText.defaultStyle()); |
||
897 | dstyle.charStyle().applyCharStyle(newStyle); |
||
898 | ite->itemText.setDefaultStyle(dstyle); |
||
899 | ite->itemText.applyCharStyle(0, ite->itemText.length(), newStyle); |
||
900 | ite->invalid = true; |
||
901 | } |
||
902 | |||
903 | void SlaOutputDev::handleActions(PageItem* ite, AnnotWidget *ano) |
||
904 | { |
||
905 | LinkAction *Lact = ano->getAction(); |
||
906 | if (Lact) |
||
907 | { |
||
908 | if (Lact->getKind() == actionJavaScript) |
||
909 | { |
||
910 | LinkJavaScript *jsa = (LinkJavaScript*)Lact; |
||
911 | if (jsa->isOk()) |
||
912 | { |
||
913 | ite->annotation().setActionType(1); |
||
914 | ite->annotation().setAction(UnicodeParsedString(jsa->getScript())); |
||
915 | } |
||
916 | } |
||
917 | else if (Lact->getKind() == actionGoTo) |
||
918 | { |
||
919 | int pagNum = 0; |
||
920 | int xco = 0; |
||
921 | int yco = 0; |
||
922 | LinkGoTo *gto = (LinkGoTo*)Lact; |
||
923 | LinkDest *dst = gto->getDest(); |
||
924 | if (dst) |
||
925 | { |
||
926 | if (dst->getKind() == destXYZ) |
||
927 | { |
||
928 | if (dst->isPageRef()) |
||
929 | { |
||
930 | Ref dstr = dst->getPageRef(); |
||
931 | pagNum = pdfDoc->findPage(dstr.num, dstr.gen); |
||
932 | } |
||
933 | else |
||
934 | pagNum = dst->getPageNum(); |
||
935 | xco = dst->getLeft(); |
||
936 | yco = dst->getTop(); |
||
937 | ite->annotation().setZiel(pagNum - 1); |
||
938 | ite->annotation().setAction(QString("%1 %2").arg(xco).arg(yco)); |
||
939 | ite->annotation().setActionType(2); |
||
940 | } |
||
941 | } |
||
942 | else |
||
943 | { |
||
944 | GooString *ndst = gto->getNamedDest(); |
||
945 | if (ndst) |
||
946 | { |
||
947 | LinkDest *dstn = pdfDoc->findDest(ndst); |
||
948 | if (dstn) |
||
949 | { |
||
950 | if (dstn->getKind() == destXYZ) |
||
951 | { |
||
952 | if (dstn->isPageRef()) |
||
953 | { |
||
954 | Ref dstr = dstn->getPageRef(); |
||
955 | pagNum = pdfDoc->findPage(dstr.num, dstr.gen); |
||
956 | } |
||
957 | else |
||
958 | pagNum = dstn->getPageNum(); |
||
959 | xco = dstn->getLeft(); |
||
960 | yco = dstn->getTop(); |
||
961 | ite->annotation().setZiel(pagNum - 1); |
||
962 | ite->annotation().setAction(QString("%1 %2").arg(xco).arg(yco)); |
||
963 | ite->annotation().setActionType(2); |
||
964 | } |
||
965 | } |
||
966 | } |
||
967 | } |
||
968 | } |
||
969 | else if (Lact->getKind() == actionGoToR) |
||
970 | { |
||
971 | int pagNum = 0; |
||
972 | int xco = 0; |
||
973 | int yco = 0; |
||
974 | LinkGoToR *gto = (LinkGoToR*)Lact; |
||
975 | QString fileName = UnicodeParsedString(gto->getFileName()); |
||
976 | LinkDest *dst = gto->getDest(); |
||
977 | if (dst) |
||
978 | { |
||
979 | if (dst->getKind() == destXYZ) |
||
980 | { |
||
981 | pagNum = dst->getPageNum(); |
||
982 | xco = dst->getLeft(); |
||
983 | yco = dst->getTop(); |
||
984 | ite->annotation().setZiel(pagNum - 1); |
||
985 | ite->annotation().setExtern(fileName); |
||
986 | ite->annotation().setAction(QString("%1 %2").arg(xco).arg(yco)); |
||
987 | ite->annotation().setActionType(9); |
||
988 | } |
||
989 | } |
||
990 | else |
||
991 | { |
||
992 | GooString *ndst = gto->getNamedDest(); |
||
993 | if (ndst) |
||
994 | { |
||
995 | LinkDest *dstn = pdfDoc->findDest(ndst); |
||
996 | if (dstn) |
||
997 | { |
||
998 | if (dstn->getKind() == destXYZ) |
||
999 | { |
||
1000 | pagNum = dstn->getPageNum(); |
||
1001 | xco = dstn->getLeft(); |
||
1002 | yco = dstn->getTop(); |
||
1003 | ite->annotation().setZiel(pagNum - 1); |
||
1004 | ite->annotation().setExtern(fileName); |
||
1005 | ite->annotation().setAction(QString("%1 %2").arg(xco).arg(yco)); |
||
1006 | ite->annotation().setActionType(9); |
||
1007 | } |
||
1008 | } |
||
1009 | } |
||
1010 | } |
||
1011 | } |
||
1012 | else if (Lact->getKind() == actionUnknown) |
||
1013 | { |
||
1014 | LinkUnknown *uno = (LinkUnknown*)Lact; |
||
1015 | QString actString = UnicodeParsedString(uno->getAction()); |
||
1016 | if (actString == "ResetForm") |
||
1017 | { |
||
1018 | ite->annotation().setActionType(4); |
||
1019 | } |
||
1020 | else |
||
1021 | { |
||
1022 | LinkAction* scact = SC_getAction(ano); |
||
1023 | if (scact) |
||
1024 | { |
||
1025 | if (actString == "ImportData") |
||
1026 | { |
||
1027 | LinkImportData *impo = (LinkImportData*)scact; |
||
1028 | if (impo->isOk()) |
||
1029 | { |
||
1030 | ite->annotation().setActionType(5); |
||
1031 | ite->annotation().setAction(UnicodeParsedString(impo->getFileName())); |
||
1032 | } |
||
1033 | } |
||
1034 | else if (actString == "SubmitForm") |
||
1035 | { |
||
1036 | LinkSubmitForm *impo = (LinkSubmitForm*)scact; |
||
1037 | if (impo->isOk()) |
||
1038 | { |
||
1039 | ite->annotation().setActionType(3); |
||
1040 | ite->annotation().setAction(UnicodeParsedString(impo->getFileName())); |
||
1041 | int fl = impo->getFlags(); |
||
1042 | if (fl == 0) |
||
1043 | ite->annotation().setHTML(0); |
||
1044 | else if (fl == 4) |
||
1045 | ite->annotation().setHTML(1); |
||
1046 | else if (fl == 64) |
||
1047 | ite->annotation().setHTML(2); |
||
1048 | else if (fl == 512) |
||
1049 | ite->annotation().setHTML(3); |
||
1050 | } |
||
1051 | } |
||
1052 | } |
||
1053 | } |
||
1054 | } |
||
1055 | else if (Lact->getKind() == actionNamed) |
||
1056 | { |
||
1057 | LinkNamed *uno = (LinkNamed*)Lact; |
||
1058 | ite->annotation().setActionType(10); |
||
1059 | ite->annotation().setAction(UnicodeParsedString(uno->getName())); |
||
1060 | } |
||
1061 | else |
||
1062 | qDebug() << "Found unsupported Action of type" << Lact->getKind(); |
||
1063 | } |
||
1064 | LinkAction *Aact = SC_getAdditionalAction("D", ano); |
||
1065 | if (Aact) |
||
1066 | { |
||
1067 | if (Aact->getKind() == actionJavaScript) |
||
1068 | { |
||
1069 | LinkJavaScript *jsa = (LinkJavaScript*)Aact; |
||
1070 | if (jsa->isOk()) |
||
1071 | { |
||
1072 | ite->annotation().setD_act(UnicodeParsedString(jsa->getScript())); |
||
1073 | ite->annotation().setAAact(true); |
||
1074 | } |
||
1075 | } |
||
1076 | Aact = NULL; |
||
1077 | } |
||
1078 | Aact = SC_getAdditionalAction("E", ano); |
||
1079 | if (Aact) |
||
1080 | { |
||
1081 | if (Aact->getKind() == actionJavaScript) |
||
1082 | { |
||
1083 | LinkJavaScript *jsa = (LinkJavaScript*)Aact; |
||
1084 | if (jsa->isOk()) |
||
1085 | { |
||
1086 | ite->annotation().setE_act(UnicodeParsedString(jsa->getScript())); |
||
1087 | ite->annotation().setAAact(true); |
||
1088 | } |
||
1089 | } |
||
1090 | Aact = NULL; |
||
1091 | } |
||
1092 | Aact = SC_getAdditionalAction("X", ano); |
||
1093 | if (Aact) |
||
1094 | { |
||
1095 | if (Aact->getKind() == actionJavaScript) |
||
1096 | { |
||
1097 | LinkJavaScript *jsa = (LinkJavaScript*)Aact; |
||
1098 | if (jsa->isOk()) |
||
1099 | { |
||
1100 | ite->annotation().setX_act(UnicodeParsedString(jsa->getScript())); |
||
1101 | ite->annotation().setAAact(true); |
||
1102 | } |
||
1103 | } |
||
1104 | Aact = NULL; |
||
1105 | } |
||
1106 | Aact = SC_getAdditionalAction("Fo", ano); |
||
1107 | if (Aact) |
||
1108 | { |
||
1109 | if (Aact->getKind() == actionJavaScript) |
||
1110 | { |
||
1111 | LinkJavaScript *jsa = (LinkJavaScript*)Aact; |
||
1112 | if (jsa->isOk()) |
||
1113 | { |
||
1114 | ite->annotation().setFo_act(UnicodeParsedString(jsa->getScript())); |
||
1115 | ite->annotation().setAAact(true); |
||
1116 | } |
||
1117 | } |
||
1118 | Aact = NULL; |
||
1119 | } |
||
1120 | Aact = SC_getAdditionalAction("Bl", ano); |
||
1121 | if (Aact) |
||
1122 | { |
||
1123 | if (Aact->getKind() == actionJavaScript) |
||
1124 | { |
||
1125 | LinkJavaScript *jsa = (LinkJavaScript*)Aact; |
||
1126 | if (jsa->isOk()) |
||
1127 | { |
||
1128 | ite->annotation().setBl_act(UnicodeParsedString(jsa->getScript())); |
||
1129 | ite->annotation().setAAact(true); |
||
1130 | } |
||
1131 | } |
||
1132 | Aact = NULL; |
||
1133 | } |
||
1134 | Aact = SC_getAdditionalAction("C", ano); |
||
1135 | if (Aact) |
||
1136 | { |
||
1137 | if (Aact->getKind() == actionJavaScript) |
||
1138 | { |
||
1139 | LinkJavaScript *jsa = (LinkJavaScript*)Aact; |
||
1140 | if (jsa->isOk()) |
||
1141 | { |
||
1142 | ite->annotation().setC_act(UnicodeParsedString(jsa->getScript())); |
||
1143 | ite->annotation().setAAact(true); |
||
1144 | } |
||
1145 | } |
||
1146 | Aact = NULL; |
||
1147 | } |
||
1148 | Aact = SC_getAdditionalAction("F", ano); |
||
1149 | if (Aact) |
||
1150 | { |
||
1151 | if (Aact->getKind() == actionJavaScript) |
||
1152 | { |
||
1153 | LinkJavaScript *jsa = (LinkJavaScript*)Aact; |
||
1154 | if (jsa->isOk()) |
||
1155 | { |
||
1156 | ite->annotation().setF_act(UnicodeParsedString(jsa->getScript())); |
||
1157 | ite->annotation().setAAact(true); |
||
1158 | ite->annotation().setFormat(5); |
||
1159 | } |
||
1160 | } |
||
1161 | Aact = NULL; |
||
1162 | } |
||
1163 | Aact = SC_getAdditionalAction("K", ano); |
||
1164 | if (Aact) |
||
1165 | { |
||
1166 | if (Aact->getKind() == actionJavaScript) |
||
1167 | { |
||
1168 | LinkJavaScript *jsa = (LinkJavaScript*)Aact; |
||
1169 | if (jsa->isOk()) |
||
1170 | { |
||
1171 | ite->annotation().setK_act(UnicodeParsedString(jsa->getScript())); |
||
1172 | ite->annotation().setAAact(true); |
||
1173 | ite->annotation().setFormat(5); |
||
1174 | } |
||
1175 | } |
||
1176 | Aact = NULL; |
||
1177 | } |
||
1178 | Aact = SC_getAdditionalAction("V", ano); |
||
1179 | if (Aact) |
||
1180 | { |
||
1181 | if (Aact->getKind() == actionJavaScript) |
||
1182 | { |
||
1183 | LinkJavaScript *jsa = (LinkJavaScript*)Aact; |
||
1184 | if (jsa->isOk()) |
||
1185 | { |
||
1186 | ite->annotation().setV_act(UnicodeParsedString(jsa->getScript())); |
||
1187 | ite->annotation().setAAact(true); |
||
1188 | } |
||
1189 | } |
||
1190 | Aact = NULL; |
||
1191 | } |
||
1192 | } |
||
1193 | |||
1194 | void SlaOutputDev::startDoc(PDFDoc *doc, XRef *xrefA, Catalog *catA) |
||
1195 | { |
||
1196 | xref = xrefA; |
||
1197 | catalog = catA; |
||
1198 | pdfDoc = doc; |
||
1199 | updateGUICounter = 0; |
||
1200 | m_fontEngine = new SplashFontEngine( |
||
1201 | #if HAVE_T1LIB_H |
||
1202 | globalParams->getEnableT1lib(), |
||
1203 | #endif |
||
1204 | #if HAVE_FREETYPE_H |
||
1205 | globalParams->getEnableFreeType(), |
||
1206 | true, |
||
1207 | true, |
||
1208 | #endif |
||
1209 | true); |
||
1210 | } |
||
1211 | |||
19595 | jghali | 1212 | void SlaOutputDev::startPage(int pageNum, GfxState *, XRef *) |
19590 | jghali | 1213 | { |
1214 | m_formWidgets = pdfDoc->getPage(pageNum)->getFormWidgets(); |
||
1215 | m_radioMap.clear(); |
||
1216 | m_radioButtons.clear(); |
||
1217 | m_actPage = pageNum; |
||
20011 | fschmid | 1218 | m_groupStack.clear(); |
1219 | pushGroup(); |
||
1220 | m_currentClipPath.resize(0); |
||
1221 | m_currentClipPath.svgInit(); |
||
1222 | m_clipPaths.clear(); |
||
19590 | jghali | 1223 | } |
1224 | |||
1225 | void SlaOutputDev::endPage() |
||
1226 | { |
||
1227 | if (!m_radioMap.isEmpty()) |
||
1228 | { |
||
1229 | QHash<QString, QList<int> >::iterator it; |
||
1230 | for (it = m_radioMap.begin(); it != m_radioMap.end(); ++it) |
||
1231 | { |
||
1232 | tmpSel->clear(); |
||
1233 | QList<int> refList = it.value(); |
||
1234 | for (int a = 0; a < refList.count(); a++) |
||
1235 | { |
||
1236 | if (m_radioButtons.contains(refList[a])) |
||
1237 | { |
||
1238 | tmpSel->addItem(m_radioButtons[refList[a]], true); |
||
1239 | m_Elements->removeAll(m_radioButtons[refList[a]]); |
||
1240 | } |
||
1241 | } |
||
1242 | if (!tmpSel->isEmpty()) |
||
1243 | { |
||
1244 | PageItem *ite = m_doc->groupObjectsSelection(tmpSel); |
||
1245 | ite->setItemName(it.key()); |
||
1246 | m_Elements->append(ite); |
||
1247 | if (m_groupStack.count() != 0) |
||
1248 | m_groupStack.top().Items.append(ite); |
||
1249 | } |
||
1250 | } |
||
1251 | } |
||
1252 | m_radioMap.clear(); |
||
1253 | m_radioButtons.clear(); |
||
1254 | // qDebug() << "ending page"; |
||
1255 | } |
||
1256 | |||
1257 | void SlaOutputDev::saveState(GfxState *state) |
||
1258 | { |
||
20011 | fschmid | 1259 | m_clipPaths.push(m_currentClipPath); |
1260 | pushGroup(); |
||
19590 | jghali | 1261 | } |
1262 | |||
1263 | void SlaOutputDev::restoreState(GfxState *state) |
||
1264 | { |
||
1265 | if (m_groupStack.count() != 0) |
||
1266 | { |
||
20011 | fschmid | 1267 | groupEntry gElements = m_groupStack.pop(); |
1268 | if (gElements.Items.count() > 0) |
||
19590 | jghali | 1269 | { |
20011 | fschmid | 1270 | if ((gElements.Items.count() != 1) && (checkClip())) |
19590 | jghali | 1271 | { |
20011 | fschmid | 1272 | tmpSel->clear(); |
1273 | for (int dre = 0; dre < gElements.Items.count(); ++dre) |
||
19590 | jghali | 1274 | { |
20011 | fschmid | 1275 | tmpSel->addItem(gElements.Items.at(dre), true); |
1276 | m_Elements->removeAll(gElements.Items.at(dre)); |
||
19590 | jghali | 1277 | } |
20011 | fschmid | 1278 | PageItem *ite = m_doc->groupObjectsSelection(tmpSel); |
1279 | ite->ClipEdited = true; |
||
1280 | ite->FrameType = 3; |
||
1281 | FPointArray out = m_currentClipPath.copy(); |
||
1282 | out.translate(m_doc->currentPage()->xOffset(), m_doc->currentPage()->yOffset()); |
||
1283 | out.translate(-ite->xPos(), -ite->yPos()); |
||
1284 | ite->PoLine = out.copy(); |
||
1285 | ite->setTextFlowMode(PageItem::TextFlowDisabled); |
||
1286 | m_doc->AdjustItemSize(ite, true); |
||
20125 | fschmid | 1287 | m_doc->resizeGroupToContents(ite); |
20011 | fschmid | 1288 | ite->OldB2 = ite->width(); |
1289 | ite->OldH2 = ite->height(); |
||
1290 | m_Elements->append(ite); |
||
1291 | if (m_groupStack.count() != 0) |
||
19590 | jghali | 1292 | { |
20011 | fschmid | 1293 | applyMask(ite); |
1294 | m_groupStack.top().Items.append(ite); |
||
19590 | jghali | 1295 | } |
20011 | fschmid | 1296 | tmpSel->clear(); |
19590 | jghali | 1297 | } |
20011 | fschmid | 1298 | else |
1299 | { |
||
1300 | if (m_groupStack.count() != 0) |
||
1301 | { |
||
1302 | for (int dre = 0; dre < gElements.Items.count(); ++dre) |
||
1303 | { |
||
1304 | PageItem *ite = gElements.Items.at(dre); |
||
1305 | applyMask(ite); |
||
1306 | m_groupStack.top().Items.append(ite); |
||
1307 | } |
||
1308 | } |
||
1309 | } |
||
19590 | jghali | 1310 | } |
1311 | } |
||
20011 | fschmid | 1312 | if (m_clipPaths.count() != 0) |
1313 | m_currentClipPath = m_clipPaths.pop(); |
||
19590 | jghali | 1314 | } |
20011 | fschmid | 1315 | |
1316 | void SlaOutputDev::beginTransparencyGroup(GfxState *state, double *bbox, GfxColorSpace * /*blendingColorSpace*/, GBool isolated, GBool knockout, GBool forSoftMask) |
||
19590 | jghali | 1317 | { |
20011 | fschmid | 1318 | pushGroup("", forSoftMask); |
20125 | fschmid | 1319 | m_groupStack.top().isolated = isolated; |
19590 | jghali | 1320 | } |
20011 | fschmid | 1321 | |
1322 | void SlaOutputDev::paintTransparencyGroup(GfxState *state, double *bbox) |
||
19590 | jghali | 1323 | { |
20011 | fschmid | 1324 | if (m_groupStack.count() != 0) |
1325 | { |
||
1326 | if ((m_groupStack.top().Items.count() != 0) && (!m_groupStack.top().forSoftMask)) |
||
1327 | { |
||
1328 | PageItem *ite = m_groupStack.top().Items.last(); |
||
1329 | ite->setFillTransparency(1.0 - state->getFillOpacity()); |
||
1330 | ite->setFillBlendmode(getBlendMode(state)); |
||
1331 | } |
||
1332 | } |
||
19590 | jghali | 1333 | } |
1334 | |||
1335 | void SlaOutputDev::endTransparencyGroup(GfxState *state) |
||
1336 | { |
||
1337 | if (m_groupStack.count() != 0) |
||
1338 | { |
||
1339 | groupEntry gElements = m_groupStack.pop(); |
||
1340 | tmpSel->clear(); |
||
1341 | if (gElements.Items.count() > 0) |
||
1342 | { |
||
1343 | if (gElements.forSoftMask) |
||
1344 | { |
||
1345 | for (int dre = 0; dre < gElements.Items.count(); ++dre) |
||
1346 | { |
||
1347 | tmpSel->addItem(gElements.Items.at(dre), true); |
||
1348 | m_Elements->removeAll(gElements.Items.at(dre)); |
||
1349 | } |
||
1350 | PageItem *ite = m_doc->groupObjectsSelection(tmpSel); |
||
1351 | ite->setFillTransparency(1.0 - state->getFillOpacity()); |
||
1352 | ite->setFillBlendmode(getBlendMode(state)); |
||
1353 | ScPattern pat = ScPattern(); |
||
1354 | pat.setDoc(m_doc); |
||
1355 | m_doc->DoDrawing = true; |
||
1356 | pat.pattern = ite->DrawObj_toImage(qMin(qMax(ite->width(), ite->height()), 500.0)); |
||
1357 | pat.xoffset = 0; |
||
1358 | pat.yoffset = 0; |
||
1359 | m_doc->DoDrawing = false; |
||
1360 | pat.width = ite->width(); |
||
1361 | pat.height = ite->height(); |
||
1362 | ite->gXpos = 0; |
||
1363 | ite->gYpos = 0; |
||
1364 | ite->setXYPos(ite->gXpos, ite->gYpos, true); |
||
1365 | pat.items.append(ite); |
||
1366 | m_doc->Items->removeAll(ite); |
||
1367 | QString id = QString("Pattern_from_PDF_%1S").arg(m_doc->docPatterns.count() + 1); |
||
1368 | m_doc->addPattern(id, pat); |
||
1369 | m_currentMask = id; |
||
1370 | tmpSel->clear(); |
||
1371 | return; |
||
1372 | } |
||
1373 | else |
||
1374 | { |
||
1375 | PageItem *ite; |
||
1376 | for (int dre = 0; dre < gElements.Items.count(); ++dre) |
||
1377 | { |
||
1378 | tmpSel->addItem(gElements.Items.at(dre), true); |
||
1379 | m_Elements->removeAll(gElements.Items.at(dre)); |
||
1380 | } |
||
20125 | fschmid | 1381 | if ((gElements.Items.count() != 1) || (gElements.isolated)) |
19590 | jghali | 1382 | ite = m_doc->groupObjectsSelection(tmpSel); |
1383 | else |
||
1384 | ite = gElements.Items.first(); |
||
20011 | fschmid | 1385 | if (ite->isGroup()) |
1386 | { |
||
1387 | ite->ClipEdited = true; |
||
1388 | ite->FrameType = 3; |
||
1389 | if (checkClip()) |
||
1390 | { |
||
1391 | FPointArray out = m_currentClipPath.copy(); |
||
1392 | out.translate(m_doc->currentPage()->xOffset(), m_doc->currentPage()->yOffset()); |
||
1393 | out.translate(-ite->xPos(), -ite->yPos()); |
||
1394 | ite->PoLine = out.copy(); |
||
1395 | ite->setTextFlowMode(PageItem::TextFlowDisabled); |
||
1396 | m_doc->AdjustItemSize(ite, true); |
||
20125 | fschmid | 1397 | m_doc->resizeGroupToContents(ite); |
20011 | fschmid | 1398 | ite->OldB2 = ite->width(); |
1399 | ite->OldH2 = ite->height(); |
||
1400 | } |
||
1401 | } |
||
19590 | jghali | 1402 | ite->setFillTransparency(1.0 - state->getFillOpacity()); |
1403 | ite->setFillBlendmode(getBlendMode(state)); |
||
20011 | fschmid | 1404 | m_Elements->append(ite); |
1405 | if (m_groupStack.count() != 0) |
||
19590 | jghali | 1406 | { |
20011 | fschmid | 1407 | applyMask(ite); |
1408 | m_groupStack.top().Items.append(ite); |
||
19590 | jghali | 1409 | } |
1410 | } |
||
1411 | } |
||
1412 | tmpSel->clear(); |
||
1413 | } |
||
1414 | } |
||
1415 | |||
1416 | void SlaOutputDev::setSoftMask(GfxState * /*state*/, double * /*bbox*/, GBool alpha, Function *transferFunc, GfxColor * /*backdropColor*/) |
||
1417 | { |
||
1418 | if (m_groupStack.count() != 0) |
||
1419 | { |
||
1420 | double lum = 0; |
||
1421 | double lum2 = 0; |
||
1422 | if (transferFunc) |
||
1423 | transferFunc->transform(&lum, &lum2); |
||
1424 | else |
||
1425 | lum2 = lum; |
||
1426 | if (lum == lum2) |
||
1427 | m_groupStack.top().inverted = false; |
||
1428 | else |
||
1429 | m_groupStack.top().inverted = true; |
||
1430 | m_groupStack.top().maskName = m_currentMask; |
||
1431 | m_groupStack.top().alpha = alpha; |
||
20011 | fschmid | 1432 | if (m_groupStack.top().Items.count() != 0) |
1433 | applyMask(m_groupStack.top().Items.last()); |
||
19590 | jghali | 1434 | } |
1435 | } |
||
1436 | |||
1437 | void SlaOutputDev::clearSoftMask(GfxState * /*state*/) |
||
1438 | { |
||
1439 | if (m_groupStack.count() != 0) |
||
1440 | m_groupStack.top().maskName = ""; |
||
1441 | } |
||
1442 | |||
1443 | void SlaOutputDev::updateFillColor(GfxState *state) |
||
1444 | { |
||
1445 | CurrFillShade = 100; |
||
1446 | CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &CurrFillShade); |
||
1447 | } |
||
1448 | |||
1449 | void SlaOutputDev::updateStrokeColor(GfxState *state) |
||
1450 | { |
||
1451 | CurrStrokeShade = 100; |
||
1452 | CurrColorStroke = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &CurrStrokeShade); |
||
1453 | } |
||
1454 | |||
1455 | void SlaOutputDev::clip(GfxState *state) |
||
1456 | { |
||
1457 | // qDebug() << "Clip"; |
||
1458 | double *ctm; |
||
1459 | ctm = state->getCTM(); |
||
1460 | m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); |
||
1461 | QString output = convertPath(state->getPath()); |
||
1462 | FPointArray out; |
||
1463 | if (!output.isEmpty()) |
||
1464 | { |
||
1465 | out.parseSVG(output); |
||
20011 | fschmid | 1466 | out.svgClosePath(); |
19590 | jghali | 1467 | out.map(m_ctm); |
20011 | fschmid | 1468 | if (checkClip()) |
1469 | { |
||
1470 | QPainterPath pathN = out.toQPainterPath(true); |
||
1471 | QPainterPath pathA = m_currentClipPath.toQPainterPath(true); |
||
1472 | QPainterPath resultPath = pathA.intersected(pathN); |
||
1473 | if (!resultPath.isEmpty()) |
||
1474 | { |
||
1475 | FPointArray polyline; |
||
1476 | polyline.resize(0); |
||
1477 | polyline.fromQPainterPath(resultPath, true); |
||
1478 | polyline.svgClosePath(); |
||
1479 | m_currentClipPath = polyline.copy(); |
||
1480 | } |
||
1481 | else |
||
1482 | { |
||
1483 | m_currentClipPath.resize(0); |
||
1484 | m_currentClipPath.svgInit(); |
||
1485 | } |
||
1486 | } |
||
1487 | else |
||
1488 | m_currentClipPath = out.copy(); |
||
19590 | jghali | 1489 | } |
1490 | } |
||
1491 | |||
1492 | void SlaOutputDev::eoClip(GfxState *state) |
||
1493 | { |
||
1494 | // qDebug() << "EoClip"; |
||
1495 | double *ctm; |
||
1496 | ctm = state->getCTM(); |
||
1497 | m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); |
||
1498 | QString output = convertPath(state->getPath()); |
||
1499 | FPointArray out; |
||
1500 | if (!output.isEmpty()) |
||
1501 | { |
||
1502 | out.parseSVG(output); |
||
20011 | fschmid | 1503 | out.svgClosePath(); |
19590 | jghali | 1504 | out.map(m_ctm); |
20011 | fschmid | 1505 | if (checkClip()) |
1506 | { |
||
1507 | QPainterPath pathN = out.toQPainterPath(true); |
||
1508 | QPainterPath pathA = m_currentClipPath.toQPainterPath(true); |
||
1509 | QPainterPath resultPath = pathA.intersected(pathN); |
||
1510 | if (!resultPath.isEmpty()) |
||
1511 | { |
||
1512 | FPointArray polyline; |
||
1513 | polyline.resize(0); |
||
1514 | polyline.fromQPainterPath(resultPath, true); |
||
1515 | polyline.svgClosePath(); |
||
1516 | m_currentClipPath = polyline.copy(); |
||
1517 | } |
||
1518 | else |
||
1519 | { |
||
1520 | m_currentClipPath.resize(0); |
||
1521 | m_currentClipPath.svgInit(); |
||
1522 | } |
||
1523 | } |
||
1524 | else |
||
1525 | m_currentClipPath = out.copy(); |
||
19590 | jghali | 1526 | } |
1527 | } |
||
1528 | |||
1529 | void SlaOutputDev::stroke(GfxState *state) |
||
1530 | { |
||
1531 | // qDebug() << "Stroke"; |
||
1532 | double *ctm; |
||
1533 | ctm = state->getCTM(); |
||
1534 | double xCoor = m_doc->currentPage()->xOffset(); |
||
1535 | double yCoor = m_doc->currentPage()->yOffset(); |
||
1536 | QString output = convertPath(state->getPath()); |
||
1537 | getPenState(state); |
||
1538 | if ((m_Elements->count() != 0) && (output == Coords)) // Path is the same as in last fill |
||
1539 | { |
||
1540 | PageItem* ite = m_Elements->last(); |
||
1541 | ite->setLineColor(CurrColorStroke); |
||
1542 | ite->setLineShade(CurrStrokeShade); |
||
1543 | ite->setLineEnd(PLineEnd); |
||
1544 | ite->setLineJoin(PLineJoin); |
||
1545 | ite->setLineWidth(state->getTransformedLineWidth()); |
||
1546 | ite->setDashes(DashValues); |
||
1547 | ite->setDashOffset(DashOffset); |
||
1548 | ite->setLineTransparency(1.0 - state->getStrokeOpacity()); |
||
1549 | } |
||
1550 | else |
||
1551 | { |
||
1552 | FPointArray out; |
||
1553 | out.parseSVG(output); |
||
1554 | m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); |
||
1555 | out.map(m_ctm); |
||
1556 | FPoint wh = out.WidthHeight(); |
||
1557 | if ((out.size() > 3) && ((wh.x() != 0.0) || (wh.y() != 0.0))) |
||
1558 | { |
||
19731 | fschmid | 1559 | CurrColorStroke = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &CurrStrokeShade); |
19590 | jghali | 1560 | int z; |
1561 | if (pathIsClosed) |
||
1562 | z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, xCoor, yCoor, 10, 10, state->getTransformedLineWidth(), CommonStrings::None, CurrColorStroke, true); |
||
1563 | else |
||
1564 | z = m_doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, xCoor, yCoor, 10, 10, state->getTransformedLineWidth(), CommonStrings::None, CurrColorStroke, true); |
||
1565 | PageItem* ite = m_doc->Items->at(z); |
||
1566 | ite->PoLine = out.copy(); |
||
1567 | ite->ClipEdited = true; |
||
1568 | ite->FrameType = 3; |
||
1569 | ite->setWidthHeight(wh.x(),wh.y()); |
||
1570 | m_doc->AdjustItemSize(ite); |
||
1571 | if (m_Elements->count() != 0) |
||
1572 | { |
||
1573 | PageItem* lItem = m_Elements->last(); |
||
1574 | if ((lItem->lineColor() == CommonStrings::None) && (lItem->PoLine == ite->PoLine)) |
||
1575 | { |
||
1576 | lItem->setLineColor(CurrColorStroke); |
||
1577 | lItem->setLineWidth(state->getTransformedLineWidth()); |
||
1578 | lItem->setLineShade(CurrStrokeShade); |
||
1579 | lItem->setLineTransparency(1.0 - state->getStrokeOpacity()); |
||
1580 | lItem->setLineBlendmode(getBlendMode(state)); |
||
1581 | lItem->setLineEnd(PLineEnd); |
||
1582 | lItem->setLineJoin(PLineJoin); |
||
1583 | lItem->setDashes(DashValues); |
||
1584 | lItem->setDashOffset(DashOffset); |
||
1585 | lItem->setTextFlowMode(PageItem::TextFlowDisabled); |
||
1586 | m_doc->Items->removeAll(ite); |
||
1587 | } |
||
1588 | else |
||
1589 | { |
||
1590 | ite->setLineShade(CurrStrokeShade); |
||
1591 | ite->setLineTransparency(1.0 - state->getStrokeOpacity()); |
||
1592 | ite->setLineBlendmode(getBlendMode(state)); |
||
1593 | ite->setLineEnd(PLineEnd); |
||
1594 | ite->setLineJoin(PLineJoin); |
||
1595 | ite->setDashes(DashValues); |
||
1596 | ite->setDashOffset(DashOffset); |
||
1597 | ite->setTextFlowMode(PageItem::TextFlowDisabled); |
||
1598 | m_Elements->append(ite); |
||
1599 | if (m_groupStack.count() != 0) |
||
1600 | m_groupStack.top().Items.append(ite); |
||
1601 | } |
||
1602 | } |
||
1603 | else |
||
1604 | { |
||
1605 | ite->setLineShade(CurrStrokeShade); |
||
1606 | ite->setLineTransparency(1.0 - state->getStrokeOpacity()); |
||
1607 | ite->setLineBlendmode(getBlendMode(state)); |
||
1608 | ite->setLineEnd(PLineEnd); |
||
1609 | ite->setLineJoin(PLineJoin); |
||
1610 | ite->setDashes(DashValues); |
||
1611 | ite->setDashOffset(DashOffset); |
||
1612 | ite->setTextFlowMode(PageItem::TextFlowDisabled); |
||
1613 | m_Elements->append(ite); |
||
1614 | if (m_groupStack.count() != 0) |
||
1615 | m_groupStack.top().Items.append(ite); |
||
1616 | } |
||
1617 | } |
||
1618 | } |
||
1619 | } |
||
1620 | |||
1621 | void SlaOutputDev::fill(GfxState *state) |
||
1622 | { |
||
1623 | // qDebug() << "Fill"; |
||
1624 | double *ctm; |
||
1625 | ctm = state->getCTM(); |
||
1626 | double xCoor = m_doc->currentPage()->xOffset(); |
||
1627 | double yCoor = m_doc->currentPage()->yOffset(); |
||
1628 | FPointArray out; |
||
1629 | QString output = convertPath(state->getPath()); |
||
1630 | out.parseSVG(output); |
||
1631 | m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); |
||
1632 | out.map(m_ctm); |
||
1633 | Coords = output; |
||
1634 | FPoint wh = out.WidthHeight(); |
||
1635 | if ((out.size() > 3) && ((wh.x() != 0.0) || (wh.y() != 0.0))) |
||
1636 | { |
||
19731 | fschmid | 1637 | CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &CurrFillShade); |
19590 | jghali | 1638 | int z; |
1639 | if (pathIsClosed) |
||
1640 | z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, xCoor, yCoor, 10, 10, 0, CurrColorFill, CommonStrings::None, true); |
||
1641 | else |
||
1642 | z = m_doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, xCoor, yCoor, 10, 10, 0, CurrColorFill, CommonStrings::None, true); |
||
1643 | PageItem* ite = m_doc->Items->at(z); |
||
1644 | ite->PoLine = out.copy(); |
||
1645 | ite->ClipEdited = true; |
||
1646 | ite->FrameType = 3; |
||
1647 | ite->setFillShade(CurrFillShade); |
||
1648 | ite->setLineShade(100); |
||
1649 | ite->setFillEvenOdd(false); |
||
1650 | ite->setFillTransparency(1.0 - state->getFillOpacity()); |
||
1651 | ite->setFillBlendmode(getBlendMode(state)); |
||
1652 | ite->setLineEnd(PLineEnd); |
||
1653 | ite->setLineJoin(PLineJoin); |
||
1654 | ite->setWidthHeight(wh.x(),wh.y()); |
||
1655 | ite->setTextFlowMode(PageItem::TextFlowDisabled); |
||
1656 | m_doc->AdjustItemSize(ite); |
||
1657 | m_Elements->append(ite); |
||
1658 | if (m_groupStack.count() != 0) |
||
1659 | { |
||
1660 | m_groupStack.top().Items.append(ite); |
||
1661 | applyMask(ite); |
||
1662 | } |
||
1663 | } |
||
1664 | } |
||
1665 | |||
1666 | void SlaOutputDev::eoFill(GfxState *state) |
||
1667 | { |
||
1668 | // qDebug() << "EoFill"; |
||
1669 | double *ctm; |
||
1670 | ctm = state->getCTM(); |
||
1671 | double xCoor = m_doc->currentPage()->xOffset(); |
||
1672 | double yCoor = m_doc->currentPage()->yOffset(); |
||
1673 | FPointArray out; |
||
1674 | QString output = convertPath(state->getPath()); |
||
1675 | out.parseSVG(output); |
||
1676 | m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); |
||
1677 | out.map(m_ctm); |
||
1678 | Coords = output; |
||
1679 | FPoint wh = out.WidthHeight(); |
||
1680 | if ((out.size() > 3) && ((wh.x() != 0.0) || (wh.y() != 0.0))) |
||
1681 | { |
||
19731 | fschmid | 1682 | CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &CurrFillShade); |
19590 | jghali | 1683 | int z; |
1684 | if (pathIsClosed) |
||
1685 | z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, xCoor, yCoor, 10, 10, 0, CurrColorFill, CommonStrings::None, true); |
||
1686 | else |
||
1687 | z = m_doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, xCoor, yCoor, 10, 10, 0, CurrColorFill, CommonStrings::None, true); |
||
1688 | PageItem* ite = m_doc->Items->at(z); |
||
1689 | ite->PoLine = out.copy(); |
||
1690 | ite->ClipEdited = true; |
||
1691 | ite->FrameType = 3; |
||
1692 | ite->setFillShade(CurrFillShade); |
||
1693 | ite->setLineShade(100); |
||
1694 | ite->setFillEvenOdd(true); |
||
1695 | ite->setFillTransparency(1.0 - state->getFillOpacity()); |
||
1696 | ite->setFillBlendmode(getBlendMode(state)); |
||
1697 | ite->setLineEnd(PLineEnd); |
||
1698 | ite->setLineJoin(PLineJoin); |
||
1699 | ite->setWidthHeight(wh.x(),wh.y()); |
||
1700 | ite->setTextFlowMode(PageItem::TextFlowDisabled); |
||
1701 | m_doc->AdjustItemSize(ite); |
||
1702 | m_Elements->append(ite); |
||
1703 | if (m_groupStack.count() != 0) |
||
1704 | { |
||
1705 | m_groupStack.top().Items.append(ite); |
||
1706 | applyMask(ite); |
||
1707 | } |
||
1708 | } |
||
1709 | } |
||
1710 | |||
1711 | GBool SlaOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) |
||
1712 | { |
||
1713 | double GrStartX; |
||
1714 | double GrStartY; |
||
1715 | double GrEndX; |
||
1716 | double GrEndY; |
||
1717 | int shade = 100; |
||
1718 | Function *func = shading->getFunc(0); |
||
1719 | VGradient FillGradient = VGradient(VGradient::linear); |
||
1720 | FillGradient.clearStops(); |
||
1721 | GfxColorSpace *color_space = shading->getColorSpace(); |
||
1722 | if (func->getType() == 3) |
||
1723 | { |
||
1724 | StitchingFunction *stitchingFunc = (StitchingFunction*)func; |
||
1725 | double *bounds = stitchingFunc->getBounds(); |
||
1726 | int num_funcs = stitchingFunc->getNumFuncs(); |
||
1727 | // Add stops from all the stitched functions |
||
1728 | for ( int i = 0 ; i < num_funcs ; i++ ) |
||
1729 | { |
||
1730 | GfxColor temp; |
||
1731 | ((GfxAxialShading*)shading)->getColor(bounds[i], &temp); |
||
1732 | QString stopColor = getColor(color_space, &temp, &shade); |
||
1733 | FillGradient.addStop( ScColorEngine::getShadeColor(m_doc->PageColors[stopColor], m_doc, shade), bounds[i], 0.5, 1.0, stopColor, shade ); |
||
1734 | if (i == num_funcs - 1) |
||
1735 | { |
||
1736 | ((GfxAxialShading*)shading)->getColor(bounds[i+1], &temp); |
||
1737 | QString stopColor = getColor(color_space, &temp, &shade); |
||
1738 | FillGradient.addStop( ScColorEngine::getShadeColor(m_doc->PageColors[stopColor], m_doc, shade), bounds[i+1], 0.5, 1.0, stopColor, shade ); |
||
1739 | } |
||
1740 | } |
||
1741 | } |
||
1742 | else if ((func->getType() == 2) || (func->getType() == 0)) |
||
1743 | { |
||
1744 | GfxColor stop1; |
||
1745 | ((GfxAxialShading*)shading)->getColor(0.0, &stop1); |
||
1746 | QString stopColor1 = getColor(color_space, &stop1, &shade); |
||
1747 | FillGradient.addStop( ScColorEngine::getShadeColor(m_doc->PageColors[stopColor1], m_doc, shade), 0.0, 0.5, 1.0, stopColor1, shade ); |
||
1748 | GfxColor stop2; |
||
1749 | ((GfxAxialShading*)shading)->getColor(1.0, &stop2); |
||
1750 | QString stopColor2 = getColor(color_space, &stop2, &shade); |
||
1751 | FillGradient.addStop( ScColorEngine::getShadeColor(m_doc->PageColors[stopColor2], m_doc, shade), 1.0, 0.5, 1.0, stopColor2, shade ); |
||
1752 | } |
||
1753 | ((GfxAxialShading*)shading)->getCoords(&GrStartX, &GrStartY, &GrEndX, &GrEndY); |
||
1754 | double xmin, ymin, xmax, ymax; |
||
1755 | // get the clip region bbox |
||
1756 | state->getClipBBox(&xmin, &ymin, &xmax, &ymax); |
||
1757 | QRectF crect = QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax)); |
||
1758 | crect = crect.normalized(); |
||
1759 | double *ctm; |
||
1760 | ctm = state->getCTM(); |
||
1761 | m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); |
||
1762 | FPointArray gr; |
||
1763 | gr.addPoint(GrStartX, GrStartY); |
||
1764 | gr.addPoint(GrEndX, GrEndY); |
||
1765 | gr.map(m_ctm); |
||
1766 | GrStartX = gr.point(0).x() - crect.x(); |
||
1767 | GrStartY = gr.point(0).y() - crect.y(); |
||
1768 | GrEndX = gr.point(1).x() - crect.x(); |
||
1769 | GrEndY = gr.point(1).y() - crect.y(); |
||
1770 | double xCoor = m_doc->currentPage()->xOffset(); |
||
1771 | double yCoor = m_doc->currentPage()->yOffset(); |
||
1772 | QString output = QString("M %1 %2").arg(0.0).arg(0.0); |
||
1773 | output += QString("L %1 %2").arg(crect.width()).arg(0.0); |
||
1774 | output += QString("L %1 %2").arg(crect.width()).arg(crect.height()); |
||
1775 | output += QString("L %1 %2").arg(0.0).arg(crect.height()); |
||
1776 | output += QString("L %1 %2").arg(0.0).arg(0.0); |
||
1777 | output += QString("Z"); |
||
1778 | pathIsClosed = true; |
||
1779 | Coords = output; |
||
1780 | int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, CurrColorFill, CommonStrings::None, true); |
||
1781 | PageItem* ite = m_doc->Items->at(z); |
||
20011 | fschmid | 1782 | if (checkClip()) |
1783 | { |
||
1784 | FPointArray out = m_currentClipPath.copy(); |
||
1785 | FPoint wh(getMinClipF(&out)); |
||
1786 | out.translate(-wh.x(), -wh.y()); |
||
1787 | ite->PoLine = out.copy(); |
||
1788 | } |
||
19590 | jghali | 1789 | ite->ClipEdited = true; |
1790 | ite->FrameType = 3; |
||
1791 | ite->setFillShade(CurrFillShade); |
||
1792 | ite->setLineShade(100); |
||
1793 | ite->setFillEvenOdd(false); |
||
1794 | ite->setFillTransparency(1.0 - state->getFillOpacity()); |
||
1795 | ite->setFillBlendmode(getBlendMode(state)); |
||
1796 | ite->setLineEnd(PLineEnd); |
||
1797 | ite->setLineJoin(PLineJoin); |
||
1798 | ite->setTextFlowMode(PageItem::TextFlowDisabled); |
||
1799 | ite->GrType = 6; |
||
1800 | if (!shading->getExtend0() || !shading->getExtend1()) |
||
1801 | { |
||
1802 | FillGradient.setRepeatMethod(VGradient::none); |
||
1803 | ite->setGradientExtend(VGradient::none); |
||
1804 | } |
||
1805 | else |
||
1806 | { |
||
1807 | FillGradient.setRepeatMethod(VGradient::pad); |
||
1808 | ite->setGradientExtend(VGradient::pad); |
||
1809 | } |
||
1810 | ite->fill_gradient = FillGradient; |
||
1811 | ite->setGradientVector(GrStartX, GrStartY, GrEndX, GrEndY, 0, 0, 1, 0); |
||
1812 | m_doc->AdjustItemSize(ite); |
||
1813 | m_Elements->append(ite); |
||
1814 | if (m_groupStack.count() != 0) |
||
1815 | { |
||
1816 | m_groupStack.top().Items.append(ite); |
||
1817 | applyMask(ite); |
||
1818 | } |
||
1819 | return gTrue; |
||
1820 | } |
||
1821 | |||
1822 | GBool SlaOutputDev::radialShadedFill(GfxState *state, GfxRadialShading *shading, double sMin, double sMax) |
||
1823 | { |
||
1824 | double GrStartX; |
||
1825 | double GrStartY; |
||
1826 | double GrEndX; |
||
1827 | double GrEndY; |
||
1828 | int shade = 100; |
||
1829 | Function *func = shading->getFunc(0); |
||
1830 | VGradient FillGradient = VGradient(VGradient::linear); |
||
1831 | FillGradient.clearStops(); |
||
1832 | GfxColorSpace *color_space = shading->getColorSpace(); |
||
1833 | if (func->getType() == 3) |
||
1834 | { |
||
1835 | StitchingFunction *stitchingFunc = (StitchingFunction*)func; |
||
1836 | double *bounds = stitchingFunc->getBounds(); |
||
1837 | int num_funcs = stitchingFunc->getNumFuncs(); |
||
1838 | // Add stops from all the stitched functions |
||
1839 | for ( int i = 0 ; i < num_funcs ; i++ ) |
||
1840 | { |
||
1841 | GfxColor temp; |
||
1842 | ((GfxRadialShading*)shading)->getColor(bounds[i], &temp); |
||
1843 | QString stopColor = getColor(color_space, &temp, &shade); |
||
1844 | FillGradient.addStop( ScColorEngine::getShadeColor(m_doc->PageColors[stopColor], m_doc, shade), bounds[i], 0.5, 1.0, stopColor, shade ); |
||
1845 | if (i == num_funcs - 1) |
||
1846 | { |
||
1847 | ((GfxRadialShading*)shading)->getColor(bounds[i+1], &temp); |
||
1848 | QString stopColor = getColor(color_space, &temp, &shade); |
||
1849 | FillGradient.addStop( ScColorEngine::getShadeColor(m_doc->PageColors[stopColor], m_doc, shade), bounds[i+1], 0.5, 1.0, stopColor, shade ); |
||
1850 | } |
||
1851 | } |
||
1852 | } |
||
1853 | else if ((func->getType() == 2) || (func->getType() == 0)) |
||
1854 | { |
||
1855 | GfxColor stop1; |
||
1856 | ((GfxRadialShading*)shading)->getColor(0.0, &stop1); |
||
1857 | QString stopColor1 = getColor(color_space, &stop1, &shade); |
||
1858 | FillGradient.addStop( ScColorEngine::getShadeColor(m_doc->PageColors[stopColor1], m_doc, shade), 0.0, 0.5, 1.0, stopColor1, shade ); |
||
1859 | GfxColor stop2; |
||
1860 | ((GfxRadialShading*)shading)->getColor(1.0, &stop2); |
||
1861 | QString stopColor2 = getColor(color_space, &stop2, &shade); |
||
1862 | FillGradient.addStop( ScColorEngine::getShadeColor(m_doc->PageColors[stopColor2], m_doc, shade), 1.0, 0.5, 1.0, stopColor2, shade ); |
||
1863 | } |
||
1864 | double r0, x1, y1, r1; |
||
1865 | ((GfxRadialShading*)shading)->getCoords(&GrStartX, &GrStartY, &r0, &x1, &y1, &r1); |
||
1866 | double xmin, ymin, xmax, ymax; |
||
1867 | // get the clip region bbox |
||
1868 | state->getClipBBox(&xmin, &ymin, &xmax, &ymax); |
||
1869 | QRectF crect = QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax)); |
||
1870 | crect = crect.normalized(); |
||
1871 | double GrFocalX = x1; |
||
1872 | double GrFocalY = y1; |
||
1873 | GrEndX = GrFocalX + r1; |
||
1874 | GrEndY = GrFocalY; |
||
1875 | double *ctm; |
||
1876 | ctm = state->getCTM(); |
||
1877 | m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); |
||
1878 | FPointArray gr; |
||
1879 | gr.addPoint(GrStartX, GrStartY); |
||
1880 | gr.addPoint(GrEndX, GrEndY); |
||
1881 | gr.addPoint(GrFocalX, GrFocalY); |
||
1882 | gr.map(m_ctm); |
||
1883 | GrStartX = gr.point(0).x() - crect.x(); |
||
1884 | GrStartY = gr.point(0).y() - crect.y(); |
||
1885 | GrEndX = gr.point(1).x() - crect.x(); |
||
1886 | GrEndY = gr.point(1).y() - crect.y(); |
||
1887 | GrFocalX = gr.point(2).x() - crect.x(); |
||
1888 | GrFocalY = gr.point(2).y() - crect.y(); |
||
1889 | double xCoor = m_doc->currentPage()->xOffset(); |
||
1890 | double yCoor = m_doc->currentPage()->yOffset(); |
||
1891 | QString output = QString("M %1 %2").arg(0.0).arg(0.0); |
||
1892 | output += QString("L %1 %2").arg(crect.width()).arg(0.0); |
||
1893 | output += QString("L %1 %2").arg(crect.width()).arg(crect.height()); |
||
1894 | output += QString("L %1 %2").arg(0.0).arg(crect.height()); |
||
1895 | output += QString("L %1 %2").arg(0.0).arg(0.0); |
||
1896 | output += QString("Z"); |
||
1897 | pathIsClosed = true; |
||
1898 | Coords = output; |
||
1899 | int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, CurrColorFill, CommonStrings::None, true); |
||
1900 | PageItem* ite = m_doc->Items->at(z); |
||
20011 | fschmid | 1901 | if (checkClip()) |
1902 | { |
||
1903 | FPointArray out = m_currentClipPath.copy(); |
||
1904 | FPoint wh(getMinClipF(&out)); |
||
1905 | out.translate(-wh.x(), -wh.y()); |
||
1906 | ite->PoLine = out.copy(); |
||
1907 | } |
||
19590 | jghali | 1908 | ite->ClipEdited = true; |
1909 | ite->FrameType = 3; |
||
1910 | ite->setFillShade(CurrFillShade); |
||
1911 | ite->setLineShade(100); |
||
1912 | ite->setFillEvenOdd(false); |
||
1913 | ite->setFillTransparency(1.0 - state->getFillOpacity()); |
||
1914 | ite->setFillBlendmode(getBlendMode(state)); |
||
1915 | ite->setLineEnd(PLineEnd); |
||
1916 | ite->setLineJoin(PLineJoin); |
||
1917 | ite->setTextFlowMode(PageItem::TextFlowDisabled); |
||
1918 | ite->GrType = 7; |
||
1919 | if (!shading->getExtend0() || !shading->getExtend1()) |
||
1920 | { |
||
1921 | FillGradient.setRepeatMethod(VGradient::none); |
||
1922 | ite->setGradientExtend(VGradient::none); |
||
1923 | } |
||
1924 | else |
||
1925 | { |
||
1926 | FillGradient.setRepeatMethod(VGradient::pad); |
||
1927 | ite->setGradientExtend(VGradient::pad); |
||
1928 | } |
||
1929 | ite->fill_gradient = FillGradient; |
||
1930 | ite->setGradientVector(GrStartX, GrStartY, GrEndX, GrEndY, GrFocalX, GrFocalY, 1, 0); |
||
1931 | m_doc->AdjustItemSize(ite); |
||
1932 | m_Elements->append(ite); |
||
1933 | if (m_groupStack.count() != 0) |
||
1934 | { |
||
1935 | m_groupStack.top().Items.append(ite); |
||
1936 | applyMask(ite); |
||
1937 | } |
||
1938 | return gTrue; |
||
1939 | } |
||
1940 | |||
1941 | GBool SlaOutputDev::gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading) |
||
1942 | { |
||
1943 | double xCoor = m_doc->currentPage()->xOffset(); |
||
1944 | double yCoor = m_doc->currentPage()->yOffset(); |
||
1945 | double xmin, ymin, xmax, ymax; |
||
1946 | // get the clip region bbox |
||
1947 | state->getClipBBox(&xmin, &ymin, &xmax, &ymax); |
||
1948 | QRectF crect = QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax)); |
||
1949 | crect = crect.normalized(); |
||
1950 | QString output = QString("M %1 %2").arg(0.0).arg(0.0); |
||
1951 | output += QString("L %1 %2").arg(crect.width()).arg(0.0); |
||
1952 | output += QString("L %1 %2").arg(crect.width()).arg(crect.height()); |
||
1953 | output += QString("L %1 %2").arg(0.0).arg(crect.height()); |
||
1954 | output += QString("L %1 %2").arg(0.0).arg(0.0); |
||
1955 | output += QString("Z"); |
||
1956 | pathIsClosed = true; |
||
1957 | Coords = output; |
||
1958 | double *ctm; |
||
1959 | ctm = state->getCTM(); |
||
1960 | m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); |
||
1961 | int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, CurrColorFill, CommonStrings::None, true); |
||
1962 | PageItem* ite = m_doc->Items->at(z); |
||
1963 | ite->ClipEdited = true; |
||
1964 | ite->FrameType = 3; |
||
1965 | ite->setFillShade(CurrFillShade); |
||
1966 | ite->setLineShade(100); |
||
1967 | ite->setFillEvenOdd(false); |
||
1968 | ite->setFillTransparency(1.0 - state->getFillOpacity()); |
||
1969 | ite->setFillBlendmode(getBlendMode(state)); |
||
1970 | ite->setLineEnd(PLineEnd); |
||
1971 | ite->setLineJoin(PLineJoin); |
||
1972 | ite->setTextFlowMode(PageItem::TextFlowDisabled); |
||
1973 | m_doc->AdjustItemSize(ite); |
||
1974 | m_Elements->append(ite); |
||
1975 | if (m_groupStack.count() != 0) |
||
1976 | { |
||
1977 | m_groupStack.top().Items.append(ite); |
||
1978 | applyMask(ite); |
||
1979 | } |
||
1980 | GfxColor color[3]; |
||
1981 | double x0, y0, x1, y1, x2, y2; |
||
1982 | for (int i = 0; i < shading->getNTriangles(); i++) |
||
1983 | { |
||
1984 | int shade = 100; |
||
1985 | meshGradientPatch patchM; |
||
1986 | shading->getTriangle(i, &x0, &y0, &color[0], &x1, &y1, &color[1], &x2, &y2, &color[2]); |
||
1987 | patchM.BL.resetTo(FPoint(x0, y0)); |
||
1988 | patchM.BL.shade = 100; |
||
1989 | patchM.BL.transparency = 1.0; |
||
1990 | patchM.BL.colorName = getColor(shading->getColorSpace(), &color[0], &shade); |
||
1991 | patchM.BL.color = ScColorEngine::getShadeColorProof(m_doc->PageColors[patchM.BL.colorName], m_doc, shade); |
||
1992 | patchM.TL.resetTo(FPoint(x1, y1)); |
||
1993 | patchM.TL.shade = 100; |
||
1994 | patchM.TL.transparency = 1.0; |
||
1995 | patchM.TL.colorName = getColor(shading->getColorSpace(), &color[1], &shade); |
||
1996 | patchM.TL.color = ScColorEngine::getShadeColorProof(m_doc->PageColors[patchM.TL.colorName], m_doc, shade); |
||
1997 | patchM.TR.resetTo(FPoint(x2, y2)); |
||
1998 | patchM.TR.shade = 100; |
||
1999 | patchM.TR.transparency = 1.0; |
||
2000 | patchM.TR.colorName = getColor(shading->getColorSpace(), &color[2], &shade); |
||
2001 | patchM.TR.color = ScColorEngine::getShadeColorProof(m_doc->PageColors[patchM.TR.colorName], m_doc, shade); |
||
2002 | patchM.BR.resetTo(FPoint(x0, y0)); |
||
2003 | patchM.BR.shade = 100; |
||
2004 | patchM.BR.transparency = 1.0; |
||
2005 | patchM.BR.colorName = getColor(shading->getColorSpace(), &color[0], &shade); |
||
2006 | patchM.BR.color = ScColorEngine::getShadeColorProof(m_doc->PageColors[patchM.BR.colorName], m_doc, shade); |
||
2007 | patchM.TL.transform(m_ctm); |
||
2008 | patchM.TL.moveRel(-crect.x(), -crect.y()); |
||
2009 | patchM.TR.transform(m_ctm); |
||
2010 | patchM.TR.moveRel(-crect.x(), -crect.y()); |
||
2011 | patchM.BR.transform(m_ctm); |
||
2012 | patchM.BR.moveRel(-crect.x(), -crect.y()); |
||
2013 | patchM.BL.transform(m_ctm); |
||
2014 | patchM.BL.moveRel(-crect.x(), -crect.y()); |
||
2015 | ite->meshGradientPatches.append(patchM); |
||
2016 | } |
||
2017 | ite->GrType = 12; |
||
2018 | return gTrue; |
||
2019 | } |
||
2020 | |||
2021 | GBool SlaOutputDev::patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *shading) |
||
2022 | { |
||
2023 | // qDebug() << "mesh shaded fill"; |
||
2024 | double xCoor = m_doc->currentPage()->xOffset(); |
||
2025 | double yCoor = m_doc->currentPage()->yOffset(); |
||
2026 | double xmin, ymin, xmax, ymax; |
||
2027 | // get the clip region bbox |
||
2028 | state->getClipBBox(&xmin, &ymin, &xmax, &ymax); |
||
2029 | QRectF crect = QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax)); |
||
2030 | crect = crect.normalized(); |
||
2031 | QString output = QString("M %1 %2").arg(0.0).arg(0.0); |
||
2032 | output += QString("L %1 %2").arg(crect.width()).arg(0.0); |
||
2033 | output += QString("L %1 %2").arg(crect.width()).arg(crect.height()); |
||
2034 | output += QString("L %1 %2").arg(0.0).arg(crect.height()); |
||
2035 | output += QString("L %1 %2").arg(0.0).arg(0.0); |
||
2036 | output += QString("Z"); |
||
2037 | pathIsClosed = true; |
||
2038 | Coords = output; |
||
2039 | double *ctm; |
||
2040 | ctm = state->getCTM(); |
||
2041 | m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); |
||
2042 | int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, CurrColorFill, CommonStrings::None, true); |
||
2043 | PageItem* ite = m_doc->Items->at(z); |
||
2044 | ite->ClipEdited = true; |
||
2045 | ite->FrameType = 3; |
||
2046 | ite->setFillShade(CurrFillShade); |
||
2047 | ite->setLineShade(100); |
||
2048 | ite->setFillEvenOdd(false); |
||
2049 | ite->setFillTransparency(1.0 - state->getFillOpacity()); |
||
2050 | ite->setFillBlendmode(getBlendMode(state)); |
||
2051 | ite->setLineEnd(PLineEnd); |
||
2052 | ite->setLineJoin(PLineJoin); |
||
2053 | ite->setTextFlowMode(PageItem::TextFlowDisabled); |
||
2054 | m_doc->AdjustItemSize(ite); |
||
2055 | m_Elements->append(ite); |
||
2056 | if (m_groupStack.count() != 0) |
||
2057 | { |
||
2058 | m_groupStack.top().Items.append(ite); |
||
2059 | applyMask(ite); |
||
2060 | } |
||
2061 | ite->meshGradientPatches.clear(); |
||
2062 | for (int i = 0; i < shading->getNPatches(); i++) |
||
2063 | { |
||
2064 | int shade = 100; |
||
2065 | GfxPatch *patch = shading->getPatch(i); |
||
2066 | GfxColor color; |
||
2067 | meshGradientPatch patchM; |
||
2068 | int u, v; |
||
2069 | patchM.BL.resetTo(FPoint(patch->x[0][0], patch->y[0][0])); |
||
2070 | patchM.BL.controlTop = FPoint(patch->x[0][1], patch->y[0][1]); |
||
2071 | patchM.BL.controlRight = FPoint(patch->x[1][0], patch->y[1][0]); |
||
2072 | patchM.BL.controlColor = FPoint(patch->x[1][1], patch->y[1][1]); |
||
2073 | u = 0; |
||
2074 | v = 0; |
||
2075 | if (shading->isParameterized()) |
||
2076 | { |
||
2077 | shading->getParameterizedColor (patch->color[u][v].c[0], &color); |
||
2078 | } |
||
2079 | else |
||
2080 | { |
||
2081 | for (int k = 0; k < shading->getColorSpace()->getNComps(); k++) |
||
2082 | { |
||
2083 | color.c[k] = GfxColorComp (patch->color[u][v].c[k]); |
||
2084 | } |
||
2085 | } |
||
2086 | patchM.BL.colorName = getColor(shading->getColorSpace(), &color, &shade); |
||
2087 | patchM.BL.shade = 100; |
||
2088 | patchM.BL.transparency = 1.0; |
||
2089 | patchM.BL.color = ScColorEngine::getShadeColorProof(m_doc->PageColors[patchM.BL.colorName], m_doc, shade); |
||
2090 | |||
2091 | u = 0; |
||
2092 | v = 1; |
||
2093 | patchM.TL.resetTo(FPoint(patch->x[0][3], patch->y[0][3])); |
||
2094 | patchM.TL.controlRight = FPoint(patch->x[1][3], patch->y[1][3]); |
||
2095 | patchM.TL.controlBottom = FPoint(patch->x[0][2], patch->y[0][2]); |
||
2096 | patchM.TL.controlColor = FPoint(patch->x[1][2], patch->y[1][2]); |
||
2097 | if (shading->isParameterized()) |
||
2098 | { |
||
2099 | shading->getParameterizedColor (patch->color[u][v].c[0], &color); |
||
2100 | } |
||
2101 | else |
||
2102 | { |
||
2103 | for (int k = 0; k < shading->getColorSpace()->getNComps(); k++) |
||
2104 | { |
||
2105 | color.c[k] = GfxColorComp (patch->color[u][v].c[k]); |
||
2106 | } |
||
2107 | } |
||
2108 | patchM.TL.colorName = getColor(shading->getColorSpace(), &color, &shade); |
||
2109 | patchM.TL.shade = 100; |
||
2110 | patchM.TL.transparency = 1.0; |
||
2111 | patchM.TL.color = ScColorEngine::getShadeColorProof(m_doc->PageColors[patchM.TL.colorName], m_doc, shade); |
||
2112 | |||
2113 | u = 1; |
||
2114 | v = 1; |
||
2115 | patchM.TR.resetTo(FPoint(patch->x[3][3], patch->y[3][3])); |
||
2116 | patchM.TR.controlBottom = FPoint(patch->x[3][2], patch->y[3][2]); |
||
2117 | patchM.TR.controlLeft = FPoint(patch->x[2][3], patch->y[2][3]); |
||
2118 | patchM.TR.controlColor = FPoint(patch->x[2][2], patch->y[2][2]); |
||
2119 | if (shading->isParameterized()) |
||
2120 | { |
||
2121 | shading->getParameterizedColor (patch->color[u][v].c[0], &color); |
||
2122 | } |
||
2123 | else |
||
2124 | { |
||
2125 | for (int k = 0; k < shading->getColorSpace()->getNComps(); k++) |
||
2126 | { |
||
2127 | color.c[k] = GfxColorComp (patch->color[u][v].c[k]); |
||
2128 | } |
||
2129 | } |
||
2130 | patchM.TR.colorName = getColor(shading->getColorSpace(), &color, &shade); |
||
2131 | patchM.TR.shade = 100; |
||
2132 | patchM.TR.transparency = 1.0; |
||
2133 | patchM.TR.color = ScColorEngine::getShadeColorProof(m_doc->PageColors[patchM.TR.colorName], m_doc, shade); |
||
2134 | |||
2135 | u = 1; |
||
2136 | v = 0; |
||
2137 | patchM.BR.resetTo(FPoint(patch->x[3][0], patch->y[3][0])); |
||
2138 | patchM.BR.controlLeft = FPoint(patch->x[2][0], patch->y[2][0]); |
||
2139 | patchM.BR.controlTop = FPoint(patch->x[3][1], patch->y[3][1]); |
||
2140 | & |