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