r15814 by pierremarc - Adjustments on the boxes model implementation (allowing to display at least one line).
scribus-commit
scribus-commit at lists.scribus.net
Mon Nov 8 18:02:40 CET 2010
Author: pierremarc
Date: Mon Nov 8 17:02:40 2010
New Revision: 15814
URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=15814
Log:
Adjustments on the boxes model implementation (allowing to display at least one line).
Modified:
branches/ScribusOIF/scribus/pageitem_textframe.cpp
branches/ScribusOIF/scribus/text/blocklayouter.cpp
branches/ScribusOIF/scribus/text/boxes.cpp
branches/ScribusOIF/scribus/text/glyphstore.cpp
branches/ScribusOIF/scribus/text/glyphstore.h
branches/ScribusOIF/scribus/text/linelayouter.cpp
branches/ScribusOIF/scribus/text/shaper.cpp
branches/ScribusOIF/scribus/text/textlayout.cpp
Modified: branches/ScribusOIF/scribus/pageitem_textframe.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15814&path=/branches/ScribusOIF/scribus/pageitem_textframe.cpp
==============================================================================
--- branches/ScribusOIF/scribus/pageitem_textframe.cpp (original)
+++ branches/ScribusOIF/scribus/pageitem_textframe.cpp Mon Nov 8 17:02:40 2010
@@ -237,6 +237,7 @@
{
// legacyLayout(this);
textLayout->layout();
+ invalid = false;
}
void PageItem_TextFrame::invalidateLayout()
Modified: branches/ScribusOIF/scribus/text/blocklayouter.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15814&path=/branches/ScribusOIF/scribus/text/blocklayouter.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/blocklayouter.cpp (original)
+++ branches/ScribusOIF/scribus/text/blocklayouter.cpp Mon Nov 8 17:02:40 2010
@@ -55,17 +55,20 @@
{
const GlyphStore * gs(m_layout->storyGlyphs());
const StoryText * story(m_layout->story());
+ const ParagraphStyle parStyle(story->paragraphStyle(startPos));
+ const CharStyle charStyle(parStyle.charStyle());
+ const BoxGroup * bg(m_layout->box());
- const BoxGroup * bg(m_layout->box());
double y(0.0);
- double x(0.0);
+ double x(parStyle.leftMargin() + parStyle.firstIndent());
if(bg->boxCount() > 0)
{
const Box* previousBox(bg->boxes().last());
y = previousBox->bbox().bottom()
+ story->paragraphStyle(startPos - 1).gapAfter()
- + story->paragraphStyle(startPos).gapBefore();
+ + parStyle.gapBefore();
}
+ y += parStyle.lineSpacing();
VBox * resultBox(new VBox);
double width(m_textFrame->width());
@@ -87,6 +90,10 @@
gs->findItem(curPos),
curPos,
lResult.endPos));
+ glyphs->moveTo(x,y);
+ glyphs->setWidth(lResult.width);
+ glyphs->setAscent(charStyle.font().ascent());
+ glyphs->setDescent(charStyle.font().descent());
line->addBox(glyphs);
}
else // we need as many GlyphBoxes as items
@@ -94,17 +101,29 @@
int item(gs->findItem(curPos));
int c(curPos);
int e(gs->itemCharCount(item) + c);
- line->addBox(new GlyphBox(const_cast<GlyphStore*>(gs), m_textFrame->doc()->PageColors, item, c, e));
+ GlyphBox * glyphs(new GlyphBox(const_cast<GlyphStore*>(gs), m_textFrame->doc()->PageColors, item, c, e));
+ glyphs->moveTo(x,y);
+ glyphs->setWidth(lResult.width);
+ glyphs->setAscent(charStyle.font().ascent());
+ glyphs->setDescent(charStyle.font().descent());
+ line->addBox(glyphs);
while(e < lResult.endPos)
{
c = e+1;
item = gs->findItem(c);
e = qMin(int(gs->itemCharCount(item) + c), lResult.endPos);
- line->addBox(new GlyphBox(const_cast<GlyphStore*>(gs), m_textFrame->doc()->PageColors, item, c, e));
+ glyphs = new GlyphBox(const_cast<GlyphStore*>(gs), m_textFrame->doc()->PageColors, item, c, e);
+ glyphs->moveTo(x,y);
+ glyphs->setWidth(lResult.width);
+ glyphs->setAscent(charStyle.font().ascent());
+ glyphs->setDescent(charStyle.font().descent());
+ line->addBox(glyphs);
}
}
+ y += parStyle.lineSpacing();
+ x = parStyle.leftMargin();
curPos = lResult.endPos + 1;
resultBox->addBox(line);
}
Modified: branches/ScribusOIF/scribus/text/boxes.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15814&path=/branches/ScribusOIF/scribus/text/boxes.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/boxes.cpp (original)
+++ branches/ScribusOIF/scribus/text/boxes.cpp Mon Nov 8 17:02:40 2010
@@ -469,7 +469,7 @@
for (unsigned int i(0); i < m_glyphs->itemGlyphCount(rItem); ++i)
{
uint glyph = layout->glyph;
- //qDebug() << "render glyph" << glyph << "width" << layout->xadvance << "font" << style.font().scName();
+ qDebug() << "render glyph" << glyph << "width" << layout->xadvance << "font" << style.font().scName() << "@" << x() << y() ;
if ((renderOptions.showControls) &&
(glyph == style.font().char2CMap(QChar(' ')) || glyph >= ScFace::CONTROL_GLYPHS))
{
Modified: branches/ScribusOIF/scribus/text/glyphstore.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15814&path=/branches/ScribusOIF/scribus/text/glyphstore.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/glyphstore.cpp (original)
+++ branches/ScribusOIF/scribus/text/glyphstore.cpp Mon Nov 8 17:02:40 2010
@@ -45,6 +45,21 @@
m_items.removeAt(i);
}
+void GlyphStore::deleteItems(QList<uint> li)
+{
+ foreach(uint it, li)
+ {
+ clearItem(it);
+ }
+ QList<ItemData> tmpStore(m_items);
+ m_items.clear();
+ for(uint it(0); it < tmpStore.length() ; ++it)
+ {
+ if(!li.contains(it))
+ m_items << tmpStore[it];
+ }
+}
+
uint GlyphStore::findItem(int pos) const
{
Modified: branches/ScribusOIF/scribus/text/glyphstore.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15814&path=/branches/ScribusOIF/scribus/text/glyphstore.h
==============================================================================
--- branches/ScribusOIF/scribus/text/glyphstore.h (original)
+++ branches/ScribusOIF/scribus/text/glyphstore.h Mon Nov 8 17:02:40 2010
@@ -162,6 +162,7 @@
void clearAllItems(uint firstItem);
/// removes this item and its associated glyphs from the store
void deleteItem(uint i);
+ void deleteItems(QList<uint> li);
/// returns the first item that contains textposition 'pos'
uint findItem(int pos) const;
/// returns a list of items for an interval of text positions
Modified: branches/ScribusOIF/scribus/text/linelayouter.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15814&path=/branches/ScribusOIF/scribus/text/linelayouter.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/linelayouter.cpp (original)
+++ branches/ScribusOIF/scribus/text/linelayouter.cpp Mon Nov 8 17:02:40 2010
@@ -62,8 +62,13 @@
{
if(cluster.textPosition() < start)
{
- cluster = gs->next(cluster);
- continue;
+ if(gs->haveNext(cluster))
+ {
+ cluster = gs->next(cluster);
+ continue;
+ }
+ else
+ break;
}
else if((cluster.textPosition() == start)
&& SpecialChars::isBreakingSpace(m_layout->story()->text(cluster.textPosition())))
Modified: branches/ScribusOIF/scribus/text/shaper.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15814&path=/branches/ScribusOIF/scribus/text/shaper.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/shaper.cpp (original)
+++ branches/ScribusOIF/scribus/text/shaper.cpp Mon Nov 8 17:02:40 2010
@@ -43,11 +43,7 @@
// reset items for this run. Radical!
QList<uint> items(gs->findIems(start, end));
- if(items.count() > 0)
- {
- foreach(uint it, items)
- gs->deleteItem(it);
- }
+ gs->deleteItems(items);
items.clear();
// redo itemization for this run
Modified: branches/ScribusOIF/scribus/text/textlayout.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15814&path=/branches/ScribusOIF/scribus/text/textlayout.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/textlayout.cpp (original)
+++ branches/ScribusOIF/scribus/text/textlayout.cpp Mon Nov 8 17:02:40 2010
@@ -329,7 +329,7 @@
m_firstInFrame = 0;
// a) the caller _MUST_ ensure that previous frame can provide a valid endOfFrame
// b) We adjust m_firstInFrame based on back frame
- // c) finally return if there's no more text to render
+ // c) finally return if there's no more text to layout
if(m_frame->prevInChain() != 0)
{
// if(!m_frame->BackBox->textLayout->isValid())
More information about the scribus-commit
mailing list