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.
7
#include "scpageoutput.h"
14
#include "cmsettings.h"
15
#include "commonstrings.h"
18
#include "pageitem_imageframe.h"
19
#include "pageitem_line.h"
20
#include "pageitem_pathtext.h"
21
#include "pageitem_polygon.h"
22
#include "pageitem_polyline.h"
23
#include "pageitem_textframe.h"
24
#include "prefsmanager.h"
27
#include "scpattern.h"
29
#include "scribusdoc.h"
31
#include "util_formats.h"
32
#include "util_math.h"
35
MarksOptions::MarksOptions(void)
44
registrationMarks = false;
49
MarksOptions::MarksOptions(struct PrintOptions& opt)
51
markOffset = opt.markOffset;
52
BleedTop = opt.bleeds.Top;
53
BleedLeft = opt.bleeds.Left;
54
BleedRight = opt.bleeds.Right;
55
BleedBottom = opt.bleeds.Bottom;
56
cropMarks = opt.cropMarks;
57
bleedMarks = opt.bleedMarks;
58
registrationMarks = opt.registrationMarks;
59
colorMarks = opt.colorMarks;
63
ScPageOutput::ScPageOutput(ScribusDoc* doc, bool reloadImages, int resolution, bool useProfiles)
67
m_reloadImages = reloadImages;
68
m_imageRes = resolution;
69
m_useProfiles = useProfiles;
72
ScImage::RequestType ScPageOutput::translateImageModeToRequest( ScPainterExBase::ImageMode mode )
74
ScImage::RequestType value = ScImage::RGBData;
75
if ( mode == ScPainterExBase::cmykImages )
76
value = ScImage::CMYKData;
77
else if ( mode == ScPainterExBase::rgbImages )
78
value = ScImage::RGBData;
79
else if ( mode == ScPainterExBase::rgbProofImages )
80
value = ScImage::RGBProof;
81
else if ( mode == ScPainterExBase::rawImages )
82
value = ScImage::RawData;
86
void ScPageOutput::drawPage( Page* page, ScPainterExBase* painter)
88
int clipx = static_cast<int>(page->xOffset());
89
int clipy = static_cast<int>(page->yOffset());
90
int clipw = qRound(page->width());
91
int cliph = qRound(page->height());
92
drawMasterItems(painter, page, QRect(clipx, clipy, clipw, cliph));
93
drawPageItems(painter, page, QRect(clipx, clipy, clipw, cliph));
94
drawMarks(page, painter, m_marksOptions);
97
void ScPageOutput::drawMasterItems(ScPainterExBase *painter, Page *page, const QRect& clip)
99
QStack<PageItem*> groupStack;
100
QStack<PageItem*> groupClips;
101
if (!page->MPageNam.isEmpty())
103
Page* Mp = m_doc->MasterPages.at(m_doc->MasterNames[page->MPageNam]);
104
if (page->FromMaster.count() != 0)
109
ll.isViewable = false;
112
uint layerCount = m_doc->layerCount();
113
for (uint la = 0; la < layerCount; ++la)
115
m_doc->Layers.levelToLayer(ll, Lnr);
117
if ( !ll.isPrintable )
119
if ((ll.isViewable) && (pr))
121
uint pageFromMasterCount=page->FromMaster.count();
122
for (uint a = 0; a < pageFromMasterCount; ++a)
124
currItem = page->FromMaster.at(a);
125
if (currItem->LayerNr != ll.LNr)
127
if ((currItem->OwnPage != -1) && (currItem->OwnPage != static_cast<int>(Mp->pageNr())))
129
if (!currItem->printEnabled())
131
if (currItem->isGroupControl)
134
groupClips.push(currItem);
135
groupStack.push(currItem->groupsLastItem);
138
int savedOwnPage = currItem->OwnPage;
139
double OldX = currItem->xPos();
140
double OldY = currItem->yPos();
141
double OldBX = currItem->BoundingX;
142
double OldBY = currItem->BoundingY;
143
currItem->OwnPage = page->pageNr();
144
if (!currItem->ChangedMasterItem)
146
currItem->moveBy(-Mp->xOffset() + page->xOffset(), -Mp->yOffset() + page->yOffset(), true);
147
currItem->BoundingX = OldBX - Mp->xOffset() + page->xOffset();
148
currItem->BoundingY = OldBY - Mp->yOffset() + page->yOffset();
151
currItem->Dirty = true;*/
152
QRect oldR(currItem->getRedrawBounding(1.0));
153
if (clip.intersects(oldR))
155
// relayout necessary to get page number ok
156
currItem->invalidateLayout();
158
drawItem(currItem, painter, clip);
160
currItem->OwnPage = savedOwnPage;
161
if (!currItem->ChangedMasterItem)
163
currItem->setXYPos(OldX, OldY, true);
164
currItem->BoundingX = OldBX;
165
currItem->BoundingY = OldBY;
167
if (groupStack.count() != 0)
169
while (currItem == groupStack.top())
172
PageItem *tmpItem = groupClips.pop();
173
FPointArray cl = tmpItem->PoLine.copy();
174
mm.translate(tmpItem->xPos(), tmpItem->yPos());
175
mm.rotate(tmpItem->rotation());
177
painter->setupPolygon(&cl);
178
painter->setClipPath();
181
if (groupStack.count() == 0)
186
for (uint a = 0; a < pageFromMasterCount; ++a)
188
currItem = page->FromMaster.at(a);
189
if (currItem->LayerNr != ll.LNr)
191
if (!currItem->isTableItem)
193
if ((currItem->OwnPage != -1) && (currItem->OwnPage != static_cast<int>(Mp->pageNr())))
195
double OldX = currItem->xPos();
196
double OldY = currItem->yPos();
197
double OldBX = currItem->BoundingX;
198
double OldBY = currItem->BoundingY;
199
if (!currItem->ChangedMasterItem)
201
currItem->setXPos(OldX - Mp->xOffset() + page->xOffset(), true);
202
currItem->setYPos(OldY - Mp->yOffset() + page->yOffset(), true);
203
currItem->BoundingX = OldBX - Mp->xOffset() + page->xOffset();
204
currItem->BoundingY = OldBY - Mp->yOffset() + page->yOffset();
206
QRect oldR(currItem->getRedrawBounding(1.0));
207
if (clip.intersects(oldR))
210
painter->translate(currItem->xPos(), currItem->yPos());
211
painter->rotate(currItem->rotation());
212
if (currItem->lineColor() != CommonStrings::None)
214
ScColorShade tmp( m_doc->PageColors[currItem->lineColor()], (int) currItem->lineShade());
215
if ((currItem->TopLine) || (currItem->RightLine) || (currItem->BottomLine) || (currItem->LeftLine))
217
painter->setPen(tmp, currItem->lineWidth(), currItem->PLineArt, Qt::SquareCap, currItem->PLineJoin);
218
if (currItem->TopLine)
219
painter->drawLine(FPoint(0.0, 0.0), FPoint(currItem->width(), 0.0));
220
if (currItem->RightLine)
221
painter->drawLine(FPoint(currItem->width(), 0.0), FPoint(currItem->width(), currItem->height()));
222
if (currItem->BottomLine)
223
painter->drawLine(FPoint(currItem->width(), currItem->height()), FPoint(0.0, currItem->height()));
224
if (currItem->LeftLine)
225
painter->drawLine(FPoint(0.0, currItem->height()), FPoint(0.0, 0.0));
230
if (!currItem->ChangedMasterItem)
232
currItem->setXPos(OldX, true);
233
currItem->setYPos(OldY, true);
234
currItem->BoundingX = OldBX;
235
currItem->BoundingY = OldBY;
245
void ScPageOutput::drawPageItems(ScPainterExBase *painter, Page *page, const QRect& clip)
247
//linkedFramesToShow.clear();
248
QStack<PageItem*> groupStack;
249
QStack<PageItem*> groupClips;
250
if (m_doc->Items->count() != 0)
255
ll.isViewable = false;
257
uint layerCount = m_doc->layerCount();
258
//int docCurrPageNo=static_cast<int>(m_doc->currentPageNumber());
259
int docCurrPageNo=static_cast<int>(page->pageNr());
260
for (uint la2 = 0; la2 < layerCount; ++la2)
262
m_doc->Layers.levelToLayer(ll, Lnr);
266
if ((ll.isViewable) && (pr))
268
for (int it = 0; it < m_doc->Items->count(); ++it)
270
currItem = m_doc->Items->at(it);
271
if (currItem->LayerNr != ll.LNr)
273
if (!currItem->printEnabled())
275
if ((m_doc->masterPageMode()) && ((currItem->OwnPage != -1) && (currItem->OwnPage != docCurrPageNo)))
277
if (!m_doc->masterPageMode() && !currItem->OnMasterPage.isEmpty())
279
if (currItem->OnMasterPage != page->pageName())
282
if (currItem->isGroupControl)
285
groupClips.push(currItem);
286
groupStack.push(currItem->groupsLastItem);
289
QRect oldR(currItem->getRedrawBounding(1.0));
290
if (clip.intersects(oldR))
292
drawItem( currItem, painter, clip );
293
if ((currItem->asTextFrame()) && ((currItem->nextInChain() != 0) || (currItem->prevInChain() != 0)))
295
PageItem *nextItem = currItem;
296
while (nextItem != 0)
298
if (nextItem->prevInChain() != 0)
299
nextItem = nextItem->prevInChain();
305
if (groupStack.count() != 0)
307
while (currItem == groupStack.top())
310
PageItem *tmpItem = groupClips.pop();
311
FPointArray cl = tmpItem->PoLine.copy();
312
mm.translate(tmpItem->xPos(), tmpItem->yPos());
313
mm.rotate(tmpItem->rotation());
315
painter->setupPolygon(&cl);
316
painter->setClipPath();
319
if (groupStack.count() == 0)
324
for (int it = 0; it < m_doc->Items->count(); ++it)
326
currItem = m_doc->Items->at(it);
327
if (currItem->LayerNr != ll.LNr)
329
if (!currItem->isTableItem)
331
QRect oldR(currItem->getRedrawBounding(1.0));
332
if (clip.intersects(oldR))
335
painter->translate(currItem->xPos(), currItem->yPos());
336
painter->rotate(currItem->rotation());
337
if (currItem->lineColor() != CommonStrings::None)
339
ScColorShade tmp( m_doc->PageColors[currItem->lineColor()], (int) currItem->lineShade() );
340
if ((currItem->TopLine) || (currItem->RightLine) || (currItem->BottomLine) || (currItem->LeftLine))
342
painter->setPen(tmp, currItem->lineWidth(), currItem->PLineArt, Qt::SquareCap, currItem->PLineJoin);
343
if (currItem->TopLine)
344
painter->drawLine(FPoint(0.0, 0.0), FPoint(currItem->width(), 0.0));
345
if (currItem->RightLine)
346
painter->drawLine(FPoint(currItem->width(), 0.0), FPoint(currItem->width(), currItem->height()));
347
if (currItem->BottomLine)
348
painter->drawLine(FPoint(currItem->width(), currItem->height()), FPoint(0.0, currItem->height()));
349
if (currItem->LeftLine)
350
painter->drawLine(FPoint(0.0, currItem->height()), FPoint(0.0, 0.0));
362
void ScPageOutput::drawItem( PageItem* item, ScPainterExBase* painter, const QRect& clip )
364
drawItem_Pre(item, painter);
365
PageItem::ItemType itemType = item->itemType();
366
if( itemType == PageItem::ImageFrame )
367
drawItem_ImageFrame( (PageItem_ImageFrame*) item, painter, clip);
368
else if( itemType == PageItem::Line )
369
drawItem_Line( (PageItem_Line*) item, painter, clip);
370
else if( itemType == PageItem::PathText )
371
drawItem_PathText( (PageItem_PathText*) item, painter, clip);
372
else if( itemType == PageItem::Polygon )
373
drawItem_Polygon( (PageItem_Polygon*) item, painter, clip);
374
else if( itemType == PageItem::PolyLine )
375
drawItem_PolyLine( (PageItem_PolyLine*) item, painter, clip);
376
else if( itemType == PageItem::TextFrame )
377
drawItem_TextFrame( (PageItem_TextFrame*) item, painter, clip);
378
drawItem_Post(item, painter);
381
void ScPageOutput::drawItem_Pre( PageItem* item, ScPainterExBase* painter)
384
if (!item->isEmbedded)
386
painter->translate( item->xPos(), item->yPos());
387
// painter->rotate(item->rotation());
389
painter->rotate(item->rotation());
390
painter->setLineWidth(item->lineWidth());
391
if (item->GrType == 8)
393
QString pat = item->pattern();
394
if ((pat.isEmpty()) || (!m_doc->docPatterns.contains(pat)))
396
painter->m_fillGradient = VGradientEx(VGradientEx::linear);
397
if (item->fillColor() != CommonStrings::None)
399
painter->setBrush(ScColorShade(m_doc->PageColors[item->fillColor()], (int) item->fillShade()));
400
painter->setFillMode(ScPainterExBase::Solid);
403
painter->setFillMode(ScPainterExBase::None);
407
QMatrix patternTransform;
408
ScPattern& pattern = m_doc->docPatterns[item->pattern()];
409
double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation;
410
item->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation);
411
patternTransform.translate(patternOffsetX, patternOffsetY);
412
patternTransform.rotate(patternRotation);
413
patternTransform.scale(pattern.scaleX, pattern.scaleY);
414
patternTransform.scale(patternScaleX / 100.0 , patternScaleY / 100.0);
415
painter->setPattern(&pattern, patternTransform);
416
painter->setFillMode(ScPainterExBase::Pattern);
419
else if (item->GrType != 0)
421
painter->setFillMode(ScPainterExBase::Gradient);
422
painter->m_fillGradient = VGradientEx(item->fill_gradient, *m_doc);
424
grm.rotate(item->rotation());
426
switch (item->GrType)
433
gra.setPoints(2, item->GrStartX, item->GrStartY, item->GrEndX, item->GrEndY);
435
painter->setGradient(VGradientEx::linear, gra.point(0), gra.point(1));
439
gra.setPoints(2, item->GrStartX, item->GrStartY, item->GrEndX, item->GrEndY);
440
painter->setGradient(VGradientEx::radial, gra.point(0), gra.point(1), gra.point(0));
446
painter->m_fillGradient = VGradientEx(VGradientEx::linear);
447
if (item->fillColor() != CommonStrings::None)
449
painter->setBrush( ScColorShade(m_doc->PageColors[item->fillColor()], (int) item->fillShade()) );
450
painter->setFillMode(ScPainterExBase::Solid);
453
painter->setFillMode(ScPainterExBase::None);
455
if (item->lineColor() != CommonStrings::None)
457
if ((item->lineWidth() == 0) && !item->asLine())
458
painter->setLineWidth(0);
461
ScColorShade tmp(m_doc->PageColors[item->lineColor()], (int) item->lineShade());
462
painter->setPen( tmp , item->lineWidth(), item->PLineArt, item->PLineEnd, item->PLineJoin);
463
if (item->DashValues.count() != 0)
464
painter->setDash(item->DashValues, item->DashOffset);
468
painter->setLineWidth(0);
469
painter->setBrushOpacity(1.0 - item->fillTransparency());
470
painter->setPenOpacity(1.0 - item->lineTransparency());
471
painter->setFillRule(item->fillRule);
474
void ScPageOutput::drawItem_Post( PageItem* item, ScPainterExBase* painter )
477
if ( item->itemType() == PageItem::PathText || item->itemType() == PageItem::PolyLine || item->itemType() == PageItem::Line )
481
if (item->lineColor() != CommonStrings::None)
483
ScColorShade tmp(m_doc->PageColors[item->lineColor()], (int) item->lineShade());
484
painter->setPen(tmp, item->lineWidth(), item->PLineArt, item->PLineEnd, item->PLineJoin);
485
if (item->DashValues.count() != 0)
486
painter->setDash(item->DashValues, item->DashOffset);
489
painter->setLineWidth(0);
490
if (!item->isTableItem)
492
painter->setupPolygon(&item->PoLine);
493
if (item->NamedLStyle.isEmpty())
494
painter->strokePath();
497
multiLine ml = m_doc->MLineStyles[item->NamedLStyle];
498
for (int it = ml.size()-1; it > -1; it--)
500
const SingleLine& sl = ml[it];
501
if ((sl.Color != CommonStrings::None) && (sl.Width != 0))
503
ScColorShade tmp(m_doc->PageColors[sl.Color], sl.Shade);
504
painter->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash),
505
static_cast<Qt::PenCapStyle>(sl.LineEnd),
506
static_cast<Qt::PenJoinStyle>(sl.LineJoin));
507
painter->strokePath();
513
// item->Tinput = false;
517
void ScPageOutput::drawGlyphs(PageItem* item, ScPainterExBase *painter, const CharStyle& style, GlyphLayout& glyphs, const QRect& clip)
519
uint glyph = glyphs.glyph;
520
if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode())) // NBSPACE
521
glyph = style.font().char2CMap(QChar(' '));
522
else if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBHYPHEN.unicode())) // NBHYPHEN
523
glyph = style.font().char2CMap(QChar('-'));
525
if (glyph >= ScFace::CONTROL_GLYPHS)
529
painter->translate(glyphs.xadvance, 0);
530
drawGlyphs(item, painter, style, *glyphs.more, clip);
535
//if (style.font().canRender(QChar(glyph)))
537
QMatrix chma, chma2, chma3, chma4, chma5, chma6;
538
chma.scale(glyphs.scaleH * style.fontSize() / 100.00, glyphs.scaleV * style.fontSize() / 100.0);
539
FPointArray gly = style.font().glyphOutline(glyph);
540
// Do underlining first so you can get typographically correct
541
// underlines when drawing a white outline
542
if ((style.effects() & ScStyle_Underline) || ((style.effects() & ScStyle_UnderlineWords) && (glyph != style.font().char2CMap(QChar(' ')))))
545
if ((style.underlineOffset() != -1) || (style.underlineWidth() != -1))
547
if (style.underlineOffset() != -1)
548
st = (style.underlineOffset() / 1000.0) * (style.font().descent(style.fontSize() / 10.0));
550
st = style.font().underlinePos(style.fontSize() / 10.0);
551
if (style.underlineWidth() != -1)
552
lw = (style.underlineWidth() / 1000.0) * (style.fontSize() / 10.0);
554
lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
558
st = style.font().underlinePos(style.fontSize() / 10.0);
559
lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
561
if (style.baselineOffset() != 0)
562
st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0);
563
ScColorShade tmpPen = painter->pen();
564
painter->setPen(painter->brush());
565
painter->setLineWidth(lw);
566
if (style.effects() & ScStyle_Subscript)
567
painter->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st));
569
painter->drawLine(FPoint(glyphs.xoffset, -st), FPoint(glyphs.xoffset + glyphs.xadvance, -st));
570
painter->setPen(tmpPen);
575
painter->translate(glyphs.xoffset, glyphs.yoffset - ((style.fontSize() / 10.0) * glyphs.scaleV));
576
if (item->reversed())
578
painter->scale(-1, 1);
579
painter->translate(-glyphs.xadvance, 0);
581
if (style.baselineOffset() != 0)
582
painter->translate(0, -(style.fontSize() / 10.0) * (style.baselineOffset() / 1000.0));
583
double glxSc = glyphs.scaleH * style.fontSize() / 100.00;
584
double glySc = glyphs.scaleV * style.fontSize() / 100.0;
585
painter->scale(glxSc, glySc);
586
painter->setFillMode(ScPainterExBase::Solid);
587
bool fr = painter->fillRule();
588
painter->setFillRule(false);
589
painter->setupPolygon(&gly, true);
592
ScColorShade tmp(PrefsManager::instance()->appPrefs.DControlCharColor, 100);
593
painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
594
painter->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() * 2 / 10000.0);
595
painter->strokePath();
597
else if ((style.font().isStroked()) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0))
599
ScColorShade tmp = painter->brush();
600
painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
601
painter->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0);
602
painter->strokePath();
606
if ((style.effects() & ScStyle_Shadowed) && (style.strokeColor() != CommonStrings::None))
609
painter->translate((style.fontSize() * glyphs.scaleH * style.shadowXOffset() / 10000.0) / glxSc, -(style.fontSize() * glyphs.scaleV * style.shadowYOffset() / 10000.0) / glySc);
610
ScColorShade tmp = painter->brush();
611
painter->setBrush(painter->pen());
612
painter->setupPolygon(&gly, true);
613
fillPath(item, painter, clip);
614
painter->setBrush(tmp);
616
painter->setupPolygon(&gly, true);
618
if (style.fillColor() != CommonStrings::None)
619
fillPath(item, painter, clip);
620
if ((style.effects() & ScStyle_Outline) && (style.strokeColor() != CommonStrings::None) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0))
622
painter->setLineWidth((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) / glySc);
623
painter->strokePath();
626
painter->setFillRule(fr);
629
if (style.effects() & ScStyle_Strikethrough)
632
if ((style.strikethruOffset() != -1) || (style.strikethruWidth() != -1))
634
if (style.strikethruOffset() != -1)
635
st = (style.strikethruOffset() / 1000.0) * (style.font().ascent(style.fontSize() / 10.0));
637
st = style.font().strikeoutPos(style.fontSize() / 10.0);
638
if (style.strikethruWidth() != -1)
639
lw = (style.strikethruWidth() / 1000.0) * (style.fontSize() / 10.0);
641
lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
645
st = style.font().strikeoutPos(style.fontSize() / 10.0);
646
lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
648
if (style.baselineOffset() != 0)
649
st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0);
650
painter->setPen(painter->brush());
651
painter->setLineWidth(lw);
652
painter->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st));
657
painter->setLineWidth(1);
658
painter->setPen(ScColorShade(Qt::red, 100));
659
painter->setBrush(ScColorShade(Qt::red, 100));
660
painter->setFillMode(1);
661
painter->drawRect(glyphs.xoffset, glyphs.yoffset - (style.fontSize() / 10.0) * glyphs.scaleV , (style.fontSize() / 10.0) * glyphs.scaleH, (style.fontSize() / 10.0) * glyphs.scaleV);
665
painter->translate(glyphs.xadvance, 0);
666
drawGlyphs(item, painter, style, *glyphs.more, clip);
670
void ScPageOutput::drawItem_Embedded( PageItem* item, ScPainterExBase *p, const QRect& clip, const CharStyle& style, PageItem* cembedded)
674
QList<PageItem*> emG;
675
QStack<PageItem*> groupStack;
676
emG.append(cembedded);
677
if (cembedded->Groups.count() != 0)
679
for (int ga=0; ga < m_doc->FrameItems.count(); ++ga)
681
if (m_doc->FrameItems.at(ga)->Groups.count() != 0)
683
if (m_doc->FrameItems.at(ga)->Groups.top() == cembedded->Groups.top())
685
if (m_doc->FrameItems.at(ga)->ItemNr != cembedded->ItemNr)
687
if (!emG.contains(m_doc->FrameItems.at(ga)))
688
emG.append(m_doc->FrameItems.at(ga));
694
for (int em = 0; em < emG.count(); ++em)
696
PageItem* embedded = emG.at(em);
697
if (embedded->isGroupControl)
700
FPointArray cl = embedded->PoLine.copy();
702
mm.translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0)));
703
if (style.baselineOffset() != 0)
704
mm.translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0));
705
mm.scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
707
groupStack.push(embedded->groupsLastItem);
711
double x = embedded->xPos();
712
double y = embedded->yPos();
713
embedded->setXPos( embedded->gXpos, true );
714
embedded->setYPos((embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos, true );
715
p->translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0)));
716
if (style.baselineOffset() != 0)
718
p->translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0));
719
embedded->setYPos( embedded->yPos() - embedded->gHeight * (style.baselineOffset() / 1000.0) );
721
p->scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
722
double pws = embedded->m_lineWidth;
723
drawItem_Pre(embedded, p);
724
switch(embedded->itemType())
726
case PageItem::ImageFrame:
727
case PageItem::LatexFrame:
728
case PageItem::TextFrame:
729
case PageItem::Polygon:
730
case PageItem::PathText:
731
drawItem(embedded, p, clip);
734
case PageItem::PolyLine:
735
embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
736
drawItem(embedded, p, clip);
741
embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
742
drawItem_Post(embedded, p);
743
embedded->setXPos(x, true);
744
embedded->setYPos(y, true);
746
if (groupStack.count() != 0)
748
while (embedded == groupStack.top())
752
if (groupStack.count() == 0)
756
embedded->m_lineWidth = pws;
758
for (int em = 0; em < emG.count(); ++em)
760
PageItem* embedded = emG.at(em);
761
if (!embedded->isTableItem)
764
double x = embedded->xPos();
765
double y = embedded->yPos();
766
embedded->setXPos(embedded->gXpos, true);
767
embedded->setYPos ((embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos, true);
768
p->translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0)));
769
if (style.baselineOffset() != 0)
771
p->translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0));
772
embedded->setYPos(embedded->yPos() - embedded->gHeight * (style.baselineOffset() / 1000.0));
774
p->scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
775
p->rotate(embedded->rotation());
776
double pws = embedded->m_lineWidth;
777
embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
778
if ((embedded->lineColor() != CommonStrings::None) && (embedded->lineWidth() != 0.0))
780
ScColorShade colorShade(m_doc->PageColors[embedded->lineColor()], embedded->lineShade());
781
if ((embedded->TopLine) || (embedded->RightLine) || (embedded->BottomLine) || (embedded->LeftLine))
783
p->setPen(colorShade, embedded->lineWidth(), embedded->PLineArt, Qt::SquareCap, embedded->PLineJoin);
784
if (embedded->TopLine)
785
p->drawLine(FPoint(0.0, 0.0), FPoint(embedded->width(), 0.0));
786
if (embedded->RightLine)
787
p->drawLine(FPoint(embedded->width(), 0.0), FPoint(embedded->width(), embedded->height()));
788
if (embedded->BottomLine)
789
p->drawLine(FPoint(embedded->width(), embedded->height()), FPoint(0.0, embedded->height()));
790
if (embedded->LeftLine)
791
p->drawLine(FPoint(0.0, embedded->height()), FPoint(0.0, 0.0));
794
embedded->m_lineWidth = pws;
795
embedded->setXPos(x, true);
796
embedded->setYPos(y, true);
801
void ScPageOutput::drawPattern( PageItem* item, ScPainterExBase* painter, const QRect& clip)
803
double x1, x2, y1, y2;
804
ScPattern& pattern = m_doc->docPatterns[item->pattern()];
805
double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation;
806
item->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation);
808
// Compute pattern tansformation matrix and its inverse for converting pattern coordinates
809
// to pageitem coordinates
810
QMatrix matrix, invMat;
811
matrix.translate(patternOffsetX, patternOffsetY);
812
matrix.rotate(patternRotation);
813
matrix.scale(pattern.scaleX, pattern.scaleY);
814
matrix.scale(patternScaleX / 100.0 , patternScaleY / 100.0);
815
invMat.scale((patternScaleX != 0) ? (100 /patternScaleX) : 1.0, (patternScaleY != 0) ? (100 /patternScaleY) : 1.0);
816
invMat.scale((pattern.scaleX != 0) ? (1 /pattern.scaleX) : 1.0, (pattern.scaleY != 0) ? (1 /pattern.scaleY) : 1.0);
817
invMat.rotate(-patternRotation);
818
invMat.translate(-patternOffsetX, -patternOffsetY);
820
// Compute bounding box in which pattern item will be drawn
821
double width = item->width();
822
double height = item->height();
823
double rot = patternRotation - floor(patternRotation / 90) * 90;
824
double ctheta = cos(rot * M_PI / 180);
825
double stheta = sin(rot * M_PI / 180);
826
QRectF itemRect(0.0, 0.0, item->width(), item->height());
827
QPointF pa( width * stheta * stheta, -width * stheta * ctheta );
828
QPointF pb( width + height * ctheta * stheta, height * stheta * stheta );
829
QPointF pc( -height * ctheta * stheta, height * ctheta * ctheta );
830
QPointF pd( width * ctheta * ctheta, height + width * ctheta * stheta );
831
QPointF ipa = invMat.map(pa), ipb = invMat.map(pb);
832
QPointF ipc = invMat.map(pc), ipd = invMat.map(pd);
835
if (item->imageClip.size() != 0)
837
painter->setupPolygon(&item->imageClip);
838
painter->setClipPath();
840
painter->setupPolygon(&item->PoLine);
841
painter->setClipPath();
842
for (int index = 0; index < pattern.items.count(); index++)
845
PageItem* it = pattern.items.at(index);
846
if (it->isGroupControl)
850
painter->translate(patternOffsetX, patternOffsetY);
851
painter->rotate(patternRotation);
852
painter->scale(pattern.scaleX, pattern.scaleY);
853
painter->scale(patternScaleX / 100.0, patternScaleY / 100.0);
855
double patWidth = (pattern.width != 0.0) ? pattern.width : 1.0;
856
double patHeight = (pattern.height != 0.0) ? pattern.height : 1.0;
857
double kxa = (ipa.x() - it->gXpos) / patWidth;
858
double kxb = (ipb.x() - it->gXpos) / patWidth;
859
double kxc = (ipc.x() - it->gXpos) / patWidth;
860
double kxd = (ipd.x() - it->gXpos) / patWidth;
861
double kya = (ipa.y() - it->gYpos) / patHeight;
862
double kyb = (ipb.y() - it->gYpos) / patHeight;
863
double kyc = (ipc.y() - it->gYpos) / patHeight;
864
double kyd = (ipd.y() - it->gYpos) / patHeight;
865
int kxMin = (int) floor( qMin(qMin(kxa, kxb), qMin(kxc, kxd)) );
866
int kxMax = (int) ceil ( qMax(qMax(kxa, kxb), qMax(kxc, kxd)) );
867
int kyMin = (int) floor( qMin(qMin(kya, kyb), qMin(kyc, kyd)) );
868
int kyMax = (int) ceil ( qMax(qMax(kya, kyb), qMax(kyc, kyd)) );
870
double itx = it->xPos();
871
double ity = it->yPos();
872
double itPosX = it->gXpos, itPosY = it->gYpos;
873
for ( int kx = kxMin; kx <= kxMax; kx++ )
875
for ( int ky = kyMin; ky <= kyMax; ky++ )
877
itPosX = it->gXpos + kx * pattern.width;
878
itPosY = it->gYpos + ky * pattern.height;
879
it->setXYPos(itPosX, itPosY);
880
it->getBoundingRect(&x1, &y1, &x2, &y2);
881
itRect.setCoords(x1, y1, x2, y2);
882
itRect = matrix.mapRect( itRect );
883
if ( itRect.intersects(itemRect) )
884
drawItem(it, painter, clip);
887
it->setXYPos(itx, ity);
893
void ScPageOutput::drawItem_ImageFrame( PageItem_ImageFrame* item, ScPainterExBase* painter, const QRect& clip )
895
ScPainterExBase::ImageMode mode = ScPainterExBase::rgbImages;
896
if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0))
898
painter->setupPolygon(&item->PoLine);
899
fillPath(item, painter, clip);
901
if (item->Pfile.isEmpty())
903
/*painter->setPen( ScColorShade(Qt::black, 100), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
904
painter->drawLine(FPoint(0, 0), FPoint(item->width(), item->height()));
905
painter->drawLine(FPoint(0, item->height()), FPoint(item->width(), 0));*/
909
if ((!item->imageShown()) || (!item->PictureIsAvailable))
911
/*painter->setPen( ScColorShade(Qt::red, 100), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
912
painter->drawLine(FPoint(0, 0), FPoint(item->width(), item->height()));
913
painter->drawLine(FPoint(0, item->height()), FPoint(item->width(), 0));*/
918
ScImage* pImage = NULL;
919
double imScaleX = item->imageXScale();
920
double imScaleY = item->imageYScale();
924
bool useCmyk = false;
925
ScPainterExBase::ImageMode imageMode = painter->imageMode();
926
if ( imageMode == ScPainterExBase::cmykImages )
928
QFileInfo fInfo(item->Pfile);
929
QString ext = fInfo.suffix();
930
CMSettings cmsSettings(item->doc(), item->IProfile, item->IRender);
931
scImg.imgInfo.valid = false;
932
scImg.imgInfo.clipPath = "";
933
scImg.imgInfo.PDSpathData.clear();
934
scImg.imgInfo.layerInfo.clear();
935
scImg.imgInfo.RequestProps = item->pixm.imgInfo.RequestProps;
936
scImg.imgInfo.isRequest = item->pixm.imgInfo.isRequest;
937
scImg.LoadPicture(item->Pfile, item->pixm.imgInfo.actualPageNumber, cmsSettings, item->UseEmbedded, m_useProfiles, translateImageModeToRequest(imageMode), m_imageRes, &dummy);
938
if( extensionIndicatesEPSorPS(ext) || extensionIndicatesPDF(ext) )
940
imScaleX *= (72.0 / (double) m_imageRes);
941
imScaleY *= (72.0 / (double) m_imageRes);
943
scImg.applyEffect(item->effectsInUse, m_doc->PageColors, useCmyk);
948
pImage = &item->pixm;
951
if (item->imageClip.size() != 0)
953
painter->setupPolygon(&item->imageClip);
954
painter->setClipPath();
956
painter->setupPolygon(&item->PoLine);
957
painter->setClipPath();
958
if (item->imageFlippedH())
960
painter->translate(item->width(), 0);
961
painter->scale(-1, 1);
963
if (item->imageFlippedV())
965
painter->translate(0, item->height());
966
painter->scale(1, -1);
968
painter->translate(item->imageXOffset() * item->imageXScale(), item->imageYOffset() * item->imageYScale());
969
//painter->translate(item->LocalX * imScaleX * scale, item->LocalY * imScaleY * scale); ??
970
painter->scale( imScaleX, imScaleY );
971
if (pImage->imgInfo.lowResType != 0)
972
painter->scale(pImage->imgInfo.lowResScale, pImage->imgInfo.lowResScale);
973
painter->drawImage(pImage, mode);
979
void ScPageOutput::drawItem_Line( PageItem_Line* item, ScPainterExBase* painter, const QRect& clip )
981
int startArrowIndex = item->startArrowIndex();
982
int endArrowIndex = item->endArrowIndex();
984
if (item->NamedLStyle.isEmpty())
985
painter->drawLine(FPoint(0, 0), FPoint(item->width(), 0));
988
multiLine ml = m_doc->MLineStyles[item->NamedLStyle];
989
for (int it = ml.size()-1; it > -1; it--)
991
const SingleLine& sl = ml[it];
992
if (sl.Color != CommonStrings::None)
994
ScColorShade tmp(m_doc->PageColors[sl.Color], sl.Shade);
995
painter->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash),
996
static_cast<Qt::PenCapStyle>(sl.LineEnd),
997
static_cast<Qt::PenJoinStyle>(sl.LineJoin));
998
painter->drawLine(FPoint(0, 0), FPoint(item->width(), 0));
1002
if (startArrowIndex != 0)
1005
arrowTrans.translate(0, 0);
1006
arrowTrans.scale(-1,1);
1007
drawArrow(painter, item, arrowTrans, startArrowIndex);
1009
if (endArrowIndex != 0)
1012
arrowTrans.translate(item->width(), 0);
1013
drawArrow(painter, item, arrowTrans, endArrowIndex);
1017
void ScPageOutput::drawItem_PathText( PageItem_PathText* item, ScPainterExBase* painter, const QRect& clip )
1019
QString chstr, chstr2, chstr3;
1021
FPoint point = FPoint(0, 0);
1022
FPoint tangent = FPoint(0, 0);
1024
double chs, dx, segLen = 0;
1025
double CurX = item->textToFrameDistLeft(); // item->CurX = item->textToFrameDistLeft()
1027
QString actFill, actStroke;
1028
double actFillShade, actStrokeShade;
1029
StoryText& itemText = item->itemText;
1030
if (item->pathTextShowFrame())
1032
painter->setupPolygon(&item->PoLine, false);
1033
if (item->NamedLStyle.isEmpty())
1035
if (item->lineColor() != CommonStrings::None)
1036
painter->strokePath();
1040
multiLine ml = m_doc->MLineStyles[item->NamedLStyle];
1041
for (int it = ml.size() - 1; it > -1; it--)
1043
const SingleLine& sl = ml[it];
1044
if ((sl.Color != CommonStrings::None) && (sl.Width != 0))
1046
ScColorShade tmp(m_doc->PageColors[sl.Color], sl.Shade);
1047
painter->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash),
1048
static_cast<Qt::PenCapStyle>(sl.LineEnd),
1049
static_cast<Qt::PenJoinStyle>(sl.LineJoin));
1050
painter->drawLine(FPoint(0, 0), FPoint(item->width(), 0));
1055
double totalTextLen = 0.0;
1056
double totalCurveLen = 0.0;
1057
double extraOffset = 0.0;
1058
if (itemText.length() != 0)
1060
CurX += itemText.item(0)->fontSize() * itemText.charStyle(0).tracking() / 10000.0;
1061
totalTextLen += itemText.charStyle(0).fontSize() * itemText.charStyle(0).tracking() / 10000.0;
1063
segLen = item->PoLine.lenPathSeg(seg);
1064
for (int a = 0; a < itemText.length(); ++a)
1066
hl = itemText.item(a);
1068
if (chstr[0] == SpecialChars::PAGENUMBER || chstr[0] == SpecialChars::PARSEP || chstr[0] == SpecialChars::PAGECOUNT
1069
|| chstr[0] == SpecialChars::TAB || chstr == SpecialChars::LINEBREAK)
1071
if (a < itemText.length()-1)
1072
chstr += itemText.text(a+1, 1);
1073
hl->glyph.yadvance = 0;
1074
item->layoutGlyphs(itemText.charStyle(a), chstr, hl->glyph);
1076
if (hl->ch == SpecialChars::OBJECT)
1077
totalTextLen += (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()) * hl->glyph.scaleH;
1079
totalTextLen += hl->glyph.wide()+hl->fontSize() * hl->tracking() / 10000.0;
1081
for (uint segs = 0; segs < item->PoLine.size()-3; segs += 4)
1083
totalCurveLen += item->PoLine.lenPathSeg(segs);
1085
if ((itemText.defaultStyle().alignment() != 0) && (totalCurveLen >= totalTextLen + item->textToFrameDistLeft()))
1087
if (itemText.defaultStyle().alignment() == 2)
1089
CurX = totalCurveLen - totalTextLen;
1090
CurX -= item->textToFrameDistLeft();
1092
if (itemText.defaultStyle().alignment() == 1)
1093
CurX = (totalCurveLen - totalTextLen) / 2.0;
1094
if ((itemText.defaultStyle().alignment() == 3) || (itemText.defaultStyle().alignment() == 4))
1095
extraOffset = (totalCurveLen - item->textToFrameDistLeft() - totalTextLen) / static_cast<double>(itemText.length());
1098
QPainterPath guidePath = item->PoLine.toQPainterPath(false);
1099
QList<QPainterPath> pathList = decomposePath(guidePath);
1100
QPainterPath currPath = pathList[0];
1101
int currPathIndex = 0;
1102
for (int a = item->firstInFrame(); a < itemText.length(); ++a)
1105
hl = itemText.item(a);
1107
if (chstr[0] == SpecialChars::PAGENUMBER || chstr[0] == SpecialChars::PARSEP || chstr[0] == SpecialChars::PAGECOUNT
1108
|| chstr[0] == SpecialChars::TAB || chstr[0] == SpecialChars::LINEBREAK)
1110
chs = hl->fontSize();
1111
if (a < itemText.length()-1)
1112
chstr += itemText.text(a+1, 1);
1113
hl->glyph.yadvance = 0;
1114
item->layoutGlyphs(itemText.charStyle(a), chstr, hl->glyph);
1115
hl->glyph.shrink(); // HACK
1116
if (hl->ch == SpecialChars::OBJECT)
1117
dx = (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()) * hl->glyph.scaleH / 2.0;
1119
dx = hl->glyph.wide() / 2.0;
1123
double currPerc = currPath.percentAtLength(CurX);
1124
if (currPerc >= 0.9999999)
1127
if (currPathIndex == pathList.count())
1129
currPath = pathList[currPathIndex];
1131
currPerc = currPath.percentAtLength(CurX);
1133
double currAngle = currPath.angleAtPercent(currPerc);
1134
if (currAngle <= 180.0)
1137
currAngle = 360.0 - currAngle;
1138
QPointF currPoint = currPath.pointAtPercent(currPerc);
1139
tangent = FPoint(cos(currAngle * M_PI / 180.0), sin(currAngle * M_PI / 180.0));
1140
point = FPoint(currPoint.x(), currPoint.y());
1142
hl->glyph.xoffset = 0;
1143
hl->PtransX = point.x();
1144
hl->PtransY = point.y();
1145
hl->PRot = currAngle * M_PI / 180.0;
1147
QMatrix trafo = QMatrix( 1, 0, 0, -1, -dx, 0 );
1148
if (item->textPathFlipped)
1149
trafo *= QMatrix(1, 0, 0, -1, 0, 0);
1150
if (item->textPathType == 0)
1151
trafo *= QMatrix( tangent.x(), tangent.y(), tangent.y(), -tangent.x(), point.x(), point.y() ); // ID's Rainbow mode
1152
else if (item->textPathType == 1)
1153
trafo *= QMatrix( 1, 0, 0, -1, point.x(), point.y() ); // ID's Stair Step mode
1154
else if (item->textPathType == 2)
1157
if (tangent.x() < 0)
1159
if (fabs(tangent.x()) > 0.1)
1160
trafo *= QMatrix( a, (tangent.y() / tangent.x()) * a, 0, -1, point.x(), point.y() ); // ID's Skew mode
1162
trafo *= QMatrix( a, 4 * a, 0, -1, point.x(), point.y() );
1164
QMatrix sca = painter->worldMatrix();
1167
QMatrix savWM = painter->worldMatrix();
1168
painter->setWorldMatrix(trafo);
1170
actFill = itemText.charStyle(a).fillColor();
1171
actFillShade = itemText.charStyle(a).fillShade();
1172
if (actFill != CommonStrings::None)
1174
ScColorShade tmp(m_doc->PageColors[actFill], qRound(actFillShade));
1175
painter->setBrush(tmp);
1177
actStroke = itemText.charStyle(a).strokeColor();
1178
actStrokeShade = itemText.charStyle(a).strokeShade();
1179
if (actStroke != CommonStrings::None)
1181
ScColorShade tmp(m_doc->PageColors[actStroke], qRound(actStrokeShade));
1182
painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1184
painter->translate(0.0, item->pathTextBaseOffset());
1185
if (hl->ch == SpecialChars::OBJECT)
1186
drawItem_Embedded(hl->embedded.getItem(), painter, clip, itemText.charStyle(a), hl->embedded.getItem());
1188
drawGlyphs(item, painter, itemText.charStyle(a), hl->glyph, clip);
1190
painter->setWorldMatrix(savWM);
1193
if (hl->ch == SpecialChars::OBJECT)
1194
CurX += (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()) * hl->glyph.scaleH;
1196
CurX += hl->glyph.wide()+hl->fontSize() * hl->tracking() / 10000.0 + extraOffset;
1200
void ScPageOutput::drawItem_Polygon ( PageItem_Polygon* item , ScPainterExBase* painter, const QRect& clip )
1202
painter->setupPolygon(&item->PoLine);
1203
fillPath(item, painter, clip);
1206
void ScPageOutput::drawItem_PolyLine( PageItem_PolyLine* item, ScPainterExBase* painter, const QRect& clip )
1208
int startArrowIndex = item->startArrowIndex();
1209
int endArrowIndex = item->endArrowIndex();
1211
if (item->PoLine.size()>=4)
1213
if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0))
1218
for (uint n = 0; n < item->PoLine.size()-3; n += 4)
1222
Start = item->PoLine.point(n);
1225
if (item->PoLine.point(n).x() > 900000)
1227
cli.addPoint(item->PoLine.point(n-2));
1228
cli.addPoint(item->PoLine.point(n-2));
1229
cli.addPoint(Start);
1230
cli.addPoint(Start);
1235
cli.addPoint(item->PoLine.point(n));
1236
cli.addPoint(item->PoLine.point(n+1));
1237
cli.addPoint(item->PoLine.point(n+2));
1238
cli.addPoint(item->PoLine.point(n+3));
1242
FPoint l1 = cli.point(cli.size()-2);
1245
cli.addPoint(Start);
1246
cli.addPoint(Start);
1248
painter->setupPolygon(&cli);
1249
fillPath(item, painter, clip);
1251
painter->setupPolygon(&item->PoLine, false);
1252
if (item->NamedLStyle.isEmpty())
1254
if (item->lineColor() != CommonStrings::None)
1255
painter->strokePath();
1259
multiLine ml = m_doc->MLineStyles[item->NamedLStyle];
1260
for (int it = ml.size()-1; it > -1; it--)
1262
const SingleLine& sl = ml[it];
1263
if (sl.Color != CommonStrings::None)
1265
ScColorShade tmp(m_doc->PageColors[sl.Color], sl.Shade);
1266
painter->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash),
1267
static_cast<Qt::PenCapStyle>(sl.LineEnd),
1268
static_cast<Qt::PenJoinStyle>(sl.LineJoin));
1269
painter->strokePath();
1273
if (startArrowIndex != 0)
1275
FPoint Start = item->PoLine.point(0);
1276
for (uint xx = 1; xx < item->PoLine.size(); xx += 2)
1278
FPoint Vector = item->PoLine.point(xx);
1279
if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
1281
double r = atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI);
1283
arrowTrans.translate(Start.x(), Start.y());
1284
arrowTrans.rotate(r);
1285
drawArrow(painter, item, arrowTrans, startArrowIndex);
1290
if (endArrowIndex != 0)
1292
FPoint End = item->PoLine.point(item->PoLine.size()-2);
1293
for (uint xx = item->PoLine.size()-1; xx > 0; xx -= 2)
1295
FPoint Vector = item->PoLine.point(xx);
1296
if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
1298
double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI);
1300
arrowTrans.translate(End.x(), End.y());
1301
arrowTrans.rotate(r);
1302
drawArrow(painter, item, arrowTrans, endArrowIndex);
1310
void ScPageOutput::drawItem_TextFrame( PageItem_TextFrame* item, ScPainterExBase* painter, const QRect& clip )
1318
QString chstr, chstr2, chstr3;
1320
double desc, asce, tabDist;
1324
if (item->isEmbedded)
1328
e2 = QRect(qRound(clip.x() + m_doc->minCanvasCoordinate.x()), qRound(clip.y() + m_doc->minCanvasCoordinate.y()), qRound(clip.width()), qRound(clip.height()));
1329
wm.translate(item->xPos(), item->yPos());
1331
wm.rotate(item->rotation());
1332
if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0))
1334
painter->setupPolygon(&item->PoLine);
1335
fillPath(item, painter, clip);
1337
if (item->lineColor() != CommonStrings::None)
1338
lineCorr = item->lineWidth() / 2.0;
1341
if ((item->isAnnotation()) && (item->annotation().Type() == 2) && (!item->Pfile.isEmpty()) && (item->PictureIsAvailable) && (item->imageShown()) && (item->annotation().UseIcons()))
1344
painter->setupPolygon(&item->PoLine);
1345
painter->setClipPath();
1346
painter->scale(item->imageXScale(), item->imageYScale());
1347
painter->translate(static_cast<int>(item->imageXOffset() * item->imageXScale()), static_cast<int>(item->imageYOffset() * item->imageYScale()));
1348
if (!item->pixm.qImage().isNull())
1349
painter->drawImage(&item->pixm, ScPainterExBase::rgbImages);
1352
if ((item->itemText.length() != 0))
1354
if (item->imageFlippedH())
1356
painter->translate(item->width(), 0);
1357
painter->scale(-1, 1);
1359
if (item->imageFlippedV())
1361
painter->translate(0, item->height());
1362
painter->scale(1, -1);
1365
for (uint ll=0; ll < item->itemText.lines(); ++ll)
1367
LineSpec ls = item->itemText.line(ll);
1370
for (a = ls.firstItem; a <= ls.lastItem; ++a)
1372
hl = item->itemText.item(a);
1373
const CharStyle& charStyle = item->itemText.charStyle(a);
1374
double chs = charStyle.fontSize() * hl->glyph.scaleV;
1375
if (charStyle.effects() & ScStyle_StartOfLine)
1378
if (charStyle.fillColor() != CommonStrings::None)
1380
ScColorShade tmp(m_doc->PageColors[charStyle.fillColor()], (int) hl->fillShade());
1381
painter->setBrush(tmp);
1383
if (charStyle.strokeColor() != CommonStrings::None)
1385
ScColorShade tmp(m_doc->PageColors[charStyle.strokeColor()], (int) hl->strokeShade());
1386
painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1388
if (charStyle.effects() & ScStyle_DropCap)
1390
const ParagraphStyle& style(item->itemText.paragraphStyle(a));
1391
if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
1392
chs = qRound(10 * ((m_doc->typographicSettings.valueBaseGrid * (style.dropCapLines()-1) + (charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10)));
1395
if (style.lineSpacingMode() == ParagraphStyle::FixedLineSpacing)
1396
chs = qRound(10 * ((style.lineSpacing() * (style.dropCapLines()-1)+(charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10)));
1399
double currasce = charStyle.font().height(style.charStyle().fontSize() / 10.0);
1400
chs = qRound(10 * ((currasce * (style.dropCapLines()-1)+(charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr[0], 10)));
1404
if (chstr[0] == SpecialChars::TAB)
1406
//if (!m_doc->RePos)
1408
//double xcoZli = CurX + hl->glyph.xoffset;
1409
desc = - charStyle.font().descent(charStyle.fontSize() / 10.0);
1410
asce = charStyle.font().ascent(charStyle.fontSize() / 10.0);
1411
if (charStyle.strokeColor() != CommonStrings::None)
1413
ScColorShade tmp(m_doc->PageColors[charStyle.strokeColor()], (int) charStyle.strokeShade());
1414
painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1416
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)))))
1419
painter->translate(CurX, ls.y);
1420
if (hl->ch == SpecialChars::OBJECT)
1421
drawItem_Embedded(item, painter, clip, charStyle, hl->embedded.getItem());
1423
drawGlyphs(item, painter, charStyle, hl->glyph, clip);
1426
if (hl->ch == SpecialChars::OBJECT)
1427
CurX += (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth());
1429
CurX += hl->glyph.wide();
1438
void ScPageOutput::drawArrow(ScPainterExBase* painter, PageItem* item, QMatrix &arrowTrans, int arrowIndex)
1440
FPointArray arrow = m_doc->arrowStyles.at(arrowIndex-1).points.copy();
1441
if (item->NamedLStyle.isEmpty())
1443
if (item->lineWidth() != 0.0)
1444
arrowTrans.scale(item->lineWidth(), item->lineWidth());
1448
multiLine ml = m_doc->MLineStyles[item->NamedLStyle];
1449
if (ml[ml.size()-1].Width != 0.0)
1450
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
1452
arrow.map(arrowTrans);
1453
painter->setupPolygon(&arrow);
1454
if (item->NamedLStyle.isEmpty())
1456
if (item->lineColor() != CommonStrings::None)
1458
ScColorShade tmp(m_doc->PageColors[item->lineColor()], item->lineShade());
1459
painter->setBrush(tmp);
1460
painter->setBrushOpacity(1.0 - item->lineTransparency());
1461
painter->setLineWidth(0);
1462
painter->setFillMode(ScPainterExBase::Solid);
1463
painter->fillPath();
1468
multiLine ml = m_doc->MLineStyles[item->NamedLStyle];
1470
if (ml[0].Color != CommonStrings::None)
1472
ScColorShade tmp(m_doc->PageColors[ml[0].Color], ml[0].Shade);
1473
painter->setBrush(tmp);
1474
painter->setLineWidth(0);
1475
painter->setFillMode(ScPainterExBase::Solid);
1476
painter->fillPath();
1478
for (int it = ml.size()-1; it > 0; it--)
1480
if (ml[it].Color != CommonStrings::None)
1482
ScColorShade tmp(m_doc->PageColors[ml[it].Color], ml[it].Shade);
1483
painter->setPen(tmp, ml[it].Width, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1484
painter->strokePath();
1490
void ScPageOutput::drawMarks( Page* page, ScPainterExBase* painter, const MarksOptions& options )
1492
double markOffs = options.markOffset;
1493
double bleedLeft = 0.0, bleedRight = 0.0;
1494
double bleedBottom = options.BleedBottom;
1495
double bleedTop = options.BleedTop;
1496
if (!options.cropMarks && !options.bleedMarks && !options.registrationMarks && !options.colorMarks)
1498
if (m_doc->locationOfPage(page->pageNr()) == LeftPage)
1500
bleedRight = options.BleedRight;
1501
bleedLeft = options.BleedLeft;
1503
else if (m_doc->locationOfPage(page->pageNr()) == RightPage)
1505
bleedRight = options.BleedLeft;
1506
bleedLeft = options.BleedRight;
1510
bleedRight = options.BleedLeft;
1511
bleedLeft = options.BleedLeft;
1513
double width = page->width();
1514
double height = page->height();
1515
double offsetX = page->xOffset();
1516
double offsetY = page->yOffset();
1517
QPointF bleedTopLeft(offsetX - bleedLeft, offsetY - bleedTop);
1518
QPointF bleedBottomRight(offsetX + width + bleedRight, offsetY + height + bleedBottom);
1519
QRectF bleedBox(bleedTopLeft, bleedBottomRight);
1521
painter->setLineWidth(0.5);
1522
painter->setPen(ScColorShade(Qt::black, 100), 0.5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin );
1523
if (options.cropMarks)
1526
double left = offsetX, right = offsetX + width;
1527
double bottom = offsetY + height, top = offsetY;
1528
drawBoxMarks( painter, QRectF(QPointF(left, top), QPointF(right, bottom)), bleedBox, markOffs );
1530
if (options.bleedMarks)
1533
double left = offsetX - bleedLeft, right = offsetX + width + bleedRight;
1534
double bottom = offsetY + height + bleedBottom, top = offsetY - bleedTop;;
1535
drawBoxMarks( painter, QRectF(QPointF(left, top), QPointF(right, bottom)), bleedBox, markOffs );
1537
if (options.registrationMarks)
1539
double posX = (2* offsetX + width) / 2.0 - 7.0;
1540
double posY = (offsetY + height + bleedBottom + markOffs + 3.0);
1542
painter->translate(posX, posY);
1543
drawRegistrationCross( painter );
1545
posX = (2 * offsetX + width) / 2.0 - 7.0;
1546
posY = (offsetY - bleedTop - markOffs - 17);
1548
painter->translate(posX, posY);
1549
drawRegistrationCross( painter );
1552
posX = (offsetX - bleedLeft - markOffs - 17);
1553
posY = (2 * offsetY + height) / 2.0 - 7.0;
1555
painter->translate(posX, posY);
1556
drawRegistrationCross( painter );
1558
posX = (offsetX + width + bleedRight + markOffs + 3.0);
1559
posY = (2 * offsetY + height) / 2.0 - 7.0;
1561
painter->translate(posX, posY);
1562
drawRegistrationCross( painter );
1565
if (options.colorMarks)
1568
double startX = offsetX + 6.0;
1569
double startY = offsetY - bleedTop - markOffs - 16.0;
1570
ScColorShade strokecolor( ScColor(0, 0, 0, 255), 100 );
1571
painter->setPen( strokecolor, 0.5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin );
1572
painter->setFillMode( ScPainterExBase::Solid );
1573
for (int i = 0; i < 11; i++ )
1575
ScColorShade fillcolor( ScColor(0, 0, 0, 255), shade );
1576
painter->setBrush( fillcolor );
1577
painter->drawRect( startX + i * 14, startY, 14, 14 );
1580
startX = offsetX + width - 20.0;
1581
painter->setBrush( ScColorShade(ScColor(0, 0, 0, 255), 50) );
1582
painter->drawRect( startX, startY, 14, 14 );
1584
painter->setBrush( ScColorShade(ScColor(0, 0, 255, 0), 50) );
1585
painter->drawRect( startX, startY, 14, 14 );
1587
painter->setBrush( ScColorShade(ScColor(0, 255, 0, 0), 50) );
1588
painter->drawRect( startX, startY, 14, 14 );
1590
painter->setBrush( ScColorShade(ScColor(255, 0, 0, 0), 50) );
1591
painter->drawRect( startX, startY, 14, 14 );
1593
painter->setBrush( ScColorShade(ScColor(255, 255, 0, 0), 100) );
1594
painter->drawRect( startX, startY, 14, 14 );
1596
painter->setBrush( ScColorShade(ScColor(255, 0, 255, 0), 100) );
1597
painter->drawRect( startX, startY, 14, 14 );
1599
painter->setBrush( ScColorShade(ScColor(0, 255, 255, 0), 100) );
1600
painter->drawRect( startX, startY, 14, 14 );
1602
painter->setBrush( ScColorShade(ScColor(0, 0, 0, 255), 100) );
1603
painter->drawRect( startX, startY, 14, 14 );
1605
painter->setBrush( ScColorShade(ScColor(0, 0, 255, 0), 100) );
1606
painter->drawRect( startX, startY, 14, 14 );
1608
painter->setBrush( ScColorShade(ScColor(0, 255, 0, 0), 100) );
1609
painter->drawRect( startX, startY, 14, 14 );
1611
painter->setBrush( ScColorShade(ScColor(255, 0, 0, 0), 100) );
1612
painter->drawRect( startX, startY, 14, 14 );
1617
void ScPageOutput::drawBoxMarks( ScPainterExBase* painter, const QRectF& box, const QRectF& bleedBox, double offset )
1620
double left = box.left(), right = box.right();
1621
double bottom = box.bottom(), top = box.top();
1622
double bleedLeft = bleedBox.left(), bleedRight = bleedBox.right();
1623
double bleedBottom = bleedBox.bottom(), bleedTop = bleedBox.top();
1625
start.setXY( bleedLeft - offset, top );
1626
end.setXY ( bleedLeft - offset - 20, top );
1627
painter->drawLine(start, end);
1628
start.setXY( left, bleedTop - offset );
1629
end.setXY ( left, bleedTop - offset - 20);
1630
painter->drawLine(start, end);
1632
start.setXY( bleedRight + offset, top );
1633
end.setXY ( bleedRight + offset + 20, top );
1634
painter->drawLine(start, end);
1635
start.setXY( right, bleedTop - offset );
1636
end.setXY ( right, bleedTop - offset - 20);
1637
painter->drawLine(start, end);
1639
start.setXY( bleedLeft - offset, bottom );
1640
end.setXY ( bleedLeft - offset - 20, bottom );
1641
painter->drawLine(start, end);
1642
start.setXY( left, bleedBottom + offset );
1643
end.setXY ( left, bleedBottom + offset + 20);
1644
painter->drawLine(start, end);
1646
start.setXY( bleedRight + offset, bottom );
1647
end.setXY ( bleedRight + offset + 20, bottom );
1648
painter->drawLine(start, end);
1649
start.setXY( right, bleedBottom + offset );
1650
end.setXY ( right, bleedBottom + offset + 20);
1651
painter->drawLine(start, end);
1654
void ScPageOutput::drawRegistrationCross( ScPainterExBase* painter )
1659
painter->moveTo(0.0, 7.0);
1660
painter->lineTo(14.0, 7.0);
1661
painter->strokePath();
1664
painter->moveTo(7.0, 0.0);
1665
painter->lineTo(7.0, 14.0);
1666
painter->strokePath();
1669
painter->moveTo(13.0, 7.0);
1670
painter->curveTo( FPoint(13.0, 10.31383), FPoint(10.31383, 13.0), FPoint(7.0, 13.0) );
1671
painter->curveTo( FPoint(3.68629, 13.0) , FPoint(1.0, 10.31383) , FPoint(1.0, 7.0) );
1672
painter->curveTo( FPoint(1.0, 3.68629) , FPoint(3.68629, 1.0) , FPoint(7.0, 1.0) );
1673
painter->curveTo( FPoint(10.31383, 1.0) , FPoint(13.0, 3.68629) , FPoint(13.0, 7.0) );
1674
painter->strokePath();
1677
painter->moveTo(10.5, 7.0);
1678
painter->curveTo( FPoint(10.5, 8.93307), FPoint(8.93307, 10.5), FPoint(7.0, 10.5) );
1679
painter->curveTo( FPoint(5.067, 10.5) , FPoint(3.5, 8.93307) , FPoint(3.5, 7.0) );
1680
painter->curveTo( FPoint(3.5, 5.067) , FPoint(5.067, 3.5) , FPoint(7.0, 3.5) );
1681
painter->curveTo( FPoint(8.93307, 3.5) , FPoint(10.5, 5.067) , FPoint(10.5, 7.0) );
1682
painter->strokePath();
1687
void ScPageOutput::fillPath( PageItem* item, ScPainterExBase* painter, const QRect& clip )
1689
if( painter->fillMode() == ScPainterExBase::Pattern && !painter->hasCapability(ScPainterExBase::patterns) )
1690
drawPattern( item, painter, clip );
1692
painter->fillPath();
1695
void ScPageOutput::strokePath( PageItem* item, ScPainterExBase* painter, const QRect& clip )
1697
painter->strokePath();