[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: Re: Problems with User-defined variables in KWord
From: Sebastian Sauer <mail () dipe ! org>
Date: 2006-03-17 18:07:05
Message-ID: 200603171907.06686.mail () dipe ! org
[Download RAW message or body]
Sebastian Sauer wrote:
> Following patch fixed it for me. But since it just don't looks like the
> best way to archive it and I don't know if it introduces regressions...
Attached is an updated version of the patch to extend the previous one with
the input Gary Cramblitt provided;
- At the beginning of a line, you do need the <text:s>, since OpenDocument
eliminates leading whitespace immediately after a starting tag.
- sequences of more than one whitespace character should be collapsed into a
single space.
- OpenDocument collapses consecutive whitespace characters, which are defined
as space (0x0020), tab (0x0009), carriage return (0x000D), and line feed
(0x000A) to a single space.
I fear the patch slows reading down a lot cause at each single line of text
two regular expressions are applied :-/
--
Sebastian Sauer aka dipesh[sebsauer]
http://www.dipe.org/public_key.asc
Fingerprint: 8F1E 219B 16E6 4EC7 29CC F408 E193 65E2 9134 2221
Coder in http://www.koffice.org && http://www.kmldonkey.org
["kotextstripparag.patch" (text/x-diff)]
Index: KoTextParag.cpp
===================================================================
--- KoTextParag.cpp (Revision 518929)
+++ KoTextParag.cpp (Arbeitskopie)
@@ -34,6 +34,7 @@
#include <kdebug.h>
#include <kglobalsettings.h>
#include <assert.h>
+#include <qregexp.h>
//#define DEBUG_PAINT
@@ -2678,6 +2679,8 @@
// Parse every child node of the parent
// Can't use forEachElement here since we also care about text nodes
QDomNode node;
+ QRegExp rxws("^[\\s]+"); // remove leading whitespaces
+ QRegExp rxsimplify("[\\s\n\r\t]+"); // simplify
for ( node = parent.firstChild(); !node.isNull(); node = node.nextSibling() )
{
QDomElement ts = node.toElement();
@@ -2692,7 +2695,7 @@
// Try to keep the order of the tag names by probability of happening
if ( node.isText() )
{
- textData = node.toText().data();
+ textData = node.toText().data().remove(rxws).replace(rxsimplify," ");
}
else if ( isTextNS && localName == "span" ) // text:span
{
_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic