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