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