Rev 20630 | Rev 20640 | 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(); |
5988 | jghali | 556 | painter->setPen(painter->brush()); |
557 | painter->setLineWidth(lw); |
||
8728 | jghali | 558 | if (style.effects() & ScStyle_Subscript) |
559 | painter->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st)); |
||
560 | else |
||
561 | painter->drawLine(FPoint(glyphs.xoffset, -st), FPoint(glyphs.xoffset + glyphs.xadvance, -st)); |
||
6824 | jghali | 562 | painter->setPen(tmpPen); |
5988 | jghali | 563 | } |
4360 | cbradney | 564 | if (gly.size() > 3) |
565 | { |
||
8728 | jghali | 566 | painter->save(); |
567 | painter->translate(glyphs.xoffset, glyphs.yoffset - ((style.fontSize() / 10.0) * glyphs.scaleV)); |
||
4360 | cbradney | 568 | if (item->reversed()) |
569 | { |
||
8728 | jghali | 570 | painter->scale(-1, 1); |
571 | painter->translate(-glyphs.xadvance, 0); |
||
4360 | cbradney | 572 | } |
5988 | jghali | 573 | if (style.baselineOffset() != 0) |
8728 | jghali | 574 | painter->translate(0, -(style.fontSize() / 10.0) * (style.baselineOffset() / 1000.0)); |
575 | double glxSc = glyphs.scaleH * style.fontSize() / 100.00; |
||
576 | double glySc = glyphs.scaleV * style.fontSize() / 100.0; |
||
577 | painter->scale(glxSc, glySc); |
||
6987 | jghali | 578 | painter->setFillMode(ScPainterExBase::Solid); |
4360 | cbradney | 579 | bool fr = painter->fillRule(); |
580 | painter->setFillRule(false); |
||
11869 | jghali | 581 | painter->setupPolygon(&gly, true); |
8728 | jghali | 582 | if (glyph == 0) |
5988 | jghali | 583 | { |
13974 | cbradney | 584 | ScColorShade tmp(PrefsManager::instance()->appPrefs.displayPrefs.controlCharColor, 100); |
8728 | jghali | 585 | painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
586 | painter->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() * 2 / 10000.0); |
||
587 | painter->strokePath(); |
||
588 | } |
||
589 | else if ((style.font().isStroked()) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0)) |
||
590 | { |
||
5988 | jghali | 591 | ScColorShade tmp = painter->brush(); |
592 | painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
||
593 | painter->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0); |
||
594 | painter->strokePath(); |
||
595 | } |
||
4360 | cbradney | 596 | else |
597 | { |
||
5988 | jghali | 598 | if ((style.effects() & ScStyle_Shadowed) && (style.strokeColor() != CommonStrings::None)) |
4360 | cbradney | 599 | { |
600 | painter->save(); |
||
8728 | jghali | 601 | painter->translate((style.fontSize() * glyphs.scaleH * style.shadowXOffset() / 10000.0) / glxSc, -(style.fontSize() * glyphs.scaleV * style.shadowYOffset() / 10000.0) / glySc); |
4360 | cbradney | 602 | ScColorShade tmp = painter->brush(); |
603 | painter->setBrush(painter->pen()); |
||
11869 | jghali | 604 | painter->setupPolygon(&gly, true); |
11905 | jghali | 605 | fillPath(item, painter, clip); |
4360 | cbradney | 606 | painter->setBrush(tmp); |
607 | painter->restore(); |
||
11869 | jghali | 608 | painter->setupPolygon(&gly, true); |
4360 | cbradney | 609 | } |
5988 | jghali | 610 | if (style.fillColor() != CommonStrings::None) |
11905 | jghali | 611 | fillPath(item, painter, clip); |
5988 | jghali | 612 | if ((style.effects() & ScStyle_Outline) && (style.strokeColor() != CommonStrings::None) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0)) |
4360 | cbradney | 613 | { |
8728 | jghali | 614 | painter->setLineWidth((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) / glySc); |
4360 | cbradney | 615 | painter->strokePath(); |
616 | } |
||
617 | } |
||
618 | painter->setFillRule(fr); |
||
8728 | jghali | 619 | painter->restore(); |
4360 | cbradney | 620 | } |
5988 | jghali | 621 | if (style.effects() & ScStyle_Strikethrough) |
4360 | cbradney | 622 | { |
623 | double st, lw; |
||
5988 | jghali | 624 | if ((style.strikethruOffset() != -1) || (style.strikethruWidth() != -1)) |
4360 | cbradney | 625 | { |
5988 | jghali | 626 | if (style.strikethruOffset() != -1) |
627 | st = (style.strikethruOffset() / 1000.0) * (style.font().ascent(style.fontSize() / 10.0)); |
||
4360 | cbradney | 628 | else |
5988 | jghali | 629 | st = style.font().strikeoutPos(style.fontSize() / 10.0); |
630 | if (style.strikethruWidth() != -1) |
||
631 | lw = (style.strikethruWidth() / 1000.0) * (style.fontSize() / 10.0); |
||
4360 | cbradney | 632 | else |
8578 | jghali | 633 | lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0); |
4360 | cbradney | 634 | } |
635 | else |
||
636 | { |
||
5988 | jghali | 637 | st = style.font().strikeoutPos(style.fontSize() / 10.0); |
8578 | jghali | 638 | lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0); |
4360 | cbradney | 639 | } |
5988 | jghali | 640 | if (style.baselineOffset() != 0) |
641 | st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0); |
||
4360 | cbradney | 642 | painter->setPen(painter->brush()); |
643 | painter->setLineWidth(lw); |
||
5988 | jghali | 644 | painter->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st)); |
4360 | cbradney | 645 | } |
646 | } |
||
6824 | jghali | 647 | /*else |
4360 | cbradney | 648 | { |
649 | painter->setLineWidth(1); |
||
5988 | jghali | 650 | painter->setPen(ScColorShade(Qt::red, 100)); |
651 | painter->setBrush(ScColorShade(Qt::red, 100)); |
||
4360 | cbradney | 652 | painter->setFillMode(1); |
5988 | jghali | 653 | 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 | 654 | }*/ |
5988 | jghali | 655 | if (glyphs.more) |
6824 | jghali | 656 | { |
6987 | jghali | 657 | painter->translate(glyphs.xadvance, 0); |
11905 | jghali | 658 | drawGlyphs(item, painter, style, *glyphs.more, clip); |
6824 | jghali | 659 | } |
4360 | cbradney | 660 | } |
661 | |||
20630 | jghali | 662 | void ScPageOutput::drawItem_Embedded( PageItem* item, ScPainterExBase *p, QRect clip, const CharStyle& style, PageItem* cembedded) |
4360 | cbradney | 663 | { |
8728 | jghali | 664 | if (!cembedded) |
665 | return; |
||
9856 | fschmid | 666 | QList<PageItem*> emG; |
8728 | jghali | 667 | emG.append(cembedded); |
9856 | fschmid | 668 | for (int em = 0; em < emG.count(); ++em) |
8728 | jghali | 669 | { |
670 | PageItem* embedded = emG.at(em); |
||
12302 | jghali | 671 | p->save(); |
672 | double x = embedded->xPos(); |
||
673 | double y = embedded->yPos(); |
||
674 | embedded->setXPos( embedded->gXpos, true ); |
||
675 | embedded->setYPos((embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos, true ); |
||
676 | p->translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0))); |
||
677 | if (style.baselineOffset() != 0) |
||
678 | { |
||
679 | p->translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0)); |
||
680 | embedded->setYPos( embedded->yPos() - embedded->gHeight * (style.baselineOffset() / 1000.0) ); |
||
681 | } |
||
682 | p->scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0); |
||
8728 | jghali | 683 | double pws = embedded->m_lineWidth; |
11905 | jghali | 684 | drawItem_Pre(embedded, p); |
8728 | jghali | 685 | switch(embedded->itemType()) |
686 | { |
||
687 | case PageItem::ImageFrame: |
||
10321 | mrdocs | 688 | case PageItem::LatexFrame: |
8728 | jghali | 689 | case PageItem::TextFrame: |
690 | case PageItem::Polygon: |
||
691 | case PageItem::PathText: |
||
16105 | fschmid | 692 | case PageItem::Symbol: |
693 | case PageItem::Group: |
||
16191 | fschmid | 694 | case PageItem::RegularPolygon: |
16215 | fschmid | 695 | case PageItem::Arc: |
11905 | jghali | 696 | drawItem(embedded, p, clip); |
8728 | jghali | 697 | break; |
698 | case PageItem::Line: |
||
699 | case PageItem::PolyLine: |
||
700 | embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0); |
||
11905 | jghali | 701 | drawItem(embedded, p, clip); |
8728 | jghali | 702 | break; |
703 | default: |
||
704 | break; |
||
705 | } |
||
706 | embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0); |
||
11905 | jghali | 707 | drawItem_Post(embedded, p); |
12302 | jghali | 708 | embedded->setXPos(x, true); |
709 | embedded->setYPos(y, true); |
||
8728 | jghali | 710 | p->restore(); |
711 | embedded->m_lineWidth = pws; |
||
4360 | cbradney | 712 | } |
713 | } |
||
714 | |||
20630 | jghali | 715 | void ScPageOutput::drawPattern( PageItem* item, ScPainterExBase* painter, QRect clip) |
4360 | cbradney | 716 | { |
6987 | jghali | 717 | double x1, x2, y1, y2; |
718 | ScPattern& pattern = m_doc->docPatterns[item->pattern()]; |
||
14260 | fschmid | 719 | double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY; |
720 | item->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY); |
||
6987 | jghali | 721 | |
722 | // Compute pattern tansformation matrix and its inverse for converting pattern coordinates |
||
723 | // to pageitem coordinates |
||
13951 | fschmid | 724 | QTransform matrix, invMat; |
6987 | jghali | 725 | matrix.translate(patternOffsetX, patternOffsetY); |
726 | matrix.rotate(patternRotation); |
||
14260 | fschmid | 727 | matrix.shear(patternSkewX, patternSkewY); |
6987 | jghali | 728 | matrix.scale(pattern.scaleX, pattern.scaleY); |
729 | matrix.scale(patternScaleX / 100.0 , patternScaleY / 100.0); |
||
730 | invMat.scale((patternScaleX != 0) ? (100 /patternScaleX) : 1.0, (patternScaleY != 0) ? (100 /patternScaleY) : 1.0); |
||
731 | invMat.scale((pattern.scaleX != 0) ? (1 /pattern.scaleX) : 1.0, (pattern.scaleY != 0) ? (1 /pattern.scaleY) : 1.0); |
||
732 | invMat.rotate(-patternRotation); |
||
733 | invMat.translate(-patternOffsetX, -patternOffsetY); |
||
734 | |||
735 | // Compute bounding box in which pattern item will be drawn |
||
736 | double width = item->width(); |
||
737 | double height = item->height(); |
||
738 | double rot = patternRotation - floor(patternRotation / 90) * 90; |
||
739 | double ctheta = cos(rot * M_PI / 180); |
||
740 | double stheta = sin(rot * M_PI / 180); |
||
10227 | jghali | 741 | QRectF itemRect(0.0, 0.0, item->width(), item->height()); |
742 | QPointF pa( width * stheta * stheta, -width * stheta * ctheta ); |
||
743 | QPointF pb( width + height * ctheta * stheta, height * stheta * stheta ); |
||
744 | QPointF pc( -height * ctheta * stheta, height * ctheta * ctheta ); |
||
745 | QPointF pd( width * ctheta * ctheta, height + width * ctheta * stheta ); |
||
746 | QPointF ipa = invMat.map(pa), ipb = invMat.map(pb); |
||
747 | QPointF ipc = invMat.map(pc), ipd = invMat.map(pd); |
||
6987 | jghali | 748 | |
749 | painter->save(); |
||
750 | if (item->imageClip.size() != 0) |
||
751 | { |
||
752 | painter->setupPolygon(&item->imageClip); |
||
753 | painter->setClipPath(); |
||
754 | } |
||
755 | painter->setupPolygon(&item->PoLine); |
||
756 | painter->setClipPath(); |
||
9859 | jghali | 757 | for (int index = 0; index < pattern.items.count(); index++) |
6987 | jghali | 758 | { |
10227 | jghali | 759 | QRectF itRect; |
6987 | jghali | 760 | PageItem* it = pattern.items.at(index); |
761 | |||
762 | painter->save(); |
||
763 | painter->translate(patternOffsetX, patternOffsetY); |
||
764 | painter->rotate(patternRotation); |
||
765 | painter->scale(pattern.scaleX, pattern.scaleY); |
||
766 | painter->scale(patternScaleX / 100.0, patternScaleY / 100.0); |
||
767 | |||
768 | double patWidth = (pattern.width != 0.0) ? pattern.width : 1.0; |
||
769 | double patHeight = (pattern.height != 0.0) ? pattern.height : 1.0; |
||
770 | double kxa = (ipa.x() - it->gXpos) / patWidth; |
||
771 | double kxb = (ipb.x() - it->gXpos) / patWidth; |
||
772 | double kxc = (ipc.x() - it->gXpos) / patWidth; |
||
773 | double kxd = (ipd.x() - it->gXpos) / patWidth; |
||
774 | double kya = (ipa.y() - it->gYpos) / patHeight; |
||
775 | double kyb = (ipb.y() - it->gYpos) / patHeight; |
||
776 | double kyc = (ipc.y() - it->gYpos) / patHeight; |
||
777 | double kyd = (ipd.y() - it->gYpos) / patHeight; |
||
10227 | jghali | 778 | int kxMin = (int) floor( qMin(qMin(kxa, kxb), qMin(kxc, kxd)) ); |
779 | int kxMax = (int) ceil ( qMax(qMax(kxa, kxb), qMax(kxc, kxd)) ); |
||
780 | int kyMin = (int) floor( qMin(qMin(kya, kyb), qMin(kyc, kyd)) ); |
||
781 | int kyMax = (int) ceil ( qMax(qMax(kya, kyb), qMax(kyc, kyd)) ); |
||
6987 | jghali | 782 | |
783 | double itx = it->xPos(); |
||
784 | double ity = it->yPos(); |
||
785 | double itPosX = it->gXpos, itPosY = it->gYpos; |
||
786 | for ( int kx = kxMin; kx <= kxMax; kx++ ) |
||
787 | { |
||
788 | for ( int ky = kyMin; ky <= kyMax; ky++ ) |
||
789 | { |
||
790 | itPosX = it->gXpos + kx * pattern.width; |
||
791 | itPosY = it->gYpos + ky * pattern.height; |
||
792 | it->setXYPos(itPosX, itPosY); |
||
793 | it->getBoundingRect(&x1, &y1, &x2, &y2); |
||
794 | itRect.setCoords(x1, y1, x2, y2); |
||
795 | itRect = matrix.mapRect( itRect ); |
||
796 | if ( itRect.intersects(itemRect) ) |
||
11905 | jghali | 797 | drawItem(it, painter, clip); |
6987 | jghali | 798 | } |
799 | } |
||
800 | it->setXYPos(itx, ity); |
||
801 | painter->restore(); |
||
802 | } |
||
803 | painter->restore(); |
||
804 | } |
||
805 | |||
17263 | jghali | 806 | void ScPageOutput::drawStrokePattern(PageItem* item, ScPainterExBase* painter, const QPainterPath& path) |
807 | { |
||
808 | |||
809 | } |
||
810 | |||
20630 | jghali | 811 | void ScPageOutput::drawItem_Arc ( PageItem_Arc* item , ScPainterExBase* painter, QRect clip ) |
17296 | jghali | 812 | { |
813 | painter->setupPolygon(&item->PoLine); |
||
814 | fillPath(item, painter, clip); |
||
815 | } |
||
816 | |||
20630 | jghali | 817 | void ScPageOutput::drawItem_Group( PageItem_Group* item, ScPainterExBase* painter, QRect clip ) |
17288 | jghali | 818 | { |
819 | if (item->groupItemList.isEmpty()) |
||
820 | return; |
||
821 | |||
822 | painter->save(); |
||
823 | if (item->imageFlippedH()) |
||
824 | { |
||
825 | painter->translate(item->width(), 0); |
||
826 | painter->scale(-1, 1); |
||
827 | } |
||
828 | if (item->imageFlippedV()) |
||
829 | { |
||
830 | painter->translate(0, item->height()); |
||
831 | painter->scale(1, -1); |
||
832 | } |
||
833 | /*if ((maskType() == 1) || (maskType() == 2) || (maskType() == 4) || (maskType() == 5)) |
||
834 | { |
||
835 | if ((maskType() == 1) || (maskType() == 2)) |
||
836 | painter->setMaskMode(1); |
||
837 | else |
||
838 | painter->setMaskMode(3); |
||
839 | if ((!gradientMask().isEmpty()) && (!m_Doc->docGradients.contains(gradientMask()))) |
||
840 | gradientMaskVal = ""; |
||
841 | if (!(gradientMask().isEmpty()) && (m_Doc->docGradients.contains(gradientMask()))) |
||
842 | mask_gradient = m_Doc->docGradients[gradientMask()]; |
||
843 | painter->mask_gradient = mask_gradient; |
||
844 | if ((maskType() == 1) || (maskType() == 4)) |
||
845 | painter->setGradientMask(VGradient::linear, FPoint(GrMaskStartX, GrMaskStartY), FPoint(GrMaskEndX, GrMaskEndY), FPoint(GrMaskStartX, GrMaskStartY), GrMaskScale, GrMaskSkew); |
||
846 | else |
||
847 | painter->setGradientMask(VGradient::radial, FPoint(GrMaskStartX, GrMaskStartY), FPoint(GrMaskEndX, GrMaskEndY), FPoint(GrMaskFocalX, GrMaskFocalY), GrMaskScale, GrMaskSkew); |
||
848 | } |
||
849 | else if ((maskType() == 3) || (maskType() == 6) || (maskType() == 7) || (maskType() == 8)) |
||
850 | { |
||
851 | if ((patternMask().isEmpty()) || (!m_Doc->docPatterns.contains(patternMask()))) |
||
852 | painter->setMaskMode(0); |
||
853 | else |
||
854 | { |
||
855 | double scw = Width / groupWidth; |
||
856 | double sch = Height / groupHeight; |
||
857 | painter->setPatternMask(&m_Doc->docPatterns[patternMask()], patternMaskScaleX * scw, patternMaskScaleY * sch, patternMaskOffsetX, patternMaskOffsetY, patternMaskRotation, patternMaskSkewX, patternMaskSkewY, patternMaskMirrorX, patternMaskMirrorY); |
||
858 | if (maskType() == 3) |
||
859 | painter->setMaskMode(2); |
||
860 | else if (maskType() == 6) |
||
861 | painter->setMaskMode(4); |
||
862 | else if (maskType() == 7) |
||
863 | painter->setMaskMode(5); |
||
864 | else |
||
865 | painter->setMaskMode(6); |
||
866 | } |
||
867 | } |
||
868 | else*/ |
||
869 | painter->setMaskMode(0); |
||
870 | painter->setFillRule(item->fillRule); |
||
871 | //painter->beginLayer(1.0 - fillTransparency(), fillBlendmode(), &PoLine); |
||
872 | painter->setMaskMode(0); |
||
873 | painter->scale(item->width() / item->groupWidth, item->height() / item->groupHeight); |
||
874 | for (int em = 0; em < item->groupItemList.count(); ++em) |
||
875 | { |
||
876 | PageItem* embedded = item->groupItemList.at(em); |
||
877 | painter->save(); |
||
878 | painter->translate(embedded->gXpos, embedded->gYpos); |
||
879 | embedded->isEmbedded = true; |
||
880 | embedded->invalidateLayout(); |
||
881 | drawItem(embedded, painter, QRect()); |
||
882 | embedded->isEmbedded = false; |
||
883 | painter->restore(); |
||
884 | } |
||
885 | //painter->endLayer(); |
||
886 | painter->restore(); |
||
887 | } |
||
888 | |||
20630 | jghali | 889 | void ScPageOutput::drawItem_ImageFrame( PageItem_ImageFrame* item, ScPainterExBase* painter, QRect clip ) |
6987 | jghali | 890 | { |
4989 | cbradney | 891 | ScPainterExBase::ImageMode mode = ScPainterExBase::rgbImages; |
4546 | subik | 892 | if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0)) |
4360 | cbradney | 893 | { |
894 | painter->setupPolygon(&item->PoLine); |
||
11905 | jghali | 895 | fillPath(item, painter, clip); |
4360 | cbradney | 896 | } |
897 | if (item->Pfile.isEmpty()) |
||
898 | { |
||
9849 | jghali | 899 | /*painter->setPen( ScColorShade(Qt::black, 100), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
6987 | jghali | 900 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), item->height())); |
9849 | jghali | 901 | painter->drawLine(FPoint(0, item->height()), FPoint(item->width(), 0));*/ |
4360 | cbradney | 902 | } |
903 | else |
||
904 | { |
||
19834 | craig | 905 | if ((!item->imageVisible()) || (!item->imageIsAvailable)) |
4360 | cbradney | 906 | { |
9849 | jghali | 907 | /*painter->setPen( ScColorShade(Qt::red, 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 | { |
||
913 | ScImage scImg; |
||
914 | ScImage* pImage = NULL; |
||
915 | double imScaleX = item->imageXScale(); |
||
916 | double imScaleY = item->imageYScale(); |
||
917 | if( m_reloadImages ) |
||
918 | { |
||
919 | bool dummy; |
||
4617 | avox | 920 | bool useCmyk = false; |
4751 | cbradney | 921 | ScPainterExBase::ImageMode imageMode = painter->imageMode(); |
922 | if ( imageMode == ScPainterExBase::cmykImages ) |
||
4617 | avox | 923 | useCmyk = true; |
4360 | cbradney | 924 | QFileInfo fInfo(item->Pfile); |
10508 | cbradney | 925 | QString ext = fInfo.suffix(); |
5959 | jghali | 926 | CMSettings cmsSettings(item->doc(), item->IProfile, item->IRender); |
14467 | jghali | 927 | cmsSettings.allowColorManagement(m_useProfiles); |
928 | cmsSettings.setUseEmbeddedProfile(item->UseEmbedded); |
||
4360 | cbradney | 929 | scImg.imgInfo.valid = false; |
930 | scImg.imgInfo.clipPath = ""; |
||
931 | scImg.imgInfo.PDSpathData.clear(); |
||
932 | scImg.imgInfo.layerInfo.clear(); |
||
933 | scImg.imgInfo.RequestProps = item->pixm.imgInfo.RequestProps; |
||
934 | scImg.imgInfo.isRequest = item->pixm.imgInfo.isRequest; |
||
14467 | jghali | 935 | scImg.loadPicture(item->Pfile, item->pixm.imgInfo.actualPageNumber, cmsSettings, translateImageModeToRequest(imageMode), m_imageRes, &dummy); |
10136 | cbradney | 936 | if( extensionIndicatesEPSorPS(ext) || extensionIndicatesPDF(ext) ) |
4360 | cbradney | 937 | { |
938 | imScaleX *= (72.0 / (double) m_imageRes); |
||
939 | imScaleY *= (72.0 / (double) m_imageRes); |
||
940 | } |
||
4617 | avox | 941 | scImg.applyEffect(item->effectsInUse, m_doc->PageColors, useCmyk); |
4989 | cbradney | 942 | mode = imageMode; |
4360 | cbradney | 943 | pImage = &scImg; |
944 | } |
||
945 | else |
||
946 | pImage = &item->pixm; |
||
947 | |||
948 | painter->save(); |
||
949 | if (item->imageClip.size() != 0) |
||
4751 | cbradney | 950 | { |
4360 | cbradney | 951 | painter->setupPolygon(&item->imageClip); |
4751 | cbradney | 952 | painter->setClipPath(); |
953 | } |
||
954 | painter->setupPolygon(&item->PoLine); |
||
4360 | cbradney | 955 | painter->setClipPath(); |
956 | if (item->imageFlippedH()) |
||
957 | { |
||
6987 | jghali | 958 | painter->translate(item->width(), 0); |
4360 | cbradney | 959 | painter->scale(-1, 1); |
960 | } |
||
961 | if (item->imageFlippedV()) |
||
962 | { |
||
6987 | jghali | 963 | painter->translate(0, item->height()); |
4360 | cbradney | 964 | painter->scale(1, -1); |
965 | } |
||
6987 | jghali | 966 | painter->translate(item->imageXOffset() * item->imageXScale(), item->imageYOffset() * item->imageYScale()); |
4360 | cbradney | 967 | //painter->translate(item->LocalX * imScaleX * scale, item->LocalY * imScaleY * scale); ?? |
968 | painter->scale( imScaleX, imScaleY ); |
||
969 | if (pImage->imgInfo.lowResType != 0) |
||
970 | painter->scale(pImage->imgInfo.lowResScale, pImage->imgInfo.lowResScale); |
||
4989 | cbradney | 971 | painter->drawImage(pImage, mode); |
4360 | cbradney | 972 | painter->restore(); |
973 | } |
||
974 | } |
||
975 | } |
||
976 | |||
20630 | jghali | 977 | void ScPageOutput::drawItem_Line( PageItem_Line* item, ScPainterExBase* painter, QRect clip ) |
4360 | cbradney | 978 | { |
17313 | jghali | 979 | if (item->PoLine.size() < 4) |
980 | return; |
||
981 | |||
13310 | jghali | 982 | int startArrowIndex = item->startArrowIndex(); |
983 | int endArrowIndex = item->endArrowIndex(); |
||
4546 | subik | 984 | |
4360 | cbradney | 985 | if (item->NamedLStyle.isEmpty()) |
17313 | jghali | 986 | { |
987 | QString patternStrokeVal = item->strokePattern(); |
||
988 | if ((!patternStrokeVal.isEmpty()) && (m_doc->docPatterns.contains(patternStrokeVal))) |
||
989 | { |
||
990 | if (item->patternStrokePath) |
||
991 | { |
||
992 | QPainterPath guidePath = item->PoLine.toQPainterPath(false); |
||
993 | guidePath.moveTo(0, 0); |
||
994 | guidePath.lineTo(item->width(), 0); |
||
995 | drawStrokePattern(item, painter, guidePath); |
||
996 | } |
||
997 | else |
||
998 | { |
||
999 | painter->setPattern(&m_doc->docPatterns[patternStrokeVal], item->patternStrokeScaleX, item->patternStrokeScaleY, item->patternStrokeOffsetX, item->patternStrokeOffsetY, item->patternStrokeRotation, item->patternStrokeSkewX, item->patternStrokeSkewY, item->patternStrokeMirrorX, item->patternStrokeMirrorY); |
||
1000 | painter->setStrokeMode(ScPainterExBase::Pattern); |
||
1001 | painter->strokePath(); |
||
1002 | } |
||
1003 | } |
||
1004 | else if (item->strokeGradientType() > 0) |
||
1005 | { |
||
1006 | QString gradientStrokeVal = item->strokeGradient(); |
||
1007 | if ((!gradientStrokeVal.isEmpty()) && (!m_doc->docGradients.contains(gradientStrokeVal))) |
||
1008 | gradientStrokeVal = ""; |
||
1009 | if (!(gradientStrokeVal.isEmpty()) && (m_doc->docGradients.contains(gradientStrokeVal))) |
||
1010 | painter->m_strokeGradient = VGradientEx(m_doc->docGradients[gradientStrokeVal], *m_doc); |
||
1011 | if (painter->m_strokeGradient.Stops() < 2) // fall back to solid stroking if there are not enough colorstops in the gradient. |
||
1012 | { |
||
1013 | if (item->lineColor() != CommonStrings::None) |
||
1014 | { |
||
1015 | ScColorShade strokeColor(m_doc->PageColors[item->lineColor()], item->lineShade()); |
||
1016 | painter->setBrush(strokeColor); |
||
1017 | painter->setStrokeMode(ScPainterExBase::Solid); |
||
1018 | } |
||
1019 | else |
||
1020 | painter->setStrokeMode(ScPainterExBase::None); |
||
1021 | } |
||
1022 | else |
||
1023 | { |
||
1024 | FPoint fpStart(item->GrStrokeStartX, item->GrStrokeStartY); |
||
1025 | FPoint fpEnd(item->GrStrokeEndX, item->GrStrokeEndY); |
||
1026 | FPoint fpFocal(item->GrStrokeFocalX, item->GrStrokeFocalY); |
||
1027 | painter->setStrokeMode(ScPainterExBase::Gradient); |
||
1028 | painter->m_strokeGradient = VGradientEx(item->stroke_gradient, *m_doc); |
||
1029 | if (item->GrTypeStroke == 6) |
||
1030 | painter->setGradient(VGradientEx::linear, fpStart, fpEnd, fpStart, item->GrStrokeScale, item->GrStrokeSkew); |
||
1031 | else |
||
1032 | painter->setGradient(VGradientEx::radial, fpStart, fpEnd, fpFocal, item->GrStrokeScale, item->GrStrokeSkew); |
||
1033 | } |
||
1034 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), 0)); |
||
1035 | } |
||
1036 | else if (item->lineColor() != CommonStrings::None) |
||
1037 | { |
||
1038 | ScColorShade scColor(m_doc->PageColors[item->lineColor()], item->lineShade()); |
||
1039 | painter->setStrokeMode(ScPainterExBase::Solid); |
||
1040 | painter->setPen(scColor, item->lineWidth(), item->PLineArt, item->PLineEnd, item->PLineJoin); |
||
1041 | if (item->DashValues.count() != 0) |
||
1042 | painter->setDash(item->DashValues, item->DashOffset); |
||
1043 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), 0)); |
||
1044 | } |
||
1045 | } |
||
4360 | cbradney | 1046 | else |
1047 | { |
||
17313 | jghali | 1048 | painter->setStrokeMode(ScPainterExBase::Solid); |
4360 | cbradney | 1049 | multiLine ml = m_doc->MLineStyles[item->NamedLStyle]; |
1050 | for (int it = ml.size()-1; it > -1; it--) |
||
1051 | { |
||
7143 | jghali | 1052 | const SingleLine& sl = ml[it]; |
17313 | jghali | 1053 | if ((sl.Color != CommonStrings::None) && (sl.Width != 0)) |
7143 | jghali | 1054 | { |
1055 | ScColorShade tmp(m_doc->PageColors[sl.Color], sl.Shade); |
||
1056 | painter->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash), |
||
1057 | static_cast<Qt::PenCapStyle>(sl.LineEnd), |
||
1058 | static_cast<Qt::PenJoinStyle>(sl.LineJoin)); |
||
1059 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), 0)); |
||
1060 | } |
||
4360 | cbradney | 1061 | } |
1062 | } |
||
1063 | if (startArrowIndex != 0) |
||
1064 | { |
||
13951 | fschmid | 1065 | QTransform arrowTrans; |
13303 | jghali | 1066 | arrowTrans.translate(0, 0); |
1067 | arrowTrans.scale(-1,1); |
||
13310 | jghali | 1068 | drawArrow(painter, item, arrowTrans, startArrowIndex); |
4360 | cbradney | 1069 | } |
1070 | if (endArrowIndex != 0) |
||
1071 | { |
||
13951 | fschmid | 1072 | QTransform arrowTrans; |
13303 | jghali | 1073 | arrowTrans.translate(item->width(), 0); |
13310 | jghali | 1074 | drawArrow(painter, item, arrowTrans, endArrowIndex); |
4360 | cbradney | 1075 | } |
1076 | } |
||
1077 | |||
20630 | jghali | 1078 | void ScPageOutput::drawItem_PathText( PageItem_PathText* item, ScPainterExBase* painter, QRect clip ) |
4360 | cbradney | 1079 | { |
17635 | jghali | 1080 | QString chstr; |
18987 | avox | 1081 | //ScText *hl; |
4360 | cbradney | 1082 | FPoint point = FPoint(0, 0); |
1083 | FPoint tangent = FPoint(0, 0); |
||
1084 | double CurX = item->textToFrameDistLeft(); // item->CurX = item->textToFrameDistLeft() |
||
10992 | jghali | 1085 | QString actFill, actStroke; |
17033 | jghali | 1086 | double actFillShade, actStrokeShade, dx; |
10992 | jghali | 1087 | StoryText& itemText = item->itemText; |
12217 | jghali | 1088 | if (item->pathTextShowFrame()) |
4360 | cbradney | 1089 | { |
12996 | jghali | 1090 | painter->setupPolygon(&item->PoLine, false); |
1091 | if (item->NamedLStyle.isEmpty()) |
||
7143 | jghali | 1092 | { |
12996 | jghali | 1093 | if (item->lineColor() != CommonStrings::None) |
1094 | painter->strokePath(); |
||
12217 | jghali | 1095 | } |
1096 | else |
||
1097 | { |
||
1098 | multiLine ml = m_doc->MLineStyles[item->NamedLStyle]; |
||
1099 | for (int it = ml.size() - 1; it > -1; it--) |
||
7143 | jghali | 1100 | { |
12217 | jghali | 1101 | const SingleLine& sl = ml[it]; |
1102 | if ((sl.Color != CommonStrings::None) && (sl.Width != 0)) |
||
1103 | { |
||
1104 | ScColorShade tmp(m_doc->PageColors[sl.Color], sl.Shade); |
||
1105 | painter->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash), |
||
1106 | static_cast<Qt::PenCapStyle>(sl.LineEnd), |
||
1107 | static_cast<Qt::PenJoinStyle>(sl.LineJoin)); |
||
1108 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), 0)); |
||
1109 | } |
||
7143 | jghali | 1110 | } |
1111 | } |
||
1112 | } |
||
10992 | jghali | 1113 | double totalTextLen = 0.0; |
1114 | double totalCurveLen = 0.0; |
||
1115 | double extraOffset = 0.0; |
||
1116 | if (itemText.length() != 0) |
||
1117 | { |
||
18524 | avox | 1118 | CurX += itemText.charStyle(0).fontSize() * itemText.charStyle(0).tracking() / 10000.0; |
10992 | jghali | 1119 | totalTextLen += itemText.charStyle(0).fontSize() * itemText.charStyle(0).tracking() / 10000.0; |
1120 | } |
||
1121 | for (int a = 0; a < itemText.length(); ++a) |
||
4360 | cbradney | 1122 | { |
18524 | avox | 1123 | GlyphLayout* glyphs = itemText.getGlyphs(a); |
1124 | chstr =itemText.text(a,1); |
||
11713 | fschmid | 1125 | if (chstr[0] == SpecialChars::PAGENUMBER || chstr[0] == SpecialChars::PARSEP || chstr[0] == SpecialChars::PAGECOUNT |
8089 | jghali | 1126 | || chstr[0] == SpecialChars::TAB || chstr == SpecialChars::LINEBREAK) |
4360 | cbradney | 1127 | continue; |
10992 | jghali | 1128 | if (a < itemText.length()-1) |
1129 | chstr += itemText.text(a+1, 1); |
||
18524 | avox | 1130 | glyphs->yadvance = 0; |
18987 | avox | 1131 | item->layoutGlyphs(itemText.charStyle(a), chstr, itemText.flags(a), *glyphs); |
18524 | avox | 1132 | glyphs->shrink(); |
1133 | if (item->itemText.hasObject(a)) |
||
1134 | totalTextLen += (item->itemText.object(a)->width() + item->itemText.object(a)->lineWidth()) * glyphs->scaleH; |
||
10992 | jghali | 1135 | else |
18524 | avox | 1136 | totalTextLen += glyphs->wide()+itemText.charStyle(a).fontSize() * itemText.charStyle(a).tracking() / 10000.0; |
10992 | jghali | 1137 | } |
18114 | jghali | 1138 | for (int segs = 0; segs < item->PoLine.size()-3; segs += 4) |
10992 | jghali | 1139 | { |
1140 | totalCurveLen += item->PoLine.lenPathSeg(segs); |
||
1141 | } |
||
1142 | if ((itemText.defaultStyle().alignment() != 0) && (totalCurveLen >= totalTextLen + item->textToFrameDistLeft())) |
||
1143 | { |
||
1144 | if (itemText.defaultStyle().alignment() == 2) |
||
4360 | cbradney | 1145 | { |
10992 | jghali | 1146 | CurX = totalCurveLen - totalTextLen; |
1147 | CurX -= item->textToFrameDistLeft(); |
||
4360 | cbradney | 1148 | } |
10992 | jghali | 1149 | if (itemText.defaultStyle().alignment() == 1) |
1150 | CurX = (totalCurveLen - totalTextLen) / 2.0; |
||
1151 | if ((itemText.defaultStyle().alignment() == 3) || (itemText.defaultStyle().alignment() == 4)) |
||
1152 | extraOffset = (totalCurveLen - item->textToFrameDistLeft() - totalTextLen) / static_cast<double>(itemText.length()); |
||
1153 | } |
||
1154 | |||
1155 | QPainterPath guidePath = item->PoLine.toQPainterPath(false); |
||
1156 | QList<QPainterPath> pathList = decomposePath(guidePath); |
||
1157 | QPainterPath currPath = pathList[0]; |
||
1158 | int currPathIndex = 0; |
||
1159 | for (int a = item->firstInFrame(); a < itemText.length(); ++a) |
||
1160 | { |
||
18524 | avox | 1161 | GlyphLayout* glyphs = itemText.getGlyphs(a); |
18987 | avox | 1162 | PathData* pdata = &(item->textLayout.point(a)); |
1163 | |||
18524 | avox | 1164 | chstr = itemText.text(a,1); |
11750 | jghali | 1165 | if (chstr[0] == SpecialChars::PAGENUMBER || chstr[0] == SpecialChars::PARSEP || chstr[0] == SpecialChars::PAGECOUNT |
10992 | jghali | 1166 | || chstr[0] == SpecialChars::TAB || chstr[0] == SpecialChars::LINEBREAK) |
1167 | continue; |
||
1168 | if (a < itemText.length()-1) |
||
1169 | chstr += itemText.text(a+1, 1); |
||
18524 | avox | 1170 | glyphs->yadvance = 0; |
18987 | avox | 1171 | item->layoutGlyphs(itemText.charStyle(a), chstr, itemText.flags(a), *glyphs); |
18524 | avox | 1172 | glyphs->shrink(); // HACK |
14443 | jghali | 1173 | // Unneeded now that glyph xadvance is set appropriately for inline objects by PageItem_TextFrame::layout() - JG |
16602 | jghali | 1174 | /*if (hl->hasObject()) |
13251 | jghali | 1175 | dx = (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()) * hl->glyph.scaleH / 2.0; |
14443 | jghali | 1176 | else*/ |
18524 | avox | 1177 | dx = glyphs->wide() / 2.0; |
10992 | jghali | 1178 | |
1179 | CurX += dx; |
||
1180 | |||
1181 | double currPerc = currPath.percentAtLength(CurX); |
||
1182 | if (currPerc >= 0.9999999) |
||
4360 | cbradney | 1183 | { |
10992 | jghali | 1184 | currPathIndex++; |
1185 | if (currPathIndex == pathList.count()) |
||
4360 | cbradney | 1186 | break; |
10992 | jghali | 1187 | currPath = pathList[currPathIndex]; |
1188 | CurX = dx; |
||
1189 | currPerc = currPath.percentAtLength(CurX); |
||
4360 | cbradney | 1190 | } |
10992 | jghali | 1191 | double currAngle = currPath.angleAtPercent(currPerc); |
13251 | jghali | 1192 | if (currAngle <= 180.0) |
1193 | currAngle *= -1.0; |
||
1194 | else |
||
1195 | currAngle = 360.0 - currAngle; |
||
10992 | jghali | 1196 | QPointF currPoint = currPath.pointAtPercent(currPerc); |
1197 | tangent = FPoint(cos(currAngle * M_PI / 180.0), sin(currAngle * M_PI / 180.0)); |
||
1198 | point = FPoint(currPoint.x(), currPoint.y()); |
||
1199 | |||
18987 | avox | 1200 | //hl = itemText.item_p(a); |
18524 | avox | 1201 | glyphs->xoffset = 0; |
18987 | avox | 1202 | pdata->PtransX = point.x(); |
1203 | pdata->PtransY = point.y(); |
||
1204 | pdata->PRot = currAngle * M_PI / 180.0; |
||
1205 | pdata->PDx = dx; |
||
13951 | fschmid | 1206 | QTransform trafo = QTransform( 1, 0, 0, -1, -dx, 0 ); |
8089 | jghali | 1207 | if (item->textPathFlipped) |
13951 | fschmid | 1208 | trafo *= QTransform(1, 0, 0, -1, 0, 0); |
8089 | jghali | 1209 | if (item->textPathType == 0) |
13951 | fschmid | 1210 | trafo *= QTransform( tangent.x(), tangent.y(), tangent.y(), -tangent.x(), point.x(), point.y() ); // ID's Rainbow mode |
8089 | jghali | 1211 | else if (item->textPathType == 1) |
13951 | fschmid | 1212 | trafo *= QTransform( 1, 0, 0, -1, point.x(), point.y() ); // ID's Stair Step mode |
8089 | jghali | 1213 | else if (item->textPathType == 2) |
1214 | { |
||
1215 | double a = 1; |
||
1216 | if (tangent.x() < 0) |
||
1217 | a = -1; |
||
1218 | if (fabs(tangent.x()) > 0.1) |
||
13951 | fschmid | 1219 | trafo *= QTransform( a, (tangent.y() / tangent.x()) * a, 0, -1, point.x(), point.y() ); // ID's Skew mode |
8089 | jghali | 1220 | else |
13951 | fschmid | 1221 | trafo *= QTransform( a, 4 * a, 0, -1, point.x(), point.y() ); |
8089 | jghali | 1222 | } |
13951 | fschmid | 1223 | QTransform sca = painter->worldMatrix(); |
4360 | cbradney | 1224 | trafo *= sca; |
1225 | painter->save(); |
||
13951 | fschmid | 1226 | QTransform savWM = painter->worldMatrix(); |
4360 | cbradney | 1227 | painter->setWorldMatrix(trafo); |
10992 | jghali | 1228 | |
1229 | actFill = itemText.charStyle(a).fillColor(); |
||
1230 | actFillShade = itemText.charStyle(a).fillShade(); |
||
1231 | if (actFill != CommonStrings::None) |
||
1232 | { |
||
11229 | fschmid | 1233 | ScColorShade tmp(m_doc->PageColors[actFill], qRound(actFillShade)); |
10992 | jghali | 1234 | painter->setBrush(tmp); |
1235 | } |
||
1236 | actStroke = itemText.charStyle(a).strokeColor(); |
||
1237 | actStrokeShade = itemText.charStyle(a).strokeShade(); |
||
1238 | if (actStroke != CommonStrings::None) |
||
1239 | { |
||
11229 | fschmid | 1240 | ScColorShade tmp(m_doc->PageColors[actStroke], qRound(actStrokeShade)); |
10992 | jghali | 1241 | painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
1242 | } |
||
13251 | jghali | 1243 | painter->translate(0.0, item->pathTextBaseOffset()); |
18524 | avox | 1244 | if (itemText.hasObject(a)) |
1245 | drawItem_Embedded(itemText.object(a), painter, clip, itemText.charStyle(a), itemText.object(a)); |
||
10992 | jghali | 1246 | else |
18524 | avox | 1247 | drawGlyphs(item, painter, itemText.charStyle(a), *glyphs, clip); |
10992 | jghali | 1248 | |
4360 | cbradney | 1249 | painter->setWorldMatrix(savWM); |
1250 | painter->restore(); |
||
1251 | CurX -= dx; |
||
18524 | avox | 1252 | if (itemText.hasObject(a)) |
1253 | CurX += (itemText.object(a)->width() + itemText.object(a)->lineWidth()) * glyphs->scaleH; |
||
10992 | jghali | 1254 | else |
18524 | avox | 1255 | CurX += glyphs->wide()+itemText.charStyle(a).fontSize() * itemText.charStyle(a).tracking() / 10000.0 + extraOffset; |
4360 | cbradney | 1256 | } |
1257 | } |
||
1258 | |||
20630 | jghali | 1259 | void ScPageOutput::drawItem_Polygon ( PageItem_Polygon* item , ScPainterExBase* painter, QRect clip ) |
4360 | cbradney | 1260 | { |
1261 | painter->setupPolygon(&item->PoLine); |
||
11905 | jghali | 1262 | fillPath(item, painter, clip); |
4360 | cbradney | 1263 | } |
1264 | |||
20630 | jghali | 1265 | void ScPageOutput::drawItem_PolyLine( PageItem_PolyLine* item, ScPainterExBase* painter, QRect clip ) |
4360 | cbradney | 1266 | { |
17313 | jghali | 1267 | if (item->PoLine.size() < 4) |
1268 | return; |
||
1269 | |||
13310 | jghali | 1270 | int startArrowIndex = item->startArrowIndex(); |
1271 | int endArrowIndex = item->endArrowIndex(); |
||
4546 | subik | 1272 | |
17313 | jghali | 1273 | if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0)) |
4360 | cbradney | 1274 | { |
17313 | jghali | 1275 | FPointArray cli; |
1276 | FPoint Start; |
||
1277 | bool firstp = true; |
||
18114 | jghali | 1278 | for (int n = 0; n < item->PoLine.size()-3; n += 4) |
4360 | cbradney | 1279 | { |
17313 | jghali | 1280 | if (firstp) |
4360 | cbradney | 1281 | { |
17313 | jghali | 1282 | Start = item->PoLine.point(n); |
1283 | firstp = false; |
||
4360 | cbradney | 1284 | } |
18801 | fschmid | 1285 | if (item->PoLine.isMarker(n)) |
4360 | cbradney | 1286 | { |
17313 | jghali | 1287 | cli.addPoint(item->PoLine.point(n-2)); |
1288 | cli.addPoint(item->PoLine.point(n-2)); |
||
4360 | cbradney | 1289 | cli.addPoint(Start); |
1290 | cli.addPoint(Start); |
||
17313 | jghali | 1291 | cli.setMarker(); |
1292 | firstp = true; |
||
1293 | continue; |
||
4360 | cbradney | 1294 | } |
17313 | jghali | 1295 | cli.addPoint(item->PoLine.point(n)); |
1296 | cli.addPoint(item->PoLine.point(n+1)); |
||
1297 | cli.addPoint(item->PoLine.point(n+2)); |
||
1298 | cli.addPoint(item->PoLine.point(n+3)); |
||
4360 | cbradney | 1299 | } |
17313 | jghali | 1300 | if (cli.size() > 2) |
13303 | jghali | 1301 | { |
17313 | jghali | 1302 | FPoint l1 = cli.point(cli.size()-2); |
1303 | cli.addPoint(l1); |
||
1304 | cli.addPoint(l1); |
||
1305 | cli.addPoint(Start); |
||
1306 | cli.addPoint(Start); |
||
1307 | } |
||
1308 | painter->setupPolygon(&cli); |
||
1309 | fillPath(item, painter, clip); |
||
1310 | } |
||
1311 | painter->setupPolygon(&item->PoLine, false); |
||
1312 | if (item->NamedLStyle.isEmpty()) |
||
1313 | { |
||
1314 | QString patternStrokeVal = item->strokePattern(); |
||
1315 | if ((!patternStrokeVal.isEmpty()) && (m_doc->docPatterns.contains(patternStrokeVal))) |
||
1316 | { |
||
1317 | if (item->patternStrokePath) |
||
1318 | { |
||
1319 | QPainterPath guidePath = item->PoLine.toQPainterPath(false); |
||
1320 | guidePath.moveTo(0, 0); |
||
1321 | guidePath.lineTo(item->width(), 0); |
||
1322 | drawStrokePattern(item, painter, guidePath); |
||
1323 | } |
||
1324 | else |
||
1325 | { |
||
1326 | painter->setPattern(&m_doc->docPatterns[patternStrokeVal], item->patternStrokeScaleX, item->patternStrokeScaleY, item->patternStrokeOffsetX, item->patternStrokeOffsetY, item->patternStrokeRotation, item->patternStrokeSkewX, item->patternStrokeSkewY, item->patternStrokeMirrorX, item->patternStrokeMirrorY); |
||
1327 | painter->setStrokeMode(ScPainterExBase::Pattern); |
||
13303 | jghali | 1328 | painter->strokePath(); |
17313 | jghali | 1329 | } |
13303 | jghali | 1330 | } |
17313 | jghali | 1331 | else if (item->strokeGradientType() > 0) |
4360 | cbradney | 1332 | { |
17313 | jghali | 1333 | QString gradientStrokeVal = item->strokeGradient(); |
1334 | if ((!gradientStrokeVal.isEmpty()) && (!m_doc->docGradients.contains(gradientStrokeVal))) |
||
1335 | gradientStrokeVal = ""; |
||
1336 | if (!(gradientStrokeVal.isEmpty()) && (m_doc->docGradients.contains(gradientStrokeVal))) |
||
1337 | painter->m_strokeGradient = VGradientEx(m_doc->docGradients[gradientStrokeVal], *m_doc); |
||
1338 | if (painter->m_strokeGradient.Stops() < 2) // fall back to solid stroking if there are not enough colorstops in the gradient. |
||
4360 | cbradney | 1339 | { |
17313 | jghali | 1340 | if (item->lineColor() != CommonStrings::None) |
7143 | jghali | 1341 | { |
17313 | jghali | 1342 | ScColorShade strokeColor(m_doc->PageColors[item->lineColor()], item->lineShade()); |
1343 | painter->setBrush(strokeColor); |
||
1344 | painter->setStrokeMode(ScPainterExBase::Solid); |
||
7143 | jghali | 1345 | } |
17313 | jghali | 1346 | else |
1347 | painter->setStrokeMode(ScPainterExBase::None); |
||
4360 | cbradney | 1348 | } |
17313 | jghali | 1349 | else |
1350 | { |
||
1351 | FPoint fpStart(item->GrStrokeStartX, item->GrStrokeStartY); |
||
1352 | FPoint fpEnd(item->GrStrokeEndX, item->GrStrokeEndY); |
||
1353 | FPoint fpFocal(item->GrStrokeFocalX, item->GrStrokeFocalY); |
||
1354 | painter->setStrokeMode(ScPainterExBase::Gradient); |
||
1355 | painter->m_strokeGradient = VGradientEx(item->stroke_gradient, *m_doc); |
||
1356 | if (item->GrTypeStroke == 6) |
||
1357 | painter->setGradient(VGradientEx::linear, fpStart, fpEnd, fpStart, item->GrStrokeScale, item->GrStrokeSkew); |
||
1358 | else |
||
1359 | painter->setGradient(VGradientEx::radial, fpStart, fpEnd, fpFocal, item->GrStrokeScale, item->GrStrokeSkew); |
||
1360 | } |
||
1361 | painter->strokePath(); |
||
4360 | cbradney | 1362 | } |
17313 | jghali | 1363 | else if (item->lineColor() != CommonStrings::None) |
4360 | cbradney | 1364 | { |
17313 | jghali | 1365 | ScColorShade scColor(m_doc->PageColors[item->lineColor()], item->lineShade()); |
1366 | painter->setStrokeMode(ScPainterExBase::Solid); |
||
1367 | painter->setPen(scColor, item->lineWidth(), item->PLineArt, item->PLineEnd, item->PLineJoin); |
||
1368 | if (item->DashValues.count() != 0) |
||
1369 | painter->setDash(item->DashValues, item->DashOffset); |
||
1370 | painter->strokePath(); |
||
1371 | } |
||
1372 | } |
||
1373 | else |
||
1374 | { |
||
1375 | multiLine ml = m_doc->MLineStyles[item->NamedLStyle]; |
||
1376 | for (int it = ml.size()-1; it > -1; it--) |
||
1377 | { |
||
1378 | const SingleLine& sl = ml[it]; |
||
1379 | if (sl.Color != CommonStrings::None) |
||
4360 | cbradney | 1380 | { |
17313 | jghali | 1381 | ScColorShade tmp(m_doc->PageColors[sl.Color], sl.Shade); |
1382 | painter->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash), |
||
1383 | static_cast<Qt::PenCapStyle>(sl.LineEnd), |
||
1384 | static_cast<Qt::PenJoinStyle>(sl.LineJoin)); |
||
1385 | painter->strokePath(); |
||
4360 | cbradney | 1386 | } |
1387 | } |
||
17313 | jghali | 1388 | } |
1389 | if (startArrowIndex != 0) |
||
1390 | { |
||
1391 | FPoint Start = item->PoLine.point(0); |
||
18114 | jghali | 1392 | for (int xx = 1; xx < item->PoLine.size(); xx += 2) |
4360 | cbradney | 1393 | { |
17313 | jghali | 1394 | FPoint Vector = item->PoLine.point(xx); |
1395 | if ((Start.x() != Vector.x()) || (Start.y() != Vector.y())) |
||
4360 | cbradney | 1396 | { |
17313 | jghali | 1397 | double r = atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI); |
1398 | QTransform arrowTrans; |
||
1399 | arrowTrans.translate(Start.x(), Start.y()); |
||
1400 | arrowTrans.rotate(r); |
||
1401 | drawArrow(painter, item, arrowTrans, startArrowIndex); |
||
1402 | break; |
||
4360 | cbradney | 1403 | } |
1404 | } |
||
1405 | } |
||
17313 | jghali | 1406 | if (endArrowIndex != 0) |
1407 | { |
||
1408 | FPoint End = item->PoLine.point(item->PoLine.size()-2); |
||
1409 | for (uint xx = item->PoLine.size()-1; xx > 0; xx -= 2) |
||
1410 | { |
||
1411 | FPoint Vector = item->PoLine.point(xx); |
||
1412 | if ((End.x() != Vector.x()) || (End.y() != Vector.y())) |
||
1413 | { |
||
1414 | double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI); |
||
1415 | QTransform arrowTrans; |
||
1416 | arrowTrans.translate(End.x(), End.y()); |
||
1417 | arrowTrans.rotate(r); |
||
1418 | drawArrow(painter, item, arrowTrans, endArrowIndex); |
||
1419 | break; |
||
1420 | } |
||
1421 | } |
||
1422 | } |
||
4360 | cbradney | 1423 | } |
1424 | |||
20630 | jghali | 1425 | void ScPageOutput::drawItem_RegularPolygon( PageItem_RegularPolygon* item, ScPainterExBase* painter, QRect clip ) |
17328 | jghali | 1426 | { |
1427 | painter->setupPolygon(&item->PoLine); |
||
1428 | painter->fillPath(); |
||
1429 | } |
||
1430 | |||
20630 | jghali | 1431 | void ScPageOutput::drawItem_Spiral( PageItem_Spiral* item, ScPainterExBase* painter, QRect clip ) |
17296 | jghali | 1432 | { |
17313 | jghali | 1433 | if (item->PoLine.size() < 4) |
1434 | return; |
||
1435 | |||
17296 | jghali | 1436 | int startArrowIndex = item->startArrowIndex(); |
1437 | int endArrowIndex = item->endArrowIndex(); |
||
1438 | |||
17313 | jghali | 1439 | if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0)) |
17296 | jghali | 1440 | { |
17313 | jghali | 1441 | FPointArray cli; |
1442 | FPoint Start; |
||
1443 | bool firstp = true; |
||
18114 | jghali | 1444 | for (int n = 0; n < item->PoLine.size()-3; n += 4) |
17296 | jghali | 1445 | { |
17313 | jghali | 1446 | if (firstp) |
17296 | jghali | 1447 | { |
17313 | jghali | 1448 | Start = item->PoLine.point(n); |
1449 | firstp = false; |
||
17296 | jghali | 1450 | } |
18801 | fschmid | 1451 | if (item->PoLine.isMarker(n)) |
17296 | jghali | 1452 | { |
17313 | jghali | 1453 | cli.addPoint(item->PoLine.point(n-2)); |
1454 | cli.addPoint(item->PoLine.point(n-2)); |
||
17296 | jghali | 1455 | cli.addPoint(Start); |
1456 | cli.addPoint(Start); |
||
17313 | jghali | 1457 | cli.setMarker(); |
1458 | firstp = true; |
||
1459 | continue; |
||
17296 | jghali | 1460 | } |
17313 | jghali | 1461 | cli.addPoint(item->PoLine.point(n)); |
1462 | cli.addPoint(item->PoLine.point(n+1)); |
||
1463 | cli.addPoint(item->PoLine.point(n+2)); |
||
1464 | cli.addPoint(item->PoLine.point(n+3)); |
||
17296 | jghali | 1465 | } |
17313 | jghali | 1466 | if (cli.size() > 2) |
17296 | jghali | 1467 | { |
17313 | jghali | 1468 | FPoint l1 = cli.point(cli.size()-2); |
1469 | cli.addPoint(l1); |
||
1470 | cli.addPoint(l1); |
||
1471 | cli.addPoint(Start); |
||
1472 | cli.addPoint(Start); |
||
1473 | } |
||
1474 | painter->setupPolygon(&cli); |
||
1475 | fillPath(item, painter, clip); |
||
1476 | } |
||
1477 | painter->setupPolygon(&item->PoLine, false); |
||
1478 | if (item->NamedLStyle.isEmpty()) |
||
1479 | { |
||
1480 | QString patternStrokeVal = item->strokePattern(); |
||
1481 | if ((!patternStrokeVal.isEmpty()) && (m_doc->docPatterns.contains(patternStrokeVal))) |
||
1482 | { |
||
1483 | if (item->patternStrokePath) |
||
1484 | { |
||
1485 | QPainterPath guidePath = item->PoLine.toQPainterPath(false); |
||
1486 | guidePath.moveTo(0, 0); |
||
1487 | guidePath.lineTo(item->width(), 0); |
||
1488 | drawStrokePattern(item, painter, guidePath); |
||
1489 | } |
||
1490 | else |
||
1491 | { |
||
1492 | painter->setPattern(&m_doc->docPatterns[patternStrokeVal], item->patternStrokeScaleX, item->patternStrokeScaleY, item->patternStrokeOffsetX, item->patternStrokeOffsetY, item->patternStrokeRotation, item->patternStrokeSkewX, item->patternStrokeSkewY, item->patternStrokeMirrorX, item->patternStrokeMirrorY); |
||
1493 | painter->setStrokeMode(ScPainterExBase::Pattern); |
||
17296 | jghali | 1494 | painter->strokePath(); |
17313 | jghali | 1495 | } |
17296 | jghali | 1496 | } |
17313 | jghali | 1497 | else if (item->strokeGradientType() > 0) |
17296 | jghali | 1498 | { |
17313 | jghali | 1499 | QString gradientStrokeVal = item->strokeGradient(); |
1500 | if ((!gradientStrokeVal.isEmpty()) && (!m_doc->docGradients.contains(gradientStrokeVal))) |
||
1501 | gradientStrokeVal = ""; |
||
1502 | if (!(gradientStrokeVal.isEmpty()) && (m_doc->docGradients.contains(gradientStrokeVal))) |
||
1503 | painter->m_strokeGradient = VGradientEx(m_doc->docGradients[gradientStrokeVal], *m_doc); |
||
1504 | if (painter->m_strokeGradient.Stops() < 2) // fall back to solid stroking if there are not enough colorstops in the gradient. |
||
17296 | jghali | 1505 | { |
17313 | jghali | 1506 | if (item->lineColor() != CommonStrings::None) |
17296 | jghali | 1507 | { |
17313 | jghali | 1508 | ScColorShade strokeColor(m_doc->PageColors[item->lineColor()], item->lineShade()); |
1509 | painter->setBrush(strokeColor); |
||
1510 | painter->setStrokeMode(ScPainterExBase::Solid); |
||
17296 | jghali | 1511 | } |
17313 | jghali | 1512 | else |
1513 | painter->setStrokeMode(ScPainterExBase::None); |
||
17296 | jghali | 1514 | } |
17313 | jghali | 1515 | else |
1516 | { |
||
1517 | FPoint fpStart(item->GrStrokeStartX, item->GrStrokeStartY); |
||
1518 | FPoint fpEnd(item->GrStrokeEndX, item->GrStrokeEndY); |
||
1519 | FPoint fpFocal(item->GrStrokeFocalX, item->GrStrokeFocalY); |
||
1520 | painter->setStrokeMode(ScPainterExBase::Gradient); |
||
1521 | painter->m_strokeGradient = VGradientEx(item->stroke_gradient, *m_doc); |
||
1522 | if (item->GrTypeStroke == 6) |
||
1523 | painter->setGradient(VGradientEx::linear, fpStart, fpEnd, fpStart, item->GrStrokeScale, item->GrStrokeSkew); |
||
1524 | else |
||
1525 | painter->setGradient(VGradientEx::radial, fpStart, fpEnd, fpFocal, item->GrStrokeScale, item->GrStrokeSkew); |
||
1526 | } |
||
1527 | painter->strokePath(); |
||
17296 | jghali | 1528 | } |
17313 | jghali | 1529 | else if (item->lineColor() != CommonStrings::None) |
17296 | jghali | 1530 | { |
17313 | jghali | 1531 | ScColorShade scColor(m_doc->PageColors[item->lineColor()], item->lineShade()); |
1532 | painter->setStrokeMode(ScPainterExBase::Solid); |
||
1533 | painter->setPen(scColor, item->lineWidth(), item->PLineArt, item->PLineEnd, item->PLineJoin); |
||
1534 | if (item->DashValues.count() != 0) |
||
1535 | painter->setDash(item->DashValues, item->DashOffset); |
||
1536 | painter->strokePath(); |
||
1537 | } |
||
1538 | } |
||
1539 | else |
||
1540 | { |
||
1541 | multiLine ml = m_doc->MLineStyles[item->NamedLStyle]; |
||
1542 | for (int it = ml.size()-1; it > -1; it--) |
||
1543 | { |
||
1544 | const SingleLine& sl = ml[it]; |
||
1545 | if (sl.Color != CommonStrings::None) |
||
17296 | jghali | 1546 | { |
17313 | jghali | 1547 | ScColorShade tmp(m_doc->PageColors[sl.Color], sl.Shade); |
1548 | painter->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash), |
||
1549 | static_cast<Qt::PenCapStyle>(sl.LineEnd), |
||
1550 | static_cast<Qt::PenJoinStyle>(sl.LineJoin)); |
||
1551 | painter->strokePath(); |
||
17296 | jghali | 1552 | } |
1553 | } |
||
17313 | jghali | 1554 | } |
1555 | if (startArrowIndex != 0) |
||
1556 | { |
||
1557 | FPoint Start = item->PoLine.point(0); |
||
18114 | jghali | 1558 | for (int xx = 1; xx < item->PoLine.size(); xx += 2) |
17296 | jghali | 1559 | { |
17313 | jghali | 1560 | FPoint Vector = item->PoLine.point(xx); |
1561 | if ((Start.x() != Vector.x()) || (Start.y() != Vector.y())) |
||
17296 | jghali | 1562 | { |
17313 | jghali | 1563 | double r = atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI); |
1564 | QTransform arrowTrans; |
||
1565 | arrowTrans.translate(Start.x(), Start.y()); |
||
1566 | arrowTrans.rotate(r); |
||
1567 | drawArrow(painter, item, arrowTrans, startArrowIndex); |
||
1568 | break; |
||
17296 | jghali | 1569 | } |
1570 | } |
||
1571 | } |
||
17313 | jghali | 1572 | if (endArrowIndex != 0) |
1573 | { |
||
1574 | FPoint End = item->PoLine.point(item->PoLine.size()-2); |
||
1575 | for (uint xx = item->PoLine.size()-1; xx > 0; xx -= 2) |
||
1576 | { |
||
1577 | FPoint Vector = item->PoLine.point(xx); |
||
1578 | if ((End.x() != Vector.x()) || (End.y() != Vector.y())) |
||
1579 | { |
||
1580 | double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI); |
||
1581 | QTransform arrowTrans; |
||
1582 | arrowTrans.translate(End.x(), End.y()); |
||
1583 | arrowTrans.rotate(r); |
||
1584 | drawArrow(painter, item, arrowTrans, endArrowIndex); |
||
1585 | break; |
||
1586 | } |
||
1587 | } |
||
1588 | } |
||
17296 | jghali | 1589 | } |
1590 | |||
20630 | jghali | 1591 | void ScPageOutput::drawItem_Table( PageItem_Table* item, ScPainterExBase* painter, QRect clip ) |
4360 | cbradney | 1592 | { |
20630 | jghali | 1593 | painter->save(); |
1594 | |||
1595 | // Set the clip path. |
||
1596 | painter->setupPolygon(&item->PoLine); |
||
1597 | painter->setClipPath(); |
||
1598 | |||
1599 | // Paint the table. |
||
1600 | CollapsedTablePainterEx tablePainter(this, item); |
||
1601 | tablePainter.paintTable(painter); |
||
1602 | |||
1603 | painter->restore(); |
||
1604 | } |
||
1605 | |||
1606 | void ScPageOutput::drawItem_TextFrame( PageItem_TextFrame* item, ScPainterExBase* painter, QRect cullingArea ) |
||
1607 | { |
||
13951 | fschmid | 1608 | QTransform wm; |
5580 | jghali | 1609 | QPoint pt1, pt2; |
1610 | FPoint ColBound; |
||
1611 | QRegion cm; |
||
5753 | jghali | 1612 | int a; |
17034 | jghali | 1613 | double desc, asce; |
6824 | jghali | 1614 | |
5580 | jghali | 1615 | painter->save(); |
20630 | jghali | 1616 | if (!item->isEmbedded) |
6824 | jghali | 1617 | wm.translate(item->xPos(), item->yPos()); |
5580 | jghali | 1618 | wm.rotate(item->rotation()); |
20630 | jghali | 1619 | |
5580 | jghali | 1620 | if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0)) |
1621 | { |
||
1622 | painter->setupPolygon(&item->PoLine); |
||
20630 | jghali | 1623 | fillPath(item, painter, cullingArea); |
5580 | jghali | 1624 | } |
19834 | craig | 1625 | if ((item->isAnnotation()) && (item->annotation().Type() == Annotation::Button) && (!item->Pfile.isEmpty()) && (item->imageIsAvailable) && (item->imageVisible()) && (item->annotation().UseIcons())) |
5580 | jghali | 1626 | { |
8728 | jghali | 1627 | painter->save(); |
5580 | jghali | 1628 | painter->setupPolygon(&item->PoLine); |
1629 | painter->setClipPath(); |
||
1630 | painter->scale(item->imageXScale(), item->imageYScale()); |
||
1631 | painter->translate(static_cast<int>(item->imageXOffset() * item->imageXScale()), static_cast<int>(item->imageYOffset() * item->imageYScale())); |
||
5599 | jghali | 1632 | if (!item->pixm.qImage().isNull()) |
5580 | jghali | 1633 | painter->drawImage(&item->pixm, ScPainterExBase::rgbImages); |
1634 | painter->restore(); |
||
1635 | } |
||
5729 | jghali | 1636 | if ((item->itemText.length() != 0)) |
5580 | jghali | 1637 | { |
1638 | if (item->imageFlippedH()) |
||
1639 | { |
||
6987 | jghali | 1640 | painter->translate(item->width(), 0); |
5580 | jghali | 1641 | painter->scale(-1, 1); |
20630 | jghali | 1642 | wm.translate(item->width(), 0); |
1643 | wm.scale(-1, 1); |
||
5580 | jghali | 1644 | } |
1645 | if (item->imageFlippedV()) |
||
1646 | { |
||
6987 | jghali | 1647 | painter->translate(0, item->height()); |
5580 | jghali | 1648 | painter->scale(1, -1); |
20630 | jghali | 1649 | wm.translate(0, item->height()); |
1650 | wm.scale(1, -1); |
||
5580 | jghali | 1651 | } |
17223 | jghali | 1652 | |
20638 | jghali | 1653 | for (uint ll = 0; ll < item->textLayout.lines(); ++ll) |
1654 | { |
||
1655 | const LineSpec& ls = item->textLayout.line(ll); |
||
1656 | const ParagraphStyle& lineStyle = item->itemText.paragraphStyle(ls.firstItem); |
||
1657 | // This code is for rendering paragraph background color. |
||
1658 | // We just need to define this attribute for the paragraphs now. |
||
1659 | if (lineStyle.backgroundColor() != CommonStrings::None) |
||
1660 | { |
||
1661 | painter->save(); |
||
1662 | painter->setFillMode(1); |
||
1663 | painter->setStrokeMode(0); |
||
1664 | ScColorShade colorShade(m_doc->PageColors[lineStyle.backgroundColor()], lineStyle.backgroundShade()); |
||
1665 | painter->setBrush(colorShade); |
||
1666 | double y1 = ls.y; |
||
1667 | double hl = ls.height; |
||
1668 | double adjX = 0; |
||
1669 | if (lineStyle.firstIndent() <= 0) |
||
1670 | adjX += lineStyle.leftMargin() + lineStyle.firstIndent(); |
||
1671 | if (lineStyle.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing) |
||
1672 | hl = item->doc()->guidesPrefs().valueBaselineGrid; |
||
1673 | else if (lineStyle.lineSpacingMode() == ParagraphStyle::FixedLineSpacing) |
||
1674 | hl = lineStyle.lineSpacing(); |
||
1675 | if (ls.isFirstLine) |
||
1676 | { |
||
1677 | if (item->textLayout.lines() == 1) |
||
1678 | hl = ls.ascent + ls.descent; |
||
1679 | if (lineStyle.hasDropCap()) |
||
1680 | hl *= lineStyle.dropCapLines(); |
||
1681 | } |
||
1682 | if (lineStyle.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing) |
||
1683 | y1 -= lineStyle.lineSpacing(); |
||
1684 | else if (item->firstLineOffset() == FLOPRealGlyphHeight || item->firstLineOffset() == FLOPFontAscent) |
||
1685 | y1 -= ls.ascent; |
||
1686 | else |
||
1687 | y1 -= ls.ascent + (hl - (ls.ascent + ls.descent)) / 2.0; |
||
1688 | painter->drawRect(ls.colLeft + adjX, y1, item->columnWidth() - adjX - lineStyle.rightMargin(), hl); |
||
1689 | painter->restore(); |
||
1690 | } |
||
1691 | // end background code |
||
1692 | } |
||
1693 | |||
18987 | avox | 1694 | for (uint ll=0; ll < item->textLayout.lines(); ++ll) |
5580 | jghali | 1695 | { |
18987 | avox | 1696 | LineSpec ls = item->textLayout.line(ll); |
6824 | jghali | 1697 | double CurX = ls.x; |
20638 | jghali | 1698 | |
1699 | // Draw text background |
||
1700 | ScColorShade tmpShade; |
||
1701 | double curXB = ls.x; |
||
1702 | QRectF scrG; |
||
1703 | QString oldBack; |
||
1704 | double oldShade = 100; |
||
1705 | for (int a = ls.firstItem; a <= ls.lastItem; ++a) |
||
1706 | { |
||
1707 | GlyphLayout* glyphs = item->itemText.getGlyphs(a); |
||
1708 | const CharStyle& charStyle(item->itemText.charStyle(a)); |
||
1709 | if (charStyle.backColor() != CommonStrings::None) |
||
1710 | { |
||
1711 | tmpShade.color = m_doc->PageColors[charStyle.backColor()]; |
||
1712 | tmpShade.shade = charStyle.backShade(); |
||
1713 | const ParagraphStyle& lineStyle = item->itemText.paragraphStyle(ls.firstItem); |
||
1714 | double y1 = ls.y; |
||
1715 | double hl = ls.height; |
||
1716 | if (lineStyle.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing) |
||
1717 | hl = m_doc->guidesPrefs().valueBaselineGrid; |
||
1718 | else if (lineStyle.lineSpacingMode() == ParagraphStyle::FixedLineSpacing) |
||
1719 | hl = lineStyle.lineSpacing(); |
||
1720 | if (ls.isFirstLine) |
||
1721 | { |
||
1722 | if (item->textLayout.lines() == 1) |
||
1723 | hl = ls.ascent + ls.descent; |
||
1724 | if (lineStyle.hasDropCap() && (a == ls.firstItem)) |
||
1725 | hl *= lineStyle.dropCapLines(); |
||
1726 | if (lineStyle.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing) |
||
1727 | y1 -= lineStyle.lineSpacing(); |
||
1728 | else if (item->firstLineOffset() == FLOPRealGlyphHeight || item->firstLineOffset() == FLOPFontAscent) |
||
1729 | y1 -= ls.ascent; |
||
1730 | else |
||
1731 | y1 -= lineStyle.lineSpacing(); |
||
1732 | } |
||
1733 | else |
||
1734 | y1 -= ls.ascent + (hl - (ls.ascent + ls.descent)) / 2.0; |
||
1735 | QRectF scr; |
||
1736 | if (item->itemText.hasObject(a)) |
||
1737 | { |
||
1738 | PageItem* obj = item->itemText.object(a); |
||
1739 | double ww = (obj->width() + obj->lineWidth()) * glyphs->scaleH; |
||
1740 | double hh = (obj->height() + obj->lineWidth()) * glyphs->scaleV; |
||
1741 | scr = QRectF(curXB, ls.y - hh, ww , hh); |
||
1742 | } |
||
1743 | else |
||
1744 | scr = QRectF(curXB, y1, glyphs->wide(), hl); |
||
1745 | if ((oldBack.isEmpty()) || ((oldBack == charStyle.backColor()) && (oldShade == charStyle.backShade()))) |
||
1746 | scrG |= scr; |
||
1747 | else if ((oldBack != charStyle.backColor()) || (oldShade != charStyle.backShade())) |
||
1748 | { |
||
1749 | tmpShade.color = m_doc->PageColors[oldBack]; |
||
1750 | tmpShade.shade = oldShade; |
||
1751 | painter->save(); |
||
1752 | painter->setFillMode(1); |
||
1753 | painter->setStrokeMode(0); |
||
1754 | painter->setBrush(tmpShade); |
||
1755 | painter->drawRect(scrG.x(), scrG.y(), scrG.width(), scrG.height()); |
||
1756 | painter->restore(); |
||
1757 | scrG = scr; |
||
1758 | } |
||
1759 | oldBack = charStyle.backColor(); |
||
1760 | oldShade = charStyle.backShade(); |
||
1761 | } |
||
1762 | else |
||
1763 | { |
||
1764 | oldBack.clear(); |
||
1765 | oldShade = 100; |
||
1766 | if (!scrG.isNull()) |
||
1767 | { |
||
1768 | painter->save(); |
||
1769 | painter->setFillMode(1); |
||
1770 | painter->setStrokeMode(0); |
||
1771 | painter->setBrush(tmpShade); |
||
1772 | painter->drawRect(scrG.x(), scrG.y(), scrG.width(), scrG.height()); |
||
1773 | painter->restore(); |
||
1774 | } |
||
1775 | scrG = QRectF(); |
||
1776 | } |
||
1777 | curXB += glyphs->wide(); |
||
1778 | } |
||
1779 | if (!scrG.isNull()) |
||
1780 | { |
||
1781 | painter->save(); |
||
1782 | painter->setFillMode(1); |
||
1783 | painter->setStrokeMode(0); |
||
1784 | painter->setBrush(tmpShade); |
||
1785 | painter->drawRect(scrG.x(), scrG.y(), scrG.width(), scrG.height()); |
||
1786 | painter->restore(); |
||
1787 | } |
||
1788 | |||
1789 | // Draw text |
||
6824 | jghali | 1790 | for (a = ls.firstItem; a <= ls.lastItem; ++a) |
4360 | cbradney | 1791 | { |
20630 | jghali | 1792 | GlyphLayout* glyphs = item->itemText.getGlyphs(a); |
10227 | jghali | 1793 | const CharStyle& charStyle = item->itemText.charStyle(a); |
17635 | jghali | 1794 | |
6824 | jghali | 1795 | if (charStyle.fillColor() != CommonStrings::None) |
4360 | cbradney | 1796 | { |
20630 | jghali | 1797 | ScColorShade tmp(m_doc->PageColors[charStyle.fillColor()], (int) charStyle.fillShade()); |
6824 | jghali | 1798 | painter->setBrush(tmp); |
4360 | cbradney | 1799 | } |
6824 | jghali | 1800 | if (charStyle.strokeColor() != CommonStrings::None) |
4360 | cbradney | 1801 | { |
20630 | jghali | 1802 | ScColorShade tmp(m_doc->PageColors[charStyle.strokeColor()], (int) charStyle.strokeShade()); |
6824 | jghali | 1803 | painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
4360 | cbradney | 1804 | } |
17635 | jghali | 1805 | |
6824 | jghali | 1806 | //if (!m_doc->RePos) |
5580 | jghali | 1807 | { |
20630 | jghali | 1808 | //double xcoZli = CurX + glyphs->xoffset; |
6824 | jghali | 1809 | desc = - charStyle.font().descent(charStyle.fontSize() / 10.0); |
1810 | asce = charStyle.font().ascent(charStyle.fontSize() / 10.0); |
||
1811 | if (charStyle.strokeColor() != CommonStrings::None) |
||
1812 | { |
||
10227 | jghali | 1813 | ScColorShade tmp(m_doc->PageColors[charStyle.strokeColor()], (int) charStyle.strokeShade()); |
6824 | jghali | 1814 | painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
1815 | } |
||
2063 |