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