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