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