r15570 by pierremarc - Merged Andreas experiments on text engine.
scribus-commit
scribus-commit at lists.scribus.net
Mon Oct 18 12:52:30 CEST 2010
Author: pierremarc
Date: Mon Oct 18 10:52:30 2010
New Revision: 15570
URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=15570
Log:
Merged Andreas experiments on text engine.
It builds & runs, but almost all what's related to text is now broken.
Tagged a lot of '#if 0' blocks with FIXME_OIF to denote what has to be done in this branch.
Added:
branches/ScribusOIF/scribus/text/boxes.cpp
branches/ScribusOIF/scribus/text/boxes.h
branches/ScribusOIF/scribus/text/glyphlayout.cpp
branches/ScribusOIF/scribus/text/glyphlayout.h
branches/ScribusOIF/scribus/text/glyphstore.cpp
branches/ScribusOIF/scribus/text/glyphstore.h
branches/ScribusOIF/scribus/text/index.cpp
branches/ScribusOIF/scribus/text/index.h
branches/ScribusOIF/scribus/text/legacylayout.cpp
branches/ScribusOIF/scribus/text/legacylayout.h
branches/ScribusOIF/scribus/text/storytext_shared.cpp
branches/ScribusOIF/scribus/text/storytext_shared.h
branches/ScribusOIF/scribus/text/textlayout.cpp
branches/ScribusOIF/scribus/text/textlayout.h
Modified:
branches/ScribusOIF/scribus/canvasgesture_resize.cpp
branches/ScribusOIF/scribus/canvasmode_edit.cpp
branches/ScribusOIF/scribus/canvasmode_legacy.cpp
branches/ScribusOIF/scribus/fonts/scface.h
branches/ScribusOIF/scribus/fonts/scface_ttf.cpp
branches/ScribusOIF/scribus/fonts/scface_ttf.h
branches/ScribusOIF/scribus/fpointarray.cpp
branches/ScribusOIF/scribus/fpointarray.h
branches/ScribusOIF/scribus/pageitem.cpp
branches/ScribusOIF/scribus/pageitem.h
branches/ScribusOIF/scribus/pageitem_pathtext.cpp
branches/ScribusOIF/scribus/pageitem_textframe.cpp
branches/ScribusOIF/scribus/pageitem_textframe.h
branches/ScribusOIF/scribus/pdflib_core.cpp
branches/ScribusOIF/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
branches/ScribusOIF/scribus/plugins/fileloader/scribus134format/scribus134format_save.cpp
branches/ScribusOIF/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
branches/ScribusOIF/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
branches/ScribusOIF/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
branches/ScribusOIF/scribus/plugins/scriptplugin/cmdtext.cpp
branches/ScribusOIF/scribus/plugins/scriptplugin/cmdutil.cpp
branches/ScribusOIF/scribus/plugins/svgexplugin/svgexplugin.cpp
branches/ScribusOIF/scribus/pslib.cpp
branches/ScribusOIF/scribus/scpageoutput.cpp
branches/ScribusOIF/scribus/scribusdoc.cpp
branches/ScribusOIF/scribus/scribusview.cpp
branches/ScribusOIF/scribus/sctextstruct.cpp
branches/ScribusOIF/scribus/sctextstruct.h
branches/ScribusOIF/scribus/text/CMakeLists.txt
branches/ScribusOIF/scribus/text/sctext_shared.cpp
branches/ScribusOIF/scribus/text/specialchars.cpp
branches/ScribusOIF/scribus/text/specialchars.h
branches/ScribusOIF/scribus/text/storytext.cpp
branches/ScribusOIF/scribus/text/storytext.h
branches/ScribusOIF/scribus/ui/search.cpp
branches/ScribusOIF/scribus/ui/storyeditor.cpp
Modified: branches/ScribusOIF/scribus/canvasgesture_resize.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/canvasgesture_resize.cpp
==============================================================================
--- branches/ScribusOIF/scribus/canvasgesture_resize.cpp (original)
+++ branches/ScribusOIF/scribus/canvasgesture_resize.cpp Mon Oct 18 10:52:30 2010
@@ -273,15 +273,18 @@
currItem->itemText.item(aa)->setScaleH(
qMax(qMin(qRound(currItem->itemText.item(aa)->scaleH() * txtScX), 4000), 100));
#else
- currItem->itemText.item(aa)->setFontSize(
- qMax(qMin(currItem->itemText.item(aa)->fontSize() * txtScY, 4000.0), 1.0));
- currItem->itemText.item(aa)->setScaleH(
- qMax(qMin(qRound(currItem->itemText.item(aa)->scaleH() * txtScX / txtScY), 4000), 100));
+// currItem->itemText.item(aa)->setFontSize(
+// qMax(qMin(currItem->itemText.item(aa)->fontSize() * txtScY, 4000.0), 1.0));
+// currItem->itemText.item(aa)->setScaleH(
+// qMax(qMin(qRound(currItem->itemText.item(aa)->scaleH() * txtScX / txtScY), 4000), 100));
+ CharStyle cs(currItem->itemText.charStyle(aa));
+ cs.setFontSize(qMax(qMin(currItem->itemText.charStyle(aa).fontSize() * txtScY, 4000.0), 1.0));
+ currItem->itemText.setCharStyle(aa, 1, cs);
#endif
// We need to scale the linespacing _only once_ per paragraph.
if((aa == 0)
- || ( SpecialChars::isBreak(currItem->itemText.itemText(aa - 1).at(0))))
+ || ( SpecialChars::isBreak(currItem->itemText.text(aa - 1))))
{
ParagraphStyle ps(currItem->itemText.paragraphStyle(aa));
double oldLS(currItem->itemText.paragraphStyle(aa).lineSpacing());
Modified: branches/ScribusOIF/scribus/canvasmode_edit.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/canvasmode_edit.cpp
==============================================================================
--- branches/ScribusOIF/scribus/canvasmode_edit.cpp (original)
+++ branches/ScribusOIF/scribus/canvasmode_edit.cpp Mon Oct 18 10:52:30 2010
@@ -207,7 +207,7 @@
textframe->CPos = qMax ( 0,qMin ( textframe->CPos, textframe->itemText.length() ) );
int textCursorPos ( textframe->CPos );
- if ( textframe->lastInFrame() >= signed ( textframe->itemText.nrOfItems() )
+ if ( textframe->lastInFrame() >= signed ( textframe->itemText.length() )
|| textframe->itemText.length() == 0 )
{
dx = textframe->textToFrameDistLeft();
@@ -225,12 +225,12 @@
if (textCursorChar == SpecialChars::PARSEP || textCursorChar == SpecialChars::LINEBREAK)
{
// The cursor must be moved to the beginning of the next line
- FRect bbox = textframe->itemText.boundingBox ( textCursorPos );
+ FRect bbox = textframe->textLayout->boundingBox ( textCursorPos );
double lineSpacing(textframe->itemText.paragraphStyle(textCursorPos).lineSpacing());
// take care if cursor is not in first column
int curCol(1);
- double ccPos(textframe->itemText.boundingBox ( textCursorPos ).x());
+ double ccPos(textframe->textLayout->boundingBox ( textCursorPos ).x());
double leftOffset(textframe->textToFrameDistLeft());
for(int ci(1); ci <= textframe->columns(); ++ci)
{
@@ -259,7 +259,7 @@
// We want to position the cursor at the beginning of the next column, if any.
// At first we need to know in which column the cursor is.
int curCol(1);
- double ccPos(textframe->itemText.boundingBox ( textCursorPos ).x());
+ double ccPos(textframe->textLayout->boundingBox ( textCursorPos ).x());
double leftOffset(textframe->textToFrameDistLeft());
for(int ci(1); ci <= textframe->columns(); ++ci)
{
@@ -275,14 +275,14 @@
{
dx = (textframe->columnWidth() * curCol) + (textframe->columnGap() * curCol) + leftOffset;
dy = textframe->textToFrameDistTop();
- dy1 = textframe->textToFrameDistTop() + textframe->itemText.boundingBox ( textCursorPos ).height();
+ dy1 = textframe->textToFrameDistTop() + textframe->textLayout->boundingBox ( textCursorPos ).height();
}
else // there is no column after the current column
{
- FRect bbox = textframe->itemText.boundingBox ( textCursorPos );
+ FRect bbox = textframe->textLayout->boundingBox ( textCursorPos );
dx = bbox.x();
dy = bbox.y();
- dx += textframe->itemText.item ( textCursorPos )->glyph.wide();
+ dx += bbox.width();
if ( bbox.height() <= 2 )
dy1 = bbox.y() + textframe->itemText.charStyle ( textCursorPos ).fontSize() / 30.0;
else
@@ -291,10 +291,10 @@
}
else
{
- FRect bbox = textframe->itemText.boundingBox ( textCursorPos );
+ FRect bbox = textframe->textLayout->boundingBox ( textCursorPos );
dx = bbox.x();
dy = bbox.y();
- dx += textframe->itemText.item ( textCursorPos )->glyph.wide();
+ dx += bbox.width();
if ( bbox.height() <= 2 )
dy1 = bbox.y() + textframe->itemText.charStyle ( textCursorPos ).fontSize() / 30.0;
else
@@ -305,7 +305,7 @@
}
else
{
- FRect bbox = textframe->itemText.boundingBox ( textCursorPos );
+ FRect bbox = textframe->textLayout->boundingBox ( textCursorPos );
dx = bbox.x();
dy = bbox.y();
if ( bbox.height() <= 2 )
Modified: branches/ScribusOIF/scribus/canvasmode_legacy.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/canvasmode_legacy.cpp
==============================================================================
--- branches/ScribusOIF/scribus/canvasmode_legacy.cpp (original)
+++ branches/ScribusOIF/scribus/canvasmode_legacy.cpp Mon Oct 18 10:52:30 2010
@@ -126,17 +126,17 @@
{
textframe->CPos = textframe->itemText.length();
}
- if (textframe->lastInFrame() >= signed(textframe->itemText.nrOfItems())
+ if (textframe->lastInFrame() >= signed(textframe->itemText.length())
|| textframe->itemText.length() == 0)
{
x = 0;
y = 0;
y1 = static_cast<int>(textframe->itemText.defaultStyle().charStyle().fontSize() / 10);
}
- else if ( textframe->CPos > textframe->itemText.endOfItem(textframe->lastInFrame())
- || (textframe->CPos >= textframe->itemText.length() && textframe->itemText.text(textframe->itemText.length()-1) != SpecialChars::PARSEP) )
- {
- FRect bbox = textframe->itemText.boundingBox(qMax(0,qMin(textframe->lastInFrame(), textframe->itemText.length()-1)));
+ else if ( textframe->CPos >= textframe->textLayout->endOfFrame()
+ || (textframe->CPos >= textframe->itemText.length() && textframe->itemText.text(textframe->itemText.length()-1) != SpecialChars::PARSEP) )
+ {
+ FRect bbox = textframe->textLayout->boundingBox(qMax(0,qMin(textframe->lastInFrame(), textframe->itemText.length()-1)));
x = static_cast<int>(bbox.x() + bbox.width());
// x = static_cast<int>(bbox.x() + textframe->itemText.item(qMax(0,qMin(textframe->lastInFrame(), textframe->itemText.length()-1)))->glyph.wide());
y = static_cast<int>(bbox.y());
@@ -147,7 +147,7 @@
}
else
{
- FRect bbox = textframe->itemText.boundingBox(qMax(0,qMin(textframe->CPos, textframe->itemText.length())));
+ FRect bbox = textframe->textLayout->boundingBox(qMax(0,qMin(textframe->CPos, textframe->itemText.length())));
x = static_cast<int>(bbox.x());
y = static_cast<int>(bbox.y());
if (bbox.height() <= 2)
Modified: branches/ScribusOIF/scribus/fonts/scface.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/fonts/scface.h
==============================================================================
--- branches/ScribusOIF/scribus/fonts/scface.h (original)
+++ branches/ScribusOIF/scribus/fonts/scface.h Mon Oct 18 10:52:30 2010
@@ -21,6 +21,7 @@
*/
#include <QString>
+#include <QList>
//#include <QVector>
#include <QMap>
//#include <QArray>
@@ -28,6 +29,7 @@
#include "fpointarray.h"
#include "fonts/fontfeatureset.h"
+
struct GlyphMetrics {
qreal width;
@@ -35,7 +37,7 @@
qreal descent;
};
-
+class ScText;
/*! \brief Base Class ScFace : This is a total rewrite of the old Foi class.
@@ -181,6 +183,7 @@
virtual void RawData(QByteArray & /*bb*/) const {}
virtual bool glyphNames(QMap<uint, std::pair<QChar, QString> >& gList) const;
virtual FontFeatureSet * features() const { return 0; }
+ virtual int shapeText(const QList<ScText*>& txt) const {return txt.count();}
// these use the cache:
virtual qreal glyphWidth(uint gl, qreal sz) const;
@@ -376,6 +379,9 @@
/// Return a features Object provided by the font
FontFeatureSet * features() { return m->features();}
+
+ /// Process a styled string
+ int shapeText(const QList<ScText*>& txt) const{return m->shapeText(txt);}
private:
Modified: branches/ScribusOIF/scribus/fonts/scface_ttf.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/fonts/scface_ttf.cpp
==============================================================================
--- branches/ScribusOIF/scribus/fonts/scface_ttf.cpp (original)
+++ branches/ScribusOIF/scribus/fonts/scface_ttf.cpp Mon Oct 18 10:52:30 2010
@@ -19,6 +19,8 @@
#include "fonts/fontfeatureset.h"
#include "util.h"
#include "scconfig.h"
+#include "sctextstruct.h"
+#include "langmgr.h"
#include "third_party/harfbuzz/src/hb-ot.h"
@@ -36,6 +38,13 @@
return name;
}
+hb_tag_t stringToTag(const QString& tag)
+{
+ return HB_TAG(tag.at(0).toAscii(),tag.at(1).toAscii(),tag.at(2).toAscii(),tag.at(3).toAscii());
+}
+
+// TODO move it to a better place
+QMap<QString, QPair<hb_tag_t, hb_tag_t> > scLangToTags;
KernFeature::KernFeature ( FT_Face face )
:m_valid ( true )
@@ -712,4 +721,61 @@
return FtFace::glyphKerning ( gl1, gl2, sz );
}
-
+int ScFace_ttf::shapeText(const QList<ScText *> &txt) const
+{
+
+}
+
+unsigned int ScFace_ttf::getlookupIndex(const QString &table, const QString &language, const QString &feature)
+{
+ hb_tag_t t = (table == QString("GSUB")) ? HB_OT_TAG_GSUB : HB_OT_TAG_GPOS;
+ fillLangToTag();
+ if(scLangToTags.contains(language))
+ {
+ hb_tag_t scriptTag = scLangToTags[language].first;
+ hb_tag_t langTag = scLangToTags[language].second;
+ hb_tag_t featureTag = stringToTag(feature);
+ bool haveIt(false);
+ QList<FontFeatureSet::Feature> ff = featureSet->features(t == HB_OT_TAG_GSUB ? FontFeatureSet::Sub :FontFeatureSet::Pos );
+ foreach(const FontFeatureSet::Feature& f, ff)
+ {
+ if((f.name == feature)
+ && (f.lang.contains( tagToString(langTag) )) )
+ {
+ haveIt = true;
+ break;
+ }
+ }
+ if(haveIt)
+ {
+ hb_face_t * face = hb_ft_face_create(ftFace(), releaseFaceForHB );
+ unsigned int scriptIndex(0);
+ unsigned int languageIndex(0);
+ unsigned int featureIndex(0);
+ unsigned int lookupIndex(0);
+ hb_ot_layout_table_find_script(face, t,scriptTag, &scriptIndex);
+ hb_ot_layout_script_find_language(face, t, scriptIndex, langTag, &languageIndex);
+ hb_ot_layout_language_find_feature(face, t,scriptIndex, languageIndex, featureTag, &featureIndex);
+
+ }
+
+
+ }
+}
+
+void ScFace_ttf::fillLangToTag()
+{
+ if(!scLangToTags.isEmpty())
+ return;
+
+ LanguageManager *lm(LanguageManager::instance());
+ QStringList langs;
+ lm->fillInstalledStringList(&langs, false);
+ // Latin scripts
+ foreach(const QString& lang, langs)
+ {
+ QString abbr(lm->getAbbrevFromLang(lang));
+ scLangToTags[lm->getLangFromTransLang(lang)] = qMakePair(HB_TAG('l','a','t','n'),
+ hb_ot_tag_from_language(hb_language_from_string(abbr.toAscii().data())));
+ }
+}
Modified: branches/ScribusOIF/scribus/fonts/scface_ttf.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/fonts/scface_ttf.h
==============================================================================
--- branches/ScribusOIF/scribus/fonts/scface_ttf.h (original)
+++ branches/ScribusOIF/scribus/fonts/scface_ttf.h Mon Oct 18 10:52:30 2010
@@ -107,8 +107,11 @@
qreal glyphKerning ( uint gl1, uint gl2, qreal sz ) const;
TTFFeatureSet * features(FontFeatureSet::FeatureType type) const {return featureSet;}
-
+ int shapeText(const QList<ScText *> &txt) const;
+
private:
+ void fillLangToTag();
+ unsigned int getlookupIndex(const QString& table, const QString& language, const QString& feature);
mutable KernFeature * kernFeature;
mutable TTFFeatureSet * featureSet;
};
Modified: branches/ScribusOIF/scribus/fpointarray.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/fpointarray.cpp
==============================================================================
--- branches/ScribusOIF/scribus/fpointarray.cpp (original)
+++ branches/ScribusOIF/scribus/fpointarray.cpp Mon Oct 18 10:52:30 2010
@@ -267,6 +267,11 @@
p->xp = mx;
p->yp = my;
}
+}
+
+void FPointArray::map(QMatrix m)
+{
+ map(QTransform(m));
}
void FPointArray::setMarker()
Modified: branches/ScribusOIF/scribus/fpointarray.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/fpointarray.h
==============================================================================
--- branches/ScribusOIF/scribus/fpointarray.h (original)
+++ branches/ScribusOIF/scribus/fpointarray.h Mon Oct 18 10:52:30 2010
@@ -25,6 +25,7 @@
#define FPOINTARRAY_H
#include <QTransform>
+#include <QMatrix>
#include <QPainterPath>
#include <QPoint>
#include <QPointF>
@@ -60,6 +61,7 @@
void scale( double sx, double sy );
FPoint WidthHeight() const;
void map(QTransform m);
+ void map(QMatrix m);
FPointArray &operator=( const FPointArray &a );
FPointArray copy() const;
void setMarker();
Modified: branches/ScribusOIF/scribus/pageitem.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/pageitem.cpp
==============================================================================
--- branches/ScribusOIF/scribus/pageitem.cpp (original)
+++ branches/ScribusOIF/scribus/pageitem.cpp Mon Oct 18 10:52:30 2010
@@ -2449,380 +2449,380 @@
sets xadvance to the advance width without kerning. If more than one glyph
is generated, kerning is included in all but the last xadvance.
*/
-double PageItem::layoutGlyphs(const CharStyle& style, const QString& chars, GlyphLayout& layout)
-{
- double retval = 0.0;
- double asce = style.font().ascent(style.fontSize() / 10.0);
- int chst = style.effects() & 1919;
-/* if (chars[0] == SpecialChars::ZWSPACE ||
- chars[0] == SpecialChars::ZWNBSPACE ||
- chars[0] == SpecialChars::NBSPACE ||
- chars[0] == SpecialChars::NBHYPHEN ||
- chars[0] == SpecialChars::SHYPHEN ||
- chars[0] == SpecialChars::PARSEP ||
- chars[0] == SpecialChars::COLBREAK ||
- chars[0] == SpecialChars::LINEBREAK ||
- chars[0] == SpecialChars::FRAMEBREAK ||
- chars[0] == SpecialChars::TAB)
- {
- layout.glyph = ScFace::CONTROL_GLYPHS + chars[0].unicode();
- }
- else */
- {
- layout.glyph = style.font().char2CMap(chars[0].unicode());
- }
- double tracking = 0.0;
- if ( (style.effects() & ScStyle_StartOfLine) == 0)
- tracking = style.fontSize() * style.tracking() / 10000.0;
-
- layout.xoffset = tracking;
- layout.yoffset = 0;
- if (chst != ScStyle_Default)
- {
- if (chst & ScStyle_Superscript)
- {
- retval -= asce * m_Doc->typographicPrefs().valueSuperScript / 100.0;
- layout.yoffset -= asce * m_Doc->typographicPrefs().valueSuperScript / 100.0;
- layout.scaleV = layout.scaleH = qMax(m_Doc->typographicPrefs().scalingSuperScript / 100.0, 10.0 / style.fontSize());
- }
- else if (chst & ScStyle_Subscript)
- {
- retval += asce * m_Doc->typographicPrefs().valueSubScript / 100.0;
- layout.yoffset += asce * m_Doc->typographicPrefs().valueSubScript / 100.0;
- layout.scaleV = layout.scaleH = qMax(m_Doc->typographicPrefs().scalingSubScript / 100.0, 10.0 / style.fontSize());
- }
- else {
- layout.scaleV = layout.scaleH = 1.0;
- }
- layout.scaleH *= style.scaleH() / 1000.0;
- layout.scaleV *= style.scaleV() / 1000.0;
- if (chst & ScStyle_AllCaps)
- {
- layout.glyph = style.font().char2CMap(chars[0].toUpper().unicode());
- }
- if (chst & ScStyle_SmallCaps)
- {
- double smallcapsScale = m_Doc->typographicPrefs().valueSmallCaps / 100.0;
- QChar uc = chars[0].toUpper();
- if (uc != chars[0])
- {
- layout.glyph = style.font().char2CMap(chars[0].toUpper().unicode());
- layout.scaleV *= smallcapsScale;
- layout.scaleH *= smallcapsScale;
- }
- }
- }
- else {
- layout.scaleH = style.scaleH() / 1000.0;
- layout.scaleV = style.scaleV() / 1000.0;
- }
+//double PageItem::layoutGlyphs(const CharStyle& style, const QString& chars, GlyphLayout& layout)
+//{
+// double retval = 0.0;
+// double asce = style.font().ascent(style.fontSize() / 10.0);
+// int chst = style.effects() & 1919;
+///* if (chars[0] == SpecialChars::ZWSPACE ||
+// chars[0] == SpecialChars::ZWNBSPACE ||
+// chars[0] == SpecialChars::NBSPACE ||
+// chars[0] == SpecialChars::NBHYPHEN ||
+// chars[0] == SpecialChars::SHYPHEN ||
+// chars[0] == SpecialChars::PARSEP ||
+// chars[0] == SpecialChars::COLBREAK ||
+// chars[0] == SpecialChars::LINEBREAK ||
+// chars[0] == SpecialChars::FRAMEBREAK ||
+// chars[0] == SpecialChars::TAB)
+// {
+// layout.glyph = ScFace::CONTROL_GLYPHS + chars[0].unicode();
+// }
+// else */
+// {
+// layout.glyph = style.font().char2CMap(chars[0].unicode());
+// }
+// double tracking = 0.0;
+// if ( (style.effects() & ScStyle_StartOfLine) == 0)
+// tracking = style.fontSize() * style.tracking() / 10000.0;
+
+// layout.xoffset = tracking;
+// layout.yoffset = 0;
+// if (chst != ScStyle_Default)
+// {
+// if (chst & ScStyle_Superscript)
+// {
+// retval -= asce * m_Doc->typographicPrefs().valueSuperScript / 100.0;
+// layout.yoffset -= asce * m_Doc->typographicPrefs().valueSuperScript / 100.0;
+// layout.scaleV = layout.scaleH = qMax(m_Doc->typographicPrefs().scalingSuperScript / 100.0, 10.0 / style.fontSize());
+// }
+// else if (chst & ScStyle_Subscript)
+// {
+// retval += asce * m_Doc->typographicPrefs().valueSubScript / 100.0;
+// layout.yoffset += asce * m_Doc->typographicPrefs().valueSubScript / 100.0;
+// layout.scaleV = layout.scaleH = qMax(m_Doc->typographicPrefs().scalingSubScript / 100.0, 10.0 / style.fontSize());
+// }
+// else {
+// layout.scaleV = layout.scaleH = 1.0;
+// }
+// layout.scaleH *= style.scaleH() / 1000.0;
+// layout.scaleV *= style.scaleV() / 1000.0;
+// if (chst & ScStyle_AllCaps)
+// {
+// layout.glyph = style.font().char2CMap(chars[0].toUpper().unicode());
+// }
+// if (chst & ScStyle_SmallCaps)
+// {
+// double smallcapsScale = m_Doc->typographicPrefs().valueSmallCaps / 100.0;
+// QChar uc = chars[0].toUpper();
+// if (uc != chars[0])
+// {
+// layout.glyph = style.font().char2CMap(chars[0].toUpper().unicode());
+// layout.scaleV *= smallcapsScale;
+// layout.scaleH *= smallcapsScale;
+// }
+// }
+// }
+// else {
+// layout.scaleH = style.scaleH() / 1000.0;
+// layout.scaleV = style.scaleV() / 1000.0;
+// }
-/* if (layout.glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode())) {
- uint replGlyph = style.font().char2CMap(QChar(' '));
- layout.xadvance = style.font().glyphWidth(replGlyph, style.fontSize() / 10) * layout.scaleH;
- layout.yadvance = style.font().glyphBBox(replGlyph, style.fontSize() / 10).ascent * layout.scaleV;
- }
- else if (layout.glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBHYPHEN.unicode())) {
- uint replGlyph = style.font().char2CMap(QChar('-'));
- layout.xadvance = style.font().glyphWidth(replGlyph, style.fontSize() / 10) * layout.scaleH;
- layout.yadvance = style.font().glyphBBox(replGlyph, style.fontSize() / 10).ascent * layout.scaleV;
- }
- else if (layout.glyph >= ScFace::CONTROL_GLYPHS) {
- layout.xadvance = 0;
- layout.yadvance = 0;
- }
- else */
- {
- layout.xadvance = style.font().glyphWidth(layout.glyph, style.fontSize() / 10) * layout.scaleH;
- layout.yadvance = style.font().glyphBBox(layout.glyph, style.fontSize() / 10).ascent * layout.scaleV;
- }
- if (layout.xadvance > 0)
- layout.xadvance += tracking;
-
- if (chars.length() > 1) {
- layout.grow();
- layoutGlyphs(style, chars.mid(1), *layout.more);
- layout.xadvance += style.font().glyphKerning(layout.glyph, layout.more->glyph, style.fontSize() / 10) * layout.scaleH;
- if (layout.more->yadvance > layout.yadvance)
- layout.yadvance = layout.more->yadvance;
- }
- else {
- layout.shrink();
- }
- return retval;
-}
-
-void PageItem::drawGlyphs(ScPainter *p, const CharStyle& style, GlyphLayout& glyphs)
-{
- uint glyph = glyphs.glyph;
- if ((m_Doc->guidesPrefs().showControls) &&
- (glyph == style.font().char2CMap(QChar(' ')) || glyph >= ScFace::CONTROL_GLYPHS))
- {
- bool stroke = false;
- if (glyph >= ScFace::CONTROL_GLYPHS)
- glyph -= ScFace::CONTROL_GLYPHS;
- else
- glyph = 32;
- QTransform chma, chma4, chma5;
- FPointArray points;
- if (glyph == SpecialChars::TAB.unicode())
- {
- points = m_Doc->symTab.copy();
- chma4.translate(glyphs.xoffset + glyphs.xadvance - ((style.fontSize() / 10.0) * glyphs.scaleH * 0.7), glyphs.yoffset - ((style.fontSize() / 10.0) * glyphs.scaleV * 0.5));
- }
- else if (glyph == SpecialChars::COLBREAK.unicode())
- {
- points = m_Doc->symNewCol.copy();
- chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.6));
- }
- else if (glyph == SpecialChars::FRAMEBREAK.unicode())
- {
- points = m_Doc->symNewFrame.copy();
- chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.6));
- }
- else if (glyph == SpecialChars::PARSEP.unicode())
- {
- points = m_Doc->symReturn.copy();
- chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.8));
- }
- else if (glyph == SpecialChars::LINEBREAK.unicode())
- {
- points = m_Doc->symNewLine.copy();
- chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.4));
- }
- else if (glyph == SpecialChars::NBSPACE.unicode() ||
- glyph == 32)
- {
- stroke = (glyph == 32);
- points = m_Doc->symNonBreak.copy();
- chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.4));
- }
- else if (glyph == SpecialChars::NBHYPHEN.unicode())
- {
- points = style.font().glyphOutline(style.font().char2CMap(QChar('-')), style.fontSize() / 100);
- chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV));
- }
- else if (glyph == SpecialChars::SHYPHEN.unicode())
- {
- points.resize(0);
- points.addQuadPoint(0, -10, 0, -10, 0, -6, 0, -6);
- stroke = true;
- }
- else // ???
- {
- points.resize(0);
- points.addQuadPoint(0, -10, 0, -10, 0, -9, 0, -9);
- points.addQuadPoint(0, -9, 0, -9, 1, -9, 1, -9);
- points.addQuadPoint(1, -9, 1, -9, 1, -10, 1, -10);
- points.addQuadPoint(1, -10, 1, -10, 0, -10, 0, -10);
- }
- chma.scale(glyphs.scaleH * style.fontSize() / 100.0, glyphs.scaleV * style.fontSize() / 100.0);
- points.map(chma * chma4);
- p->setupPolygon(&points, true);
- QColor oldBrush = p->brush();
- p->setBrush( (style.effects() & ScStyle_SuppressSpace) ? Qt::green
- : PrefsManager::instance()->appPrefs.displayPrefs.controlCharColor);
- if (stroke)
- {
- QColor tmp = p->pen();
- p->setPen(p->brush(), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
- p->setLineWidth(style.fontSize() * glyphs.scaleV / 200.0);
- p->strokePath();
- p->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
- }
- else
- {
- p->setFillMode(1);
- p->fillPath();
- }
- p->setBrush(oldBrush);
- if (glyphs.more)
- {
- p->translate(glyphs.xadvance, 0);
- drawGlyphs(p, style, *glyphs.more);
- }
- return;
- }
- else if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode()) ||
- glyph == (ScFace::CONTROL_GLYPHS + 32))
- glyph = style.font().char2CMap(QChar(' '));
- else if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBHYPHEN.unicode()))
- glyph = style.font().char2CMap(QChar('-'));
+///* if (layout.glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode())) {
+// uint replGlyph = style.font().char2CMap(QChar(' '));
+// layout.xadvance = style.font().glyphWidth(replGlyph, style.fontSize() / 10) * layout.scaleH;
+// layout.yadvance = style.font().glyphBBox(replGlyph, style.fontSize() / 10).ascent * layout.scaleV;
+// }
+// else if (layout.glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBHYPHEN.unicode())) {
+// uint replGlyph = style.font().char2CMap(QChar('-'));
+// layout.xadvance = style.font().glyphWidth(replGlyph, style.fontSize() / 10) * layout.scaleH;
+// layout.yadvance = style.font().glyphBBox(replGlyph, style.fontSize() / 10).ascent * layout.scaleV;
+// }
+// else if (layout.glyph >= ScFace::CONTROL_GLYPHS) {
+// layout.xadvance = 0;
+// layout.yadvance = 0;
+// }
+// else */
+// {
+// layout.xadvance = style.font().glyphWidth(layout.glyph, style.fontSize() / 10) * layout.scaleH;
+// layout.yadvance = style.font().glyphBBox(layout.glyph, style.fontSize() / 10).ascent * layout.scaleV;
+// }
+// if (layout.xadvance > 0)
+// layout.xadvance += tracking;
+
+// if (chars.length() > 1) {
+// layout.grow();
+// layoutGlyphs(style, chars.mid(1), *layout.more);
+// layout.xadvance += style.font().glyphKerning(layout.glyph, layout.more->glyph, style.fontSize() / 10) * layout.scaleH;
+// if (layout.more->yadvance > layout.yadvance)
+// layout.yadvance = layout.more->yadvance;
+// }
+// else {
+// layout.shrink();
+// }
+// return retval;
+//}
+
+//void PageItem::drawGlyphs(ScPainter *p, const CharStyle& style, GlyphLayout& glyphs)
+//{
+// uint glyph = glyphs.glyph;
+// if ((m_Doc->guidesPrefs().showControls) &&
+// (glyph == style.font().char2CMap(QChar(' ')) || glyph >= ScFace::CONTROL_GLYPHS))
+// {
+// bool stroke = false;
+// if (glyph >= ScFace::CONTROL_GLYPHS)
+// glyph -= ScFace::CONTROL_GLYPHS;
+// else
+// glyph = 32;
+// QTransform chma, chma4, chma5;
+// FPointArray points;
+// if (glyph == SpecialChars::TAB.unicode())
+// {
+// points = m_Doc->symTab.copy();
+// chma4.translate(glyphs.xoffset + glyphs.xadvance - ((style.fontSize() / 10.0) * glyphs.scaleH * 0.7), glyphs.yoffset - ((style.fontSize() / 10.0) * glyphs.scaleV * 0.5));
+// }
+// else if (glyph == SpecialChars::COLBREAK.unicode())
+// {
+// points = m_Doc->symNewCol.copy();
+// chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.6));
+// }
+// else if (glyph == SpecialChars::FRAMEBREAK.unicode())
+// {
+// points = m_Doc->symNewFrame.copy();
+// chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.6));
+// }
+// else if (glyph == SpecialChars::PARSEP.unicode())
+// {
+// points = m_Doc->symReturn.copy();
+// chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.8));
+// }
+// else if (glyph == SpecialChars::LlayoutGINEBREAK.unicode())
+// {
+// points = m_Doc->symNewLine.copy();
+// chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.4));
+// }
+// else if (glyph == SpecialChars::NBSPACE.unicode() ||
+// glyph == 32)
+// {
+// stroke = (glyph == 32);
+// points = m_Doc->symNonBreak.copy();
+// chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.4));
+// }
+// else if (glyph == SpecialChars::NBHYPHEN.unicode())
+// {
+// points = style.font().glyphOutline(style.font().char2CMap(QChar('-')), style.fontSize() / 100);
+// chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV));
+// }
+// else if (glyph == SpecialChars::SHYPHEN.unicode())
+// {
+// points.resize(0);
+// points.addQuadPoint(0, -10, 0, -10, 0, -6, 0, -6);
+// stroke = true;
+// }
+// else // ???
+// {
+// points.resize(0);
+// points.addQuadPoint(0, -10, 0, -10, 0, -9, 0, -9);
+// points.addQuadPoint(0, -9, 0, -9, 1, -9, 1, -9);
+// points.addQuadPoint(1, -9, 1, -9, 1, -10, 1, -10);
+// points.addQuadPoint(1, -10, 1, -10, 0, -10, 0, -10);
+// }
+// chma.scale(glyphs.scaleH * style.fontSize() / 100.0, glyphs.scaleV * style.fontSize() / 100.0);
+// points.map(chma * chma4);
+// p->setupPolygon(&points, true);
+// QColor oldBrush = p->brush();
+// p->setBrush( (style.effects() & ScStyle_SuppressSpace) ? Qt::green
+// : PrefsManager::instance()->appPrefs.displayPrefs.controlCharColor);
+// if (stroke)
+// {
+// QColor tmp = p->pen();
+// p->setPen(p->brush(), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+// p->setLineWidth(style.fontSize() * glyphs.scaleV / 200.0);
+// p->strokePath();
+// p->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+// }
+// else
+// {
+// p->setFillMode(1);
+// p->fillPath();
+// }
+// p->setBrush(oldBrush);
+// if (glyphs.more)
+// {
+// p->translate(glyphs.xadvance, 0);
+// drawGlyphs(p, style, *glyphs.more);
+// }
+// return;
+// }
+// else if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode()) ||
+// glyph == (ScFace::CONTROL_GLYPHS + 32))
+// glyph = style.font().char2CMap(QChar(' '));
+// else if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBHYPHEN.unicode()))
+// glyph = style.font().char2CMap(QChar('-'));
- if (glyph >= ScFace::CONTROL_GLYPHS || (style.effects() & ScStyle_SuppressSpace)) {
-// qDebug("drawGlyphs: skipping %d", glyph);
- // all those are empty
- if (glyphs.more)
- {
- p->translate(glyphs.xadvance, 0);
- drawGlyphs(p, style, *glyphs.more);
- }
- return;
- }
-// if (style.font().canRender(QChar(glyph)))
- {
- FPointArray gly = style.font().glyphOutline(glyph);
- // Do underlining first so you can get typographically correct
- // underlines when drawing a white outline
- if (((style.effects() & ScStyle_Underline) || ((style.effects() & ScStyle_UnderlineWords) && glyph != style.font().char2CMap(QChar(' ')))) && (style.strokeColor() != CommonStrings::None))
- {
- double st, lw;
- if ((style.underlineOffset() != -1) || (style.underlineWidth() != -1))
- {
- if (style.underlineOffset() != -1)
- st = (style.underlineOffset() / 1000.0) * (style.font().descent(style.fontSize() / 10.0));
- else
- st = style.font().underlinePos(style.fontSize() / 10.0);
- if (style.underlineWidth() != -1)
- lw = (style.underlineWidth() / 1000.0) * (style.fontSize() / 10.0);
- else
- lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
- }
- else
- {
- st = style.font().underlinePos(style.fontSize() / 10.0);
- lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
- }
- if (style.baselineOffset() != 0)
- st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0);
- QColor tmpC = p->pen();
- p->setPen(p->brush());
- p->setLineWidth(lw);
- if (style.effects() & ScStyle_Subscript)
- p->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st));
- else
- p->drawLine(FPoint(glyphs.xoffset, -st), FPoint(glyphs.xoffset + glyphs.xadvance, -st));
- p->setPen(tmpC);
- }
- if (gly.size() > 3)
- {
- if (glyph == 0)
- {
-// qDebug() << QString("glyph 0: (%1,%2) * %3 %4 + %5").arg(glyphs.xoffset).arg(glyphs.yoffset).arg(glyphs.scaleH).arg(glyphs.scaleV).arg(glyphs.xadvance));
- }
- p->save();
- p->translate(glyphs.xoffset, glyphs.yoffset - ((style.fontSize() / 10.0) * glyphs.scaleV));
- if (Reverse)
- {
- p->scale(-1, 1);
- p->translate(-glyphs.xadvance, 0);
- }
- if (style.baselineOffset() != 0)
- p->translate(0, -(style.fontSize() / 10.0) * (style.baselineOffset() / 1000.0));
- double glxSc = glyphs.scaleH * style.fontSize() / 100.00;
- double glySc = glyphs.scaleV * style.fontSize() / 100.0;
- p->scale(glxSc, glySc);
-// p->setFillMode(1);
- bool fr = p->fillRule();
- p->setFillRule(false);
-// double a = gly.point(0).x();
-// double b = gly.point(0).y();
-// double c = gly.point(3).x();
-// double d = gly.point(3).y();
-// qDebug() << QString("drawglyphs: %1 (%2,%3) (%4,%5) scaled %6,%7 trans %8,%9")
-// .arg(gly.size()).arg(a).arg(b).arg(c).arg(d)
-// .arg(p->worldMatrix().m11()).arg(p->worldMatrix().m22()).arg(p->worldMatrix().dx()).arg(p->worldMatrix().dy());
- p->setupPolygon(&gly, true);
- if (m_Doc->layerOutline(LayerID))
- {
- p->save();
- p->setPen(m_Doc->layerMarker(LayerID), 0.5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
- p->setFillMode(ScPainter::None);
- p->setBrushOpacity(1.0);
- p->setPenOpacity(1.0);
- p->strokePath();
- p->restore();
- p->setFillRule(fr);
- p->restore();
- if (glyphs.more)
- {
- p->translate(glyphs.xadvance, 0);
- drawGlyphs(p, style, *glyphs.more);
- }
- return;
- }
- if (glyph == 0)
- {
- p->setPen(PrefsManager::instance()->appPrefs.displayPrefs.controlCharColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
- p->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() * 2 / 10000.0);
- p->strokePath();
- }
- else if ((style.font().isStroked()) && (style.strokeColor() != CommonStrings::None) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0))
- {
- QColor tmp = p->brush();
- p->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
- p->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0);
- p->strokePath();
- }
- else
- {
- if ((style.effects() & ScStyle_Shadowed) && (style.strokeColor() != CommonStrings::None))
- {
- p->save();
- p->translate((style.fontSize() * glyphs.scaleH * style.shadowXOffset() / 10000.0) / glxSc, -(style.fontSize() * glyphs.scaleV * style.shadowYOffset() / 10000.0) / glySc);
- QColor tmp = p->brush();
- p->setBrush(p->pen());
- p->setupPolygon(&gly, true);
- p->fillPath();
- p->setBrush(tmp);
- p->restore();
- p->setupPolygon(&gly, true);
- }
- if (style.fillColor() != CommonStrings::None)
- p->fillPath();
- if ((style.effects() & ScStyle_Outline) && (style.strokeColor() != CommonStrings::None) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0))
- {
- p->setLineWidth((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) / glySc);
- p->strokePath();
- }
- }
- p->setFillRule(fr);
- p->restore();
- }
- else {
-// qDebug() << "drawGlyphs: empty glyph" << glyph;
- }
- if ((style.effects() & ScStyle_Strikethrough) && (style.strokeColor() != CommonStrings::None))
- {
- double st, lw;
- if ((style.strikethruOffset() != -1) || (style.strikethruWidth() != -1))
- {
- if (style.strikethruOffset() != -1)
- st = (style.strikethruOffset() / 1000.0) * (style.font().ascent(style.fontSize() / 10.0));
- else
- st = style.font().strikeoutPos(style.fontSize() / 10.0);
- if (style.strikethruWidth() != -1)
- lw = (style.strikethruWidth() / 1000.0) * (style.fontSize() / 10.0);
- else
- lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
- }
- else
- {
- st = style.font().strikeoutPos(style.fontSize() / 10.0);
- lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
- }
- if (style.baselineOffset() != 0)
- st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0);
- p->setPen(p->brush());
- p->setLineWidth(lw);
- p->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st));
- }
- }
-/* else
- {
- p->setLineWidth(1);
- p->setPen(red);
- p->setBrush(red);
- p->setFillMode(1);
- p->drawRect(glyphs.xoffset, glyphs.yoffset - (style.fontSize() / 10.0) * glyphs.scaleV , (style.fontSize() / 10.0) * glyphs.scaleH, (style.fontSize() / 10.0) * glyphs.scaleV);
- }
- */
- if (glyphs.more)
- {
- p->translate(glyphs.xadvance, 0);
- drawGlyphs(p, style, *glyphs.more);
- }
-}
+// if (glyph >= ScFace::CONTROL_GLYPHS || (style.effects() & ScStyle_SuppressSpace)) {
+//// qDebug("drawGlyphs: skipping %d", glyph);
+// // all those are empty
+// if (glyphs.more)
+// {
+// p->translate(glyphs.xadvance, 0);
+// drawGlyphs(p, style, *glyphs.more);
+// }
+// return;
+// }
+//// if (style.font().canRender(QChar(glyph)))
+// {
+// FPointArray gly = style.font().glyphOutline(glyph);
+// // Do underlining first so you can get typographically correct
+// // underlines when drawing a white outline
+// if (((style.effects() & ScStyle_Underline) || ((style.effects() & ScStyle_UnderlineWords) && glyph != style.font().char2CMap(QChar(' ')))) && (style.strokeColor() != CommonStrings::None))
+// {
+// double st, lw;
+// if ((style.underlineOffset() != -1) || (style.underlineWidth() != -1))
+// {
+// if (style.underlineOffset() != -1)
+// st = (style.underlineOffset() / 1000.0) * (style.font().descent(style.fontSize() / 10.0));
+// else
+// st = style.font().underlinePos(style.fontSize() / 10.0);
+// if (style.underlineWidth() != -1)
+// lw = (style.underlineWidth() / 1000.0) * (style.fontSize() / 10.0);
+// else
+// lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
+// }
+// else
+// {
+// st = style.font().underlinePos(style.fontSize() / 10.0);
+// lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
+// }
+// if (style.baselineOffset() != 0)
+// st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0);
+// QColor tmpC = p->pen();
+// p->setPen(p->brush());
+// p->setLineWidth(lw);
+// if (style.effects() & ScStyle_Subscript)
+// p->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st));
+// else
+// p->drawLine(FPoint(glyphs.xoffset, -st), FPoint(glyphs.xoffset + glyphs.xadvance, -st));
+// p->setPen(tmpC);
+// }
+// if (gly.size() > 3)
+// {
+// if (glyph == 0)
+// {
+//// qDebug() << QString("glyph 0: (%1,%2) * %3 %4 + %5").arg(glyphs.xoffset).arg(glyphs.yoffset).arg(glyphs.scaleH).arg(glyphs.scaleV).arg(glyphs.xadvance));
+// }
+// p->save();
+// p->translate(glyphs.xoffset, glyphs.yoffset - ((style.fontSize() / 10.0) * glyphs.scaleV));
+// if (Reverse)
+// {
+// p->scale(-1, 1);
+// p->translate(-glyphs.xadvance, 0);
+// }
+// if (style.baselineOffset() != 0)
+// p->translate(0, -(style.fontSize() / 10.0) * (style.baselineOffset() / 1000.0));
+// double glxSc = glyphs.scaleH * style.fontSize() / 100.00;
+// double glySc = glyphs.scaleV * style.fontSize() / 100.0;
+// p->scale(glxSc, glySc);
+//// p->setFillMode(1);
+// bool fr = p->fillRule();
+// p->setFillRule(false);
+//// double a = gly.point(0).x();
+//// double b = gly.point(0).y();
+//// double c = gly.point(3).x();
+//// double d = gly.point(3).y();
+//// qDebug() << QString("drawglyphs: %1 (%2,%3) (%4,%5) scaled %6,%7 trans %8,%9")
+//// .arg(gly.size()).arg(a).arg(b).arg(c).arg(d)
+//// .arg(p->worldMatrix().m11()).arg(p->worldMatrix().m22()).arg(p->worldMatrix().dx()).arg(p->worldMatrix().dy());
+// p->setupPolygon(&gly, true);
+// if (m_Doc->layerOutline(LayerID))
+// {
+// p->save();
+// p->setPen(m_Doc->layerMarker(LayerID), 0.5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+// p->setFillMode(ScPainter::None);
+// p->setBrushOpacity(1.0);
+// p->setPenOpacity(1.0);
+// p->strokePath();
+// p->restore();
+// p->setFillRule(fr);
+// p->restore();
+// if (glyphs.more)
+// {
+// p->translate(glyphs.xadvance, 0);
+// drawGlyphs(p, style, *glyphs.more);
+// }
+// return;
+// }
+// if (glyph == 0)
+// {
+// p->setPen(PrefsManager::instance()->appPrefs.displayPrefs.controlCharColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+// p->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() * 2 / 10000.0);
+// p->strokePath();
+// }
+// else if ((style.font().isStroked()) && (style.strokeColor() != CommonStrings::None) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0))
+// {
+// QColor tmp = p->brush();
+// p->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+// p->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0);
+// p->strokePath();
+// }
+// else
+// {
+// if ((style.effects() & ScStyle_Shadowed) && (style.strokeColor() != CommonStrings::None))
+// {
+// p->save();
+// p->translate((style.fontSize() * glyphs.scaleH * style.shadowXOffset() / 10000.0) / glxSc, -(style.fontSize() * glyphs.scaleV * style.shadowYOffset() / 10000.0) / glySc);
+// QColor tmp = p->brush();
+// p->setBrush(p->pen());
+// p->setupPolygon(&gly, true);
+// p->fillPath();
+// p->setBrush(tmp);
+// p->restore();
+// p->setupPolygon(&gly, true);
+// }
+// if (style.fillColor() != CommonStrings::None)
+// p->fillPath();
+// if ((style.effects() & ScStyle_Outline) && (style.strokeColor() != CommonStrings::None) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0))
+// {
+// p->setLineWidth((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) / glySc);
+// p->strokePath();
+// }
+// }
+// p->setFillRule(fr);
+// p->restore();
+// }
+// else {
+//// qDebug() << "drawGlyphs: empty glyph" << glyph;
+// }
+// if ((style.effects() & ScStyle_Strikethrough) && (style.strokeColor() != CommonStrings::None))
+// {
+// double st, lw;
+// if ((style.strikethruOffset() != -1) || (style.strikethruWidth() != -1))
+// {
+// if (style.strikethruOffset() != -1)
+// st = (style.strikethruOffset() / 1000.0) * (style.font().ascent(style.fontSize() / 10.0));
+// else
+// st = style.font().strikeoutPos(style.fontSize() / 10.0);
+// if (style.strikethruWidth() != -1)
+// lw = (style.strikethruWidth() / 1000.0) * (style.fontSize() / 10.0);
+// else
+// lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
+// }
+// else
+// {
+// st = style.font().strikeoutPos(style.fontSize() / 10.0);
+// lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
+// }
+// if (style.baselineOffset() != 0)
+// st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0);
+// p->setPen(p->brush());
+// p->setLineWidth(lw);
+// p->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st));
+// }
+// }
+///* else
+// {
+// p->setLineWidth(1);
+// p->setPen(red);
+// p->setBrush(red);
+// p->setFillMode(1);
+// p->drawRect(glyphs.xoffset, glyphs.yoffset - (style.fontSize() / 10.0) * glyphs.scaleV , (style.fontSize() / 10.0) * glyphs.scaleH, (style.fontSize() / 10.0) * glyphs.scaleV);
+// }
+// */
+// if (glyphs.more)
+// {
+// p->translate(glyphs.xadvance, 0);
+// drawGlyphs(p, style, *glyphs.more);
+// }
+//}
void PageItem::DrawPolyL(QPainter *p, QPolygon pts)
{
Modified: branches/ScribusOIF/scribus/pageitem.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/pageitem.h
==============================================================================
--- branches/ScribusOIF/scribus/pageitem.h (original)
+++ branches/ScribusOIF/scribus/pageitem.h Mon Oct 18 10:52:30 2010
@@ -49,6 +49,9 @@
#include "undoobject.h"
#include "vgradient.h"
#include "mesh.h"
+#include "text/nlsconfig.h"
+#include "text/storytext.h"
+#include "desaxe/saxio.h"
#ifdef HAVE_CONFIG_H
#include "scconfig.h"
#endif
@@ -70,6 +73,7 @@
class PageItem_PathText;
class PageItem_LatexFrame;
class PageItem_Symbol;
+class TextLayout;
class PageItem_OSGFrame;
struct CopyPasteBuffer;
@@ -350,9 +354,9 @@
/// returns the style at the current charpos
const CharStyle& currentCharStyle() const;
// deprecated:
- double layoutGlyphs(const CharStyle& style, const QString& chars, GlyphLayout& layout);
+// double layoutGlyphs(const CharStyle& style, const QString& chars, GlyphLayout& layout);
void SetQColor(QColor *tmp, QString farbe, double shad);
- void drawGlyphs(ScPainter *p, const CharStyle& style, GlyphLayout& glyphs );
+// void drawGlyphs(ScPainter *p, const CharStyle& style, GlyphLayout& glyphs );
void DrawPolyL(QPainter *p, QPolygon pts);
QString ExpandToken(uint base);
@@ -498,6 +502,7 @@
int CPos;
/** Text des Elements */
StoryText itemText;
+ TextLayout* textLayout;
/** Flag fuer PDF-Bookmark */
bool isBookmark;
/** Flag for redraw in EditMode */
@@ -518,6 +523,7 @@
void dropLinks();
protected:
+ friend class FrameControl;
PageItem *BackBox;
PageItem *NextBox;
uint firstChar;
Modified: branches/ScribusOIF/scribus/pageitem_pathtext.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/pageitem_pathtext.cpp
==============================================================================
--- branches/ScribusOIF/scribus/pageitem_pathtext.cpp (original)
+++ branches/ScribusOIF/scribus/pageitem_pathtext.cpp Mon Oct 18 10:52:30 2010
@@ -73,269 +73,269 @@
void PageItem_PathText::DrawObj_Item(ScPainter *p, QRectF cullingArea)
{
- itemText.invalidateAll();
- firstChar = 0;
- MaxChars = 0;
- int a;
- double chs;
- QString chstr, chstr2, chstr3;
- ScText *hl;
- double dx;
- FPoint point = FPoint(0, 0);
- FPoint tangent = FPoint(0, 0);
- uint seg = 0;
- double segLen = 0;
- QColor tmp;
- CurX = Extra;
- QString cachedStroke = "";
- QString cachedFill = "";
- double cachedFillShade = -1;
- double cachedStrokeShade = -1;
- QString actStroke = "";
- QString actFill = "";
- double actFillShade = -1;
- double actStrokeShade = -1;
- QColor cachedFillQ;
- QColor cachedStrokeQ;
- if (!m_Doc->layerOutline(LayerID))
- {
- if (PoShow)
- {
- p->setupPolygon(&PoLine, false);
- if (NamedLStyle.isEmpty())
- {
- if ((!patternStrokeVal.isEmpty()) && (m_Doc->docPatterns.contains(patternStrokeVal)))
- {
- if (patternStrokePath)
- {
- QPainterPath guidePath = PoLine.toQPainterPath(false);
- DrawStrokePattern(p, guidePath);
- }
- else
- {
- p->setPattern(&m_Doc->docPatterns[patternStrokeVal], patternStrokeScaleX, patternStrokeScaleY, patternStrokeOffsetX, patternStrokeOffsetY, patternStrokeRotation, patternStrokeSkewX, patternStrokeSkewY, patternStrokeMirrorX, patternStrokeMirrorY);
- p->setStrokeMode(ScPainter::Pattern);
- p->strokePath();
- }
- }
- else if (GrTypeStroke > 0)
- {
- if ((!gradientStrokeVal.isEmpty()) && (!m_Doc->docGradients.contains(gradientStrokeVal)))
- gradientStrokeVal = "";
- if (!(gradientStrokeVal.isEmpty()) && (m_Doc->docGradients.contains(gradientStrokeVal)))
- stroke_gradient = m_Doc->docGradients[gradientStrokeVal];
- if (stroke_gradient.Stops() < 2) // fall back to solid stroking if there are not enough colorstops in the gradient.
- {
- if (lineColor() != CommonStrings::None)
- {
- p->setBrush(strokeQColor);
- p->setStrokeMode(ScPainter::Solid);
- }
- else
- p->setStrokeMode(ScPainter::None);
- }
- else
- {
- p->setStrokeMode(ScPainter::Gradient);
- p->stroke_gradient = stroke_gradient;
- if (GrTypeStroke == 6)
- p->setGradient(VGradient::linear, FPoint(GrStrokeStartX, GrStrokeStartY), FPoint(GrStrokeEndX, GrStrokeEndY), FPoint(GrStrokeStartX, GrStrokeStartY), GrStrokeScale, GrStrokeSkew);
- else
- p->setGradient(VGradient::radial, FPoint(GrStrokeStartX, GrStrokeStartY), FPoint(GrStrokeEndX, GrStrokeEndY), FPoint(GrStrokeFocalX, GrStrokeFocalY), GrStrokeScale, GrStrokeSkew);
- }
- p->strokePath();
- }
- else if (lineColor() != CommonStrings::None)
- {
- p->setStrokeMode(ScPainter::Solid);
- p->strokePath();
- }
- }
- else
- {
- p->setStrokeMode(ScPainter::Solid);
- multiLine ml = m_Doc->MLineStyles[NamedLStyle];
- QColor tmp;
- for (int it = ml.size()-1; it > -1; it--)
- {
- if (ml[it].Color != CommonStrings::None) // && (ml[it].Width != 0))
- {
- SetQColor(&tmp, ml[it].Color, ml[it].Shade);
- p->setPen(tmp, ml[it].Width, static_cast<Qt::PenStyle>(ml[it].Dash), static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
- p->strokePath();
- }
- }
- }
- }
- }
- double totalTextLen = 0.0;
- double totalCurveLen = 0.0;
- double extraOffset = 0.0;
- if (itemText.length() != 0)
- {
- CurX += itemText.charStyle(0).fontSize() * itemText.charStyle(0).tracking() / 10000.0;
- totalTextLen += itemText.charStyle(0).fontSize() * itemText.charStyle(0).tracking() / 10000.0;
- }
- segLen = PoLine.lenPathSeg(seg);
- for (a = firstChar; a < itemText.length(); ++a)
- {
- hl = itemText.item(a);
- chstr = hl->ch;
- if (chstr[0] == SpecialChars::PAGENUMBER || chstr[0] == SpecialChars::PARSEP || chstr[0] == SpecialChars::PAGECOUNT
- || chstr[0] == SpecialChars::TAB || chstr[0] == SpecialChars::LINEBREAK)
- continue;
- if (a < itemText.length()-1)
- chstr += itemText.text(a+1, 1);
- hl->glyph.yadvance = 0;
- layoutGlyphs(itemText.charStyle(a), chstr, hl->glyph);
- hl->glyph.shrink();
- if (hl->ch == SpecialChars::OBJECT)
- totalTextLen += (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()) * hl->glyph.scaleH;
- else
- totalTextLen += hl->glyph.wide()+hl->fontSize() * hl->tracking() / 10000.0;
- }
- for (uint segs = 0; segs < PoLine.size()-3; segs += 4)
- {
- totalCurveLen += PoLine.lenPathSeg(segs);
- }
- if ((itemText.defaultStyle().alignment() != 0) && (totalCurveLen >= totalTextLen + Extra))
- {
- if (itemText.defaultStyle().alignment() == 2)
- {
- CurX = totalCurveLen - totalTextLen;
- CurX -= Extra;
- }
- if (itemText.defaultStyle().alignment() == 1)
- CurX = (totalCurveLen - totalTextLen) / 2.0;
- if ((itemText.defaultStyle().alignment() == 3) || (itemText.defaultStyle().alignment() == 4))
- extraOffset = (totalCurveLen - Extra - totalTextLen) / static_cast<double>(itemText.length());
- }
-#ifndef NLS_PROTO
- QPainterPath guidePath = PoLine.toQPainterPath(false);
- QList<QPainterPath> pathList = decomposePath(guidePath);
- QPainterPath currPath = pathList[0];
- int currPathIndex = 0;
- for (a = firstChar; a < itemText.length(); ++a)
- {
- CurY = 0;
- hl = itemText.item(a);
- chstr = hl->ch;
- if (chstr[0] == SpecialChars::PAGENUMBER || chstr[0] == SpecialChars::PARSEP || chstr[0] == SpecialChars::PAGECOUNT
- || chstr[0] == SpecialChars::TAB || chstr[0] == SpecialChars::LINEBREAK)
- continue;
- chs = hl->fontSize();
- if (a < itemText.length()-1)
- chstr += itemText.text(a+1, 1);
- hl->glyph.yadvance = 0;
- layoutGlyphs(itemText.charStyle(a), chstr, hl->glyph);
- hl->glyph.shrink(); // HACK
- if (hl->ch == SpecialChars::OBJECT)
- dx = (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()) * hl->glyph.scaleH / 2.0;
- else
- dx = hl->glyph.wide() / 2.0;
- CurX += dx;
-
- double currPerc = currPath.percentAtLength(CurX);
- if (currPerc >= 0.9999999)
- {
- currPathIndex++;
- if (currPathIndex == pathList.count())
- {
- MaxChars = a;
- break;
- }
- currPath = pathList[currPathIndex];
- CurX = dx;
- currPerc = currPath.percentAtLength(CurX);
- }
- double currAngle = currPath.angleAtPercent(currPerc);
-#if QT_VERSION >= 0x040400
- if (currAngle <= 180.0)
- currAngle *= -1.0;
- else
- currAngle = 360.0 - currAngle;
-#endif
- QPointF currPoint = currPath.pointAtPercent(currPerc);
- tangent = FPoint(cos(currAngle * M_PI / 180.0), sin(currAngle * M_PI / 180.0));
- point = FPoint(currPoint.x(), currPoint.y());
- hl->glyph.xoffset = 0;
- hl->PtransX = point.x();
- hl->PtransY = point.y();
- hl->PRot = currAngle * M_PI / 180.0;
- hl->PDx = dx;
- QTransform trafo = QTransform( 1, 0, 0, -1, -dx, 0 );
- if (textPathFlipped)
- trafo *= QTransform(1, 0, 0, -1, 0, 0);
- if (textPathType == 0)
- trafo *= QTransform( tangent.x(), tangent.y(), tangent.y(), -tangent.x(), point.x(), point.y() ); // ID's Rainbow mode
- else if (textPathType == 1)
- trafo *= QTransform( 1, 0, 0, -1, point.x(), point.y() ); // ID's Stair Step mode
- else if (textPathType == 2)
- {
- double a = 1;
- if (tangent.x() < 0)
- a = -1;
- if (fabs(tangent.x()) > 0.1)
- trafo *= QTransform( a, (tangent.y() / tangent.x()) * a, 0, -1, point.x(), point.y() ); // ID's Skew mode
- else
- trafo *= QTransform( a, 4 * a, 0, -1, point.x(), point.y() );
- }
- QTransform sca = p->worldMatrix();
- trafo *= sca;
- p->save();
- QTransform savWM = p->worldMatrix();
- p->setWorldMatrix(trafo);
- if (!m_Doc->RePos)
- {
- actFill = itemText.charStyle(a).fillColor();
- actFillShade = itemText.charStyle(a).fillShade();
- if (actFill != CommonStrings::None)
- {
- p->setFillMode(ScPainter::Solid);
- if ((cachedFillShade != actFillShade) || (cachedFill != actFill))
- {
- SetQColor(&tmp, actFill, actFillShade);
- p->setBrush(tmp);
- cachedFillQ = tmp;
- cachedFill = actFill;
- cachedFillShade = actFillShade;
- }
- else
- p->setBrush(cachedFillQ);
- }
- else
- p->setFillMode(ScPainter::None);
- actStroke = itemText.charStyle(a).strokeColor();
- actStrokeShade = itemText.charStyle(a).strokeShade();
- if (actStroke != CommonStrings::None)
- {
- if ((cachedStrokeShade != actStrokeShade) || (cachedStroke != actStroke))
- {
- SetQColor(&tmp, actStroke, actStrokeShade);
- p->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
- cachedStrokeQ = tmp;
- cachedStroke = actStroke;
- cachedStrokeShade = actStrokeShade;
- }
- else
- p->setPen(cachedStrokeQ, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
- }
- p->translate(0.0, BaseOffs);
- if (hl->ch == SpecialChars::OBJECT)
- DrawObj_Embedded(p, cullingArea, itemText.charStyle(a), hl->embedded.getItem());
- else
- drawGlyphs(p, itemText.charStyle(a), hl->glyph);
- }
- p->setWorldMatrix(savWM);
- p->restore();
- MaxChars = a+1;
- CurX -= dx;
- if (hl->ch == SpecialChars::OBJECT)
- CurX += (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()) * hl->glyph.scaleH;
- else
- CurX += hl->glyph.wide()+hl->fontSize() * hl->tracking() / 10000.0 + extraOffset;
- }
-#endif
+// itemText.invalidateAll();
+// firstChar = 0;
+// MaxChars = 0;
+// int a;
+// double chs;
+// QString chstr, chstr2, chstr3;
+// ScText *hl;
+// double dx;
+// FPoint point = FPoint(0, 0);
+// FPoint tangent = FPoint(0, 0);
+// uint seg = 0;
+// double segLen = 0;
+// QColor tmp;
+// CurX = Extra;
+// QString cachedStroke = "";
+// QString cachedFill = "";
+// double cachedFillShade = -1;
+// double cachedStrokeShade = -1;
+// QString actStroke = "";
+// QString actFill = "";
+// double actFillShade = -1;
+// double actStrokeShade = -1;
+// QColor cachedFillQ;
+// QColor cachedStrokeQ;
+// if (!m_Doc->layerOutline(LayerID))
+// {
+// if (PoShow)
+// {
+// p->setupPolygon(&PoLine, false);
+// if (NamedLStyle.isEmpty())
+// {
+// if ((!patternStrokeVal.isEmpty()) && (m_Doc->docPatterns.contains(patternStrokeVal)))
+// {
+// if (patternStrokePath)
+// {
+// QPainterPath guidePath = PoLine.toQPainterPath(false);
+// DrawStrokePattern(p, guidePath);
+// }
+// else
+// {
+// p->setPattern(&m_Doc->docPatterns[patternStrokeVal], patternStrokeScaleX, patternStrokeScaleY, patternStrokeOffsetX, patternStrokeOffsetY, patternStrokeRotation, patternStrokeSkewX, patternStrokeSkewY, patternStrokeMirrorX, patternStrokeMirrorY);
+// p->setStrokeMode(ScPainter::Pattern);
+// p->strokePath();
+// }
+// }
+// else if (GrTypeStroke > 0)
+// {
+// if ((!gradientStrokeVal.isEmpty()) && (!m_Doc->docGradients.contains(gradientStrokeVal)))
+// gradientStrokeVal = "";
+// if (!(gradientStrokeVal.isEmpty()) && (m_Doc->docGradients.contains(gradientStrokeVal)))
+// stroke_gradient = m_Doc->docGradients[gradientStrokeVal];
+// if (stroke_gradient.Stops() < 2) // fall back to solid stroking if there are not enough colorstops in the gradient.
+// {
+// if (lineColor() != CommonStrings::None)
+// {
+// p->setBrush(strokeQColor);
+// p->setStrokeMode(ScPainter::Solid);
+// }
+// else
+// p->setStrokeMode(ScPainter::None);
+// }
+// else
+// {
+// p->setStrokeMode(ScPainter::Gradient);
+// p->stroke_gradient = stroke_gradient;
+// if (GrTypeStroke == 6)
+// p->setGradient(VGradient::linear, FPoint(GrStrokeStartX, GrStrokeStartY), FPoint(GrStrokeEndX, GrStrokeEndY), FPoint(GrStrokeStartX, GrStrokeStartY), GrStrokeScale, GrStrokeSkew);
+// else
+// p->setGradient(VGradient::radial, FPoint(GrStrokeStartX, GrStrokeStartY), FPoint(GrStrokeEndX, GrStrokeEndY), FPoint(GrStrokeFocalX, GrStrokeFocalY), GrStrokeScale, GrStrokeSkew);
+// }
+// p->strokePath();
+// }
+// else if (lineColor() != CommonStrings::None)
+// {
+// p->setStrokeMode(ScPainter::Solid);
+// p->strokePath();
+// }
+// }
+// else
+// {
+// p->setStrokeMode(ScPainter::Solid);
+// multiLine ml = m_Doc->MLineStyles[NamedLStyle];
+// QColor tmp;
+// for (int it = ml.size()-1; it > -1; it--)
+// {
+// if (ml[it].Color != CommonStrings::None) // && (ml[it].Width != 0))
+// {
+// SetQColor(&tmp, ml[it].Color, ml[it].Shade);
+// p->setPen(tmp, ml[it].Width, static_cast<Qt::PenStyle>(ml[it].Dash), static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
+// p->strokePath();
+// }
+// }
+// }
+// }
+// }
+// double totalTextLen = 0.0;
+// double totalCurveLen = 0.0;
+// double extraOffset = 0.0;
+// if (itemText.length() != 0)
+// {
+// CurX += itemText.charStyle(0).fontSize() * itemText.charStyle(0).tracking() / 10000.0;
+// totalTextLen += itemText.charStyle(0).fontSize() * itemText.charStyle(0).tracking() / 10000.0;
+// }
+// segLen = PoLine.lenPathSeg(seg);
+// for (a = firstChar; a < itemText.length(); ++a)
+// {
+// hl = itemText.item(a);
+// chstr = hl->ch;
+// if (chstr[0] == SpecialChars::PAGENUMBER || chstr[0] == SpecialChars::PARSEP || chstr[0] == SpecialChars::PAGECOUNT
+// || chstr[0] == SpecialChars::TAB || chstr[0] == SpecialChars::LINEBREAK)
+// continue;
+// if (a < itemText.length()-1)
+// chstr += itemText.text(a+1, 1);
+// hl->glyph.yadvance = 0;
+// layoutGlyphs(itemText.charStyle(a), chstr, hl->glyph);
+// hl->glyph.shrink();
+// if (hl->ch == SpecialChars::OBJECT)
+// totalTextLen += (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()) * hl->glyph.scaleH;
+// else
+// totalTextLen += hl->glyph.wide()+hl->fontSize() * hl->tracking() / 10000.0;
+// }
+// for (uint segs = 0; segs < PoLine.size()-3; segs += 4)
+// {
+// totalCurveLen += PoLine.lenPathSeg(segs);
+// }
+// if ((itemText.defaultStyle().alignment() != 0) && (totalCurveLen >= totalTextLen + Extra))
+// {
+// if (itemText.defaultStyle().alignment() == 2)
+// {
+// CurX = totalCurveLen - totalTextLen;
+// CurX -= Extra;
+// }
+// if (itemText.defaultStyle().alignment() == 1)
+// CurX = (totalCurveLen - totalTextLen) / 2.0;
+// if ((itemText.defaultStyle().alignment() == 3) || (itemText.defaultStyle().alignment() == 4))
+// extraOffset = (totalCurveLen - Extra - totalTextLen) / static_cast<double>(itemText.length());
+// }
+//#ifndef NLS_PROTO
+// QPainterPath guidePath = PoLine.toQPainterPath(false);
+// QList<QPainterPath> pathList = decomposePath(guidePath);
+// QPainterPath currPath = pathList[0];
+// int currPathIndex = 0;
+// for (a = firstChar; a < itemText.length(); ++a)
+// {
+// CurY = 0;
+// hl = itemText.item(a);
+// chstr = hl->ch;
+// if (chstr[0] == SpecialChars::PAGENUMBER || chstr[0] == SpecialChars::PARSEP || chstr[0] == SpecialChars::PAGECOUNT
+// || chstr[0] == SpecialChars::TAB || chstr[0] == SpecialChars::LINEBREAK)
+// continue;
+// chs = hl->fontSize();
+// if (a < itemText.length()-1)
+// chstr += itemText.text(a+1, 1);
+// hl->glyph.yadvance = 0;
+// layoutGlyphs(itemText.charStyle(a), chstr, hl->glyph);
+// hl->glyph.shrink(); // HACK
+// if (hl->ch == SpecialChars::OBJECT)
+// dx = (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()) * hl->glyph.scaleH / 2.0;
+// else
+// dx = hl->glyph.wide() / 2.0;
+// CurX += dx;
+
+// double currPerc = currPath.percentAtLength(CurX);
+// if (currPerc >= 0.9999999)
+// {
+// currPathIndex++;
+// if (currPathIndex == pathList.count())
+// {
+// MaxChars = a;
+// break;
+// }
+// currPath = pathList[currPathIndex];
+// CurX = dx;
+// currPerc = currPath.percentAtLength(CurX);
+// }
+// double currAngle = currPath.angleAtPercent(currPerc);
+//#if QT_VERSION >= 0x040400
+// if (currAngle <= 180.0)
+// currAngle *= -1.0;
+// else
+// currAngle = 360.0 - currAngle;
+//#endif
+// QPointF currPoint = currPath.pointAtPercent(currPerc);
+// tangent = FPoint(cos(currAngle * M_PI / 180.0), sin(currAngle * M_PI / 180.0));
+// point = FPoint(currPoint.x(), currPoint.y());
+// hl->glyph.xoffset = 0;
+// hl->PtransX = point.x();
+// hl->PtransY = point.y();
+// hl->PRot = currAngle * M_PI / 180.0;
+// hl->PDx = dx;
+// QTransform trafo = QTransform( 1, 0, 0, -1, -dx, 0 );
+// if (textPathFlipped)
+// trafo *= QTransform(1, 0, 0, -1, 0, 0);
+// if (textPathType == 0)
+// trafo *= QTransform( tangent.x(), tangent.y(), tangent.y(), -tangent.x(), point.x(), point.y() ); // ID's Rainbow mode
+// else if (textPathType == 1)
+// trafo *= QTransform( 1, 0, 0, -1, point.x(), point.y() ); // ID's Stair Step mode
+// else if (textPathType == 2)
+// {
+// double a = 1;
+// if (tangent.x() < 0)
+// a = -1;
+// if (fabs(tangent.x()) > 0.1)
+// trafo *= QTransform( a, (tangent.y() / tangent.x()) * a, 0, -1, point.x(), point.y() ); // ID's Skew mode
+// else
+// trafo *= QTransform( a, 4 * a, 0, -1, point.x(), point.y() );
+// }
+// QTransform sca = p->worldMatrix();
+// trafo *= sca;
+// p->save();
+// QTransform savWM = p->worldMatrix();
+// p->setWorldMatrix(trafo);
+// if (!m_Doc->RePos)
+// {
+// actFill = itemText.charStyle(a).fillColor();
+// actFillShade = itemText.charStyle(a).fillShade();
+// if (actFill != CommonStrings::None)
+// {
+// p->setFillMode(ScPainter::Solid);
+// if ((cachedFillShade != actFillShade) || (cachedFill != actFill))
+// {
+// SetQColor(&tmp, actFill, actFillShade);
+// p->setBrush(tmp);
+// cachedFillQ = tmp;
+// cachedFill = actFill;
+// cachedFillShade = actFillShade;
+// }
+// else
+// p->setBrush(cachedFillQ);
+// }
+// else
+// p->setFillMode(ScPainter::None);
+// actStroke = itemText.charStyle(a).strokeColor();
+// actStrokeShade = itemText.charStyle(a).strokeShade();
+// if (actStroke != CommonStrings::None)
+// {
+// if ((cachedStrokeShade != actStrokeShade) || (cachedStroke != actStroke))
+// {
+// SetQColor(&tmp, actStroke, actStrokeShade);
+// p->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+// cachedStrokeQ = tmp;
+// cachedStroke = actStroke;
+// cachedStrokeShade = actStrokeShade;
+// }
+// else
+// p->setPen(cachedStrokeQ, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+// }
+// p->translate(0.0, BaseOffs);
+// if (hl->ch == SpecialChars::OBJECT)
+// DrawObj_Embedded(p, cullingArea, itemText.charStyle(a), hl->embedded.getItem());
+// else
+// drawGlyphs(p, itemText.charStyle(a), hl->glyph);
+// }
+// p->setWorldMatrix(savWM);
+// p->restore();
+// MaxChars = a+1;
+// CurX -= dx;
+// if (hl->ch == SpecialChars::OBJECT)
+// CurX += (hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth()) * hl->glyph.scaleH;
+// else
+// CurX += hl->glyph.wide()+hl->fontSize() * hl->tracking() / 10000.0 + extraOffset;
+// }
+//#endif
}
bool PageItem_PathText::createInfoGroup(QFrame *infoGroup, QGridLayout *infoGroupLayout)
@@ -372,7 +372,7 @@
linesCT->setText(tr("Lines: "));
infoGroupLayout->addWidget( linesCT, 2, 0, Qt::AlignRight );
- linesT->setText(QString::number(itemText.lines()));
+ linesT->setText(QString::number(textLayout->lines()));
infoGroupLayout->addWidget( linesT, 2, 1 );
Modified: branches/ScribusOIF/scribus/pageitem_textframe.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/pageitem_textframe.cpp
==============================================================================
--- branches/ScribusOIF/scribus/pageitem_textframe.cpp (original)
+++ branches/ScribusOIF/scribus/pageitem_textframe.cpp Mon Oct 18 10:52:30 2010
@@ -47,7 +47,10 @@
#include "scribusdoc.h"
#include "scribusstructs.h"
#include "selection.h"
+#include "text/glyphlayout.h"
+#include "text/legacylayout.h"
#include "text/nlsconfig.h"
+#include "text/textlayout.h"
#include "undomanager.h"
#include "undostate.h"
#include "util.h"
@@ -229,2029 +232,10 @@
currentShadow = newShadow;
}
}
-
-#ifdef NLS_PROTO
-#include "text/pageitem_textframe.cpp"
-#else
-
-static void dumpIt(const ParagraphStyle& pstyle, QString indent = QString("->"))
-{
- QString db = QString("%6%1/%2 @ %3: %4--%5 linespa%6: %7 align%8")
- .arg(pstyle.name())
- .arg(pstyle.parent())
- .arg( (unsigned long int) &pstyle)
- .arg(pstyle.leftMargin())
- .arg(pstyle.rightMargin())
- .arg(indent)
- .arg(pstyle.lineSpacingMode())
- .arg(pstyle.lineSpacing())
- .arg(pstyle.alignment());
- qDebug() << db;
- static QString more(" ");
- if (pstyle.hasParent())
- dumpIt(*dynamic_cast<const ParagraphStyle*>(pstyle.parentStyle()), more + indent);
-}
-
-
-static const bool legacy = true;
-
-/*
-static void layoutDropCap(GlyphLayout layout, double curX, double curY, double offsetX, double offsetY, double dropCapDrop)
-{
-}
-*/
-
-/**
- Clones the tab fill char as often as necssary after all distances are known
- */
-static void fillInTabLeaders(StoryText & itemText, LineSpec & curLine)
-{
- // fill in tab leaders
- double xPos = curLine.x;
- for (int ti= curLine.firstItem; ti <= curLine.lastItem; ++ti)
- {
- ScText * hl = itemText.item(ti);
- if (hl->ch == SpecialChars::TAB)
- {
- GlyphLayout * tglyph = hl->glyph.more;
-
- if (!tglyph)
- continue;
-
- const CharStyle & charStyle(itemText.charStyle(ti));
- double wt = charStyle.font().glyphWidth(tglyph->glyph, charStyle.fontSize() * tglyph->scaleV / 10.0);
- double len = hl->glyph.xadvance;
- int count = static_cast<int>(len / wt);
- double sPos = -len;
- tglyph->xoffset = sPos;
-// qDebug() << QString("tab leaders: %1 %2 width=%3 count=%4").arg(sPos).arg(curLine.y).arg(wt).arg(count);
- for (int cx = 1; cx < count; ++cx)
- {
- // clone fillchar
- tglyph->grow();
- *(tglyph->more) = *tglyph;
- tglyph->more->more = NULL;
- tglyph = tglyph->more;
- tglyph->xoffset = sPos + wt * cx;
- }
- }
- xPos += hl->glyph.wide();
- }
-}
-
-
-
-enum TabStatus {
- TabNONE = 0,
- TabLEFT = TabNONE,
- TabRIGHT = 1,
- TabPOINT = 2,
- TabCOMMA = 3,
- TabCENTER = 4
-};
-
-
-/**
-fields which describe what type of tab is currently active
- */
-struct TabControl {
- bool active;
- int status;
- int charIndex;
- double xPos;
- QChar fillChar;
-};
-
-/**
-fields which describe how the current line is placed into the frame
- */
-struct LineControl {
- LineSpec line;
- int itemsInLine;
- int hyphenCount;
- double colWidth;
- double colGap;
- double colLeft;
- double colRight;
- int column;
- bool startOfCol;
- bool hasDropCap;
- double ascend;
- double descend;
- double width;
- double xPos;
- double yPos;
- int breakIndex;
- double breakXPos;
-
- double maxShrink;
- double maxStretch;
-
-
- /// remember frame dimensions and offsets
- void init(double w, double h, const MarginStruct& extra, double lCorr)
- {
- insets = extra;
- lineCorr = lCorr;
- frameWidth = w;
- frameHeight = h;
- hasDropCap = false;
- }
-
- /// start at column 0
- void initColumns(double width, double gap)
- {
- column = 0;
- colWidth = width;
- colGap = gap;
- }
-
- /// move position to next column
- void nextColumn(double asce)
- {
- startOfCol = true;
- colLeft = (colWidth + colGap) * column + insets.Left + lineCorr;
- colRight = colLeft + colWidth;
- if (legacy)
- colRight += insets.Right + lineCorr; //???
- xPos = colLeft;
- yPos = asce + insets.Top + lineCorr + 1;
- }
-
- bool isEndOfCol(double morespace = 0)
- {
- return yPos + morespace + insets.Bottom + lineCorr > frameHeight;
- }
-
- /**
- init fields for a new line at current position
- */
- void startLine(int first)
- {
- itemsInLine = 0;
- line.x = xPos;
- line.y = yPos;
- line.firstItem = first;
- line.ascent = 10;
- line.descent = 0;
- line.width = 0;
- line.naturalWidth = 0;
- line.colLeft = colLeft;
- breakIndex = -1;
- breakXPos = 0;
- maxShrink = 0;
- maxStretch = 0;
- }
-
-
- /// called when glyphs are placed on the line
- void rememberShrinkStretch(QChar ch, double wide, const ParagraphStyle& style)
- {
- if (SpecialChars::isExpandingSpace(ch))
- maxShrink += (1 - style.minWordTracking()) * wide;
- else
- {
- maxShrink += (1 - style.minGlyphExtension()) * wide;
- }
- maxStretch += (style.maxGlyphExtension() - 1) * wide;
- }
-
- /// called when a possible break is passed
- void rememberBreak(int index, double pos)
- {
- if (pos > colRight)
- {
- // only look for the first break behind the right edge
- maxShrink = 0;
-
- // check if we already have a better break
- if (breakIndex >= 0)
- {
- double oldLooseness = qAbs(colRight - breakXPos);
-
- double newLooseness = pos - colRight;
- if (newLooseness >= oldLooseness)
- return;
- }
- breakXPos = colRight;
- }
- else
- {
- breakXPos = pos;
- }
- breakIndex = index;
- }
-
- /// called when a mandatory break is found
- void breakLine(const StoryText& itemText, const ParagraphStyle& style, FirstLineOffsetPolicy offsetPolicy, int last)
- {
- breakIndex = last;
- breakXPos = line.x;
- for (int j = line.firstItem; j <= last; ++j)
- if ( (itemText.item(j)->effects() & ScStyle_SuppressSpace) == 0)
- breakXPos += itemText.item(j)->glyph.wide();
- // #8194, #8717 : update line ascent and descent with sensible values
- // so that endOfLine() returns correct result
- updateHeightMetrics(itemText);
- // #9060 : update line offset too
- updateLineOffset(itemText, style, offsetPolicy);
- }
-
- /// use the last remembered break to set line width and itemrange
- void finishLine(double endX)
- {
- line.lastItem = breakIndex;
- line.naturalWidth = breakXPos - line.x;
- line.width = endX - line.x;
- maxShrink = maxStretch = 0;
- }
-
-
- bool isEndOfLine(double moreSpace = 0)
- {
- if (legacy)
- return xPos + insets.Right + lineCorr + moreSpace - maxShrink >= colRight;
- else
- return xPos + moreSpace - maxShrink >= colRight;
- }
-
- /// find x position to start current line
- double startOfLine(const QRegion& shape, const QTransform& pf2, double ascent, double descent, double morespace)
- {
- QPoint pt1, pt2;
- double tmpX = xPos;
- pt1 = QPoint(static_cast<int>(ceil(tmpX)), static_cast<int>(yPos + descent));
- pt2 = QPoint(static_cast<int>(ceil(tmpX)), static_cast<int>(ceil(yPos - ascent)));
- // increase pt1/pt2 until i-beam reaches end of line
- while ((!shape.contains(pf2.map(pt1))) || (!shape.contains(pf2.map(pt2))))
- {
- tmpX++;
- if (xPos + (legacy? lineCorr + insets.Right : 0) + lineCorr + morespace >= colRight)
- {
- return tmpX;
- }
- pt1 = QPoint(static_cast<int>(ceil(tmpX)), static_cast<int>(yPos + descent));
- pt2 = QPoint(static_cast<int>(ceil(tmpX)), static_cast<int>(ceil(yPos - ascent)));
- }
- return tmpX;
- }
-
- /// find x position where this line must end
- double endOfLine(const QRegion& shape, const QTransform& pf2, double morespace = 0)
- {
- // Keep old code for reference
- /*double EndX = floor(qMax(line.x, qMin(colRight,breakXPos) - 1));
- QPoint pt1, pt2;
- // qDebug() << QString("endx start=%1, hl is '%2'").arg(EndX).arg(hl->ch);
- do {
- EndX += 0.125;
- pt1 = QPoint(qRound(ceil(EndX + insets.Right)), static_cast<int>(yPos+descent));
- pt2 = QPoint(qRound(ceil(EndX + insets.Right)), static_cast<int>(ceil(yPos-ascent)));
- } while ( (EndX + (legacy? lineCorr + insets.Right : 0) < colRight - morespace)
- && shape.contains(pf2.map(pt1))
- && shape.contains(pf2.map(pt2))
- );*/
-
- // if we aren't restricted further, we'll end at this maxX:
- double maxX = colRight - morespace;
- if (legacy) maxX -= (lineCorr + insets.Right);
-
- double StartX = floor(qMax(line.x, qMin(colRight,breakXPos) - 1));
- int xPos = static_cast<int>(ceil(maxX + insets.Right));
- int yDesc = static_cast<int>(yPos+line.descent);
- int yAsc = static_cast<int>(ceil(yPos-line.ascent));
-
- QPoint pt12 (xPos, yDesc);
- QPoint pt22 (xPos, yAsc);
-
- // simple and fast case: transformed line completely falls within range
- // this will happen if we don't wrap around anything - ie. very often
- QPolygon p;
- p.append (pf2.map (QPoint (StartX, yAsc)));
- p.append (pf2.map (QPoint (StartX, yDesc)));
- p.append (pf2.map (pt12));
- p.append (pf2.map (pt22));
- // check if something gets in the way
- QRegion lineI = shape.intersected (p.boundingRect());
- // if the intersection only has 1 rectangle, then nothing gets in the way
- if (lineI.numRects() == 1)
- {
- int xPos = qRound(ceil(StartX + 0.125 + insets.Right));
- pt12.setX(xPos);
- pt22.setX(xPos);
- if (shape.contains(pf2.map(pt12)) && shape.contains(pf2.map(pt22)))
- {
- QRect rect = lineI.rects().at(0);
- double mx = qMax(rect.left(), rect.right()) - pf2.dx();
- int steps = static_cast<int>((mx - StartX - insets.Right - 2)/0.125);
- if (steps > 0)
- StartX += steps * 0.125;
- }
- }
-
- // qDebug()<<"endOfLine: going for the hard case";
- double EndX2 = StartX;
- double Interval = 0.125;
- do {
- EndX2 += Interval;
- int xPos = qRound(ceil(EndX2 + insets.Right));
- pt12.setX (xPos);
- pt22.setX (xPos);
- } while ((EndX2 < maxX) && shape.contains(pf2.map(pt12)) && shape.contains(pf2.map(pt22)));
-
- /*if (EndX!=EndX2)
- {
- qDebug()<<EndX<<EndX2<<StartX<<maxX;
- qDebug()<<"DIFFERING ENDX!!!!!";
- }*/
- return EndX2;
- }
-
-
- double getLineAscent(const StoryText& itemText)
- {
- double result = 0;
- if ((itemText.text(line.firstItem) == SpecialChars::PARSEP) || (itemText.text(line.firstItem) == SpecialChars::LINEBREAK))
- result = itemText.charStyle(line.firstItem).font().ascent(itemText.charStyle(line.firstItem).fontSize() / 10.0);
- else if (itemText.object(line.firstItem) != 0)
- result = qMax(result, (itemText.object(line.firstItem)->gHeight + itemText.object(line.firstItem)->lineWidth()) * (itemText.charStyle(line.firstItem).scaleV() / 1000.0));
- else //if (itemText.charStyle(current.line.firstItem).effects() & ScStyle_DropCap == 0)
- result = itemText.charStyle(line.firstItem).font().realCharAscent(itemText.text(line.firstItem), itemText.charStyle(line.firstItem).fontSize() / 10.0);
- for (int zc = 0; zc < itemsInLine; ++zc)
- {
- QChar ch = itemText.text(line.firstItem + zc);
- if ((ch == SpecialChars::PAGENUMBER) || (ch == SpecialChars::PAGECOUNT))
- ch = '8'; // should have highest ascender even in oldstyle
- const CharStyle& cStyle(itemText.charStyle(line.firstItem + zc));
- if ((ch == SpecialChars::TAB) || (ch == QChar(10))
- || (ch == SpecialChars::PARSEP) || (ch == SpecialChars::NBHYPHEN)
- || (ch == SpecialChars::COLBREAK) || (ch == SpecialChars::LINEBREAK)
- || (ch == SpecialChars::FRAMEBREAK) || (ch.isSpace()))
- continue;
- double asce;
- if (itemText.object(line.firstItem + zc) != 0)
- asce = itemText.object(line.firstItem + zc)->gHeight + itemText.object(line.firstItem + zc)->lineWidth() * (cStyle.scaleV() / 1000.0);
- else //if (itemText.charStyle(current.line.firstItem + zc).effects() & ScStyle_DropCap == 0)
- asce = cStyle.font().realCharAscent(ch, cStyle.fontSize() / 10.0);
- // qDebug() << QString("checking char 'x%2' with ascender %1 > %3").arg(asce).arg(ch.unicode()).arg(result);
- result = qMax(result, asce);
- }
- return result;
- }
-
- double getLineDescent(const StoryText& itemText)
- {
- double result = 0;
- if ((itemText.text(line.firstItem) == SpecialChars::PARSEP) || (itemText.text(line.firstItem) == SpecialChars::LINEBREAK))
- result = itemText.charStyle(line.firstItem).font().descent(itemText.charStyle(line.firstItem).fontSize() / 10.0);
- else if (itemText.object(line.firstItem) != 0)
- result = 0.0;
- else //if (itemText.charStyle(current.line.firstItem).effects() & ScStyle_DropCap == 0)
- result = itemText.charStyle(line.firstItem).font().realCharDescent(itemText.text(line.firstItem), itemText.charStyle(line.firstItem).fontSize() / 10.0);
- for (int zc = 0; zc < itemsInLine; ++zc)
- {
- QChar ch = itemText.text(line.firstItem + zc);
- if ((ch == SpecialChars::PAGENUMBER) || (ch == SpecialChars::PAGECOUNT))
- ch = '8'; // should have highest ascender even in oldstyle
- const CharStyle& cStyle(itemText.charStyle(line.firstItem + zc));
- if ((ch == SpecialChars::TAB) || (ch == QChar(10))
- || (ch == SpecialChars::PARSEP) || (ch == SpecialChars::NBHYPHEN)
- || (ch == SpecialChars::COLBREAK) || (ch == SpecialChars::LINEBREAK)
- || (ch == SpecialChars::FRAMEBREAK) || (ch.isSpace()))
- continue;
- double desc;
- if (itemText.object(line.firstItem + zc) != 0)
- desc = 0.0;
- else //if (itemText.charStyle(current.line.firstItem + zc).effects() & ScStyle_DropCap == 0)
- desc = cStyle.font().realCharDescent(ch, cStyle.fontSize() / 10.0);
- // qDebug() << QString("checking char 'x%2' with ascender %1 > %3").arg(asce).arg(ch.unicode()).arg(result);
- result = qMax(result, desc);
- }
- return result;
- }
-
- double getLineHeight(const StoryText& itemText)
- {
- double result = 0;
- if (itemText.object(line.firstItem) != 0)
- result = qMax(result, (itemText.object(line.firstItem)->gHeight + itemText.object(line.firstItem)->lineWidth()) * (itemText.charStyle(line.firstItem).scaleV() / 1000.0));
- else //if (itemText.charStyle(current.line.firstItem).effects() & ScStyle_DropCap == 0)
- result = itemText.charStyle(line.firstItem).font().height(itemText.charStyle(line.firstItem).fontSize() / 10.0);
- for (int zc = 0; zc < itemsInLine; ++zc)
- {
- QChar ch = itemText.text(line.firstItem+zc);
- if ((ch == SpecialChars::TAB) || (ch == QChar(10))
- || (ch == SpecialChars::PARSEP) || (ch == SpecialChars::NBHYPHEN)
- || (ch == SpecialChars::COLBREAK) || (ch == SpecialChars::FRAMEBREAK)
- || (ch == SpecialChars::LINEBREAK) || (ch.isSpace()))
- continue;
- double asce;
- if (itemText.object(line.firstItem+zc) != 0)
- asce = (itemText.object(line.firstItem+zc)->gHeight + itemText.object(line.firstItem+zc)->lineWidth()) * (itemText.charStyle(line.firstItem+zc).scaleV() / 1000.0);
- else //if (itemText.charStyle(current.line.firstItem+zc).effects() & ScStyle_DropCap == 0)
- asce = itemText.charStyle(line.firstItem+zc).font().height(itemText.charStyle(line.firstItem+zc).fontSize() / 10.0);
- // qDebug() << QString("checking char 'x%2' with ascender %1 > %3").arg(asce).arg(ch.unicode()).arg(result);
- result = qMax(result, asce);
- }
- return result;
- }
-
- void updateHeightMetrics(const StoryText& itemText)
- {
- double asce, desc;
- line.ascent = 0;
- line.descent = 0;
- for (int zc = 0; zc < itemsInLine; ++zc)
- {
- QChar ch = itemText.text(line.firstItem+zc);
- if ((ch == SpecialChars::TAB) || (ch == QChar(10))
- || (ch == SpecialChars::PARSEP) || (ch == SpecialChars::NBHYPHEN)
- || (ch == SpecialChars::COLBREAK) || (ch == SpecialChars::FRAMEBREAK)
- || (ch == SpecialChars::LINEBREAK) || (ch.isSpace()))
- continue;
- const CharStyle& cStyle(itemText.charStyle(line.firstItem + zc));
- if (itemText.object(line.firstItem+zc) != 0)
- {
- asce = (itemText.object(line.firstItem+zc)->gHeight + itemText.object(line.firstItem+zc)->lineWidth()) * (itemText.charStyle(line.firstItem+zc).scaleV() / 1000.0);
- desc = 0.0;
- }
- else //if (itemText.charStyle(current.line.firstItem+zc).effects() & ScStyle_DropCap == 0)
- {
- asce = cStyle.font().realCharAscent(ch, cStyle.fontSize() / 10.0);
- desc = cStyle.font().realCharDescent(ch, cStyle.fontSize() / 10.0);
- }
- // qDebug() << QString("checking char 'x%2' with ascender %1 > %3").arg(asce).arg(ch.unicode()).arg(result);
- line.ascent = qMax(line.ascent, asce);
- line.descent = qMax(line.descent, desc);
- }
- }
-
- void updateLineOffset(const StoryText& itemText, const ParagraphStyle& style, FirstLineOffsetPolicy offsetPolicy)
- {
- if (itemsInLine <= 0)
- return;
- if ((!hasDropCap) && (startOfCol) && (style.lineSpacingMode() != ParagraphStyle::BaselineGridLineSpacing))
- {
- //FIXME: use glyphs, not chars
- double firstasce = itemText.charStyle(line.firstItem).font().ascent(itemText.charStyle(line.firstItem).fontSize() / 10.0);
- double adj (0.0);
- double currasce (this->getLineAscent(itemText));
- if( offsetPolicy == FLOPRealGlyphHeight )
- {
- adj = firstasce - currasce;
- }
- else if( offsetPolicy == FLOPFontAscent )
- {
- adj = 0.0;
- }
- else if( offsetPolicy == FLOPLineSpacing )
- {
- adj = firstasce - style.lineSpacing();
- }
- line.ascent = currasce;
- line.y -= adj;
- yPos -= adj;
- }
- else if ((!startOfCol) && (style.lineSpacingMode() == ParagraphStyle::AutomaticLineSpacing))
- {
- QChar ch = itemText.text(line.firstItem);
- double firstasce = style.lineSpacing();
- double currasce = getLineHeight(itemText);
- double adj = firstasce - currasce;
-// qDebug() << QString("move2 line %1.. down by %2").arg(current.line.firstItem).arg(-adj);
- line.ascent = currasce;
- line.y -= adj;
- yPos -= adj;
- }
- }
-
-private:
- double frameWidth;
- double frameHeight;
- MarginStruct insets;
- double lineCorr;
-};
-
-
-
-/// called when line length is known and line is to be justified
-static void justifyLine(StoryText& itemText, LineSpec& line)
-{
-
- double glyphNatural = 0;
- double spaceNatural = 0;
- double glyphExtension;
- double spaceExtension;
-
- const ParagraphStyle& style(itemText.paragraphStyle(line.firstItem));
-
- // measure natural widths for glyphs and spaces
- for (int sof = line.firstItem; sof <= line.lastItem; ++sof)
- {
- if (!SpecialChars::isExpandingSpace(itemText.text(sof)))
- {
- glyphNatural += itemText.item(sof)->glyph.wide();
- }
- else if ( (itemText.item(sof)->effects() & ScStyle_SuppressSpace) == 0)
- {
- spaceNatural += itemText.item(sof)->glyph.wide();
- }
- }
-
- // decision: prio 1: stretch glyph; prio 2: stretch spaces
-
- if (line.width < spaceNatural + glyphNatural * style.minGlyphExtension() && spaceNatural > 0)
- {
- glyphExtension = style.minGlyphExtension() - 1;
- spaceExtension = (line.width - glyphNatural * (1+glyphExtension) ) / spaceNatural - 1;
- }
- else if (line.width < spaceNatural + glyphNatural * style.maxGlyphExtension() && glyphNatural > 0)
- {
- spaceExtension = 0;
- glyphExtension = (line.width - spaceNatural) / glyphNatural - 1;
- }
- else
- {
- glyphExtension = style.maxGlyphExtension() - 1;
- if (spaceNatural > 0)
- spaceExtension = (line.width - glyphNatural * (1+glyphExtension) ) / spaceNatural - 1;
- else
- spaceExtension = 0;
- }
-
- double glyphScale = 1 + glyphExtension;
-
-/*
- qDebug() << QString("justify: line = %7 natural = %1 + %2 = %3 (%4); spaces + %5%%; min=%8; glyphs + %6%%; min=%9")
- .arg(spaceNatural).arg(glyphNatural).arg(spaceNatural+glyphNatural).arg(line.naturalWidth)
- .arg(spaceExtension).arg(glyphExtension).arg(line.width)
- .arg(style.minWordTracking()).arg(style.minGlyphExtension());
- */
-
- // distribute whitespace on spaces and glyphs
- for (int yof = line.firstItem; yof <= line.lastItem; ++yof)
- {
- double wide = itemText.item(yof)->glyph.wide();
- if (!SpecialChars::isExpandingSpace(itemText.text(yof)))
- {
- itemText.item(yof)->glyph.last()->xadvance += wide * glyphExtension;
- GlyphLayout* glyph = &(itemText.item(yof)->glyph);
- while (glyph)
- {
- glyph->xoffset *= glyphScale;
- glyph->scaleH *= glyphScale;
- glyph = glyph->more;
- }
- }
- else if ((itemText.item(yof)->effects() & ScStyle_SuppressSpace) == 0)
- {
- itemText.item(yof)->glyph.last()->xadvance += wide * spaceExtension;
- }
- }
-}
-
-
-/// called when linelength is known and line is not justified
-static void indentLine(StoryText& itemText, LineSpec& line, double leftIndent)
-{
- if (line.naturalWidth > line.width)
- {
- justifyLine(itemText, line);
- }
- if (leftIndent > 0)
- {
- line.x += leftIndent;
- line.width -= leftIndent;
- }
-}
-
-/// calculate how much the first char should stick out to the left
-static double opticalLeftMargin(const StoryText& itemText, const LineSpec& line)
-{
- int b = line.firstItem;
- while (b < line.lastItem && (itemText.item(b)->effects() & ScStyle_SuppressSpace))
- ++b;
-
- double chs = itemText.charStyle(b).fontSize() * (itemText.charStyle(b).scaleH() / 1000.0);
- QChar chr = itemText.text(b);
- double leftCorr = itemText.charStyle(b).font().realCharWidth(chr, chs / 10.0);
- if (QString("'´`").indexOf(chr) >= 0
- || chr == QChar(0x2018) // quote 6
- || chr == QChar(0x2019) // quote 9
- || chr == QChar(0x201a) // lower quote 9
- || chr == QChar(0x201b) // upper reversed 9 6
- || chr == QChar(0x2039) // single guillemet <
- || chr == QChar(0x203a) // single guillemet >
- )
- leftCorr *= -0.7;
- else if (QString("\"").indexOf(chr) >= 0
- || chr == QChar(0x00ab) // guillemet <<
- || chr == QChar(0x00bb) // guillemet >>
- || chr == QChar(0x201c) // quote 66
- || chr == QChar(0x201d) // quote 99
- || chr == QChar(0x201e) // lower quote 99
- || chr == QChar(0x201f) // upper reversed 99
- )
- leftCorr *= -0.5;
- else {
- leftCorr = itemText.charStyle(b).font().charWidth(QChar(' '), chs / 10.0, chr);
- leftCorr -= itemText.charStyle(b).font().charWidth(QChar(' '), chs / 10.0);
-// double leftCorr2 = itemText.charStyle(a).font().charWidth(QChar('K'), chs / 10.0, chr);
-// leftCorr2 -= itemText.charStyle(a).font().charWidth(QChar('K'), chs / 10.0);
-// leftCorr = qMin(leftCorr, leftCorr2);
- }
- return leftCorr;
-}
-
-
-
-/// calculate how much the last char should stick out to the right
-static double opticalRightMargin(const StoryText& itemText, const LineSpec& line)
-{
- int b = line.lastItem;
- while (b > line.firstItem &&
- (SpecialChars::isBreakingSpace(itemText.text(b)) || SpecialChars::isBreak(itemText.text(b)))
- )
- --b;
- if (b >= line.firstItem)
- {
- double chs = itemText.charStyle(b).fontSize() * (itemText.charStyle(b).scaleH() / 1000.0);
- QChar chr = (itemText.item(b)->effects() & ScStyle_SoftHyphenVisible) ?
- QChar('-') : itemText.text(b);
- double rightCorr = itemText.charStyle(b).font().realCharWidth(chr, chs / 10.0);
- if (QString("-,.`´'~").indexOf(chr) >= 0
- || chr == QChar(0x2018)
- || chr == QChar(0x2019)
- || chr == QChar(0x201a)
- || chr == QChar(0x201b)
- || chr == QChar(0x2039)
- || chr == QChar(0x203a)
- || chr == QChar(0x2032) // PRIME
- )
- rightCorr *= 0.7;
- else if (QString(";:\"").indexOf(chr) >= 0
- || chr == QChar(0x00ab)
- || chr == QChar(0x00bb)
- || chr == QChar(0x201c)
- || chr == QChar(0x201d)
- || chr == QChar(0x201e)
- || chr == QChar(0x201f)
- || chr == QChar(0x2013) // EN DASH
- || chr == QChar(0x2033) // double prime
- )
- rightCorr *= 0.5;
- else {
- rightCorr = itemText.charStyle(b).font().charWidth(chr, chs / 10.0);
- rightCorr -= itemText.charStyle(b).font().charWidth(chr, chs / 10.0, QChar('.'));
- }
- return rightCorr;
- }
- return 0.0;
-}
-
-
-
-
-
-void PageItem_TextFrame::layout()
-{
-// qDebug()<<"==Layout==" << itemName() ;
-// printBacktrace(24);
- if (BackBox != NULL && BackBox->invalid) {
-// qDebug("textframe: len=%d, going back", itemText.length());
- invalid = false;
- PageItem_TextFrame* prevInChain = dynamic_cast<PageItem_TextFrame*>(BackBox);
- if (!prevInChain)
- qDebug() << QString("layout(): backBox=%1 is no textframe!!").arg((ulong)BackBox);
- else
- BackBox->layout();
- return;
- }
- else if (!invalid && OnMasterPage.isEmpty()) {
-// qDebug() << QString("textframe: len=%1, invalid=%2 OnMasterPage=%3: no relayout").arg(itemText.length()).arg(invalid).arg(OnMasterPage);
- return;
- }
- if (invalid && BackBox == NULL)
- firstChar = 0;
-
-// qDebug() << QString("textframe(%1,%2): len=%3, start relayout at %4").arg(Xpos).arg(Ypos).arg(itemText.length()).arg(firstInFrame());
-// ScribusView* view = m_Doc->view();
- QTransform pf2;
- QPoint pt1, pt2;
- /*QRegion cm;*/
- double chs, chsd = 0;
- double oldCurY, EndX, OFs, wide, kernVal;
- QString chstr;
- ScText *hl;
- ParagraphStyle style;
- int /*ParagraphStyle::OpticalMarginType*/ opticalMargins = ParagraphStyle::OM_None;
-
- bool outs = false;
- bool fBorder = false;
- bool goNoRoom = false;
- bool goNextColumn = false;
-
- TabControl tabs;
- tabs.active = false; // RTab
- tabs.status = TabNONE; // TabCode
- tabs.charIndex = -1; // StartRT
- tabs.xPos = 0; // RTabX
-
- QList<ParagraphStyle::TabRecord> tTabValues;
- tTabValues.clear();
-
- bool DropCmode = false;
- double desc=0, asce=0, maxDY=0, desc2=0, maxDX=0;
- double DropCapDrop = 0;
- int DropLines = 0;
- int DropLinesCount = 0;
-
-
- itemText.clearLines();
-
- double lineCorr = 0;
- if (lineColor() != CommonStrings::None)
- lineCorr = m_lineWidth / 2.0;
-
- // TODO: refactor this into PageItem
- MarginStruct extra;
- extra.Top = TExtra;
- extra.Left = Extra;
- extra.Right = RExtra;
- extra.Bottom = BExtra;
-
- LineControl current;
- current.init(Width, Height, extra, lineCorr);
- current.initColumns(columnWidth(), ColGap);
- current.hyphenCount = 0;
-
- // dump styles
-/*
- for (int i=0; i < itemText.nrOfParagraphs(); ++i) {
- const ParagraphStyle& pstyle(itemText.paragraphStyle(itemText.endOfParagraph(i)));
- qDebug("par %d:", i);
- dumpIt(pstyle);
- }
- qDebug() << "default:";
- dumpIt(itemText.defaultStyle());
-*/
-
-// pf2.begin(view->viewport());
- pf2.translate(Xpos, Ypos);
- pf2.rotate(Rot);
-
- setShadow();
- if ((itemText.length() != 0)) // || (NextBox != 0))
- {
- // determine layout area
- QRegion cl = availableRegion(QRegion(pf2.map(Clip)));
- if (cl.isEmpty())
- {
- MaxChars = firstInFrame();
- goto NoRoom;
- }
-
- if (imageFlippedH())
- {
- pf2.translate(Width, 0);
- pf2.scale(-1, 1);
- }
- if (imageFlippedV())
- {
- pf2.translate(0, Height);
- pf2.scale(1, -1);
- }
-
- current.nextColumn(0);
-
- // find start of first line
- if (firstInFrame() < itemText.length())
- {
- hl = itemText.item(firstInFrame());
- style = itemText.paragraphStyle(firstInFrame());
- if (style.lineSpacingMode() == ParagraphStyle::AutomaticLineSpacing)
- {
- style.setLineSpacing(style.charStyle().font().height(style.charStyle().fontSize() / 10.0));
-// qDebug() << QString("auto linespacing: %1").arg(style.lineSpacing());
- }
- else if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- style.setLineSpacing(m_Doc->guidesPrefs().valueBaselineGrid);
-
-// qDebug() << QString("style @0: %1 -- %2, %4/%5 char: %3").arg(style.leftMargin()).arg(style.rightMargin())
-// .arg(style.charStyle().asString()).arg(style.name()).arg(style.parent()?style.parent()->name():"");
- if (style.hasDropCap())
- {
- if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- chs = qRound(m_Doc->guidesPrefs().valueBaselineGrid * style.dropCapLines() * 10);
- else
- chs = qRound(style.lineSpacing() * style.dropCapLines() * 10);
- }
- else
- chs = hl->fontSize();
- desc2 = -hl->font().descent(chs / 10.0);
- current.yPos = extra.Top + lineCorr;
-// qDebug() << QString("first line at y=%1").arg(current.yPos);
- }
- else // empty itemText:
- {
- desc2 = -itemText.defaultStyle().charStyle().font().descent(itemText.defaultStyle().charStyle().fontSize() / 10.0);
- current.yPos = itemText.defaultStyle().lineSpacing() + extra.Top+lineCorr-desc2;
- }
- current.startLine(firstInFrame());
- outs = false;
- OFs = 0;
- MaxChars = 0;
- for (int a = firstInFrame(); a < itemText.length(); ++a)
- {
- hl = itemText.item(a);
- if (a > 0 && itemText.text(a-1) == SpecialChars::PARSEP)
- style = itemText.paragraphStyle(a);
- if (current.itemsInLine == 0)
- opticalMargins = style.opticalMargins();
-
-// qDebug() << QString("style pos %1: %2 (%3)").arg(a).arg(style.alignment()).arg(style.parent());
- const CharStyle& charStyle = (hl->ch != SpecialChars::PARSEP? itemText.charStyle(a) : itemText.paragraphStyle(a).charStyle());
- if (!charStyle.parent().isEmpty())
- {
-// qDebug() << QString("charstyle pos %1: %2 (%3 %4 %5 %6 %7 %8 %9)").arg(a).arg(charStyle.parent())
-// .arg((uint)charStyle.parentStyle()).arg(charStyle.font().scName()).arg(charStyle.fontSize())
-// .arg(charStyle.fillColor()).arg(charStyle.strokeColor()).arg(charStyle.parentStyle()->name()).arg((uint)charStyle.parentStyle()->parentStyle());
- }
-// qDebug() << QString("charstyle pos %1: %2 (%3)").arg(a).arg(charStyle.asString()).arg(charStyle.fontSize());
-// qDebug() << QString("style @%6: %1 -- %2, %4/%5 char: %3").arg(style.leftMargin()).arg(style.rightMargin())
-// .arg(style.charStyle().asString()).arg(style.name()).arg(style.parent())
-// .arg(a);
-
- chstr = ExpandToken(a);
- if (chstr.isEmpty())
- chstr = SpecialChars::ZWNBSPACE;
- if (style.lineSpacingMode() == ParagraphStyle::AutomaticLineSpacing)
- {
- style.setLineSpacing(style.charStyle().font().height(style.charStyle().fontSize() / 10.0));
- }
- else if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- style.setLineSpacing(m_Doc->guidesPrefs().valueBaselineGrid);
- // find out about par gap and dropcap
- if (a == firstInFrame())
- {
- if (a == 0 || itemText.text(a-1) == SpecialChars::PARSEP)
- {
- current.yPos += style.gapBefore();
- if (chstr[0] != SpecialChars::PARSEP)
- {
- DropCmode = style.hasDropCap();
- if (DropCmode)
- DropLines = style.dropCapLines();
- }
- else
- DropCmode = false;
- }
- }
-
- { // local block for 'fl'
- StyleFlag fl = hl->effects();
- fl &= ~ScStyle_DropCap;
- fl &= ~ScStyle_SoftHyphenVisible;
- hl->setEffects(fl);
- }
-
- // No space at begin of line,
- if (legacy)
- {
- // unless at begin of par (eeks)
- if ( (current.itemsInLine == 0) && (SpecialChars::isBreakingSpace(hl->ch))
- && (a > 0 && ! SpecialChars::isBreak(itemText.text(a-1)))
- && ! (a > 0 && SpecialChars::isBreakingSpace(itemText.text(a-1))
- && (itemText.charStyle(a-1).effects() & ScStyle_SuppressSpace) != ScStyle_SuppressSpace))
- {
- hl->setEffects(hl->effects() | ScStyle_SuppressSpace);
- hl->glyph.xadvance = 0;
- continue;
- }
- else
- hl->setEffects(hl->effects() & ~ScStyle_SuppressSpace);
- }
- else // from 134 on use NBSPACE for this effect
- {
- if ( current.itemsInLine == 0 && (SpecialChars::isBreakingSpace(hl->ch) || hl->ch.isSpace()))
- {
- hl->setEffects(hl->effects() | ScStyle_SuppressSpace);
- hl->glyph.xadvance = 0;
- continue;
- }
- else
- hl->setEffects(hl->effects() & ~ScStyle_SuppressSpace);
- }
- // qDebug() << QString("textframe(%1,%2): len=%3, fontsize=%4, ascent=%5").arg(Xpos).arg(Ypos).arg(itemText.length())
-// .arg(charStyle.fontSize()).arg(charStyle.font().ascent());
- if (current.itemsInLine == 0)
- {
- // more about par gap and dropcaps
- if ((a > firstInFrame() && itemText.text(a-1) == SpecialChars::PARSEP) || (a == 0 && BackBox == 0 && !current.startOfCol)) // after || always evaluates to false? FIXME
- {
-// qDebug() << QString("gap before2: y=%1+%2").arg(current.yPos).arg(style.gapBefore());
- current.yPos += style.gapBefore();
- DropCapDrop = 0;
- if (chstr[0] != SpecialChars::PARSEP)
- DropCmode = style.hasDropCap();
- else
- DropCmode = false;
- if (DropCmode)
- {
- DropLines = style.dropCapLines();
- if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- DropCapDrop = m_Doc->guidesPrefs().valueBaselineGrid * (DropLines-1);
- else
- {
- if (style.lineSpacingMode() == ParagraphStyle::FixedLineSpacing)
- DropCapDrop = style.lineSpacing() * (DropLines-1);
- else
- DropCapDrop = charStyle.font().height(style.charStyle().fontSize() / 10.0) * (DropLines-1);
- }
-// qDebug() << QString("dropcapdrop: y=%1+%2").arg(current.yPos).arg(DropCapDrop);
- current.yPos += DropCapDrop;
- }
- }
- }
- // find charsize & y pos
- if (DropCmode)
- {
- // dropcap active?
- if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- DropCapDrop = m_Doc->guidesPrefs().valueBaselineGrid * (DropLines-1);
- else
- {
- if (style.lineSpacingMode() == ParagraphStyle::FixedLineSpacing)
- DropCapDrop = style.lineSpacing() * (DropLines-1);
- else
- DropCapDrop = charStyle.font().height(style.charStyle().fontSize() / 10.0) * (DropLines-1);
- }
-
- // FIXME : we should ensure that fonts are loaded before calls to layout()
- // ScFace::realCharHeight()/Ascent() ensure font is loaded thanks to an indirect call to char2CMap()
- // ScFace::ascent() can be called safely afterwards
- double realCharHeight = charStyle.font().realCharHeight(chstr[0], 1);
- double realCharAscent = charStyle.font().realCharAscent(chstr[0], 1);
- double fontAscent = charStyle.font().ascent(style.charStyle().fontSize() / 10.0);
- if (realCharHeight == 0.0)
- realCharHeight = charStyle.font().height(style.charStyle().fontSize() / 10.0);
- if (realCharAscent == 0.0)
- realCharAscent = fontAscent;
- if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- {
- chsd = (10 * ((m_Doc->guidesPrefs().valueBaselineGrid * (DropLines-1) + fontAscent) / realCharHeight));
- chs = (10 * ((m_Doc->guidesPrefs().valueBaselineGrid * (DropLines-1) + fontAscent) / realCharAscent));
- }
- else
- {
- if (style.lineSpacingMode() == ParagraphStyle::FixedLineSpacing)
- {
- chsd = (10 * ((style.lineSpacing() * (DropLines-1) + fontAscent) / realCharHeight));
- chs = (10 * ((style.lineSpacing() * (DropLines-1) + fontAscent) / realCharAscent));
- }
- else
- {
- double currasce = charStyle.font().height(style.charStyle().fontSize() / 10.0);
- chsd = (10 * ((currasce * (DropLines-1) + fontAscent) / realCharHeight));
- chs = (10 * ((currasce * (DropLines-1) + fontAscent) / realCharAscent));
- }
- }
- hl->setEffects(hl->effects() | ScStyle_DropCap);
- hl->glyph.yoffset -= DropCapDrop;
- }
- else // ! dropCapMode
- {
- if ((hl->ch == SpecialChars::OBJECT) && (hl->embedded.hasItem()))
- chs = qRound((hl->embedded.getItem()->gHeight + hl->embedded.getItem()->lineWidth()) * 10);
- else
- chs = charStyle.fontSize();
- }
- // find tracking
- if (current.itemsInLine == 0)
- {
- itemText.item(a)->setEffects(itemText.item(a)->effects() | ScStyle_StartOfLine);
- kernVal = 0;
- }
- else
- {
- kernVal = 0; // chs * charStyle.tracking() / 10000.0;
- itemText.item(a)->setEffects(itemText.item(a)->effects() & ~ScStyle_StartOfLine);
- }
- hl->glyph.yadvance = 0;
- oldCurY = layoutGlyphs(*hl, chstr, hl->glyph);
- // find out width of char
- if ((hl->ch == SpecialChars::OBJECT) && (hl->embedded.hasItem()))
- {
- wide = hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth();
- hl->glyph.xadvance = wide * hl->glyph.scaleH;
- }
- else
- {
- wide = hl->glyph.wide();
- // apply kerning
- if (a+1 < itemText.length())
- {
- uint glyph2 = charStyle.font().char2CMap(itemText.text(a+1));
- double kern= charStyle.font().glyphKerning(hl->glyph.glyph, glyph2, chs / 10.0) * hl->glyph.scaleH;
- wide += kern;
- hl->glyph.xadvance += kern;
- }
- }
- if (DropCmode)
- {
- // drop caps are wider...
- if ((hl->ch == SpecialChars::OBJECT) && (hl->embedded.hasItem()))
- {
- double itemHeight = hl->embedded.getItem()->gHeight + hl->embedded.getItem()->lineWidth();
- if (itemHeight == 0)
- itemHeight = charStyle.font().height(style.charStyle().fontSize() / 10.0);
- wide = hl->embedded.getItem()->gWidth + hl->embedded.getItem()->lineWidth();
- if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- asce = m_Doc->guidesPrefs().valueBaselineGrid * DropLines;
- else
- {
- if (style.lineSpacingMode() == ParagraphStyle::FixedLineSpacing)
- asce = style.lineSpacing() * DropLines;
- else
- asce = charStyle.font().height(style.charStyle().fontSize() / 10.0) * DropLines;
- }
- hl->glyph.scaleH /= hl->glyph.scaleV;
- hl->glyph.scaleV = (asce / itemHeight);
- hl->glyph.scaleH *= hl->glyph.scaleV;
- }
- else
- {
- double realCharHeight = charStyle.font().realCharHeight(chstr[0], charStyle.fontSize() / 10.0);
- if (realCharHeight == 0)
- realCharHeight = charStyle.font().height(style.charStyle().fontSize() / 10.0);
- wide = charStyle.font().realCharWidth(chstr[0], chsd / 10.0);
- asce = charStyle.font().realCharHeight(chstr[0], chsd / 10.0);
-// qDebug() QString("dropcaps pre: chsd=%1 realCharHeight = %2 chstr=%3").arg(chsd).arg(asce).arg(chstr2[0]);
- hl->glyph.scaleH /= hl->glyph.scaleV;
- hl->glyph.scaleV = (asce / realCharHeight);
- hl->glyph.scaleH *= hl->glyph.scaleV;
- }
- hl->glyph.xadvance = wide;
- desc2 = 0;
- desc = 0;
- }
- else // !DropCMode
- {
-// qDebug( ) << QString("textframe ascent/descent: fontsize=%1, ascent=%2, descent=%3")
-// .arg(charStyle.fontSize()).arg(charStyle.font().ascent()).arg(charStyle.font().descent());
-
- if (SpecialChars::isExpandingSpace(hl->ch))
- {
- double wordtracking = charStyle.wordTracking();
- hl->glyph.xadvance *= wordtracking;
- wide *= wordtracking;
- }
-
- // find ascent / descent
- double hlcsize10=charStyle.fontSize() / 10.0;
- if ((hl->ch == SpecialChars::OBJECT) && (hl->embedded.hasItem()))
- {
- desc = desc2 = 0;
- }
- else
- {
- desc = desc2 = -charStyle.font().descent(hlcsize10);
- current.rememberShrinkStretch(hl->ch, wide, style);
- }
- asce = charStyle.font().ascent(hlcsize10);
-// wide = wide * hl->glyph.scaleH;
- }
- fBorder = false;
- // end of col reached?
-// qDebug() << QString("eocol? %1 + %2 + %3 > %4 -- asce=%5").arg(current.yPos).arg(extra.Bottom).arg(lineCorr).arg(Height).arg(asce);
- if (current.isEndOfCol())
- {
- current.column++;
- if (current.column < Cols)
- {
- // start next col
- current.nextColumn(asce);
- if (((a > firstInFrame()) && (itemText.text(a-1) == SpecialChars::PARSEP))
- || ((a == firstInFrame()) && (BackBox == 0)))
- {
- if (chstr[0] != SpecialChars::PARSEP)
- DropCmode = style.hasDropCap();
- else
- DropCmode = false;
- if (DropCmode)
- {
- if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- desc2 = -charStyle.font().descent() * m_Doc->guidesPrefs().valueBaselineGrid * style.dropCapLines();
- else
- desc2 = -charStyle.font().descent() * style.lineSpacing() * style.dropCapLines();
- }
- if (DropCmode)
- DropLines = style.dropCapLines();
- }
-// qDebug() << QString("layout: nextcol grid=%1 x %2").arg(style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing).arg(m_Doc->typographicSettings.valueBaseGrid);
- if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- {
- double by = Ypos;
- if (OwnPage != -1)
- by = Ypos - m_Doc->Pages->at(OwnPage)->yOffset();
- int ol1 = qRound((by + current.yPos - m_Doc->guidesPrefs().offsetBaselineGrid) * 10000.0);
- int ol2 = static_cast<int>(ol1 / m_Doc->guidesPrefs().valueBaselineGrid);
-// qDebug() << QString("baseline adjust: y=%1->%2").arg(current.yPos).arg(ceil( ol2 / 10000.0 ) * m_Doc->typographicSettings.valueBaselineGrid + m_Doc->typographicSettings.offsetBaselineGrid - by);
-
- current.yPos = ceil( ol2 / 10000.0 ) * m_Doc->guidesPrefs().valueBaselineGrid + m_Doc->guidesPrefs().offsetBaselineGrid - by;
- }
- }
- else
- {
- MaxChars = a;
-// qDebug() << QString("no room A: %1").arg(a);
- goto NoRoom;
- }
- }
- // ok, there's more room in col
- if (current.itemsInLine == 0)
- {
-// qDebug() << QString("newline: '%1' %2 %3").arg(a).arg(current.yPos).arg(asce);
- // start a new line
- double TopOffset = asce;
- double BotOffset = desc2;
- goNoRoom = false;
- if (current.startOfCol)
- {
-// qDebug() << QString("current.startOfCol: %1 + %2 + %3 + 1 =%4").arg(asce).arg(extra.Top).arg(lineCorr).arg(asce + extra.Top + lineCorr + 1);
- current.yPos = asce + extra.Top + lineCorr + 1;
-// if (((a > 0) && (itemText.at(a-1)->ch == QChar(13))) || ((a == 0) && (BackBox == 0)))
-// current.yPos += m_Doc->docParagraphStyles[hl->cab].gapBefore;
- }
-// qDebug() << QString("layout: nextline grid=%1 x %2").arg(style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing).arg(m_Doc->typographicSettings.valueBaselineGrid);
- if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- {
- double by = Ypos;
- if (OwnPage != -1)
- by = Ypos - m_Doc->Pages->at(OwnPage)->yOffset();
- int ol1 = qRound((by + current.yPos - m_Doc->guidesPrefs().offsetBaselineGrid) * 10000.0);
- int ol2 = static_cast<int>(ol1 / m_Doc->guidesPrefs().valueBaselineGrid);
-// qDebug() << QString("useBaselIneGrid: %1 * %2 + %3 - %4").arg(ol2 / 10000.0).arg(m_Doc->typographicSettings.valueBaselineGrid).arg(m_Doc->typographicSettings.offsetBaselineGrid).arg(by);
-// qDebug() << QString("baseline adjust: y=%1->%2").arg(current.yPos).arg(ceil( ol2 / 10000.0 ) * m_Doc->typographicSettings.valueBaselineGrid + m_Doc->typographicSettings.offsetBaselineGrid - by);
- current.yPos = ceil( ol2 / 10000.0 ) * m_Doc->guidesPrefs().valueBaselineGrid + m_Doc->guidesPrefs().offsetBaselineGrid - by;
- }
- /* this causes different spacing for first line:
- if (current.yPos-TopOffset < 0.0)
- {
- qDebug(= << QString("current.yPos - Ascender < 0 (%1 - %2 < 0)").arg(current.yPos).arg(TopOffset);
- current.yPos = TopOffset+1;
- }
- */
- // find linelength:
- pt1 = QPoint(static_cast<int>(ceil(current.xPos)), static_cast<int>(current.yPos+BotOffset));
- pt2 = QPoint(static_cast<int>(ceil(current.xPos)), static_cast<int>(ceil(current.yPos-TopOffset)));
- // increase pt1/pt2 until i-beam reaches end of line
-// qDebug() << QString("linestart: %1 + %2 + %3 < %4").arg(current.xPos).arg(wide).arg(style.rightMargin()).arg(current.colRight);
- double leftIndent = 0;
- double xStep = legacy? 1 : 0.125;
- while (!cl.contains(pf2.map(pt1)) || !cl.contains(pf2.map(pt2)) || current.isEndOfLine(wide + leftIndent + style.rightMargin()))
- {
- fBorder = true;
- current.xPos += xStep;
- if (current.isEndOfLine(wide + leftIndent + style.rightMargin()))
- {
-// qDebug() << QString("eocol %5? %1 + %2 + %3 + %4").arg(current.yPos).arg(current.startOfCol).arg(style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing).arg(style.lineSpacing()).arg(current.column);
- // new line
- fBorder = false;
- current.xPos = current.colLeft;
-
- leftIndent = style.leftMargin();
- if (a > 0 && itemText.text(a-1) == SpecialChars::PARSEP)
- leftIndent += style.firstIndent();
-
- if (current.startOfCol)
- current.yPos++;
- else
- current.yPos += qMax(style.lineSpacing(), 1.0);
-// qDebug() << QString("layout: next lower line grid=%1 x %2").arg(style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing).arg(m_Doc->typographicSettings.valueBaselineGrid);
- if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- {
- double by = Ypos;
- if (OwnPage != -1)
- by = Ypos - m_Doc->Pages->at(OwnPage)->yOffset();
- int ol1 = qRound((by + current.yPos - m_Doc->guidesPrefs().offsetBaselineGrid) * 10000.0);
- int ol2 = static_cast<int>(ol1 / m_Doc->guidesPrefs().valueBaselineGrid);
-// qDebug() << QString("baseline adjust: y=%1->%2").arg(current.yPos).arg(ceil( ol2 / 10000.0 ) * m_Doc->typographicSettings.valueBaselineGrid + m_Doc->typographicSettings.offsetBaselineGrid - by);
- current.yPos = ceil( ol2 / 10000.0 ) * m_Doc->guidesPrefs().valueBaselineGrid + m_Doc->guidesPrefs().offsetBaselineGrid - by;
- }
- if (current.isEndOfCol())
- {
- fBorder = false;
- current.column++;
- if (current.column < Cols)
- {
- current.nextColumn(asce);
- if (((a > firstInFrame()) && (itemText.text(a-1) == SpecialChars::PARSEP)) || ((a == firstInFrame()) && (BackBox == 0)))
- {
- if (chstr[0] != SpecialChars::PARSEP)
- DropCmode = style.hasDropCap();
- else
- DropCmode = false;
- if (DropCmode)
- {
- if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- desc2 = -charStyle.font().descent() * m_Doc->guidesPrefs().valueBaselineGrid * style.dropCapLines();
- else
- desc2 = -charStyle.font().descent() * style.lineSpacing() * style.dropCapLines();
- }
- if (DropCmode)
- DropLines = style.dropCapLines();
- }
-// qDebug() << QString("layout: nextcol2 grid=%1 x %2").arg(style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing).arg(m_Doc->guideSettings.valueBaselineGrid);
- if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- {
- double by = Ypos;
- if (OwnPage != -1)
- by = Ypos - m_Doc->Pages->at(OwnPage)->yOffset();
- int ol1 = qRound((by + current.yPos - m_Doc->guidesPrefs().offsetBaselineGrid) * 10000.0);
- int ol2 = static_cast<int>(ol1 / m_Doc->guidesPrefs().valueBaselineGrid);
-// qDebug() << QString("baseline adjust: y=%1->%2").arg(current.yPos).arg(ceil( ol2 / 10000.0 ) * m_Doc->guideSettings.valueBaseGrid + m_Doc->typographicSettings.offsetBaselineGrid - by);
- current.yPos = ceil( ol2 / 10000.0 ) * m_Doc->guidesPrefs().valueBaselineGrid + m_Doc->guidesPrefs().offsetBaselineGrid - by;
- }
- }
- else
- {
- MaxChars = a;
-// qDebug() << QString("no room B: %1").arg(a);
- goto NoRoom;
- }
- }
- }
- pt1 = QPoint(static_cast<int>(ceil(current.xPos)), static_cast<int>(current.yPos+BotOffset));
- pt2 = QPoint(static_cast<int>(ceil(current.xPos)), static_cast<int>(ceil(current.yPos-TopOffset)));
- }
-
- if (((fBorder)) && (!current.hasDropCap))
- current.xPos += extra.Left;
- // indent first line of par
- if (a > 0)
- {
- if (itemText.text(a-1) == SpecialChars::PARSEP)
- current.xPos += style.firstIndent();
- }
- else
- {
- if (legacy)
- current.xPos += style.firstIndent();
- }
- // add left margin
- if (!current.hasDropCap)
- current.xPos += style.leftMargin();
- if (opticalMargins & ParagraphStyle::OM_LeftHangingPunct) {
- current.xPos += opticalLeftMargin(itemText, current.line);
- }
-// qDebug() << QString("store line: (%1,%2)").arg(current.xPos).arg(current.yPos);
- current.line.x = current.xPos;
- current.line.y = current.yPos;
- fBorder = false;
- }
- else {
-// qDebug() << QString("cont.' line: '%1'").arg(a);
- }
- // right tab stuff
- if (tabs.active)
- {
- if (((hl->ch == '.') && (tabs.status == TabPOINT)) || ((hl->ch == ',') && (tabs.status == TabCOMMA)) || (hl->ch == SpecialChars::TAB))
- {
- tabs.active = false;
- tabs.status = TabNONE;
- }
- }
- // tab positioning
- if (hl->ch == SpecialChars::TAB)
- {
- wide = 1;
- if (tabs.active)
- tabs.active = false;
- else // ???
- {
- tabs.xPos = current.xPos;
- tTabValues = style.tabValues();
- if (tTabValues.isEmpty())
- {
- double dtw=m_Doc->itemToolPrefs().textTabWidth;
- if ((current.xPos - current.colLeft) != 0)
- {
- if (current.xPos == current.colLeft + ceil((current.xPos-current.colLeft) / dtw) * dtw)
- current.xPos += dtw;
- else
- current.xPos = current.colLeft + ceil((current.xPos-current.colLeft) / dtw) * dtw;
- }
- else
- current.xPos = current.colLeft + dtw;
- tabs.status = TabNONE;
- tabs.active = false;
- }
- else
- {
- double tCurX = current.xPos - current.colLeft;
- double oCurX = tCurX + wide;
- for (int yg = static_cast<int>(tTabValues.count()-1); yg > -1; yg--)
- {
- if (oCurX < tTabValues.at(yg).tabPosition)
- {
- tabs.status = static_cast<int>(tTabValues.at(yg).tabType);
- tCurX = tTabValues.at(yg).tabPosition;
- tabs.fillChar = tTabValues.at(yg).tabFillChar;
- }
- }
- tabs.active = (tabs.status != TabLEFT);
- if (tCurX == oCurX-wide)
- current.xPos = current.colLeft + ceil((current.xPos-current.colLeft) / m_Doc->itemToolPrefs().textTabWidth) * m_Doc->itemToolPrefs().textTabWidth;
- else
- current.xPos = current.colLeft + tCurX;
-
- // remember fill char
-// qDebug() << QString("tab: %1 '%2'").arg(tCurX).arg(tabs.fillChar);
- if (!tabs.fillChar.isNull()) {
- hl->glyph.growWithTabLayout();
- TabLayout * tglyph = dynamic_cast<TabLayout*>(hl->glyph.more);
- if (tglyph)
- {
- tglyph->fillChar = tabs.fillChar;
- tglyph->glyph = charStyle.font().char2CMap(tabs.fillChar);
- tglyph->yoffset = hl->glyph.yoffset;
- tglyph->scaleV = tglyph->scaleH = chs / charStyle.fontSize();
- tglyph->xadvance = 0;
- }
- }
- }
- current.xPos -= (legacy ? 1.0 : 0.0);
- hl->glyph.xadvance = current.xPos + wide + kernVal - tabs.xPos;
-// wide = current.xPos - RTabX;
- tabs.charIndex = a;
- }
- }
-
- // remember y pos
- if (DropCmode)
- hl->glyph.yoffset -= charStyle.font().realCharHeight(chstr[0], chsd / 10.0) - charStyle.font().realCharAscent(chstr[0], chsd / 10.0);
-
-
- // remember x pos
- double breakPos = current.xPos;
-
- if (!tabs.active) // normal case
- {
- current.xPos += wide+kernVal;
- }
- else if (tabs.active && tabs.status == TabCENTER) // center tab
- {
- current.xPos += (wide+kernVal) / 2;
- current.xPos = qMax(current.xPos, current.colLeft);
- }
- else // other tabs.active
- {
- current.xPos = qMax(current.xPos, current.colLeft);
- }
-
- //FIXME: asce / desc set correctly?
- if (legacy &&
- (((hl->ch == '-' || (hl->effects() & ScStyle_HyphenationPossible)) && (current.hyphenCount < m_Doc->hyphConsecutiveLines() || m_Doc->hyphConsecutiveLines() == 0))
- || hl->ch == SpecialChars::SHYPHEN))
- {
- if (hl->effects() & ScStyle_HyphenationPossible || hl->ch == SpecialChars::SHYPHEN)
- {
- pt1 = QPoint(qRound(ceil(current.xPos+extra.Right - current.maxShrink + charStyle.font().charWidth('-', charStyle.fontSize() / 10.0) * (charStyle.scaleH() / 1000.0))), qRound(current.yPos+desc));
- pt2 = QPoint(qRound(ceil(current.xPos+extra.Right - current.maxShrink + charStyle.font().charWidth('-', charStyle.fontSize() / 10.0) * (charStyle.scaleH() / 1000.0))), qRound(ceil(current.yPos-asce)));
- }
- else
- {
- pt1 = QPoint(qRound(ceil(current.xPos+extra.Right - current.maxShrink )), qRound(current.yPos+desc));
- pt2 = QPoint(qRound(ceil(current.xPos+extra.Right - current.maxShrink )), qRound(ceil(current.yPos-asce)));
- }
- }
- else if (!legacy && SpecialChars::isBreakingSpace(hl->ch))
- {
- pt1 = QPoint(qRound(ceil(breakPos + extra.Right - current.maxShrink )), qRound(current.yPos+desc));
- pt2 = QPoint(qRound(ceil(breakPos + extra.Right - current.maxShrink )), qRound(ceil(current.yPos-asce)));
- }
- else
- {
- pt1 = QPoint(qRound(ceil(current.xPos+extra.Right - current.maxShrink)), qRound(current.yPos+desc));
- pt2 = QPoint(qRound(ceil(current.xPos+extra.Right - current.maxShrink)), qRound(ceil(current.yPos-asce)));
- }
-
- // test if end of line reached
- if ((!cl.contains(pf2.map(pt1))) || (!cl.contains(pf2.map(pt2))) || (legacy && current.isEndOfLine(style.rightMargin())))
- outs = true;
- if (current.isEndOfCol())
- outs = true;
- if ((hl->ch == SpecialChars::FRAMEBREAK) && (a < itemText.length()-1))
- goNoRoom = true;
- if ((hl->ch == SpecialChars::COLBREAK) && (Cols > 1))
- goNextColumn = true;
-
-
- // remember possible break
- // #5783 : comment out "&& !outs" as this make it possible to perform a line break
- // before a space which contradicts unicode line breaking rules
- if ( (SpecialChars::isBreakingSpace(hl->ch) || hl->ch == SpecialChars::TAB) /*&& !outs*/)
- {
- if ( a == firstInFrame() || !SpecialChars::isBreakingSpace(itemText.text(a-1)) )
- {
- current.rememberBreak(a, breakPos);
- }
- }
-
-
- // hyphenation
- if (((hl->effects() & ScStyle_HyphenationPossible) || (hl->ch == '-') || hl->ch == SpecialChars::SHYPHEN) && (!outs) && !itemText.text(a-1).isSpace() )
- {
- breakPos = current.xPos;
- if (hl->ch != '-')
- {
- breakPos += charStyle.font().charWidth('-', charStyle.fontSize() / 10.0) * (charStyle.scaleH() / 1000.0);
- }
-
- double rightHang = 0;
- if (opticalMargins & ParagraphStyle::OM_RightHangingPunct) {
- rightHang = 0.7 * charStyle.font().realCharWidth('-', (charStyle.fontSize() / 10.0) * (charStyle.scaleH() / 1000.0));
- }
-
- if (legacy || (breakPos - rightHang < current.colRight - style.rightMargin()))
- {
- if ((current.hyphenCount < m_Doc->hyphConsecutiveLines()) || (m_Doc->hyphConsecutiveLines() == 0) || hl->ch == SpecialChars::SHYPHEN)
- {
- current.rememberBreak(a, breakPos);
- }
- }
- }
-
-
- ++current.itemsInLine;
-
- if (tabs.active)
- {
- double cen = 1;
- if (tabs.status == TabCENTER)
- cen = 2;
-
- double newTabAdvance = itemText.item(tabs.charIndex)->glyph.xadvance - (wide+kernVal) / cen;
-
- if (newTabAdvance >= 0) {
- itemText.item(tabs.charIndex)->glyph.xadvance = newTabAdvance;
- }
- else {
- tabs.active = false;
- tabs.status = TabNONE;
- }
- }
-
- if (DropCmode)
- {
- DropCmode = false;
- DropLinesCount = 0;
- maxDY = current.yPos;
- current.hasDropCap = true;
- current.xPos += style.dropCapOffset();
- hl->glyph.xadvance += style.dropCapOffset();
-// qDebug() << QString("dropcapoffset: %1 -> %2").arg(current.xPos-style.dropCapOffset()).arg(current.xPos);
- current.xPos = qMax(current.xPos, current.colLeft);
- maxDX = current.xPos;
- QPolygon tcli(4);
- if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- {
- current.yPos -= m_Doc->guidesPrefs().valueBaselineGrid * (DropLines-1);
- double by = Ypos;
- if (OwnPage != -1)
- by = Ypos - m_Doc->Pages->at(OwnPage)->yOffset();
- int ol1 = qRound((by + current.yPos - m_Doc->guidesPrefs().offsetBaselineGrid) * 10000.0);
- int ol2 = static_cast<int>(ol1 / m_Doc->guidesPrefs().valueBaselineGrid);
-// qDebug() << QString("baseline adjust after dropcaps: y=%1->%2").arg(current.yPos).arg(ceil( ol2 / 10000.0 ) * m_Doc->guideSettings.valueBaselineGrid + m_Doc->typographicSettings.offsetBaselineGrid - by);
- current.yPos = ceil( ol2 / 10000.0 ) * m_Doc->guidesPrefs().valueBaselineGrid + m_Doc->guidesPrefs().offsetBaselineGrid - by;
- //FIXME: use current.colLeft instead of xOffset?
- tcli.setPoint(0, QPoint(qRound(hl->glyph.xoffset), qRound(maxDY-DropLines*m_Doc->guidesPrefs().valueBaselineGrid)));
- tcli.setPoint(1, QPoint(qRound(maxDX), qRound(maxDY-DropLines*m_Doc->guidesPrefs().valueBaselineGrid)));
- }
- else
- {
- if (style.lineSpacingMode() == ParagraphStyle::FixedLineSpacing)
- {
- current.yPos -= style.lineSpacing() * (DropLines-1);
-// qDebug() << QString("after dropcaps: y=%1").arg(current.yPos);
- tcli.setPoint(0, QPoint(qRound(hl->glyph.xoffset), qRound(maxDY - DropLines * style.lineSpacing())));
- tcli.setPoint(1, QPoint(qRound(maxDX), qRound(maxDY-DropLines*style.lineSpacing())));
- }
- else
- {
- double currasce = charStyle.font().height(style.charStyle().fontSize() / 10.0);
- current.yPos -= currasce * (DropLines-1);
-// qDebug() << QString("after dropcaps: y=%1").arg(current.yPos);
- tcli.setPoint(0, QPoint(qRound(hl->glyph.xoffset), qRound(maxDY-DropLines*currasce)));
- tcli.setPoint(1, QPoint(qRound(maxDX), qRound(maxDY-DropLines*currasce)));
- }
- }
- tcli.setPoint(2, QPoint(qRound(maxDX), qRound(maxDY)));
- tcli.setPoint(3, QPoint(qRound(hl->glyph.xoffset), qRound(maxDY)));
- // #6821 : the following two lines are causing bad text flow around drop caps
- // in some case, discarding them put more emphasis on user control of line spacing
- /*cm = QRegion(pf2.map(tcli));
- cl = cl.subtract(cm);*/
-// current.yPos = maxDY;
- }
- // end of line
- if ( SpecialChars::isBreak(hl->ch, Cols > 1) || (outs))
- {
- tabs.active = false;
- tabs.status = TabNONE;
- if (SpecialChars::isBreak(hl->ch, Cols > 1))
- {
- // find end of line
- current.breakLine(itemText, style, firstLineOffset(), a);
- EndX = current.endOfLine(cl, pf2, style.rightMargin());
- current.finishLine(EndX);
-
-// if (style.alignment() != 0)
- {
- if (opticalMargins & ParagraphStyle::OM_RightHangingPunct)
- current.line.width += opticalRightMargin(itemText, current.line);
-
- OFs = 0;
- if (style.alignment() == ParagraphStyle::Rightaligned)
- OFs = current.line.width - current.line.naturalWidth;
- if (style.alignment() == ParagraphStyle::Centered)
- OFs = (current.line.width - current.line.naturalWidth) / 2;
- if (style.alignment() == ParagraphStyle::Justified)
- OFs = 0;
-
- if (style.alignment() == ParagraphStyle::Extended
- || (style.alignment() == ParagraphStyle::Justified
- && (hl->ch == SpecialChars::LINEBREAK ||
- hl->ch == SpecialChars::FRAMEBREAK ||
- hl->ch == SpecialChars::COLBREAK)
- && !itemText.text(current.line.lastItem - 1).isSpace()))
- {
- justifyLine(itemText, current.line);
- }
- else
- {
- if (opticalMargins & ParagraphStyle::OM_RightHangingPunct)
- current.line.naturalWidth += opticalRightMargin(itemText, current.line);
- double optiWidth = current.colRight - style.lineSpacing()/2.0 - current.line.x;
- if (current.line.naturalWidth > optiWidth)
- current.line.width = qMax(current.line.width - current.maxShrink, optiWidth);
- // simple offset
- indentLine(itemText, current.line, OFs);
- }
- current.xPos = current.colRight;
- }
- }
- else // outs -- last char went outside the columns (or into flow-around shape)
- {
- if (current.breakIndex >= 0) // Hier koenen auch andere Trennungen eingebaut werden
- {
- // go back to last break position
-// qDebug() << QString("new break pos a=%1 BuPos=%2 current.breakIndex=%3").arg(a).arg(BuPos).arg(current.breakIndex);
- a = current.breakIndex;
- assert( a >= 0 );
- assert( a < itemText.length() );
- hl = itemText.item(a);
- style = itemText.paragraphStyle(a);
- if (style.lineSpacingMode() == ParagraphStyle::AutomaticLineSpacing)
- {
- style.setLineSpacing(style.charStyle().font().height(style.charStyle().fontSize() / 10.0));
-// qDebug() << QString("auto linespacing: %1").arg(style.lineSpacing());
- }
- else if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- style.setLineSpacing(m_Doc->guidesPrefs().valueBaselineGrid);
- current.itemsInLine = a - current.line.firstItem + 1;
-// qDebug() << QString("style outs pos %1: %2 (%3)").arg(a).arg(style.alignment()).arg(style.parent());
-// qDebug() << QString("style <@%6: %1 -- %2, %4/%5 char: %3").arg(style.leftMargin()).arg(style.rightMargin())
-// .arg(style.charStyle().asString()).arg(style.name()).arg(style.parent()?style.parent()->name():"")
-// .arg(a);
-
- if (hl->ch == ' ') {
- hl->setEffects(hl->effects() | ScStyle_SuppressSpace);
- hl->glyph.xadvance = 0;
- }
-
- current.updateHeightMetrics(itemText);
- current.updateLineOffset(itemText, style, firstLineOffset());
- EndX = current.endOfLine(cl, pf2, style.rightMargin());
- current.finishLine(EndX);
-
-//??? current.breakXPos = current.line.x;
-//??? for (int j=current.line.firstItem; j <= a; ++j)
-//??? current.breakXPos += itemText.item(j)->glyph.wide();
-
- if ((hl->effects() & ScStyle_HyphenationPossible) || hl->ch == SpecialChars::SHYPHEN)
- {
- // insert hyphen
- current.hyphenCount++;
- hl->setEffects(hl->effects() | ScStyle_SoftHyphenVisible);
- hl->glyph.grow();
- hl->glyph.more->glyph = charStyle.font().char2CMap(QChar('-'));
- hl->glyph.more->xadvance = charStyle.font().charWidth('-', itemText.charStyle(a).fontSize() / 10.0) * (itemText.charStyle(a).scaleH() / 1000.0);
- }
- else
- {
- if (hl->ch != '-')
- current.hyphenCount = 0;
- hl->setEffects(hl->effects() & ~ScStyle_SoftHyphenVisible);
- hl->glyph.shrink();
- }
-
- // Justification
-// if (style.alignment() != 0)
- {
- if (opticalMargins & ParagraphStyle::OM_RightHangingPunct)
- current.line.width += opticalRightMargin(itemText, current.line);
-
- OFs = 0;
- if (style.alignment() == ParagraphStyle::Rightaligned)
- OFs = current.line.width - current.line.naturalWidth;
- if (style.alignment() == ParagraphStyle::Centered)
- OFs = (current.line.width - current.line.naturalWidth) / 2;
-
- if ((style.alignment() == ParagraphStyle::Justified)
- || (style.alignment() == ParagraphStyle::Extended))
- {
- justifyLine(itemText, current.line);
- }
- else
- {
- if (opticalMargins & ParagraphStyle::OM_RightHangingPunct)
- current.line.naturalWidth += opticalRightMargin(itemText, current.line);
- indentLine(itemText, current.line, OFs);
- }
-// qDebug() << QString("line: endx=%1 next pos=(%2,%3").arg(EndX).arg(current.line.x + current.line.width).arg(current.yPos);
- current.xPos = current.line.x + current.line.width;
- }
- }
- else // no break position
- {
- if (a >= current.line.firstItem)
- {
- if ((hl->effects() & ScStyle_HyphenationPossible) || hl->ch == SpecialChars::SHYPHEN)
- {
- current.itemsInLine = 0;
- a = current.line.firstItem - 1;
- }
- else
- {
- --a;
- --current.itemsInLine;
- }
- }
- if (a >= 0)
- {
- hl = itemText.item(a);
- style = itemText.paragraphStyle(a);
- if (style.lineSpacingMode() == ParagraphStyle::AutomaticLineSpacing)
- {
- style.setLineSpacing(style.charStyle().font().height(style.charStyle().fontSize() / 10.0));
-// qDebug() << QString("auto linespacing: %1").arg(style.lineSpacing());
- }
- else if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- style.setLineSpacing(m_Doc->guidesPrefs().valueBaselineGrid);
- }
- current.breakLine(itemText, style, firstLineOffset(), a);
-// qDebug() << QString("style no break pos %1: %2 (%3)").arg(a).arg(style.alignment()).arg(style.parent());
-// qDebug() << QString("style nb @%6: %1 -- %2, %4/%5 char: %3").arg(style.leftMargin()).arg(style.rightMargin())
-// .arg(style.charStyle().asString()).arg(style.name()).arg(style.parent())
-// .arg(a);
- EndX = current.endOfLine(cl, pf2, style.rightMargin());
- current.finishLine(EndX);
-// qDebug() << QString("no break pos: %1-%2 @ %3 wid %4 nat %5 endX %6")
-// .arg(current.line.firstItem).arg(current.line.firstItem)
-// .arg(current.line.x).arg(current.line.width).arg(current.line.naturalWidth).arg(EndX);
- indentLine(itemText, current.line, 0);
- }
- }
- if ( outs || SpecialChars::isBreak(hl->ch, (Cols > 1)) )
- {
- if (outs && !current.isEndOfLine(hl->glyph.wide() + style.rightMargin()))
- {
- if (( hl->ch == SpecialChars::PARSEP || hl->ch == SpecialChars::LINEBREAK)
- && current.hasDropCap)
- {
- current.hasDropCap = false;
- if (current.yPos < maxDY)
- current.yPos = maxDY;
-// qDebug() << QString("after dropcaps: y=%1 maxDY=%2").arg(current.yPos).arg(maxDY);
- }
- bool fromOut = true;
- double BotOffset = desc+extra.Bottom+lineCorr;
- while (!current.isEndOfLine(style.rightMargin()))
- {
- current.xPos++;
- if (current.isEndOfLine(style.rightMargin()))
- {
- fromOut = false;
-// qDebug() << QString("layout: next lower2 grid=%1 x %2").arg(style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing).arg(m_Doc->typographicSettings.valueBaseGrid);
-// qDebug() << QString("nextline: y=%1+%2").arg(current.yPos).arg(style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing? m_Doc->typographicSettings.valueBaseGrid : style.lineSpacing());
-
- if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- current.yPos += m_Doc->guidesPrefs().valueBaselineGrid;
- else
- current.yPos += style.lineSpacing();
- if (current.isEndOfCol(desc) && (current.column+1 == Cols))
- {
- goNoRoom = true;
- MaxChars = a + 1;
-// qDebug() << QString("go no room 1: %1").arg(a));
- break;
- }
- if (current.hasDropCap)
- {
- ++DropLinesCount;
- if (DropLinesCount >= DropLines)
- {
- current.hasDropCap = false;
- current.xPos = current.colLeft;
- }
- else
- current.xPos = maxDX;
- }
- else
- current.xPos = current.colLeft;
- if (SpecialChars::isBreak(hl->ch))
- {
- if (hl->ch == SpecialChars::PARSEP)
- {
-// qDebug() << QString("gap after: y=%1+%2").arg(current.yPos).arg(style.gapAfter());
- current.yPos += style.gapAfter();
- }
- current.hyphenCount = 0;
- }
- break;
- }
- // #7944 : Do not use static_cast<int> here, this is not consistent with computations
- // performed at lines 1488-1512 and can trigger hang due to changing region detection
- //pt1 = QPoint(qRound(current.xPos+extra.Right), static_cast<int>(current.yPos+BotOffset));
- //pt2 = QPoint(qRound(current.xPos+extra.Right), static_cast<int>(ceil(current.yPos-asce)));
- pt1 = QPoint(qRound(current.xPos+extra.Right), qRound(current.yPos+BotOffset));
- pt2 = QPoint(qRound(current.xPos+extra.Right), qRound(ceil(current.yPos-asce)));
- if (cl.contains(pf2.map(pt1)) && cl.contains(pf2.map(pt2)))
- break;
-// else
-// qDebug() << QString("looking for start of line at %1,%2").arg(current.xPos).arg(current.yPos);
- }
- if (fromOut)
- {
- if (current.isEndOfCol(desc) && (current.column+1 == Cols))
- {
- goNoRoom = true;
- MaxChars = a + 1;
-// qDebug() << QString("go no room 2: %1").arg(a);
- break;
- }
- current.xPos--;
- current.xPos = qMax(current.xPos, current.colLeft);
- }
- }
- else
- {
- if (( hl->ch == SpecialChars::PARSEP || hl->ch == SpecialChars::LINEBREAK )
- && current.hasDropCap)
- {
- current.hasDropCap = false;
- if (current.yPos < maxDY)
- current.yPos = maxDY;
-// qDebug() << QString("after dropcap2: y=%1+%2").arg(current.yPos).arg(maxDY);
- }
-// qDebug() << QString("layout: next lower3 grid=%1 x %2").arg(style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing).arg(m_Doc->typographicSettings.valueBaseGrid);
-
-
- if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- {
-// qDebug() << QString("next line (grid): y=%1+%2").arg(current.yPos).arg(m_Doc->typographicSettings.valueBaseGrid);
-
- current.yPos += m_Doc->guidesPrefs().valueBaselineGrid;
- }
- else
- {
-// qDebug() << QString("next line (auto): y=%1+%2").arg(current.yPos).arg(style.lineSpacing());
- //#5845 : use next paragraph line spacing for switching to next paragraph instead of current one
- //current.yPos += style.lineSpacing();
- const ParagraphStyle& pStyle = itemText.paragraphStyle(a+1);
- double lineSpacing = pStyle.lineSpacing();
- if (pStyle.lineSpacingMode() == ParagraphStyle::AutomaticLineSpacing)
- lineSpacing = pStyle.charStyle().font().height(pStyle.charStyle().fontSize() / 10.0);
- else if (pStyle.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- lineSpacing = m_Doc->guidesPrefs().valueBaselineGrid;
- current.yPos += lineSpacing;
- }
- if (current.hasDropCap)
- {
- ++DropLinesCount;
- if (DropLinesCount >= DropLines)
- {
- current.hasDropCap = false;
- current.xPos = current.colLeft;
- }
- else
- current.xPos = maxDX;
- }
- else
- current.xPos = current.colLeft;
- if ( SpecialChars::isBreak(hl->ch) )
- {
- if (hl->ch == SpecialChars::PARSEP)
- {
-// qDebug() << QString("gap after: y=%1+%2").arg(current.yPos).arg(style.gapAfter());
- current.yPos += style.gapAfter();
- }
- current.hyphenCount = 0;
- }
- }
- }
-
-
- // calc. needed vertical space
- // Letâs try to change into "calc. _wanted_ vertical space" - pm
- if (current.itemsInLine != 0)
- {
- if ( itemText.charStyle(current.line.firstItem).effects() & ScStyle_DropCap)
- {
- // put line back to top
- current.line.y -= DropCapDrop;
- itemText.item(current.line.firstItem)->glyph.yoffset += DropCapDrop;
- }
- }
-
- fillInTabLeaders(itemText, current.line);
-
- current.startOfCol = false;
-/* has no effect except setting wide, asce and desc
- uint loopC = BuPos3;
- if (m_Doc->guidesPrefs().showControls)
- loopC++; // ??? AV
- for (int zc = 0; zc < loopC; ++zc)
- {
- if ( zc >= current.itemsInLine) {
- qDebug("layout: zc too large %d / %d", zc, current.itemsInLine);
- continue;
- }
- if ( startLin + zc >= itemText.length()) {
- qDebug("layout: startLin+zc too large %d+%d / %d", startLin, zc, itemText.length());
- continue;
- }
-// else
-// qDebug("layout: startLin, zc ok. %d, %d, %d", startLin, zc, LiList.count());
- double wide2 = 0;
- double xcoZli = itemText.item(current.line.firstItem + zc)->glyph.xoffset;
-// itemText.item(startLin+zc)->glyph.xoffset = Zli2->xco;
-/// itemText.item(startLin+zc)->glyph.yoffset = Zli2->yco;
- tTabValues = itemText.paragraphStyle(startLin+zc).tabValues();
- desc = - itemText.charStyle(startLin+zc).font().descent(itemText.charStyle(startLin+zc).fontSize() / 10.0);
- asce = itemText.charStyle(startLin+zc).font().ascent(itemText.charStyle(startLin+zc).fontSize() / 10.0);
- bool Sele = itemText.selected(startLin+zc);
- if (((Sele && (Select)) || (((NextBox != 0) || (BackBox != 0)) && Sele)) && (m_Doc->appMode == modeEdit))
- {
- wide = itemText.item(startLin+zc)->glyph.xadvance;
- if ((zc > 0) && (itemText.text(startLin+zc) == SpecialChars::TAB))
- {
- wide2 = itemText.item(startLin+zc-1)->glyph.xadvance;
- xcoZli = itemText.item(startLin+zc-1)->glyph.xoffset + wide2;
- wide = itemText.item(startLin+zc)->glyph.xoffset - xcoZli + itemText.item(startLin+zc)->glyph.xadvance;
- }
- }
- }
- */
-// qDebug() << QString("layout: line %1 - %2 @ (%3,%4) wd %5/%6").arg(current.line.firstItem).arg(current.line.lastItem)
-// .arg(current.line.x).arg(current.line.y).arg(current.line.naturalWidth).arg(current.line.width);
- if (current.line.firstItem > current.line.lastItem)
- ; //qDebug() << QString("layout: empty line %1 - %2").arg(current.line.firstItem).arg(current.line.lastItem);
- else if (current.itemsInLine > 0)
- itemText.appendLine(current.line);
- current.startLine(a+1);
- outs = false;
- if (goNoRoom)
- {
- goNoRoom = false;
- MaxChars = a+1;
-// qDebug() << QString("no room C: %1").arg(a+1);
- goto NoRoom;
- }
- if (goNextColumn)
- {
- goNextColumn = false;
- current.column++;
- if (current.column < Cols)
- {
- current.nextColumn(asce);
- }
- else
- {
- MaxChars = a;
-// qDebug() << QString("no room D: %1").arg(a);
- goto NoRoom;
- }
- }
- }
- }
- if (goNoRoom)
- {
- goNoRoom = false;
- goto NoRoom;
- }
-// end of itemText
- int a = itemText.length()-1;
- hl = a >=0 ? itemText.item(a) : NULL;
- current.breakLine(itemText, style, firstLineOffset(), a);
- EndX = current.endOfLine(cl, pf2, style.rightMargin());
- current.finishLine(EndX);
-
-// if (style.alignment() != 0)
- {
- if (opticalMargins & ParagraphStyle::OM_RightHangingPunct)
- {
- current.line.width += opticalRightMargin(itemText, current.line);
- }
-
- OFs = 0;
- if (style.alignment() == ParagraphStyle::Rightaligned)
- OFs = current.line.width - current.line.naturalWidth;
- if (style.alignment() == ParagraphStyle::Centered)
- OFs = (current.line.width - current.line.naturalWidth) / 2;
- if (style.alignment() == ParagraphStyle::Justified)
- OFs = 0;
- if (style.alignment() == ParagraphStyle::Extended
- || (style.alignment() == ParagraphStyle::Justified
- && (hl->ch == SpecialChars::LINEBREAK ||
- hl->ch == SpecialChars::FRAMEBREAK ||
- hl->ch == SpecialChars::COLBREAK)
- && !itemText.text(current.line.firstItem + current.itemsInLine-1).isSpace()))
- {
- justifyLine(itemText, current.line);
- }
- else
- {
- if (opticalMargins & ParagraphStyle::OM_RightHangingPunct)
- current.line.naturalWidth += opticalRightMargin(itemText, current.line);
- indentLine(itemText, current.line, OFs);
- }
- }
-
- if (current.itemsInLine != 0)
- {
- if ( itemText.charStyle(current.line.firstItem).effects() & ScStyle_DropCap )
- {
- // put line back to top
- current.line.y -= DropCapDrop;
- itemText.item(current.line.firstItem)->glyph.yoffset += DropCapDrop;
- }
- }
- fillInTabLeaders(itemText, current.line);
- current.startOfCol = false;
- goNextColumn = false;
-
-// qDebug() << QString("layout: last line %1 - %2 @ (%3,%4) wd %5/%6").arg(current.line.firstItem).arg(current.line.lastItem)
-// .arg(current.line.x).arg(current.line.y).arg(current.line.naturalWidth).arg(current.line.width);
-
- if (current.itemsInLine > 0) {
- itemText.appendLine(current.line);
- }
- }
- MaxChars = itemText.length();
- invalid = false;
-// pf2.end();
- if (NextBox != NULL)
- {
- PageItem_TextFrame* nextFrame = dynamic_cast<PageItem_TextFrame*>(NextBox);
- if (nextFrame != NULL)
- {
- nextFrame->invalid = true;
- nextFrame->firstChar = MaxChars;
- }
- }
-// qDebug("textframe: len=%d, done relayout", itemText.length());
- return;
-
-NoRoom:
-// pf2.end();
- invalid = false;
- PageItem_TextFrame * next = dynamic_cast<PageItem_TextFrame*>(NextBox);
- if (next != NULL)
- {
- next->invalid = true;
- next->firstChar = MaxChars;
- if (CPos > signed(MaxChars))
- {
- int nCP = CPos;
-// CPos = MaxChars;
- if (m_Doc->appMode == modeEdit)
- {
- // OwnPage->Deselect(true);
- next->CPos = qMax(nCP, signed(MaxChars));
- // Doc->currentPage = NextBox->OwnPage;
- // NextBox->OwnPage->SelectItemNr(NextBox->ItemNr);
-// qDebug("textframe: len=%d, leaving relayout in editmode && Tinput", itemText.length());
- return;
- }
- }
- // relayout next frame
-// qDebug("textframe: len=%d, going to next", itemText.length());
- next->layout();
- }
-// qDebug("textframe: len=%d, done relayout (no room %d)", itemText.length(), MaxChars);
+
+void PageItem_TextFrame::layout()
+{
+ legacyLayout(this);
}
void PageItem_TextFrame::invalidateLayout()
@@ -2387,6 +371,17 @@
uint tabCc = 0;
assert( firstInFrame() >= 0 );
assert( lastInFrame() < itemText.length() );
+
+ RenderOptions options;
+ options.markSelection = itemText.lengthOfSelection() > 0;
+ options.showControls = (m_Doc->guidesPrefs().showControls);
+ options.controlCharColor = PrefsManager::instance()->appPrefs.displayPrefs.controlCharColor;
+ options.reverse = Reverse; // hope we have bidi soon...
+ options.layerOutline = (m_Doc->layerOutline(LayerID));
+ options.layerMarker = m_Doc->layerMarker(LayerID);
+ textLayout->box()->render(p, options);
+
+#if 0
LineSpec ls;
for (uint ll=0; ll < itemText.lines(); ++ll)
{
@@ -2556,6 +551,7 @@
// // qDebug("skipping textframe: len=%d", itemText.count());
// }
// pf2.end();
+#endif
}
p->restore();//RE1
}
@@ -2901,12 +897,12 @@
pos = len-1;
if ( (buttonModifiers & Qt::ControlModifier) == 0 )
{
- pos = itemText.startOfLine(pos);
+ pos = textLayout->startOfLine(pos);
}
else
{
//Control Home for start of frame text
- pos = itemText.startOfFrame(pos);
+ pos = textLayout->startOfFrame();
}
CPos = pos;
if ( buttonModifiers & Qt::ShiftModifier )
@@ -2922,12 +918,12 @@
break; // at end of frame
if ( (buttonModifiers & Qt::ControlModifier) == 0 )
{
- CPos = itemText.endOfLine(CPos);
+ CPos = textLayout->endOfLine(CPos);
}
else
{
//Control End for end of frame text
- CPos = itemText.endOfFrame(CPos);
+ CPos = textLayout->endOfFrame();
}
if ( buttonModifiers & Qt::ShiftModifier )
ExpandSel(1, oldPos);
@@ -2948,7 +944,7 @@
{
if (CPos <= lastInFrame())
{
- CPos = itemText.nextLine(CPos);
+ CPos = textLayout->nextLine(CPos);
if ( buttonModifiers & Qt::ShiftModifier )
{
if ( buttonModifiers & Qt::AltModifier )
@@ -2956,7 +952,10 @@
ExpandSel(1, oldPos);
}
else
- if ((itemText.lines() > 0) && (oldPos >= itemText.line(itemText.lines()-1).firstItem) && (CPos >= lastInFrame()) && (NextBox != 0))
+ if ((textLayout->startOfFrame() != textLayout->endOfFrame())
+// && (oldPos >= textLayout->line(itemText.lines()-1).firstItem)
+ && (CPos >= lastInFrame())
+ && (NextBox != 0))
{
if (NextBox->frameDisplays(CPos))
{
@@ -3001,7 +1000,7 @@
{
if (CPos > lastInFrame() || CPos >= itemText.length())
CPos = lastInFrame();
- CPos = itemText.prevLine(CPos);
+ CPos = textLayout->prevLine(CPos);
if ( buttonModifiers & Qt::ShiftModifier )
{
if ( buttonModifiers & Qt::AltModifier )
@@ -3009,7 +1008,10 @@
ExpandSel(-1, oldPos);
}
else
- if ((itemText.lines() > 0) && (oldPos <= itemText.line(0).lastItem) && (CPos == firstInFrame()) && (BackBox != 0))
+ if ((textLayout->startOfFrame() != textLayout->endOfFrame())
+// && (oldPos <= itemText.line(0).lastItem)
+ && (CPos == firstInFrame())
+ && (BackBox != 0))
{
view->Deselect(true);
// TODO position at the right place in previous frame
@@ -3033,13 +1035,13 @@
m_Doc->scMW()->setTBvals(this);
break;
case Qt::Key_PageUp:
- CPos = itemText.startOfFrame(CPos);
+ CPos = textLayout->startOfFrame();
if ( buttonModifiers & Qt::ShiftModifier )
ExpandSel(-1, oldPos);
m_Doc->scMW()->setTBvals(this);
break;
case Qt::Key_PageDown:
- CPos = itemText.endOfFrame(CPos);
+ CPos = textLayout->endOfFrame();
if ( buttonModifiers & Qt::ShiftModifier )
ExpandSel(1, oldPos);
m_Doc->scMW()->setTBvals(this);
@@ -3548,7 +1550,6 @@
}
-#endif //NLS_PROTO
bool PageItem_TextFrame::createInfoGroup(QFrame *infoGroup, QGridLayout *infoGroupLayout)
{
@@ -3586,7 +1587,7 @@
linesCT->setText(tr("Lines: "));
infoGroupLayout->addWidget( linesCT, 2, 0, Qt::AlignRight );
- linesT->setText(QString::number(itemText.lines()));
+ linesT->setText(QString::number(0)); // FIXME
infoGroupLayout->addWidget( linesT, 2, 1 );
@@ -3635,7 +1636,7 @@
}
actionList << "itemConvertToOutlines";
}
- if (itemText.lines() != 0)
+ if (textLayout->endOfFrame() > 0)
actionList << "editClearContents";
}
Modified: branches/ScribusOIF/scribus/pageitem_textframe.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/pageitem_textframe.h
==============================================================================
--- branches/ScribusOIF/scribus/pageitem_textframe.h (original)
+++ branches/ScribusOIF/scribus/pageitem_textframe.h Mon Oct 18 10:52:30 2010
@@ -76,14 +76,14 @@
int firstTextItem() const { return itemText.firstFrameItem; }
int lastTextItem() const { return itemText.lastFrameItem; }
#endif
-
+
+ QRegion availableRegion(QRegion clip);
protected:
virtual void DrawObj_Item(ScPainter *p, QRectF e);
virtual void DrawObj_Post(ScPainter *p);
virtual void DrawObj_Decoration(ScPainter *p);
void drawOverflowMarker(ScPainter *p);
void drawColumnBorders(ScPainter *p);
- QRegion availableRegion(QRegion clip);
#ifdef NLS_PROTO
void DrawLineItem(ScPainter *p, double width,
Modified: branches/ScribusOIF/scribus/pdflib_core.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/pdflib_core.cpp
==============================================================================
--- branches/ScribusOIF/scribus/pdflib_core.cpp (original)
+++ branches/ScribusOIF/scribus/pdflib_core.cpp Mon Oct 18 10:52:30 2010
@@ -4821,6 +4821,7 @@
// Return a PDF substring representing a PageItem's text
QString PDFLibCore::setTextSt(PageItem *ite, uint PNr, const Page* pag)
{
+#if 0 // FIXME_OIF
int tabCc = 0;
int savedOwnPage = ite->OwnPage;
double tabDist = ite->textToFrameDistLeft();
@@ -5043,10 +5044,12 @@
if (ite->itemType() == PageItem::TextFrame)
tmp += "ET\n"+tmp2;
return tmp;
+#endif
}
bool PDFLibCore::setTextCh(PageItem *ite, uint PNr, double x, double y, uint d, QString &tmp, QString &tmp2, const ScText *hl, const ParagraphStyle& pstyle, const Page* pag)
{
+#if 0 // FIXME_OIF
#ifndef NLS_PROTO
QString output;
QString FillColor = "";
@@ -5635,6 +5638,7 @@
hl2.glyph.more = 0;
}
return true;
+#endif
#endif
}
Modified: branches/ScribusOIF/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
==============================================================================
--- branches/ScribusOIF/scribus/plugins/fileloader/scribus134format/scribus134format.cpp (original)
+++ branches/ScribusOIF/scribus/plugins/fileloader/scribus134format/scribus134format.cpp Mon Oct 18 10:52:30 2010
@@ -2046,12 +2046,217 @@
return success;
}
+//bool Scribus134Format::readItemText(PageItem *obj, ScXmlStreamAttributes& attrs, LastStyles* last, bool impo, bool VorLFound)
+//{
+// QString tmp2;
+// CharStyle newStyle;
+// ScribusDoc* doc = obj->doc();
+
+// readCharacterStyleAttrs(doc, attrs, newStyle);
+
+// if (attrs.hasAttribute(QLatin1String("Unicode")))
+// {
+// tmp2 = QChar(attrs.valueAsInt("Unicode"));
+// }
+// else
+// {
+// tmp2 = attrs.valueAsString("CH");
+
+// // legacy stuff:
+// tmp2.replace(QRegExp("\r"), QChar(13));
+// tmp2.replace(QRegExp("\n"), QChar(13));
+// tmp2.replace(QRegExp("\t"), QChar(9));
+// }
+
+// // more legacy stuff:
+// static const QString CFONT("CFONT");
+// if (attrs.hasAttribute(CFONT))
+// newStyle.setFont(m_AvailableFonts->findFont(attrs.valueAsString(CFONT), doc));
+
+// static const QString CSIZE("CSIZE");
+// if (attrs.hasAttribute(CSIZE))
+// newStyle.setFontSize(qRound(attrs.valueAsDouble(CSIZE) * 10));
+
+// static const QString CCOLOR("CCOLOR");
+// if (attrs.hasAttribute(CCOLOR))
+// newStyle.setFillColor(attrs.valueAsString(CCOLOR));
+
+// static const QString CEXTRA("CEXTRA");
+// if (attrs.hasAttribute(CEXTRA))
+// newStyle.setTracking(qRound(attrs.valueAsDouble(CEXTRA) / attrs.valueAsDouble(CSIZE) * 1000.0));
+// else if (attrs.hasAttribute(QLatin1String("CKERN")))
+// newStyle.setTracking(attrs.valueAsInt("CKERN"));
+
+// static const QString CSHADE("CSHADE");
+// if (attrs.hasAttribute(CSHADE))
+// newStyle.setFillShade(attrs.valueAsInt(CSHADE));
+
+// static const QString CSTYLE("CSTYLE");
+// if (attrs.hasAttribute(CSTYLE))
+// newStyle.setFeatures(static_cast<StyleFlag>(attrs.valueAsInt(CSTYLE)).featureList());
+
+// QString pstylename = attrs.valueAsString("PSTYLE", "");
+// int calign = attrs.valueAsInt("CALIGN", -1);
+
+// int ab = attrs.valueAsInt("CAB", -1);
+// if (ab >= 5) {
+// pstylename = doc->paragraphStyles()[ab-5].name();
+// calign = -1;
+// }
+// else if (ab >= 0) {
+// pstylename = "";
+// calign = ab;
+// }
+
+// static const QString CSTROKE("CSTROKE");
+// if (attrs.hasAttribute(CSTROKE))
+// newStyle.setStrokeColor(attrs.valueAsString(CSTROKE, CommonStrings::None));
+
+// static const QString CSHADE2("CSHADE2");
+// if (attrs.hasAttribute(CSHADE2))
+// newStyle.setStrokeShade(attrs.valueAsInt(CSHADE2, 100));
+
+// static const QString CSCALE("CSCALE");
+// if (attrs.hasAttribute(CSCALE))
+// newStyle.setScaleH(qMin(qMax(qRound(attrs.valueAsDouble(CSCALE, 100.0) * 10), 100), 4000));
+
+// static const QString CSCALEV("CSCALEV");
+// if (attrs.hasAttribute(CSCALEV))
+// newStyle.setScaleV(qMin(qMax(qRound(attrs.valueAsDouble(CSCALEV, 100.0) * 10), 100), 4000));
+
+// static const QString CBASE("CBASE");
+// if (attrs.hasAttribute(CBASE))
+// newStyle.setBaselineOffset(qRound(attrs.valueAsDouble(CBASE) * 10));
+
+// static const QString CSHX("CSHX");
+// if (attrs.hasAttribute(CSHX))
+// newStyle.setShadowXOffset(qRound(attrs.valueAsDouble(CSHX, 5.0) * 10));
+
+// static const QString CSHY("CSHY");
+// if (attrs.hasAttribute(CSHY))
+// newStyle.setShadowYOffset(qRound(attrs.valueAsDouble(CSHY, -5.0) * 10));
+
+// static const QString COUT("CSHY");
+// if (attrs.hasAttribute(COUT))
+// newStyle.setOutlineWidth(qRound(attrs.valueAsDouble(COUT, 1.0) * 10));
+
+// static const QString CULP("CULP");
+// if (attrs.hasAttribute(CULP))
+// newStyle.setUnderlineOffset(qRound(attrs.valueAsDouble(CULP, -0.1) * 10));
+
+// static const QString CULW("CULW");
+// if (attrs.hasAttribute(CULW))
+// newStyle.setUnderlineWidth(qRound(attrs.valueAsDouble(CULW, -0.1) * 10));
+
+// static const QString CSTP("CSTP");
+// if (attrs.hasAttribute(CSTP))
+// newStyle.setStrikethruOffset(qRound(attrs.valueAsDouble(CSTP, -0.1) * 10));
+
+// static const QString CSTW("CSTW");
+// if (attrs.hasAttribute(CSTW))
+// newStyle.setStrikethruWidth(qRound(attrs.valueAsDouble(CSTW, -0.1) * 10));
+
+// fixLegacyCharStyle(newStyle);
+
+// if (impo && ab >= 0 && VorLFound)
+// last->ParaStyle = DoVorl[ab].toInt();
+// else
+// last->ParaStyle = pstylename;
+// // end of legacy stuff
+
+// int iobj = attrs.valueAsInt("COBJ", -1);
+
+// for (int cxx=0; cxx<tmp2.length(); ++cxx)
+// {
+// QChar ch = tmp2.at(cxx);
+// { // Legacy mode
+// if (ch == QChar(5))
+// ch = SpecialChars::PARSEP;
+// if (ch == QChar(4))
+// ch = SpecialChars::TAB;
+// }
+
+// int pos = obj->itemText.length();
+// if (ch == SpecialChars::OBJECT) {
+// if (iobj >= 0) {
+// if (iobj < doc->FrameItems.count())
+// obj->itemText.insertObject(pos, doc->FrameItems.at(iobj));
+// else
+// qDebug() << QString("scribus134format: invalid inline frame used in text object : %1").arg(iobj);
+// }
+// }
+// else if (ch == SpecialChars::SHYPHEN && pos > 0)
+// {
+//// qDebug() << QString("scribus134format: SHYPHEN at %1").arg(pos);
+// ScText* lastItem = obj->itemText.item(pos-1);
+// // double SHY means user provided SHY, single SHY is automatic one
+// if (lastItem->effects() & ScStyle_HyphenationPossible)
+// {
+// lastItem->setEffects(lastItem->effects() & ~ScStyle_HyphenationPossible);
+// obj->itemText.insertChars(pos, QString(ch));
+// }
+// else
+// {
+// lastItem->setEffects(lastItem->effects() | ScStyle_HyphenationPossible);
+// }
+// }
+// else {
+// obj->itemText.insertChars(pos, QString(ch));
+// }
+//// qDebug() << QString("style at %1: %2 ^ %3 = %4 (%5)").arg(pos).arg((uint)newStyle.effects()).arg((uint)last->Style.effects()).arg((uint)(newStyle.effects() ^ last->Style.effects())).arg(newStyle != last->Style);
+// if (newStyle != last->Style) // || (newStyle.effects() ^ last->Style.effects()) == ScStyle_HyphenationPossible)
+// { // FIXME StyleFlag operator== ignores hyphen flag
+//// qDebug() << QString("new style at %1: %2 -> %3").arg(pos).arg(last->Style.asString()).arg(newStyle.asString());
+// obj->itemText.setCharStyle(last->StyleStart, pos-last->StyleStart, last->Style);
+// last->Style = newStyle;
+// last->StyleStart = pos;
+// }
+// if (ch == SpecialChars::PARSEP) {
+// ParagraphStyle pstyle;
+// // Qt4 if (last->ParaStyle >= 0) {
+// if (!last->ParaStyle.isEmpty()) {
+// pstyle.setParent( last->ParaStyle );
+// }
+// if (calign >= 0)
+// pstyle.setAlignment(static_cast<ParagraphStyle::AlignmentType>(calign));
+//// qDebug() << QString("par style at %1: %2/%3 (%4) calign %5").arg(pos).arg(pstyle.name()).arg(pstyle.parent()).arg(last->ParaStyle).arg(calign);
+// obj->itemText.applyStyle(pos, pstyle);
+// }
+// }
+
+// obj->itemText.setCharStyle(last->StyleStart, obj->itemText.length()-last->StyleStart, last->Style);
+// last->StyleStart = obj->itemText.length();
+///*
+// QString dbg("");
+// for (int i=0; i < obj->itemText.length(); ++i)
+// {
+// dbg += obj->itemText.text(i,1);
+// if (obj->itemText.item(i)->effects() & ScStyle_HyphenationPossible)
+// dbg += "~";
+// }
+// qDebug("scribus134format: read itemtext %d '%s'", obj->itemText.length(), dbg.latin1());
+// */
+// ParagraphStyle pstyle;
+
+// if (!last->ParaStyle.isEmpty()) { // Qt4 >= 0) {
+// pstyle.setParent( last->ParaStyle );
+// obj->itemText.applyStyle(obj->itemText.length()-1, pstyle);
+// }
+// if (calign >= 0) {
+// pstyle.setAlignment(static_cast<ParagraphStyle::AlignmentType>(calign));
+// obj->itemText.applyStyle(obj->itemText.length()-1, pstyle);
+// }
+
+// return true;
+//}
+
+
bool Scribus134Format::readItemText(PageItem *obj, ScXmlStreamAttributes& attrs, LastStyles* last, bool impo, bool VorLFound)
{
QString tmp2;
CharStyle newStyle;
ScribusDoc* doc = obj->doc();
-
+
readCharacterStyleAttrs(doc, attrs, newStyle);
if (attrs.hasAttribute(QLatin1String("Unicode")))
@@ -2061,43 +2266,43 @@
else
{
tmp2 = attrs.valueAsString("CH");
-
+
// legacy stuff:
tmp2.replace(QRegExp("\r"), QChar(13));
tmp2.replace(QRegExp("\n"), QChar(13));
tmp2.replace(QRegExp("\t"), QChar(9));
}
-
+
// more legacy stuff:
static const QString CFONT("CFONT");
if (attrs.hasAttribute(CFONT))
newStyle.setFont(m_AvailableFonts->findFont(attrs.valueAsString(CFONT), doc));
-
+
static const QString CSIZE("CSIZE");
if (attrs.hasAttribute(CSIZE))
newStyle.setFontSize(qRound(attrs.valueAsDouble(CSIZE) * 10));
-
+
static const QString CCOLOR("CCOLOR");
if (attrs.hasAttribute(CCOLOR))
newStyle.setFillColor(attrs.valueAsString(CCOLOR));
-
+
static const QString CEXTRA("CEXTRA");
if (attrs.hasAttribute(CEXTRA))
newStyle.setTracking(qRound(attrs.valueAsDouble(CEXTRA) / attrs.valueAsDouble(CSIZE) * 1000.0));
else if (attrs.hasAttribute(QLatin1String("CKERN")))
newStyle.setTracking(attrs.valueAsInt("CKERN"));
-
+
static const QString CSHADE("CSHADE");
if (attrs.hasAttribute(CSHADE))
newStyle.setFillShade(attrs.valueAsInt(CSHADE));
-
+
static const QString CSTYLE("CSTYLE");
if (attrs.hasAttribute(CSTYLE))
newStyle.setFeatures(static_cast<StyleFlag>(attrs.valueAsInt(CSTYLE)).featureList());
QString pstylename = attrs.valueAsString("PSTYLE", "");
- int calign = attrs.valueAsInt("CALIGN", -1);
-
+ int calign = attrs.valueAsInt("CALIGN", -1);
+
int ab = attrs.valueAsInt("CAB", -1);
if (ab >= 5) {
pstylename = doc->paragraphStyles()[ab-5].name();
@@ -2107,86 +2312,83 @@
pstylename = "";
calign = ab;
}
-
+
static const QString CSTROKE("CSTROKE");
if (attrs.hasAttribute(CSTROKE))
newStyle.setStrokeColor(attrs.valueAsString(CSTROKE, CommonStrings::None));
-
+
static const QString CSHADE2("CSHADE2");
if (attrs.hasAttribute(CSHADE2))
newStyle.setStrokeShade(attrs.valueAsInt(CSHADE2, 100));
-
+
static const QString CSCALE("CSCALE");
if (attrs.hasAttribute(CSCALE))
newStyle.setScaleH(qMin(qMax(qRound(attrs.valueAsDouble(CSCALE, 100.0) * 10), 100), 4000));
-
+
static const QString CSCALEV("CSCALEV");
if (attrs.hasAttribute(CSCALEV))
newStyle.setScaleV(qMin(qMax(qRound(attrs.valueAsDouble(CSCALEV, 100.0) * 10), 100), 4000));
-
+
static const QString CBASE("CBASE");
if (attrs.hasAttribute(CBASE))
newStyle.setBaselineOffset(qRound(attrs.valueAsDouble(CBASE) * 10));
-
+
static const QString CSHX("CSHX");
if (attrs.hasAttribute(CSHX))
newStyle.setShadowXOffset(qRound(attrs.valueAsDouble(CSHX, 5.0) * 10));
-
+
static const QString CSHY("CSHY");
if (attrs.hasAttribute(CSHY))
newStyle.setShadowYOffset(qRound(attrs.valueAsDouble(CSHY, -5.0) * 10));
-
+
static const QString COUT("CSHY");
if (attrs.hasAttribute(COUT))
newStyle.setOutlineWidth(qRound(attrs.valueAsDouble(COUT, 1.0) * 10));
-
+
static const QString CULP("CULP");
if (attrs.hasAttribute(CULP))
newStyle.setUnderlineOffset(qRound(attrs.valueAsDouble(CULP, -0.1) * 10));
-
+
static const QString CULW("CULW");
if (attrs.hasAttribute(CULW))
newStyle.setUnderlineWidth(qRound(attrs.valueAsDouble(CULW, -0.1) * 10));
-
+
static const QString CSTP("CSTP");
if (attrs.hasAttribute(CSTP))
newStyle.setStrikethruOffset(qRound(attrs.valueAsDouble(CSTP, -0.1) * 10));
-
+
static const QString CSTW("CSTW");
if (attrs.hasAttribute(CSTW))
newStyle.setStrikethruWidth(qRound(attrs.valueAsDouble(CSTW, -0.1) * 10));
-
+
fixLegacyCharStyle(newStyle);
-
+
if (impo && ab >= 0 && VorLFound)
last->ParaStyle = DoVorl[ab].toInt();
else
last->ParaStyle = pstylename;
// end of legacy stuff
-
+
int iobj = attrs.valueAsInt("COBJ", -1);
for (int cxx=0; cxx<tmp2.length(); ++cxx)
{
- QChar ch = tmp2.at(cxx);
+ QChar ch = tmp2.at(cxx);
{ // Legacy mode
if (ch == QChar(5))
ch = SpecialChars::PARSEP;
if (ch == QChar(4))
ch = SpecialChars::TAB;
}
-
+
int pos = obj->itemText.length();
if (ch == SpecialChars::OBJECT) {
- if (iobj >= 0) {
- if (iobj < doc->FrameItems.count())
- obj->itemText.insertObject(pos, doc->FrameItems.at(iobj));
- else
- qDebug() << QString("scribus134format: invalid inline frame used in text object : %1").arg(iobj);
+ if (iobj != -1) {
+ obj->itemText.insertObject(pos, doc->FrameItems.at(iobj));
}
}
else if (ch == SpecialChars::SHYPHEN && pos > 0)
- {
+ {/* FIXME
// qDebug() << QString("scribus134format: SHYPHEN at %1").arg(pos);
ScText* lastItem = obj->itemText.item(pos-1);
// double SHY means user provided SHY, single SHY is automatic one
@@ -2198,13 +2400,13 @@
else
{
lastItem->setEffects(lastItem->effects() | ScStyle_HyphenationPossible);
- }
+ }*/
}
else {
obj->itemText.insertChars(pos, QString(ch));
}
// qDebug() << QString("style at %1: %2 ^ %3 = %4 (%5)").arg(pos).arg((uint)newStyle.effects()).arg((uint)last->Style.effects()).arg((uint)(newStyle.effects() ^ last->Style.effects())).arg(newStyle != last->Style);
- if (newStyle != last->Style) // || (newStyle.effects() ^ last->Style.effects()) == ScStyle_HyphenationPossible)
+ if (newStyle != last->Style) // || (newStyle.effects() ^ last->Style.effects()) == ScStyle_HyphenationPossible)
{ // FIXME StyleFlag operator== ignores hyphen flag
// qDebug() << QString("new style at %1: %2 -> %3").arg(pos).arg(last->Style.asString()).arg(newStyle.asString());
obj->itemText.setCharStyle(last->StyleStart, pos-last->StyleStart, last->Style);
@@ -2249,6 +2451,7 @@
return true;
}
+
bool Scribus134Format::readPageItemAttributes(PageItem* item, ScXmlStreamReader& reader)
{
Modified: branches/ScribusOIF/scribus/plugins/fileloader/scribus134format/scribus134format_save.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/plugins/fileloader/scribus134format/scribus134format_save.cpp
==============================================================================
--- branches/ScribusOIF/scribus/plugins/fileloader/scribus134format/scribus134format_save.cpp (original)
+++ branches/ScribusOIF/scribus/plugins/fileloader/scribus134format/scribus134format_save.cpp Mon Oct 18 10:52:30 2010
@@ -965,6 +965,150 @@
} // namespace anon
+//void Scribus134Format::writeITEXTs(ScribusDoc *doc, ScXmlStreamWriter &docu, PageItem* item)
+//{
+// CharStyle lastStyle;
+// int lastPos = 0;
+// QString tmpnum;
+// for(int k = 0; k < item->itemText.length(); ++k)
+// {
+// const CharStyle& style1(item->itemText.charStyle(k));
+// const QChar ch = item->itemText.text(k);
+
+// if (ch == SpecialChars::OBJECT ||
+// ch == SpecialChars::TAB ||
+// ch == SpecialChars::PARSEP ||
+// ch == SpecialChars::LINEBREAK ||
+// ch == SpecialChars::COLBREAK ||
+// ch == SpecialChars::FRAMEBREAK ||
+// ch == SpecialChars::PAGENUMBER ||
+// ch == SpecialChars::PAGECOUNT ||
+// ch == SpecialChars::NBHYPHEN ||
+// ch == SpecialChars::NBSPACE ||
+// ch == SpecialChars::ZWNBSPACE ||
+// ch == SpecialChars::ZWSPACE ||
+// ch.unicode() < 32 ||
+// (0xd800 <= ch.unicode() && ch.unicode() < 0xe000) ||
+// ch.unicode() == 0xfffe || ch.unicode() == 0xffff ||
+// style1 != lastStyle)
+// {
+// // something new, write pending chars
+// if (k - lastPos > 0)
+// {
+// docu.writeEmptyElement("ITEXT");
+// /*if (item->asPathText()) // seems to cause problems when loading pathtext elements
+// putCStylePT(docu, lastStyle);
+// else*/
+// putCStyle(docu, lastStyle);
+// docu.writeAttribute("CH", textWithSoftHyphens(item->itemText, lastPos, k));
+// }
+// lastStyle = style1;
+// lastPos = k;
+// }
+
+// if (ch == SpecialChars::OBJECT && item->itemText.object(k) != NULL)
+// {
+// // each obj in its own ITEXT for now
+// docu.writeEmptyElement("ITEXT");
+// /*if (item->asPathText()) // seems to cause problems when loading pathtext elements
+// putCStylePT(docu, lastStyle);
+// else*/
+// putCStyle(docu, lastStyle);
+// tmpnum.setNum(ch.unicode());
+// docu.writeAttribute("Unicode", tmpnum);
+// docu.writeAttribute("COBJ", item->itemText.object(k)->ItemNr);
+// }
+// else if (ch == SpecialChars::PARSEP) // stores also the paragraphstyle for preceding chars
+// putPStyle(docu, item->itemText.paragraphStyle(k), "para");
+// else if (ch == SpecialChars::TAB)
+// {
+// docu.writeEmptyElement("tab");
+// putCStyle(docu, lastStyle);
+// }
+// else if (ch == SpecialChars::LINEBREAK)
+// docu.writeEmptyElement("breakline");
+// else if (ch == SpecialChars::COLBREAK)
+// docu.writeEmptyElement("breakcol");
+// else if (ch == SpecialChars::FRAMEBREAK)
+// docu.writeEmptyElement("breakframe");
+// else if (ch == SpecialChars::NBHYPHEN)
+// docu.writeEmptyElement("nbhyphen");
+// else if (ch == SpecialChars::NBSPACE)
+// docu.writeEmptyElement("nbspace");
+// else if (ch == SpecialChars::ZWNBSPACE)
+// docu.writeEmptyElement("zwnbspace");
+// else if (ch == SpecialChars::ZWSPACE)
+// docu.writeEmptyElement("zwspace");
+// else if (ch == SpecialChars::PAGENUMBER)
+// {
+// docu.writeEmptyElement("var");
+// docu.writeAttribute("name", "pgno");
+// putCStyle(docu, lastStyle);
+// }
+// else if (ch == SpecialChars::PAGECOUNT)
+// {
+// docu.writeEmptyElement("var");
+// docu.writeAttribute("name", "pgco");
+// putCStyle(docu, lastStyle);
+// }
+// else if (ch.unicode() < 32 ||
+// (0xd800 <= ch.unicode() && ch.unicode() < 0xe000) ||
+// ch.unicode() == 0xfffe || ch.unicode() == 0xffff)
+// {
+// docu.writeEmptyElement("ITEXT");
+// putCStyle(docu, lastStyle);
+// tmpnum.setNum(ch.unicode());
+// docu.writeAttribute("Unicode", tmpnum);
+// }
+// else
+// {
+// continue;
+// }
+// // otherwise we just wrote something special and are done with position 'k'
+// lastPos = k + 1;
+// }
+// // write pending chars
+// if ( item->itemText.length() - lastPos > 0)
+// {
+// docu.writeEmptyElement("ITEXT");
+// /*if (item->asPathText())
+// putCStylePT(docu, lastStyle);
+// else*/
+// putCStyle(docu, lastStyle);
+// docu.writeAttribute("CH", textWithSoftHyphens(item->itemText, lastPos, item->itemText.length()));
+// }
+// // paragraphstyle for trailing chars
+// if (item->itemText.length() == 0 || item->itemText.text(item->itemText.length()-1) != SpecialChars::PARSEP)
+// {
+// putPStyle(docu, item->itemText.paragraphStyle(item->itemText.length()), "trail");
+// }
+//}
+
+
+namespace { // anon
+ QString textWithSmartHyphens(StoryText& itemText, int from, int to)
+ {
+ QString result("");
+ int lastPos = from;
+ for (int i = from; i < to; ++i)
+ {
+ if (itemText.charStyle(i).effects() & ScStyle_HyphenationPossible
+ // duplicate SHYPHEN if already present to indicate a user provided SHYPHEN:
+ || itemText.text(i) == SpecialChars::SHYPHEN)
+ {
+ result += itemText.text(lastPos, i + 1 - lastPos);
+ result += SpecialChars::SHYPHEN;
+ lastPos = i+1;
+ }
+ }
+ if (lastPos < to)
+ result += itemText.text(lastPos, to - lastPos);
+ return result;
+ }
+} // namespace anon
+
+
+
void Scribus134Format::writeITEXTs(ScribusDoc *doc, ScXmlStreamWriter &docu, PageItem* item)
{
CharStyle lastStyle;
@@ -974,7 +1118,7 @@
{
const CharStyle& style1(item->itemText.charStyle(k));
const QChar ch = item->itemText.text(k);
-
+
if (ch == SpecialChars::OBJECT ||
ch == SpecialChars::TAB ||
ch == SpecialChars::PARSEP ||
@@ -987,7 +1131,7 @@
ch == SpecialChars::NBSPACE ||
ch == SpecialChars::ZWNBSPACE ||
ch == SpecialChars::ZWSPACE ||
- ch.unicode() < 32 ||
+ ch.unicode() < 32 ||
(0xd800 <= ch.unicode() && ch.unicode() < 0xe000) ||
ch.unicode() == 0xfffe || ch.unicode() == 0xffff ||
style1 != lastStyle)
@@ -999,32 +1143,29 @@
/*if (item->asPathText()) // seems to cause problems when loading pathtext elements
putCStylePT(docu, lastStyle);
else*/
- putCStyle(docu, lastStyle);
- docu.writeAttribute("CH", textWithSoftHyphens(item->itemText, lastPos, k));
+ putCStyle(docu, lastStyle);
+ docu.writeAttribute("CH", textWithSmartHyphens(item->itemText, lastPos, k));
}
lastStyle = style1;
lastPos = k;
}
- if (ch == SpecialChars::OBJECT && item->itemText.object(k) != NULL)
+ if (ch == SpecialChars::OBJECT && item->itemText.object(k).hasItem())
{
// each obj in its own ITEXT for now
docu.writeEmptyElement("ITEXT");
/*if (item->asPathText()) // seems to cause problems when loading pathtext elements
putCStylePT(docu, lastStyle);
else*/
- putCStyle(docu, lastStyle);
+ putCStyle(docu, lastStyle);
tmpnum.setNum(ch.unicode());
docu.writeAttribute("Unicode", tmpnum);
- docu.writeAttribute("COBJ", item->itemText.object(k)->ItemNr);
+ docu.writeAttribute("COBJ", item->itemText.object(k).getItem()->ItemNr);
}
else if (ch == SpecialChars::PARSEP) // stores also the paragraphstyle for preceding chars
putPStyle(docu, item->itemText.paragraphStyle(k), "para");
else if (ch == SpecialChars::TAB)
- {
docu.writeEmptyElement("tab");
- putCStyle(docu, lastStyle);
- }
else if (ch == SpecialChars::LINEBREAK)
docu.writeEmptyElement("breakline");
else if (ch == SpecialChars::COLBREAK)
@@ -1039,26 +1180,26 @@
docu.writeEmptyElement("zwnbspace");
else if (ch == SpecialChars::ZWSPACE)
docu.writeEmptyElement("zwspace");
- else if (ch == SpecialChars::PAGENUMBER)
+ else if (ch == SpecialChars::PAGENUMBER)
{
docu.writeEmptyElement("var");
docu.writeAttribute("name", "pgno");
putCStyle(docu, lastStyle);
}
- else if (ch == SpecialChars::PAGECOUNT)
+ else if (ch == SpecialChars::PAGECOUNT)
{
docu.writeEmptyElement("var");
docu.writeAttribute("name", "pgco");
putCStyle(docu, lastStyle);
}
- else if (ch.unicode() < 32 ||
+ else if (ch.unicode() < 32 ||
(0xd800 <= ch.unicode() && ch.unicode() < 0xe000) ||
ch.unicode() == 0xfffe || ch.unicode() == 0xffff)
{
docu.writeEmptyElement("ITEXT");
putCStyle(docu, lastStyle);
tmpnum.setNum(ch.unicode());
- docu.writeAttribute("Unicode", tmpnum);
+ docu.writeAttribute("Unicode", tmpnum);
}
else
{
@@ -1074,13 +1215,13 @@
/*if (item->asPathText())
putCStylePT(docu, lastStyle);
else*/
- putCStyle(docu, lastStyle);
- docu.writeAttribute("CH", textWithSoftHyphens(item->itemText, lastPos, item->itemText.length()));
+ putCStyle(docu, lastStyle);
+ docu.writeAttribute("CH", textWithSmartHyphens(item->itemText, lastPos, item->itemText.length()));
}
// paragraphstyle for trailing chars
if (item->itemText.length() == 0 || item->itemText.text(item->itemText.length()-1) != SpecialChars::PARSEP)
{
- putPStyle(docu, item->itemText.paragraphStyle(item->itemText.length()), "trail");
+ putPStyle(docu, item->itemText.paragraphStyle(item->itemText.length()), "para");
}
}
Modified: branches/ScribusOIF/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
==============================================================================
--- branches/ScribusOIF/scribus/plugins/fileloader/scribus13format/scribus13format.cpp (original)
+++ branches/ScribusOIF/scribus/plugins/fileloader/scribus13format/scribus13format.cpp Mon Oct 18 10:52:30 2010
@@ -1765,6 +1765,159 @@
return (*m_AvailableFonts)[fontname];
}
*/
+//void Scribus13Format::GetItemText(QDomElement *it, ScribusDoc *doc, PageItem* obj, LastStyles* last, bool impo, bool VorLFound)
+//{
+// ScFace dummy = ScFace::none();
+// QString tmp2, tmpf;
+// CharStyle newStyle;
+
+// tmp2 = it->attribute("CH");
+// tmp2.replace(QRegExp("\r"), QChar(13));
+// tmp2.replace(QRegExp("\n"), QChar(13));
+// tmp2.replace(QRegExp("\t"), QChar(9));
+// tmp2.replace(SpecialChars::OLD_NBHYPHEN, SpecialChars::NBHYPHEN);
+// tmp2.replace(SpecialChars::OLD_NBSPACE, SpecialChars::NBSPACE);
+// tmpf = it->attribute("CFONT", "");
+
+// if (! tmpf.isEmpty() )
+// newStyle.setFont(m_AvailableFonts->findFont(tmpf, doc));
+
+// if (it->hasAttribute("CSIZE"))
+// newStyle.setFontSize(qRound(ScCLocale::toDoubleC(it->attribute("CSIZE")) * 10));
+
+// if (it->hasAttribute("CCOLOR"))
+// newStyle.setFillColor(it->attribute("CCOLOR"));
+
+// if (it->hasAttribute("CSHADE"))
+// newStyle.setFillShade(it->attribute("CSHADE").toInt());
+
+// QString fColor = newStyle.fillColor();
+// int fShade = qRound(newStyle.fillShade());
+// handleOldColorShade(doc, fColor, fShade);
+// newStyle.setFillColor(fColor);
+// newStyle.setFillShade(fShade);
+
+// if (it->hasAttribute("CEXTRA"))
+// {
+// double cv = ScCLocale::toDoubleC(it->attribute("CEXTRA"));
+// double cs = ScCLocale::toDoubleC(it->attribute("CSIZE"));
+// newStyle.setTracking(qRound(cv / cs * 1000.0));
+// }
+// else if (it->hasAttribute("CKERN"))
+// newStyle.setTracking(it->attribute("CKERN").toInt());
+
+// if (it->hasAttribute("CSTYLE"))
+// newStyle.setFeatures(static_cast<StyleFlag>(it->attribute("CSTYLE").toInt()).featureList());
+
+// QString pstylename = it->attribute("PSTYLE", "");
+// int calign = it->attribute("CALIGN", "-1").toInt();
+
+// int ab = it->attribute("CAB", "-1").toInt();
+// if (ab >= 5) {
+// pstylename = DoVorl[ab];
+// calign = -1;
+// }
+// else if (ab >= 0) {
+// pstylename = "";
+// calign = ab;
+// }
+
+// if (it->hasAttribute("CSTROKE"))
+// newStyle.setStrokeColor(it->attribute("CSTROKE", CommonStrings::None));
+
+// if (it->hasAttribute("CSHADE2"))
+// newStyle.setStrokeShade(it->attribute("CSHADE2", "100").toInt());
+
+// QString sColor = newStyle.strokeColor();
+// int sShade = qRound(newStyle.strokeShade());
+// handleOldColorShade(doc, sColor, sShade);
+// newStyle.setStrokeColor(sColor);
+// newStyle.setStrokeShade(sShade);
+
+// if (it->hasAttribute("CSCALE"))
+// newStyle.setScaleH(qMin(qMax(qRound(ScCLocale::toDoubleC(it->attribute("CSCALE"), 100.0) * 10), 100), 4000));
+
+// if (it->hasAttribute("CSCALEV"))
+// newStyle.setScaleV(qMin(qMax(qRound(ScCLocale::toDoubleC(it->attribute("CSCALEV"), 100.0) * 10), 100), 4000));
+
+// if (it->hasAttribute("CBASE"))
+// newStyle.setBaselineOffset(qRound(ScCLocale::toDoubleC(it->attribute("CBASE"), 0.0) * 10));
+
+// if (it->hasAttribute("CSHX"))
+// newStyle.setShadowXOffset(qRound(ScCLocale::toDoubleC(it->attribute("CSHX"), 5.0) * 10));
+
+// if (it->hasAttribute("CSHY"))
+// newStyle.setShadowYOffset(qRound(ScCLocale::toDoubleC(it->attribute("CSHY"), -5.0) * 10));
+
+// if (it->hasAttribute("COUT"))
+// newStyle.setOutlineWidth(qRound(ScCLocale::toDoubleC(it->attribute("COUT"), 1.0) * 10));
+
+// if (it->hasAttribute("CULP"))
+// newStyle.setUnderlineOffset(qRound(ScCLocale::toDoubleC(it->attribute("CULP"), -0.1) * 10));
+
+// if (it->hasAttribute("CULW"))
+// newStyle.setUnderlineWidth(qRound(ScCLocale::toDoubleC(it->attribute("CULW"), -0.1) * 10));
+
+
+// if (it->hasAttribute("CSTP"))
+// newStyle.setStrikethruOffset(qRound(ScCLocale::toDoubleC(it->attribute("CSTP"), -0.1) * 10));
+
+// if (it->hasAttribute("CSTW"))
+// newStyle.setStrikethruWidth(qRound(ScCLocale::toDoubleC(it->attribute("CSTW"), -0.1) * 10));
+
+// int iobj = it->attribute("COBJ", "-1").toInt();
+// for (int cxx=0; cxx<tmp2.length(); ++cxx)
+// {
+// QChar ch = tmp2.at(cxx);
+// { // Legacy mode
+// if (ch == QChar(5))
+// ch = SpecialChars::PARSEP;
+// if (ch == QChar(4))
+// ch = SpecialChars::TAB;
+// }
+
+// if (impo && ab >= 0 && VorLFound)
+// last->ParaStyle = DoVorl[ab];
+// else
+// last->ParaStyle = pstylename;
+
+// int pos = obj->itemText.length();
+// if (ch == SpecialChars::OBJECT) {
+// if (iobj >= 0) {
+// if (iobj < doc->FrameItems.count())
+// obj->itemText.insertObject(pos, doc->FrameItems.at(iobj));
+// else
+// qDebug() << QString("scribus13format: invalid inline frame used in text object : %1").arg(iobj);
+// }
+// }
+// else {
+// obj->itemText.insertChars(pos, QString(ch));
+// }
+// if (newStyle != last->Style) {
+//// qDebug() << QString("new style at %1: %2 -> %3").arg(pos).arg(last->Style.asString()).arg(newStyle.asString();
+// obj->itemText.applyCharStyle(last->StyleStart, pos-last->StyleStart, last->Style);
+// last->Style = newStyle;
+// last->StyleStart = pos;
+// }
+// if (ch == SpecialChars::PARSEP) {
+// ParagraphStyle pstyle;
+// pstyle.setParent( last->ParaStyle );
+// if (calign >= 0)
+// pstyle.setAlignment(static_cast<ParagraphStyle::AlignmentType>(calign));
+//// qDebug() << QString("par style at %1: %2/%3 (%4) calign %5").arg(pos).arg(pstyle.name()).arg(pstyle.parent()).arg(last->ParaStyle).arg(calign);
+// obj->itemText.applyStyle(pos, pstyle);
+// }
+// }
+// obj->itemText.applyCharStyle(last->StyleStart, obj->itemText.length()-last->StyleStart, last->Style);
+// ParagraphStyle pstyle;
+// pstyle.setParent( last->ParaStyle );
+// if (calign >= 0)
+// pstyle.setAlignment(static_cast<ParagraphStyle::AlignmentType>(calign));
+//// qDebug() << QString("par style at end: %1/%2 (%3) calign %4").arg(pstyle.name()).arg(pstyle.parent()).arg(last->ParaStyle).arg(calign);
+// obj->itemText.applyStyle(obj->itemText.length()-1, pstyle);
+// //last->StyleStart = obj->itemText.length();
+//}
+
void Scribus13Format::GetItemText(QDomElement *it, ScribusDoc *doc, PageItem* obj, LastStyles* last, bool impo, bool VorLFound)
{
ScFace dummy = ScFace::none();
@@ -1784,7 +1937,7 @@
if (it->hasAttribute("CSIZE"))
newStyle.setFontSize(qRound(ScCLocale::toDoubleC(it->attribute("CSIZE")) * 10));
-
+
if (it->hasAttribute("CCOLOR"))
newStyle.setFillColor(it->attribute("CCOLOR"));
@@ -1796,7 +1949,7 @@
handleOldColorShade(doc, fColor, fShade);
newStyle.setFillColor(fColor);
newStyle.setFillShade(fShade);
-
+
if (it->hasAttribute("CEXTRA"))
{
double cv = ScCLocale::toDoubleC(it->attribute("CEXTRA"));
@@ -1805,13 +1958,13 @@
}
else if (it->hasAttribute("CKERN"))
newStyle.setTracking(it->attribute("CKERN").toInt());
-
+
if (it->hasAttribute("CSTYLE"))
newStyle.setFeatures(static_cast<StyleFlag>(it->attribute("CSTYLE").toInt()).featureList());
QString pstylename = it->attribute("PSTYLE", "");
- int calign = it->attribute("CALIGN", "-1").toInt();
-
+ int calign = it->attribute("CALIGN", "-1").toInt();
+
int ab = it->attribute("CAB", "-1").toInt();
if (ab >= 5) {
pstylename = DoVorl[ab];
@@ -1821,10 +1974,10 @@
pstylename = "";
calign = ab;
}
-
+
if (it->hasAttribute("CSTROKE"))
newStyle.setStrokeColor(it->attribute("CSTROKE", CommonStrings::None));
-
+
if (it->hasAttribute("CSHADE2"))
newStyle.setStrokeShade(it->attribute("CSHADE2", "100").toInt());
@@ -1833,13 +1986,13 @@
handleOldColorShade(doc, sColor, sShade);
newStyle.setStrokeColor(sColor);
newStyle.setStrokeShade(sShade);
-
+
if (it->hasAttribute("CSCALE"))
newStyle.setScaleH(qMin(qMax(qRound(ScCLocale::toDoubleC(it->attribute("CSCALE"), 100.0) * 10), 100), 4000));
-
+
if (it->hasAttribute("CSCALEV"))
newStyle.setScaleV(qMin(qMax(qRound(ScCLocale::toDoubleC(it->attribute("CSCALEV"), 100.0) * 10), 100), 4000));
-
+
if (it->hasAttribute("CBASE"))
newStyle.setBaselineOffset(qRound(ScCLocale::toDoubleC(it->attribute("CBASE"), 0.0) * 10));
@@ -1848,7 +2001,7 @@
if (it->hasAttribute("CSHY"))
newStyle.setShadowYOffset(qRound(ScCLocale::toDoubleC(it->attribute("CSHY"), -5.0) * 10));
-
+
if (it->hasAttribute("COUT"))
newStyle.setOutlineWidth(qRound(ScCLocale::toDoubleC(it->attribute("COUT"), 1.0) * 10));
@@ -1858,24 +2011,24 @@
if (it->hasAttribute("CULW"))
newStyle.setUnderlineWidth(qRound(ScCLocale::toDoubleC(it->attribute("CULW"), -0.1) * 10));
-
+
if (it->hasAttribute("CSTP"))
newStyle.setStrikethruOffset(qRound(ScCLocale::toDoubleC(it->attribute("CSTP"), -0.1) * 10));
-
+
if (it->hasAttribute("CSTW"))
newStyle.setStrikethruWidth(qRound(ScCLocale::toDoubleC(it->attribute("CSTW"), -0.1) * 10));
int iobj = it->attribute("COBJ", "-1").toInt();
for (int cxx=0; cxx<tmp2.length(); ++cxx)
{
- QChar ch = tmp2.at(cxx);
+ QChar ch = tmp2.at(cxx);
{ // Legacy mode
if (ch == QChar(5))
ch = SpecialChars::PARSEP;
if (ch == QChar(4))
ch = SpecialChars::TAB;
}
-
+
if (impo && ab >= 0 && VorLFound)
last->ParaStyle = DoVorl[ab];
else
@@ -1883,11 +2036,8 @@
int pos = obj->itemText.length();
if (ch == SpecialChars::OBJECT) {
- if (iobj >= 0) {
- if (iobj < doc->FrameItems.count())
- obj->itemText.insertObject(pos, doc->FrameItems.at(iobj));
- else
- qDebug() << QString("scribus13format: invalid inline frame used in text object : %1").arg(iobj);
+ if (iobj != -1) {
+ obj->itemText.insertObject(pos, doc->FrameItems.at(iobj));
}
}
else {
@@ -3318,7 +3468,339 @@
}
}
-void Scribus13Format::WriteObjects(ScribusDoc *doc, QDomDocument *docu, QDomElement *dc, const QString& baseDir,
+//void Scribus13Format::WriteObjects(ScribusDoc *doc, QDomDocument *docu, QDomElement *dc, const QString& baseDir,
+// QProgressBar *dia2, uint maxC, int master)
+//{
+// int tst, tst2, tsb, tsb2, tobj, tobj2;
+// QString text, tf, tf2, tc, tc2, tcs, tcs2, tmp, tmpy, Ndir;
+// double ts, ts2, tsc, tsc2, tscv, tscv2, tb, tb2, tsx, tsx2, tsy, tsy2, tout, tout2, tulp, tulp2, tulw, tulw2, tstp, tstp2, tstw, tstw2;
+// double te, te2, tsh, tsh2, tshs, tshs2;
+// uint ObCount = maxC;
+// PageItem *item = NULL;
+// QDomElement ob;
+// uint objects = 0;
+// switch (master)
+// {
+// case 0:
+// objects = doc->MasterItems.count();
+// break;
+// case 1:
+// objects = doc->DocItems.count();
+// break;
+// case 2:
+// objects = doc->FrameItems.count();
+// break;
+// }
+// for(uint j = 0; j < objects;++j)
+// {
+// ObCount++;
+// if (dia2 != 0)
+// dia2->setValue(ObCount);
+// switch (master)
+// {
+// case 0:
+// item = doc->MasterItems.at(j);
+// ob = docu->createElement("MASTEROBJECT");
+// break;
+// case 1:
+// item = doc->DocItems.at(j);
+// ob = docu->createElement("PAGEOBJECT");
+// break;
+// case 2:
+// item = doc->FrameItems.at(j);
+// ob = docu->createElement("FRAMEOBJECT");
+// break;
+// }
+// SetItemProps(&ob, item, baseDir, true);
+// ob.setAttribute("OnMasterPage", item->OnMasterPage);
+// ob.setAttribute("ImageClip", item->pixm.imgInfo.usedPath);
+// ob.setAttribute("ImageRes", item->pixm.imgInfo.lowResType);
+// ob.setAttribute("isInline", static_cast<int>(item->isEmbedded));
+// ob.setAttribute("fillRule", static_cast<int>(item->fillRule));
+// ob.setAttribute("doOverprint", static_cast<int>(item->doOverprint));
+// ob.setAttribute("gXpos", item->gXpos);
+// ob.setAttribute("gYpos", item->gYpos);
+// ob.setAttribute("gWidth", item->gWidth);
+// ob.setAttribute("gHeight", item->gHeight);
+// if (item->GrType != 0)
+// {
+// QList<VColorStop*> cstops = item->fill_gradient.colorStops();
+// for (uint cst = 0; cst < item->fill_gradient.Stops(); ++cst)
+// {
+// QDomElement itcl = docu->createElement("CSTOP");
+// itcl.setAttribute("RAMP", cstops.at(cst)->rampPoint);
+// itcl.setAttribute("NAME", cstops.at(cst)->name);
+// itcl.setAttribute("SHADE", cstops.at(cst)->shade);
+// itcl.setAttribute("TRANS", cstops.at(cst)->opacity);
+// ob.appendChild(itcl);
+// }
+// ob.setAttribute("GRSTARTX", item->GrStartX);
+// ob.setAttribute("GRSTARTY", item->GrStartY);
+// ob.setAttribute("GRENDX", item->GrEndX);
+// ob.setAttribute("GRENDY", item->GrEndY);
+// }
+// if (item->effectsInUse.count() != 0)
+// {
+// for (int a = 0; a < item->effectsInUse.count(); ++a)
+// {
+// QDomElement imeff = docu->createElement("ImageEffect");
+// imeff.setAttribute("Code", item->effectsInUse.at(a).effectCode);
+// imeff.setAttribute("Param", item->effectsInUse.at(a).effectParameters);
+// ob.appendChild(imeff);
+// }
+// }
+///*
+// if (item->TabValues.count() != 0)
+// {
+// for (uint a = 0; a < item->TabValues.count(); ++a)
+// {
+// QDomElement tabs = docu->createElement("Tabs");
+// tabs.setAttribute("Type", (*item->TabValues.at(a)).tabType);
+// tabs.setAttribute("Pos", (*item->TabValues.at(a)).tabPosition);
+// QString tabCh = "";
+// if (!(*item->TabValues.at(a)).tabFillChar.isNull())
+// tabCh = QString((*item->TabValues.at(a)).tabFillChar);
+// tabs.setAttribute("Fill", tabCh);
+// ob.appendChild(tabs);
+// }
+// }
+//*/
+// if (((item->asImageFrame()) || (item->asTextFrame())) && (!item->Pfile.isEmpty()) && (item->pixm.imgInfo.layerInfo.count() != 0) && (item->pixm.imgInfo.isRequest))
+// {
+// QMap<int, ImageLoadRequest>::iterator it2;
+// for (it2 = item->pixm.imgInfo.RequestProps.begin(); it2 != item->pixm.imgInfo.RequestProps.end(); ++it2)
+// {
+// QDomElement psd = docu->createElement("PSDLayer");
+// psd.setAttribute("Layer",it2.key());
+// psd.setAttribute("Visible", static_cast<int>(it2.value().visible));
+// psd.setAttribute("useMask", static_cast<int>(it2.value().useMask));
+// psd.setAttribute("Opacity", it2.value().opacity);
+// psd.setAttribute("Blend", it2.value().blend);
+// ob.appendChild(psd);
+// }
+// }
+// ob.setAttribute("ALIGN", findParagraphStyle(doc, item->itemText.defaultStyle()));
+// ob.setAttribute("BOOKMARK", item->isBookmark ? 1 : 0);
+// for(int k = 0; k < item->itemText.length(); ++k)
+// {
+// const CharStyle& style1(item->itemText.charStyle(k));
+// QChar ch = item->itemText.text(k);
+// QDomElement it=docu->createElement("ITEXT");
+// ts = style1.fontSize() / 10.0;
+// tf = style1.font().scName();
+// tc = style1.fillColor();
+// te = style1.tracking();
+// tsh = style1.fillShade();
+// tst = style1.effects() & ScStyle_UserStyles;
+//#ifndef NLS_PROTO
+// tsb = findParagraphStyle(doc, item->itemText.paragraphStyle(k));
+//#else
+// tsb = 0;
+//#endif
+// tcs = style1.strokeColor();
+// tshs = style1.strokeShade();
+// tsc = style1.scaleH() / 10.0;
+// tscv = style1.scaleV() / 10.0;
+// tb = style1.baselineOffset() / 10.0;
+// tsx = style1.shadowXOffset() / 10.0;
+// tsy = style1.shadowYOffset() / 10.0;
+// tout = style1.outlineWidth() / 10.0;
+// tulp = style1.underlineOffset() / 10.0;
+// tulw = style1.underlineWidth() / 10.0;
+// tstp = style1.strikethruOffset() / 10.0;
+// tstw = style1.strikethruWidth() / 10.0;
+//#ifndef NLS_PROTO
+// if ((ch == SpecialChars::OBJECT) && (item->itemText.item(k)->embedded.hasItem()))
+// tobj = item->itemText.item(k)->embedded.getItem()->ItemNr;
+// else
+//#endif
+// tobj = -1;
+// if (ch == SpecialChars::PARSEP)
+// text = QChar(5);
+// else if (ch == SpecialChars::TAB)
+// text = QChar(4);
+// else
+// text = ch;
+// ++k;
+// if (k == item->itemText.length())
+// {
+// it.setAttribute("CH",text);
+// it.setAttribute("CSIZE",ts);
+// it.setAttribute("CFONT",tf);
+// it.setAttribute("CCOLOR",tc);
+// it.setAttribute("CKERN",te);
+// it.setAttribute("CSHADE",tsh);
+// it.setAttribute("CSTYLE",tst);
+// it.setAttribute("CAB",tsb);
+// it.setAttribute("CSTROKE",tcs);
+// it.setAttribute("CSHADE2",tshs);
+// it.setAttribute("CSCALE",tsc);
+// it.setAttribute("CSCALEV",tscv);
+// it.setAttribute("CBASE",tb);
+// it.setAttribute("CSHX",tsx);
+// it.setAttribute("CSHY",tsy);
+// it.setAttribute("COUT",tout);
+// it.setAttribute("CULP",tulp);
+// it.setAttribute("CULW",tulw);
+// it.setAttribute("CSTP",tstp);
+// it.setAttribute("CSTW",tstw);
+// if (tobj != -1)
+// it.setAttribute("COBJ", tobj);
+// ob.appendChild(it);
+// break;
+// }
+// const CharStyle& style2(item->itemText.charStyle(k));
+// ch = item->itemText.text(k);
+// ts2 = style2.fontSize() / 10.0;
+// tf2 = style2.font().scName();
+// tc2 = style2.fillColor();
+// te2 = style2.tracking();
+// tsh2 = style2.fillShade();
+// tst2 = style2.effects() & ScStyle_UserStyles;
+//#ifndef NLS_PROTO
+// tsb2 = findParagraphStyle(doc, item->itemText.paragraphStyle(k));
+//#else
+// tsb2 = 0;
+//#endif
+// tcs2 = style2.strokeColor();
+// tshs2 = style2.strokeShade();
+// tsc2 = style2.scaleH() / 10.0;
+// tscv2 = style2.scaleV() / 10.0;
+// tb2 = style2.baselineOffset() / 10.0;
+// tsx2 = style2.shadowXOffset() / 10.0;
+// tsy2 = style2.shadowYOffset() / 10.0;
+// tout2 = style2.outlineWidth() / 10.0;
+// tulp2 = style2.underlineOffset() / 10.0;
+// tulw2 = style2.underlineWidth() / 10.0;
+// tstp2 = style2.strikethruOffset() / 10.0;
+// tstw2 = style2.strikethruWidth() / 10.0;
+//#ifndef NLS_PROTO
+// if ((ch == SpecialChars::OBJECT) && (item->itemText.item(k)->embedded.hasItem()))
+// tobj2 = item->itemText.item(k)->embedded.getItem()->ItemNr;
+// else
+//#endif
+// tobj2 = -1;
+// while ((ts2 == ts)
+// && (tsb2 == tsb)
+// && (tf2 == tf)
+// && (tc2 == tc)
+// && (te2 == te)
+// && (tsh2 == tsh)
+// && (tshs2 == tshs)
+// && (tsc2 == tsc)
+// && (tscv2 == tscv)
+// && (tcs2 == tcs)
+// && (tb2 == tb)
+// && (tsx2 == tsx)
+// && (tsy2 == tsy)
+// && (tout2 == tout)
+// && (tulp2 == tulp)
+// && (tulw2 == tulw)
+// && (tstp2 == tstp)
+// && (tstw2 == tstw)
+// && (tobj2 == tobj)
+// && (tst2 == tst))
+// {
+// if (ch == SpecialChars::PARSEP)
+// text += QChar(5);
+// else if (ch == SpecialChars::TAB)
+// text += QChar(4);
+// else
+// text += ch;
+// ++k;
+// if (k == item->itemText.length())
+// break;
+// const CharStyle& style3(item->itemText.charStyle(k));
+// ch = item->itemText.text(k);
+// ts2 = style3.fontSize() / 10.0;
+// tf2 = style3.font().scName();
+// tc2 = style3.fillColor();
+// te2 = style3.tracking();
+// tsh2 = style3.fillShade();
+// tst2 = style3.effects() & ScStyle_UserStyles;
+//#ifndef NLS_PROTO
+// tsb2 = findParagraphStyle(doc, item->itemText.paragraphStyle(k));
+//#else
+// tsb2 = 0;
+//#endif
+// tcs2 = style3.strokeColor();
+// tshs2 = style3.strokeShade();
+// tsc2 = style3.scaleH() / 10.0;
+// tscv2 = style3.scaleV() / 10.0;
+// tb2 = style3.baselineOffset() / 10.0;
+// tsx2 = style3.shadowXOffset() / 10.0;
+// tsy2 = style3.shadowYOffset() / 10.0;
+// tout2 = style3.outlineWidth() / 10.0;
+// tulp2 = style3.underlineOffset() / 10.0;
+// tulw2 = style3.underlineWidth() / 10.0;
+// tstp2 = style3.strikethruOffset() / 10.0;
+// tstw2 = style3.strikethruWidth() / 10.0;
+//#ifndef NLS_PROTO
+// if ((ch == SpecialChars::OBJECT) && (item->itemText.item(k)->embedded.hasItem()))
+// tobj2 = item->itemText.item(k)->embedded.getItem()->ItemNr;
+// else
+//#endif
+// tobj2 = -1;
+// }
+// it.setAttribute("CH",text);
+// it.setAttribute("CSIZE",ts);
+// it.setAttribute("CFONT",tf);
+// it.setAttribute("CCOLOR",tc);
+// it.setAttribute("CKERN",te);
+// it.setAttribute("CSHADE",tsh);
+// it.setAttribute("CSTYLE",tst);
+// it.setAttribute("CAB",tsb);
+// it.setAttribute("CSTROKE",tcs);
+// it.setAttribute("CSHADE2",tshs);
+// it.setAttribute("CSCALE",tsc);
+// it.setAttribute("CSCALEV",tscv);
+// it.setAttribute("CBASE",tb);
+// it.setAttribute("CSHX",tsx);
+// it.setAttribute("CSHY",tsy);
+// it.setAttribute("COUT",tout);
+// it.setAttribute("CULP",tulp);
+// it.setAttribute("CULW",tulw);
+// it.setAttribute("CSTP",tstp);
+// it.setAttribute("CSTW",tstw);
+// if (tobj != -1)
+// it.setAttribute("COBJ", tobj);
+// k--;
+// ob.appendChild(it);
+// }
+// if (item->prevInChain() != 0)
+// ob.setAttribute("BACKITEM", item->prevInChain()->ItemNr);
+// else
+// ob.setAttribute("BACKITEM", -1);
+// if (item->nextInChain() != 0)
+// ob.setAttribute("NEXTITEM", item->nextInChain()->ItemNr);
+// else
+// ob.setAttribute("NEXTITEM", -1);
+// ob.setAttribute("LAYER", item->LayerID);
+
+// //CB PageItemAttributes
+// QDomElement docItemAttrs = docu->createElement("PageItemAttributes");
+// ObjAttrVector *attributes=item->getObjectAttributes();
+// for(ObjAttrVector::Iterator objAttrIt = attributes->begin() ; objAttrIt != attributes->end(); ++objAttrIt )
+// {
+// QDomElement itemAttr = docu->createElement("ItemAttribute");
+// itemAttr.setAttribute("Name", (*objAttrIt).name);
+// itemAttr.setAttribute("Type", (*objAttrIt).type);
+// itemAttr.setAttribute("Value", (*objAttrIt).value);
+// itemAttr.setAttribute("Parameter", (*objAttrIt).parameter);
+// itemAttr.setAttribute("Relationship", (*objAttrIt).relationship);
+// itemAttr.setAttribute("RelationshipTo", (*objAttrIt).relationshipto);
+// itemAttr.setAttribute("AutoAddTo", (*objAttrIt).autoaddto);
+// docItemAttrs.appendChild(itemAttr);
+// }
+// ob.appendChild(docItemAttrs);
+
+// dc->appendChild(ob);
+// }
+//}
+
+
+
+void Scribus13Format::WriteObjects(ScribusDoc *doc, QDomDocument *docu, QDomElement *dc, const QString& baseDir,
QProgressBar *dia2, uint maxC, int master)
{
int tst, tst2, tsb, tsb2, tobj, tobj2;
@@ -3460,8 +3942,14 @@
tstp = style1.strikethruOffset() / 10.0;
tstw = style1.strikethruWidth() / 10.0;
#ifndef NLS_PROTO
- if ((ch == SpecialChars::OBJECT) && (item->itemText.item(k)->embedded.hasItem()))
- tobj = item->itemText.item(k)->embedded.getItem()->ItemNr;
+ if (ch == SpecialChars::OBJECT)
+ {
+ PageItem* inlineFrame = item->itemText.object(k).getItem();
+ if (inlineFrame != NULL)
+ tobj = inlineFrame->ItemNr;
+ else
+ tobj = -1;
+ }
else
#endif
tobj = -1;
@@ -3525,8 +4013,14 @@
tstp2 = style2.strikethruOffset() / 10.0;
tstw2 = style2.strikethruWidth() / 10.0;
#ifndef NLS_PROTO
- if ((ch == SpecialChars::OBJECT) && (item->itemText.item(k)->embedded.hasItem()))
- tobj2 = item->itemText.item(k)->embedded.getItem()->ItemNr;
+ if (ch == SpecialChars::OBJECT)
+ {
+ PageItem* inlineF2 = item->itemText.object(k).getItem();
+ if (inlineF2 != NULL)
+ tobj2 = inlineF2->ItemNr;
+ else
+ tobj2 = -1;
+ }
else
#endif
tobj2 = -1;
@@ -3586,8 +4080,14 @@
tstp2 = style3.strikethruOffset() / 10.0;
tstw2 = style3.strikethruWidth() / 10.0;
#ifndef NLS_PROTO
- if ((ch == SpecialChars::OBJECT) && (item->itemText.item(k)->embedded.hasItem()))
- tobj2 = item->itemText.item(k)->embedded.getItem()->ItemNr;
+ if (ch == SpecialChars::OBJECT)
+ {
+ PageItem* inlineFr = item->itemText.object(k).getItem();
+ if (inlineFr != NULL)
+ tobj2 = inlineFr->ItemNr;
+ else
+ tobj2 = -1;
+ }
else
#endif
tobj2 = -1;
Modified: branches/ScribusOIF/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- branches/ScribusOIF/scribus/plugins/fileloader/scribus150format/scribus150format.cpp (original)
+++ branches/ScribusOIF/scribus/plugins/fileloader/scribus150format/scribus150format.cpp Mon Oct 18 10:52:30 2010
@@ -2164,12 +2164,18 @@
return success;
}
+/// Replace it with NTE and see
+//bool Scribus150Format::readItemText(PageItem *obj, ScXmlStreamAttributes& attrs, LastStyles* last)
+
+// fixLegacyCharStyle(newStyle);
+// last->ParaStyle = pstyl
+
bool Scribus150Format::readItemText(PageItem *obj, ScXmlStreamAttributes& attrs, LastStyles* last)
{
QString tmp2;
CharStyle newStyle;
ScribusDoc* doc = obj->doc();
-
+
readCharacterStyleAttrs(doc, attrs, newStyle);
if (attrs.hasAttribute(QLatin1String("Unicode")))
@@ -2179,43 +2185,40 @@
else
{
tmp2 = attrs.valueAsString("CH");
-
+
// legacy stuff:
tmp2.replace(QRegExp("\r"), QChar(13));
tmp2.replace(QRegExp("\n"), QChar(13));
tmp2.replace(QRegExp("\t"), QChar(9));
}
-
+
// more legacy stuff:
- QString pstylename = attrs.valueAsString("PSTYLE", "");
+ QString pstylename = attrs.valueAsString("PSTYLE", "");
fixLegacyCharStyle(newStyle);
last->ParaStyle = pstylename;
// end of legacy stuff
-
+
int iobj = attrs.valueAsInt("COBJ", -1);
for (int cxx=0; cxx<tmp2.length(); ++cxx)
{
- QChar ch = tmp2.at(cxx);
+ QChar ch = tmp2.at(cxx);
{ // Legacy mode
if (ch == QChar(5))
ch = SpecialChars::PARSEP;
if (ch == QChar(4))
ch = SpecialChars::TAB;
}
-
+
int pos = obj->itemText.length();
if (ch == SpecialChars::OBJECT) {
- if (iobj >= 0) {
- if (iobj < doc->FrameItems.count())
- obj->itemText.insertObject(pos, doc->FrameItems.at(iobj));
- else
- qDebug() << QString("scribus150format: invalid inline frame used in text object : %1").arg(iobj);
+ if (iobj != -1) {
+ obj->itemText.insertObject(pos, doc->FrameItems.at(iobj));
}
}
else if (ch == SpecialChars::SHYPHEN && pos > 0)
- {
+ { /*FIXME
// qDebug() << QString("scribus150format: SHYPHEN at %1").arg(pos);
ScText* lastItem = obj->itemText.item(pos-1);
// double SHY means user provided SHY, single SHY is automatic one
@@ -2227,13 +2230,13 @@
else
{
lastItem->setEffects(lastItem->effects() | ScStyle_HyphenationPossible);
- }
+ }*/
}
else {
obj->itemText.insertChars(pos, QString(ch));
}
// qDebug() << QString("style at %1: %2 ^ %3 = %4 (%5)").arg(pos).arg((uint)newStyle.effects()).arg((uint)last->Style.effects()).arg((uint)(newStyle.effects() ^ last->Style.effects())).arg(newStyle != last->Style);
- if (newStyle != last->Style) // || (newStyle.effects() ^ last->Style.effects()) == ScStyle_HyphenationPossible)
+ if (newStyle != last->Style) // || (newStyle.effects() ^ last->Style.effects()) == ScStyle_HyphenationPossible)
{ // FIXME StyleFlag operator== ignores hyphen flag
// qDebug() << QString("new style at %1: %2 -> %3").arg(pos).arg(last->Style.asString()).arg(newStyle.asString());
obj->itemText.setCharStyle(last->StyleStart, pos-last->StyleStart, last->Style);
@@ -2271,6 +2274,7 @@
return true;
}
+
bool Scribus150Format::readPageItemAttributes(PageItem* item, ScXmlStreamReader& reader)
{
Modified: branches/ScribusOIF/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
==============================================================================
--- branches/ScribusOIF/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp (original)
+++ branches/ScribusOIF/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp Mon Oct 18 10:52:30 2010
@@ -991,6 +991,150 @@
} // namespace anon
+//void Scribus150Format::writeITEXTs(ScribusDoc *doc, ScXmlStreamWriter &docu, PageItem* item)
+//{
+// CharStyle lastStyle;
+// int lastPos = 0;
+// QString tmpnum;
+// for(int k = 0; k < item->itemText.length(); ++k)
+// {
+// const CharStyle& style1(item->itemText.charStyle(k));
+// const QChar ch = item->itemText.text(k);
+
+// if (ch == SpecialChars::OBJECT ||
+// ch == SpecialChars::TAB ||
+// ch == SpecialChars::PARSEP ||
+// ch == SpecialChars::LINEBREAK ||
+// ch == SpecialChars::COLBREAK ||
+// ch == SpecialChars::FRAMEBREAK ||
+// ch == SpecialChars::PAGENUMBER ||
+// ch == SpecialChars::PAGECOUNT ||
+// ch == SpecialChars::NBHYPHEN ||
+// ch == SpecialChars::NBSPACE ||
+// ch == SpecialChars::ZWNBSPACE ||
+// ch == SpecialChars::ZWSPACE ||
+// ch.unicode() < 32 ||
+// (0xd800 <= ch.unicode() && ch.unicode() < 0xe000) ||
+// ch.unicode() == 0xfffe || ch.unicode() == 0xffff ||
+// style1 != lastStyle)
+// {
+// // something new, write pending chars
+// if (k - lastPos > 0)
+// {
+// docu.writeEmptyElement("ITEXT");
+// /*if (item->asPathText()) // seems to cause problems when loading pathtext elements
+// putCStylePT(docu, lastStyle);
+// else*/
+// putCStyle(docu, lastStyle);
+// docu.writeAttribute("CH", textWithSoftHyphens(item->itemText, lastPos, k));
+// }
+// lastStyle = style1;
+// lastPos = k;
+// }
+
+// if (ch == SpecialChars::OBJECT && item->itemText.object(k) != NULL)
+// {
+// // each obj in its own ITEXT for now
+// docu.writeEmptyElement("ITEXT");
+// /*if (item->asPathText()) // seems to cause problems when loading pathtext elements
+// putCStylePT(docu, lastStyle);
+// else*/
+// putCStyle(docu, lastStyle);
+// tmpnum.setNum(ch.unicode());
+// docu.writeAttribute("Unicode", tmpnum);
+// docu.writeAttribute("COBJ", item->itemText.object(k)->ItemNr);
+// }
+// else if (ch == SpecialChars::PARSEP) // stores also the paragraphstyle for preceding chars
+// putPStyle(docu, item->itemText.paragraphStyle(k), "para");
+// else if (ch == SpecialChars::TAB)
+// {
+// docu.writeEmptyElement("tab");
+// putCStyle(docu, lastStyle);
+// }
+// else if (ch == SpecialChars::LINEBREAK)
+// docu.writeEmptyElement("breakline");
+// else if (ch == SpecialChars::COLBREAK)
+// docu.writeEmptyElement("breakcol");
+// else if (ch == SpecialChars::FRAMEBREAK)
+// docu.writeEmptyElement("breakframe");
+// else if (ch == SpecialChars::NBHYPHEN)
+// docu.writeEmptyElement("nbhyphen");
+// else if (ch == SpecialChars::NBSPACE)
+// docu.writeEmptyElement("nbspace");
+// else if (ch == SpecialChars::ZWNBSPACE)
+// docu.writeEmptyElement("zwnbspace");
+// else if (ch == SpecialChars::ZWSPACE)
+// docu.writeEmptyElement("zwspace");
+// else if (ch == SpecialChars::PAGENUMBER)
+// {
+// docu.writeEmptyElement("var");
+// docu.writeAttribute("name", "pgno");
+// putCStyle(docu, lastStyle);
+// }
+// else if (ch == SpecialChars::PAGECOUNT)
+// {
+// docu.writeEmptyElement("var");
+// docu.writeAttribute("name", "pgco");
+// putCStyle(docu, lastStyle);
+// }
+// else if (ch.unicode() < 32 ||
+// (0xd800 <= ch.unicode() && ch.unicode() < 0xe000) ||
+// ch.unicode() == 0xfffe || ch.unicode() == 0xffff)
+// {
+// docu.writeEmptyElement("ITEXT");
+// putCStyle(docu, lastStyle);
+// tmpnum.setNum(ch.unicode());
+// docu.writeAttribute("Unicode", tmpnum);
+// }
+// else
+// {
+// continue;
+// }
+// // otherwise we just wrote something special and are done with position 'k'
+// lastPos = k + 1;
+// }
+// // write pending chars
+// if ( item->itemText.length() - lastPos > 0)
+// {
+// docu.writeEmptyElement("ITEXT");
+// /*if (item->asPathText())
+// putCStylePT(docu, lastStyle);
+// else*/
+// putCStyle(docu, lastStyle);
+// docu.writeAttribute("CH", textWithSoftHyphens(item->itemText, lastPos, item->itemText.length()));
+// }
+// // paragraphstyle for trailing chars
+// if (item->itemText.length() == 0 || item->itemText.text(item->itemText.length()-1) != SpecialChars::PARSEP)
+// {
+// putPStyle(docu, item->itemText.paragraphStyle(item->itemText.length()), "trail");
+// }
+//}
+
+
+namespace { // anon
+ QString textWithSmartHyphens(StoryText& itemText, int from, int to)
+ {
+ QString result("");
+ int lastPos = from;
+ for (int i = from; i < to; ++i)
+ {
+ if (itemText.charStyle(i).effects() & ScStyle_HyphenationPossible
+ // duplicate SHYPHEN if already present to indicate a user provided SHYPHEN:
+ || itemText.text(i) == SpecialChars::SHYPHEN)
+ {
+ result += itemText.text(lastPos, i + 1 - lastPos);
+ result += SpecialChars::SHYPHEN;
+ lastPos = i+1;
+ }
+ }
+ if (lastPos < to)
+ result += itemText.text(lastPos, to - lastPos);
+ return result;
+ }
+} // namespace anon
+
+
+
void Scribus150Format::writeITEXTs(ScribusDoc *doc, ScXmlStreamWriter &docu, PageItem* item)
{
CharStyle lastStyle;
@@ -1000,7 +1144,7 @@
{
const CharStyle& style1(item->itemText.charStyle(k));
const QChar ch = item->itemText.text(k);
-
+
if (ch == SpecialChars::OBJECT ||
ch == SpecialChars::TAB ||
ch == SpecialChars::PARSEP ||
@@ -1013,7 +1157,7 @@
ch == SpecialChars::NBSPACE ||
ch == SpecialChars::ZWNBSPACE ||
ch == SpecialChars::ZWSPACE ||
- ch.unicode() < 32 ||
+ ch.unicode() < 32 ||
(0xd800 <= ch.unicode() && ch.unicode() < 0xe000) ||
ch.unicode() == 0xfffe || ch.unicode() == 0xffff ||
style1 != lastStyle)
@@ -1026,13 +1170,13 @@
putCStylePT(docu, lastStyle);
else*/
putCStyle(docu, lastStyle);
- docu.writeAttribute("CH", textWithSoftHyphens(item->itemText, lastPos, k));
+ docu.writeAttribute("CH", textWithSmartHyphens(item->itemText, lastPos, k));
}
lastStyle = style1;
lastPos = k;
}
- if (ch == SpecialChars::OBJECT && item->itemText.object(k) != NULL)
+ if (ch == SpecialChars::OBJECT && item->itemText.object(k).hasItem())
{
// each obj in its own ITEXT for now
docu.writeEmptyElement("ITEXT");
@@ -1042,15 +1186,12 @@
putCStyle(docu, lastStyle);
tmpnum.setNum(ch.unicode());
docu.writeAttribute("Unicode", tmpnum);
- docu.writeAttribute("COBJ", item->itemText.object(k)->ItemNr);
+ docu.writeAttribute("COBJ", item->itemText.object(k).getItem()->ItemNr);
}
else if (ch == SpecialChars::PARSEP) // stores also the paragraphstyle for preceding chars
putPStyle(docu, item->itemText.paragraphStyle(k), "para");
else if (ch == SpecialChars::TAB)
- {
docu.writeEmptyElement("tab");
- putCStyle(docu, lastStyle);
- }
else if (ch == SpecialChars::LINEBREAK)
docu.writeEmptyElement("breakline");
else if (ch == SpecialChars::COLBREAK)
@@ -1065,26 +1206,26 @@
docu.writeEmptyElement("zwnbspace");
else if (ch == SpecialChars::ZWSPACE)
docu.writeEmptyElement("zwspace");
- else if (ch == SpecialChars::PAGENUMBER)
+ else if (ch == SpecialChars::PAGENUMBER)
{
docu.writeEmptyElement("var");
docu.writeAttribute("name", "pgno");
putCStyle(docu, lastStyle);
}
- else if (ch == SpecialChars::PAGECOUNT)
+ else if (ch == SpecialChars::PAGECOUNT)
{
docu.writeEmptyElement("var");
docu.writeAttribute("name", "pgco");
putCStyle(docu, lastStyle);
}
- else if (ch.unicode() < 32 ||
+ else if (ch.unicode() < 32 ||
(0xd800 <= ch.unicode() && ch.unicode() < 0xe000) ||
ch.unicode() == 0xfffe || ch.unicode() == 0xffff)
{
docu.writeEmptyElement("ITEXT");
putCStyle(docu, lastStyle);
tmpnum.setNum(ch.unicode());
- docu.writeAttribute("Unicode", tmpnum);
+ docu.writeAttribute("Unicode", tmpnum);
}
else
{
@@ -1101,7 +1242,7 @@
putCStylePT(docu, lastStyle);
else*/
putCStyle(docu, lastStyle);
- docu.writeAttribute("CH", textWithSoftHyphens(item->itemText, lastPos, item->itemText.length()));
+ docu.writeAttribute("CH", textWithSmartHyphens(item->itemText, lastPos, item->itemText.length()));
}
// paragraphstyle for trailing chars
if (item->itemText.length() == 0 || item->itemText.text(item->itemText.length()-1) != SpecialChars::PARSEP)
@@ -1109,6 +1250,7 @@
putPStyle(docu, item->itemText.paragraphStyle(item->itemText.length()), "trail");
}
}
+
void Scribus150Format::WriteObjects(ScribusDoc *doc, ScXmlStreamWriter& docu, const QString& baseDir, QProgressBar *dia2, uint maxC, ItemSelection master, QList<PageItem*> *some_items)
{
Modified: branches/ScribusOIF/scribus/plugins/scriptplugin/cmdtext.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/plugins/scriptplugin/cmdtext.cpp
==============================================================================
--- branches/ScribusOIF/scribus/plugins/scriptplugin/cmdtext.cpp (original)
+++ branches/ScribusOIF/scribus/plugins/scriptplugin/cmdtext.cpp Mon Oct 18 10:52:30 2010
@@ -99,7 +99,7 @@
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get number of lines of non-text frame.","python error").toLocal8Bit().constData());
return NULL;
}
- return PyInt_FromLong(static_cast<long>(i->itemText.lines()));
+ return PyInt_FromLong(static_cast<long>(i->textLayout->lines()));
}
PyObject *scribus_getcolumns(PyObject* /* self */, PyObject* args)
@@ -682,10 +682,20 @@
if (it->HasSel)
{
if (it->itemText.selected(b))
- it->itemText.item(b)->setFillColor(QString::fromUtf8(Color));
+ {
+ CharStyle tmpCS(it->itemText.charStyle(b));
+ tmpCS.setFillColor(QString::fromUtf8(Color));
+ it->itemText.setCharStyle(b, 1, tmpCS);
+// it->itemText.item(b)->setFillColor(QString::fromUtf8(Color));
+ }
}
else
- it->itemText.item(b)->setFillColor(QString::fromUtf8(Color));
+ {
+ CharStyle tmpCS(it->itemText.charStyle(b));
+ tmpCS.setFillColor(QString::fromUtf8(Color));
+ it->itemText.setCharStyle(b, 1, tmpCS);
+// it->itemText.item(b)->setFillColor(QString::fromUtf8(Color));
+ }
}
// it->TxtFill = QString::fromUtf8(Color);
}
@@ -718,10 +728,20 @@
if (it->HasSel)
{
if (it->itemText.selected(b))
- it->itemText.item(b)->setStrokeColor(QString::fromUtf8(Color));
+ {
+ CharStyle tmpCS(it->itemText.charStyle(b));
+ tmpCS.setStrokeColor(QString::fromUtf8(Color));
+ it->itemText.setCharStyle(b, 1, tmpCS);
+// it->itemText.item(b)->setStrokeColor(QString::fromUtf8(Color));
+ }
}
else
- it->itemText.item(b)->setStrokeColor(QString::fromUtf8(Color));
+ {
+ CharStyle tmpCS(it->itemText.charStyle(b));
+ tmpCS.setStrokeColor(QString::fromUtf8(Color));
+ it->itemText.setCharStyle(b, 1, tmpCS);
+// it->itemText.item(b)->setStrokeColor(QString::fromUtf8(Color));
+ }
}
// it->TxtStroke = QString::fromUtf8(Color);
}
@@ -831,10 +851,20 @@
if (it->HasSel)
{
if (it->itemText.selected(b))
- it->itemText.item(b)->setFillShade(w);
+ {
+ CharStyle tmpCS(it->itemText.charStyle(b));
+ tmpCS.setFillShade(w);
+ it->itemText.setCharStyle(b, 1, tmpCS);
+// it->itemText.item(b)->setFillShade(w);
+ }
}
else
- it->itemText.item(b)->setFillShade(w);
+ {
+ CharStyle tmpCS(it->itemText.charStyle(b));
+ tmpCS.setFillShade(w);
+ it->itemText.setCharStyle(b, 1, tmpCS);
+// it->itemText.item(b)->setFillShade(w);
+ }
}
// it->ShTxtFill = w;
}
Modified: branches/ScribusOIF/scribus/plugins/scriptplugin/cmdutil.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/plugins/scriptplugin/cmdutil.cpp
==============================================================================
--- branches/ScribusOIF/scribus/plugins/scriptplugin/cmdutil.cpp (original)
+++ branches/ScribusOIF/scribus/plugins/scriptplugin/cmdutil.cpp Mon Oct 18 10:52:30 2010
@@ -82,10 +82,17 @@
for (int d = 0; d < ite->itemText.length(); d++)
{
//FIXME:NLS that should work on runs
+ CharStyle tmpCS(ite->itemText.charStyle(d));
if (col == ite->itemText.charStyle(d).fillColor())
- ite->itemText.item(d)->setFillColor(rep);
+ {
+ tmpCS.setFillColor(rep);
+ ite->itemText.setCharStyle(d, 1, tmpCS);
+ }
if (col == ite->itemText.charStyle(d).strokeColor())
- ite->itemText.item(d)->setStrokeColor(rep);
+ {
+ tmpCS.setStrokeColor(rep);
+ ite->itemText.setCharStyle(d, 1, tmpCS);
+ }
}
}
if (col == ite->fillColor())
@@ -111,10 +118,17 @@
for (int d = 0; d < ite->itemText.length(); d++)
{
//FIXME: NLS this should work on runs
+ CharStyle tmpCS(ite->itemText.charStyle(d));
if (col == ite->itemText.charStyle(d).fillColor())
- ite->itemText.item(d)->setFillColor(rep);
+ {
+ tmpCS.setFillColor(rep);
+ ite->itemText.setCharStyle(d, 1, tmpCS);
+ }
if (col == ite->itemText.charStyle(d).strokeColor())
- ite->itemText.item(d)->setStrokeColor(rep);
+ {
+ tmpCS.setStrokeColor(rep);
+ ite->itemText.setCharStyle(d, 1, tmpCS);
+ }
}
}
if (col == ite->fillColor())
Modified: branches/ScribusOIF/scribus/plugins/svgexplugin/svgexplugin.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/plugins/svgexplugin/svgexplugin.cpp
==============================================================================
--- branches/ScribusOIF/scribus/plugins/svgexplugin/svgexplugin.cpp (original)
+++ branches/ScribusOIF/scribus/plugins/svgexplugin/svgexplugin.cpp Mon Oct 18 10:52:30 2010
@@ -715,6 +715,7 @@
QDomElement SVGExPlug::processTextItem(PageItem *Item, QString trans, QString fill, QString stroke)
{
+#if 0 // FIXME_OIF
QDomElement ob;
ob = docu.createElement("g");
ob.setAttribute("transform", trans);
@@ -944,10 +945,12 @@
}
}
return ob;
+#endif
}
QDomElement SVGExPlug::processPathTextItem(PageItem *Item, QString trans, QString stroke)
{
+#if 0 // FIXME_OIF
QDomElement ob;
ob = docu.createElement("g");
ob.setAttribute("transform", trans);
@@ -1188,10 +1191,12 @@
}
}
return ob;
+#endif
}
QDomElement SVGExPlug::processInlineItem(double xpos, double ypos, QTransform &finalMat, ScText *hl, bool pathT, QString trans)
{
+#if 0 // FIXME_OIF
const CharStyle & charStyle(*hl);
QList<PageItem*> emG = hl->embedded.getGroupedItems();
QStack<PageItem*> groupStack;
@@ -1322,10 +1327,12 @@
}
}
return layerGroup;
+#endif
}
QString SVGExPlug::handleGlyph(uint chr, ScText *hl)
{
+#if 0 // FIXME_OIF
if (chr == 32)
return "SPACE";
QString glName = QString("Gl%1%2").arg(hl->font().psName().simplified().replace(QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )).arg(chr);
@@ -1339,6 +1346,7 @@
globalDefs.appendChild(ob);
glyphNames.append(glName);
return glName;
+#endif
}
QDomElement SVGExPlug::processArrows(PageItem *Item, QDomElement line, QString trans)
Modified: branches/ScribusOIF/scribus/pslib.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/pslib.cpp
==============================================================================
--- branches/ScribusOIF/scribus/pslib.cpp (original)
+++ branches/ScribusOIF/scribus/pslib.cpp Mon Oct 18 10:52:30 2010
@@ -2216,6 +2216,8 @@
}
}
#ifndef NLS_PROTO
+#if 0 // FIXME_OIF
+
for (d = c->firstInFrame(); d <= c->lastInFrame(); ++d)
{
hl = c->itemText.item(d);
@@ -2645,6 +2647,7 @@
}
}
#endif
+#endif
break;
case PageItem::Symbol:
if (m_Doc->docPatterns.contains(c->pattern()))
@@ -4235,6 +4238,7 @@
void PSLib::setTextSt(ScribusDoc* Doc, PageItem* ite, bool gcr, uint argh, Page* pg, bool sep, bool farb, bool ic, bool master)
{
+#if 0 // FIXME_OIF
// qDebug() << QString("pslib setTextSt: ownPage=%1 pageNr=%2 OnMasterPage=%3;").arg(ite->OwnPage).arg(pg->pageNr()).arg(ite->OnMasterPage);
int tabCc = 0;
int savedOwnPage = ite->OwnPage;
@@ -4355,10 +4359,12 @@
}
}
#endif
+#endif
}
void PSLib::setTextCh(ScribusDoc* Doc, PageItem* ite, double x, double y, bool gcr, uint argh, uint doh, ScText *hl, const ParagraphStyle& pstyle, Page* pg, bool sep, bool farb, bool ic, bool master)
{
+#if 0 // FIXME_OIF
const CharStyle & cstyle(*hl);
const GlyphLayout & glyphs(hl->glyph);
uint glyph = glyphs.glyph;
@@ -4715,6 +4721,7 @@
}
}
}*/
+#endif
}
void PSLib::putColor(const QString& colorName, double shade, bool fill)
Modified: branches/ScribusOIF/scribus/scpageoutput.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/scpageoutput.cpp
==============================================================================
--- branches/ScribusOIF/scribus/scpageoutput.cpp (original)
+++ branches/ScribusOIF/scribus/scpageoutput.cpp Mon Oct 18 10:52:30 2010
@@ -488,6 +488,7 @@
void ScPageOutput::drawGlyphs(PageItem* item, ScPainterExBase *painter, const CharStyle& style, GlyphLayout& glyphs, const QRect& clip)
{
+#if 0 //FIXME_OIF
uint glyph = glyphs.glyph;
if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode())) // NBSPACE
glyph = style.font().char2CMap(QChar(' '));
@@ -637,6 +638,7 @@
painter->translate(glyphs.xadvance, 0);
drawGlyphs(item, painter, style, *glyphs.more, clip);
}
+#endif
}
void ScPageOutput::drawItem_Embedded( PageItem* item, ScPainterExBase *p, const QRect& clip, const CharStyle& style, PageItem* cembedded)
@@ -991,6 +993,7 @@
void ScPageOutput::drawItem_PathText( PageItem_PathText* item, ScPainterExBase* painter, const QRect& clip )
{
+#if 0 //FIXME_OIF
QString chstr, chstr2, chstr3;
ScText *hl;
FPoint point = FPoint(0, 0);
@@ -1171,6 +1174,7 @@
else
CurX += hl->glyph.wide()+hl->fontSize() * hl->tracking() / 10000.0 + extraOffset;
}
+#endif
}
void ScPageOutput::drawItem_Polygon ( PageItem_Polygon* item , ScPainterExBase* painter, const QRect& clip )
@@ -1285,6 +1289,7 @@
void ScPageOutput::drawItem_TextFrame( PageItem_TextFrame* item, ScPainterExBase* painter, const QRect& clip )
{
+#if 0 //FIXME_OIF
QTransform wm;
QPoint pt1, pt2;
FPoint ColBound;
@@ -1410,6 +1415,7 @@
}
}
painter->restore();
+#endif
}
void ScPageOutput::drawArrow(ScPainterExBase* painter, PageItem* item, QTransform &arrowTrans, int arrowIndex)
Modified: branches/ScribusOIF/scribus/scribusdoc.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/scribusdoc.cpp
==============================================================================
--- branches/ScribusOIF/scribus/scribusdoc.cpp (original)
+++ branches/ScribusOIF/scribus/scribusdoc.cpp Mon Oct 18 10:52:30 2010
@@ -6715,10 +6715,14 @@
{
if (currItem->itemText.selected(a))
{
- StyleFlag fl = currItem->itemText.item(a)->effects();
+// StyleFlag fl = currItem->itemText.item(a)->effects();
+ CharStyle tmpCS(currItem->itemText.charStyle(a));
+ StyleFlag fl = tmpCS.effects();
fl &= static_cast<StyleFlag>(~1919); // 0x11101111111
fl |= static_cast<StyleFlag>(s & 1919);
- currItem->itemText.item(a)->setFeatures(fl.featureList());
+ tmpCS.setFeatures(fl.featureList());
+ currItem->itemText.setCharStyle(a, 1, tmpCS);
+// currItem->itemText.item(a)->setFeatures(fl.featureList());
}
}
}
@@ -6726,10 +6730,16 @@
{
for (int a = 0; a < currItem->itemText.length(); ++a)
{
- StyleFlag fl = currItem->itemText.item(a)->effects();
- fl &= static_cast<StyleFlag>(~1919); // 1024+512+256+64+32+16+8+4+2+1
+// StyleFlag fl = currItem->itemText.item(a)->effects();
+// fl &= static_cast<StyleFlag>(~1919); // 1024+512+256+64+32+16+8+4+2+1
+// fl |= static_cast<StyleFlag>(s & 1919);
+// currItem->itemText.item(a)->setFeatures(fl.featureList());
+ CharStyle tmpCS(currItem->itemText.charStyle(a));
+ StyleFlag fl = tmpCS.effects();
+ fl &= static_cast<StyleFlag>(~1919); // 0x11101111111
fl |= static_cast<StyleFlag>(s & 1919);
- currItem->itemText.item(a)->setFeatures(fl.featureList());
+ tmpCS.setFeatures(fl.featureList());
+ currItem->itemText.setCharStyle(a, 1, tmpCS);
}
}
#endif
@@ -6823,8 +6833,8 @@
int currItemTextCount = currItem->itemText.length();
if ((currItemTextCount > 0) && (appMode == modeEdit))
{
- int start = currItem->itemText.startOfItem(currItem->firstInFrame());
- int stop = currItem->itemText.endOfItem(currItem->lastInFrame());
+ int start = currItem->firstInFrame();
+ int stop = currItem->lastInFrame()+1;
if (appMode == modeEdit)
{
start = currItem->itemText.startOfSelection();
@@ -6877,8 +6887,8 @@
int currItemTextCount = currItem->itemText.length();
if ((currItemTextCount > 0) && (appMode == modeEdit))
{
- int start = currItem->itemText.startOfItem(currItem->firstInFrame());
- int stop = currItem->itemText.endOfItem(currItem->lastInFrame());
+ int start = currItem->firstInFrame();
+ int stop = currItem->lastInFrame()+1;
if (appMode == modeEdit)
{
start = currItem->itemText.startOfSelection();
@@ -6941,8 +6951,8 @@
}
if (currItemTextCount > 0)
{
- int start = currItem->asPathText() ? currItem->itemText.startOfItem(currItem->firstInFrame()) : 0;
- int stop = currItem->asPathText() ? currItem->itemText.endOfItem(currItem->lastInFrame()) : currItemTextCount;
+ int start = currItem->asPathText() ? currItem->firstInFrame() : 0;
+ int stop = currItem->asPathText() ? currItem->lastInFrame()+1 : currItemTextCount;
if (appMode == modeEdit)
{
start = currItem->itemText.startOfSelection();
@@ -6992,8 +7002,8 @@
int currItemTextCount = currItem->itemText.length();
if ((currItemTextCount > 0) && (appMode == modeEdit))
{
- int start = currItem->itemText.startOfItem(currItem->firstInFrame());
- int length = currItem->itemText.endOfItem(currItem->lastInFrame()) - start;
+ int start = currItem->firstInFrame();
+ int length = currItem->lastInFrame() + 1 - start;
if (appMode == modeEdit)
{
if (currItem->itemText.lengthOfSelection() > 0)
@@ -7051,8 +7061,8 @@
int currItemTextCount = currItem->itemText.length();
if ((currItemTextCount > 0) && (appMode == modeEdit))
{
- int start = currItem->itemText.startOfItem(currItem->firstInFrame());
- int length = currItem->itemText.endOfItem(currItem->lastInFrame()) - start;
+ int start = currItem->firstInFrame();
+ int length = currItem->lastInFrame() + 1 - start;
if (appMode == modeEdit)
{
if (currItem->itemText.lengthOfSelection() > 0)
@@ -7109,8 +7119,8 @@
int currItemTextCount = currItem->itemText.length();
if ((currItemTextCount > 0) && (appMode == modeEdit))
{
- int start = currItem->itemText.startOfItem(currItem->firstInFrame());
- int length = currItem->itemText.endOfItem(currItem->lastInFrame()) - start;
+ int start = currItem->firstInFrame();
+ int length = currItem->lastInFrame() + 1 - start;
if (appMode == modeEdit)
{
if (currItem->itemText.lengthOfSelection() > 0)
@@ -11409,8 +11419,12 @@
if ((bb->itemText.length() != 0) && (!bb->isTableItem))
{
// bb->setLineSpacing(((bb->fontSize() / 10.0) * static_cast<double>(Doc->typographicSettings.autoLineSpacing) / 100) + (bb->fontSize() / 10.0));
+ CharStyle cs;
for (aa = 0; aa < bb->itemText.length(); ++aa)
- bb->itemText.item(aa)->setFontSize(qMax(qRound(bb->itemText.item(aa)->fontSize()*((scx+scy)/2)), 1));
+ {
+ cs.setFontSize(qMax(qRound(bb->itemText.charStyle(aa).fontSize()*((scx+scy)/2)), 1));
+ bb->itemText.applyCharStyle(aa, 1, cs);
+ }
if (bb->asPathText())
bb->updatePolyClip();
}
Modified: branches/ScribusOIF/scribus/scribusview.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/scribusview.cpp
==============================================================================
--- branches/ScribusOIF/scribus/scribusview.cpp (original)
+++ branches/ScribusOIF/scribus/scribusview.cpp Mon Oct 18 10:52:30 2010
@@ -1665,13 +1665,13 @@
{ //handle Right to Left writing
FPoint point(currItem->width()-(pf.x() - currItem->xPos()), pf.y() - currItem->yPos());
currItem->CPos = currItem->itemText.length() == 0 ? 0 :
- currItem->itemText.screenToPosition(point);
+ /*currItem->itemText.screenToPosition(point)*/ currItem->textLayout->screenToPosition(point);
}
else
{
FPoint point(pf.x() - currItem->xPos(), pf.y() - currItem->yPos());
currItem->CPos = currItem->itemText.length() == 0 ? 0 :
- currItem->itemText.screenToPosition(point);
+ /*currItem->itemText.screenToPosition(point)*/ currItem->textLayout->screenToPosition(point);
}
if (currItem->itemText.length() > 0)
@@ -3488,6 +3488,7 @@
void ScribusView::TextToPath()
{
+#if 0 // FIXME_OIF
#ifndef NLS_PROTO
if (Doc->appMode == modeEditClip)
requestMode(submodeEndNodeEdit);
@@ -4169,6 +4170,7 @@
trans.commit();
}
#endif
+#endif
}
void ScribusView::keyPressEvent(QKeyEvent *k)
Modified: branches/ScribusOIF/scribus/sctextstruct.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/sctextstruct.cpp
==============================================================================
--- branches/ScribusOIF/scribus/sctextstruct.cpp (original)
+++ branches/ScribusOIF/scribus/sctextstruct.cpp Mon Oct 18 10:52:30 2010
@@ -7,18 +7,13 @@
#include <QObject>
#include <QList>
+#include <QMatrix>
#include <QPointer>
+
#include "sctextstruct.h"
-#include "scfonts.h"
+
#include "pageitem.h"
#include "scribusdoc.h"
-
-void GlyphLayout::growWithTabLayout()
-{
- if (more)
- shrink();
- more = new TabLayout();
-}
struct InlineFrameData
{
@@ -43,6 +38,7 @@
return refs == 0;
}
};
+
InlineFrame::InlineFrame(PageItem* item)
{
@@ -119,18 +115,3 @@
}
return result;
}
-
-
-ScText::~ScText()
-{
- // delete the linked list if present
- GlyphLayout * more = glyph.more;
- while (more) {
- glyph.more = glyph.more->more;
- delete more;
- more = glyph.more;
- }
- if (parstyle)
- delete parstyle;
- parstyle = NULL;
-}
Modified: branches/ScribusOIF/scribus/sctextstruct.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/sctextstruct.h
==============================================================================
--- branches/ScribusOIF/scribus/sctextstruct.h (original)
+++ branches/ScribusOIF/scribus/sctextstruct.h Mon Oct 18 10:52:30 2010
@@ -20,6 +20,7 @@
#define NLS_PRIVATE public
#endif
+#include <QFlags>
#include <QString>
#include "scfonts.h"
@@ -28,6 +29,7 @@
#include "styles/paragraphstyle.h"
class PageItem;
+class ScPainterExBase;
/* Struktur fuer Pageitem Text */
@@ -41,62 +43,24 @@
*
*/
-
-
/**
- * This struct stores a positioned glyph. This is the result of the layout process.
- * If a char gets translated to more than one glyph, a linked list is built.
+ * This enum is used for storing layout attributes that used to be stored
+ * in StyleFlag.
*/
-struct SCRIBUS_API GlyphLayout {
- float xadvance;
- float yadvance;
- float xoffset;
- float yoffset;
- double scaleV;
- double scaleH;
- uint glyph;
- GlyphLayout* more;
-
- GlyphLayout() : xadvance(0.0f), yadvance(0.0f), xoffset(0.0f), yoffset(0.0f),
- scaleV(1.0), scaleH(1.0), glyph(0), more(NULL)
- { }
- virtual ~GlyphLayout()
- { }
- double wide() const
- {
- double ret = 0;
- for(const GlyphLayout* p=this; p; p=p->more)
- ret += p->xadvance;
- return ret;
- }
- GlyphLayout* last()
- {
- if (more)
- return more->last();
- else
- return this;
- }
- void shrink()
- {
- if (more) {
- more->shrink();
- delete more;
- more = NULL;
- }
- }
- void grow()
- {
- if (!more) {
- more = new GlyphLayout();
- }
- }
- virtual void growWithTabLayout();
+enum TextFlag {
+ TextFlag_None = 0,
+ TextFlag_HyphenationPossible = 1,
+ TextFlag_SmartHyphenVisible = 2,
+ TextFlag_DropCap = 4,
+ TextFlag_SuppressSpace = 8,
+ TextFlag_StartOfLine = 16,
+ TextFlag_ClusterStart = 32,
+ TextFlag_WordBoundary = 64,
};
-struct SCRIBUS_API TabLayout : public GlyphLayout
-{
- QChar fillChar;
-};
+Q_DECLARE_FLAGS(TextFlags, TextFlag)
+Q_DECLARE_OPERATORS_FOR_FLAGS(TextFlags)
+
struct InlineFrameData;
@@ -116,44 +80,18 @@
InlineFrameData* d;
};
-
-#ifndef NLS_PROTO
-class SCRIBUS_API ScText : public CharStyle
+struct PathData
{
-public:
- ParagraphStyle* parstyle; // only for parseps
- GlyphLayout glyph;
float PtransX;
float PtransY;
float PRot;
- float PDx;
- InlineFrame embedded;
- QChar ch;
- ScText() :
- CharStyle(),
- parstyle(NULL), glyph(),
- PtransX(0.0f), PtransY(0.0f), PRot(0.0f), PDx(0.0f), embedded(NULL), ch() {}
- ScText(const ScText& other) :
- CharStyle(other),
- parstyle(NULL), glyph(other.glyph),
- PtransX(other.PtransX), PtransY(other.PtransY), PRot(other.PRot), PDx(other.PDx),
- embedded(other.embedded), ch(other.ch)
- {
- glyph.more = NULL;
- GlyphLayout *layout = &glyph;
- const GlyphLayout *otherLayout = &other.glyph;
- while (otherLayout->more)
- {
- layout->more = new GlyphLayout(*otherLayout->more);
- layout = layout->more;
- otherLayout = otherLayout->more;
- }
- if (other.parstyle)
- parstyle = new ParagraphStyle(*other.parstyle);
- }
- ~ScText();
+ float PDx;
+
+ PathData() : PtransX(0.0f), PtransY(0.0f), PRot(0.0f), PDx(0.0f) {}
+ PathData(const PathData& other) : PtransX(other.PtransX), PtransY(other.PtransY), PRot(other.PRot), PDx(other.PDx) {}
};
-#endif
+
+
/** @brief First Line Offset Policy
Modified: branches/ScribusOIF/scribus/text/CMakeLists.txt
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/text/CMakeLists.txt
==============================================================================
--- branches/ScribusOIF/scribus/text/CMakeLists.txt (original)
+++ branches/ScribusOIF/scribus/text/CMakeLists.txt Mon Oct 18 10:52:30 2010
@@ -4,15 +4,20 @@
${FREETYPE_INCLUDE_DIRS}
)
-
SET(SCRIBUS_TEXT_MOC_CLASSES
storytext.h
)
SET(SCRIBUS_TEXT_LIB_SOURCES
+boxes.cpp
+glyphlayout.cpp
+glyphstore.cpp
+index.cpp
+legacylayout.cpp
specialchars.cpp
storytext.cpp
-sctext_shared.cpp
+storytext_shared.cpp
+textlayout.cpp
fsize.cpp
frect.cpp
)
Modified: branches/ScribusOIF/scribus/text/sctext_shared.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/text/sctext_shared.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/sctext_shared.cpp (original)
+++ branches/ScribusOIF/scribus/text/sctext_shared.cpp Mon Oct 18 10:52:30 2010
@@ -1,10 +1,3 @@
-/*
-For general Scribus (>=1.3.2) copyright and licensing information please refer
-to the COPYING file provided with the program. Following this notice may exist
-a copyright and/or license notice that predates the release of Scribus 1.3.2
-for which a new license (GPL+exception) is in place.
-*/
-
#include <cassert> //added to make Fedora-5 happy
//#include <QDebug>
Modified: branches/ScribusOIF/scribus/text/specialchars.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/text/specialchars.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/specialchars.cpp (original)
+++ branches/ScribusOIF/scribus/text/specialchars.cpp Mon Oct 18 10:52:30 2010
@@ -24,6 +24,9 @@
#include "specialchars.h"
QChar SpecialChars::OBJECT = QChar(25);
+QChar SpecialChars::START_TAG = QChar(1);
+QChar SpecialChars::END_TAG = QChar(2);
+QChar SpecialChars::EMPTY_TAG = QChar(3);
QChar SpecialChars::TAB = QChar(9);
QChar SpecialChars::PARSEP = QChar(13);
QChar SpecialChars::LINEBREAK = QChar(28);
@@ -39,6 +42,111 @@
QChar SpecialChars::PAGENUMBER = QChar(30);
QChar SpecialChars::PAGECOUNT = QChar(23);
QChar SpecialChars::BLANK = QChar(32); // SPACE is some macro on my machine - av
+
+SpecialChars::SymbolGlyphs SpecialChars::symbols;
+
+SpecialChars::SymbolGlyphs::SymbolGlyphs() : Return(), NewLine(), Tab(), NonBreak(), NewCol(), NewFrame()
+{
+ Return.resize(0);
+ Return.addQuadPoint(1.98438, 9.14062, 1.98438, 9.14062, 1.98438, 4.03125, 1.98438, 4.03125);
+ Return.addQuadPoint(1.98438, 4.03125, 1.98438, 4.03125, 0.546875, 3.45312, 1.09375, 4);
+ Return.addQuadPoint(0.546875, 3.45312, 0.546875, 3.45312, 0, 2.0625, 0, 2.92188);
+ Return.addQuadPoint(0, 2.0625, 0, 2.0625, 0.65625, 0.5, 0, 1.04688);
+ Return.addQuadPoint(0.65625, 0.5, 0.65625, 0.5, 2.3125, 0, 1.28125, 0);
+ Return.addQuadPoint(2.3125, 0, 2.3125, 0, 5.40625, 0, 5.40625, 0);
+ Return.addQuadPoint(5.40625, 0, 5.40625, 0, 5.40625, 0.84375, 5.40625, 0.84375);
+ Return.addQuadPoint(5.40625, 0.84375, 5.40625, 0.84375, 4.70312, 0.84375, 4.70312, 0.84375);
+ Return.addQuadPoint(4.70312, 0.84375, 4.70312, 0.84375, 4.70312, 9.14062, 4.70312, 9.14062);
+ Return.addQuadPoint(4.70312, 9.14062, 4.70312, 9.14062, 3.875, 9.14062, 3.875, 9.14062);
+ Return.addQuadPoint(3.875, 9.14062, 3.875, 9.14062, 3.875, 0.84375, 3.875, 0.84375);
+ Return.addQuadPoint(3.875, 0.84375, 3.875, 0.84375, 2.78125, 0.84375, 2.78125, 0.84375);
+ Return.addQuadPoint(2.78125, 0.84375, 2.78125, 0.84375, 2.78125, 9.14062, 2.78125, 9.14062);
+ Return.addQuadPoint(2.78125, 9.14062, 2.78125, 9.14062, 1.98438, 9.14062, 1.98438, 9.14062);
+ NewLine.resize(0);
+ NewLine.addQuadPoint(6.51562, 2.625, 6.51562, 2.625, 0.90625, 2.64062, 0.90625, 2.64062);
+ NewLine.addQuadPoint(0.90625, 2.64062, 0.90625, 2.64062, 1.4375, 1.92188, 1.26562, 2.1875);
+ NewLine.addQuadPoint(1.4375, 1.92188, 1.4375, 1.92188, 1.76562, 1.14062, 1.75, 1.42188);
+ NewLine.addQuadPoint(1.76562, 1.14062, 1.76562, 1.14062, 1.60938, 1.03125, 1.60938, 1.03125);
+ NewLine.addQuadPoint(1.60938, 1.03125, 1.60938, 1.03125, 0.90625, 1.92188, 0.90625, 1.92188);
+ NewLine.addQuadPoint(0.90625, 1.92188, 0.90625, 1.92188, 0, 2.90625, 0.578125, 2.23438);
+ NewLine.addQuadPoint(0, 2.90625, 0, 2.90625, 0.75, 3.875, 0.75, 3.875);
+ NewLine.addQuadPoint(0.75, 3.875, 0.75, 3.875, 1.57812, 4.78125, 1.1875, 4.40625);
+ NewLine.addQuadPoint(1.57812, 4.78125, 1.57812, 4.78125, 1.65625, 4.79688, 1.65625, 4.79688);
+ NewLine.addQuadPoint(1.65625, 4.79688, 1.65625, 4.79688, 1.76562, 4.65625, 1.76562, 4.65625);
+ NewLine.addQuadPoint(1.76562, 4.65625, 1.76562, 4.65625, 0.90625, 3.17188, 1.73438, 4.34375);
+ NewLine.addQuadPoint(0.90625, 3.17188, 0.90625, 3.17188, 0.96875, 3.125, 0.96875, 3.125);
+ NewLine.addQuadPoint(0.96875, 3.125, 0.96875, 3.125, 6.75, 3.125, 6.75, 3.125);
+ NewLine.addQuadPoint(6.75, 3.125, 6.75, 3.125, 6.51562, 2.625, 6.51562, 2.625);
+ NewLine.addQuadPoint(6.51562, 2.625, 6.51562, 2.625, 6.51562, 2.625, 6.51562, 2.625);
+ NewLine.addQuadPoint(999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999);
+ NewLine.addQuadPoint(6.875, 0, 6.875, 0, 6.51562, 0, 6.51562, 0);
+ NewLine.addQuadPoint(6.51562, 0, 6.51562, 0, 6.51562, 2.84375, 6.51562, 2.84375);
+ NewLine.addQuadPoint(6.51562, 2.84375, 6.51562, 2.84375, 6.75, 3.125, 6.51562, 3.125);
+ NewLine.addQuadPoint(6.75, 3.125, 6.75, 3.125, 6.85938, 3.0625, 6.85938, 3.0625);
+ NewLine.addQuadPoint(6.85938, 3.0625, 6.85938, 3.0625, 6.875, 0, 6.875, 0);
+ Tab.resize(0);
+ Tab.addQuadPoint(4.82812, 3.96875, 4.82812, 3.96875, 4.5625, 3.73438, 4.5625, 3.96875);
+ Tab.addQuadPoint(4.5625, 3.73438, 4.5625, 3.73438, 5.07812, 3.10938, 4.5625, 3.57812);
+ Tab.addQuadPoint(5.07812, 3.10938, 5.07812, 3.10938, 0, 3.10938, 0, 3.10938);
+ Tab.addQuadPoint(0, 3.10938, 0, 3.10938, 0, 2.625, 0, 2.625);
+ Tab.addQuadPoint(0, 2.625, 0, 2.625, 5.53125, 2.625, 5.53125, 2.625);
+ Tab.addQuadPoint(5.53125, 2.625, 5.53125, 2.625, 6.3125, 1.8125, 6.3125, 1.8125);
+ Tab.addQuadPoint(6.3125, 1.8125, 6.3125, 1.8125, 5.64062, 1.29688, 5.64062, 1.29688);
+ Tab.addQuadPoint(5.64062, 1.29688, 5.64062, 1.29688, 0, 1.29688, 0, 1.29688);
+ Tab.addQuadPoint(0, 1.29688, 0, 1.29688, 0, 0.8125, 0, 0.8125);
+ Tab.addQuadPoint(0, 0.8125, 0, 0.8125, 5.01562, 0.8125, 5.01562, 0.8125);
+ Tab.addQuadPoint(5.01562, 0.8125, 5.01562, 0.8125, 4.45312, 0.265625, 4.45312, 0.453125);
+ Tab.addQuadPoint(4.45312, 0.265625, 4.45312, 0.265625, 4.6875, 0, 4.45312, 0);
+ Tab.addQuadPoint(4.6875, 0, 4.6875, 0, 5.90625, 0.828125, 4.875, 0);
+ Tab.addQuadPoint(5.90625, 0.828125, 5.90625, 0.828125, 6.9375, 1.79688, 6.9375, 1.64062);
+ Tab.addQuadPoint(6.9375, 1.79688, 6.9375, 1.79688, 5.95312, 2.96875, 6.9375, 1.95312);
+ Tab.addQuadPoint(5.95312, 2.96875, 5.95312, 2.96875, 4.82812, 3.96875, 4.98438, 3.96875);
+ NonBreak.resize(0);
+ NonBreak.addQuadPoint(1.32812, 2.59375, 1.32812, 2.59375, 0.390625, 2.21875, 0.796875, 2.59375);
+ NonBreak.addQuadPoint(0.390625, 2.21875, 0.390625, 2.21875, 0, 1.3125, 0, 1.84375);
+ NonBreak.addQuadPoint(0, 1.3125, 0, 1.3125, 0.390625, 0.390625, 0, 0.765625);
+ NonBreak.addQuadPoint(0.390625, 0.390625, 0.390625, 0.390625, 1.32812, 0, 0.796875, 0);
+ NonBreak.addQuadPoint(1.32812, 0, 1.32812, 0, 2.23438, 0.390625, 1.85938, 0);
+ NonBreak.addQuadPoint(2.23438, 0.390625, 2.23438, 0.390625, 2.60938, 1.29688, 2.60938, 0.765625);
+ NonBreak.addQuadPoint(2.60938, 1.29688, 2.60938, 1.29688, 2.23438, 2.21875, 2.60938, 1.84375);
+ NonBreak.addQuadPoint(2.23438, 2.21875, 2.23438, 2.21875, 1.32812, 2.59375, 1.875, 2.59375);
+ NewCol.resize(0);
+ NewCol.addQuadPoint(1.73438, 0, 1.73438, 0, 2.67188, 0.109375, 2.03125, 0);
+ NewCol.addQuadPoint(2.67188, 0.109375, 2.67188, 0.109375, 3.59375, 0.203125, 3.26562, 0.21875);
+ NewCol.addQuadPoint(3.59375, 0.203125, 3.59375, 0.203125, 3.79688, 0.1875, 3.64062, 0.203125);
+ NewCol.addQuadPoint(3.79688, 0.1875, 3.79688, 0.1875, 4, 0.171875, 3.92188, 0.171875);
+ NewCol.addQuadPoint(4, 0.171875, 4, 0.171875, 4.20312, 0.1875, 4.20312, 0.1875);
+ NewCol.addQuadPoint(4.20312, 0.1875, 4.20312, 0.1875, 4.3125, 1.39062, 4.20312, 0.5625);
+ NewCol.addQuadPoint(4.3125, 1.39062, 4.3125, 1.39062, 4.42188, 2.64062, 4.42188, 2.21875);
+ NewCol.addQuadPoint(4.42188, 2.64062, 4.42188, 2.64062, 4.28125, 2.73438, 4.28125, 2.73438);
+ NewCol.addQuadPoint(4.28125, 2.73438, 4.28125, 2.73438, 3.75, 1.03125, 4.01562, 2.64062);
+ NewCol.addQuadPoint(3.75, 1.03125, 3.75, 1.03125, 3.67188, 1.03125, 3.67188, 1.03125);
+ NewCol.addQuadPoint(3.67188, 1.03125, 3.67188, 1.03125, 0.28125, 6.20312, 0.28125, 6.20312);
+ NewCol.addQuadPoint(0.28125, 6.20312, 0.28125, 6.20312, 0, 5.95312, 0.03125, 6.17188);
+ NewCol.addQuadPoint(0, 5.95312, 0, 5.95312, 3.35938, 0.71875, 3.35938, 0.71875);
+ NewCol.addQuadPoint(3.35938, 0.71875, 3.35938, 0.71875, 3.375, 0.640625, 3.375, 0.640625);
+ NewCol.addQuadPoint(3.375, 0.640625, 3.375, 0.640625, 2.4375, 0.484375, 2.79688, 0.5625);
+ NewCol.addQuadPoint(2.4375, 0.484375, 2.4375, 0.484375, 1.67188, 0.140625, 1.71875, 0.328125);
+ NewCol.addQuadPoint(1.67188, 0.140625, 1.67188, 0.140625, 1.73438, 0, 1.73438, 0);
+ NewFrame.resize(0);
+ NewFrame.addQuadPoint(1.75, 6.20312, 1.75, 6.20312, 2.67188, 6.09375, 2.0625, 6.20312);
+ NewFrame.addQuadPoint(2.67188, 6.09375, 2.67188, 6.09375, 3.60938, 5.98438, 3.28125, 5.98438);
+ NewFrame.addQuadPoint(3.60938, 5.98438, 3.60938, 5.98438, 3.84375, 6.01562, 3.6875, 5.98438);
+ NewFrame.addQuadPoint(3.84375, 6.01562, 3.84375, 6.01562, 4.07812, 6.03125, 4, 6.03125);
+ NewFrame.addQuadPoint(4.07812, 6.03125, 4.07812, 6.03125, 4.20312, 6.01562, 4.20312, 6.01562);
+ NewFrame.addQuadPoint(4.20312, 6.01562, 4.20312, 6.01562, 4.32812, 4.79688, 4.21875, 5.625);
+ NewFrame.addQuadPoint( 4.32812, 4.79688, 4.32812, 4.79688, 4.42188, 3.5625, 4.42188, 3.98438);
+ NewFrame.addQuadPoint(4.42188, 3.5625, 4.42188, 3.5625, 4.29688, 3.45312, 4.29688, 3.45312);
+ NewFrame.addQuadPoint(4.29688, 3.45312, 4.29688, 3.45312, 3.75, 5.17188, 4.03125, 3.54688);
+ NewFrame.addQuadPoint(3.75, 5.17188, 3.75, 5.17188, 3.67188, 5.17188, 3.67188, 5.17188);
+ NewFrame.addQuadPoint(3.67188, 5.17188, 3.67188, 5.17188, 0.28125, 0, 0.28125, 0);
+ NewFrame.addQuadPoint(0.28125, 0, 0.28125, 0, 0, 0.25, 0.03125, 0.015625);
+ NewFrame.addQuadPoint(0, 0.25, 0, 0.25, 3.375, 5.46875, 3.375, 5.46875);
+ NewFrame.addQuadPoint(3.375, 5.46875, 3.375, 5.46875, 3.39062, 5.54688, 3.39062, 5.54688);
+ NewFrame.addQuadPoint(3.39062, 5.54688, 3.39062, 5.54688, 2.4375, 5.70312, 2.8125, 5.625);
+ NewFrame.addQuadPoint(2.4375, 5.70312, 2.4375, 5.70312, 1.67188, 6.0625, 1.71875, 5.875);
+ NewFrame.addQuadPoint(1.67188, 6.0625, 1.67188, 6.0625, 1.75, 6.20312, 1.75, 6.20312);
+}
bool SpecialChars::isBreakingSpace(QChar c)
Modified: branches/ScribusOIF/scribus/text/specialchars.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/text/specialchars.h
==============================================================================
--- branches/ScribusOIF/scribus/text/specialchars.h (original)
+++ branches/ScribusOIF/scribus/text/specialchars.h Mon Oct 18 10:52:30 2010
@@ -28,10 +28,16 @@
#include <QString>
#include "scribusapi.h"
+#include "fpointarray.h"
+
+
class SCRIBUS_API SpecialChars {
public:
static QChar OBJECT;
+ static QChar START_TAG;
+ static QChar END_TAG;
+ static QChar EMPTY_TAG;
static QChar TAB;
static QChar PARSEP;
static QChar LINEBREAK;
@@ -51,6 +57,21 @@
static bool isBreak(QChar c, bool includeColBreak = true);
static bool isBreakingSpace(QChar c);
static bool isExpandingSpace(QChar c);
+
+ class SymbolGlyphs
+ {
+ friend class SpecialChars;
+ SymbolGlyphs();
+ public:
+ FPointArray Return;
+ FPointArray NewLine;
+ FPointArray Tab;
+ FPointArray NonBreak;
+ FPointArray NewCol;
+ FPointArray NewFrame;
+ };
+
+ static SymbolGlyphs symbols;
};
Modified: branches/ScribusOIF/scribus/text/storytext.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/text/storytext.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/storytext.cpp (original)
+++ branches/ScribusOIF/scribus/text/storytext.cpp Mon Oct 18 10:52:30 2010
@@ -28,7 +28,8 @@
#include "fpoint.h"
#include "scfonts.h"
#include "scribusdoc.h"
-#include "sctext_shared.h"
+#include "glyphstore.h"
+#include "storytext_shared.h"
#include "storytext.h"
#include "scribus.h"
#include "util.h"
@@ -40,57 +41,33 @@
StoryText::StoryText(ScribusDoc * doc_) : doc(doc_)
{
- if (doc_) {
- d = new ScText_Shared(&doc_->paragraphStyles());
- doc->paragraphStyles().connect(this, SLOT(invalidateAll()));
- doc->charStyles().connect(this, SLOT(invalidateAll()));
- }
- else {
- d = new ScText_Shared(NULL);
- }
+ data = new Storytext_Shared();
+ data->setDocument(doc_);
+ m_glyphStore = new GlyphStore(this);
selFirst = 0;
selLast = -1;
-
- firstFrameItem = 0;
- lastFrameItem = -1;
- m_magicX = 0.0;
- m_lastMagicPos = -1;
-
- d->len = 0;
+
invalidateAll();
}
StoryText::StoryText() : doc(NULL)
{
- d = new ScText_Shared(NULL);
+ data = new Storytext_Shared();
+ m_glyphStore = new GlyphStore(this);
selFirst = 0;
selLast = -1;
- firstFrameItem = 0;
- lastFrameItem = -1;
- m_magicX = 0.0;
- m_lastMagicPos = -1;
-}
-
-StoryText::StoryText(const StoryText & other) : QObject(), SaxIO(), doc(other.doc)
-{
- d = other.d;
- d->refs++;
-
- if(doc) {
- doc->paragraphStyles().connect(this, SLOT(invalidateAll()));
- doc->charStyles().connect(this, SLOT(invalidateAll()));
- }
+}
+
+StoryText::StoryText(const StoryText & other) : QObject(), SaxIO()
+{
+ data = other.data;
+ m_glyphStore = new GlyphStore(this);
selFirst = 0;
selLast = -1;
- firstFrameItem = 0;
- lastFrameItem = -1;
- m_magicX = 0.0;
- m_lastMagicPos = -1;
-
invalidateLayout();
}
@@ -104,40 +81,19 @@
doc->paragraphStyles().disconnect(this, SLOT(invalidateAll()));
doc->charStyles().disconnect(this, SLOT(invalidateAll()));
} */
- d->refs--;
- if (d->refs == 0) {
- d->clear();
- d->len = 0;
- delete d;
- }
}
StoryText StoryText::copy() const
{
- StoryText result(doc);
- *(result.d) = *d;
+ StoryText result(*this);
+ result.data.detach();
return result;
-// qDebug() << QString("StoryText::copy:");
- QListIterator<ScText*> it( *(result.d) );
- ScText* elem;
- while ( it.hasNext() ) {
- elem = it.next();
-// qDebug() << QString("\tchar '%1' size %2 (orig %3)").arg(elem->ch).arg(elem->fontSize()).arg(charStyle(i++).fontSize());
- }
-
- return result;
}
StoryText& StoryText::operator= (const StoryText & other)
{
- other.d->refs++;
-
- d->refs--;
- if (d->refs == 0) {
- clear();
- delete d;
- }
+ data = other.data;
if(doc) {
doc->paragraphStyles().disconnect(this, SLOT(invalidateAll()));
@@ -145,7 +101,7 @@
}
doc = other.doc;
- d = other.d;
+ data = other.data;
if (doc) {
doc->paragraphStyles().connect(this, SLOT(invalidateAll()));
@@ -155,9 +111,6 @@
selFirst = 0;
selLast = -1;
- firstFrameItem = 0;
- lastFrameItem = -1;
-
invalidateLayout();
return *this;
}
@@ -168,14 +121,7 @@
selFirst = 0;
selLast = -1;
- firstFrameItem = 0;
- lastFrameItem = -1;
-
- d->defaultStyle.erase();
- d->trailingStyle.erase();
-
- d->clear();
- d->len = 0;
+ data->clear();
invalidateAll();
}
@@ -185,6 +131,13 @@
if (pos < 0)
pos += length()+1;
+ int otherStart = onlySelection? other.startOfSelection() : 0;
+ int otherEnd = onlySelection? other.endOfSelection() : other.length();
+
+
+ data->insert(pos, *other.data, otherStart, otherEnd);
+
+ /*
CharStyle cstyle(charStyle(pos));
ParagraphStyle pstyle(paragraphStyle(pos));
@@ -202,7 +155,7 @@
continue;
int len = i - cstyleStart;
if (len > 0) {
- insertCharsWithSoftHyphens(pos, other.textWithSoftHyphens(cstyleStart, len));
+ insertCharsWithSmartHyphens(pos, other.textWithSmartHyphens(cstyleStart, len));
applyCharStyle(pos, len, otherDefault.charStyle());
applyCharStyle(pos, len, cstyle);
pos += len;
@@ -217,7 +170,7 @@
}
else if (other.text(i) == SpecialChars::OBJECT) {
insertChars(pos, SpecialChars::OBJECT);
- item(pos)->embedded = other.item(i)->embedded;
+ // item(pos)->embedded = other.item(i)->embedded;
cstyleStart = i+1;
pos += 1;
}
@@ -228,7 +181,7 @@
}
int len = otherEnd - cstyleStart;
if (len > 0) {
- insertCharsWithSoftHyphens(pos, other.textWithSoftHyphens(cstyleStart, len));
+ insertCharsWithSmartHyphens(pos, other.textWithSmartHyphens(cstyleStart, len));
applyCharStyle(pos, len, otherDefault.charStyle());
applyCharStyle(pos, len, cstyle);
pos += len;
@@ -237,18 +190,19 @@
//applyStyle(pos, otherDefault);
applyStyle(pos, other.paragraphStyle(otherEnd-1));
}
- }
+ }*/
+
invalidate(pos, length());
}
-
+#if 0
/**
Make sure that the paragraph CharStyle's point to the new ParagraphStyle
*/
void StoryText::insertParSep(int pos)
{
- ScText* it = item_p(pos);
- if(!it->parstyle) {
+// ScText* it = item_p(pos);
+/* if(!it->parstyle) {
it->parstyle = new ParagraphStyle(paragraphStyle(pos+1));
it->parstyle->setContext( & d->pstyleContext);
// #7432 : when inserting a paragraph separator, apply/erase the trailing Style
@@ -257,11 +211,13 @@
applyStyle(pos, d->trailingStyle);
d->trailingStyle.erase();
}
+
// it->parstyle->setName("para"); // DONT TRANSLATE
// it->parstyle->charStyle().setName("cpara"); // DONT TRANSLATE
// it->parstyle->charStyle().setContext( d->defaultStyle.charStyleContext() );
}
d->replaceCharStyleContextInParagraph(pos, it->parstyle->charStyleContext());
+*/
}
/**
need to remove the ParagraphStyle structure and replace all pointers
@@ -269,8 +225,8 @@
*/
void StoryText::removeParSep(int pos)
{
- ScText* it = item_p(pos);
- if (it->parstyle) {
+// ScText* it = item_p(pos);
+/* if (it->parstyle) {
// const CharStyle* oldP = & it->parstyle->charStyle();
// const CharStyle* newP = & that->paragraphStyle(pos+1).charStyle();
// d->replaceParentStyle(pos, oldP, newP);
@@ -281,7 +237,9 @@
// doesnt choke:
it->ch = 0;
d->replaceCharStyleContextInParagraph(pos, paragraphStyle(pos+1).charStyleContext());
-}
+*/
+}
+#endif
void StoryText::removeChars(int pos, uint len)
{
@@ -297,9 +255,11 @@
if (pos + static_cast<int>(len) > length())
len = length() - pos;
- for ( int i=pos + static_cast<int>(len) - 1; i >= pos; --i )
- {
- ScText *it = d->at(i);
+ data->replaceChars(QString(""), pos, len);
+
+/* for ( int i=pos + static_cast<int>(len) - 1; i >= pos; --i )
+ {
+// ScText *it = d->at(i);
if ((it->ch == SpecialChars::PARSEP)) {
removeParSep(i);
}
@@ -308,8 +268,7 @@
d->len--;
delete it;
}
-
- d->len = d->count();
+*/
invalidate(pos, length());
}
@@ -324,6 +283,10 @@
if (txt.length() == 0)
return;
+ data->replaceChars(txt, pos, 0);
+ //FIXME: what to do about neighbourStyle?
+
+ /*
const StyleContext* cStyleContext = paragraphStyle(pos).charStyleContext();
ScText clone;
@@ -335,7 +298,7 @@
}
for (int i = 0; i < txt.length(); ++i) {
- ScText * item = new ScText(clone);
+// ScText * item = new ScText(clone);
item->ch= txt.at(i);
item->setContext(cStyleContext);
d->insert(pos + i, item);
@@ -347,11 +310,16 @@
}
d->len = d->count();
+*/
invalidate(pos, pos + txt.length());
}
-void StoryText::insertCharsWithSoftHyphens(int pos, QString txt, bool applyNeighbourStyle)
-{
+void StoryText::insertCharsWithSmartHyphens(int pos, QString txt, bool applyNeighbourStyle)
+{
+ //FIXME:
+ insertChars(pos, txt, applyNeighbourStyle);
+ return;
+
if (pos < 0)
pos += length()+1;
@@ -362,8 +330,9 @@
return;
const StyleContext* cStyleContext = paragraphStyle(pos).charStyleContext();
-
- ScText clone;
+ int inserted = 0;
+/*
+// ScText clone;
if (applyNeighbourStyle)
{
int referenceChar = qMax(0, qMin(pos, length()-1));
@@ -371,14 +340,13 @@
clone.setEffects(ScStyle_Default);
}
- int inserted = 0;
for (int i = 0; i < txt.length(); ++i)
{
QChar ch = txt.at(i);
int index = pos + inserted;
bool insert = true;
if (ch == SpecialChars::SHYPHEN && index > 0) {
- ScText* lastItem = this->item(index - 1);
+// ScText* lastItem = this->item(index - 1);
// qreal SHY means user provided SHY, single SHY is automatic one
if (lastItem->effects() & ScStyle_HyphenationPossible)
lastItem->setEffects(lastItem->effects() & ~ScStyle_HyphenationPossible);
@@ -390,7 +358,7 @@
}
if (insert)
{
- ScText * item = new ScText(clone);
+// ScText * item = new ScText(clone);
item->ch = ch;
item->setContext(cStyleContext);
d->insert(index, item);
@@ -401,8 +369,7 @@
++inserted;
}
}
-
- d->len = d->count();
+*/
invalidate(pos, pos + inserted);
}
@@ -413,8 +380,10 @@
assert(pos >= 0);
assert(pos < length());
-
- ScText* item = d->at(pos);
+
+ data->replaceChars(ch, pos, 1);
+/*
+// ScText* item = d->at(pos);
if (item->ch == ch)
return;
@@ -425,7 +394,7 @@
if (d->at(pos)->ch == SpecialChars::PARSEP) {
insertParSep(pos);
}
-
+ */
invalidate(pos, pos + 1);
}
@@ -439,11 +408,11 @@
{
// dump += d->at(i)->ch;
if(hyphens && hyphens[i-pos] & 1) {
- d->at(i)->setEffects(d->at(i)->effects() | ScStyle_HyphenationPossible);
+ data->charAttributes(i) |= TextFlag_HyphenationPossible;
// dump += "-";
}
else {
- d->at(i)->setEffects(d->at(i)->effects() & ~ScStyle_HyphenationPossible);
+ data->charAttributes(i) &= ~TextFlags(TextFlag_HyphenationPossible);
}
}
// qDebug() << QString("st: %1").arg(dump);
@@ -455,15 +424,14 @@
if (pos < 0)
pos += length()+1;
- insertChars(pos, SpecialChars::OBJECT);
- const_cast<StoryText *>(this)->d->at(pos)->embedded = InlineFrame(ob);
+ data->insertObject(InlineFrame(ob), pos);
ob->isEmbedded = true; // this might not be enough...
}
int StoryText::length() const
{
- return d->len;
+ return data->length();
}
QChar StoryText::text(int pos) const
@@ -474,7 +442,7 @@
assert(pos >= 0);
assert(pos < length());
- return const_cast<StoryText *>(this)->d->at(pos)->ch;
+ return data->text(pos);
}
QString StoryText::text(int pos, uint len) const
@@ -485,16 +453,10 @@
assert(pos >= 0);
assert(pos + signed(len) <= length());
- QString result;
- StoryText* that(const_cast<StoryText*>(this));
- for (int i = pos; i < pos+signed(len); ++i) {
- result += that->d->at(i)->ch;
- }
-
- return result;
-}
-
-QString StoryText::textWithSoftHyphens(int pos, uint len) const
+ return data->text(pos, len);
+}
+
+QString StoryText::textWithSmartHyphens(int pos, uint len) const
{
QString result("");
int lastPos = pos;
@@ -516,16 +478,26 @@
return result;
}
-PageItem* StoryText::object(int pos) const
+TextFlags& StoryText::charAttributes(int pos)
+{
+ return data->charAttributes(pos);
+}
+
+
+const TextFlags& StoryText::charAttributes(int pos) const
+{
+ return data->charAttributes(pos);
+}
+
+InlineFrame StoryText::object(int pos) const
{
if (pos < 0)
pos += length();
assert(pos >= 0);
assert(pos < length());
-
- StoryText* that = const_cast<StoryText *>(this);
- return that->d->at(pos)->embedded.getItem();
+
+ return data->object(pos);
}
@@ -548,8 +520,7 @@
if (text(pos) == SpecialChars::PARSEP)
return paragraphStyle(pos).charStyle();
- StoryText* that = const_cast<StoryText *>(this);
- return dynamic_cast<const CharStyle &> (*that->d->at(pos));
+ return data->charStyle(pos);
}
const ParagraphStyle & StoryText::paragraphStyle(int pos) const
@@ -560,48 +531,23 @@
assert(pos >= 0);
assert(pos <= length());
- assert(d);
-
- StoryText * that = const_cast<StoryText *> (this);
-// assert( that->at(pos)->cab >= 0 );
-// assert( that->at(pos)->cab < doc->docParagraphStyles.count() );
-// return doc->docParagraphStyles[that->at(pos)->cab];
-
- while (pos < length() && that->d->at(pos)->ch != SpecialChars::PARSEP) {
- ++pos;
- }
- if (pos >= length()) {
- return that->d->trailingStyle;
- }
- else if ( !that->d->at(pos)->parstyle ) {
- ScText* current = that->d->at(pos);
- qDebug("inserting default parstyle at %i", pos);
- current->parstyle = new ParagraphStyle();
- current->parstyle->setContext( & d->pstyleContext);
-// current->parstyle->setName( "para(paragraphStyle)" ); // DONT TRANSLATE
-// current->parstyle->charStyle().setName( "cpara(paragraphStyle)" ); // DONT TRANSLATE
-// current->parstyle->charStyle().setContext( d->defaultStyle.charStyleContext());
- }
- else {
-// qDebug() << QString("using parstyle at %1").arg(pos);
- }
- assert (that->d->at(pos)->parstyle);
- return *that->d->at(pos)->parstyle;
+ return data->paragraphStyle(pos);
+
}
const ParagraphStyle& StoryText::defaultStyle() const
{
- assert(d);
- return d->defaultStyle;
+ assert(data);
+ return data->paragraphStyle(0);
}
void StoryText::setDefaultStyle(const ParagraphStyle& style)
{
- const StyleContext * oldPContext = d->defaultStyle.context();
+ const StyleContext * oldPContext = data->paragraphStyle(0).context();
// const StyleContext * oldCContext = d->defaultStyle.charStyle().context();
- d->defaultStyle = style;
- d->defaultStyle.setContext( oldPContext );
+ data->setStyle(style, 0, 1);
+// d->defaultStyle.setContext( oldPContext );
// d->defaultStyle.setName( "storydefault" ); // DONT TRANSLATE
// d->defaultStyle.charStyle().setName( "cstorydefault" ); // DONT TRANSLATE
// qDebug() << QString("defstyle %1 context %2 defcstyle %3 ccontext %4 newcontext %5")
@@ -628,28 +574,8 @@
if (len == 0)
return;
-
- int lastParStart = pos == 0? 0 : -1;
- ScText* itText;
- for (uint i=pos; i < pos+len; ++i) {
- itText = d->at(i);
- // #6165 : applying style on last character applies style on whole text on next open
- // #9173 et. al.: move charstyle to parstyle if whole paragraph is affected
- if (itText->ch == SpecialChars::PARSEP && itText->parstyle != NULL && lastParStart >= 0)
- {
- eraseCharStyle(lastParStart, i - lastParStart, style);
- itText->parstyle->charStyle().applyCharStyle(style);
- lastParStart = i + 1;
- }
- itText->applyCharStyle(style);
- }
- if (pos + signed(len) == length() && lastParStart >= 0)
- {
- eraseCharStyle(lastParStart, length() - lastParStart, style);
- d->trailingStyle.charStyle().applyCharStyle(style);
- }
-
- invalidate(pos, pos + len);
+
+ data->applyStyle(style, pos, len);
}
@@ -664,22 +590,9 @@
if (len == 0)
return;
-
- ScText* itText;
- for (uint i=pos; i < pos+len; ++i) {
- itText = d->at(i);
- // FIXME?? see #6165 : should we really erase charstyle of paragraph style??
- if (itText->ch == SpecialChars::PARSEP && itText->parstyle != NULL)
- itText->parstyle->charStyle().eraseCharStyle(style);
- itText->eraseCharStyle(style);
- }
- if (pos + signed(len) == length())
- {
- d->trailingStyle.charStyle().eraseCharStyle(style);
- }
-
- invalidate(pos, pos + len);
-}
+ data->eraseStyle(style, pos, len);
+}
+
void StoryText::applyStyle(int pos, const ParagraphStyle& style, bool rmDirectFormatting)
{
@@ -689,37 +602,14 @@
assert(pos >= 0);
assert(pos <= length());
- int i = pos;
- while (i < length() && d->at(i)->ch != SpecialChars::PARSEP) {
- ++i;
- }
- if (i < length()) {
- if (!d->at(i)->parstyle) {
- qDebug("PARSEP without style at pos %i", i);
- d->at(i)->parstyle = new ParagraphStyle();
- d->at(i)->parstyle->setContext( & d->pstyleContext);
-// d->at(i)->parstyle->setName( "para(applyStyle)" ); // DONT TRANSLATE
-// d->at(i)->parstyle->charStyle().setName( "cpara(applyStyle)" ); // DONT TRANSLATE
-// d->at(i)->parstyle->charStyle().setContext( d->defaultStyle.charStyleContext() );
- }
-// qDebug() << QString("applying parstyle %2 at %1 for %3").arg(i).arg(paragraphStyle(pos).name()).arg(pos);
- d->at(i)->parstyle->applyStyle(style);
- }
- else {
- // not happy about this but inserting a new PARSEP makes more trouble
-// qDebug() << QString("applying parstyle %1 as defaultstyle for %2").arg(paragraphStyle(pos).name()).arg(pos);
- d->trailingStyle.applyStyle(style);
- }
+ uint par = data->nrOfParagraph(pos);
+ int start = data->startOfParagraph(par);
+ int end = data->endOfParagraph(par);
if (rmDirectFormatting)
{
- --i;
- while (i >= 0 && d->at(i)->ch != SpecialChars::PARSEP)
- {
- d->at(i)->eraseDirectFormatting();
- --i;
- }
- }
- invalidate(pos, qMin(i, length()));
+ data->setStyle(CharStyle(), start, end-start);
+ }
+ data->applyStyle(style, start, end-start);
}
void StoryText::eraseStyle(int pos, const ParagraphStyle& style)
@@ -730,35 +620,19 @@
assert(pos >= 0);
assert(pos <= length());
- int i = pos;
- while (i < length() && d->at(i)->ch != SpecialChars::PARSEP) {
- ++i;
- }
- if (i < length()) {
- if (!d->at(i)->parstyle) {
- qDebug("PARSEP without style at pos %i", i);
- d->at(i)->parstyle = new ParagraphStyle();
- d->at(i)->parstyle->setContext( & d->pstyleContext);
-// d->at(i)->parstyle->setName( "para(eraseStyle)" ); // DONT TRANSLATE
-// d->at(i)->parstyle->charStyle().setName( "cpara(eraseStyle)" ); // DONT TRANSLATE
-// d->at(i)->parstyle->charStyle().setContext( d->defaultStyle.charStyleContext());
- }
- // qDebug() << QString("applying parstyle %2 at %1 for %3").arg(i).arg(paragraphStyle(pos).name()).arg(pos);
- d->at(i)->parstyle->eraseStyle(style);
- }
- else {
- // not happy about this but inserting a new PARSEP makes more trouble
- // qDebug() << QString("applying parstyle %1 as defaultstyle for %2").arg(paragraphStyle(pos).name()).arg(pos);
- d->trailingStyle.eraseStyle(style);
- }
- invalidate(pos, qMin(i, length()));
+ data->eraseStyle(style, pos, 1);
}
void StoryText::setStyle(int pos, const ParagraphStyle& style)
{
- eraseStyle(pos, paragraphStyle(pos));
- applyStyle(pos, style);
+ if (pos < 0)
+ pos += length();
+
+ assert(pos >= 0);
+ assert(pos <= length());
+
+ data->setStyle(style, pos, 1);
}
@@ -773,35 +647,15 @@
if (len == 0)
return;
-
- ScText* itText;
- for (uint i=pos; i < pos+len; ++i) {
- itText = d->at(i);
- // #6165 : applying style on last character applies style on whole text on next open
- /*if (itText->ch == SpecialChars::PARSEP && itText->parstyle != NULL)
- itText->parstyle->charStyle() = style;*/
- itText->setStyle(style);
- }
-
- invalidate(pos, pos + len);
+
+ data->setStyle(style, pos, len);
}
void StoryText::getNamedResources(ResourceCollection& lists) const
{
- d->defaultStyle.getNamedResources(lists);
- d->trailingStyle.getNamedResources(lists);
-
- for (int i=0; i < length(); ++i)
- {
- if (text(i) == SpecialChars::PARSEP)
- paragraphStyle(i).getNamedResources(lists);
- else if (text(i) == SpecialChars::OBJECT)
- object(i)->getNamedResources(lists);
- else
- charStyle(i).getNamedResources(lists);
- }
+ data->getNamedResources(lists);
}
@@ -814,24 +668,7 @@
void StoryText::replaceNamedResources(ResourceCollection& newNames)
{
- int len = length();
-
- d->defaultStyle.replaceNamedResources(newNames);
- d->trailingStyle.replaceNamedResources(newNames);
-
- if (len == 0)
- return;
-
- ScText* itText;
- for (int i=0; i < len; ++i) {
- itText = d->at(i);
- if (itText->parstyle)
- itText->parstyle->replaceNamedResources(newNames);
- else
- itText->replaceNamedResources(newNames);
- }
-
- invalidate(0, len);
+ data->replaceNamedResources(newNames);
}
@@ -843,70 +680,39 @@
}
-int StoryText::nrOfParagraph(uint index) const
-{
- int result = 0;
- StoryText* that = const_cast<StoryText *>(this);
- bool lastWasPARSEP = true;
- index = qMin(index, (uint) that->length());
- for (uint i=0; i < index; ++i) {
- lastWasPARSEP = that->d->at(i)->ch == SpecialChars::PARSEP;
- if (lastWasPARSEP)
- ++result;
- }
- return result;
-}
-
uint StoryText::nrOfParagraphs() const
{
- uint result = 0;
- StoryText* that = const_cast<StoryText *>(this);
- bool lastWasPARSEP = true;
- for (int i=0; i < length(); ++i) {
- lastWasPARSEP = that->d->at(i)->ch == SpecialChars::PARSEP;
- if (lastWasPARSEP)
- ++result;
- }
- return lastWasPARSEP ? result : result + 1;
+ return data->nrOfParagraphs();
+}
+
+uint StoryText::nrOfParagraph(int pos) const
+{
+ return data->nrOfParagraph(pos);
}
int StoryText::startOfParagraph(uint index) const
{
- if (index == 0)
- return 0;
-
- StoryText* that = const_cast<StoryText *>(this);
- for (int i=0; i < length(); ++i) {
- if (that->d->at(i)->ch == SpecialChars::PARSEP && ! --index)
- return i + 1;
- }
- return length();
+ return data->startOfParagraph(index);
}
int StoryText::endOfParagraph(uint index) const
{
- ++index;
- StoryText* that = const_cast<StoryText *>(this);
- for (int i=0; i < length(); ++i) {
- if (that->d->at(i)->ch == SpecialChars::PARSEP && ! --index)
- return i;
- }
- return length();
+ return data->endOfParagraph(index);
}
uint StoryText::nrOfRuns() const
{
- return length();
+ return data->nrOfRuns();
}
int StoryText::startOfRun(uint index) const
{
- return index;
+ return data->startOfRun(index);
}
int StoryText::endOfRun(uint index) const
{
- return index + 1;
+ return data->endOfRun(index);
}
// positioning. all positioning methods return char positions
@@ -975,103 +781,6 @@
return pos;
}
-// these need valid layout:
-
-int StoryText::startOfLine(int pos)
-{
- for (int i=0; i < m_lines.count(); ++i) {
- const LineSpec & ls(m_lines.at(i));
- if (ls.firstItem <= pos && pos <= ls.lastItem)
- return ls.firstItem;
- }
- return 0;
-}
-int StoryText::endOfLine(int pos)
-{
- for (int i=0; i < m_lines.count(); ++i) {
- const LineSpec & ls(m_lines.at(i));
- if (ls.firstItem <= pos && pos <= ls.lastItem)
- return text(ls.lastItem) == SpecialChars::PARSEP ? ls.lastItem :
- text(ls.lastItem) == ' ' ? ls.lastItem : ls.lastItem + 1;
- }
- return length();
-}
-int StoryText::prevLine(int pos)
-{
- for (int i=0; i < m_lines.count(); ++i)
- {
- // find line for pos
- const LineSpec & ls(m_lines.at(i));
- if (ls.firstItem <= pos && pos <= ls.lastItem)
- {
- if (i == 0)
- return startOfLine(pos);
- // find current xpos
- qreal xpos = 0.0;
- for (int j = ls.firstItem; j < pos; ++j)
- xpos += item(j)->glyph.wide();
- if (pos != m_lastMagicPos || xpos > m_magicX)
- m_magicX = xpos;
- const LineSpec & ls2(m_lines.at(i-1));
- // find new cpos
- xpos = 0.0;
- for (int j = ls2.firstItem; j <= ls2.lastItem; ++j)
- {
- xpos += item(j)->glyph.wide();
- if (xpos > m_magicX) {
- m_lastMagicPos = j;
- return j;
- }
- }
- m_lastMagicPos = ls2.lastItem;
- return ls2.lastItem;
- }
- }
- return firstFrameItem;
-}
-
-int StoryText::nextLine(int pos)
-{
- for (int i=0; i < m_lines.count(); ++i)
- {
- // find line for pos
- const LineSpec & ls(m_lines.at(i));
- if (ls.firstItem <= pos && pos <= ls.lastItem)
- {
- if (i+1 == m_lines.count())
- return endOfLine(pos);
- // find current xpos
- qreal xpos = 0.0;
- for (int j = ls.firstItem; j < pos; ++j)
- xpos += item(j)->glyph.wide();
- if (pos != m_lastMagicPos || xpos > m_magicX)
- m_magicX = xpos;
- const LineSpec & ls2(m_lines.at(i+1));
- // find new cpos
- xpos = 0.0;
- for (int j = ls2.firstItem; j <= ls2.lastItem; ++j)
- {
- xpos += item(j)->glyph.wide();
- if (xpos > m_magicX) {
- m_lastMagicPos = j;
- return j;
- }
- }
- m_lastMagicPos = ls2.lastItem + 1;
- return ls2.lastItem + 1;
- }
- }
- return lastFrameItem;
-}
-
-int StoryText::startOfFrame(int pos)
-{
- return firstFrameItem;
-}
-int StoryText::endOfFrame(int pos)
-{
- return lastFrameItem + 1;
-}
// selection
@@ -1246,17 +955,12 @@
void StoryText::invalidateAll()
{
- d->pstyleContext.invalidate();
- invalidate(0, nrOfItems());
-}
-
-void StoryText::invalidate(int firstItem, int endItem)
-{
- for (int i=firstItem; i < endItem; ++i) {
- ParagraphStyle* par = item(i)->parstyle;
- if (par)
- par->charStyleContext()->invalidate();
- }
+ invalidate(0, length());
+}
+
+void StoryText::invalidate(int startPos, int endPos)
+{
+ data->invalidate(startPos, endPos);
emit changed();
}
@@ -1275,154 +979,6 @@
}
*/
-int StoryText::screenToPosition(FPoint coord) const
-{
- qreal maxx = coord.x() - 1.0;
- for (unsigned int i=0; i < lines(); ++i)
- {
- LineSpec ls = line(i);
-// qDebug() << QString("screenToPosition: (%1,%2) -> y %3 - %4 + %5").arg(coord.x()).arg(coord.y()).arg(ls.y).arg(ls.ascent).arg(ls.descent);
- if (ls.y + ls.descent < coord.y())
- continue;
- qreal xpos = ls.x;
- for (int j = ls.firstItem; j <= ls.lastItem; ++j) {
-// qDebug() << QString("screenToPosition: (%1,%2) -> x %3 + %4").arg(coord.x()).arg(coord.y()).arg(xpos).arg(item(j)->glyph.wide());
- qreal width = item(j)->glyph.wide();
- xpos += width;
- if (xpos >= coord.x())
- return xpos - width/2 > coord.x() ? j : j+1;
- }
- if (xpos > maxx)
- maxx = xpos;
- if (xpos + 1.0 > coord.x()) // allow 1pt after end of line
- return ls.lastItem + 1;
- else if (coord.x() <= ls.x + ls.width) // last line of paragraph?
- return ((ls.lastItem == lastFrameItem) ? (ls.lastItem + 1) : ls.lastItem);
- else if (xpos < ls.x + 0.01 && maxx >= coord.x()) // check for empty line
- return ls.firstItem;
- }
- return qMax(lastFrameItem+1, firstFrameItem);
-}
-
-
-FRect StoryText::boundingBox(int pos, uint len) const
-{
- FRect result;
- LineSpec ls;
- for (uint i=0; i < lines(); ++i)
- {
- ls = line(i);
- if (ls.lastItem < pos)
- continue;
- if (ls.firstItem <= pos) {
- /*
- if (ls.lastItem == pos && (item(pos)->effects() & ScStyle_SuppressSpace) )
- {
- if (i+1 < lines())
- {
- ls = line(i+1);
- result.setRect(ls.x, ls.y - ls.ascent, 1, ls.ascent + ls.descent);
- }
- else
- {
- ls = line(lines()-1);
- const ParagraphStyle& pstyle(paragraphStyle(pos));
- result.setRect(ls.x, ls.y + pstyle.lineSpacing() - ls.ascent, 1, ls.ascent + ls.descent);
- }
- }
- else */
- {
- qreal xpos = ls.x;
- for (int j = ls.firstItem; j < pos; ++j)
- {
- if (item(j)->ch == SpecialChars::OBJECT)
- xpos += (object(j)->gWidth + object(j)->lineWidth()) * item(j)->glyph.scaleH;
- else
- xpos += item(j)->glyph.wide();
- }
- qreal finalw = 1;
- if (item(pos)->ch == SpecialChars::OBJECT)
- finalw = (object(pos)->gWidth + object(pos)->lineWidth()) * item(pos)->glyph.scaleH;
- else
- finalw = item(pos)->glyph.wide();
- const CharStyle& cs(charStyle(pos));
- qreal desc = -cs.font().descent(cs.fontSize() / 10.0);
- qreal asce = cs.font().ascent(cs.fontSize() / 10.0);
- result.setRect(xpos, ls.y - asce, pos < length()? finalw : 1, desc+asce);
- }
- return result;
- }
- }
- const ParagraphStyle& pstyle(paragraphStyle(qMin(pos, length()))); // rather the trailing style than a segfault.
- if (lines() > 0)
- {
- ls = line(lines()-1);
- result.setRect(ls.x, ls.y + pstyle.lineSpacing() - ls.ascent, 1, ls.ascent + ls.descent);
- }
- else
- {
- result.setRect(1, 1, 1, pstyle.lineSpacing());
- }
- return result;
-}
-
-int StoryText::layout(int startItem)
-{
- //FIXME:NLS
- return -1;
-}
-
-
-uint StoryText::nrOfItems() const
-{
- return length();
-}
-
-
-ScText* StoryText::item(uint itm)
-{
- assert( static_cast<int>(itm) < length() );
- return const_cast<StoryText *>(this)->d->at(itm);
-}
-
-
-const ScText* StoryText::item(uint itm) const
-{
- assert( static_cast<int>(itm) < length() );
- return const_cast<StoryText *>(this)->d->at(itm);
-}
-
-
-const QString StoryText::itemText(uint itm) const
-{
-
- assert( static_cast<int>(itm) < length() );
-
- return text(itm, 1);
-}
-
-
-const CharStyle StoryText::itemStyle(uint itm) const
-{
- assert( static_cast<int>(itm) < length() );
-
- return charStyle(itm);
-}
-
-
-int StoryText::startOfItem(uint itm) const
-{
- assert( static_cast<int>(itm) < length() );
-
- return itm;
-}
-
-int StoryText::endOfItem(uint itm) const
-{
- assert( static_cast<int>(itm) < length() );
-
- return itm + 1;
-}
using namespace desaxe;
@@ -1466,7 +1022,7 @@
// something new, write pending chars
if (i - lastPos > 0)
{
- handler.chars(textWithSoftHyphens(lastPos, i-lastPos));
+ handler.chars(textWithSmartHyphens(lastPos, i-lastPos));
}
lastPos = i;
}
@@ -1481,9 +1037,9 @@
handler.begin("span", empty);
lastStyle.erase();
}
- else if (curr == SpecialChars::OBJECT && object(i) != NULL)
- {
- object(i)->saxx(handler);
+ else if (curr == SpecialChars::OBJECT && object(i).hasItem())
+ {
+ object(i).getItem()->saxx(handler);
}
else if (curr == SpecialChars::TAB)
{
@@ -1531,7 +1087,7 @@
}
if (length() - lastPos > 0)
- handler.chars(textWithSoftHyphens(lastPos, length()-lastPos));
+ handler.chars(textWithSmartHyphens(lastPos, length()-lastPos));
handler.end("span");
handler.end("p");
@@ -1560,7 +1116,7 @@
if (toInsert > 0)
obj->insertChars(obj->length(), txt.mid(lastPos, toInsert));
len = obj->length();
- ScText* lastItem = obj->item(len-1);
+/* ScText* lastItem = obj->item(len-1);
// qreal SHY means user provided SHY, single SHY is automatic one
if (lastItem->effects() & ScStyle_HyphenationPossible)
{
@@ -1571,6 +1127,7 @@
{
lastItem->setEffects(lastItem->effects() | ScStyle_HyphenationPossible);
}
+ */
lastPos = i + 1;
}
}
@@ -1627,19 +1184,6 @@
{
StoryText* story = this->dig->top<StoryText>(1);
PageItem* obj = this->dig->top<PageItem>(0);
- // FIXME : currently inline objects are added to doc items when parsing
- // We have to remove them from object list and add them to the FrameItems list
- // before inserting them in story object
- QList<PageItem*> *items = obj->doc()->Items;
- if (items->count() > 0)
- {
- if (items->last() == obj) // try a fast path first
- items->removeLast();
- else
- items->removeAll(obj);
- }
- obj->doc()->FrameItems.append(obj);
- obj->ItemNr = obj->doc()->FrameItems.count() - 1;
story->insertObject(-1, obj);
}
};
Modified: branches/ScribusOIF/scribus/text/storytext.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/text/storytext.h
==============================================================================
--- branches/ScribusOIF/scribus/text/storytext.h (original)
+++ branches/ScribusOIF/scribus/text/storytext.h Mon Oct 18 10:52:30 2010
@@ -25,6 +25,9 @@
#ifndef STORYTEXT_H_
#define STORYTEXT_H_
+#undef NDEBUG
+
+#include <QExplicitlySharedDataPointer>
#include <QObject>
#include <QString>
#include <QList>
@@ -32,7 +35,10 @@
//#include "text/paragraphlayout.h"
#include "text/frect.h"
+#include "text/glyphstore.h" // for TextStore
#include "text/specialchars.h"
+#include "text/textlayout.h"
+
#include "sctextstruct.h"
#include "style.h"
#include "styles/charstyle.h"
@@ -51,23 +57,10 @@
//class ScTextEngine;
//class ScScriptItem;
class ScribusDoc;
-class ScText_Shared;
+class GlyphStore;
+class Storytext_Shared;
class ResourceCollection;
-
-struct LineSpec
-{
- qreal x;
- qreal y;
- qreal width;
- qreal ascent;
- qreal descent;
- qreal colLeft;
-
- int firstItem;
- int lastItem;
- qreal naturalWidth;
-};
/**
* This class holds the text of a Scribus textframe and pointers to its
@@ -85,11 +78,14 @@
* offsets to its basepoint. Other information in the ScriptItem is only
* used by the layouter.
*/
-class SCRIBUS_API StoryText : public QObject, public SaxIO
+class SCRIBUS_API StoryText : public QObject, public SaxIO, public TextStore
+
{
Q_OBJECT
public:
+
+ friend class TextLayout;
StoryText(ScribusDoc * doc);
StoryText();
StoryText(const StoryText & other);
@@ -113,22 +109,25 @@
void hyphenateWord(int pos, uint len, char* hyphens);
- int length() const;
- QChar text(int pos) const;
- QString text(int pos, uint len) const;
- PageItem* object(int pos) const;
-
- int nextCharPos(int c);
+ virtual int length() const;
+ virtual QChar text(int pos) const;
+ virtual QString text(int pos, uint len) const;
+ virtual TextFlags& charAttributes(int pos);
+ virtual const TextFlags& charAttributes(int pos) const;
+
+ InlineFrame object(int pos) const;
+
+ /*int nextCharPos(int c);
int prevCharPos(int c);
int nextWordPos(int c);
int prevWordPos(int c);
int nextLinePos(int c, qreal oldX);
int prevLinePos(int c, qreal oldX);
int nextFramePos(int c);
- int prevFramePos(int c);
+ int prevFramePos(int c);*/
const CharStyle& charStyle(int pos) const;
- const ParagraphStyle& paragraphStyle(int pos) const;
+ virtual const ParagraphStyle& paragraphStyle(int pos) const;
const ParagraphStyle& defaultStyle() const;
void setDefaultStyle(const ParagraphStyle& style);
void setCharStyle(int pos, uint len, const CharStyle& style);
@@ -144,9 +143,9 @@
void replaceNamedResources(ResourceCollection& newNames);
uint nrOfParagraphs() const;
+ uint nrOfParagraph(int pos) const;
int startOfParagraph(uint index) const;
int endOfParagraph(uint index) const;
- int nrOfParagraph(uint index) const;
uint nrOfRuns() const;
int startOfRun(uint index) const;
@@ -161,15 +160,6 @@
int prevSentence(int pos);
int nextParagraph(int pos);
int prevParagraph(int pos);
-
-// these need valid layout:
-
- int startOfLine(int pos);
- int endOfLine(int pos);
- int prevLine(int pos);
- int nextLine(int pos);
- int startOfFrame(int pos);
- int endOfFrame(int pos);
// selection
@@ -200,81 +190,44 @@
void changed();
public:
-// physical view
-
- bool overflows() const;
- /// layouts the text -- FIXME: better interface for this
- int layout(int startItem);
- uint nrOfItems() const;
-//private:
- ScText * item(uint index);
- const ScText * item(uint index) const;
-public:
- ScText * item_p(uint index) { return item(index); }
+ // uint nrOfItems() const;
+
+ GlyphStore* glyphStore() { return m_glyphStore; }
+ const GlyphStore* glyphStore() const { return m_glyphStore; }
+private:
+ GlyphStore* m_glyphStore;
+
+private:
+ void * item(uint index);
+ const void * item(uint index) const;
+//public ScText * item_p(uint index) { return item(index); }
// void bidiReorder(uint firstItem, uint lastItem, uint indices[]) const;
/** returns the Unicode string which belongs to this ScScriptItem */
- const QString itemText(uint index) const;
+ //const QString itemText(uint index) const;
/** returns the CharStyle which belongs to this ScScriptItem */
- const CharStyle itemStyle(uint index) const;
+ //const CharStyle itemStyle(uint index) const;
/// returns the character postion at the start of this item
- int startOfItem(uint index) const;
+ //int startOfItem(uint index) const;
/// returns the character position after this item
- int endOfItem(uint index) const;
+ //int endOfItem(uint index) const;
// const ScTextEngine * engineForRun(uint index) const;
// const ScTextEngine * engineForItem(uint index) const;
// ParagraphLayout layouter;
- int screenToPosition(FPoint coord) const;
- FRect boundingBox(int pos, uint len = 1) const;
-
- uint lines() const { return (uint) m_lines.count(); }
-
- LineSpec line(uint i) const { return m_lines[i]; }
-
- void appendLine(const LineSpec& ls)
- {
- assert( ls.firstItem >= 0 );
- assert( ls.firstItem < length() );
- assert( ls.lastItem >= 0 && ls.firstItem - ls.lastItem < 1 );
- assert( ls.lastItem < length() );
- m_lines.append(ls);
- if (lastFrameItem < firstFrameItem) {
- firstFrameItem = ls.firstItem;
- lastFrameItem = ls.lastItem;
- }
- else {
- firstFrameItem = qMin(firstFrameItem, ls.firstItem);
- lastFrameItem = qMax(lastFrameItem, ls.lastItem);
- }
- }
-
- void clearLines()
- {
- m_lines.clear();
- firstFrameItem = 0;
- lastFrameItem = -1;
- }
-
- int firstInFrame() { return firstFrameItem; }
- int lastInFrame() { return lastFrameItem; }
-
+
+
private:
ScribusDoc * doc;
int selFirst, selLast;
- int firstFrameItem, lastFrameItem;
- QList<LineSpec> m_lines;
- bool m_validLayout;
- qreal m_magicX;
- int m_lastMagicPos;
-
- QString textWithSoftHyphens (int pos, uint len) const;
- void insertCharsWithSoftHyphens(int pos, QString txt, bool applyNeighbourStyle = false);
-
- /// mark these runs as invalid, ie. need itemize and shaping
- void invalidate(int firstRun, int lastRun);
- void removeParSep(int pos);
- void insertParSep(int pos);
+
+ QString textWithSmartHyphens (int pos, uint len) const;
+ void insertCharsWithSmartHyphens(int pos, QString txt, bool applyNeighbourStyle = false);
+
+ /// mark this part as invalid, ie. need itemize and shaping
+ void invalidate(int startPos, int endPos);
+ //void removeParSep(int pos);
+ //void insertParSep(int pos);
// int splitRun(int pos);
@@ -283,7 +236,8 @@
*/
// void validate();
/// private data structure
- ScText_Shared * d;
+ QExplicitlySharedDataPointer<Storytext_Shared> data;
+// ScText_Shared * d;
/// gives the physical view which was last given to the layouter
// uint layouterVersion;
/// is true after layout() has been exercised
Modified: branches/ScribusOIF/scribus/ui/search.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/ui/search.cpp
==============================================================================
--- branches/ScribusOIF/scribus/ui/search.cpp (original)
+++ branches/ScribusOIF/scribus/ui/search.cpp Mon Oct 18 10:52:30 2010
@@ -691,10 +691,16 @@
{
if (Item->itemText.selected(a))
{
- StyleFlag fl = Item->itemText.item(a)->effects();
- fl &= static_cast<StyleFlag>(~1919);
- fl |= static_cast<StyleFlag>(s);
- Item->itemText.item(a)->setFeatures(fl.featureList());
+// StyleFlag fl = Item->itemText.item(a)->effects();
+// fl &= static_cast<StyleFlag>(~1919);
+// fl |= static_cast<StyleFlag>(s);
+// Item->itemText.item(a)->setFeatures(fl.featureList());
+ CharStyle tmpCS(Item->itemText.charStyle(a));
+ StyleFlag fl = tmpCS.effects();
+ fl &= static_cast<StyleFlag>(~1919); // 0x11101111111
+ fl |= static_cast<StyleFlag>(s & 1919);
+ tmpCS.setFeatures(fl.featureList());
+ Item->itemText.setCharStyle(a, 1, tmpCS);
}
}
#endif
Modified: branches/ScribusOIF/scribus/ui/storyeditor.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15570&path=/branches/ScribusOIF/scribus/ui/storyeditor.cpp
==============================================================================
--- branches/ScribusOIF/scribus/ui/storyeditor.cpp (original)
+++ branches/ScribusOIF/scribus/ui/storyeditor.cpp Mon Oct 18 10:52:30 2010
@@ -179,7 +179,7 @@
while ((pos1 <= pos2) && (pos1 < editor->StyledText.length()))
{
paraInfo.first = pos1;
- if (editor->StyledText.item(pos1)->ch == SpecialChars::PARSEP)
+ if (editor->StyledText.text(pos1) == SpecialChars::PARSEP)
{
paraInfo.second = pos1;
pos1 += 1;
More information about the scribus-commit
mailing list