Rev 6987 | Rev 7143 | 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; |
||
42 | BleedTop = opt.BleedTop; |
||
43 | BleedLeft = opt.BleedLeft; |
||
44 | BleedRight = opt.BleedRight; |
||
45 | BleedBottom = opt.BleedBottom; |
||
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 ); |
4360 | cbradney | 279 | if ((currItem->asTextFrame()) && ((currItem->NextBox != 0) || (currItem->BackBox != 0))) |
280 | { |
||
281 | PageItem *nextItem = currItem; |
||
282 | while (nextItem != 0) |
||
283 | { |
||
284 | if (nextItem->BackBox != 0) |
||
285 | nextItem = nextItem->BackBox; |
||
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 | { |
||
485 | ScColorShade tmp( m_doc->PageColors[ml[it].Color], ml[it].Shade ); |
||
486 | painter->setPen(tmp, ml[it].Width, |
||
487 | static_cast<Qt::PenStyle>(ml[it].Dash), |
||
488 | static_cast<Qt::PenCapStyle>(ml[it].LineEnd), |
||
489 | static_cast<Qt::PenJoinStyle>(ml[it].LineJoin)); |
||
490 | painter->strokePath(); |
||
491 | } |
||
492 | } |
||
493 | } |
||
494 | } |
||
495 | if ((!item->isEmbedded)) |
||
6987 | jghali | 496 | double scpInv = 1.0; |
4360 | cbradney | 497 | item->Tinput = false; |
498 | item->FrameOnly = false; |
||
499 | painter->restore(); |
||
500 | } |
||
501 | |||
6987 | jghali | 502 | void ScPageOutput::DrawGlyphs(PageItem* item, ScPainterExBase *painter, const CharStyle& style, GlyphLayout& glyphs, QRect& clip) |
4360 | cbradney | 503 | { |
6824 | jghali | 504 | uint glyph = glyphs.glyph; |
505 | if (glyph == (ScFace::CONTROL_GLYPHS + 29)) // NBSPACE |
||
506 | glyph = style.font().char2CMap(QChar(' ')); |
||
507 | else if (glyph == (ScFace::CONTROL_GLYPHS + 24)) // NBHYPHEN |
||
508 | glyph = style.font().char2CMap(QChar('-')); |
||
509 | |||
510 | if (glyph >= ScFace::CONTROL_GLYPHS) |
||
4360 | cbradney | 511 | return; |
5988 | jghali | 512 | |
6824 | jghali | 513 | //if (style.font().canRender(QChar(glyph))) |
4360 | cbradney | 514 | { |
515 | QWMatrix chma, chma2, chma3, chma4, chma5, chma6; |
||
5988 | jghali | 516 | chma.scale(glyphs.scaleH * style.fontSize() / 100.00, glyphs.scaleV * style.fontSize() / 100.0); |
517 | // qDebug(QString("glyphscale: %1 %2").arg(glyphs.scaleH).arg(glyphs.scaleV)); |
||
6824 | jghali | 518 | FPointArray gly = style.font().glyphOutline(glyph); |
5988 | jghali | 519 | // Do underlining first so you can get typographically correct |
520 | // underlines when drawing a white outline |
||
6824 | jghali | 521 | if ((style.effects() & ScStyle_Underline) || ((style.effects() & ScStyle_UnderlineWords) && (glyph != style.font().char2CMap(QChar(' '))))) |
5988 | jghali | 522 | { |
523 | double st, lw; |
||
6824 | jghali | 524 | if ((style.underlineOffset() != -1) || (style.underlineWidth() != -1)) |
5988 | jghali | 525 | { |
6824 | jghali | 526 | if (style.underlineOffset() != -1) |
527 | st = (style.underlineOffset() / 1000.0) * (style.font().descent(style.fontSize() / 10.0)); |
||
5988 | jghali | 528 | else |
529 | st = style.font().underlinePos(style.fontSize() / 10.0); |
||
530 | if (style.underlineWidth() != -1) |
||
531 | lw = (style.underlineWidth() / 1000.0) * (style.fontSize() / 10.0); |
||
532 | else |
||
533 | lw = QMAX(style.font().strokeWidth(style.fontSize() / 10.0), 1); |
||
534 | } |
||
535 | else |
||
536 | { |
||
537 | st = style.font().underlinePos(style.fontSize() / 10.0); |
||
538 | lw = QMAX(style.font().strokeWidth(style.fontSize() / 10.0), 1); |
||
539 | } |
||
540 | if (style.baselineOffset() != 0) |
||
541 | st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0); |
||
6824 | jghali | 542 | ScColorShade tmpPen = painter->pen(); |
5988 | jghali | 543 | painter->setPen(painter->brush()); |
544 | painter->setLineWidth(lw); |
||
545 | painter->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st)); |
||
6824 | jghali | 546 | painter->setPen(tmpPen); |
5988 | jghali | 547 | } |
4360 | cbradney | 548 | if (gly.size() > 3) |
549 | { |
||
550 | if (item->reversed()) |
||
551 | { |
||
552 | chma3.scale(-1, 1); |
||
5988 | jghali | 553 | chma3.translate(-glyphs.xadvance, 0); |
4360 | cbradney | 554 | } |
5988 | jghali | 555 | chma4.translate(glyphs.xoffset, glyphs.yoffset - ((style.fontSize() / 10.0) * glyphs.scaleV)); |
556 | if (style.baselineOffset() != 0) |
||
6987 | jghali | 557 | chma6.translate(0, -(style.fontSize() / 10.0) * (style.baselineOffset() / 1000.0)); |
5988 | jghali | 558 | gly.map(chma * chma3 * chma4 * chma5 * chma6); |
6987 | jghali | 559 | painter->setFillMode(ScPainterExBase::Solid); |
4360 | cbradney | 560 | bool fr = painter->fillRule(); |
561 | painter->setFillRule(false); |
||
562 | painter->setupTextPolygon(&gly); |
||
5988 | jghali | 563 | if ((style.font().isStroked()) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0)) |
564 | { |
||
565 | ScColorShade tmp = painter->brush(); |
||
566 | painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
||
567 | painter->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0); |
||
568 | painter->strokePath(); |
||
569 | } |
||
4360 | cbradney | 570 | else |
571 | { |
||
5988 | jghali | 572 | if ((style.effects() & ScStyle_Shadowed) && (style.strokeColor() != CommonStrings::None)) |
4360 | cbradney | 573 | { |
574 | painter->save(); |
||
6987 | jghali | 575 | painter->translate((style.fontSize() * glyphs.scaleH * style.shadowXOffset() / 10000.0), -(style.fontSize() * glyphs.scaleV * style.shadowYOffset() / 10000.0)); |
4360 | cbradney | 576 | ScColorShade tmp = painter->brush(); |
577 | painter->setBrush(painter->pen()); |
||
5988 | jghali | 578 | painter->setupTextPolygon(&gly); |
6987 | jghali | 579 | FillPath(item, painter, clip); |
4360 | cbradney | 580 | painter->setBrush(tmp); |
581 | painter->restore(); |
||
5988 | jghali | 582 | painter->setupTextPolygon(&gly); |
4360 | cbradney | 583 | } |
5988 | jghali | 584 | if (style.fillColor() != CommonStrings::None) |
6987 | jghali | 585 | FillPath(item, painter, clip); |
5988 | jghali | 586 | if ((style.effects() & ScStyle_Outline) && (style.strokeColor() != CommonStrings::None) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0)) |
4360 | cbradney | 587 | { |
5988 | jghali | 588 | painter->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0); |
4360 | cbradney | 589 | painter->strokePath(); |
590 | } |
||
591 | } |
||
592 | painter->setFillRule(fr); |
||
593 | } |
||
5988 | jghali | 594 | if (style.effects() & ScStyle_Strikethrough) |
4360 | cbradney | 595 | { |
596 | double st, lw; |
||
5988 | jghali | 597 | if ((style.strikethruOffset() != -1) || (style.strikethruWidth() != -1)) |
4360 | cbradney | 598 | { |
5988 | jghali | 599 | if (style.strikethruOffset() != -1) |
600 | st = (style.strikethruOffset() / 1000.0) * (style.font().ascent(style.fontSize() / 10.0)); |
||
4360 | cbradney | 601 | else |
5988 | jghali | 602 | st = style.font().strikeoutPos(style.fontSize() / 10.0); |
603 | if (style.strikethruWidth() != -1) |
||
604 | lw = (style.strikethruWidth() / 1000.0) * (style.fontSize() / 10.0); |
||
4360 | cbradney | 605 | else |
5988 | jghali | 606 | lw = QMAX(style.font().strokeWidth(style.fontSize() / 10.0), 1); |
4360 | cbradney | 607 | } |
608 | else |
||
609 | { |
||
5988 | jghali | 610 | st = style.font().strikeoutPos(style.fontSize() / 10.0); |
611 | lw = QMAX(style.font().strokeWidth(style.fontSize() / 10.0), 1); |
||
4360 | cbradney | 612 | } |
5988 | jghali | 613 | if (style.baselineOffset() != 0) |
614 | st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0); |
||
4360 | cbradney | 615 | painter->setPen(painter->brush()); |
616 | painter->setLineWidth(lw); |
||
5988 | jghali | 617 | painter->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st)); |
4360 | cbradney | 618 | } |
619 | } |
||
6824 | jghali | 620 | /*else |
4360 | cbradney | 621 | { |
622 | painter->setLineWidth(1); |
||
5988 | jghali | 623 | painter->setPen(ScColorShade(Qt::red, 100)); |
624 | painter->setBrush(ScColorShade(Qt::red, 100)); |
||
4360 | cbradney | 625 | painter->setFillMode(1); |
5988 | jghali | 626 | 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 | 627 | }*/ |
5988 | jghali | 628 | if (glyphs.more) |
6824 | jghali | 629 | { |
6987 | jghali | 630 | painter->translate(glyphs.xadvance, 0); |
631 | DrawGlyphs(item, painter, style, *glyphs.more, clip); |
||
6824 | jghali | 632 | } |
4360 | cbradney | 633 | } |
634 | |||
6987 | jghali | 635 | void ScPageOutput::DrawItem_Embedded( PageItem* item, ScPainterExBase *p, QRect& clip, const CharStyle& style, PageItem* cembedded) |
4360 | cbradney | 636 | { |
637 | QPtrList<PageItem> emG; |
||
638 | emG.clear(); |
||
5988 | jghali | 639 | if (cembedded != 0) |
4360 | cbradney | 640 | { |
5988 | jghali | 641 | if (!item->doc()->DoDrawing) |
4360 | cbradney | 642 | { |
5988 | jghali | 643 | cembedded->Tinput = false; |
644 | cembedded->FrameOnly = false; |
||
4360 | cbradney | 645 | return; |
646 | } |
||
5988 | jghali | 647 | emG.append(cembedded); |
648 | if (cembedded->Groups.count() != 0) |
||
4360 | cbradney | 649 | { |
5988 | jghali | 650 | for (uint ga=0; ga < m_doc->FrameItems.count(); ++ga) |
4360 | cbradney | 651 | { |
652 | if (m_doc->FrameItems.at(ga)->Groups.count() != 0) |
||
653 | { |
||
5988 | jghali | 654 | if (m_doc->FrameItems.at(ga)->Groups.top() == cembedded->Groups.top()) |
4360 | cbradney | 655 | { |
5988 | jghali | 656 | if (m_doc->FrameItems.at(ga)->ItemNr != cembedded->ItemNr) |
4360 | cbradney | 657 | { |
658 | if (emG.find(m_doc->FrameItems.at(ga)) == -1) |
||
659 | emG.append(m_doc->FrameItems.at(ga)); |
||
660 | } |
||
661 | } |
||
662 | } |
||
663 | } |
||
664 | } |
||
665 | for (uint em = 0; em < emG.count(); ++em) |
||
666 | { |
||
667 | PageItem* embedded = emG.at(em); |
||
5988 | jghali | 668 | /* |
669 | ParagraphStyle vg; |
||
4360 | cbradney | 670 | QValueList<ParagraphStyle> savedParagraphStyles; |
671 | for (int xxx=0; xxx<5; ++xxx) |
||
672 | { |
||
5988 | jghali | 673 | vg.setLineSpacingMode(static_cast<ParagraphStyle::LineSpacingMode>(m_Doc->docParagraphStyles[xxx].lineSpacingMode())); |
674 | vg.setUseBaselineGrid(m_Doc->docParagraphStyles[xxx].useBaselineGrid()); |
||
675 | vg.setLineSpacing(m_Doc->docParagraphStyles[xxx].lineSpacing()); |
||
676 | vg.charStyle().setFontSize(m_Doc->docParagraphStyles[xxx].charStyle().fontSize()); |
||
677 | vg.setLeftMargin(m_Doc->docParagraphStyles[xxx].leftMargin()); |
||
678 | vg.setFirstIndent(m_Doc->docParagraphStyles[xxx].firstIndent()); |
||
679 | vg.setGapBefore(m_Doc->docParagraphStyles[xxx].gapBefore()); |
||
680 | vg.setGapAfter(m_Doc->docParagraphStyles[xxx].gapAfter()); |
||
4360 | cbradney | 681 | savedParagraphStyles.append(vg); |
682 | } |
||
5988 | jghali | 683 | */ |
4360 | cbradney | 684 | p->save(); |
5988 | jghali | 685 | double pws=0; |
686 | /* FIXME |
||
687 | embedded->Xpos = Xpos + hl->xco + embedded->gXpos; |
||
688 | embedded->Ypos = Ypos + (hl->yco - (embedded->gHeight * (hl->scalev / 1000.0))) + embedded->gYpos; |
||
4360 | cbradney | 689 | 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()); |
690 | if (hl->base != 0) |
||
691 | { |
||
692 | p->translate(0, -embedded->gHeight * (hl->base / 1000.0) * p->zoomFactor()); |
||
5988 | jghali | 693 | embedded->Ypos -= embedded->gHeight * (hl->base / 1000.0); |
4360 | cbradney | 694 | } |
695 | p->scale(hl->scale / 1000.0, hl->scalev / 1000.0); |
||
5988 | jghali | 696 | embedded->Dirty = Dirty; |
697 | embedded->invalid = invalid; |
||
698 | double sc; |
||
699 | double pws = embedded->m_lineWidth; |
||
700 | embedded->DrawObj_Pre(p, sc); |
||
4360 | cbradney | 701 | switch(embedded->itemType()) |
702 | { |
||
5988 | jghali | 703 | case ImageFrame: |
704 | case TextFrame: |
||
705 | case Polygon: |
||
706 | case PathText: |
||
707 | embedded->DrawObj_Item(p, e, sc); |
||
4360 | cbradney | 708 | break; |
5988 | jghali | 709 | case Line: |
710 | case PolyLine: |
||
711 | embedded->m_lineWidth = pws * QMIN(hl->scale / 1000.0, hl->scalev / 1000.0); |
||
712 | embedded->DrawObj_Item(p, e, sc); |
||
4360 | cbradney | 713 | break; |
714 | default: |
||
715 | break; |
||
716 | } |
||
5988 | jghali | 717 | embedded->m_lineWidth = pws * QMIN(hl->scale / 1000.0, hl->scalev / 1000.0); |
718 | embedded->DrawObj_Post(p); |
||
719 | */ |
||
4360 | cbradney | 720 | p->restore(); |
4617 | avox | 721 | embedded->setLineWidth(pws); |
5988 | jghali | 722 | /* |
723 | for (int xxx=0; xxx<5; ++xxx) |
||
4360 | cbradney | 724 | { |
5988 | jghali | 725 | m_Doc->docParagraphStyles[xxx].setLineSpacingMode(static_cast<ParagraphStyle::LineSpacingMode>(savedParagraphStyles[xxx].lineSpacingMode())); |
726 | m_Doc->docParagraphStyles[xxx].setUseBaselineGrid(savedParagraphStyles[xxx].useBaselineGrid()); |
||
727 | m_Doc->docParagraphStyles[xxx].setLineSpacing(savedParagraphStyles[xxx].lineSpacing()); |
||
728 | m_Doc->docParagraphStyles[xxx].charStyle().setFontSize(savedParagraphStyles[xxx].charStyle().fontSize()); |
||
729 | m_Doc->docParagraphStyles[xxx].setLeftMargin(savedParagraphStyles[xxx].leftMargin()); |
||
730 | m_Doc->docParagraphStyles[xxx].setFirstIndent(savedParagraphStyles[xxx].firstIndent()); |
||
731 | m_Doc->docParagraphStyles[xxx].setGapBefore(savedParagraphStyles[xxx].gapBefore()); |
||
732 | m_Doc->docParagraphStyles[xxx].setGapAfter(savedParagraphStyles[xxx].gapAfter()); |
||
4360 | cbradney | 733 | } |
734 | savedParagraphStyles.clear(); |
||
5988 | jghali | 735 | */ |
4360 | cbradney | 736 | } |
737 | } |
||
738 | } |
||
739 | |||
6987 | jghali | 740 | void ScPageOutput::DrawPattern( PageItem* item, ScPainterExBase* painter, QRect& clip) |
4360 | cbradney | 741 | { |
6987 | jghali | 742 | double x1, x2, y1, y2; |
743 | ScPattern& pattern = m_doc->docPatterns[item->pattern()]; |
||
744 | double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation; |
||
745 | item->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation); |
||
746 | |||
747 | // Compute pattern tansformation matrix and its inverse for converting pattern coordinates |
||
748 | // to pageitem coordinates |
||
749 | QWMatrix matrix, invMat; |
||
750 | matrix.translate(patternOffsetX, patternOffsetY); |
||
751 | matrix.rotate(patternRotation); |
||
752 | matrix.scale(pattern.scaleX, pattern.scaleY); |
||
753 | matrix.scale(patternScaleX / 100.0 , patternScaleY / 100.0); |
||
754 | invMat.scale((patternScaleX != 0) ? (100 /patternScaleX) : 1.0, (patternScaleY != 0) ? (100 /patternScaleY) : 1.0); |
||
755 | invMat.scale((pattern.scaleX != 0) ? (1 /pattern.scaleX) : 1.0, (pattern.scaleY != 0) ? (1 /pattern.scaleY) : 1.0); |
||
756 | invMat.rotate(-patternRotation); |
||
757 | invMat.translate(-patternOffsetX, -patternOffsetY); |
||
758 | |||
759 | // Compute bounding box in which pattern item will be drawn |
||
760 | double width = item->width(); |
||
761 | double height = item->height(); |
||
762 | double rot = patternRotation - floor(patternRotation / 90) * 90; |
||
763 | double ctheta = cos(rot * M_PI / 180); |
||
764 | double stheta = sin(rot * M_PI / 180); |
||
765 | QRect itemRect(0, 0, item->width(), item->height()); |
||
766 | QPoint pa( width * stheta * stheta, -width * stheta * ctheta ); |
||
767 | QPoint pb( width + height * ctheta * stheta, height * stheta * stheta ); |
||
768 | QPoint pc( -height * ctheta * stheta, height * ctheta * ctheta ); |
||
769 | QPoint pd( width * ctheta * ctheta, height + width * ctheta * stheta ); |
||
770 | QPoint ipa = invMat.map(pa), ipb = invMat.map(pb); |
||
771 | QPoint ipc = invMat.map(pc), ipd = invMat.map(pd); |
||
772 | |||
773 | painter->save(); |
||
774 | if (item->imageClip.size() != 0) |
||
775 | { |
||
776 | painter->setupPolygon(&item->imageClip); |
||
777 | painter->setClipPath(); |
||
778 | } |
||
779 | painter->setupPolygon(&item->PoLine); |
||
780 | painter->setClipPath(); |
||
781 | for (uint index = 0; index < pattern.items.count(); index++) |
||
782 | { |
||
783 | QRect itRect; |
||
784 | PageItem* it = pattern.items.at(index); |
||
785 | if (it->isGroupControl) |
||
786 | continue; |
||
787 | |||
788 | painter->save(); |
||
789 | painter->translate(patternOffsetX, patternOffsetY); |
||
790 | painter->rotate(patternRotation); |
||
791 | painter->scale(pattern.scaleX, pattern.scaleY); |
||
792 | painter->scale(patternScaleX / 100.0, patternScaleY / 100.0); |
||
793 | |||
794 | double patWidth = (pattern.width != 0.0) ? pattern.width : 1.0; |
||
795 | double patHeight = (pattern.height != 0.0) ? pattern.height : 1.0; |
||
796 | double kxa = (ipa.x() - it->gXpos) / patWidth; |
||
797 | double kxb = (ipb.x() - it->gXpos) / patWidth; |
||
798 | double kxc = (ipc.x() - it->gXpos) / patWidth; |
||
799 | double kxd = (ipd.x() - it->gXpos) / patWidth; |
||
800 | double kya = (ipa.y() - it->gYpos) / patHeight; |
||
801 | double kyb = (ipb.y() - it->gYpos) / patHeight; |
||
802 | double kyc = (ipc.y() - it->gYpos) / patHeight; |
||
803 | double kyd = (ipd.y() - it->gYpos) / patHeight; |
||
804 | int kxMin = floor( QMIN(QMIN(kxa, kxb), QMIN(kxc, kxd)) ); |
||
805 | int kxMax = ceil ( QMAX(QMAX(kxa, kxb), QMAX(kxc, kxd)) ); |
||
806 | int kyMin = floor( QMIN(QMIN(kya, kyb), QMIN(kyc, kyd)) ); |
||
807 | int kyMax = ceil ( QMAX(QMAX(kya, kyb), QMAX(kyc, kyd)) ); |
||
808 | |||
809 | double itx = it->xPos(); |
||
810 | double ity = it->yPos(); |
||
811 | double itPosX = it->gXpos, itPosY = it->gYpos; |
||
812 | for ( int kx = kxMin; kx <= kxMax; kx++ ) |
||
813 | { |
||
814 | for ( int ky = kyMin; ky <= kyMax; ky++ ) |
||
815 | { |
||
816 | itPosX = it->gXpos + kx * pattern.width; |
||
817 | itPosY = it->gYpos + ky * pattern.height; |
||
818 | it->setXYPos(itPosX, itPosY); |
||
819 | it->getBoundingRect(&x1, &y1, &x2, &y2); |
||
820 | itRect.setCoords(x1, y1, x2, y2); |
||
821 | itRect = matrix.mapRect( itRect ); |
||
822 | if ( itRect.intersects(itemRect) ) |
||
823 | DrawItem(it, painter, clip); |
||
824 | } |
||
825 | } |
||
826 | it->setXYPos(itx, ity); |
||
827 | painter->restore(); |
||
828 | } |
||
829 | painter->restore(); |
||
830 | } |
||
831 | |||
832 | void ScPageOutput::DrawItem_ImageFrame( PageItem_ImageFrame* item, ScPainterExBase* painter, QRect& clip ) |
||
833 | { |
||
4989 | cbradney | 834 | ScPainterExBase::ImageMode mode = ScPainterExBase::rgbImages; |
4546 | subik | 835 | if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0)) |
4360 | cbradney | 836 | { |
837 | painter->setupPolygon(&item->PoLine); |
||
6987 | jghali | 838 | FillPath(item, painter, clip); |
4360 | cbradney | 839 | } |
840 | if (item->Pfile.isEmpty()) |
||
841 | { |
||
6987 | jghali | 842 | painter->setPen( ScColorShade(Qt::black, 100), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
843 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), item->height())); |
||
844 | painter->drawLine(FPoint(0, item->height()), FPoint(item->width(), 0)); |
||
4360 | cbradney | 845 | } |
846 | else |
||
847 | { |
||
4506 | cbradney | 848 | if ((!item->imageShown()) || (!item->PicAvail)) |
4360 | cbradney | 849 | { |
6987 | jghali | 850 | painter->setPen( ScColorShade(Qt::red, 100), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
851 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), item->height())); |
||
852 | painter->drawLine(FPoint(0, item->height()), FPoint(item->width(), 0)); |
||
4360 | cbradney | 853 | } |
854 | else |
||
855 | { |
||
856 | ScImage scImg; |
||
857 | ScImage* pImage = NULL; |
||
858 | double imScaleX = item->imageXScale(); |
||
859 | double imScaleY = item->imageYScale(); |
||
860 | if( m_reloadImages ) |
||
861 | { |
||
862 | bool dummy; |
||
4617 | avox | 863 | bool useCmyk = false; |
4751 | cbradney | 864 | ScPainterExBase::ImageMode imageMode = painter->imageMode(); |
865 | if ( imageMode == ScPainterExBase::cmykImages ) |
||
4617 | avox | 866 | useCmyk = true; |
4360 | cbradney | 867 | QFileInfo fInfo(item->Pfile); |
868 | QString ext = fInfo.extension(false); |
||
5959 | jghali | 869 | CMSettings cmsSettings(item->doc(), item->IProfile, item->IRender); |
4360 | cbradney | 870 | scImg.imgInfo.valid = false; |
871 | scImg.imgInfo.clipPath = ""; |
||
872 | scImg.imgInfo.PDSpathData.clear(); |
||
873 | scImg.imgInfo.layerInfo.clear(); |
||
874 | scImg.imgInfo.RequestProps = item->pixm.imgInfo.RequestProps; |
||
875 | scImg.imgInfo.isRequest = item->pixm.imgInfo.isRequest; |
||
5959 | jghali | 876 | scImg.LoadPicture(item->Pfile, cmsSettings, item->UseEmbedded, m_useProfiles, translateImageModeToRequest(imageMode), m_imageRes, &dummy); |
4360 | cbradney | 877 | if( ext == "eps" || ext == "pdf" || ext == "ps" ) |
878 | { |
||
879 | imScaleX *= (72.0 / (double) m_imageRes); |
||
880 | imScaleY *= (72.0 / (double) m_imageRes); |
||
881 | } |
||
4617 | avox | 882 | scImg.applyEffect(item->effectsInUse, m_doc->PageColors, useCmyk); |
4989 | cbradney | 883 | mode = imageMode; |
4360 | cbradney | 884 | pImage = &scImg; |
885 | } |
||
886 | else |
||
887 | pImage = &item->pixm; |
||
888 | |||
889 | painter->save(); |
||
890 | if (item->imageClip.size() != 0) |
||
4751 | cbradney | 891 | { |
4360 | cbradney | 892 | painter->setupPolygon(&item->imageClip); |
4751 | cbradney | 893 | painter->setClipPath(); |
894 | } |
||
895 | painter->setupPolygon(&item->PoLine); |
||
4360 | cbradney | 896 | painter->setClipPath(); |
897 | if (item->imageFlippedH()) |
||
898 | { |
||
6987 | jghali | 899 | painter->translate(item->width(), 0); |
4360 | cbradney | 900 | painter->scale(-1, 1); |
901 | } |
||
902 | if (item->imageFlippedV()) |
||
903 | { |
||
6987 | jghali | 904 | painter->translate(0, item->height()); |
4360 | cbradney | 905 | painter->scale(1, -1); |
906 | } |
||
6987 | jghali | 907 | painter->translate(item->imageXOffset() * item->imageXScale(), item->imageYOffset() * item->imageYScale()); |
4360 | cbradney | 908 | //painter->translate(item->LocalX * imScaleX * scale, item->LocalY * imScaleY * scale); ?? |
909 | painter->scale( imScaleX, imScaleY ); |
||
910 | if (pImage->imgInfo.lowResType != 0) |
||
911 | painter->scale(pImage->imgInfo.lowResScale, pImage->imgInfo.lowResScale); |
||
4989 | cbradney | 912 | painter->drawImage(pImage, mode); |
4360 | cbradney | 913 | painter->restore(); |
914 | } |
||
915 | } |
||
916 | } |
||
917 | |||
6987 | jghali | 918 | void ScPageOutput::DrawItem_Line( PageItem_Line* item, ScPainterExBase* painter, QRect& clip ) |
4360 | cbradney | 919 | { |
920 | int startArrowIndex; |
||
921 | int endArrowIndex; |
||
4546 | subik | 922 | |
4360 | cbradney | 923 | startArrowIndex = item->startArrowIndex(); |
924 | endArrowIndex = item->endArrowIndex(); |
||
925 | |||
926 | if (item->NamedLStyle.isEmpty()) |
||
927 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), 0)); |
||
928 | else |
||
929 | { |
||
930 | multiLine ml = m_doc->MLineStyles[item->NamedLStyle]; |
||
931 | for (int it = ml.size()-1; it > -1; it--) |
||
932 | { |
||
933 | ScColorShade colorShade(m_doc->PageColors[ml[it].Color], ml[it].Shade); |
||
934 | painter->setPen(colorShade, ml[it].Width, |
||
935 | static_cast<Qt::PenStyle>(ml[it].Dash), |
||
936 | static_cast<Qt::PenCapStyle>(ml[it].LineEnd), |
||
937 | static_cast<Qt::PenJoinStyle>(ml[it].LineJoin)); |
||
938 | painter->drawLine(FPoint(0, 0), FPoint(item->width(), 0)); |
||
939 | } |
||
940 | } |
||
941 | if (startArrowIndex != 0) |
||
942 | { |
||
943 | QWMatrix arrowTrans; |
||
944 | FPointArray arrow = ( *m_doc->arrowStyles.at(startArrowIndex - 1) ).points.copy(); |
||
945 | arrowTrans.translate( 0, 0 ); |
||
946 | arrowTrans.scale( item->lineWidth(), item->lineWidth()); |
||
947 | arrowTrans.scale( -1 , 1 ); |
||
948 | arrow.map( arrowTrans ); |
||
949 | painter->setBrush( painter->pen() ); |
||
950 | painter->setBrushOpacity( 1.0 - item->lineTransparency() ); |
||
951 | painter->setLineWidth( 0 ); |
||
952 | painter->setFillMode(ScPainterExBase::Solid); |
||
953 | painter->setupPolygon( &arrow ); |
||
6987 | jghali | 954 | FillPath(item, painter, clip); |
4360 | cbradney | 955 | } |
956 | if (endArrowIndex != 0) |
||
957 | { |
||
958 | QWMatrix arrowTrans; |
||
959 | FPointArray arrow = (*m_doc->arrowStyles.at(endArrowIndex-1) ).points.copy(); |
||
960 | arrowTrans.translate( item->width(), 0 ); |
||
961 | arrowTrans.scale( item->lineWidth(), item->lineWidth()); |
||
962 | arrow.map( arrowTrans ); |
||
963 | painter->setBrush( painter->pen() ); |
||
964 | painter->setBrushOpacity( 1.0 - item->lineTransparency() ); |
||
965 | painter->setLineWidth( 0 ); |
||
966 | painter->setFillMode( ScPainterExBase::Solid ); |
||
967 | painter->setupPolygon( &arrow ); |
||
6987 | jghali | 968 | FillPath(item, painter, clip); |
4360 | cbradney | 969 | } |
970 | } |
||
971 | |||
6987 | jghali | 972 | void ScPageOutput::DrawItem_PathText( PageItem_PathText* item, ScPainterExBase* painter, QRect& clip ) |
4360 | cbradney | 973 | { |
5753 | jghali | 974 | int a; |
4360 | cbradney | 975 | int chs; |
976 | double wide; |
||
5721 | avox | 977 | QString chstr, chstr2, chstr3; |
4689 | mrdocs | 978 | ScText *hl; |
4360 | cbradney | 979 | double dx; |
980 | double sp = 0; |
||
981 | double oldSp = 0; |
||
982 | double oCurX = 0; |
||
983 | FPoint point = FPoint(0, 0); |
||
984 | FPoint normal = FPoint(0, 0); |
||
985 | FPoint tangent = FPoint(0, 0); |
||
986 | FPoint extPoint = FPoint(0, 0); |
||
987 | bool ext = false; |
||
988 | bool first = true; |
||
989 | double fsx = 0; |
||
990 | uint seg = 0; |
||
991 | double segLen = 0; |
||
992 | double distCurX; |
||
993 | double CurX = item->textToFrameDistLeft(); // item->CurX = item->textToFrameDistLeft() |
||
994 | double CurY = 0; |
||
4546 | subik | 995 | if (item->lineColor() != CommonStrings::None && item->PoShow) |
4360 | cbradney | 996 | { |
997 | painter->setupPolygon(&item->PoLine, false); |
||
998 | painter->strokePath(); |
||
999 | } |
||
5729 | jghali | 1000 | if (item->itemText.length() != 0) |
1001 | CurX += item->itemText.item(0)->fontSize() * item->itemText.item(0)->tracking() / 10000.0; |
||
4360 | cbradney | 1002 | segLen = item->PoLine.lenPathSeg(seg); |
5729 | jghali | 1003 | for (a = 0; a < item->itemText.length(); ++a) |
4360 | cbradney | 1004 | { |
1005 | CurY = 0; |
||
5729 | jghali | 1006 | hl = item->itemText.item(a); |
5721 | avox | 1007 | chstr = hl->ch; |
1008 | if ((chstr == QChar(30)) || (chstr == QChar(13)) || (chstr == QChar(9)) || (chstr == QChar(28))) |
||
4360 | cbradney | 1009 | continue; |
5692 | jghali | 1010 | chs = hl->fontSize(); |
5988 | jghali | 1011 | //item->SetZeichAttr(*hl, &chs, &chstr); //FIXME: layoutglyphs |
5721 | avox | 1012 | if (chstr == QChar(29)) |
1013 | chstr2 = " "; |
||
1014 | else if (chstr == QChar(24)) |
||
1015 | chstr2 = "-"; |
||
4360 | cbradney | 1016 | else |
5721 | avox | 1017 | chstr2 = chstr; |
5729 | jghali | 1018 | if (a < item->itemText.length() - 1) |
4360 | cbradney | 1019 | { |
5729 | jghali | 1020 | if (item->itemText.item(a+1)->ch == QChar(29)) |
5721 | avox | 1021 | chstr3 = " "; |
5729 | jghali | 1022 | else if (item->itemText.item(a+1)->ch == QChar(24)) |
5721 | avox | 1023 | chstr3 = "-"; |
4360 | cbradney | 1024 | else |
5721 | avox | 1025 | chstr3 = item->itemText.text(a+1, 1); |
5988 | jghali | 1026 | wide = hl->font().charWidth(chstr2[0], chs, chstr3[0]); |
4360 | cbradney | 1027 | } |
1028 | else |
||
5988 | jghali | 1029 | wide = hl->font().charWidth(chstr2[0], chs); |
5692 | jghali | 1030 | wide = wide * (hl->scaleH() / 1000.0); |
4360 | cbradney | 1031 | dx = wide / 2.0; |
1032 | CurX += dx; |
||
1033 | ext = false; |
||
1034 | while ( (seg < item->PoLine.size()-3) && (CurX > fsx + segLen)) |
||
1035 | { |
||
1036 | fsx += segLen; |
||
1037 | seg += 4; |
||
1038 | if (seg > item->PoLine.size()-3) |
||
1039 | break; |
||
1040 | segLen = item->PoLine.lenPathSeg(seg); |
||
1041 | ext = true; |
||
1042 | } |
||
1043 | if (seg > item->PoLine.size()-3) |
||
1044 | break; |
||
1045 | if (CurX > fsx + segLen) |
||
1046 | break; |
||
1047 | if (ext) |
||
1048 | { |
||
1049 | sp = 0; |
||
1050 | distCurX = item->PoLine.lenPathDist(seg, 0, sp); |
||
1051 | while (distCurX <= ((CurX - oCurX) - (fsx - oCurX))) |
||
1052 | { |
||
1053 | sp += 0.001; |
||
1054 | distCurX = item->PoLine.lenPathDist(seg, 0, sp); |
||
1055 | } |
||
1056 | item->PoLine.pointTangentNormalAt(seg, sp, &point, &tangent, &normal ); |
||
1057 | CurX = (CurX - (CurX - fsx)) + distCurX; |
||
1058 | oldSp = sp; |
||
1059 | ext = false; |
||
1060 | } |
||
1061 | else |
||
1062 | { |
||
1063 | if( seg < item->PoLine.size()-3 ) |
||
1064 | { |
||
1065 | if (CurX > fsx + segLen) |
||
1066 | break; |
||
1067 | distCurX = item->PoLine.lenPathDist(seg, oldSp, sp); |
||
1068 | while (distCurX <= (CurX - oCurX)) |
||
1069 | { |
||
1070 | sp += 0.001; |
||
1071 | if (sp >= 1.0) |
||
1072 | { |
||
1073 | sp = 0.9999; |
||
1074 | break; |
||
1075 | } |
||
1076 | distCurX = item->PoLine.lenPathDist(seg, oldSp, sp); |
||
1077 | } |
||
1078 | item->PoLine.pointTangentNormalAt(seg, sp, &point, &tangent, &normal ); |
||
1079 | CurX = oCurX + distCurX; |
||
1080 | oldSp = sp; |
||
1081 | } |
||
1082 | else |
||
1083 | break; |
||
1084 | } |
||
5692 | jghali | 1085 | hl->glyph.xoffset = point.x(); |
1086 | hl->glyph.yoffset = point.y(); |
||
4360 | cbradney | 1087 | hl->PtransX = tangent.x(); |
1088 | hl->PtransY = tangent.y(); |
||
1089 | hl->PRot = dx; |
||
6987 | jghali | 1090 | QWMatrix trafo = QWMatrix( 1, 0, 0, -1, -dx, 0 ); |
1091 | trafo *= QWMatrix( tangent.x(), tangent.y(), tangent.y(), -tangent.x(), point.x(), point.y() ); |
||
4360 | cbradney | 1092 | QWMatrix sca = painter->worldMatrix(); |
1093 | trafo *= sca; |
||
1094 | painter->save(); |
||
1095 | QWMatrix savWM = painter->worldMatrix(); |
||
1096 | painter->setWorldMatrix(trafo); |
||
5988 | jghali | 1097 | //DrawCharacters(item, painter, Zli); |
4360 | cbradney | 1098 | painter->setWorldMatrix(savWM); |
1099 | painter->restore(); |
||
5580 | jghali | 1100 | //item->MaxChars = a+1; |
4360 | cbradney | 1101 | oCurX = CurX; |
1102 | CurX -= dx; |
||
5692 | jghali | 1103 | CurX += wide+hl->fontSize() * hl->tracking() / 10000.0; |
4360 | cbradney | 1104 | first = false; |
1105 | } |
||
1106 | } |
||
1107 | |||
6987 | jghali | 1108 | void ScPageOutput::DrawItem_Polygon ( PageItem_Polygon* item , ScPainterExBase* painter, QRect& clip ) |
4360 | cbradney | 1109 | { |
1110 | painter->setupPolygon(&item->PoLine); |
||
6987 | jghali | 1111 | FillPath(item, painter, clip); |
4360 | cbradney | 1112 | } |
1113 | |||
6987 | jghali | 1114 | void ScPageOutput::DrawItem_PolyLine( PageItem_PolyLine* item, ScPainterExBase* painter, QRect& clip ) |
4360 | cbradney | 1115 | { |
1116 | int startArrowIndex; |
||
1117 | int endArrowIndex; |
||
4546 | subik | 1118 | |
4360 | cbradney | 1119 | startArrowIndex = item->startArrowIndex(); |
1120 | endArrowIndex = item->endArrowIndex(); |
||
1121 | |||
1122 | if (item->PoLine.size()>=4) |
||
1123 | { |
||
4546 | subik | 1124 | if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0)) |
4360 | cbradney | 1125 | { |
1126 | FPointArray cli; |
||
1127 | FPoint Start; |
||
1128 | bool firstp = true; |
||
1129 | for (uint n = 0; n < item->PoLine.size()-3; n += 4) |
||
1130 | { |
||
1131 | if (firstp) |
||
1132 | { |
||
1133 | Start = item->PoLine.point(n); |
||
1134 | firstp = false; |
||
1135 | } |
||
1136 | if (item->PoLine.point(n).x() > 900000) |
||
1137 | { |
||
1138 | cli.addPoint(item->PoLine.point(n-2)); |
||
1139 | cli.addPoint(item->PoLine.point(n-2)); |
||
1140 | cli.addPoint(Start); |
||
1141 | cli.addPoint(Start); |
||
1142 | cli.setMarker(); |
||
1143 | firstp = true; |
||
1144 | continue; |
||
1145 | } |
||
1146 | cli.addPoint(item->PoLine.point(n)); |
||
1147 | cli.addPoint(item->PoLine.point(n+1)); |
||
1148 | cli.addPoint(item->PoLine.point(n+2)); |
||
1149 | cli.addPoint(item->PoLine.point(n+3)); |
||
1150 | } |
||
1151 | if (cli.size() > 2) |
||
1152 | { |
||
1153 | FPoint l1 = cli.point(cli.size()-2); |
||
1154 | cli.addPoint(l1); |
||
1155 | cli.addPoint(l1); |
||
1156 | cli.addPoint(Start); |
||
1157 | cli.addPoint(Start); |
||
1158 | } |
||
1159 | painter->setupPolygon(&cli); |
||
6987 | jghali | 1160 | FillPath(item, painter, clip); |
4360 | cbradney | 1161 | } |
1162 | painter->setupPolygon(&item->PoLine, false); |
||
1163 | if (item->NamedLStyle.isEmpty()) |
||
1164 | painter->strokePath(); |
||
1165 | else |
||
1166 | { |
||
1167 | multiLine ml = m_doc->MLineStyles[item->NamedLStyle]; |
||
1168 | for (int it = ml.size()-1; it > -1; it--) |
||
1169 | { |
||
1170 | ScColorShade tmp(m_doc->PageColors[ml[it].Color], ml[it].Shade); |
||
1171 | painter->setPen(tmp, ml[it].Width, |
||
1172 | static_cast<Qt::PenStyle>(ml[it].Dash), |
||
1173 | static_cast<Qt::PenCapStyle>(ml[it].LineEnd), |
||
1174 | static_cast<Qt::PenJoinStyle>(ml[it].LineJoin)); |
||
1175 | painter->strokePath(); |
||
1176 | } |
||
1177 | } |
||
1178 | if (startArrowIndex != 0) |
||
1179 | { |
||
1180 | FPoint Start = item->PoLine.point(0); |
||
1181 | for (uint xx = 1; xx < item->PoLine.size(); xx += 2) |
||
1182 | { |
||
1183 | FPoint Vector = item->PoLine.point(xx); |
||
1184 | if ((Start.x() != Vector.x()) || (Start.y() != Vector.y())) |
||
1185 | { |
||
1186 | double r = atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI); |
||
1187 | QWMatrix arrowTrans; |
||
1188 | FPointArray arrow = (*m_doc->arrowStyles.at(startArrowIndex-1)).points.copy(); |
||
1189 | arrowTrans.translate(Start.x(), Start.y()); |
||
1190 | arrowTrans.rotate(r); |
||
1191 | arrowTrans.scale(item->lineWidth(), item->lineWidth()); |
||
1192 | arrow.map(arrowTrans); |
||
1193 | painter->setBrush(painter->pen()); |
||
1194 | painter->setBrushOpacity(1.0 - item->lineTransparency()); |
||
1195 | painter->setLineWidth(0); |
||
1196 | painter->setFillMode(ScPainterExBase::Solid); |
||
1197 | painter->setupPolygon(&arrow); |
||
6987 | jghali | 1198 | FillPath(item, painter, clip); |
4360 | cbradney | 1199 | break; |
1200 | } |
||
1201 | } |
||
1202 | } |
||
1203 | if (endArrowIndex != 0) |
||
1204 | { |
||
1205 | FPoint End = item->PoLine.point(item->PoLine.size()-2); |
||
1206 | for (uint xx = item->PoLine.size()-1; xx > 0; xx -= 2) |
||
1207 | { |
||
1208 | FPoint Vector = item->PoLine.point(xx); |
||
1209 | if ((End.x() != Vector.x()) || (End.y() != Vector.y())) |
||
1210 | { |
||
1211 | double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI); |
||
1212 | QWMatrix arrowTrans; |
||
1213 | FPointArray arrow = (*m_doc->arrowStyles.at(endArrowIndex-1)).points.copy(); |
||
1214 | arrowTrans.translate(End.x(), End.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 | } |
||
1229 | } |
||
1230 | |||
6987 | jghali | 1231 | void ScPageOutput::DrawItem_TextFrame( PageItem_TextFrame* item, ScPainterExBase* painter, QRect& clip ) |
4360 | cbradney | 1232 | { |
5580 | jghali | 1233 | QWMatrix wm; |
1234 | QPoint pt1, pt2; |
||
1235 | FPoint ColBound; |
||
1236 | QRegion cm; |
||
5753 | jghali | 1237 | int a; |
6824 | jghali | 1238 | double lineCorr; |
5721 | avox | 1239 | QString chstr, chstr2, chstr3; |
5580 | jghali | 1240 | ScText *hl; |
4360 | cbradney | 1241 | |
5580 | jghali | 1242 | QValueList<ParagraphStyle::TabRecord> tTabValues; |
1243 | double desc, asce, tabDist; |
||
1244 | tTabValues.clear(); |
||
6824 | jghali | 1245 | |
1246 | QRect e2; |
||
5580 | jghali | 1247 | painter->save(); |
6824 | jghali | 1248 | if (item->isEmbedded) |
6987 | jghali | 1249 | e2 = clip; |
6824 | jghali | 1250 | else |
1251 | { |
||
6987 | jghali | 1252 | e2 = QRect(qRound(clip.x() + m_doc->minCanvasCoordinate.x()), qRound(clip.y() + m_doc->minCanvasCoordinate.y()), qRound(clip.width()), qRound(clip.height())); |
6824 | jghali | 1253 | wm.translate(item->xPos(), item->yPos()); |
1254 | } |
||
5580 | jghali | 1255 | wm.rotate(item->rotation()); |
1256 | if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0)) |
||
1257 | { |
||
1258 | painter->setupPolygon(&item->PoLine); |
||
6987 | jghali | 1259 | FillPath(item, painter, clip); |
5580 | jghali | 1260 | } |
1261 | if (item->lineColor() != CommonStrings::None) |
||
1262 | lineCorr = item->lineWidth() / 2.0; |
||
1263 | else |
||
1264 | lineCorr = 0; |
||
1265 | if ((item->isAnnotation()) && (item->annotation().Type() == 2) && (!item->Pfile.isEmpty()) && (item->PicAvail) && (item->imageShown()) && (item->annotation().UseIcons())) |
||
1266 | { |
||
1267 | painter->setupPolygon(&item->PoLine); |
||
1268 | painter->setClipPath(); |
||
1269 | painter->save(); |
||
1270 | painter->scale(item->imageXScale(), item->imageYScale()); |
||
1271 | painter->translate(static_cast<int>(item->imageXOffset() * item->imageXScale()), static_cast<int>(item->imageYOffset() * item->imageYScale())); |
||
5599 | jghali | 1272 | if (!item->pixm.qImage().isNull()) |
5580 | jghali | 1273 | painter->drawImage(&item->pixm, ScPainterExBase::rgbImages); |
1274 | painter->restore(); |
||
1275 | } |
||
5729 | jghali | 1276 | if ((item->itemText.length() != 0)) |
5580 | jghali | 1277 | { |
1278 | if (item->imageFlippedH()) |
||
1279 | { |
||
6987 | jghali | 1280 | painter->translate(item->width(), 0); |
5580 | jghali | 1281 | painter->scale(-1, 1); |
1282 | } |
||
1283 | if (item->imageFlippedV()) |
||
1284 | { |
||
6987 | jghali | 1285 | painter->translate(0, item->height()); |
5580 | jghali | 1286 | painter->scale(1, -1); |
1287 | } |
||
1288 | uint tabCc = 0; |
||
6824 | jghali | 1289 | for (uint ll=0; ll < item->itemText.lines(); ++ll) |
5580 | jghali | 1290 | { |
6824 | jghali | 1291 | LineSpec ls = item->itemText.line(ll); |
1292 | tabDist = ls.x; |
||
1293 | double CurX = ls.x; |
||
1294 | for (a = ls.firstItem; a <= ls.lastItem; ++a) |
||
4360 | cbradney | 1295 | { |
6824 | jghali | 1296 | hl = item->itemText.item(a); |
1297 | const CharStyle& charStyle = item->itemText.charStyle(a); |
||
1298 | const ParagraphStyle& style = item->itemText.paragraphStyle(a); |
||
1299 | tTabValues = style.tabValues(); |
||
1300 | double chs = charStyle.fontSize() * hl->glyph.scaleV; |
||
1301 | bool selected = item->itemText.selected(a); |
||
1302 | if (charStyle.effects() & ScStyle_StartOfLine) |
||
1303 | tabCc = 0; |
||
1304 | chstr = hl->ch; |
||
1305 | if (hl->glyph.glyph == 0) |
||
1306 | continue; |
||
1307 | if (charStyle.fillColor() != CommonStrings::None) |
||
4360 | cbradney | 1308 | { |
6824 | jghali | 1309 | ScColorShade tmp(m_doc->PageColors[charStyle.fillColor()], hl->fillShade()); |
1310 | painter->setBrush(tmp); |
||
4360 | cbradney | 1311 | } |
6824 | jghali | 1312 | if (charStyle.strokeColor() != CommonStrings::None) |
4360 | cbradney | 1313 | { |
6824 | jghali | 1314 | ScColorShade tmp(m_doc->PageColors[charStyle.strokeColor()], hl->strokeShade()); |
1315 | painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
||
4360 | cbradney | 1316 | } |
6824 | jghali | 1317 | if (charStyle.effects() & ScStyle_DropCap) |
4360 | cbradney | 1318 | { |
6824 | jghali | 1319 | if (style.useBaselineGrid()) |
1320 | chs = qRound(10 * ((m_doc->typographicSettings.valueBaseGrid * (style.dropCapLines()-1) + (charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10))); |
||
1321 | else |
||
4360 | cbradney | 1322 | { |
6824 | jghali | 1323 | if (style.lineSpacingMode() == ParagraphStyle::FixedLineSpacing) |
1324 | chs = qRound(10 * ((style.lineSpacing() * (style.dropCapLines()-1)+(charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10))); |
||
1325 | else |
||
1326 | { |
||
1327 | double currasce = charStyle.font().height(style.charStyle().fontSize() / 10.0); |
||
1328 | chs = qRound(10 * ((currasce * (style.dropCapLines()-1)+(charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10))); |
||
1329 | } |
||
4360 | cbradney | 1330 | } |
5580 | jghali | 1331 | } |
6824 | jghali | 1332 | if ((chstr == SpecialChars::TAB) && (tTabValues.count() != 0) && (tabCc < tTabValues.count()) && (!tTabValues[tabCc].tabFillChar.isNull())) |
5580 | jghali | 1333 | { |
6824 | jghali | 1334 | QChar tabFillChar(tTabValues[tabCc].tabFillChar); |
1335 | double wt = charStyle.font().charWidth(tabFillChar, chs / 10.0); |
||
1336 | int coun = static_cast<int>((CurX - tabDist) / wt); |
||
1337 | double sPos = tabDist - CurX + hl->glyph.xoffset + 1; |
||
1338 | desc = -charStyle.font().descent(chs / 10.0); |
||
1339 | asce = charStyle.font().ascent(chs / 10.0); |
||
1340 | GlyphLayout tglyph; |
||
1341 | tglyph.glyph = tabFillChar.unicode(); |
||
1342 | tglyph.yoffset = hl->glyph.yoffset; |
||
1343 | tglyph.scaleV = tglyph.scaleH = chs / charStyle.fontSize(); |
||
1344 | tglyph.xadvance = wt; |
||
1345 | painter->save(); |
||
1346 | for (int cx = 0; cx < coun; ++cx) |
||
1347 | { |
||
1348 | tglyph.xoffset = sPos + wt * cx; |
||
1349 | 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 | 1350 | DrawGlyphs(item, painter, charStyle, tglyph, clip); |
6824 | jghali | 1351 | } |
1352 | painter->restore(); |
||
5580 | jghali | 1353 | } |
6824 | jghali | 1354 | if (chstr[0] == SpecialChars::TAB) |
1355 | tabCc++; |
||
1356 | //if (!m_doc->RePos) |
||
5580 | jghali | 1357 | { |
6824 | jghali | 1358 | double xcoZli = CurX + hl->glyph.xoffset; |
1359 | desc = - charStyle.font().descent(charStyle.fontSize() / 10.0); |
||
1360 | asce = charStyle.font().ascent(charStyle.fontSize() / 10.0); |
||
1361 | if (charStyle.strokeColor() != CommonStrings::None) |
||
1362 | { |
||
1363 | ScColorShade tmp(m_doc->PageColors[charStyle.strokeColor()], charStyle.strokeShade()); |
||
1364 | painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
||
1365 | } |
||
1366 | 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))))) |
||
1367 | { |
||
1368 | painter->save(); |
||
6987 | jghali | 1369 | painter->translate(CurX, ls.y); |
6824 | jghali | 1370 | if (hl->ch[0] == SpecialChars::OBJECT) |
1371 | { |
||
6987 | jghali | 1372 | DrawItem_Embedded(item, painter, clip, charStyle, hl->cembedded); |
1373 | CurX += (hl->cembedded->gWidth + hl->cembedded->lineWidth()); |
||
6824 | jghali | 1374 | } |
1375 | else |
||
1376 | { |
||
6987 | jghali | 1377 | DrawGlyphs(item, painter, charStyle, hl->glyph, clip); |
6824 | jghali | 1378 | CurX += hl->glyph.wide(); |
1379 | } |
||
1380 | painter->restore(); |
||
1381 | } |
||
5580 | jghali | 1382 | } |
6824 | jghali | 1383 | tabDist = CurX; |
4360 | cbradney | 1384 | } |
1385 | } |
||
1386 | } |
||
5580 | jghali | 1387 | painter->restore(); |
4360 | cbradney | 1388 | } |
1389 | |||
7108 | jghali | 1390 | void ScPageOutput::DrawMarks( Page* page, ScPainterExBase* painter, const MarksOptions& options ) |
1391 | { |
||
1392 | double markOffs = options.markOffset; |
||
1393 | double bleedLeft = 0.0, bleedRight = 0.0; |
||
1394 | double bleedBottom = options.BleedBottom; |
||
1395 | double bleedTop = options.BleedTop; |
||
1396 | if (!options.cropMarks && !options.bleedMarks && !options.registrationMarks && !options.colorMarks) |
||
1397 | return; |
||
1398 | if (m_doc->locationOfPage(page->pageNr()) == LeftPage) |
||
1399 | { |
||
1400 | bleedRight = options.BleedRight; |
||
1401 | bleedLeft = options.BleedLeft; |
||
1402 | } |
||
1403 | else if (m_doc->locationOfPage(page->pageNr()) == RightPage) |
||
1404 | { |
||
1405 | bleedRight = options.BleedLeft; |
||
1406 | bleedLeft = options.BleedRight; |
||
1407 | } |
||
1408 | else |
||
1409 | { |
||
1410 | bleedRight = options.BleedLeft; |
||
1411 | bleedLeft = options.BleedLeft; |
||
1412 | } |
||
1413 | double width = page->width(); |
||
1414 | double height = page->height(); |
||
1415 | double offsetX = page->xOffset(); |
||
1416 | double offsetY = page->yOffset(); |
||
1417 | painter->save(); |
||
1418 | painter->setLineWidth(0.5); |
||
1419 | painter->setPen(ScColorShade(Qt::black, 100), 0.5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin ); |
||
1420 | if (options.cropMarks) |
||
1421 | { |
||
1422 | FPoint start, end; |
||
1423 | double left = offsetX, right = offsetX + width; |
||
1424 | double bottom = offsetY + height, top = offsetY; |
||
1425 | DrawBoxMarks( painter, FPoint(left, top), FPoint(right, bottom), markOffs ); |
||
1426 | } |
||
1427 | if (options.bleedMarks) |
||
1428 | { |
||
1429 | FPoint start, end; |
||
1430 | double left = offsetX - bleedLeft, right = offsetX + width + bleedRight; |
||
1431 | double bottom = offsetY + height + bleedBottom, top = offsetY - bleedTop;; |
||
1432 | DrawBoxMarks( painter, FPoint(left, top), FPoint(right, bottom), markOffs ); |
||
1433 | } |
||
1434 | if (options.registrationMarks) |
||
1435 | { |
||
1436 | double posX = (2* offsetX + width) / 2.0 - 7.0; |
||
1437 | double posY = (offsetY + height + bleedBottom + markOffs + 3.0); |
||
1438 | painter->save(); |
||
1439 | painter->translate(posX, posY); |
||
1440 | DrawRegistrationCross( painter ); |
||
1441 | painter->restore(); |
||
1442 | posX = (2 * offsetX + width) / 2.0 - 7.0; |
||
1443 | posY = (offsetY - bleedTop - markOffs - 17); |
||
1444 | painter->save(); |
||
1445 | painter->translate(posX, posY); |
||
1446 | DrawRegistrationCross( painter ); |
||
1447 | painter->restore(); |
||
1448 | |||
1449 | posX = (offsetX - bleedLeft - markOffs - 17); |
||
1450 | posY = (2 * offsetY + height) / 2.0 - 7.0; |
||
1451 | painter->save(); |
||
1452 | painter->translate(posX, posY); |
||
1453 | DrawRegistrationCross( painter ); |
||
1454 | painter->restore(); |
||
1455 | posX = (offsetX + width + bleedRight + markOffs + 3.0); |
||
1456 | posY = (2 * offsetY + height) / 2.0 - 7.0; |
||
1457 | painter->save(); |
||
1458 | painter->translate(posX, posY); |
||
1459 | DrawRegistrationCross( painter ); |
||
1460 | painter->restore(); |
||
1461 | } |
||
1462 | if (options.colorMarks) |
||
1463 | { |
||
1464 | int shade = 100; |
||
1465 | double startX = offsetX + 6.0; |
||
1466 | double startY = offsetY - bleedTop - markOffs - 16.0; |
||
1467 | ScColorShade strokecolor( ScColor(0, 0, 0, 255), 100 ); |
||
1468 | painter->setPen( strokecolor, 0.5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin ); |
||
1469 | painter->setFillMode( ScPainterExBase::Solid ); |
||
1470 | for (int i = 0; i < 11; i++ ) |
||
1471 | { |
||
1472 | ScColorShade fillcolor( ScColor(0, 0, 0, 255), shade ); |
||
1473 | painter->setBrush( fillcolor ); |
||
1474 | painter->drawRect( startX + i * 14, startY, 14, 14 ); |
||
1475 | shade -= 10; |
||
1476 | } |
||
1477 | startX = offsetX + width - 20.0; |
||
1478 | painter->setBrush( ScColorShade(ScColor(0, 0, 0, 255), 50) ); |
||
1479 | painter->drawRect( startX, startY, 14, 14 ); |
||
1480 | startX -= 14; |
||
1481 | painter->setBrush( ScColorShade(ScColor(0, 0, 255, 0), 50) ); |
||
1482 | painter->drawRect( startX, startY, 14, 14 ); |
||
1483 | startX -= 14; |
||
1484 | painter->setBrush( ScColorShade(ScColor(0, 255, 0, 0), 50) ); |
||
1485 | painter->drawRect( startX, startY, 14, 14 ); |
||
1486 | startX -= 14; |
||
1487 | painter->setBrush( ScColorShade(ScColor(255, 0, 0, 0), 50) ); |
||
1488 | painter->drawRect( startX, startY, 14, 14 ); |
||
1489 | startX -= 14; |
||
1490 | painter->setBrush( ScColorShade(ScColor(255, 255, 0, 0), 100) ); |
||
1491 | painter->drawRect( startX, startY, 14, 14 ); |
||
1492 | startX -= 14; |
||
1493 | painter->setBrush( ScColorShade(ScColor(255, 0, 255, 0), 100) ); |
||
1494 | painter->drawRect( startX, startY, 14, 14 ); |
||
1495 | startX -= 14; |
||
1496 | painter->setBrush( ScColorShade(ScColor(0, 255, 255, 0), 100) ); |
||
1497 | painter->drawRect( startX, startY, 14, 14 ); |
||
1498 | startX -= 14; |
||
1499 | painter->setBrush( ScColorShade(ScColor(0, 0, 0, 255), 100) ); |
||
1500 | painter->drawRect( startX, startY, 14, 14 ); |
||
1501 | startX -= 14; |
||
1502 | painter->setBrush( ScColorShade(ScColor(0, 0, 255, 0), 100) ); |
||
1503 | painter->drawRect( startX, startY, 14, 14 ); |
||
1504 | startX -= 14; |
||
1505 | painter->setBrush( ScColorShade(ScColor(0, 255, 0, 0), 100) ); |
||
1506 | painter->drawRect( startX, startY, 14, 14 ); |
||
1507 | startX -= 14; |
||
1508 | painter->setBrush( ScColorShade(ScColor(255, 0, 0, 0), 100) ); |
||
1509 | painter->drawRect( startX, startY, 14, 14 ); |
||
1510 | } |
||
1511 | painter->restore(); |
||
1512 | } |
||
1513 | |||
1514 | void ScPageOutput::DrawBoxMarks( ScPainterExBase* painter, FPoint& topLeft, FPoint& bottomRight, double offset ) |
||
1515 | { |
||
1516 | FPoint start, end; |
||
1517 | double left = topLeft.x(), right = bottomRight.x(); |
||
1518 | double bottom = bottomRight.y(), top = topLeft.y(); |
||
1519 | // Top Left |
||
1520 | start.setXY( left - offset, top ); |
||
1521 | end.setXY ( left - offset - 20, top ); |
||
1522 | painter->drawLine(start, end); |
||
1523 | start.setXY( left, top - offset ); |
||
1524 | end.setXY ( left, top - offset - 20); |
||
1525 | painter->drawLine(start, end); |
||
1526 | // Top Right |
||
1527 | start.setXY( right + offset, top ); |
||
1528 | end.setXY ( right + offset + 20, top ); |
||
1529 | painter->drawLine(start, end); |
||
1530 | start.setXY( right, top - offset ); |
||
1531 | end.setXY ( right, top - offset - 20); |
||
1532 | painter->drawLine(start, end); |
||
1533 | // Bottom Left |
||
1534 | start.setXY( left - offset, bottom ); |
||
1535 | end.setXY ( left - offset - 20, bottom ); |
||
1536 | painter->drawLine(start, end); |
||
1537 | start.setXY( left, bottom + offset ); |
||
1538 | end.setXY ( left, bottom + offset + 20); |
||
1539 | painter->drawLine(start, end); |
||
1540 | // Bottom Right |
||
1541 | start.setXY( right + offset, bottom ); |
||
1542 | end.setXY ( right + offset + 20, bottom ); |
||
1543 | painter->drawLine(start, end); |
||
1544 | start.setXY( right, bottom + offset ); |
||
1545 | end.setXY ( right, bottom + offset + 20); |
||
1546 | painter->drawLine(start, end); |
||
1547 | } |
||
1548 | |||
1549 | void ScPageOutput::DrawRegistrationCross( ScPainterExBase* painter ) |
||
1550 | { |
||
1551 | painter->save(); |
||
1552 | |||
1553 | painter->newPath(); |
||
1554 | painter->moveTo(0.0, 7.0); |
||
1555 | painter->lineTo(14.0, 7.0); |
||
1556 | painter->strokePath(); |
||
1557 | |||
1558 | painter->newPath(); |
||
1559 | painter->moveTo(7.0, 0.0); |
||
1560 | painter->lineTo(7.0, 14.0); |
||
1561 | painter->strokePath(); |
||
1562 | |||
1563 | painter->newPath(); |
||
1564 | painter->moveTo(13.0, 7.0); |
||
1565 | painter->curveTo( FPoint(13.0, 10.31383), FPoint(10.31383, 13.0), FPoint(7.0, 13.0) ); |
||
1566 | painter->curveTo( FPoint(3.68629, 13.0) , FPoint(1.0, 10.31383) , FPoint(1.0, 7.0) ); |
||
1567 | painter->curveTo( FPoint(1.0, 3.68629) , FPoint(3.68629, 1.0) , FPoint(7.0, 1.0) ); |
||
1568 | painter->curveTo( FPoint(10.31383, 1.0) , FPoint(13.0, 3.68629) , FPoint(13.0, 7.0) ); |
||
1569 | painter->strokePath(); |
||
1570 | |||
1571 | painter->newPath(); |
||
1572 | painter->moveTo(10.5, 7.0); |
||
1573 | painter->curveTo( FPoint(10.5, 8.93307), FPoint(8.93307, 10.5), FPoint(7.0, 10.5) ); |
||
1574 | painter->curveTo( FPoint(5.067, 10.5) , FPoint(3.5, 8.93307) , FPoint(3.5, 7.0) ); |
||
1575 | painter->curveTo( FPoint(3.5, 5.067) , FPoint(5.067, 3.5) , FPoint(7.0, 3.5) ); |
||
1576 | painter->curveTo( FPoint(8.93307, 3.5) , FPoint(10.5, 5.067) , FPoint(10.5, 7.0) ); |
||
1577 | painter->strokePath(); |
||
1578 | |||
1579 | painter->restore(); |
||
1580 | } |
||
1581 | |||
6987 | jghali | 1582 | void ScPageOutput::FillPath( PageItem* item, ScPainterExBase* painter, QRect& clip ) |
1583 | { |
||
1584 | if( painter->fillMode() == ScPainterExBase::Pattern && !painter->hasCapability(ScPainterExBase::patterns) ) |
||
1585 | DrawPattern( item, painter, clip ); |
||
1586 | else |
||
1587 | painter->fillPath(); |
||
1588 | } |
||
4360 | cbradney | 1589 | |
6987 | jghali | 1590 | void ScPageOutput::StrokePath( PageItem* item, ScPainterExBase* painter, QRect& clip ) |
1591 | { |
||
1592 | painter->strokePath(); |
||
1593 | } |
||
1594 |