Rev 12217 | Rev 12996 | 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); |
535 | // qDebug(QString("glyphscale: %1 %2").arg(glyphs.scaleH).arg(glyphs.scaleV)); |
||
6824 | jghali | 536 | FPointArray gly = style.font().glyphOutline(glyph); |
5988 | jghali | 537 | // Do underlining first so you can get typographically correct |
538 | // underlines when drawing a white outline |
||
6824 | jghali | 539 | if ((style.effects() & ScStyle_Underline) || ((style.effects() & ScStyle_UnderlineWords) && (glyph != style.font().char2CMap(QChar(' '))))) |
5988 | jghali | 540 | { |
541 | double st, lw; |
||
6824 | jghali | 542 | if ((style.underlineOffset() != -1) || (style.underlineWidth() != -1)) |
5988 | jghali | 543 | { |
6824 | jghali | 544 | if (style.underlineOffset() != -1) |
545 | st = (style.underlineOffset() / 1000.0) * (style.font().descent(style.fontSize() / 10.0)); |
||
5988 | jghali | 546 | else |
547 | st = style.font().underlinePos(style.fontSize() / 10.0); |
||
548 | if (style.underlineWidth() != -1) |
||
549 | lw = (style.underlineWidth() / 1000.0) * (style.fontSize() / 10.0); |
||
550 | else |
||
8578 | jghali | 551 | lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0); |
5988 | jghali | 552 | } |
553 | else |
||
554 | { |
||
555 | st = style.font().underlinePos(style.fontSize() / 10.0); |
||
8578 | jghali | 556 | lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0); |
5988 | jghali | 557 | } |
558 | if (style.baselineOffset() != 0) |
||
559 | st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0); |
||
6824 | jghali | 560 | ScColorShade tmpPen = painter->pen(); |
5988 | jghali | 561 | painter->setPen(painter->brush()); |
562 | painter->setLineWidth(lw); |
||
8728 | jghali | 563 | if (style.effects() & ScStyle_Subscript) |
564 | painter->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st)); |
||
565 | else |
||
566 | painter->drawLine(FPoint(glyphs.xoffset, -st), FPoint(glyphs.xoffset + glyphs.xadvance, -st)); |
||
6824 | jghali | 567 | painter->setPen(tmpPen); |
5988 | jghali | 568 | } |
4360 | cbradney | 569 | if (gly.size() > 3) |
570 | { |
||
8728 | jghali | 571 | painter->save(); |
572 | painter->translate(glyphs.xoffset, glyphs.yoffset - ((style.fontSize() / 10.0) * glyphs.scaleV)); |
||
4360 | cbradney | 573 | if (item->reversed()) |
574 | { |
||
8728 | jghali | 575 | painter->scale(-1, 1); |
576 | painter->translate(-glyphs.xadvance, 0); |
||
4360 | cbradney | 577 | } |
5988 | jghali | 578 | if (style.baselineOffset() != 0) |
8728 | jghali | 579 | painter->translate(0, -(style.fontSize() / 10.0) * (style.baselineOffset() / 1000.0)); |
580 | double glxSc = glyphs.scaleH * style.fontSize() / 100.00; |
||
581 | double glySc = glyphs.scaleV * style.fontSize() / 100.0; |
||
582 | painter->scale(glxSc, glySc); |
||
6987 | jghali | 583 | painter->setFillMode(ScPainterExBase::Solid); |
4360 | cbradney | 584 | bool fr = painter->fillRule(); |
585 | painter->setFillRule(false); |
||
11869 | jghali | 586 | painter->setupPolygon(&gly, true); |
8728 | jghali | 587 | if (glyph == 0) |
5988 | jghali | 588 | { |
8728 | jghali | 589 | ScColorShade tmp(PrefsManager::instance()->appPrefs.DControlCharColor, 100); |
590 | painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
||
591 | painter->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() * 2 / 10000.0); |
||
592 | painter->strokePath(); |
||
593 | } |
||
594 | else if ((style.font().isStroked()) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0)) |
||
595 | { |
||
5988 | jghali | 596 | ScColorShade tmp = painter->brush(); |
597 | painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
||
598 | painter->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0); |
||
599 | painter->strokePath(); |
||
600 | } |
||
4360 | cbradney | 601 | else |
602 | { |
||
5988 | jghali | 603 | if ((style.effects() & ScStyle_Shadowed) && (style.strokeColor() != CommonStrings::None)) |
4360 | cbradney | 604 | { |
605 | painter->save(); |
||
8728 | jghali | 606 | painter->translate((style.fontSize() * glyphs.scaleH * style.shadowXOffset() / 10000.0) / glxSc, -(style.fontSize() * glyphs.scaleV * style.shadowYOffset() / 10000.0) / glySc); |
4360 | cbradney | 607 | ScColorShade tmp = painter->brush(); |
608 | painter->setBrush(painter->pen()); |
||
11869 | jghali | 609 | painter->setupPolygon(&gly, true); |
11905 | jghali | 610 | fillPath(item, painter, clip); |
4360 | cbradney | 611 | painter->setBrush(tmp); |
612 | painter->restore(); |
||
11869 | jghali | 613 | painter->setupPolygon(&gly, true); |
4360 | cbradney | 614 | } |
5988 | jghali | 615 | if (style.fillColor() != CommonStrings::None) |
11905 | jghali | 616 | fillPath(item, painter, clip); |
5988 | jghali | 617 | if ((style.effects() & ScStyle_Outline) && (style.strokeColor() != CommonStrings::None) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0)) |
4360 | cbradney | 618 | { |
8728 | jghali | 619 | painter->setLineWidth((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) / glySc); |
4360 | cbradney | 620 | painter->strokePath(); |
621 | } |
||
622 | } |
||
623 | painter->setFillRule(fr); |
||
8728 | jghali | 624 | painter->restore(); |
4360 | cbradney | 625 | } |
5988 | jghali | 626 | if (style.effects() & ScStyle_Strikethrough) |
4360 | cbradney | 627 | { |
628 | double st, lw; |
||
5988 | jghali | 629 | if ((style.strikethruOffset() != -1) || (style.strikethruWidth() != -1)) |
4360 | cbradney | 630 | { |
5988 | jghali | 631 | if (style.strikethruOffset() != -1) |
632 | st = (style.strikethruOffset() / 1000.0) * (style.font().ascent(style.fontSize() / 10.0)); |
||
4360 | cbradney | 633 | else |
5988 | jghali | 634 | st = style.font().strikeoutPos(style.fontSize() / 10.0); |
635 | if (style.strikethruWidth() != -1) |
||
636 | lw = (style.strikethruWidth() / 1000.0) * (style.fontSize() / 10.0); |
||
4360 | cbradney | 637 | else |
8578 | jghali | 638 | lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0); |
4360 | cbradney | 639 | } |
640 | else |
||
641 | { |
||
5988 | jghali | 642 | st = style.font().strikeoutPos(style.fontSize() / 10.0); |
8578 | jghali | 643 | lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0); |
4360 | cbradney | 644 | } |
5988 | jghali | 645 | if (style.baselineOffset() != 0) |
646 | st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0); |
||
4360 | cbradney | 647 | painter->setPen(painter->brush()); |
648 | painter->setLineWidth(lw); |
||
5988 | jghali | 649 | painter->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st)); |
4360 | cbradney | 650 | } |
651 | } |
||
6824 | jghali | 652 | /*else |
4360 | cbradney | 653 | { |
654 | painter->setLineWidth(1); |
||
5988 | jghali | 655 | painter->setPen(ScColorShade(Qt::red, 100)); |
656 | painter->setBrush(ScColorShade(Qt::red, 100)); |
||
4360 | cbradney | 657 | painter->setFillMode(1); |
5988 | jghali | 658 | 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 | 659 | }*/ |
5988 | jghali | 660 | if (glyphs.more) |
6824 | jghali | 661 | { |
6987 | jghali | 662 | painter->translate(glyphs.xadvance, 0); |
11905 | jghali | 663 | drawGlyphs(item, painter, style, *glyphs.more, clip); |
6824 | jghali | 664 | } |
4360 | cbradney | 665 | } |
666 | |||
11905 | jghali | 667 | void ScPageOutput::drawItem_Embedded( PageItem* item, ScPainterExBase *p, const QRect& clip, const CharStyle& style, PageItem* cembedded) |
4360 | cbradney | 668 | { |
8728 | jghali | 669 | if (!cembedded) |
670 | return; |
||
9856 | fschmid | 671 | QList<PageItem*> emG; |
9922 | fschmid | 672 | QStack<PageItem*> groupStack; |
8728 | jghali | 673 | emG.append(cembedded); |
674 | if (cembedded->Groups.count() != 0) |
||
4360 | cbradney | 675 | { |
9859 | jghali | 676 | for (int ga=0; ga < m_doc->FrameItems.count(); ++ga) |
4360 | cbradney | 677 | { |
8728 | jghali | 678 | if (m_doc->FrameItems.at(ga)->Groups.count() != 0) |
4360 | cbradney | 679 | { |
8728 | jghali | 680 | if (m_doc->FrameItems.at(ga)->Groups.top() == cembedded->Groups.top()) |
4360 | cbradney | 681 | { |
8728 | jghali | 682 | if (m_doc->FrameItems.at(ga)->ItemNr != cembedded->ItemNr) |
4360 | cbradney | 683 | { |
9856 | fschmid | 684 | if (!emG.contains(m_doc->FrameItems.at(ga))) |
8728 | jghali | 685 | emG.append(m_doc->FrameItems.at(ga)); |
4360 | cbradney | 686 | } |
687 | } |
||
688 | } |
||
689 | } |
||
8728 | jghali | 690 | } |
9856 | fschmid | 691 | for (int em = 0; em < emG.count(); ++em) |
8728 | jghali | 692 | { |
693 | PageItem* embedded = emG.at(em); |
||
694 | if (embedded->isGroupControl) |
||
695 | { |
||
4360 | cbradney | 696 | p->save(); |
8728 | jghali | 697 | FPointArray cl = embedded->PoLine.copy(); |
10030 | cbradney | 698 | QMatrix mm; |
12302 | jghali | 699 | mm.translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0))); |
700 | if (style.baselineOffset() != 0) |
||
701 | mm.translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0)); |
||
702 | mm.scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0); |
||
8728 | jghali | 703 | cl.map( mm ); |
704 | groupStack.push(embedded->groupsLastItem); |
||
705 | continue; |
||
706 | } |
||
12302 | jghali | 707 | p->save(); |
708 | double x = embedded->xPos(); |
||
709 | double y = embedded->yPos(); |
||
710 | embedded->setXPos( embedded->gXpos, true ); |
||
711 | embedded->setYPos((embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos, true ); |
||
712 | p->translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0))); |
||
713 | if (style.baselineOffset() != 0) |
||
714 | { |
||
715 | p->translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0)); |
||
716 | embedded->setYPos( embedded->yPos() - embedded->gHeight * (style.baselineOffset() / 1000.0) ); |
||
717 | } |
||
718 | p->scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0); |
||
8728 | jghali | 719 | double pws = embedded->m_lineWidth; |
11905 | jghali | 720 | drawItem_Pre(embedded, p); |
8728 | jghali | 721 | switch(embedded->itemType()) |
722 | { |
||
723 | case PageItem::ImageFrame: |
||
10321 | mrdocs | 724 | case PageItem::LatexFrame: |
8728 | jghali | 725 | case PageItem::TextFrame: |
726 | case PageItem::Polygon: |
||
727 | case PageItem::PathText: |
||
11905 | jghali | 728 | drawItem(embedded, p, clip); |
8728 | jghali | 729 | break; |
730 | case PageItem::Line: |
||
731 | case PageItem::PolyLine: |
||
732 | embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0); |
||
11905 | jghali | 733 | drawItem(embedded, p, clip); |
8728 | jghali | 734 | break; |
735 | default: |
||
736 | break; |
||
737 | } |
||
738 | embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0); |
||
11905 | jghali | 739 | drawItem_Post(embedded, p); |
12302 | jghali | 740 | embedded->setXPos(x, true); |
741 | embedded->setYPos(y, true); |
||
8728 | jghali | 742 | p->restore(); |
743 | if (groupStack.count() != 0) |
||
744 | { |
||
745 | while (embedded == groupStack.top()) |
||
4360 | cbradney | 746 | { |
8728 | jghali | 747 | p->restore(); |
748 | groupStack.pop(); |
||
9827 | fschmid | 749 | if (groupStack.count() == 0) |
750 | break; |
||
4360 | cbradney | 751 | } |
752 | } |
||
8728 | jghali | 753 | embedded->m_lineWidth = pws; |
4360 | cbradney | 754 | } |
12302 | jghali | 755 | for (int em = 0; em < emG.count(); ++em) |
756 | { |
||
757 | PageItem* embedded = emG.at(em); |
||
758 | if (!embedded->isTableItem) |
||
759 | continue; |
||
760 | p->save(); |
||
761 | double x = embedded->xPos(); |
||
762 | double y = embedded->yPos(); |
||
763 | embedded->setXPos(embedded->gXpos, true); |
||
764 | embedded->setYPos ((embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos, true); |
||
765 | p->translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0))); |
||
766 | if (style.baselineOffset() != 0) |
||
767 | { |
||
768 | p->translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0)); |
||
769 | embedded->setYPos(embedded->yPos() - embedded->gHeight * (style.baselineOffset() / 1000.0)); |
||
770 | } |
||
771 | p->scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0); |
||
772 | p->rotate(embedded->rotation()); |
||
773 | double pws = embedded->m_lineWidth; |
||
774 | embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0); |
||
775 | if ((embedded->lineColor() != CommonStrings::None) && (embedded->lineWidth() != 0.0)) |
||
776 | { |
||
777 | ScColorShade colorShade(m_doc->PageColors[embedded->lineColor()], embedded->lineShade()); |
||
778 | if ((embedded->TopLine) || (embedded->RightLine) || (embedded->BottomLine) || (embedded->LeftLine)) |
||
779 | { |
||
780 | p->setPen(colorShade, embedded->lineWidth(), embedded->PLineArt, Qt::SquareCap, embedded->PLineJoin); |
||
781 | if (embedded->TopLine) |
||
782 | p->drawLine(FPoint(0.0, 0.0), FPoint(embedded->width(), 0.0)); |
||
783 | if (embedded->RightLine) |
||
784 | p->drawLine(FPoint(embedded->width(), 0.0), FPoint(embedded->width(), embedded->height())); |
||
785 | if (embedded->BottomLine) |
||
786 | p->drawLine(FPoint(embedded->width(), embedded->height()), FPoint(0.0, embedded->height())); |
||
787 | if (embedded->LeftLine) |
||
788 | p->drawLine(FPoint(0.0, embedded->height()), FPoint(0.0, 0.0)); |
||
789 | } |
||
790 | } |
||
791 | embedded->m_lineWidth = pws; |
||
792 | embedded->setXPos(x, true); |
||
793 | embedded->setYPos(y, true); |
||
794 | p->restore(); |
||
795 | } |
||
4360 | cbradney | 796 | } |
797 | |||
11905 | jghali | 798 | void ScPageOutput::drawPattern( PageItem* item, ScPainterExBase* painter, const QRect& clip) |
4360 | cbradney | 799 | { |
6987 | jghali | 800 | double x1, x2, y1, y2; |
801 | ScPattern& pattern = m_doc->docPatterns[item->pattern()]; |
||
802 | double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation; |
||
803 | item->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation); |
||
804 | |||
805 | // Compute pattern tansformation matrix and its inverse for converting pattern coordinates |
||
806 | // to pageitem coordinates |
||
10030 | cbradney | 807 | QMatrix matrix, invMat; |
6987 | jghali | 808 | matrix.translate(patternOffsetX, patternOffsetY); |
809 | matrix.rotate(patternRotation); |
||
810 | matrix.scale(pattern.scaleX, pattern.scaleY); |
||
811 | matrix.scale(patternScaleX / 100.0 , patternScaleY / 100.0); |
||
812 | invMat.scale((patternScaleX != 0) ? (100 /patternScaleX) : 1.0, (patternScaleY != 0) ? (100 /patternScaleY) : 1.0); |
||
813 | invMat.scale((pattern.scaleX != 0) ? (1 /pattern.scaleX) : 1.0, (pattern.scaleY != 0) ? (1 /pattern.scaleY) : 1.0); |
||
814 | invMat.rotate(-patternRotation); |
||
815 | invMat.translate(-patternOffsetX, -patternOffsetY); |
||
816 | |||
817 | // Compute bounding box in which pattern item will be drawn |
||
818 | double width = item->width(); |
||
819 | double height = item->height(); |
||
820 | double rot = patternRotation - floor(patternRotation / 90) * 90; |
||
821 | double ctheta = cos(rot * M_PI / 180); |
||
822 | double stheta = sin(rot * M_PI / 180); |
||
10227 | jghali | 823 | QRectF itemRect(0.0, 0.0, item->width(), item->height()); |
824 | QPointF pa( width * stheta * stheta, -width * stheta * ctheta ); |
||
825 | QPointF pb( width + height * ctheta * stheta, height * stheta * stheta ); |
||
826 | QPointF pc( -height * ctheta * stheta, height * ctheta * ctheta ); |
||
827 | QPointF pd( width * ctheta * ctheta, height + width * ctheta * stheta ); |
||
828 | QPointF ipa = invMat.map(pa), ipb = invMat.map(pb); |
||
829 | QPointF ipc = invMat.map(pc), ipd = invMat.map(pd); |
||
6987 | jghali | 830 | |
831 | painter->save(); |
||
832 | if (item->imageClip.size() != 0) |
||
833 | { |
||
834 | painter->setupPolygon(&item->imageClip); |
||
835 | painter->setClipPath(); |
||
836 | } |
||
837 | painter->setupPolygon(&item->PoLine); |
||
838 | painter->setClipPath(); |
||
9859 | jghali | 839 | for (int index = 0; index < pattern.items.count(); index++) |
6987 | jghali | 840 | { |
10227 | jghali | 841 | QRectF itRect; |
6987 | jghali | 842 | PageItem* it = pattern.items.at(index); |
843 | if (it->isGroupControl) |
||
844 | continue; |
||
845 | |||
846 | painter->save(); |
||
847 | painter->translate(patternOffsetX, patternOffsetY); |
||
848 | painter->rotate(patternRotation); |
||
849 | painter->scale(pattern.scaleX, pattern.scaleY); |
||
850 | painter->scale(patternScaleX / 100.0, patternScaleY / 100.0); |
||
851 | |||
852 | double patWidth = (pattern.width != 0.0) ? pattern.width : 1.0; |
||
853 | double patHeight = (pattern.height != 0.0) ? pattern.height : 1.0; |
||
854 | double kxa = (ipa.x() - it->gXpos) / patWidth; |
||
855 | double kxb = (ipb.x() - it->gXpos) / patWidth; |
||
856 | double kxc = (ipc.x() - it->gXpos) / patWidth; |
||
857 | double kxd = (ipd.x() - it->gXpos) / patWidth; |
||
858 | double kya = (ipa.y() - it->gYpos) / patHeight; |
||
859 | double kyb = (ipb.y() - it->gYpos) / patHeight; |
||
860 | double kyc = (ipc.y() - it->gYpos) / patHeight; |
||
861 | double kyd = (ipd.y() - it->gYpos) / patHeight; |
||
10227 | jghali | 862 | int kxMin = (int) floor( qMin(qMin(kxa, kxb), qMin(kxc, kxd)) ); |
863 | int kxMax = (int) ceil ( qMax(qMax(kxa, kxb), qMax(kxc, kxd)) ); |
||
864 | int kyMin = (int) floor( qMin(qMin(kya, kyb), qMin(kyc, kyd)) ); |
||
865 | int kyMax = (int) ceil ( qMax(qMax(kya, kyb), qMax(kyc, kyd)) ); |
||
6987 | jghali | 866 | |
867 | double itx = it->xPos(); |
||
868 | double ity = it->yPos(); |
||
869 | double itPosX = it->gXpos, itPosY = it->gYpos; |
||
870 | for ( int kx = kxMin; kx <= kxMax; kx++ ) |
||
871 | { |
||
872 | for ( int ky = kyMin; ky <= kyMax; ky++ ) |
||
873 | { |
||
874 | itPosX = it->gXpos + kx * pattern.width; |
||
875 | itPosY = it->gYpos + ky * pattern.height; |
||
876 | it->setXYPos(itPosX, itPosY); |
||
877 | it->getBoundingRect(&x1, &y1, &x2, &y2); |
||
878 | itRect.setCoords(x1, y1, x2, y2); |
||
879 | itRect = matrix.mapRect( itRect ); |
||
880 | if ( itRect.intersects(itemRect) ) |
||
11905 | jghali | 881 | drawItem(it, painter, clip); |
6987 | jghali | 882 | } |
883 | } |
||
884 | it->setXYPos(itx, ity); |
||
885 | painter->restore(); |
||
886 | } |
||
887 | painter->restore(); |
||
888 | } |
||
889 | |||
11905 | jghali | 890 | void ScPageOutput::drawItem_ImageFrame( PageItem_ImageFrame* item, ScPainterExBase* painter, const QRect& clip ) |
6987 | jghali | 891 | { |
4989 | cbradney | 892 | ScPainterExBase::ImageMode mode = ScPainterExBase::rgbImages; |
4546 | subik | 893 | if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0)) |
4360 | cbradney | 894 | { |
895 | painter->setupPolygon(&item->PoLine); |
||
11905 | jghali | 896 | fillPath(item, painter, clip); |
4360 | cbradney | 897 | } |
898 | if (item->Pfile.isEmpty()) |
||
899 | { |
||
9849 | jghali | 900 | /*painter->setPen( ScColorShade(Qt::black, 100), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
6987 | jghali | 901 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), item->height())); |
9849 | jghali | 902 | painter->drawLine(FPoint(0, item->height()), FPoint(item->width(), 0));*/ |
4360 | cbradney | 903 | } |
904 | else |
||
905 | { |
||
4506 | cbradney | 906 | if ((!item->imageShown()) || (!item->PicAvail)) |
4360 | cbradney | 907 | { |
9849 | jghali | 908 | /*painter->setPen( ScColorShade(Qt::red, 100), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
6987 | jghali | 909 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), item->height())); |
9849 | jghali | 910 | painter->drawLine(FPoint(0, item->height()), FPoint(item->width(), 0));*/ |
4360 | cbradney | 911 | } |
912 | else |
||
913 | { |
||
914 | ScImage scImg; |
||
915 | ScImage* pImage = NULL; |
||
916 | double imScaleX = item->imageXScale(); |
||
917 | double imScaleY = item->imageYScale(); |
||
918 | if( m_reloadImages ) |
||
919 | { |
||
920 | bool dummy; |
||
4617 | avox | 921 | bool useCmyk = false; |
4751 | cbradney | 922 | ScPainterExBase::ImageMode imageMode = painter->imageMode(); |
923 | if ( imageMode == ScPainterExBase::cmykImages ) |
||
4617 | avox | 924 | useCmyk = true; |
4360 | cbradney | 925 | QFileInfo fInfo(item->Pfile); |
10508 | cbradney | 926 | QString ext = fInfo.suffix(); |
5959 | jghali | 927 | CMSettings cmsSettings(item->doc(), item->IProfile, item->IRender); |
4360 | cbradney | 928 | scImg.imgInfo.valid = false; |
929 | scImg.imgInfo.clipPath = ""; |
||
930 | scImg.imgInfo.PDSpathData.clear(); |
||
931 | scImg.imgInfo.layerInfo.clear(); |
||
932 | scImg.imgInfo.RequestProps = item->pixm.imgInfo.RequestProps; |
||
933 | scImg.imgInfo.isRequest = item->pixm.imgInfo.isRequest; |
||
12141 | avox | 934 | scImg.LoadPicture(item->Pfile, item->pixm.imgInfo.actualPageNumber, cmsSettings, item->UseEmbedded, m_useProfiles, translateImageModeToRequest(imageMode), m_imageRes, &dummy); |
10136 | cbradney | 935 | if( extensionIndicatesEPSorPS(ext) || extensionIndicatesPDF(ext) ) |
4360 | cbradney | 936 | { |
937 | imScaleX *= (72.0 / (double) m_imageRes); |
||
938 | imScaleY *= (72.0 / (double) m_imageRes); |
||
939 | } |
||
4617 | avox | 940 | scImg.applyEffect(item->effectsInUse, m_doc->PageColors, useCmyk); |
4989 | cbradney | 941 | mode = imageMode; |
4360 | cbradney | 942 | pImage = &scImg; |
943 | } |
||
944 | else |
||
945 | pImage = &item->pixm; |
||
946 | |||
947 | painter->save(); |
||
948 | if (item->imageClip.size() != 0) |
||
4751 | cbradney | 949 | { |
4360 | cbradney | 950 | painter->setupPolygon(&item->imageClip); |
4751 | cbradney | 951 | painter->setClipPath(); |
952 | } |
||
953 | painter->setupPolygon(&item->PoLine); |
||
4360 | cbradney | 954 | painter->setClipPath(); |
955 | if (item->imageFlippedH()) |
||
956 | { |
||
6987 | jghali | 957 | painter->translate(item->width(), 0); |
4360 | cbradney | 958 | painter->scale(-1, 1); |
959 | } |
||
960 | if (item->imageFlippedV()) |
||
961 | { |
||
6987 | jghali | 962 | painter->translate(0, item->height()); |
4360 | cbradney | 963 | painter->scale(1, -1); |
964 | } |
||
6987 | jghali | 965 | painter->translate(item->imageXOffset() * item->imageXScale(), item->imageYOffset() * item->imageYScale()); |
4360 | cbradney | 966 | //painter->translate(item->LocalX * imScaleX * scale, item->LocalY * imScaleY * scale); ?? |
967 | painter->scale( imScaleX, imScaleY ); |
||
968 | if (pImage->imgInfo.lowResType != 0) |
||
969 | painter->scale(pImage->imgInfo.lowResScale, pImage->imgInfo.lowResScale); |
||
4989 | cbradney | 970 | painter->drawImage(pImage, mode); |
4360 | cbradney | 971 | painter->restore(); |
972 | } |
||
973 | } |
||
974 | } |
||
975 | |||
11905 | jghali | 976 | void ScPageOutput::drawItem_Line( PageItem_Line* item, ScPainterExBase* painter, const QRect& clip ) |
4360 | cbradney | 977 | { |
978 | int startArrowIndex; |
||
979 | int endArrowIndex; |
||
4546 | subik | 980 | |
4360 | cbradney | 981 | startArrowIndex = item->startArrowIndex(); |
982 | endArrowIndex = item->endArrowIndex(); |
||
983 | |||
984 | if (item->NamedLStyle.isEmpty()) |
||
985 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), 0)); |
||
986 | else |
||
987 | { |
||
988 | multiLine ml = m_doc->MLineStyles[item->NamedLStyle]; |
||
989 | for (int it = ml.size()-1; it > -1; it--) |
||
990 | { |
||
7143 | jghali | 991 | const SingleLine& sl = ml[it]; |
992 | if ((sl.Color != CommonStrings::None) && (sl.Width != 0)) |
||
993 | { |
||
994 | ScColorShade tmp(m_doc->PageColors[sl.Color], sl.Shade); |
||
995 | painter->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash), |
||
996 | static_cast<Qt::PenCapStyle>(sl.LineEnd), |
||
997 | static_cast<Qt::PenJoinStyle>(sl.LineJoin)); |
||
998 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), 0)); |
||
999 | } |
||
4360 | cbradney | 1000 | } |
1001 | } |
||
1002 | if (startArrowIndex != 0) |
||
1003 | { |
||
10030 | cbradney | 1004 | QMatrix arrowTrans; |
9803 | fschmid | 1005 | FPointArray arrow = m_doc->arrowStyles.at(startArrowIndex - 1).points.copy(); |
4360 | cbradney | 1006 | arrowTrans.translate( 0, 0 ); |
1007 | arrowTrans.scale( item->lineWidth(), item->lineWidth()); |
||
1008 | arrowTrans.scale( -1 , 1 ); |
||
1009 | arrow.map( arrowTrans ); |
||
1010 | painter->setBrush( painter->pen() ); |
||
1011 | painter->setBrushOpacity( 1.0 - item->lineTransparency() ); |
||
1012 | painter->setLineWidth( 0 ); |
||
1013 | painter->setFillMode(ScPainterExBase::Solid); |
||
1014 | painter->setupPolygon( &arrow ); |
||
11905 | jghali | 1015 | fillPath(item, painter, clip); |
4360 | cbradney | 1016 | } |
1017 | if (endArrowIndex != 0) |
||
1018 | { |
||
10030 | cbradney | 1019 | QMatrix arrowTrans; |
9803 | fschmid | 1020 | FPointArray arrow = m_doc->arrowStyles.at(endArrowIndex-1).points.copy(); |
4360 | cbradney | 1021 | arrowTrans.translate( item->width(), 0 ); |
1022 | arrowTrans.scale( item->lineWidth(), item->lineWidth()); |
||
1023 | arrow.map( arrowTrans ); |
||
1024 | painter->setBrush( painter->pen() ); |
||
1025 | painter->setBrushOpacity( 1.0 - item->lineTransparency() ); |
||
1026 | painter->setLineWidth( 0 ); |
||
1027 | painter->setFillMode( ScPainterExBase::Solid ); |
||
1028 | painter->setupPolygon( &arrow ); |
||
11905 | jghali | 1029 | fillPath(item, painter, clip); |
4360 | cbradney | 1030 | } |
1031 | } |
||
1032 | |||
11905 | jghali | 1033 | void ScPageOutput::drawItem_PathText( PageItem_PathText* item, ScPainterExBase* painter, const QRect& clip ) |
4360 | cbradney | 1034 | { |
5721 | avox | 1035 | QString chstr, chstr2, chstr3; |
4689 | mrdocs | 1036 | ScText *hl; |
4360 | cbradney | 1037 | FPoint point = FPoint(0, 0); |
1038 | FPoint tangent = FPoint(0, 0); |
||
1039 | uint seg = 0; |
||
10992 | jghali | 1040 | double chs, dx, segLen = 0; |
4360 | cbradney | 1041 | double CurX = item->textToFrameDistLeft(); // item->CurX = item->textToFrameDistLeft() |
1042 | double CurY = 0; |
||
10992 | jghali | 1043 | QString actFill, actStroke; |
1044 | double actFillShade, actStrokeShade; |
||
1045 | StoryText& itemText = item->itemText; |
||
12217 | jghali | 1046 | if (item->pathTextShowFrame()) |
4360 | cbradney | 1047 | { |
12217 | jghali | 1048 | if (item->lineColor() != CommonStrings::None) |
7143 | jghali | 1049 | { |
12217 | jghali | 1050 | painter->setupPolygon(&item->PoLine, false); |
1051 | painter->strokePath(); |
||
1052 | } |
||
1053 | else if (item->NamedLStyle.isEmpty()) |
||
1054 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), 0)); |
||
1055 | else |
||
1056 | { |
||
1057 | multiLine ml = m_doc->MLineStyles[item->NamedLStyle]; |
||
1058 | for (int it = ml.size() - 1; it > -1; it--) |
||
7143 | jghali | 1059 | { |
12217 | jghali | 1060 | const SingleLine& sl = ml[it]; |
1061 | if ((sl.Color != CommonStrings::None) && (sl.Width != 0)) |
||
1062 | { |
||
1063 | ScColorShade tmp(m_doc->PageColors[sl.Color], sl.Shade); |
||
1064 | painter->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash), |
||
1065 | static_cast<Qt::PenCapStyle>(sl.LineEnd), |
||
1066 | static_cast<Qt::PenJoinStyle>(sl.LineJoin)); |
||
1067 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), 0)); |
||
1068 | } |
||
7143 | jghali | 1069 | } |
1070 | } |
||
1071 | } |
||
10992 | jghali | 1072 | double totalTextLen = 0.0; |
1073 | double totalCurveLen = 0.0; |
||
1074 | double extraOffset = 0.0; |
||
1075 | if (itemText.length() != 0) |
||
1076 | { |
||
1077 | CurX += itemText.item(0)->fontSize() * itemText.charStyle(0).tracking() / 10000.0; |
||
1078 | totalTextLen += itemText.charStyle(0).fontSize() * itemText.charStyle(0).tracking() / 10000.0; |
||
1079 | } |
||
4360 | cbradney | 1080 | segLen = item->PoLine.lenPathSeg(seg); |
10992 | jghali | 1081 | for (int a = 0; a < itemText.length(); ++a) |
4360 | cbradney | 1082 | { |
10992 | jghali | 1083 | hl = itemText.item(a); |
5721 | avox | 1084 | chstr = hl->ch; |
11713 | fschmid | 1085 | if (chstr[0] == SpecialChars::PAGENUMBER || chstr[0] == SpecialChars::PARSEP || chstr[0] == SpecialChars::PAGECOUNT |
8089 | jghali | 1086 | || chstr[0] == SpecialChars::TAB || chstr == SpecialChars::LINEBREAK) |
4360 | cbradney | 1087 | continue; |
10992 | jghali | 1088 | if (a < itemText.length()-1) |
1089 | chstr += itemText.text(a+1, 1); |
||
8089 | jghali | 1090 | hl->glyph.yadvance = 0; |
10992 | jghali | 1091 | item->layoutGlyphs(itemText.charStyle(a), chstr, hl->glyph); |
8089 | jghali | 1092 | hl->glyph.shrink(); |
10992 | jghali | 1093 | if (hl->ch == SpecialChars::OBJECT) |
1094 | totalTextLen += (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()); |
||
1095 | else |
||
1096 | totalTextLen += hl->glyph.wide()+hl->fontSize() * hl->tracking() / 10000.0; |
||
1097 | } |
||
1098 | for (uint segs = 0; segs < item->PoLine.size()-3; segs += 4) |
||
1099 | { |
||
1100 | totalCurveLen += item->PoLine.lenPathSeg(segs); |
||
1101 | } |
||
1102 | if ((itemText.defaultStyle().alignment() != 0) && (totalCurveLen >= totalTextLen + item->textToFrameDistLeft())) |
||
1103 | { |
||
1104 | if (itemText.defaultStyle().alignment() == 2) |
||
4360 | cbradney | 1105 | { |
10992 | jghali | 1106 | CurX = totalCurveLen - totalTextLen; |
1107 | CurX -= item->textToFrameDistLeft(); |
||
4360 | cbradney | 1108 | } |
10992 | jghali | 1109 | if (itemText.defaultStyle().alignment() == 1) |
1110 | CurX = (totalCurveLen - totalTextLen) / 2.0; |
||
1111 | if ((itemText.defaultStyle().alignment() == 3) || (itemText.defaultStyle().alignment() == 4)) |
||
1112 | extraOffset = (totalCurveLen - item->textToFrameDistLeft() - totalTextLen) / static_cast<double>(itemText.length()); |
||
1113 | } |
||
1114 | |||
1115 | QPainterPath guidePath = item->PoLine.toQPainterPath(false); |
||
1116 | QList<QPainterPath> pathList = decomposePath(guidePath); |
||
1117 | QPainterPath currPath = pathList[0]; |
||
1118 | int currPathIndex = 0; |
||
1119 | for (int a = item->firstInFrame(); a < itemText.length(); ++a) |
||
1120 | { |
||
1121 | CurY = 0; |
||
1122 | hl = itemText.item(a); |
||
1123 | chstr = hl->ch; |
||
11750 | jghali | 1124 | if (chstr[0] == SpecialChars::PAGENUMBER || chstr[0] == SpecialChars::PARSEP || chstr[0] == SpecialChars::PAGECOUNT |
10992 | jghali | 1125 | || chstr[0] == SpecialChars::TAB || chstr[0] == SpecialChars::LINEBREAK) |
1126 | continue; |
||
1127 | chs = hl->fontSize(); |
||
1128 | if (a < itemText.length()-1) |
||
1129 | chstr += itemText.text(a+1, 1); |
||
1130 | hl->glyph.yadvance = 0; |
||
1131 | item->layoutGlyphs(itemText.charStyle(a), chstr, hl->glyph); |
||
1132 | hl->glyph.shrink(); // HACK |
||
1133 | if (hl->ch == SpecialChars::OBJECT) |
||
1134 | dx = (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()) / 2.0; |
||
4360 | cbradney | 1135 | else |
10992 | jghali | 1136 | dx = hl->glyph.wide() / 2.0; |
1137 | |||
1138 | CurX += dx; |
||
1139 | |||
1140 | double currPerc = currPath.percentAtLength(CurX); |
||
1141 | if (currPerc >= 0.9999999) |
||
4360 | cbradney | 1142 | { |
10992 | jghali | 1143 | currPathIndex++; |
1144 | if (currPathIndex == pathList.count()) |
||
4360 | cbradney | 1145 | break; |
10992 | jghali | 1146 | currPath = pathList[currPathIndex]; |
1147 | CurX = dx; |
||
1148 | currPerc = currPath.percentAtLength(CurX); |
||
4360 | cbradney | 1149 | } |
10992 | jghali | 1150 | double currAngle = currPath.angleAtPercent(currPerc); |
1151 | QPointF currPoint = currPath.pointAtPercent(currPerc); |
||
1152 | tangent = FPoint(cos(currAngle * M_PI / 180.0), sin(currAngle * M_PI / 180.0)); |
||
1153 | point = FPoint(currPoint.x(), currPoint.y()); |
||
1154 | |||
1155 | hl->glyph.xoffset = 0; |
||
11750 | jghali | 1156 | hl->PtransX = point.x(); |
1157 | hl->PtransY = point.y(); |
||
1158 | hl->PRot = currAngle * M_PI / 180.0; |
||
1159 | hl->PDx = dx; |
||
10030 | cbradney | 1160 | QMatrix trafo = QMatrix( 1, 0, 0, -1, -dx, 0 ); |
8089 | jghali | 1161 | if (item->textPathFlipped) |
10030 | cbradney | 1162 | trafo *= QMatrix(1, 0, 0, -1, 0, 0); |
8089 | jghali | 1163 | if (item->textPathType == 0) |
10030 | cbradney | 1164 | trafo *= QMatrix( tangent.x(), tangent.y(), tangent.y(), -tangent.x(), point.x(), point.y() ); // ID's Rainbow mode |
8089 | jghali | 1165 | else if (item->textPathType == 1) |
10030 | cbradney | 1166 | trafo *= QMatrix( 1, 0, 0, -1, point.x(), point.y() ); // ID's Stair Step mode |
8089 | jghali | 1167 | else if (item->textPathType == 2) |
1168 | { |
||
1169 | double a = 1; |
||
1170 | if (tangent.x() < 0) |
||
1171 | a = -1; |
||
1172 | if (fabs(tangent.x()) > 0.1) |
||
10030 | cbradney | 1173 | trafo *= QMatrix( a, (tangent.y() / tangent.x()) * a, 0, -1, point.x(), point.y() ); // ID's Skew mode |
8089 | jghali | 1174 | else |
10030 | cbradney | 1175 | trafo *= QMatrix( a, 4 * a, 0, -1, point.x(), point.y() ); |
8089 | jghali | 1176 | } |
10030 | cbradney | 1177 | QMatrix sca = painter->worldMatrix(); |
4360 | cbradney | 1178 | trafo *= sca; |
1179 | painter->save(); |
||
10030 | cbradney | 1180 | QMatrix savWM = painter->worldMatrix(); |
4360 | cbradney | 1181 | painter->setWorldMatrix(trafo); |
10992 | jghali | 1182 | |
1183 | actFill = itemText.charStyle(a).fillColor(); |
||
1184 | actFillShade = itemText.charStyle(a).fillShade(); |
||
1185 | if (actFill != CommonStrings::None) |
||
1186 | { |
||
11229 | fschmid | 1187 | ScColorShade tmp(m_doc->PageColors[actFill], qRound(actFillShade)); |
10992 | jghali | 1188 | painter->setBrush(tmp); |
1189 | } |
||
1190 | actStroke = itemText.charStyle(a).strokeColor(); |
||
1191 | actStrokeShade = itemText.charStyle(a).strokeShade(); |
||
1192 | if (actStroke != CommonStrings::None) |
||
1193 | { |
||
11229 | fschmid | 1194 | ScColorShade tmp(m_doc->PageColors[actStroke], qRound(actStrokeShade)); |
10992 | jghali | 1195 | painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
1196 | } |
||
1197 | if (hl->ch == SpecialChars::OBJECT) |
||
1198 | { |
||
1199 | painter->translate(0.0, item->pathTextBaseOffset()); |
||
11905 | jghali | 1200 | drawItem_Embedded(hl->embedded.getItem(), painter, clip, itemText.charStyle(a), hl->embedded.getItem()); |
10992 | jghali | 1201 | } |
1202 | else |
||
11905 | jghali | 1203 | drawGlyphs(item, painter, itemText.charStyle(a), hl->glyph, clip); |
10992 | jghali | 1204 | |
4360 | cbradney | 1205 | painter->setWorldMatrix(savWM); |
1206 | painter->restore(); |
||
1207 | CurX -= dx; |
||
10992 | jghali | 1208 | if (hl->ch == SpecialChars::OBJECT) |
1209 | CurX += (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()); |
||
1210 | else |
||
1211 | CurX += hl->glyph.wide()+hl->fontSize() * hl->tracking() / 10000.0 + extraOffset; |
||
4360 | cbradney | 1212 | } |
1213 | } |
||
1214 | |||
11905 | jghali | 1215 | void ScPageOutput::drawItem_Polygon ( PageItem_Polygon* item , ScPainterExBase* painter, const QRect& clip ) |
4360 | cbradney | 1216 | { |
1217 | painter->setupPolygon(&item->PoLine); |
||
11905 | jghali | 1218 | fillPath(item, painter, clip); |
4360 | cbradney | 1219 | } |
1220 | |||
11905 | jghali | 1221 | void ScPageOutput::drawItem_PolyLine( PageItem_PolyLine* item, ScPainterExBase* painter, const QRect& clip ) |
4360 | cbradney | 1222 | { |
1223 | int startArrowIndex; |
||
1224 | int endArrowIndex; |
||
4546 | subik | 1225 | |
4360 | cbradney | 1226 | startArrowIndex = item->startArrowIndex(); |
1227 | endArrowIndex = item->endArrowIndex(); |
||
1228 | |||
1229 | if (item->PoLine.size()>=4) |
||
1230 | { |
||
4546 | subik | 1231 | if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0)) |
4360 | cbradney | 1232 | { |
1233 | FPointArray cli; |
||
1234 | FPoint Start; |
||
1235 | bool firstp = true; |
||
1236 | for (uint n = 0; n < item->PoLine.size()-3; n += 4) |
||
1237 | { |
||
1238 | if (firstp) |
||
1239 | { |
||
1240 | Start = item->PoLine.point(n); |
||
1241 | firstp = false; |
||
1242 | } |
||
1243 | if (item->PoLine.point(n).x() > 900000) |
||
1244 | { |
||
1245 | cli.addPoint(item->PoLine.point(n-2)); |
||
1246 | cli.addPoint(item->PoLine.point(n-2)); |
||
1247 | cli.addPoint(Start); |
||
1248 | cli.addPoint(Start); |
||
1249 | cli.setMarker(); |
||
1250 | firstp = true; |
||
1251 | continue; |
||
1252 | } |
||
1253 | cli.addPoint(item->PoLine.point(n)); |
||
1254 | cli.addPoint(item->PoLine.point(n+1)); |
||
1255 | cli.addPoint(item->PoLine.point(n+2)); |
||
1256 | cli.addPoint(item->PoLine.point(n+3)); |
||
1257 | } |
||
1258 | if (cli.size() > 2) |
||
1259 | { |
||
1260 | FPoint l1 = cli.point(cli.size()-2); |
||
1261 | cli.addPoint(l1); |
||
1262 | cli.addPoint(l1); |
||
1263 | cli.addPoint(Start); |
||
1264 | cli.addPoint(Start); |
||
1265 | } |
||
1266 | painter->setupPolygon(&cli); |
||
11905 | jghali | 1267 | fillPath(item, painter, clip); |
4360 | cbradney | 1268 | } |
1269 | painter->setupPolygon(&item->PoLine, false); |
||
1270 | if (item->NamedLStyle.isEmpty()) |
||
1271 | painter->strokePath(); |
||
1272 | else |
||
1273 | { |
||
1274 | multiLine ml = m_doc->MLineStyles[item->NamedLStyle]; |
||
1275 | for (int it = ml.size()-1; it > -1; it--) |
||
1276 | { |
||
7143 | jghali | 1277 | const SingleLine& sl = ml[it]; |
1278 | if ((sl.Color != CommonStrings::None) && (sl.Width != 0)) |
||
1279 | { |
||
1280 | ScColorShade tmp(m_doc->PageColors[sl.Color], sl.Shade); |
||
1281 | painter->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash), |
||
1282 | static_cast<Qt::PenCapStyle>(sl.LineEnd), |
||
1283 | static_cast<Qt::PenJoinStyle>(sl.LineJoin)); |
||
1284 | painter->strokePath(); |
||
1285 | } |
||
4360 | cbradney | 1286 | } |
1287 | } |
||
1288 | if (startArrowIndex != 0) |
||
1289 | { |
||
1290 | FPoint Start = item->PoLine.point(0); |
||
1291 | for (uint xx = 1; xx < item->PoLine.size(); xx += 2) |
||
1292 | { |
||
1293 | FPoint Vector = item->PoLine.point(xx); |
||
1294 | if ((Start.x() != Vector.x()) || (Start.y() != Vector.y())) |
||
1295 | { |
||
1296 | double r = atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI); |
||
10030 | cbradney | 1297 | QMatrix arrowTrans; |
9803 | fschmid | 1298 | FPointArray arrow = m_doc->arrowStyles.at(startArrowIndex-1).points.copy(); |
4360 | cbradney | 1299 | arrowTrans.translate(Start.x(), Start.y()); |
1300 | arrowTrans.rotate(r); |
||
1301 | arrowTrans.scale(item->lineWidth(), item->lineWidth()); |
||
1302 | arrow.map(arrowTrans); |
||
1303 | painter->setBrush(painter->pen()); |
||
1304 | painter->setBrushOpacity(1.0 - item->lineTransparency()); |
||
1305 | painter->setLineWidth(0); |
||
1306 | painter->setFillMode(ScPainterExBase::Solid); |
||
1307 | painter->setupPolygon(&arrow); |
||
11905 | jghali | 1308 | fillPath(item, painter, clip); |
4360 | cbradney | 1309 | break; |
1310 | } |
||
1311 | } |
||
1312 | } |
||
1313 | if (endArrowIndex != 0) |
||
1314 | { |
||
1315 | FPoint End = item->PoLine.point(item->PoLine.size()-2); |
||
1316 | for (uint xx = item->PoLine.size()-1; xx > 0; xx -= 2) |
||
1317 | { |
||
1318 | FPoint Vector = item->PoLine.point(xx); |
||
1319 | if ((End.x() != Vector.x()) || (End.y() != Vector.y())) |
||
1320 | { |
||
1321 | double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI); |
||
10030 | cbradney | 1322 | QMatrix arrowTrans; |
9803 | fschmid | 1323 | FPointArray arrow = m_doc->arrowStyles.at(endArrowIndex-1).points.copy(); |
4360 | cbradney | 1324 | arrowTrans.translate(End.x(), End.y()); |
1325 | arrowTrans.rotate(r); |
||
1326 | arrowTrans.scale( item->lineWidth(), item->lineWidth() ); |
||
1327 | arrow.map(arrowTrans); |
||
1328 | painter->setBrush(painter->pen()); |
||
1329 | painter->setBrushOpacity(1.0 - item->lineTransparency()); |
||
1330 | painter->setLineWidth(0); |
||
1331 | painter->setFillMode(ScPainterExBase::Solid); |
||
1332 | painter->setupPolygon(&arrow); |
||
11905 | jghali | 1333 | fillPath(item, painter, clip); |
4360 | cbradney | 1334 | break; |
1335 | } |
||
1336 | } |
||
1337 | } |
||
1338 | } |
||
1339 | } |
||
1340 | |||
11905 | jghali | 1341 | void ScPageOutput::drawItem_TextFrame( PageItem_TextFrame* item, ScPainterExBase* painter, const QRect& clip ) |
4360 | cbradney | 1342 | { |
10030 | cbradney | 1343 | QMatrix wm; |
5580 | jghali | 1344 | QPoint pt1, pt2; |
1345 | FPoint ColBound; |
||
1346 | QRegion cm; |
||
5753 | jghali | 1347 | int a; |
6824 | jghali | 1348 | double lineCorr; |
5721 | avox | 1349 | QString chstr, chstr2, chstr3; |
5580 | jghali | 1350 | ScText *hl; |
1351 | double desc, asce, tabDist; |
||
6824 | jghali | 1352 | |
1353 | QRect e2; |
||
5580 | jghali | 1354 | painter->save(); |
6824 | jghali | 1355 | if (item->isEmbedded) |
6987 | jghali | 1356 | e2 = clip; |
6824 | jghali | 1357 | else |
1358 | { |
||
6987 | jghali | 1359 | e2 = QRect(qRound(clip.x() + m_doc->minCanvasCoordinate.x()), qRound(clip.y() + m_doc->minCanvasCoordinate.y()), qRound(clip.width()), qRound(clip.height())); |
6824 | jghali | 1360 | wm.translate(item->xPos(), item->yPos()); |
1361 | } |
||
5580 | jghali | 1362 | wm.rotate(item->rotation()); |
1363 | if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0)) |
||
1364 | { |
||
1365 | painter->setupPolygon(&item->PoLine); |
||
11905 | jghali | 1366 | fillPath(item, painter, clip); |
5580 | jghali | 1367 | } |
1368 | if (item->lineColor() != CommonStrings::None) |
||
1369 | lineCorr = item->lineWidth() / 2.0; |
||
1370 | else |
||
1371 | lineCorr = 0; |
||
1372 | if ((item->isAnnotation()) && (item->annotation().Type() == 2) && (!item->Pfile.isEmpty()) && (item->PicAvail) && (item->imageShown()) && (item->annotation().UseIcons())) |
||
1373 | { |
||
8728 | jghali | 1374 | painter->save(); |
5580 | jghali | 1375 | painter->setupPolygon(&item->PoLine); |
1376 | painter->setClipPath(); |
||
1377 | painter->scale(item->imageXScale(), item->imageYScale()); |
||
1378 | painter->translate(static_cast<int>(item->imageXOffset() * item->imageXScale()), static_cast<int>(item->imageYOffset() * item->imageYScale())); |
||
5599 | jghali | 1379 | if (!item->pixm.qImage().isNull()) |
5580 | jghali | 1380 | painter->drawImage(&item->pixm, ScPainterExBase::rgbImages); |
1381 | painter->restore(); |
||
1382 | } |
||
5729 | jghali | 1383 | if ((item->itemText.length() != 0)) |
5580 | jghali | 1384 | { |
1385 | if (item->imageFlippedH()) |
||
1386 | { |
||
6987 | jghali | 1387 | painter->translate(item->width(), 0); |
5580 | jghali | 1388 | painter->scale(-1, 1); |
1389 | } |
||
1390 | if (item->imageFlippedV()) |
||
1391 | { |
||
6987 | jghali | 1392 | painter->translate(0, item->height()); |
5580 | jghali | 1393 | painter->scale(1, -1); |
1394 | } |
||
8728 | jghali | 1395 | uint tabCc = 0; |
6824 | jghali | 1396 | for (uint ll=0; ll < item->itemText.lines(); ++ll) |
5580 | jghali | 1397 | { |
6824 | jghali | 1398 | LineSpec ls = item->itemText.line(ll); |
1399 | tabDist = ls.x; |
||
1400 | double CurX = ls.x; |
||
1401 | for (a = ls.firstItem; a <= ls.lastItem; ++a) |
||
4360 | cbradney | 1402 | { |
6824 | jghali | 1403 | hl = item->itemText.item(a); |
10227 | jghali | 1404 | const CharStyle& charStyle = item->itemText.charStyle(a); |
6824 | jghali | 1405 | double chs = charStyle.fontSize() * hl->glyph.scaleV; |
1406 | if (charStyle.effects() & ScStyle_StartOfLine) |
||
1407 | tabCc = 0; |
||
1408 | chstr = hl->ch; |
||
1409 | if (charStyle.fillColor() != CommonStrings::None) |
||
4360 | cbradney | 1410 | { |
10227 | jghali | 1411 | ScColorShade tmp(m_doc->PageColors[charStyle.fillColor()], (int) hl->fillShade()); |
6824 | jghali | 1412 | painter->setBrush(tmp); |
4360 | cbradney | 1413 | } |
6824 | jghali | 1414 | if (charStyle.strokeColor() != CommonStrings::None) |
4360 | cbradney | 1415 | { |
10227 | jghali | 1416 | ScColorShade tmp(m_doc->PageColors[charStyle.strokeColor()], (int) hl->strokeShade()); |
6824 | jghali | 1417 | painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
4360 | cbradney | 1418 | } |
6824 | jghali | 1419 | if (charStyle.effects() & ScStyle_DropCap) |
4360 | cbradney | 1420 | { |
8728 | jghali | 1421 | const ParagraphStyle& style(item->itemText.paragraphStyle(a)); |
1422 | if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing) |
||
6824 | jghali | 1423 | chs = qRound(10 * ((m_doc->typographicSettings.valueBaseGrid * (style.dropCapLines()-1) + (charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10))); |
1424 | else |
||
4360 | cbradney | 1425 | { |
6824 | jghali | 1426 | if (style.lineSpacingMode() == ParagraphStyle::FixedLineSpacing) |
1427 | chs = qRound(10 * ((style.lineSpacing() * (style.dropCapLines()-1)+(charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10))); |
||
1428 | else |
||
1429 | { |
||
1430 | double currasce = charStyle.font().height(style.charStyle().fontSize() / 10.0); |
||
1431 | chs = qRound(10 * ((currasce * (style.dropCapLines()-1)+(charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10))); |
||
1432 | } |
||
4360 | cbradney | 1433 | } |
5580 | jghali | 1434 | } |
6824 | jghali | 1435 | if (chstr[0] == SpecialChars::TAB) |
1436 | tabCc++; |
||
1437 | //if (!m_doc->RePos) |
||
5580 | jghali | 1438 | { |
10227 | jghali | 1439 | //double xcoZli = CurX + hl->glyph.xoffset; |
6824 | jghali | 1440 | desc = - charStyle.font().descent(charStyle.fontSize() / 10.0); |
1441 | asce = charStyle.font().ascent(charStyle.fontSize() / 10.0); |
||
1442 | if (charStyle.strokeColor() != CommonStrings::None) |
||
1443 | { |
||
10227 | jghali | 1444 | ScColorShade tmp(m_doc->PageColors[charStyle.strokeColor()], (int) charStyle.strokeShade()); |
6824 | jghali | 1445 | painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
1446 | } |
||
1447 | 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))))) |
||
1448 | { |
||
1449 | painter->save(); |
||
6987 | jghali | 1450 | painter->translate(CurX, ls.y); |
9737 | jghali | 1451 | if (hl->ch == SpecialChars::OBJECT) |
11905 | jghali | 1452 | drawItem_Embedded(item, painter, clip, charStyle, hl->embedded.getItem()); |
6824 | jghali | 1453 | else |
11905 | jghali | 1454 | drawGlyphs(item, painter, charStyle, hl->glyph, clip); |
6824 | jghali | 1455 | painter->restore(); |
1456 | } |
||
9737 | jghali | 1457 | if (hl->ch == SpecialChars::OBJECT) |
8728 | jghali | 1458 | CurX += (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()); |
1459 | else |
||
1460 | CurX += hl->glyph.wide(); |
||
5580 | jghali | 1461 | } |
6824 | jghali | 1462 | tabDist = CurX; |
4360 | cbradney | 1463 | } |
1464 | } |
||
1465 | } |
||
5580 | jghali | 1466 | painter->restore(); |
4360 | cbradney | 1467 | } |
1468 | |||
11905 | jghali | 1469 | void ScPageOutput::drawMarks( Page* page, ScPainterExBase* painter, const MarksOptions& options ) |
7108 | jghali | 1470 | { |
1471 | double markOffs = options.markOffset; |
||
1472 | double bleedLeft = 0.0, bleedRight = 0.0; |
||
1473 | double bleedBottom = options.BleedBottom; |
||
1474 | double bleedTop = options.BleedTop; |
||
1475 | if (!options.cropMarks && !options.bleedMarks && !options.registrationMarks && !options.colorMarks) |
||
1476 | return; |
||
1477 | if (m_doc->locationOfPage(page->pageNr()) == LeftPage) |
||
1478 | { |
||
1479 | bleedRight = options.BleedRight; |
||
1480 | bleedLeft = options.BleedLeft; |
||
1481 | } |
||
1482 | else if (m_doc->locationOfPage(page->pageNr()) == RightPage) |
||
1483 | { |
||
1484 | bleedRight = options.BleedLeft; |
||
1485 | bleedLeft = options.BleedRight; |
||
1486 | } |
||
1487 | else |
||
1488 | { |
||
1489 | bleedRight = options.BleedLeft; |
||
1490 | bleedLeft = options.BleedLeft; |
||
1491 | } |
||
1492 | double width = page->width(); |
||
1493 | double height = page->height(); |
||
1494 | double offsetX = page->xOffset(); |
||
1495 | double offsetY = page->yOffset(); |
||
11385 | jghali | 1496 | QPointF bleedTopLeft(offsetX - bleedLeft, offsetY - bleedTop); |
1497 | QPointF bleedBottomRight(offsetX + width + bleedRight, offsetY + height + bleedBottom); |
||
1498 | QRectF bleedBox(bleedTopLeft, bleedBottomRight); |
||
7108 | jghali | 1499 | painter->save(); |
1500 | painter->setLineWidth(0.5); |
||
1501 | painter->setPen(ScColorShade(Qt::black, 100), 0.5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin ); |
||
1502 | if (options.cropMarks) |
||
1503 | { |
||
1504 | FPoint start, end; |
||
1505 | double left = offsetX, right = offsetX + width; |
||
1506 | double bottom = offsetY + height, top = offsetY; |
||
11905 | jghali | 1507 | drawBoxMarks( painter, QRectF(QPointF(left, top), QPointF(right, bottom)), bleedBox, markOffs ); |
7108 | jghali | 1508 | } |
1509 | if (options.bleedMarks) |
||
1510 | { |
||
1511 | FPoint start, end; |
||
1512 | double left = offsetX - bleedLeft, right = offsetX + width + bleedRight; |
||
1513 | double bottom = offsetY + height + bleedBottom, top = offsetY - bleedTop;; |
||
11905 | jghali | 1514 | drawBoxMarks( painter, QRectF(QPointF(left, top), QPointF(right, bottom)), bleedBox, markOffs ); |
7108 | jghali | 1515 | } |
1516 | if (options.registrationMarks) |
||
1517 | { |
||
1518 | double posX = (2* offsetX + width) / 2.0 - 7.0; |
||
1519 | double posY = (offsetY + height + bleedBottom + markOffs + 3.0); |
||
1520 | painter->save(); |
||
1521 | painter->translate(posX, posY); |
||
11905 | jghali | 1522 | drawRegistrationCross( painter ); |
7108 | jghali | 1523 | painter->restore(); |
1524 | posX = (2 * offsetX + width) / 2.0 - 7.0; |
||
1525 | posY = (offsetY - bleedTop - markOffs - 17); |
||
1526 | painter->save(); |
||
1527 | painter->translate(posX, posY); |
||
11905 | jghali | 1528 | drawRegistrationCross( painter ); |
7108 | jghali | 1529 | painter->restore(); |
1530 | |||
1531 | posX = (offsetX - bleedLeft - markOffs - 17); |
||
1532 | posY = (2 * offsetY + height) / 2.0 - 7.0; |
||
1533 | painter->save(); |
||
1534 | painter->translate(posX, posY); |
||
11905 | jghali | 1535 | drawRegistrationCross( painter ); |
7108 | jghali | 1536 | painter->restore(); |
1537 | posX = (offsetX + width + bleedRight + markOffs + 3.0); |
||
1538 | posY = (2 * offsetY + height) / 2.0 - 7.0; |
||
1539 | painter->save(); |
||
1540 | painter->translate(posX, posY); |
||
11905 | jghali | 1541 | drawRegistrationCross( painter ); |
7108 | jghali | 1542 | painter->restore(); |
1543 | } |
||
1544 | if (options.colorMarks) |
||
1545 | { |
||
1546 | int shade = 100; |
||
1547 | double startX = offsetX + 6.0; |
||
1548 | double startY = offsetY - bleedTop - markOffs - 16.0; |
||
1549 | ScColorShade strokecolor( ScColor(0, 0, 0, 255), 100 ); |
||
1550 | painter->setPen( strokecolor, 0.5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin ); |
||
1551 | painter->setFillMode( ScPainterExBase::Solid ); |
||
1552 | for (int i = 0; i < 11; i++ ) |
||
1553 | { |
||
1554 | ScColorShade fillcolor( ScColor(0, 0, 0, 255), shade ); |
||
1555 | painter->setBrush( fillcolor ); |
||
1556 | painter->drawRect( startX + i * 14, startY, 14, 14 ); |
||
1557 | shade -= 10; |
||
1558 | } |
||
1559 | startX = offsetX + width - 20.0; |
||
1560 | painter->setBrush( ScColorShade(ScColor(0, 0, 0, 255), 50) ); |
||
1561 | painter->drawRect( startX, startY, 14, 14 ); |
||
1562 | startX -= 14; |
||
1563 | painter->setBrush( ScColorShade(ScColor(0, 0, 255, 0), 50) ); |
||
1564 | painter->drawRect( startX, startY, 14, 14 ); |
||
1565 | startX -= 14; |
||
1566 | painter->setBrush( ScColorShade(ScColor(0, 255, 0, 0), 50) ); |
||
1567 | painter->drawRect( startX, startY, 14, 14 ); |
||
1568 | startX -= 14; |
||
1569 | painter->setBrush( ScColorShade(ScColor(255, 0, 0, 0), 50) ); |
||
1570 | painter->drawRect( startX, startY, 14, 14 ); |
||
1571 | startX -= 14; |
||
1572 | painter->setBrush( ScColorShade(ScColor(255, 255, 0, 0), 100) ); |
||
1573 | painter->drawRect( startX, startY, 14, 14 ); |
||
1574 | startX -= 14; |
||
1575 | painter->setBrush( ScColorShade(ScColor(255, 0, 255, 0), 100) ); |
||
1576 | painter->drawRect( startX, startY, 14, 14 ); |
||
1577 | startX -= 14; |
||
1578 | painter->setBrush( ScColorShade(ScColor(0, 255, 255, 0), 100) ); |
||
1579 | painter->drawRect( startX, startY, 14, 14 ); |
||
1580 | startX -= 14; |
||
1581 | painter->setBrush( ScColorShade(ScColor(0, 0, 0, 255), 100) ); |
||
1582 | painter->drawRect( startX, startY, 14, 14 ); |
||
1583 | startX -= 14; |
||
1584 | painter->setBrush( ScColorShade(ScColor(0, 0, 255, 0), 100) ); |
||
1585 | painter->drawRect( startX, startY, 14, 14 ); |
||
1586 | startX -= 14; |
||
1587 | painter->setBrush( ScColorShade(ScColor(0, 255, 0, 0), 100) ); |
||
1588 | painter->drawRect( startX, startY, 14, 14 ); |
||
1589 | startX -= 14; |
||
1590 | painter->setBrush( ScColorShade(ScColor(255, 0, 0, 0), 100) ); |
||
1591 | painter->drawRect( startX, startY, 14, 14 ); |
||
1592 | } |
||
1593 | painter->restore(); |
||
1594 | } |
||
1595 | |||
11905 | jghali | 1596 | void ScPageOutput::drawBoxMarks( ScPainterExBase* painter, const QRectF& box, const QRectF& bleedBox, double offset ) |
7108 | jghali | 1597 | { |
1598 | FPoint start, end; |
||
11385 | jghali | 1599 | double left = box.left(), right = box.right(); |
1600 | double bottom = box.bottom(), top = box.top(); |
||
1601 | double bleedLeft = bleedBox.left(), bleedRight = bleedBox.right(); |
||
1602 | double bleedBottom = bleedBox.bottom(), bleedTop = bleedBox.top(); |
||
7108 | jghali | 1603 | // Top Left |
11385 | jghali | 1604 | start.setXY( bleedLeft - offset, top ); |
1605 | end.setXY ( bleedLeft - offset - 20, top ); |
||
7108 | jghali | 1606 | painter->drawLine(start, end); |
11385 | jghali | 1607 | start.setXY( left, bleedTop - offset ); |
1608 | end.setXY ( left, bleedTop - offset - 20); |
||
7108 | jghali | 1609 | painter->drawLine(start, end); |
1610 | // Top Right |
||
11385 | jghali | 1611 | start.setXY( bleedRight + offset, top ); |
1612 | end.setXY ( bleedRight + offset + 20, top ); |
||
7108 | jghali | 1613 | painter->drawLine(start, end); |
11385 | jghali | 1614 | start.setXY( right, bleedTop - offset ); |
1615 | end.setXY ( right, bleedTop - offset - 20); |
||
7108 | jghali | 1616 | painter->drawLine(start, end); |
1617 | // Bottom Left |
||
11385 | jghali | 1618 | start.setXY( bleedLeft - offset, bottom ); |
1619 | end.setXY ( bleedLeft - offset - 20, bottom ); |
||
7108 | jghali | 1620 | painter->drawLine(start, end); |
11385 | jghali | 1621 | start.setXY( left, bleedBottom + offset ); |
1622 | end.setXY ( left, bleedBottom + offset + 20); |
||
7108 | jghali | 1623 | painter->drawLine(start, end); |
1624 | // Bottom Right |
||
11385 | jghali | 1625 | start.setXY( bleedRight + offset, bottom ); |
1626 | end.setXY ( bleedRight + offset + 20, bottom ); |
||
7108 | jghali | 1627 | painter->drawLine(start, end); |
11385 | jghali | 1628 | start.setXY( right, bleedBottom + offset ); |
1629 | end.setXY ( right, bleedBottom + offset + 20); |
||
7108 | jghali | 1630 | painter->drawLine(start, end); |
1631 | } |
||
1632 | |||
11905 | jghali | 1633 | void ScPageOutput::drawRegistrationCross( ScPainterExBase* painter ) |
7108 | jghali | 1634 | { |
1635 | painter->save(); |
||
1636 | |||
1637 | painter->newPath(); |
||
1638 | painter->moveTo(0.0, 7.0); |
||
1639 | painter->lineTo(14.0, 7.0); |
||
1640 | painter->strokePath(); |
||
1641 | |||
1642 | painter->newPath(); |
||
1643 | painter->moveTo(7.0, 0.0); |
||
1644 | painter->lineTo(7.0, 14.0); |
||
1645 | painter->strokePath(); |
||
1646 | |||
1647 | painter->newPath(); |
||
1648 | painter->moveTo(13.0, 7.0); |
||
1649 | painter->curveTo( FPoint(13.0, 10.31383), FPoint(10.31383, 13.0), FPoint(7.0, 13.0) ); |
||
1650 | painter->curveTo( FPoint(3.68629, 13.0) , FPoint(1.0, 10.31383) , FPoint(1.0, 7.0) ); |
||
1651 | painter->curveTo( FPoint(1.0, 3.68629) , FPoint(3.68629, 1.0) , FPoint(7.0, 1.0) ); |
||
1652 | painter->curveTo( FPoint(10.31383, 1.0) , FPoint(13.0, 3.68629) , FPoint(13.0, 7.0) ); |
||
1653 | painter->strokePath(); |
||
1654 | |||
1655 | painter->newPath(); |
||
1656 | painter->moveTo(10.5, 7.0); |
||
1657 | painter->curveTo( FPoint(10.5, 8.93307), FPoint(8.93307, 10.5), FPoint(7.0, 10.5) ); |
||
1658 | painter->curveTo( FPoint(5.067, 10.5) , FPoint(3.5, 8.93307) , FPoint(3.5, 7.0) ); |
||
1659 | painter->curveTo( FPoint(3.5, 5.067) , FPoint(5.067, 3.5) , FPoint(7.0, 3.5) ); |
||
1660 | painter->curveTo( FPoint(8.93307, 3.5) , FPoint(10.5, 5.067) , FPoint(10.5, 7.0) ); |
||
1661 | painter->strokePath(); |
||
1662 | |||
1663 | painter->restore(); |
||
1664 | } |
||
1665 | |||
11905 | jghali | 1666 | void ScPageOutput::fillPath( PageItem* item, ScPainterExBase* painter, const QRect& clip ) |
6987 | jghali | 1667 | { |
1668 | if( painter->fillMode() == ScPainterExBase::Pattern && !painter->hasCapability(ScPainterExBase::patterns) ) |
||
11905 | jghali | 1669 | drawPattern( item, painter, clip ); |
6987 | jghali | 1670 | else |
1671 | painter->fillPath(); |
||
1672 | } |
||
4360 | cbradney | 1673 | |
11905 | jghali | 1674 | void ScPageOutput::strokePath( PageItem* item, ScPainterExBase* painter, const QRect& clip ) |
6987 | jghali | 1675 | { |
1676 | painter->strokePath(); |
||
1677 | } |
||
1678 | |||
10140 | jghali | 1679 | |
11385 | jghali | 1680 | |
12217 | jghali | 1681 |