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