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