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