diff -r 138c2cdc02fd -r 6691000c3262 noteobj.cpp --- a/noteobj.cpp Tue Jan 24 15:09:48 2006 +0000 +++ b/noteobj.cpp Tue Jan 24 15:09:48 2006 +0000 @@ -14,6 +14,12 @@ clear(); } +NoteObj::NoteObj(const QString &s) +{ + clear(); + note=s; +} + void NoteObj::copy (NoteObj other) { note=other.note; @@ -38,6 +44,78 @@ return note; } +QString NoteObj::getNoteASCII() +{ + QString r=note; + + // convert all "" to "\n" + QRegExp re(""); + re.setMinimal(true); + r.replace (re,"\n"); + + // convert all "

" to "\n" + re.setPattern ("

"); + r.replace (re,"\n"); + + // remove all remaining tags + re.setPattern ("<.*>"); + r.replace (re,""); + + // If string starts with \n now, remove it. + // It would be wrong in an OOo export for example + while (r.at(0)=='\n') r.remove (0,1); + + // convert "&", "<" and ">" + re.setPattern (">"); + r.replace (re,">"); + re.setPattern ("<"); + r.replace (re,"<"); + re.setPattern ("&"); + r.replace (re,"&"); + re.setPattern ("""); + r.replace (re,"\""); + + return r; +} + +QString NoteObj::getNoteOpenDoc() +{ + // Evil hack to transform QT Richtext into + // something which can be used in OpenDoc format + // + // TODO create clean XML transformation which also + // considers fonts, colors, ... + + QString r=note; + + // convert all "" + QRegExp re(""); + re.setMinimal(true); + r.replace (re,""); + + // convert all "

" + re.setPattern ("

"); + r.replace (re,""); + + // Remove all other tags, e.g. paragraphs will be added in + // templates used during export + re.setPattern (""); + r.replace (re,""); + re.setPattern (""); + r.replace (re,""); + re.setPattern (""); + r.replace (re,""); + re.setPattern (""); + r.replace (re,""); + re.setPattern (""); + r.replace (re,""); + re.setPattern (""); + r.replace (re,""); + + r=""+r+""; + return r; +} + void NoteObj::setFontHint (const QString &s) { // only for backward compatibility (pre 1.5 )