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