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