Rev 17407 | Rev 17474 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4430 | cbradney | 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 | */ |
||
4360 | cbradney | 7 | #include "scpageoutput.h" |
8 | |||
10212 | cbradney | 9 | #include <QList> |
10227 | jghali | 10 | #include <QPointF> |
11 | #include <QRectF> |
||
9922 | fschmid | 12 | #include <QStack> |
10212 | cbradney | 13 | |
5784 | jghali | 14 | #include "cmsettings.h" |
4617 | avox | 15 | #include "commonstrings.h" |
10212 | cbradney | 16 | #include "pageitem.h" |
17296 | jghali | 17 | #include "pageitem_arc.h" |
17288 | jghali | 18 | #include "pageitem_group.h" |
4360 | cbradney | 19 | #include "pageitem_imageframe.h" |
20 | #include "pageitem_line.h" |
||
21 | #include "pageitem_pathtext.h" |
||
22 | #include "pageitem_polygon.h" |
||
23 | #include "pageitem_polyline.h" |
||
17328 | jghali | 24 | #include "pageitem_regularpolygon.h" |
17296 | jghali | 25 | #include "pageitem_spiral.h" |
4360 | cbradney | 26 | #include "pageitem_textframe.h" |
10212 | cbradney | 27 | #include "prefsmanager.h" |
5993 | avox | 28 | #include "scfonts.h" |
10212 | cbradney | 29 | #include "scimage.h" |
16736 | jghali | 30 | #include "scpage.h" |
10601 | mrdocs | 31 | #include "scpattern.h" |
4360 | cbradney | 32 | #include "scribus.h" |
10212 | cbradney | 33 | #include "scribusdoc.h" |
4360 | cbradney | 34 | #include "util.h" |
10212 | cbradney | 35 | #include "util_formats.h" |
10992 | jghali | 36 | #include "util_math.h" |
4360 | cbradney | 37 | |
10212 | cbradney | 38 | |
7108 | jghali | 39 | MarksOptions::MarksOptions(void) |
4360 | cbradney | 40 | { |
17401 | jghali | 41 | markLength = 20.0; |
7108 | jghali | 42 | markOffset = 0.0; |
43 | BleedTop = 0.0; |
||
44 | BleedLeft = 0.0; |
||
45 | BleedRight = 0.0; |
||
46 | BleedBottom = 0.0; |
||
47 | cropMarks = false; |
||
48 | bleedMarks = false; |
||
49 | registrationMarks = false; |
||
50 | colorMarks = false; |
||
51 | docInfoMarks = false; |
||
52 | } |
||
53 | |||
54 | MarksOptions::MarksOptions(struct PrintOptions& opt) |
||
55 | { |
||
17401 | jghali | 56 | markLength = opt.markLength; |
7108 | jghali | 57 | markOffset = opt.markOffset; |
7252 | jghali | 58 | BleedTop = opt.bleeds.Top; |
59 | BleedLeft = opt.bleeds.Left; |
||
60 | BleedRight = opt.bleeds.Right; |
||
61 | BleedBottom = opt.bleeds.Bottom; |
||
7108 | jghali | 62 | cropMarks = opt.cropMarks; |
63 | bleedMarks = opt.bleedMarks; |
||
64 | registrationMarks = opt.registrationMarks; |
||
65 | colorMarks = opt.colorMarks; |
||
66 | docInfoMarks = true; |
||
67 | } |
||
68 | |||
69 | ScPageOutput::ScPageOutput(ScribusDoc* doc, bool reloadImages, int resolution, bool useProfiles) |
||
70 | : m_marksOptions() |
||
71 | { |
||
4360 | cbradney | 72 | m_doc = doc; |
73 | m_reloadImages = reloadImages; |
||
74 | m_imageRes = resolution; |
||
75 | m_useProfiles = useProfiles; |
||
76 | } |
||
77 | |||
5345 | mrdocs | 78 | ScImage::RequestType ScPageOutput::translateImageModeToRequest( ScPainterExBase::ImageMode mode ) |
79 | { |
||
80 | ScImage::RequestType value = ScImage::RGBData; |
||
81 | if ( mode == ScPainterExBase::cmykImages ) |
||
82 | value = ScImage::CMYKData; |
||
83 | else if ( mode == ScPainterExBase::rgbImages ) |
||
84 | value = ScImage::RGBData; |
||
85 | else if ( mode == ScPainterExBase::rawImages ) |
||
86 | value = ScImage::RawData; |
||
87 | return value; |
||
88 | } |
||
89 | |||
16729 | fschmid | 90 | void ScPageOutput::drawPage( ScPage* page, ScPainterExBase* painter) |
4360 | cbradney | 91 | { |
92 | int clipx = static_cast<int>(page->xOffset()); |
||
93 | int clipy = static_cast<int>(page->yOffset()); |
||
94 | int clipw = qRound(page->width()); |
||
95 | int cliph = qRound(page->height()); |
||
13873 | jghali | 96 | ScLayer layer; |
97 | layer.isViewable = false; |
||
98 | uint layerCount = m_doc->layerCount(); |
||
99 | for (uint la = 0; la < layerCount; ++la) |
||
100 | { |
||
101 | m_doc->Layers.levelToLayer(layer, la); |
||
102 | drawMasterItems(painter, page, layer, QRect(clipx, clipy, clipw, cliph)); |
||
103 | drawPageItems(painter, page, layer, QRect(clipx, clipy, clipw, cliph)); |
||
104 | } |
||
11905 | jghali | 105 | drawMarks(page, painter, m_marksOptions); |
4360 | cbradney | 106 | } |
107 | |||
16729 | fschmid | 108 | void ScPageOutput::drawMasterItems(ScPainterExBase *painter, ScPage *page, ScLayer& layer, const QRect& clip) |
4360 | cbradney | 109 | { |
13873 | jghali | 110 | PageItem* currItem; |
111 | if (page->MPageNam.isEmpty()) |
||
112 | return; |
||
113 | if (page->FromMaster.count() <= 0) |
||
114 | return; |
||
115 | if (!layer.isViewable || !layer.isPrintable) |
||
116 | return; |
||
16729 | fschmid | 117 | ScPage* Mp = m_doc->MasterPages.at(m_doc->MasterNames[page->MPageNam]); |
13873 | jghali | 118 | uint pageFromMasterCount = page->FromMaster.count(); |
119 | for (uint a = 0; a < pageFromMasterCount; ++a) |
||
4360 | cbradney | 120 | { |
13873 | jghali | 121 | currItem = page->FromMaster.at(a); |
13875 | jghali | 122 | if (currItem->LayerID != layer.ID) |
13873 | jghali | 123 | continue; |
124 | if ((currItem->OwnPage != -1) && (currItem->OwnPage != static_cast<int>(Mp->pageNr()))) |
||
125 | continue; |
||
126 | if (!currItem->printEnabled()) |
||
127 | continue; |
||
128 | int savedOwnPage = currItem->OwnPage; |
||
129 | double OldX = currItem->xPos(); |
||
130 | double OldY = currItem->yPos(); |
||
131 | double OldBX = currItem->BoundingX; |
||
132 | double OldBY = currItem->BoundingY; |
||
133 | currItem->OwnPage = page->pageNr(); |
||
134 | if (!currItem->ChangedMasterItem) |
||
135 | { |
||
136 | currItem->moveBy(-Mp->xOffset() + page->xOffset(), -Mp->yOffset() + page->yOffset(), true); |
||
137 | currItem->BoundingX = OldBX - Mp->xOffset() + page->xOffset(); |
||
138 | currItem->BoundingY = OldBY - Mp->yOffset() + page->yOffset(); |
||
139 | } |
||
140 | /*if (evSpon) |
||
141 | currItem->Dirty = true;*/ |
||
142 | QRect oldR(currItem->getRedrawBounding(1.0)); |
||
143 | if (clip.intersects(oldR)) |
||
144 | { |
||
145 | // relayout necessary to get page number ok |
||
146 | currItem->invalidateLayout(); |
||
147 | currItem->layout(); |
||
148 | drawItem(currItem, painter, clip); |
||
149 | } |
||
150 | currItem->OwnPage = savedOwnPage; |
||
151 | if (!currItem->ChangedMasterItem) |
||
152 | { |
||
153 | currItem->setXYPos(OldX, OldY, true); |
||
154 | currItem->BoundingX = OldBX; |
||
155 | currItem->BoundingY = OldBY; |
||
156 | } |
||
157 | } |
||
4360 | cbradney | 158 | } |
159 | |||
16729 | fschmid | 160 | void ScPageOutput::drawPageItems(ScPainterExBase *painter, ScPage *page, ScLayer& layer, const QRect& clip) |
4360 | cbradney | 161 | { |
13873 | jghali | 162 | PageItem *currItem; |
163 | if (m_doc->Items->count() <= 0) |
||
164 | return; |
||
165 | if (!layer.isViewable || !layer.isPrintable) |
||
166 | return; |
||
167 | int docCurrPageNo = static_cast<int>(page->pageNr()); |
||
168 | for (int it = 0; it < m_doc->Items->count(); ++it) |
||
4360 | cbradney | 169 | { |
13873 | jghali | 170 | currItem = m_doc->Items->at(it); |
13875 | jghali | 171 | if (currItem->LayerID != layer.ID) |
13873 | jghali | 172 | continue; |
173 | if (!currItem->printEnabled()) |
||
174 | continue; |
||
175 | if ((m_doc->masterPageMode()) && ((currItem->OwnPage != -1) && (currItem->OwnPage != docCurrPageNo))) |
||
176 | continue; |
||
177 | if (!m_doc->masterPageMode() && !currItem->OnMasterPage.isEmpty()) |
||
4360 | cbradney | 178 | { |
13873 | jghali | 179 | if (currItem->OnMasterPage != page->pageName()) |
180 | continue; |
||
181 | } |
||
182 | QRect oldR(currItem->getRedrawBounding(1.0)); |
||
183 | if (clip.intersects(oldR)) |
||
184 | { |
||
185 | drawItem( currItem, painter, clip ); |
||
186 | } |
||
187 | } |
||
4360 | cbradney | 188 | } |
189 | |||
11905 | jghali | 190 | void ScPageOutput::drawItem( PageItem* item, ScPainterExBase* painter, const QRect& clip ) |
4360 | cbradney | 191 | { |
11905 | jghali | 192 | drawItem_Pre(item, painter); |
4360 | cbradney | 193 | PageItem::ItemType itemType = item->itemType(); |
17296 | jghali | 194 | if (itemType == PageItem::Arc) |
195 | drawItem_Arc( (PageItem_Arc*) item, painter, clip); |
||
196 | else if (itemType == PageItem::Group) |
||
17288 | jghali | 197 | drawItem_Group( (PageItem_Group*) item, painter, clip); |
198 | else if (itemType == PageItem::ImageFrame) |
||
11905 | jghali | 199 | drawItem_ImageFrame( (PageItem_ImageFrame*) item, painter, clip); |
17288 | jghali | 200 | else if (itemType == PageItem::Line) |
11905 | jghali | 201 | drawItem_Line( (PageItem_Line*) item, painter, clip); |
17288 | jghali | 202 | else if (itemType == PageItem::PathText) |
11905 | jghali | 203 | drawItem_PathText( (PageItem_PathText*) item, painter, clip); |
17288 | jghali | 204 | else if (itemType == PageItem::Polygon) |
11905 | jghali | 205 | drawItem_Polygon( (PageItem_Polygon*) item, painter, clip); |
17288 | jghali | 206 | else if (itemType == PageItem::PolyLine) |
11905 | jghali | 207 | drawItem_PolyLine( (PageItem_PolyLine*) item, painter, clip); |
17328 | jghali | 208 | else if (itemType == PageItem::RegularPolygon) |
209 | drawItem_RegularPolygon( (PageItem_RegularPolygon*) item, painter, clip); |
||
17296 | jghali | 210 | else if (itemType == PageItem::Spiral) |
211 | drawItem_Spiral( (PageItem_Spiral*) item, painter, clip); |
||
17288 | jghali | 212 | else if (itemType == PageItem::TextFrame) |
11905 | jghali | 213 | drawItem_TextFrame( (PageItem_TextFrame*) item, painter, clip); |
214 | drawItem_Post(item, painter); |
||
4360 | cbradney | 215 | } |
216 | |||
11905 | jghali | 217 | void ScPageOutput::drawItem_Pre( PageItem* item, ScPainterExBase* painter) |
4360 | cbradney | 218 | { |
219 | painter->save(); |
||
220 | if (!item->isEmbedded) |
||
6987 | jghali | 221 | painter->translate( item->xPos(), item->yPos()); |
4360 | cbradney | 222 | painter->rotate(item->rotation()); |
17263 | jghali | 223 | painter->setBlendModeFill(item->fillBlendmode()); |
4617 | avox | 224 | painter->setLineWidth(item->lineWidth()); |
17263 | jghali | 225 | if (item->isGroup()) |
226 | return; |
||
6987 | jghali | 227 | if (item->GrType == 8) |
4360 | cbradney | 228 | { |
6987 | jghali | 229 | QString pat = item->pattern(); |
230 | if ((pat.isEmpty()) || (!m_doc->docPatterns.contains(pat))) |
||
231 | { |
||
232 | painter->m_fillGradient = VGradientEx(VGradientEx::linear); |
||
233 | if (item->fillColor() != CommonStrings::None) |
||
234 | { |
||
10227 | jghali | 235 | painter->setBrush(ScColorShade(m_doc->PageColors[item->fillColor()], (int) item->fillShade())); |
7108 | jghali | 236 | painter->setFillMode(ScPainterExBase::Solid); |
6987 | jghali | 237 | } |
238 | else |
||
7108 | jghali | 239 | painter->setFillMode(ScPainterExBase::None); |
6987 | jghali | 240 | } |
241 | else |
||
242 | { |
||
13951 | fschmid | 243 | QTransform patternTransform; |
6987 | jghali | 244 | ScPattern& pattern = m_doc->docPatterns[item->pattern()]; |
14260 | fschmid | 245 | double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY; |
17263 | jghali | 246 | bool patternMirrorX, patternMirrorY; |
14260 | fschmid | 247 | item->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY); |
17263 | jghali | 248 | item->patternFlip(patternMirrorX, patternMirrorY); |
249 | painter->setPattern(&pattern, patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY, patternMirrorX, patternMirrorY); |
||
6987 | jghali | 250 | painter->setFillMode(ScPainterExBase::Pattern); |
251 | } |
||
252 | } |
||
17263 | jghali | 253 | else if (item->GrType == 9) |
254 | { |
||
255 | painter->setFillMode(ScPainterExBase::Gradient); |
||
256 | FPoint pG1 = FPoint(0, 0); |
||
257 | FPoint pG2 = FPoint(item->width(), 0); |
||
258 | FPoint pG3 = FPoint(item->width(), item->height()); |
||
259 | FPoint pG4 = FPoint(0, item->height()); |
||
260 | ScColorShade col1(m_doc->PageColors[item->GrColorP1], item->GrCol1Shade); |
||
261 | ScColorShade col2(m_doc->PageColors[item->GrColorP2], item->GrCol2Shade); |
||
262 | ScColorShade col3(m_doc->PageColors[item->GrColorP3], item->GrCol3Shade); |
||
263 | ScColorShade col4(m_doc->PageColors[item->GrColorP4], item->GrCol4Shade); |
||
264 | painter->set4ColorGeometry(pG1, pG2, pG3, pG4, item->GrControl1, item->GrControl2, item->GrControl3, item->GrControl4); |
||
265 | painter->set4ColorColors(col1, col2, col3, col4); |
||
266 | } |
||
6987 | jghali | 267 | else if (item->GrType != 0) |
268 | { |
||
17263 | jghali | 269 | QString gradientVal = item->gradient(); |
270 | if ((!gradientVal.isEmpty()) && (!m_doc->docGradients.contains(gradientVal))) |
||
271 | gradientVal = ""; |
||
272 | if (!(gradientVal.isEmpty()) && (m_doc->docGradients.contains(gradientVal))) |
||
273 | painter->m_fillGradient = VGradientEx(m_doc->docGradients[gradientVal], *m_doc); |
||
274 | if ((painter->m_fillGradient.Stops() < 2) && (item->GrType < 9)) // fall back to solid filling if there are not enough colorstops in the gradient. |
||
4360 | cbradney | 275 | { |
17263 | jghali | 276 | if (item->fillColor() != CommonStrings::None) |
277 | { |
||
278 | painter->setBrush( ScColorShade(m_doc->PageColors[item->fillColor()], (int) item->fillShade()) ); |
||
279 | painter->setFillMode(ScPainterExBase::Solid); |
||
280 | } |
||
281 | else |
||
282 | painter->setFillMode(ScPainterExBase::None); |
||
4360 | cbradney | 283 | } |
17263 | jghali | 284 | else |
285 | { |
||
286 | FPoint fpStart(item->GrStartX, item->GrStartY), fpEnd(item->GrEndX, item->GrEndY); |
||
287 | FPoint fpFocal(item->GrFocalX, item->GrFocalY); |
||
288 | painter->setFillMode(ScPainterExBase::Gradient); |
||
289 | painter->m_fillGradient = VGradientEx(item->fill_gradient, *m_doc); |
||
290 | switch (item->GrType) |
||
291 | { |
||
292 | case 1: |
||
293 | case 2: |
||
294 | case 3: |
||
295 | case 4: |
||
296 | case 6: |
||
297 | painter->setGradient(VGradientEx::linear, fpStart, fpEnd, fpStart, item->GrScale, item->GrSkew); |
||
298 | break; |
||
299 | case 5: |
||
300 | case 7: |
||
301 | painter->setGradient(VGradientEx::radial, fpStart, fpEnd, fpFocal, item->GrScale, item->GrSkew); |
||
302 | break; |
||
303 | case 10: |
||
304 | painter->setFillMode(ScPainterExBase::Gradient); |
||
305 | painter->setDiamondGeometry(FPoint(0, 0), FPoint(item->width(), 0), FPoint(item->width(), item->height()), FPoint(0, item->height()), |
||
306 | item->GrControl1, item->GrControl2, item->GrControl3, item->GrControl4, item->GrControl5); |
||
307 | break; |
||
308 | case 11: |
||
309 | case 13: |
||
310 | painter->setFillMode(ScPainterExBase::Gradient); |
||
311 | painter->setMeshGradient(FPoint(0, 0), FPoint(item->width(), 0), FPoint(item->width(), item->height()), FPoint(0, item->height()), item->meshGradientArray); |
||
312 | break; |
||
313 | case 12: |
||
314 | painter->setFillMode(ScPainterExBase::Gradient); |
||
315 | painter->setMeshGradient(FPoint(0, 0), FPoint(item->width(), 0), FPoint(item->width(), item->height()), FPoint(0, item->height()), item->meshGradientPatches); |
||
316 | break; |
||
317 | } |
||
318 | } |
||
4360 | cbradney | 319 | } |
320 | else |
||
321 | { |
||
6987 | jghali | 322 | painter->m_fillGradient = VGradientEx(VGradientEx::linear); |
4546 | subik | 323 | if (item->fillColor() != CommonStrings::None) |
4360 | cbradney | 324 | { |
10227 | jghali | 325 | painter->setBrush( ScColorShade(m_doc->PageColors[item->fillColor()], (int) item->fillShade()) ); |
4360 | cbradney | 326 | painter->setFillMode(ScPainterExBase::Solid); |
327 | } |
||
328 | else |
||
329 | painter->setFillMode(ScPainterExBase::None); |
||
330 | } |
||
4546 | subik | 331 | if (item->lineColor() != CommonStrings::None) |
4360 | cbradney | 332 | { |
4617 | avox | 333 | if ((item->lineWidth() == 0) && !item->asLine()) |
4360 | cbradney | 334 | painter->setLineWidth(0); |
335 | else |
||
336 | { |
||
10227 | jghali | 337 | ScColorShade tmp(m_doc->PageColors[item->lineColor()], (int) item->lineShade()); |
4617 | avox | 338 | painter->setPen( tmp , item->lineWidth(), item->PLineArt, item->PLineEnd, item->PLineJoin); |
4360 | cbradney | 339 | if (item->DashValues.count() != 0) |
340 | painter->setDash(item->DashValues, item->DashOffset); |
||
341 | } |
||
342 | } |
||
343 | else |
||
344 | painter->setLineWidth(0); |
||
345 | painter->setBrushOpacity(1.0 - item->fillTransparency()); |
||
346 | painter->setPenOpacity(1.0 - item->lineTransparency()); |
||
4480 | cbradney | 347 | painter->setFillRule(item->fillRule); |
17263 | jghali | 348 | |
349 | if ((item->GrMask == 1) || (item->GrMask == 2) || (item->GrMask == 4) || (item->GrMask == 5)) |
||
350 | { |
||
351 | QString gradientMaskVal = item->gradientMaskVal; |
||
352 | FPoint fpMaskStart(item->GrMaskStartX, item->GrMaskStartY); |
||
353 | FPoint fpMaskEnd(item->GrMaskEndX, item->GrMaskEndY); |
||
354 | FPoint fpMaskFocal(item->GrMaskFocalX, item->GrMaskFocalY); |
||
355 | if ((item->GrMask == 1) || (item->GrMask == 2)) |
||
356 | painter->setMaskMode(1); |
||
357 | else |
||
358 | painter->setMaskMode(3); |
||
359 | if ((!gradientMaskVal.isEmpty()) && (!m_doc->docGradients.contains(gradientMaskVal))) |
||
360 | gradientMaskVal = ""; |
||
361 | if (!(gradientMaskVal.isEmpty()) && (m_doc->docGradients.contains(gradientMaskVal))) |
||
362 | painter->m_maskGradient = VGradientEx(m_doc->docGradients[gradientMaskVal], *m_doc); |
||
363 | if ((item->GrMask == 1) || (item->GrMask == 4)) |
||
364 | painter->setGradientMask(VGradientEx::linear, fpMaskStart, fpMaskEnd, fpMaskStart, item->GrMaskScale, item->GrMaskSkew); |
||
365 | else |
||
366 | painter->setGradientMask(VGradientEx::radial, fpMaskStart, fpMaskEnd, fpMaskFocal, item->GrMaskScale, item->GrMaskSkew); |
||
367 | } |
||
368 | else if ((item->GrMask == 3) || (item->GrMask == 6) || (item->GrMask == 7) || (item->GrMask == 8)) |
||
369 | { |
||
370 | QString patternMaskVal = item->patternMaskVal; |
||
371 | if ((patternMaskVal.isEmpty()) || (!m_doc->docPatterns.contains(patternMaskVal))) |
||
372 | painter->setMaskMode(0); |
||
373 | else |
||
374 | { |
||
375 | painter->setPatternMask(&m_doc->docPatterns[patternMaskVal], item->patternMaskScaleX, item->patternMaskScaleY, item->patternMaskOffsetX, item->patternMaskOffsetY, |
||
376 | item->patternMaskRotation, item->patternMaskSkewX, item->patternMaskSkewY, item->patternMaskMirrorX, item->patternMaskMirrorY); |
||
377 | if (item->GrMask == 3) |
||
378 | painter->setMaskMode(2); |
||
379 | else if (item->GrMask == 6) |
||
380 | painter->setMaskMode(4); |
||
381 | else if (item->GrMask == 7) |
||
382 | painter->setMaskMode(5); |
||
383 | else |
||
384 | painter->setMaskMode(6); |
||
385 | } |
||
386 | } |
||
387 | else |
||
388 | painter->setMaskMode(0); |
||
4360 | cbradney | 389 | } |
390 | |||
11905 | jghali | 391 | void ScPageOutput::drawItem_Post( PageItem* item, ScPainterExBase* painter ) |
4360 | cbradney | 392 | { |
17263 | jghali | 393 | bool doStroke = true; |
394 | if (!item->isGroup()) |
||
4360 | cbradney | 395 | { |
17263 | jghali | 396 | painter->setMaskMode(0); |
17328 | jghali | 397 | if (item->isGroup() || item->isLine() || item->isPathText() || item->isPolyLine() || item->isSpiral() || item->isSymbol() || item->isTable() ) |
17263 | jghali | 398 | doStroke = false; |
399 | if ((doStroke)) |
||
4360 | cbradney | 400 | { |
17263 | jghali | 401 | painter->setBlendModeStroke(item->lineBlendmode()); |
402 | painter->setPenOpacity(1.0 - item->lineTransparency()); |
||
403 | if ((item->lineColor() != CommonStrings::None)|| (!item->strokePattern().isEmpty()) || (item->strokeGradientType() > 0)) |
||
404 | { |
||
405 | ScColorShade tmp(m_doc->PageColors[item->lineColor()], (int) item->lineShade()); |
||
406 | painter->setPen(tmp, item->lineWidth(), item->PLineArt, item->PLineEnd, item->PLineJoin); |
||
407 | if (item->DashValues.count() != 0) |
||
408 | painter->setDash(item->DashValues, item->DashOffset); |
||
409 | } |
||
4360 | cbradney | 410 | else |
17263 | jghali | 411 | painter->setLineWidth(0); |
17418 | fschmid | 412 | if ((item->itemType() == PageItem::LatexFrame) || (item->itemType() == PageItem::ImageFrame) || (item->itemType() == PageItem::OSGFrame)) |
413 | painter->setupPolygon(&item->PoLine); |
||
414 | if (item->NamedLStyle.isEmpty()) |
||
4360 | cbradney | 415 | { |
17418 | fschmid | 416 | QString patternStrokeVal = item->strokePattern(); |
417 | if ((!patternStrokeVal.isEmpty()) && (m_doc->docPatterns.contains(patternStrokeVal))) |
||
4360 | cbradney | 418 | { |
17418 | fschmid | 419 | if (item->patternStrokePath) |
7143 | jghali | 420 | { |
17418 | fschmid | 421 | QPainterPath guidePath = item->PoLine.toQPainterPath(false); |
422 | drawStrokePattern(item, painter, guidePath); |
||
17263 | jghali | 423 | } |
17418 | fschmid | 424 | else |
17263 | jghali | 425 | { |
17418 | fschmid | 426 | painter->setPattern(&m_doc->docPatterns[patternStrokeVal], item->patternStrokeScaleX, item->patternStrokeScaleY, item->patternStrokeOffsetX, item->patternStrokeOffsetY, item->patternStrokeRotation, item->patternStrokeSkewX, item->patternStrokeSkewY, item->patternStrokeMirrorX, item->patternStrokeMirrorY); |
427 | painter->setStrokeMode(ScPainterExBase::Pattern); |
||
428 | painter->strokePath(); |
||
429 | } |
||
430 | } |
||
431 | else if (item->strokeGradientType() > 0) |
||
432 | { |
||
433 | QString gradientStrokeVal = item->strokeGradient(); |
||
434 | if ((!gradientStrokeVal.isEmpty()) && (!m_doc->docGradients.contains(gradientStrokeVal))) |
||
435 | gradientStrokeVal = ""; |
||
436 | if (!(gradientStrokeVal.isEmpty()) && (m_doc->docGradients.contains(gradientStrokeVal))) |
||
437 | painter->m_strokeGradient = VGradientEx(m_doc->docGradients[gradientStrokeVal], *m_doc); |
||
438 | if (painter->m_strokeGradient.Stops() < 2) // fall back to solid stroking if there are not enough colorstops in the gradient. |
||
439 | { |
||
440 | if (item->lineColor() != CommonStrings::None) |
||
17263 | jghali | 441 | { |
17418 | fschmid | 442 | ScColorShade strokeColor(m_doc->PageColors[item->lineColor()], item->lineShade()); |
443 | painter->setBrush(strokeColor); |
||
444 | painter->setStrokeMode(ScPainterExBase::Solid); |
||
17263 | jghali | 445 | } |
446 | else |
||
17418 | fschmid | 447 | painter->setStrokeMode(ScPainterExBase::None); |
7143 | jghali | 448 | } |
17418 | fschmid | 449 | else |
17263 | jghali | 450 | { |
17418 | fschmid | 451 | FPoint fpStart(item->GrStrokeStartX, item->GrStrokeStartY); |
452 | FPoint fpEnd(item->GrStrokeEndX, item->GrStrokeEndY); |
||
453 | FPoint fpFocal(item->GrStrokeFocalX, item->GrStrokeFocalY); |
||
454 | painter->setStrokeMode(ScPainterExBase::Gradient); |
||
455 | painter->m_strokeGradient = VGradientEx(item->stroke_gradient, *m_doc); |
||
456 | if (item->GrTypeStroke == 6) |
||
457 | painter->setGradient(VGradientEx::linear, fpStart, fpEnd, fpStart, item->GrStrokeScale, item->GrStrokeSkew); |
||
458 | else |
||
459 | painter->setGradient(VGradientEx::radial, fpStart, fpEnd, fpFocal, item->GrStrokeScale, item->GrStrokeSkew); |
||
17263 | jghali | 460 | } |
17418 | fschmid | 461 | painter->strokePath(); |
4360 | cbradney | 462 | } |
17418 | fschmid | 463 | else if (item->lineColor() != CommonStrings::None) |
17263 | jghali | 464 | { |
17418 | fschmid | 465 | ScColorShade scColor(m_doc->PageColors[item->lineColor()], item->lineShade()); |
466 | painter->setStrokeMode(ScPainterExBase::Solid); |
||
467 | painter->setPen(scColor, item->lineWidth(), item->PLineArt, item->PLineEnd, item->PLineJoin); |
||
468 | if (item->DashValues.count() != 0) |
||
469 | painter->setDash(item->DashValues, item->DashOffset); |
||
470 | painter->strokePath(); |
||
471 | } |
||
472 | } |
||
473 | else |
||
474 | { |
||
475 | multiLine ml = m_doc->MLineStyles[item->NamedLStyle]; |
||
476 | for (int it = ml.size()-1; it > -1; it--) |
||
477 | { |
||
478 | const SingleLine& sl = ml[it]; |
||
479 | if ((sl.Color != CommonStrings::None) && (sl.Width != 0)) |
||
17263 | jghali | 480 | { |
17418 | fschmid | 481 | ScColorShade tmp(m_doc->PageColors[sl.Color], sl.Shade); |
482 | painter->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash), |
||
483 | static_cast<Qt::PenCapStyle>(sl.LineEnd), |
||
484 | static_cast<Qt::PenJoinStyle>(sl.LineJoin)); |
||
485 | painter->strokePath(); |
||
17263 | jghali | 486 | } |
487 | } |
||
4360 | cbradney | 488 | } |
17263 | jghali | 489 | painter->setBlendModeStroke(0); |
4360 | cbradney | 490 | } |
491 | } |
||
17263 | jghali | 492 | painter->setFillMode(ScPainterExBase::Solid); |
493 | painter->setBlendModeFill(0); |
||
494 | painter->setStrokeMode(ScPainterExBase::Solid); |
||
495 | painter->setBlendModeStroke(0); |
||
4360 | cbradney | 496 | painter->restore(); |
497 | } |
||
498 | |||
11905 | jghali | 499 | void ScPageOutput::drawGlyphs(PageItem* item, ScPainterExBase *painter, const CharStyle& style, GlyphLayout& glyphs, const QRect& clip) |
4360 | cbradney | 500 | { |
6824 | jghali | 501 | uint glyph = glyphs.glyph; |
8728 | jghali | 502 | if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode())) // NBSPACE |
6824 | jghali | 503 | glyph = style.font().char2CMap(QChar(' ')); |
8728 | jghali | 504 | else if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBHYPHEN.unicode())) // NBHYPHEN |
6824 | jghali | 505 | glyph = style.font().char2CMap(QChar('-')); |
506 | |||
507 | if (glyph >= ScFace::CONTROL_GLYPHS) |
||
8728 | jghali | 508 | { |
509 | if (glyphs.more) |
||
510 | { |
||
511 | painter->translate(glyphs.xadvance, 0); |
||
11905 | jghali | 512 | drawGlyphs(item, painter, style, *glyphs.more, clip); |
8728 | jghali | 513 | } |
4360 | cbradney | 514 | return; |
8728 | jghali | 515 | } |
5988 | jghali | 516 | |
6824 | jghali | 517 | //if (style.font().canRender(QChar(glyph))) |
4360 | cbradney | 518 | { |
13951 | fschmid | 519 | QTransform chma, chma2, chma3, chma4, chma5, chma6; |
5988 | jghali | 520 | chma.scale(glyphs.scaleH * style.fontSize() / 100.00, glyphs.scaleV * style.fontSize() / 100.0); |
6824 | jghali | 521 | FPointArray gly = style.font().glyphOutline(glyph); |
5988 | jghali | 522 | // Do underlining first so you can get typographically correct |
523 | // underlines when drawing a white outline |
||
6824 | jghali | 524 | if ((style.effects() & ScStyle_Underline) || ((style.effects() & ScStyle_UnderlineWords) && (glyph != style.font().char2CMap(QChar(' '))))) |
5988 | jghali | 525 | { |
526 | double st, lw; |
||
6824 | jghali | 527 | if ((style.underlineOffset() != -1) || (style.underlineWidth() != -1)) |
5988 | jghali | 528 | { |
6824 | jghali | 529 | if (style.underlineOffset() != -1) |
530 | st = (style.underlineOffset() / 1000.0) * (style.font().descent(style.fontSize() / 10.0)); |
||
5988 | jghali | 531 | else |
532 | st = style.font().underlinePos(style.fontSize() / 10.0); |
||
533 | if (style.underlineWidth() != -1) |
||
534 | lw = (style.underlineWidth() / 1000.0) * (style.fontSize() / 10.0); |
||
535 | else |
||
8578 | jghali | 536 | lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0); |
5988 | jghali | 537 | } |
538 | else |
||
539 | { |
||
540 | st = style.font().underlinePos(style.fontSize() / 10.0); |
||
8578 | jghali | 541 | lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0); |
5988 | jghali | 542 | } |
543 | if (style.baselineOffset() != 0) |
||
544 | st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0); |
||
6824 | jghali | 545 | ScColorShade tmpPen = painter->pen(); |
5988 | jghali | 546 | painter->setPen(painter->brush()); |
547 | painter->setLineWidth(lw); |
||
8728 | jghali | 548 | if (style.effects() & ScStyle_Subscript) |
549 | painter->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st)); |
||
550 | else |
||
551 | painter->drawLine(FPoint(glyphs.xoffset, -st), FPoint(glyphs.xoffset + glyphs.xadvance, -st)); |
||
6824 | jghali | 552 | painter->setPen(tmpPen); |
5988 | jghali | 553 | } |
4360 | cbradney | 554 | if (gly.size() > 3) |
555 | { |
||
8728 | jghali | 556 | painter->save(); |
557 | painter->translate(glyphs.xoffset, glyphs.yoffset - ((style.fontSize() / 10.0) * glyphs.scaleV)); |
||
4360 | cbradney | 558 | if (item->reversed()) |
559 | { |
||
8728 | jghali | 560 | painter->scale(-1, 1); |
561 | painter->translate(-glyphs.xadvance, 0); |
||
4360 | cbradney | 562 | } |
5988 | jghali | 563 | if (style.baselineOffset() != 0) |
8728 | jghali | 564 | painter->translate(0, -(style.fontSize() / 10.0) * (style.baselineOffset() / 1000.0)); |
565 | double glxSc = glyphs.scaleH * style.fontSize() / 100.00; |
||
566 | double glySc = glyphs.scaleV * style.fontSize() / 100.0; |
||
567 | painter->scale(glxSc, glySc); |
||
6987 | jghali | 568 | painter->setFillMode(ScPainterExBase::Solid); |
4360 | cbradney | 569 | bool fr = painter->fillRule(); |
570 | painter->setFillRule(false); |
||
11869 | jghali | 571 | painter->setupPolygon(&gly, true); |
8728 | jghali | 572 | if (glyph == 0) |
5988 | jghali | 573 | { |
13974 | cbradney | 574 | ScColorShade tmp(PrefsManager::instance()->appPrefs.displayPrefs.controlCharColor, 100); |
8728 | jghali | 575 | painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
576 | painter->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() * 2 / 10000.0); |
||
577 | painter->strokePath(); |
||
578 | } |
||
579 | else if ((style.font().isStroked()) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0)) |
||
580 | { |
||
5988 | jghali | 581 | ScColorShade tmp = painter->brush(); |
582 | painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
||
583 | painter->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0); |
||
584 | painter->strokePath(); |
||
585 | } |
||
4360 | cbradney | 586 | else |
587 | { |
||
5988 | jghali | 588 | if ((style.effects() & ScStyle_Shadowed) && (style.strokeColor() != CommonStrings::None)) |
4360 | cbradney | 589 | { |
590 | painter->save(); |
||
8728 | jghali | 591 | painter->translate((style.fontSize() * glyphs.scaleH * style.shadowXOffset() / 10000.0) / glxSc, -(style.fontSize() * glyphs.scaleV * style.shadowYOffset() / 10000.0) / glySc); |
4360 | cbradney | 592 | ScColorShade tmp = painter->brush(); |
593 | painter->setBrush(painter->pen()); |
||
11869 | jghali | 594 | painter->setupPolygon(&gly, true); |
11905 | jghali | 595 | fillPath(item, painter, clip); |
4360 | cbradney | 596 | painter->setBrush(tmp); |
597 | painter->restore(); |
||
11869 | jghali | 598 | painter->setupPolygon(&gly, true); |
4360 | cbradney | 599 | } |
5988 | jghali | 600 | if (style.fillColor() != CommonStrings::None) |
11905 | jghali | 601 | fillPath(item, painter, clip); |
5988 | jghali | 602 | if ((style.effects() & ScStyle_Outline) && (style.strokeColor() != CommonStrings::None) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0)) |
4360 | cbradney | 603 | { |
8728 | jghali | 604 | painter->setLineWidth((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) / glySc); |
4360 | cbradney | 605 | painter->strokePath(); |
606 | } |
||
607 | } |
||
608 | painter->setFillRule(fr); |
||
8728 | jghali | 609 | painter->restore(); |
4360 | cbradney | 610 | } |
5988 | jghali | 611 | if (style.effects() & ScStyle_Strikethrough) |
4360 | cbradney | 612 | { |
613 | double st, lw; |
||
5988 | jghali | 614 | if ((style.strikethruOffset() != -1) || (style.strikethruWidth() != -1)) |
4360 | cbradney | 615 | { |
5988 | jghali | 616 | if (style.strikethruOffset() != -1) |
617 | st = (style.strikethruOffset() / 1000.0) * (style.font().ascent(style.fontSize() / 10.0)); |
||
4360 | cbradney | 618 | else |
5988 | jghali | 619 | st = style.font().strikeoutPos(style.fontSize() / 10.0); |
620 | if (style.strikethruWidth() != -1) |
||
621 | lw = (style.strikethruWidth() / 1000.0) * (style.fontSize() / 10.0); |
||
4360 | cbradney | 622 | else |
8578 | jghali | 623 | lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0); |
4360 | cbradney | 624 | } |
625 | else |
||
626 | { |
||
5988 | jghali | 627 | st = style.font().strikeoutPos(style.fontSize() / 10.0); |
8578 | jghali | 628 | lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0); |
4360 | cbradney | 629 | } |
5988 | jghali | 630 | if (style.baselineOffset() != 0) |
631 | st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0); |
||
4360 | cbradney | 632 | painter->setPen(painter->brush()); |
633 | painter->setLineWidth(lw); |
||
5988 | jghali | 634 | painter->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st)); |
4360 | cbradney | 635 | } |
636 | } |
||
6824 | jghali | 637 | /*else |
4360 | cbradney | 638 | { |
639 | painter->setLineWidth(1); |
||
5988 | jghali | 640 | painter->setPen(ScColorShade(Qt::red, 100)); |
641 | painter->setBrush(ScColorShade(Qt::red, 100)); |
||
4360 | cbradney | 642 | painter->setFillMode(1); |
5988 | jghali | 643 | painter->drawRect(glyphs.xoffset, glyphs.yoffset - (style.fontSize() / 10.0) * glyphs.scaleV , (style.fontSize() / 10.0) * glyphs.scaleH, (style.fontSize() / 10.0) * glyphs.scaleV); |
6824 | jghali | 644 | }*/ |
5988 | jghali | 645 | if (glyphs.more) |
6824 | jghali | 646 | { |
6987 | jghali | 647 | painter->translate(glyphs.xadvance, 0); |
11905 | jghali | 648 | drawGlyphs(item, painter, style, *glyphs.more, clip); |
6824 | jghali | 649 | } |
4360 | cbradney | 650 | } |
651 | |||
11905 | jghali | 652 | void ScPageOutput::drawItem_Embedded( PageItem* item, ScPainterExBase *p, const QRect& clip, const CharStyle& style, PageItem* cembedded) |
4360 | cbradney | 653 | { |
8728 | jghali | 654 | if (!cembedded) |
655 | return; |
||
9856 | fschmid | 656 | QList<PageItem*> emG; |
8728 | jghali | 657 | emG.append(cembedded); |
9856 | fschmid | 658 | for (int em = 0; em < emG.count(); ++em) |
8728 | jghali | 659 | { |
660 | PageItem* embedded = emG.at(em); |
||
12302 | jghali | 661 | p->save(); |
662 | double x = embedded->xPos(); |
||
663 | double y = embedded->yPos(); |
||
664 | embedded->setXPos( embedded->gXpos, true ); |
||
665 | embedded->setYPos((embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos, true ); |
||
666 | p->translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0))); |
||
667 | if (style.baselineOffset() != 0) |
||
668 | { |
||
669 | p->translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0)); |
||
670 | embedded->setYPos( embedded->yPos() - embedded->gHeight * (style.baselineOffset() / 1000.0) ); |
||
671 | } |
||
672 | p->scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0); |
||
8728 | jghali | 673 | double pws = embedded->m_lineWidth; |
11905 | jghali | 674 | drawItem_Pre(embedded, p); |
8728 | jghali | 675 | switch(embedded->itemType()) |
676 | { |
||
677 | case PageItem::ImageFrame: |
||
10321 | mrdocs | 678 | case PageItem::LatexFrame: |
8728 | jghali | 679 | case PageItem::TextFrame: |
680 | case PageItem::Polygon: |
||
681 | case PageItem::PathText: |
||
16105 | fschmid | 682 | case PageItem::Symbol: |
683 | case PageItem::Group: |
||
16191 | fschmid | 684 | case PageItem::RegularPolygon: |
16215 | fschmid | 685 | case PageItem::Arc: |
11905 | jghali | 686 | drawItem(embedded, p, clip); |
8728 | jghali | 687 | break; |
688 | case PageItem::Line: |
||
689 | case PageItem::PolyLine: |
||
690 | embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0); |
||
11905 | jghali | 691 | drawItem(embedded, p, clip); |
8728 | jghali | 692 | break; |
693 | default: |
||
694 | break; |
||
695 | } |
||
696 | embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0); |
||
11905 | jghali | 697 | drawItem_Post(embedded, p); |
12302 | jghali | 698 | embedded->setXPos(x, true); |
699 | embedded->setYPos(y, true); |
||
8728 | jghali | 700 | p->restore(); |
701 | embedded->m_lineWidth = pws; |
||
4360 | cbradney | 702 | } |
703 | } |
||
704 | |||
11905 | jghali | 705 | void ScPageOutput::drawPattern( PageItem* item, ScPainterExBase* painter, const QRect& clip) |
4360 | cbradney | 706 | { |
6987 | jghali | 707 | double x1, x2, y1, y2; |
708 | ScPattern& pattern = m_doc->docPatterns[item->pattern()]; |
||
14260 | fschmid | 709 | double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY; |
710 | item->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY); |
||
6987 | jghali | 711 | |
712 | // Compute pattern tansformation matrix and its inverse for converting pattern coordinates |
||
713 | // to pageitem coordinates |
||
13951 | fschmid | 714 | QTransform matrix, invMat; |
6987 | jghali | 715 | matrix.translate(patternOffsetX, patternOffsetY); |
716 | matrix.rotate(patternRotation); |
||
14260 | fschmid | 717 | matrix.shear(patternSkewX, patternSkewY); |
6987 | jghali | 718 | matrix.scale(pattern.scaleX, pattern.scaleY); |
719 | matrix.scale(patternScaleX / 100.0 , patternScaleY / 100.0); |
||
720 | invMat.scale((patternScaleX != 0) ? (100 /patternScaleX) : 1.0, (patternScaleY != 0) ? (100 /patternScaleY) : 1.0); |
||
721 | invMat.scale((pattern.scaleX != 0) ? (1 /pattern.scaleX) : 1.0, (pattern.scaleY != 0) ? (1 /pattern.scaleY) : 1.0); |
||
722 | invMat.rotate(-patternRotation); |
||
723 | invMat.translate(-patternOffsetX, -patternOffsetY); |
||
724 | |||
725 | // Compute bounding box in which pattern item will be drawn |
||
726 | double width = item->width(); |
||
727 | double height = item->height(); |
||
728 | double rot = patternRotation - floor(patternRotation / 90) * 90; |
||
729 | double ctheta = cos(rot * M_PI / 180); |
||
730 | double stheta = sin(rot * M_PI / 180); |
||
10227 | jghali | 731 | QRectF itemRect(0.0, 0.0, item->width(), item->height()); |
732 | QPointF pa( width * stheta * stheta, -width * stheta * ctheta ); |
||
733 | QPointF pb( width + height * ctheta * stheta, height * stheta * stheta ); |
||
734 | QPointF pc( -height * ctheta * stheta, height * ctheta * ctheta ); |
||
735 | QPointF pd( width * ctheta * ctheta, height + width * ctheta * stheta ); |
||
736 | QPointF ipa = invMat.map(pa), ipb = invMat.map(pb); |
||
737 | QPointF ipc = invMat.map(pc), ipd = invMat.map(pd); |
||
6987 | jghali | 738 | |
739 | painter->save(); |
||
740 | if (item->imageClip.size() != 0) |
||
741 | { |
||
742 | painter->setupPolygon(&item->imageClip); |
||
743 | painter->setClipPath(); |
||
744 | } |
||
745 | painter->setupPolygon(&item->PoLine); |
||
746 | painter->setClipPath(); |
||
9859 | jghali | 747 | for (int index = 0; index < pattern.items.count(); index++) |
6987 | jghali | 748 | { |
10227 | jghali | 749 | QRectF itRect; |
6987 | jghali | 750 | PageItem* it = pattern.items.at(index); |
751 | |||
752 | painter->save(); |
||
753 | painter->translate(patternOffsetX, patternOffsetY); |
||
754 | painter->rotate(patternRotation); |
||
755 | painter->scale(pattern.scaleX, pattern.scaleY); |
||
756 | painter->scale(patternScaleX / 100.0, patternScaleY / 100.0); |
||
757 | |||
758 | double patWidth = (pattern.width != 0.0) ? pattern.width : 1.0; |
||
759 | double patHeight = (pattern.height != 0.0) ? pattern.height : 1.0; |
||
760 | double kxa = (ipa.x() - it->gXpos) / patWidth; |
||
761 | double kxb = (ipb.x() - it->gXpos) / patWidth; |
||
762 | double kxc = (ipc.x() - it->gXpos) / patWidth; |
||
763 | double kxd = (ipd.x() - it->gXpos) / patWidth; |
||
764 | double kya = (ipa.y() - it->gYpos) / patHeight; |
||
765 | double kyb = (ipb.y() - it->gYpos) / patHeight; |
||
766 | double kyc = (ipc.y() - it->gYpos) / patHeight; |
||
767 | double kyd = (ipd.y() - it->gYpos) / patHeight; |
||
10227 | jghali | 768 | int kxMin = (int) floor( qMin(qMin(kxa, kxb), qMin(kxc, kxd)) ); |
769 | int kxMax = (int) ceil ( qMax(qMax(kxa, kxb), qMax(kxc, kxd)) ); |
||
770 | int kyMin = (int) floor( qMin(qMin(kya, kyb), qMin(kyc, kyd)) ); |
||
771 | int kyMax = (int) ceil ( qMax(qMax(kya, kyb), qMax(kyc, kyd)) ); |
||
6987 | jghali | 772 | |
773 | double itx = it->xPos(); |
||
774 | double ity = it->yPos(); |
||
775 | double itPosX = it->gXpos, itPosY = it->gYpos; |
||
776 | for ( int kx = kxMin; kx <= kxMax; kx++ ) |
||
777 | { |
||
778 | for ( int ky = kyMin; ky <= kyMax; ky++ ) |
||
779 | { |
||
780 | itPosX = it->gXpos + kx * pattern.width; |
||
781 | itPosY = it->gYpos + ky * pattern.height; |
||
782 | it->setXYPos(itPosX, itPosY); |
||
783 | it->getBoundingRect(&x1, &y1, &x2, &y2); |
||
784 | itRect.setCoords(x1, y1, x2, y2); |
||
785 | itRect = matrix.mapRect( itRect ); |
||
786 | if ( itRect.intersects(itemRect) ) |
||
11905 | jghali | 787 | drawItem(it, painter, clip); |
6987 | jghali | 788 | } |
789 | } |
||
790 | it->setXYPos(itx, ity); |
||
791 | painter->restore(); |
||
792 | } |
||
793 | painter->restore(); |
||
794 | } |
||
795 | |||
17263 | jghali | 796 | void ScPageOutput::drawStrokePattern(PageItem* item, ScPainterExBase* painter, const QPainterPath& path) |
797 | { |
||
798 | |||
799 | } |
||
800 | |||
17296 | jghali | 801 | void ScPageOutput::drawItem_Arc ( PageItem_Arc* item , ScPainterExBase* painter, const QRect& clip ) |
802 | { |
||
803 | painter->setupPolygon(&item->PoLine); |
||
804 | fillPath(item, painter, clip); |
||
805 | } |
||
806 | |||
17288 | jghali | 807 | void ScPageOutput::drawItem_Group( PageItem_Group* item, ScPainterExBase* painter, const QRect& clip ) |
808 | { |
||
809 | if (item->groupItemList.isEmpty()) |
||
810 | return; |
||
811 | |||
812 | painter->save(); |
||
813 | if (item->imageFlippedH()) |
||
814 | { |
||
815 | painter->translate(item->width(), 0); |
||
816 | painter->scale(-1, 1); |
||
817 | } |
||
818 | if (item->imageFlippedV()) |
||
819 | { |
||
820 | painter->translate(0, item->height()); |
||
821 | painter->scale(1, -1); |
||
822 | } |
||
823 | /*if ((maskType() == 1) || (maskType() == 2) || (maskType() == 4) || (maskType() == 5)) |
||
824 | { |
||
825 | if ((maskType() == 1) || (maskType() == 2)) |
||
826 | painter->setMaskMode(1); |
||
827 | else |
||
828 | painter->setMaskMode(3); |
||
829 | if ((!gradientMask().isEmpty()) && (!m_Doc->docGradients.contains(gradientMask()))) |
||
830 | gradientMaskVal = ""; |
||
831 | if (!(gradientMask().isEmpty()) && (m_Doc->docGradients.contains(gradientMask()))) |
||
832 | mask_gradient = m_Doc->docGradients[gradientMask()]; |
||
833 | painter->mask_gradient = mask_gradient; |
||
834 | if ((maskType() == 1) || (maskType() == 4)) |
||
835 | painter->setGradientMask(VGradient::linear, FPoint(GrMaskStartX, GrMaskStartY), FPoint(GrMaskEndX, GrMaskEndY), FPoint(GrMaskStartX, GrMaskStartY), GrMaskScale, GrMaskSkew); |
||
836 | else |
||
837 | painter->setGradientMask(VGradient::radial, FPoint(GrMaskStartX, GrMaskStartY), FPoint(GrMaskEndX, GrMaskEndY), FPoint(GrMaskFocalX, GrMaskFocalY), GrMaskScale, GrMaskSkew); |
||
838 | } |
||
839 | else if ((maskType() == 3) || (maskType() == 6) || (maskType() == 7) || (maskType() == 8)) |
||
840 | { |
||
841 | if ((patternMask().isEmpty()) || (!m_Doc->docPatterns.contains(patternMask()))) |
||
842 | painter->setMaskMode(0); |
||
843 | else |
||
844 | { |
||
845 | double scw = Width / groupWidth; |
||
846 | double sch = Height / groupHeight; |
||
847 | painter->setPatternMask(&m_Doc->docPatterns[patternMask()], patternMaskScaleX * scw, patternMaskScaleY * sch, patternMaskOffsetX, patternMaskOffsetY, patternMaskRotation, patternMaskSkewX, patternMaskSkewY, patternMaskMirrorX, patternMaskMirrorY); |
||
848 | if (maskType() == 3) |
||
849 | painter->setMaskMode(2); |
||
850 | else if (maskType() == 6) |
||
851 | painter->setMaskMode(4); |
||
852 | else if (maskType() == 7) |
||
853 | painter->setMaskMode(5); |
||
854 | else |
||
855 | painter->setMaskMode(6); |
||
856 | } |
||
857 | } |
||
858 | else*/ |
||
859 | painter->setMaskMode(0); |
||
860 | painter->setFillRule(item->fillRule); |
||
861 | //painter->beginLayer(1.0 - fillTransparency(), fillBlendmode(), &PoLine); |
||
862 | painter->setMaskMode(0); |
||
863 | painter->scale(item->width() / item->groupWidth, item->height() / item->groupHeight); |
||
864 | for (int em = 0; em < item->groupItemList.count(); ++em) |
||
865 | { |
||
866 | PageItem* embedded = item->groupItemList.at(em); |
||
867 | painter->save(); |
||
868 | painter->translate(embedded->gXpos, embedded->gYpos); |
||
869 | embedded->isEmbedded = true; |
||
870 | embedded->invalidateLayout(); |
||
871 | drawItem(embedded, painter, QRect()); |
||
872 | embedded->isEmbedded = false; |
||
873 | painter->restore(); |
||
874 | } |
||
875 | //painter->endLayer(); |
||
876 | painter->restore(); |
||
877 | } |
||
878 | |||
11905 | jghali | 879 | void ScPageOutput::drawItem_ImageFrame( PageItem_ImageFrame* item, ScPainterExBase* painter, const QRect& clip ) |
6987 | jghali | 880 | { |
4989 | cbradney | 881 | ScPainterExBase::ImageMode mode = ScPainterExBase::rgbImages; |
4546 | subik | 882 | if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0)) |
4360 | cbradney | 883 | { |
884 | painter->setupPolygon(&item->PoLine); |
||
11905 | jghali | 885 | fillPath(item, painter, clip); |
4360 | cbradney | 886 | } |
887 | if (item->Pfile.isEmpty()) |
||
888 | { |
||
9849 | jghali | 889 | /*painter->setPen( ScColorShade(Qt::black, 100), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
6987 | jghali | 890 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), item->height())); |
9849 | jghali | 891 | painter->drawLine(FPoint(0, item->height()), FPoint(item->width(), 0));*/ |
4360 | cbradney | 892 | } |
893 | else |
||
894 | { |
||
13097 | subik | 895 | if ((!item->imageShown()) || (!item->PictureIsAvailable)) |
4360 | cbradney | 896 | { |
9849 | jghali | 897 | /*painter->setPen( ScColorShade(Qt::red, 100), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
6987 | jghali | 898 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), item->height())); |
9849 | jghali | 899 | painter->drawLine(FPoint(0, item->height()), FPoint(item->width(), 0));*/ |
4360 | cbradney | 900 | } |
901 | else |
||
902 | { |
||
903 | ScImage scImg; |
||
904 | ScImage* pImage = NULL; |
||
905 | double imScaleX = item->imageXScale(); |
||
906 | double imScaleY = item->imageYScale(); |
||
907 | if( m_reloadImages ) |
||
908 | { |
||
909 | bool dummy; |
||
4617 | avox | 910 | bool useCmyk = false; |
4751 | cbradney | 911 | ScPainterExBase::ImageMode imageMode = painter->imageMode(); |
912 | if ( imageMode == ScPainterExBase::cmykImages ) |
||
4617 | avox | 913 | useCmyk = true; |
4360 | cbradney | 914 | QFileInfo fInfo(item->Pfile); |
10508 | cbradney | 915 | QString ext = fInfo.suffix(); |
5959 | jghali | 916 | CMSettings cmsSettings(item->doc(), item->IProfile, item->IRender); |
14467 | jghali | 917 | cmsSettings.allowColorManagement(m_useProfiles); |
918 | cmsSettings.setUseEmbeddedProfile(item->UseEmbedded); |
||
4360 | cbradney | 919 | scImg.imgInfo.valid = false; |
920 | scImg.imgInfo.clipPath = ""; |
||
921 | scImg.imgInfo.PDSpathData.clear(); |
||
922 | scImg.imgInfo.layerInfo.clear(); |
||
923 | scImg.imgInfo.RequestProps = item->pixm.imgInfo.RequestProps; |
||
924 | scImg.imgInfo.isRequest = item->pixm.imgInfo.isRequest; |
||
14467 | jghali | 925 | scImg.loadPicture(item->Pfile, item->pixm.imgInfo.actualPageNumber, cmsSettings, translateImageModeToRequest(imageMode), m_imageRes, &dummy); |
10136 | cbradney | 926 | if( extensionIndicatesEPSorPS(ext) || extensionIndicatesPDF(ext) ) |
4360 | cbradney | 927 | { |
928 | imScaleX *= (72.0 / (double) m_imageRes); |
||
929 | imScaleY *= (72.0 / (double) m_imageRes); |
||
930 | } |
||
4617 | avox | 931 | scImg.applyEffect(item->effectsInUse, m_doc->PageColors, useCmyk); |
4989 | cbradney | 932 | mode = imageMode; |
4360 | cbradney | 933 | pImage = &scImg; |
934 | } |
||
935 | else |
||
936 | pImage = &item->pixm; |
||
937 | |||
938 | painter->save(); |
||
939 | if (item->imageClip.size() != 0) |
||
4751 | cbradney | 940 | { |
4360 | cbradney | 941 | painter->setupPolygon(&item->imageClip); |
4751 | cbradney | 942 | painter->setClipPath(); |
943 | } |
||
944 | painter->setupPolygon(&item->PoLine); |
||
4360 | cbradney | 945 | painter->setClipPath(); |
946 | if (item->imageFlippedH()) |
||
947 | { |
||
6987 | jghali | 948 | painter->translate(item->width(), 0); |
4360 | cbradney | 949 | painter->scale(-1, 1); |
950 | } |
||
951 | if (item->imageFlippedV()) |
||
952 | { |
||
6987 | jghali | 953 | painter->translate(0, item->height()); |
4360 | cbradney | 954 | painter->scale(1, -1); |
955 | } |
||
6987 | jghali | 956 | painter->translate(item->imageXOffset() * item->imageXScale(), item->imageYOffset() * item->imageYScale()); |
4360 | cbradney | 957 | //painter->translate(item->LocalX * imScaleX * scale, item->LocalY * imScaleY * scale); ?? |
958 | painter->scale( imScaleX, imScaleY ); |
||
959 | if (pImage->imgInfo.lowResType != 0) |
||
960 | painter->scale(pImage->imgInfo.lowResScale, pImage->imgInfo.lowResScale); |
||
4989 | cbradney | 961 | painter->drawImage(pImage, mode); |
4360 | cbradney | 962 | painter->restore(); |
963 | } |
||
964 | } |
||
965 | } |
||
966 | |||
11905 | jghali | 967 | void ScPageOutput::drawItem_Line( PageItem_Line* item, ScPainterExBase* painter, const QRect& clip ) |
4360 | cbradney | 968 | { |
17313 | jghali | 969 | if (item->PoLine.size() < 4) |
970 | return; |
||
971 | |||
13310 | jghali | 972 | int startArrowIndex = item->startArrowIndex(); |
973 | int endArrowIndex = item->endArrowIndex(); |
||
4546 | subik | 974 | |
4360 | cbradney | 975 | if (item->NamedLStyle.isEmpty()) |
17313 | jghali | 976 | { |
977 | QString patternStrokeVal = item->strokePattern(); |
||
978 | if ((!patternStrokeVal.isEmpty()) && (m_doc->docPatterns.contains(patternStrokeVal))) |
||
979 | { |
||
980 | if (item->patternStrokePath) |
||
981 | { |
||
982 | QPainterPath guidePath = item->PoLine.toQPainterPath(false); |
||
983 | guidePath.moveTo(0, 0); |
||
984 | guidePath.lineTo(item->width(), 0); |
||
985 | drawStrokePattern(item, painter, guidePath); |
||
986 | } |
||
987 | else |
||
988 | { |
||
989 | painter->setPattern(&m_doc->docPatterns[patternStrokeVal], item->patternStrokeScaleX, item->patternStrokeScaleY, item->patternStrokeOffsetX, item->patternStrokeOffsetY, item->patternStrokeRotation, item->patternStrokeSkewX, item->patternStrokeSkewY, item->patternStrokeMirrorX, item->patternStrokeMirrorY); |
||
990 | painter->setStrokeMode(ScPainterExBase::Pattern); |
||
991 | painter->strokePath(); |
||
992 | } |
||
993 | } |
||
994 | else if (item->strokeGradientType() > 0) |
||
995 | { |
||
996 | QString gradientStrokeVal = item->strokeGradient(); |
||
997 | if ((!gradientStrokeVal.isEmpty()) && (!m_doc->docGradients.contains(gradientStrokeVal))) |
||
998 | gradientStrokeVal = ""; |
||
999 | if (!(gradientStrokeVal.isEmpty()) && (m_doc->docGradients.contains(gradientStrokeVal))) |
||
1000 | painter->m_strokeGradient = VGradientEx(m_doc->docGradients[gradientStrokeVal], *m_doc); |
||
1001 | if (painter->m_strokeGradient.Stops() < 2) // fall back to solid stroking if there are not enough colorstops in the gradient. |
||
1002 | { |
||
1003 | if (item->lineColor() != CommonStrings::None) |
||
1004 | { |
||
1005 | ScColorShade strokeColor(m_doc->PageColors[item->lineColor()], item->lineShade()); |
||
1006 | painter->setBrush(strokeColor); |
||
1007 | painter->setStrokeMode(ScPainterExBase::Solid); |
||
1008 | } |
||
1009 | else |
||
1010 | painter->setStrokeMode(ScPainterExBase::None); |
||
1011 | } |
||
1012 | else |
||
1013 | { |
||
1014 | FPoint fpStart(item->GrStrokeStartX, item->GrStrokeStartY); |
||
1015 | FPoint fpEnd(item->GrStrokeEndX, item->GrStrokeEndY); |
||
1016 | FPoint fpFocal(item->GrStrokeFocalX, item->GrStrokeFocalY); |
||
1017 | painter->setStrokeMode(ScPainterExBase::Gradient); |
||
1018 | painter->m_strokeGradient = VGradientEx(item->stroke_gradient, *m_doc); |
||
1019 | if (item->GrTypeStroke == 6) |
||
1020 | painter->setGradient(VGradientEx::linear, fpStart, fpEnd, fpStart, item->GrStrokeScale, item->GrStrokeSkew); |
||
1021 | else |
||
1022 | painter->setGradient(VGradientEx::radial, fpStart, fpEnd, fpFocal, item->GrStrokeScale, item->GrStrokeSkew); |
||
1023 | } |
||
1024 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), 0)); |
||
1025 | } |
||
1026 | else if (item->lineColor() != CommonStrings::None) |
||
1027 | { |
||
1028 | ScColorShade scColor(m_doc->PageColors[item->lineColor()], item->lineShade()); |
||
1029 | painter->setStrokeMode(ScPainterExBase::Solid); |
||
1030 | painter->setPen(scColor, item->lineWidth(), item->PLineArt, item->PLineEnd, item->PLineJoin); |
||
1031 | if (item->DashValues.count() != 0) |
||
1032 | painter->setDash(item->DashValues, item->DashOffset); |
||
1033 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), 0)); |
||
1034 | } |
||
1035 | } |
||
4360 | cbradney | 1036 | else |
1037 | { |
||
17313 | jghali | 1038 | painter->setStrokeMode(ScPainterExBase::Solid); |
4360 | cbradney | 1039 | multiLine ml = m_doc->MLineStyles[item->NamedLStyle]; |
1040 | for (int it = ml.size()-1; it > -1; it--) |
||
1041 | { |
||
7143 | jghali | 1042 | const SingleLine& sl = ml[it]; |
17313 | jghali | 1043 | if ((sl.Color != CommonStrings::None) && (sl.Width != 0)) |
7143 | jghali | 1044 | { |
1045 | ScColorShade tmp(m_doc->PageColors[sl.Color], sl.Shade); |
||
1046 | painter->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash), |
||
1047 | static_cast<Qt::PenCapStyle>(sl.LineEnd), |
||
1048 | static_cast<Qt::PenJoinStyle>(sl.LineJoin)); |
||
1049 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), 0)); |
||
1050 | } |
||
4360 | cbradney | 1051 | } |
1052 | } |
||
1053 | if (startArrowIndex != 0) |
||
1054 | { |
||
13951 | fschmid | 1055 | QTransform arrowTrans; |
13303 | jghali | 1056 | arrowTrans.translate(0, 0); |
1057 | arrowTrans.scale(-1,1); |
||
13310 | jghali | 1058 | drawArrow(painter, item, arrowTrans, startArrowIndex); |
4360 | cbradney | 1059 | } |
1060 | if (endArrowIndex != 0) |
||
1061 | { |
||
13951 | fschmid | 1062 | QTransform arrowTrans; |
13303 | jghali | 1063 | arrowTrans.translate(item->width(), 0); |
13310 | jghali | 1064 | drawArrow(painter, item, arrowTrans, endArrowIndex); |
4360 | cbradney | 1065 | } |
1066 | } |
||
1067 | |||
11905 | jghali | 1068 | void ScPageOutput::drawItem_PathText( PageItem_PathText* item, ScPainterExBase* painter, const QRect& clip ) |
4360 | cbradney | 1069 | { |
5721 | avox | 1070 | QString chstr, chstr2, chstr3; |
4689 | mrdocs | 1071 | ScText *hl; |
4360 | cbradney | 1072 | FPoint point = FPoint(0, 0); |
1073 | FPoint tangent = FPoint(0, 0); |
||
1074 | double CurX = item->textToFrameDistLeft(); // item->CurX = item->textToFrameDistLeft() |
||
10992 | jghali | 1075 | QString actFill, actStroke; |
17033 | jghali | 1076 | double actFillShade, actStrokeShade, dx; |
10992 | jghali | 1077 | StoryText& itemText = item->itemText; |
12217 | jghali | 1078 | if (item->pathTextShowFrame()) |
4360 | cbradney | 1079 | { |
12996 | jghali | 1080 | painter->setupPolygon(&item->PoLine, false); |
1081 | if (item->NamedLStyle.isEmpty()) |
||
7143 | jghali | 1082 | { |
12996 | jghali | 1083 | if (item->lineColor() != CommonStrings::None) |
1084 | painter->strokePath(); |
||
12217 | jghali | 1085 | } |
1086 | else |
||
1087 | { |
||
1088 | multiLine ml = m_doc->MLineStyles[item->NamedLStyle]; |
||
1089 | for (int it = ml.size() - 1; it > -1; it--) |
||
7143 | jghali | 1090 | { |
12217 | jghali | 1091 | const SingleLine& sl = ml[it]; |
1092 | if ((sl.Color != CommonStrings::None) && (sl.Width != 0)) |
||
1093 | { |
||
1094 | ScColorShade tmp(m_doc->PageColors[sl.Color], sl.Shade); |
||
1095 | painter->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash), |
||
1096 | static_cast<Qt::PenCapStyle>(sl.LineEnd), |
||
1097 | static_cast<Qt::PenJoinStyle>(sl.LineJoin)); |
||
1098 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), 0)); |
||
1099 | } |
||
7143 | jghali | 1100 | } |
1101 | } |
||
1102 | } |
||
10992 | jghali | 1103 | double totalTextLen = 0.0; |
1104 | double totalCurveLen = 0.0; |
||
1105 | double extraOffset = 0.0; |
||
1106 | if (itemText.length() != 0) |
||
1107 | { |
||
1108 | CurX += itemText.item(0)->fontSize() * itemText.charStyle(0).tracking() / 10000.0; |
||
1109 | totalTextLen += itemText.charStyle(0).fontSize() * itemText.charStyle(0).tracking() / 10000.0; |
||
1110 | } |
||
1111 | for (int a = 0; a < itemText.length(); ++a) |
||
4360 | cbradney | 1112 | { |
10992 | jghali | 1113 | hl = itemText.item(a); |
5721 | avox | 1114 | chstr = hl->ch; |
11713 | fschmid | 1115 | if (chstr[0] == SpecialChars::PAGENUMBER || chstr[0] == SpecialChars::PARSEP || chstr[0] == SpecialChars::PAGECOUNT |
8089 | jghali | 1116 | || chstr[0] == SpecialChars::TAB || chstr == SpecialChars::LINEBREAK) |
4360 | cbradney | 1117 | continue; |
10992 | jghali | 1118 | if (a < itemText.length()-1) |
1119 | chstr += itemText.text(a+1, 1); |
||
8089 | jghali | 1120 | hl->glyph.yadvance = 0; |
10992 | jghali | 1121 | item->layoutGlyphs(itemText.charStyle(a), chstr, hl->glyph); |
8089 | jghali | 1122 | hl->glyph.shrink(); |
17407 | fschmid | 1123 | if (hl->hasObject(m_doc)) |
1124 | totalTextLen += (hl->getItem(m_doc)->width() + hl->getItem(m_doc)->lineWidth()) * hl->glyph.scaleH; |
||
10992 | jghali | 1125 | else |
1126 | totalTextLen += hl->glyph.wide()+hl->fontSize() * hl->tracking() / 10000.0; |
||
1127 | } |
||
1128 | for (uint segs = 0; segs < item->PoLine.size()-3; segs += 4) |
||
1129 | { |
||
1130 | totalCurveLen += item->PoLine.lenPathSeg(segs); |
||
1131 | } |
||
1132 | if ((itemText.defaultStyle().alignment() != 0) && (totalCurveLen >= totalTextLen + item->textToFrameDistLeft())) |
||
1133 | { |
||
1134 | if (itemText.defaultStyle().alignment() == 2) |
||
4360 | cbradney | 1135 | { |
10992 | jghali | 1136 | CurX = totalCurveLen - totalTextLen; |
1137 | CurX -= item->textToFrameDistLeft(); |
||
4360 | cbradney | 1138 | } |
10992 | jghali | 1139 | if (itemText.defaultStyle().alignment() == 1) |
1140 | CurX = (totalCurveLen - totalTextLen) / 2.0; |
||
1141 | if ((itemText.defaultStyle().alignment() == 3) || (itemText.defaultStyle().alignment() == 4)) |
||
1142 | extraOffset = (totalCurveLen - item->textToFrameDistLeft() - totalTextLen) / static_cast<double>(itemText.length()); |
||
1143 | } |
||
1144 | |||
1145 | QPainterPath guidePath = item->PoLine.toQPainterPath(false); |
||
1146 | QList<QPainterPath> pathList = decomposePath(guidePath); |
||
1147 | QPainterPath currPath = pathList[0]; |
||
1148 | int currPathIndex = 0; |
||
1149 | for (int a = item->firstInFrame(); a < itemText.length(); ++a) |
||
1150 | { |
||
1151 | hl = itemText.item(a); |
||
1152 | chstr = hl->ch; |
||
11750 | jghali | 1153 | if (chstr[0] == SpecialChars::PAGENUMBER || chstr[0] == SpecialChars::PARSEP || chstr[0] == SpecialChars::PAGECOUNT |
10992 | jghali | 1154 | || chstr[0] == SpecialChars::TAB || chstr[0] == SpecialChars::LINEBREAK) |
1155 | continue; |
||
1156 | if (a < itemText.length()-1) |
||
1157 | chstr += itemText.text(a+1, 1); |
||
1158 | hl->glyph.yadvance = 0; |
||
1159 | item->layoutGlyphs(itemText.charStyle(a), chstr, hl->glyph); |
||
1160 | hl->glyph.shrink(); // HACK |
||
14443 | jghali | 1161 | // Unneeded now that glyph xadvance is set appropriately for inline objects by PageItem_TextFrame::layout() - JG |
16602 | jghali | 1162 | /*if (hl->hasObject()) |
13251 | jghali | 1163 | dx = (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()) * hl->glyph.scaleH / 2.0; |
14443 | jghali | 1164 | else*/ |
1165 | dx = hl->glyph.wide() / 2.0; |
||
10992 | jghali | 1166 | |
1167 | CurX += dx; |
||
1168 | |||
1169 | double currPerc = currPath.percentAtLength(CurX); |
||
1170 | if (currPerc >= 0.9999999) |
||
4360 | cbradney | 1171 | { |
10992 | jghali | 1172 | currPathIndex++; |
1173 | if (currPathIndex == pathList.count()) |
||
4360 | cbradney | 1174 | break; |
10992 | jghali | 1175 | currPath = pathList[currPathIndex]; |
1176 | CurX = dx; |
||
1177 | currPerc = currPath.percentAtLength(CurX); |
||
4360 | cbradney | 1178 | } |
10992 | jghali | 1179 | double currAngle = currPath.angleAtPercent(currPerc); |
13251 | jghali | 1180 | if (currAngle <= 180.0) |
1181 | currAngle *= -1.0; |
||
1182 | else |
||
1183 | currAngle = 360.0 - currAngle; |
||
10992 | jghali | 1184 | QPointF currPoint = currPath.pointAtPercent(currPerc); |
1185 | tangent = FPoint(cos(currAngle * M_PI / 180.0), sin(currAngle * M_PI / 180.0)); |
||
1186 | point = FPoint(currPoint.x(), currPoint.y()); |
||
1187 | |||
1188 | hl->glyph.xoffset = 0; |
||
11750 | jghali | 1189 | hl->PtransX = point.x(); |
1190 | hl->PtransY = point.y(); |
||
1191 | hl->PRot = currAngle * M_PI / 180.0; |
||
1192 | hl->PDx = dx; |
||
13951 | fschmid | 1193 | QTransform trafo = QTransform( 1, 0, 0, -1, -dx, 0 ); |
8089 | jghali | 1194 | if (item->textPathFlipped) |
13951 | fschmid | 1195 | trafo *= QTransform(1, 0, 0, -1, 0, 0); |
8089 | jghali | 1196 | if (item->textPathType == 0) |
13951 | fschmid | 1197 | trafo *= QTransform( tangent.x(), tangent.y(), tangent.y(), -tangent.x(), point.x(), point.y() ); // ID's Rainbow mode |
8089 | jghali | 1198 | else if (item->textPathType == 1) |
13951 | fschmid | 1199 | trafo *= QTransform( 1, 0, 0, -1, point.x(), point.y() ); // ID's Stair Step mode |
8089 | jghali | 1200 | else if (item->textPathType == 2) |
1201 | { |
||
1202 | double a = 1; |
||
1203 | if (tangent.x() < 0) |
||
1204 | a = -1; |
||
1205 | if (fabs(tangent.x()) > 0.1) |
||
13951 | fschmid | 1206 | trafo *= QTransform( a, (tangent.y() / tangent.x()) * a, 0, -1, point.x(), point.y() ); // ID's Skew mode |
8089 | jghali | 1207 | else |
13951 | fschmid | 1208 | trafo *= QTransform( a, 4 * a, 0, -1, point.x(), point.y() ); |
8089 | jghali | 1209 | } |
13951 | fschmid | 1210 | QTransform sca = painter->worldMatrix(); |
4360 | cbradney | 1211 | trafo *= sca; |
1212 | painter->save(); |
||
13951 | fschmid | 1213 | QTransform savWM = painter->worldMatrix(); |
4360 | cbradney | 1214 | painter->setWorldMatrix(trafo); |
10992 | jghali | 1215 | |
1216 | actFill = itemText.charStyle(a).fillColor(); |
||
1217 | actFillShade = itemText.charStyle(a).fillShade(); |
||
1218 | if (actFill != CommonStrings::None) |
||
1219 | { |
||
11229 | fschmid | 1220 | ScColorShade tmp(m_doc->PageColors[actFill], qRound(actFillShade)); |
10992 | jghali | 1221 | painter->setBrush(tmp); |
1222 | } |
||
1223 | actStroke = itemText.charStyle(a).strokeColor(); |
||
1224 | actStrokeShade = itemText.charStyle(a).strokeShade(); |
||
1225 | if (actStroke != CommonStrings::None) |
||
1226 | { |
||
11229 | fschmid | 1227 | ScColorShade tmp(m_doc->PageColors[actStroke], qRound(actStrokeShade)); |
10992 | jghali | 1228 | painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
1229 | } |
||
13251 | jghali | 1230 | painter->translate(0.0, item->pathTextBaseOffset()); |
10992 | jghali | 1231 | if (hl->ch == SpecialChars::OBJECT) |
17407 | fschmid | 1232 | drawItem_Embedded(hl->getItem(m_doc), painter, clip, itemText.charStyle(a), hl->getItem(m_doc)); |
10992 | jghali | 1233 | else |
11905 | jghali | 1234 | drawGlyphs(item, painter, itemText.charStyle(a), hl->glyph, clip); |
10992 | jghali | 1235 | |
4360 | cbradney | 1236 | painter->setWorldMatrix(savWM); |
1237 | painter->restore(); |
||
1238 | CurX -= dx; |
||
17407 | fschmid | 1239 | if (hl->hasObject(m_doc)) |
1240 | CurX += (hl->getItem(m_doc)->width() + hl->getItem(m_doc)->lineWidth()) * hl->glyph.scaleH; |
||
10992 | jghali | 1241 | else |
1242 | CurX += hl->glyph.wide()+hl->fontSize() * hl->tracking() / 10000.0 + extraOffset; |
||
4360 | cbradney | 1243 | } |
1244 | } |
||
1245 | |||
11905 | jghali | 1246 | void ScPageOutput::drawItem_Polygon ( PageItem_Polygon* item , ScPainterExBase* painter, const QRect& clip ) |
4360 | cbradney | 1247 | { |
1248 | painter->setupPolygon(&item->PoLine); |
||
11905 | jghali | 1249 | fillPath(item, painter, clip); |
4360 | cbradney | 1250 | } |
1251 | |||
11905 | jghali | 1252 | void ScPageOutput::drawItem_PolyLine( PageItem_PolyLine* item, ScPainterExBase* painter, const QRect& clip ) |
4360 | cbradney | 1253 | { |
17313 | jghali | 1254 | if (item->PoLine.size() < 4) |
1255 | return; |
||
1256 | |||
13310 | jghali | 1257 | int startArrowIndex = item->startArrowIndex(); |
1258 | int endArrowIndex = item->endArrowIndex(); |
||
4546 | subik | 1259 | |
17313 | jghali | 1260 | if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0)) |
4360 | cbradney | 1261 | { |
17313 | jghali | 1262 | FPointArray cli; |
1263 | FPoint Start; |
||
1264 | bool firstp = true; |
||
1265 | for (uint n = 0; n < item->PoLine.size()-3; n += 4) |
||
4360 | cbradney | 1266 | { |
17313 | jghali | 1267 | if (firstp) |
4360 | cbradney | 1268 | { |
17313 | jghali | 1269 | Start = item->PoLine.point(n); |
1270 | firstp = false; |
||
4360 | cbradney | 1271 | } |
17313 | jghali | 1272 | if (item->PoLine.point(n).x() > 900000) |
4360 | cbradney | 1273 | { |
17313 | jghali | 1274 | cli.addPoint(item->PoLine.point(n-2)); |
1275 | cli.addPoint(item->PoLine.point(n-2)); |
||
4360 | cbradney | 1276 | cli.addPoint(Start); |
1277 | cli.addPoint(Start); |
||
17313 | jghali | 1278 | cli.setMarker(); |
1279 | firstp = true; |
||
1280 | continue; |
||
4360 | cbradney | 1281 | } |
17313 | jghali | 1282 | cli.addPoint(item->PoLine.point(n)); |
1283 | cli.addPoint(item->PoLine.point(n+1)); |
||
1284 | cli.addPoint(item->PoLine.point(n+2)); |
||
1285 | cli.addPoint(item->PoLine.point(n+3)); |
||
4360 | cbradney | 1286 | } |
17313 | jghali | 1287 | if (cli.size() > 2) |
13303 | jghali | 1288 | { |
17313 | jghali | 1289 | FPoint l1 = cli.point(cli.size()-2); |
1290 | cli.addPoint(l1); |
||
1291 | cli.addPoint(l1); |
||
1292 | cli.addPoint(Start); |
||
1293 | cli.addPoint(Start); |
||
1294 | } |
||
1295 | painter->setupPolygon(&cli); |
||
1296 | fillPath(item, painter, clip); |
||
1297 | } |
||
1298 | painter->setupPolygon(&item->PoLine, false); |
||
1299 | if (item->NamedLStyle.isEmpty()) |
||
1300 | { |
||
1301 | QString patternStrokeVal = item->strokePattern(); |
||
1302 | if ((!patternStrokeVal.isEmpty()) && (m_doc->docPatterns.contains(patternStrokeVal))) |
||
1303 | { |
||
1304 | if (item->patternStrokePath) |
||
1305 | { |
||
1306 | QPainterPath guidePath = item->PoLine.toQPainterPath(false); |
||
1307 | guidePath.moveTo(0, 0); |
||
1308 | guidePath.lineTo(item->width(), 0); |
||
1309 | drawStrokePattern(item, painter, guidePath); |
||
1310 | } |
||
1311 | else |
||
1312 | { |
||
1313 | painter->setPattern(&m_doc->docPatterns[patternStrokeVal], item->patternStrokeScaleX, item->patternStrokeScaleY, item->patternStrokeOffsetX, item->patternStrokeOffsetY, item->patternStrokeRotation, item->patternStrokeSkewX, item->patternStrokeSkewY, item->patternStrokeMirrorX, item->patternStrokeMirrorY); |
||
1314 | painter->setStrokeMode(ScPainterExBase::Pattern); |
||
13303 | jghali | 1315 | painter->strokePath(); |
17313 | jghali | 1316 | } |
13303 | jghali | 1317 | } |
17313 | jghali | 1318 | else if (item->strokeGradientType() > 0) |
4360 | cbradney | 1319 | { |
17313 | jghali | 1320 | QString gradientStrokeVal = item->strokeGradient(); |
1321 | if ((!gradientStrokeVal.isEmpty()) && (!m_doc->docGradients.contains(gradientStrokeVal))) |
||
1322 | gradientStrokeVal = ""; |
||
1323 | if (!(gradientStrokeVal.isEmpty()) && (m_doc->docGradients.contains(gradientStrokeVal))) |
||
1324 | painter->m_strokeGradient = VGradientEx(m_doc->docGradients[gradientStrokeVal], *m_doc); |
||
1325 | if (painter->m_strokeGradient.Stops() < 2) // fall back to solid stroking if there are not enough colorstops in the gradient. |
||
4360 | cbradney | 1326 | { |
17313 | jghali | 1327 | if (item->lineColor() != CommonStrings::None) |
7143 | jghali | 1328 | { |
17313 | jghali | 1329 | ScColorShade strokeColor(m_doc->PageColors[item->lineColor()], item->lineShade()); |
1330 | painter->setBrush(strokeColor); |
||
1331 | painter->setStrokeMode(ScPainterExBase::Solid); |
||
7143 | jghali | 1332 | } |
17313 | jghali | 1333 | else |
1334 | painter->setStrokeMode(ScPainterExBase::None); |
||
4360 | cbradney | 1335 | } |
17313 | jghali | 1336 | else |
1337 | { |
||
1338 | FPoint fpStart(item->GrStrokeStartX, item->GrStrokeStartY); |
||
1339 | FPoint fpEnd(item->GrStrokeEndX, item->GrStrokeEndY); |
||
1340 | FPoint fpFocal(item->GrStrokeFocalX, item->GrStrokeFocalY); |
||
1341 | painter->setStrokeMode(ScPainterExBase::Gradient); |
||
1342 | painter->m_strokeGradient = VGradientEx(item->stroke_gradient, *m_doc); |
||
1343 | if (item->GrTypeStroke == 6) |
||
1344 | painter->setGradient(VGradientEx::linear, fpStart, fpEnd, fpStart, item->GrStrokeScale, item->GrStrokeSkew); |
||
1345 | else |
||
1346 | painter->setGradient(VGradientEx::radial, fpStart, fpEnd, fpFocal, item->GrStrokeScale, item->GrStrokeSkew); |
||
1347 | } |
||
1348 | painter->strokePath(); |
||
4360 | cbradney | 1349 | } |
17313 | jghali | 1350 | else if (item->lineColor() != CommonStrings::None) |
4360 | cbradney | 1351 | { |
17313 | jghali | 1352 | ScColorShade scColor(m_doc->PageColors[item->lineColor()], item->lineShade()); |
1353 | painter->setStrokeMode(ScPainterExBase::Solid); |
||
1354 | painter->setPen(scColor, item->lineWidth(), item->PLineArt, item->PLineEnd, item->PLineJoin); |
||
1355 | if (item->DashValues.count() != 0) |
||
1356 | painter->setDash(item->DashValues, item->DashOffset); |
||
1357 | painter->strokePath(); |
||
1358 | } |
||
1359 | } |
||
1360 | else |
||
1361 | { |
||
1362 | multiLine ml = m_doc->MLineStyles[item->NamedLStyle]; |
||
1363 | for (int it = ml.size()-1; it > -1; it--) |
||
1364 | { |
||
1365 | const SingleLine& sl = ml[it]; |
||
1366 | if (sl.Color != CommonStrings::None) |
||
4360 | cbradney | 1367 | { |
17313 | jghali | 1368 | ScColorShade tmp(m_doc->PageColors[sl.Color], sl.Shade); |
1369 | painter->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash), |
||
1370 | static_cast<Qt::PenCapStyle>(sl.LineEnd), |
||
1371 | static_cast<Qt::PenJoinStyle>(sl.LineJoin)); |
||
1372 | painter->strokePath(); |
||
4360 | cbradney | 1373 | } |
1374 | } |
||
17313 | jghali | 1375 | } |
1376 | if (startArrowIndex != 0) |
||
1377 | { |
||
1378 | FPoint Start = item->PoLine.point(0); |
||
1379 | for (uint xx = 1; xx < item->PoLine.size(); xx += 2) |
||
4360 | cbradney | 1380 | { |
17313 | jghali | 1381 | FPoint Vector = item->PoLine.point(xx); |
1382 | if ((Start.x() != Vector.x()) || (Start.y() != Vector.y())) |
||
4360 | cbradney | 1383 | { |
17313 | jghali | 1384 | double r = atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI); |
1385 | QTransform arrowTrans; |
||
1386 | arrowTrans.translate(Start.x(), Start.y()); |
||
1387 | arrowTrans.rotate(r); |
||
1388 | drawArrow(painter, item, arrowTrans, startArrowIndex); |
||
1389 | break; |
||
4360 | cbradney | 1390 | } |
1391 | } |
||
1392 | } |
||
17313 | jghali | 1393 | if (endArrowIndex != 0) |
1394 | { |
||
1395 | FPoint End = item->PoLine.point(item->PoLine.size()-2); |
||
1396 | for (uint xx = item->PoLine.size()-1; xx > 0; xx -= 2) |
||
1397 | { |
||
1398 | FPoint Vector = item->PoLine.point(xx); |
||
1399 | if ((End.x() != Vector.x()) || (End.y() != Vector.y())) |
||
1400 | { |
||
1401 | double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI); |
||
1402 | QTransform arrowTrans; |
||
1403 | arrowTrans.translate(End.x(), End.y()); |
||
1404 | arrowTrans.rotate(r); |
||
1405 | drawArrow(painter, item, arrowTrans, endArrowIndex); |
||
1406 | break; |
||
1407 | } |
||
1408 | } |
||
1409 | } |
||
4360 | cbradney | 1410 | } |
1411 | |||
17328 | jghali | 1412 | void ScPageOutput::drawItem_RegularPolygon( PageItem_RegularPolygon* item, ScPainterExBase* painter, const QRect& clip ) |
1413 | { |
||
1414 | painter->setupPolygon(&item->PoLine); |
||
1415 | painter->fillPath(); |
||
1416 | } |
||
1417 | |||
17296 | jghali | 1418 | void ScPageOutput::drawItem_Spiral( PageItem_Spiral* item, ScPainterExBase* painter, const QRect& clip ) |
1419 | { |
||
17313 | jghali | 1420 | if (item->PoLine.size() < 4) |
1421 | return; |
||
1422 | |||
17296 | jghali | 1423 | int startArrowIndex = item->startArrowIndex(); |
1424 | int endArrowIndex = item->endArrowIndex(); |
||
1425 | |||
17313 | jghali | 1426 | if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0)) |
17296 | jghali | 1427 | { |
17313 | jghali | 1428 | FPointArray cli; |
1429 | FPoint Start; |
||
1430 | bool firstp = true; |
||
1431 | for (uint n = 0; n < item->PoLine.size()-3; n += 4) |
||
17296 | jghali | 1432 | { |
17313 | jghali | 1433 | if (firstp) |
17296 | jghali | 1434 | { |
17313 | jghali | 1435 | Start = item->PoLine.point(n); |
1436 | firstp = false; |
||
17296 | jghali | 1437 | } |
17313 | jghali | 1438 | if (item->PoLine.point(n).x() > 900000) |
17296 | jghali | 1439 | { |
17313 | jghali | 1440 | cli.addPoint(item->PoLine.point(n-2)); |
1441 | cli.addPoint(item->PoLine.point(n-2)); |
||
17296 | jghali | 1442 | cli.addPoint(Start); |
1443 | cli.addPoint(Start); |
||
17313 | jghali | 1444 | cli.setMarker(); |
1445 | firstp = true; |
||
1446 | continue; |
||
17296 | jghali | 1447 | } |
17313 | jghali | 1448 | cli.addPoint(item->PoLine.point(n)); |
1449 | cli.addPoint(item->PoLine.point(n+1)); |
||
1450 | cli.addPoint(item->PoLine.point(n+2)); |
||
1451 | cli.addPoint(item->PoLine.point(n+3)); |
||
17296 | jghali | 1452 | } |
17313 | jghali | 1453 | if (cli.size() > 2) |
17296 | jghali | 1454 | { |
17313 | jghali | 1455 | FPoint l1 = cli.point(cli.size()-2); |
1456 | cli.addPoint(l1); |
||
1457 | cli.addPoint(l1); |
||
1458 | cli.addPoint(Start); |
||
1459 | cli.addPoint(Start); |
||
1460 | } |
||
1461 | painter->setupPolygon(&cli); |
||
1462 | fillPath(item, painter, clip); |
||
1463 | } |
||
1464 | painter->setupPolygon(&item->PoLine, false); |
||
1465 | if (item->NamedLStyle.isEmpty()) |
||
1466 | { |
||
1467 | QString patternStrokeVal = item->strokePattern(); |
||
1468 | if ((!patternStrokeVal.isEmpty()) && (m_doc->docPatterns.contains(patternStrokeVal))) |
||
1469 | { |
||
1470 | if (item->patternStrokePath) |
||
1471 | { |
||
1472 | QPainterPath guidePath = item->PoLine.toQPainterPath(false); |
||
1473 | guidePath.moveTo(0, 0); |
||
1474 | guidePath.lineTo(item->width(), 0); |
||
1475 | drawStrokePattern(item, painter, guidePath); |
||
1476 | } |
||
1477 | else |
||
1478 | { |
||
1479 | painter->setPattern(&m_doc->docPatterns[patternStrokeVal], item->patternStrokeScaleX, item->patternStrokeScaleY, item->patternStrokeOffsetX, item->patternStrokeOffsetY, item->patternStrokeRotation, item->patternStrokeSkewX, item->patternStrokeSkewY, item->patternStrokeMirrorX, item->patternStrokeMirrorY); |
||
1480 | painter->setStrokeMode(ScPainterExBase::Pattern); |
||
17296 | jghali | 1481 | painter->strokePath(); |
17313 | jghali | 1482 | } |
17296 | jghali | 1483 | } |
17313 | jghali | 1484 | else if (item->strokeGradientType() > 0) |
17296 | jghali | 1485 | { |
17313 | jghali | 1486 | QString gradientStrokeVal = item->strokeGradient(); |
1487 | if ((!gradientStrokeVal.isEmpty()) && (!m_doc->docGradients.contains(gradientStrokeVal))) |
||
1488 | gradientStrokeVal = ""; |
||
1489 | if (!(gradientStrokeVal.isEmpty()) && (m_doc->docGradients.contains(gradientStrokeVal))) |
||
1490 | painter->m_strokeGradient = VGradientEx(m_doc->docGradients[gradientStrokeVal], *m_doc); |
||
1491 | if (painter->m_strokeGradient.Stops() < 2) // fall back to solid stroking if there are not enough colorstops in the gradient. |
||
17296 | jghali | 1492 | { |
17313 | jghali | 1493 | if (item->lineColor() != CommonStrings::None) |
17296 | jghali | 1494 | { |
17313 | jghali | 1495 | ScColorShade strokeColor(m_doc->PageColors[item->lineColor()], item->lineShade()); |
1496 | painter->setBrush(strokeColor); |
||
1497 | painter->setStrokeMode(ScPainterExBase::Solid); |
||
17296 | jghali | 1498 | } |
17313 | jghali | 1499 | else |
1500 | painter->setStrokeMode(ScPainterExBase::None); |
||
17296 | jghali | 1501 | } |
17313 | jghali | 1502 | else |
1503 | { |
||
1504 | FPoint fpStart(item->GrStrokeStartX, item->GrStrokeStartY); |
||
1505 | FPoint fpEnd(item->GrStrokeEndX, item->GrStrokeEndY); |
||
1506 | FPoint fpFocal(item->GrStrokeFocalX, item->GrStrokeFocalY); |
||
1507 | painter->setStrokeMode(ScPainterExBase::Gradient); |
||
1508 | painter->m_strokeGradient = VGradientEx(item->stroke_gradient, *m_doc); |
||
1509 | if (item->GrTypeStroke == 6) |
||
1510 | painter->setGradient(VGradientEx::linear, fpStart, fpEnd, fpStart, item->GrStrokeScale, item->GrStrokeSkew); |
||
1511 | else |
||
1512 | painter->setGradient(VGradientEx::radial, fpStart, fpEnd, fpFocal, item->GrStrokeScale, item->GrStrokeSkew); |
||
1513 | } |
||
1514 | painter->strokePath(); |
||
17296 | jghali | 1515 | } |
17313 | jghali | 1516 | else if (item->lineColor() != CommonStrings::None) |
17296 | jghali | 1517 | { |
17313 | jghali | 1518 | ScColorShade scColor(m_doc->PageColors[item->lineColor()], item->lineShade()); |
1519 | painter->setStrokeMode(ScPainterExBase::Solid); |
||
1520 | painter->setPen(scColor, item->lineWidth(), item->PLineArt, item->PLineEnd, item->PLineJoin); |
||
1521 | if (item->DashValues.count() != 0) |
||
1522 | painter->setDash(item->DashValues, item->DashOffset); |
||
1523 | painter->strokePath(); |
||
1524 | } |
||
1525 | } |
||
1526 | else |
||
1527 | { |
||
1528 | multiLine ml = m_doc->MLineStyles[item->NamedLStyle]; |
||
1529 | for (int it = ml.size()-1; it > -1; it--) |
||
1530 | { |
||
1531 | const SingleLine& sl = ml[it]; |
||
1532 | if (sl.Color != CommonStrings::None) |
||
17296 | jghali | 1533 | { |
17313 | jghali | 1534 | ScColorShade tmp(m_doc->PageColors[sl.Color], sl.Shade); |
1535 | painter->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash), |
||
1536 | static_cast<Qt::PenCapStyle>(sl.LineEnd), |
||
1537 | static_cast<Qt::PenJoinStyle>(sl.LineJoin)); |
||
1538 | painter->strokePath(); |
||
17296 | jghali | 1539 | } |
1540 | } |
||
17313 | jghali | 1541 | } |
1542 | if (startArrowIndex != 0) |
||
1543 | { |
||
1544 | FPoint Start = item->PoLine.point(0); |
||
1545 | for (uint xx = 1; xx < item->PoLine.size(); xx += 2) |
||
17296 | jghali | 1546 | { |
17313 | jghali | 1547 | FPoint Vector = item->PoLine.point(xx); |
1548 | if ((Start.x() != Vector.x()) || (Start.y() != Vector.y())) |
||
17296 | jghali | 1549 | { |
17313 | jghali | 1550 | double r = atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI); |
1551 | QTransform arrowTrans; |
||
1552 | arrowTrans.translate(Start.x(), Start.y()); |
||
1553 | arrowTrans.rotate(r); |
||
1554 | drawArrow(painter, item, arrowTrans, startArrowIndex); |
||
1555 | break; |
||
17296 | jghali | 1556 | } |
1557 | } |
||
1558 | } |
||
17313 | jghali | 1559 | if (endArrowIndex != 0) |
1560 | { |
||
1561 | FPoint End = item->PoLine.point(item->PoLine.size()-2); |
||
1562 | for (uint xx = item->PoLine.size()-1; xx > 0; xx -= 2) |
||
1563 | { |
||
1564 | FPoint Vector = item->PoLine.point(xx); |
||
1565 | if ((End.x() != Vector.x()) || (End.y() != Vector.y())) |
||
1566 | { |
||
1567 | double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI); |
||
1568 | QTransform arrowTrans; |
||
1569 | arrowTrans.translate(End.x(), End.y()); |
||
1570 | arrowTrans.rotate(r); |
||
1571 | drawArrow(painter, item, arrowTrans, endArrowIndex); |
||
1572 | break; |
||
1573 | } |
||
1574 | } |
||
1575 | } |
||
17296 | jghali | 1576 | } |
1577 | |||
11905 | jghali | 1578 | void ScPageOutput::drawItem_TextFrame( PageItem_TextFrame* item, ScPainterExBase* painter, const QRect& clip ) |
4360 | cbradney | 1579 | { |
13951 | fschmid | 1580 | QTransform wm; |
5580 | jghali | 1581 | QPoint pt1, pt2; |
1582 | FPoint ColBound; |
||
1583 | QRegion cm; |
||
5753 | jghali | 1584 | int a; |
5721 | avox | 1585 | QString chstr, chstr2, chstr3; |
5580 | jghali | 1586 | ScText *hl; |
17034 | jghali | 1587 | double desc, asce; |
6824 | jghali | 1588 | |
1589 | QRect e2; |
||
5580 | jghali | 1590 | painter->save(); |
6824 | jghali | 1591 | if (item->isEmbedded) |
6987 | jghali | 1592 | e2 = clip; |
6824 | jghali | 1593 | else |
1594 | { |
||
6987 | jghali | 1595 | e2 = QRect(qRound(clip.x() + m_doc->minCanvasCoordinate.x()), qRound(clip.y() + m_doc->minCanvasCoordinate.y()), qRound(clip.width()), qRound(clip.height())); |
6824 | jghali | 1596 | wm.translate(item->xPos(), item->yPos()); |
1597 | } |
||
5580 | jghali | 1598 | wm.rotate(item->rotation()); |
1599 | if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0)) |
||
1600 | { |
||
1601 | painter->setupPolygon(&item->PoLine); |
||
11905 | jghali | 1602 | fillPath(item, painter, clip); |
5580 | jghali | 1603 | } |
13097 | subik | 1604 | if ((item->isAnnotation()) && (item->annotation().Type() == 2) && (!item->Pfile.isEmpty()) && (item->PictureIsAvailable) && (item->imageShown()) && (item->annotation().UseIcons())) |
5580 | jghali | 1605 | { |
8728 | jghali | 1606 | painter->save(); |
5580 | jghali | 1607 | painter->setupPolygon(&item->PoLine); |
1608 | painter->setClipPath(); |
||
1609 | painter->scale(item->imageXScale(), item->imageYScale()); |
||
1610 | painter->translate(static_cast<int>(item->imageXOffset() * item->imageXScale()), static_cast<int>(item->imageYOffset() * item->imageYScale())); |
||
5599 | jghali | 1611 | if (!item->pixm.qImage().isNull()) |
5580 | jghali | 1612 | painter->drawImage(&item->pixm, ScPainterExBase::rgbImages); |
1613 | painter->restore(); |
||
1614 | } |
||
5729 | jghali | 1615 | if ((item->itemText.length() != 0)) |
5580 | jghali | 1616 | { |
1617 | if (item->imageFlippedH()) |
||
1618 | { |
||
6987 | jghali | 1619 | painter->translate(item->width(), 0); |
5580 | jghali | 1620 | painter->scale(-1, 1); |
1621 | } |
||
1622 | if (item->imageFlippedV()) |
||
1623 | { |
||
6987 | jghali | 1624 | painter->translate(0, item->height()); |
5580 | jghali | 1625 | painter->scale(1, -1); |
1626 | } |
||
8728 | jghali | 1627 | uint tabCc = 0; |
17223 | jghali | 1628 | |
1629 | //automatic line spacing factor (calculated once) |
||
1630 | double autoLS = static_cast<double>(m_doc->typographicPrefs().autoLineSpacing) / 100.0; |
||
1631 | |||
6824 | jghali | 1632 | for (uint ll=0; ll < item->itemText.lines(); ++ll) |
5580 | jghali | 1633 | { |
6824 | jghali | 1634 | LineSpec ls = item->itemText.line(ll); |
1635 | double CurX = ls.x; |
||
1636 | for (a = ls.firstItem; a <= ls.lastItem; ++a) |
||
4360 | cbradney | 1637 | { |
6824 | jghali | 1638 | hl = item->itemText.item(a); |
10227 | jghali | 1639 | const CharStyle& charStyle = item->itemText.charStyle(a); |
6824 | jghali | 1640 | double chs = charStyle.fontSize() * hl->glyph.scaleV; |
1641 | if (charStyle.effects() & ScStyle_StartOfLine) |
||
1642 | tabCc = 0; |
||
1643 | chstr = hl->ch; |
||
1644 | if (charStyle.fillColor() != CommonStrings::None) |
||
4360 | cbradney | 1645 | { |
10227 | jghali | 1646 | ScColorShade tmp(m_doc->PageColors[charStyle.fillColor()], (int) hl->fillShade()); |
6824 | jghali | 1647 | painter->setBrush(tmp); |
4360 | cbradney | 1648 | } |
6824 | jghali | 1649 | if (charStyle.strokeColor() != CommonStrings::None) |
4360 | cbradney | 1650 | { |
10227 | jghali | 1651 | ScColorShade tmp(m_doc->PageColors[charStyle.strokeColor()], (int) hl->strokeShade()); |
6824 | jghali | 1652 | painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
4360 | cbradney | 1653 | } |
6824 | jghali | 1654 | if (charStyle.effects() & ScStyle_DropCap) |
4360 | cbradney | 1655 | { |
8728 | jghali | 1656 | const ParagraphStyle& style(item->itemText.paragraphStyle(a)); |
1657 | if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing) |
||
14932 | cbradney | 1658 | chs = qRound(10 * ((m_doc->guidesPrefs().valueBaselineGrid * (style.dropCapLines()-1) + (charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10))); |
17223 | jghali | 1659 | else if (style.lineSpacingMode() == ParagraphStyle::FixedLineSpacing) |
1660 | chs = qRound(10 * ((style.lineSpacing() * (style.dropCapLines()-1)+(charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10))); |
||
6824 | jghali | 1661 | else |
4360 | cbradney | 1662 | { |
17223 | jghali | 1663 | double currasce = charStyle.font().height(style.charStyle().fontSize() / 10.0) * autoLS; |
1664 | chs = qRound(10 * ((currasce * (style.dropCapLines() - 1)+(charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10))); |
||
4360 | cbradney | 1665 | } |
5580 | jghali | 1666 | } |
6824 | jghali | 1667 | if (chstr[0] == SpecialChars::TAB) |
1668 | tabCc++; |
||
1669 | //if (!m_doc->RePos) |
||
5580 | jghali | 1670 | { |
10227 | jghali | 1671 | //double xcoZli = CurX + hl->glyph.xoffset; |
6824 | jghali | 1672 | desc = - charStyle.font().descent(charStyle.fontSize() / 10.0); |
1673 | asce = charStyle.font().ascent(charStyle.fontSize() / 10.0); |
||
1674 | if (charStyle.strokeColor() != CommonStrings::None) |
||
1675 | { |
||
10227 | jghali | 1676 | ScColorShade tmp(m_doc->PageColors[charStyle.strokeColor()], (int) charStyle.strokeShade()); |
6824 | jghali | 1677 | painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
1678 | } |
||
1679 | if (e2.intersects(wm.mapRect(QRect(qRound(CurX + hl->glyph.xoffset),qRound(ls.y + hl->glyph.yoffset-asce), qRound(hl->glyph.xadvance+1), qRound(asce+desc))))) |
||
1680 | { |
||
1681 | painter->save(); |
||
6987 | jghali | 1682 | painter->translate(CurX, ls.y); |
9737 | jghali | 1683 | if (hl->ch == SpecialChars::OBJECT) |
17407 | fschmid | 1684 | drawItem_Embedded(item, painter, clip, charStyle, hl->getItem(m_doc)); |
6824 | jghali | 1685 | else |
11905 | jghali | 1686 | drawGlyphs(item, painter, charStyle, hl->glyph, clip); |
6824 | jghali | 1687 | painter->restore(); |
1688 | } |
||
14443 | jghali | 1689 | // Unneeded now that glyph xadvance is set appropriately for inline objects by PageItem_TextFrame::layout() - JG |
16602 | jghali | 1690 | /*if (hl->hasObject()) |
8728 | jghali | 1691 | CurX += (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()); |
14443 | jghali | 1692 | else*/ |
1693 | CurX += hl->glyph.wide(); |
||
5580 | jghali | 1694 | } |
4360 | cbradney | 1695 | } |
1696 | } |
||
1697 | } |
||
5580 | jghali | 1698 | painter->restore(); |
4360 | cbradney | 1699 | } |
1700 | |||
13951 | fschmid | 1701 | void ScPageOutput::drawArrow(ScPainterExBase* painter, PageItem* item, QTransform &arrowTrans, int arrowIndex) |
13303 | jghali | 1702 | { |
14969 | cbradney | 1703 | FPointArray arrow = m_doc->arrowStyles().at(arrowIndex-1).points.copy(); |
13303 | jghali | 1704 | if (item->NamedLStyle.isEmpty()) |
1705 | { |
||
1706 | if (item->lineWidth() != 0.0) |
||
1707 | arrowTrans.scale(item->lineWidth(), item->lineWidth()); |
||
1708 | } |
||
1709 | else |
||
1710 | { |
||
1711 | multiLine ml = m_doc->MLineStyles[item->NamedLStyle]; |
||
1712 | if (ml[ml.size()-1].Width != 0.0) |
||
1713 | arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width); |
||
1714 | } |
||
1715 | arrow.map(arrowTrans); |
||
1716 | painter->setupPolygon(&arrow); |
||
1717 | if (item->NamedLStyle.isEmpty()) |
||
1718 | { |
||
13310 | jghali | 1719 | if (item->lineColor() != CommonStrings::None) |
1720 | { |
||
1721 | ScColorShade tmp(m_doc->PageColors[item->lineColor()], item->lineShade()); |
||
1722 | painter->setBrush(tmp); |
||
1723 | painter->setBrushOpacity(1.0 - item->lineTransparency()); |
||
1724 | painter->setLineWidth(0); |
||
1725 | painter->setFillMode(ScPainterExBase::Solid); |
||
1726 | painter->fillPath(); |
||
1727 | } |
||
13303 | jghali | 1728 | } |
1729 | else |
||
1730 | { |
||
1731 | multiLine ml = m_doc->MLineStyles[item->NamedLStyle]; |
||
1732 | QColor tmp; |
||
1733 | if (ml[0].Color != CommonStrings::None) |
||
1734 | { |
||
1735 | ScColorShade tmp(m_doc->PageColors[ml[0].Color], ml[0].Shade); |
||
1736 | painter->setBrush(tmp); |
||
1737 | painter->setLineWidth(0); |
||
1738 | painter->setFillMode(ScPainterExBase::Solid); |
||
1739 | painter->fillPath(); |
||
1740 | } |
||
1741 | for (int it = ml.size()-1; it > 0; it--) |
||
1742 | { |
||
1743 | if (ml[it].Color != CommonStrings::None) |
||
1744 | { |
||
1745 | ScColorShade tmp(m_doc->PageColors[ml[it].Color], ml[it].Shade); |
||
1746 | painter->setPen(tmp, ml[it].Width, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
||
1747 | painter->strokePath(); |
||
1748 | } |
||
1749 | } |
||
1750 | } |
||
1751 | } |
||
1752 | |||
16729 | fschmid | 1753 | void ScPageOutput::drawMarks( ScPage* page, ScPainterExBase* painter, const MarksOptions& options ) |
7108 | jghali | 1754 | { |
17401 | jghali | 1755 | double markLength = options.markLength; |
1756 | double markOffs = options.markOffset; |
||
7108 | jghali | 1757 | double bleedLeft = 0.0, bleedRight = 0.0; |
1758 | double bleedBottom = options.BleedBottom; |
||
1759 | double bleedTop = options.BleedTop; |
||
1760 | if (!options.cropMarks && !options.bleedMarks && !options.registrationMarks && !options.colorMarks) |
||
1761 | return; |
||
1762 | if (m_doc->locationOfPage(page->pageNr()) == LeftPage) |
||
1763 | { |
||
1764 | bleedRight = options.BleedRight; |
||
1765 | bleedLeft = options.BleedLeft; |
||
1766 | } |
||
1767 | else if (m_doc->locationOfPage(page->pageNr()) == RightPage) |
||
1768 | { |
||
1769 | bleedRight = options.BleedLeft; |
||
1770 | bleedLeft = options.BleedRight; |
||
1771 | } |
||
1772 | else |
||
1773 | { |
||
1774 | bleedRight = options.BleedLeft; |
||
1775 | bleedLeft = options.BleedLeft; |
||
1776 | } |
||
1777 | double width = page->width(); |
||
1778 | double height = page->height(); |
||
1779 | double offsetX = page->xOffset(); |
||
1780 | double offsetY = page->yOffset(); |
||
11385 | jghali | 1781 | QPointF bleedTopLeft(offsetX - bleedLeft, offsetY - bleedTop); |
1782 | QPointF bleedBottomRight(offsetX + width + bleedRight, offsetY + height + bleedBottom); |
||
1783 | QRectF bleedBox(bleedTopLeft, bleedBottomRight); |
||
7108 | jghali | 1784 | painter->save(); |
1785 | painter->setLineWidth(0.5); |
||
1786 | painter->setPen(ScColorShade(Qt::black, 100), 0.5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin ); |
||
1787 | if (options.cropMarks) |
||
1788 | { |
||
1789 | FPoint start, end; |
||
1790 | double left = offsetX, right = offsetX + width; |
||
1791 | double bottom = offsetY + height, top = offsetY; |
||
17401 | jghali | 1792 | drawBoxMarks( painter, QRectF(QPointF(left, top), QPointF(right, bottom)), bleedBox, markOffs, markLength); |
7108 | jghali | 1793 | } |
1794 | if (options.bleedMarks) |
||
1795 | { |
||
1796 | FPoint start, end; |
||
1797 | double left = offsetX - bleedLeft, right = offsetX + width + bleedRight; |
||
1798 | double bottom = offsetY + height + bleedBottom, top = offsetY - bleedTop;; |
||
17401 | jghali | 1799 | drawBoxMarks( painter, QRectF(QPointF(left, top), QPointF(right, bottom)), bleedBox, markOffs, markLength); |
7108 | jghali | 1800 | } |
1801 | if (options.registrationMarks) |
||
1802 | { |
||
1803 | double posX = (2* offsetX + width) / 2.0 - 7.0; |
||
1804 | double posY = (offsetY + height + bleedBottom + markOffs + 3.0); |
||
1805 | painter->save(); |
||
1806 | painter->translate(posX, posY); |
||
11905 | jghali | 1807 | drawRegistrationCross( painter ); |
7108 | jghali | 1808 | painter->restore(); |
1809 | posX = (2 * offsetX + width) / 2.0 - 7.0; |
||
1810 | posY = (offsetY - bleedTop - markOffs - 17); |
||
1811 | painter->save(); |
||
1812 | painter->translate(posX, posY); |
||
11905 | jghali | 1813 | drawRegistrationCross( painter ); |
7108 | jghali | 1814 | painter->restore(); |
1815 | |||
1816 |