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