[Kst] extragear/graphics/kst/src
Andrew Walker
arwalker at sumusltd.com
Tue Mar 14 19:40:44 CET 2006
SVN commit 518634 by arwalker:
BUG:96244 Do not interpret \n in legend
M +1 -1 libkstapp/kstviewlegend.cpp
M +2 -2 libkstmath/kstbasecurve.cpp
M +13 -9 libkstmath/labelparser.cpp
M +1 -1 libkstmath/labelparser.h
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewlegend.cpp #518633:518634
@@ -517,7 +517,7 @@
void KstViewLegend::reparseTitle() {
delete _parsedTitle;
- _parsedTitle = Label::parse(_title, true);
+ _parsedTitle = Label::parse(_title, true, false);
setDirty();
}
--- trunk/extragear/graphics/kst/src/libkstmath/kstbasecurve.cpp #518633:518634
@@ -56,9 +56,9 @@
void KstBaseCurve::updateParsedLegendTag() {
delete _parsedLegendTag;
if (_legendText.isEmpty()) {
- _parsedLegendTag = Label::parse(tagName(), false);
+ _parsedLegendTag = Label::parse(tagName(), false, false);
} else {
- _parsedLegendTag = Label::parse(legendText(), true);
+ _parsedLegendTag = Label::parse(legendText(), true, false);
}
}
--- trunk/extragear/graphics/kst/src/libkstmath/labelparser.cpp #518633:518634
@@ -120,7 +120,7 @@
break;
-inline bool parseOutChar(const QString& txt, uint from, int *skip, Chunk **tail) {
+inline bool parseOutChar(const QString& txt, uint from, int *skip, Chunk **tail, bool interpretNewLine) {
QChar c = txt[from];
bool upper = false;
*skip = 1;
@@ -243,7 +243,7 @@
*skip = 2;
setNormalChar(QChar(0x2260), tail);
return true;
- } else {
+ } else if (interpretNewLine) {
*skip = 1;
if (!*tail || !(*tail)->text.isEmpty() || (*tail)->locked()) {
*tail = new Chunk(*tail, Chunk::None, false, true);
@@ -251,6 +251,10 @@
(*tail)->linebreak = true;
*tail = new Chunk(*tail, Chunk::None, false, true);
return true;
+ } else {
+ *skip = 1;
+ setNormalChar(QChar(0x20), tail);
+ return true;
}
break;
@@ -388,7 +392,7 @@
}
-static Chunk *parseInternal(Chunk *ctail, const QString& txt, uint& start, uint cnt) {
+static Chunk *parseInternal(Chunk *ctail, const QString& txt, uint& start, uint cnt, bool interpretNewLine) {
Chunk *chead = ctail;
if (ctail->group) {
@@ -422,7 +426,7 @@
setNormalChar('\\', &ctail);
} else {
int skip = 0;
- if (!parseOutChar(txt, i, &skip, &ctail)) {
+ if (!parseOutChar(txt, i, &skip, &ctail, interpretNewLine)) {
setNormalChar(txt[i], &ctail);
} else {
i += skip - 1;
@@ -450,15 +454,15 @@
if (ctail->text.isEmpty() && !ctail->group) {
ctail->group = true;
dumpattr(ctail, "start group with non-group and empty text");
- ctail = parseInternal(ctail, txt, ++i, cnt);
+ ctail = parseInternal(ctail, txt, ++i, cnt, interpretNewLine);
dumpattr(ctail, "after start group with non-group and empty text");
} else {
if (ctail->vOffset == Chunk::None) {
dumpattr(ctail, "start group with text or group");
- ctail = parseInternal(new Chunk(ctail, Chunk::None, true, true), txt, ++i, cnt);
+ ctail = parseInternal(new Chunk(ctail, Chunk::None, true, true), txt, ++i, cnt, interpretNewLine);
dumpattr(ctail, "after start group with text or group");
} else {
- ctail = parseInternal(new Chunk(ctail->prev, Chunk::None, true, true), txt, ++i, cnt);
+ ctail = parseInternal(new Chunk(ctail->prev, Chunk::None, true, true), txt, ++i, cnt, interpretNewLine);
}
}
if (!ctail) {
@@ -533,7 +537,7 @@
}
-Parsed *Label::parse(const QString& txt, bool interpret) {
+Parsed *Label::parse(const QString& txt, bool interpret, bool interpretNewLine) {
Parsed *parsed = new Parsed;
Chunk *ctail = parsed->chunk = new Chunk(0L);
if (!interpret) {
@@ -543,7 +547,7 @@
uint start = 0;
uint cnt = txt.length();
- Chunk *rc = parseInternal(ctail, txt, start, cnt);
+ Chunk *rc = parseInternal(ctail, txt, start, cnt, interpretNewLine);
if (!rc) {
// Parse error - how to recover?
delete parsed;
--- trunk/extragear/graphics/kst/src/libkstmath/labelparser.h #518633:518634
@@ -76,7 +76,7 @@
};
- extern KST_EXPORT Parsed *parse(const QString&, bool interpret = true);
+ extern KST_EXPORT Parsed *parse(const QString&, bool interpret = true, bool interpretNewLine = true);
}
#endif
More information about the Kst
mailing list