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