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