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