147
147
for (int a = 0; a < m_Doc->MasterItems.count(); ++a)
149
149
docItem = m_Doc->MasterItems.at(a);
150
// #10642 : masterpage items interact only with items placed on same masterpage
151
if (docItem->OnMasterPage != OnMasterPage)
150
153
LayerLevItem = m_Doc->layerLevelFromNumber(docItem->LayerNr);
151
154
if (((docItem->ItemNr > ItemNr) && (docItem->LayerNr == LayerNr)) || (LayerLevItem > LayerLev && m_Doc->layerFlow(docItem->LayerNr)))
245
static void debugLineLayout(const StoryText& itemText, const LineSpec& line)
247
QFile debugFile(QDir::homePath() + "/Desktop/debug_line.csv");
248
debugFile.open(QIODevice::WriteOnly);
250
QTextStream stream(&debugFile);
251
stream.setRealNumberNotation(QTextStream::FixedNotation);
252
stream.setRealNumberPrecision(7);
254
stream << "xoffset" << "\t";
255
stream << "yoffset" << "\t";
256
stream << "xadvance" << "\t";
257
stream << "yadvance" << "\t";
258
stream << "scaleH" << "\t";
259
stream << "scaleV" << "\t";
262
for (int zc = line.firstItem; zc < line.lastItem; ++zc)
264
const ScText* item = itemText.item(zc);
266
stream << item->glyph.xoffset << "\t";
267
stream << item->glyph.yoffset << "\t";
268
stream << item->glyph.xadvance << "\t";
269
stream << item->glyph.yadvance << "\t";
270
stream << item->glyph.scaleH << "\t";
271
stream << item->glyph.scaleV << "\t";
242
278
static void dumpIt(const ParagraphStyle& pstyle, QString indent = QString("->"))
244
280
QString db = QString("%6%1/%2 @ %3: %4--%5 linespa%6: %7 align%8")
1001
1037
double oldCurY, EndX, OFs, wide, kernVal;
1040
PageItem_TextFrame* nextFrame;
1004
1041
ParagraphStyle style;
1005
int /*ParagraphStyle::OpticalMarginType*/ opticalMargins = ParagraphStyle::OM_None;
1042
int opticalMargins = ParagraphStyle::OM_None;
1007
1044
bool outs = false;
1008
1045
bool goNoRoom = false;
1562
1599
double Xpos, Xend;
1563
1600
bool done = false;
1564
1601
bool newColumn = false;
1603
//FIX ME - that should be paragraph style`s properties
1604
//if set then indent is add to possible line start point (after overflow)
1605
//if not then indent is calculated from column left edge
1606
//if you dont agree that adding indent to overflow should be default behaviour
1607
//then change it to false
1608
bool addIndent2overflow = false; // should be addIndent2Overflow = style.addIndent2Overlow();
1609
bool addFirstIndent2overflow = true; // should be addFirstIndent2Overflow = style.addFirstIndent2Overlow();
1610
//if first line indent is negative and left indent should not be added to overflow
1611
//then dont add first line ident either
1612
if ((style.firstIndent() < 0) && !addIndent2overflow)
1613
addFirstIndent2overflow = false;
1567
Xpos = current.xPos;
1617
Xpos = current.xPos + (addIndent2overflow ? 0 : current.leftIndent);
1568
1618
Xend = current.xPos + current.leftIndent;
1569
1619
//check if in indent any overflow occurs
1570
1620
while (Xpos <= Xend && Xpos < current.colRight)
1622
pt.moveTopLeft(QPoint(static_cast<int>(floor(Xpos)),maxYAsc));
1572
1623
if (!regionContainsRect(cl, pt))
1574
1625
Xpos = current.xPos = realEnd = findRealOverflowEnd(cl, pt, current.colRight);
1575
Xend = current.xPos + current.leftIndent;
1626
Xend = current.xPos + (addIndent2overflow ? current.leftIndent : 0);
1627
//for first paragraph`s line - move it back if first line offset should not be add
1628
if ( addFirstIndent2overflow && (a==0 || (a > 0 && (itemText.text(a-1) == SpecialChars::PARSEP))))
1629
Xend += style.firstIndent();
1579
pt.moveTopLeft(QPoint(static_cast<int>(floor(Xpos)),maxYAsc));
1581
1634
current.xPos = Xend;
1583
if (current.isEndOfLine((style.minGlyphExtension() * wide) + current.rightMargin + current.leftIndent))
1636
if (current.isEndOfLine((style.minGlyphExtension() * wide) + current.rightMargin))
1586
1639
current.xPos = qMax(current.colLeft, maxDX);
2446
2499
MaxChars = itemText.length();
2447
2500
invalid = false;
2448
if (NextBox != NULL)
2502
nextFrame = dynamic_cast<PageItem_TextFrame*>(NextBox);
2503
while (nextFrame != NULL)
2450
PageItem_TextFrame* nextFrame = dynamic_cast<PageItem_TextFrame*>(NextBox);
2451
if (nextFrame != NULL)
2453
nextFrame->invalid = true;
2454
nextFrame->firstChar = MaxChars;
2505
nextFrame->invalid = true;
2506
nextFrame->firstChar = MaxChars;
2507
nextFrame = dynamic_cast<PageItem_TextFrame*>(nextFrame->NextBox);
2457
2509
// qDebug("textframe: len=%d, done relayout", itemText.length());
2614
2661
pf2.translate(0, Height);
2615
2662
pf2.scale(1, -1);
2618
2664
assert( firstInFrame() >= 0 );
2619
2665
assert( lastInFrame() < itemText.length() );
2621
2667
for (uint ll=0; ll < itemText.lines(); ++ll)
2623
2669
ls = itemText.line(ll);
2625
2670
double CurX = ls.x;
2627
2672
// Draw text selection rectangles
2703
2748
hl = itemText.item(a);
2704
2749
const CharStyle& charStyle(itemText.charStyle(a));
2705
double chs = charStyle.fontSize() * hl->glyph.scaleV;
2706
2750
bool selected = itemText.selected(a);
2707
if (charStyle.effects() & ScStyle_StartOfLine)
2710
2752
actFill = charStyle.fillColor();
2711
2753
actFillShade = charStyle.fillShade();
2712
2754
if (actFill != CommonStrings::None)
2727
2769
p->setFillMode(ScPainter::None);
2728
if (charStyle.effects() & ScStyle_DropCap)
2730
const ParagraphStyle& style(itemText.paragraphStyle(a));
2731
if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
2732
chs = qRound(10 * ((m_Doc->typographicSettings.valueBaseGrid * (style.dropCapLines()-1) + (charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr0, 10)));
2735
if (style.lineSpacingMode() == ParagraphStyle::FixedLineSpacing)
2736
chs = qRound(10 * ((style.lineSpacing() * (style.dropCapLines()-1)+(charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr0, 10)));
2739
double currasce = charStyle.font().height(style.charStyle().fontSize() / 10.0);
2740
chs = qRound(10 * ((currasce * (style.dropCapLines()-1)+(charStyle.font().ascent(style.charStyle().fontSize() / 10.0))) / charStyle.font().realCharHeight(chstr0, 10)));
2744
if (chstr0 == SpecialChars::TAB)
2747
2771
if (!m_Doc->RePos)
2851
2874
if ((!isEmbedded) && (!m_Doc->RePos))
2853
2876
// added to prevent fat frame outline due to antialiasing and considering you can’t pass a cosmetic pen to scpainter - pm
2854
double aestheticFactor(5.0);
2855
double scpInv = 1.0 / (qMax(view->scale(), 1.0) * aestheticFactor);
2877
double aestheticFactor(3.33);
2878
double scpInv = 1.0 / (view->scale() * aestheticFactor);
2856
2879
if ((Frame) && (m_Doc->guidesSettings.framesShown))
2858
2881
p->setPen(PrefsManager::instance()->appPrefs.DFrameNormColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
2902
2925
drawColumnBorders(p);
2903
2926
if ((m_Doc->guidesSettings.layerMarkersShown) && (m_Doc->layerCount() > 1) && (!m_Doc->layerOutline(LayerNr)) && (!view->m_canvas->isPreviewMode()))
2905
p->setPen(Qt::black, 0.5/ m_Doc->view()->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
2928
p->setPen(Qt::black, 0.5 / m_Doc->view()->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
2906
2929
p->setPenOpacity(1.0);
2907
2930
p->setBrush(m_Doc->layerMarker(LayerNr));
2908
2931
p->setBrushOpacity(1.0);
2992
3019
//Check if we are trying to enter Unicode sequence mode first
2993
3020
QKeySequence currKeySeq = QKeySequence(k->key() | keyModifiers);
2994
if(currKeySeq.matches(doc()->scMW()->scrActions["specialUnicodeSequenceBegin"]->shortcut())==QKeySequence::ExactMatch)
3021
if (currKeySeq.matches(doc()->scMW()->scrActions["specialUnicodeSequenceBegin"]->shortcut())==QKeySequence::ExactMatch)
2996
3023
unicodeTextEditMode = true;
2997
3024
unicodeInputCount = 0;
3110
3137
case Qt::Key_End:
3111
3138
// go to end of line
3112
3139
len = lastInFrame();
3113
if ( itemText.cursorPosition() >= len )
3140
if (itemText.cursorPosition() >= (len + 1))
3114
3141
break; // at end of frame
3115
if ( (buttonModifiers & Qt::ControlModifier) == 0 )
3142
if ((buttonModifiers & Qt::ControlModifier) == 0)
3117
3144
itemText.setCursorPosition( itemText.endOfLine(itemText.cursorPosition()) );
3121
3148
//Control End for end of frame text
3122
3149
itemText.setCursorPosition( itemText.endOfFrame(itemText.cursorPosition()) );
3124
if ( buttonModifiers & Qt::ShiftModifier )
3151
if (buttonModifiers & Qt::ShiftModifier)
3125
3152
ExpandSel(1, oldPos);
3126
// if ( this->itemText.lengthOfSelection() > 0 )
3153
// if (this->itemText.lengthOfSelection() > 0)
3127
3154
// view->RefreshItem(this);
3128
3155
m_Doc->scMW()->setTBvals(this);
3802
3829
p->drawLine(FPoint(0, TExtra + lineCorr), FPoint(Width, TExtra + lineCorr));
3803
3830
if (BExtra + lineCorr!=0.0)
3804
3831
p->drawLine(FPoint(0, Height - BExtra - lineCorr), FPoint(Width, Height - BExtra - lineCorr));
3805
double oldColRightX = Extra + lineCorr;
3806
3832
while(curCol < Cols)
3808
3834
colLeft=(colWidth + ColGap) * curCol + Extra + lineCorr;
3810
3836
p->drawLine(FPoint(colLeft, 0), FPoint(colLeft, 0+Height));
3811
3837
if (colLeft + colWidth != Width)
3812
3838
p->drawLine(FPoint(colLeft+colWidth, 0), FPoint(colLeft+colWidth, 0+Height));
3813
oldColRightX=colLeft+colWidth;