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