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