summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/Bkmks.cpp18
-rw-r--r--noncore/apps/opie-reader/Bkmks.h7
-rw-r--r--noncore/apps/opie-reader/StyleConsts.cpp7
-rw-r--r--noncore/apps/opie-reader/StyleConsts.h8
-rw-r--r--noncore/apps/opie-write/qrichtext.cpp5
-rw-r--r--noncore/apps/tinykate/libkate/document/katehighlight.cpp7
-rw-r--r--noncore/apps/tinykate/libkate/document/katehighlight.h2
7 files changed, 38 insertions, 16 deletions
diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp
index 440d8be..28f6318 100644
--- a/noncore/apps/opie-reader/Bkmks.cpp
+++ b/noncore/apps/opie-reader/Bkmks.cpp
@@ -1,70 +1,86 @@
#include <qmessagebox.h>
#include "Bkmks.h"
#include "StyleConsts.h"
#include "Markups.h"
#include "my_list.h"
#include "version.h"
#include "names.h"
const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE);
-Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p)
+Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p) :
+ m_name(0),
+ m_namelen(0),
+ m_anno(0),
+ m_annolen(0),
+ m_position(0)
{
init(_nm, _nmlen, _anno, _annolen, _p);
}
Bkmk::Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short annolen, unsigned int _p) : m_position(_p)
{
init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, annolen, _p);
}
+Bkmk::Bkmk(const Bkmk& rhs) :
+ m_name(0),
+ m_namelen(0),
+ m_anno(0),
+ m_annolen(0),
+ m_position(0)
+{
+ init(rhs.name(), sizeof(tchar)*(ustrlen(rhs.name())+1), rhs.anno(),
+ sizeof(tchar)*(ustrlen(rhs.anno())+1), rhs.value());
+}
+
Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p)
{
if (_anno == NULL)
{
tchar t = 0;
init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p);
}
else
{
init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p);
}
}
Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2) : m_position(_p)
{
if (_anno == NULL)
{
tchar t = 0;
init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p);
}
else
{
init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p);
}
m_position2 = _p2;
m_red = m_green = m_blue = 127;
}
void Bkmk::init(const void* _nm, unsigned short _nmlen, const void* _anno, unsigned short _annolen, unsigned int _p)
{
m_namelen = _nmlen;
if (m_namelen > 0)
{
m_name = new unsigned char[m_namelen];
memcpy(m_name, _nm, m_namelen);
}
else
{
m_name = NULL;
}
m_annolen = _annolen;
if (m_annolen > 0)
{
m_anno = new unsigned char[m_annolen];
memcpy(m_anno, _anno, m_annolen);
}
else
diff --git a/noncore/apps/opie-reader/Bkmks.h b/noncore/apps/opie-reader/Bkmks.h
index c2275e2..985e158 100644
--- a/noncore/apps/opie-reader/Bkmks.h
+++ b/noncore/apps/opie-reader/Bkmks.h
@@ -1,79 +1,76 @@
#ifndef __Bkmks_h
#define __Bkmks_h
#include "config.h"
#include "Filedata.h"
#include <stdio.h>
template<class T>
class CList;
class Bkmk
{
friend class BkmkFile;
unsigned char* m_name;
unsigned short m_namelen;
unsigned char* m_anno;
unsigned short m_annolen;
unsigned int m_position;
unsigned int m_position2;
unsigned char m_red,m_green,m_blue, m_level;
void init(const void*, unsigned short, const void*, unsigned short, unsigned int);
public:
- Bkmk() : m_name(NULL), m_namelen(0), m_anno(NULL), m_annolen(0), m_position(0) {};
+ Bkmk() : m_name(0), m_namelen(0), m_anno(0), m_annolen(0), m_position(0) {};
Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p);
Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short _annolen, unsigned int _p);
Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p);
Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2);
- Bkmk(const Bkmk& rhs) : m_name(NULL), m_anno(NULL)
- {
- *this = rhs;
- }
+ Bkmk(const Bkmk& rhs);
~Bkmk();
unsigned int value() const { return m_position; }
void value(unsigned int _v) { m_position = _v; }
unsigned int value2() const { return m_position2; }
void value2(unsigned int _v) { m_position2 = _v; }
unsigned char red() { return m_red; }
unsigned char green() { return m_green; }
unsigned char blue() { return m_blue; }
void red(unsigned char _v) { m_red = _v; }
void green(unsigned char _v) { m_green = _v; }
void blue(unsigned char _v) { m_blue = _v; }
unsigned char level() { return m_level; }
void level(unsigned char _v) { m_level = _v; }
tchar *name() const { return (tchar*)m_name; }
tchar *anno() const { return (tchar*)m_anno; }
bool operator<(const Bkmk& rhs) { return (m_position < rhs.m_position); }
Bkmk& operator=(const Bkmk& rhs);
bool operator==(const Bkmk& rhs);
void setAnno(tchar* t);
void setAnno(unsigned char* t, unsigned short len);
unsigned char* filedata()
{
CFiledata fd(anno());
return m_anno+fd.length();
}
unsigned short filedatalen()
{
CFiledata fd(anno());
return m_annolen - fd.length();
}
};
class BkmkFile
{
FILE* f;
bool wt;
bool isUpgraded, m_extras;
static const unsigned long magic;
private:
static Bkmk* read07(BkmkFile*, FILE*);
static Bkmk* read06(BkmkFile*, FILE*);
static Bkmk* read05(BkmkFile*, FILE*);
static Bkmk* read03(BkmkFile*, FILE*);
CList<Bkmk>* readall00(Bkmk*(*fn)(BkmkFile*, FILE*));
void write(const Bkmk& b);
public:
bool upgraded() { return isUpgraded; }
BkmkFile(const char *fnm, bool w, bool _x);
diff --git a/noncore/apps/opie-reader/StyleConsts.cpp b/noncore/apps/opie-reader/StyleConsts.cpp
index 77c9d3b..c19fa3d 100644
--- a/noncore/apps/opie-reader/StyleConsts.cpp
+++ b/noncore/apps/opie-reader/StyleConsts.cpp
@@ -1,54 +1,61 @@
#include <qimage.h>
#include "StyleConsts.h"
GraphicLink::~GraphicLink() { delete graphic; }
+pmstore::pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) :
+ count(1),
+ m_isScaleable(_canScale)
+{
+ graphic = new GraphicLink(p, isLnk, tgt);
+}
+
pmstore::~pmstore()
{
//// qDebug("Deleting image");
delete graphic;
}
CStyle::~CStyle()
{
if (graphic != NULL)
{
if (--(graphic->count) == 0)
{
delete graphic;
}
}
}
CStyle::CStyle(const CStyle& rhs) : graphic(NULL)
{
*this = rhs;
}
CStyle& CStyle::operator=(const CStyle& rhs)
{
if (rhs.graphic != NULL)
{
(rhs.graphic->count)++;
if (graphic != NULL)
{
if (--(graphic->count) == 0)
{
delete graphic;
}
}
graphic = rhs.graphic;
}
else
{
if (graphic != NULL)
{
if (--(graphic->count) == 0)
{
delete graphic;
}
graphic = NULL;
}
}
sty = rhs.sty;
diff --git a/noncore/apps/opie-reader/StyleConsts.h b/noncore/apps/opie-reader/StyleConsts.h
index 4b7ff4b..5fd9669 100644
--- a/noncore/apps/opie-reader/StyleConsts.h
+++ b/noncore/apps/opie-reader/StyleConsts.h
@@ -1,80 +1,78 @@
#ifndef __STYLECONSTS_H
#define __STYLECONSTS_H
typedef unsigned short StyleType;
#ifdef _WINDOWS
#include <string.h>
#endif
#include <string.h>
#include <stdlib.h>
#include <qglobal.h>
class QImage;
struct GraphicLink
{
QImage* graphic;
bool isLink;
unsigned long link;
GraphicLink(QImage* p, bool isLnk, unsigned long tgt) :
graphic(p), isLink(isLnk), link(tgt) {}
~GraphicLink();
};
-struct pmstore
+class pmstore
{
+ public:
unsigned int count;
bool m_isScaleable;
GraphicLink* graphic;
- pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) : count(1), m_isScaleable(_canScale)
- {
- graphic = new GraphicLink(p, isLnk, tgt);
- }
+ pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt);
~pmstore();
};
enum EalignmentType
{
m_AlignLeft,
m_AlignRight,
m_AlignCentre,
m_AlignJustify,
m_AlignNone
};
class CBasicStyle
{
friend class CStyle;
bool m_bold,
m_italic;
unsigned long m_table;
int m_fontsize;
EalignmentType m_align;
unsigned char red, green, blue;
unsigned char bred, bgreen, bblue;
unsigned char pred, pgreen, pblue;
unsigned long data;
unsigned long offset;
bool isLink;
// bool isVisited;
bool m_underline;
bool m_strikethru;
bool m_monospaced;
unsigned char m_leftmargin, m_rightmargin;
signed char m_extraspace;
signed char m_voffset;
CBasicStyle()
{
unset();
m_table = 0xffffffff;
}
bool operator!=(const CBasicStyle& rhs)
{
return (memcmp(this, &rhs, sizeof(CBasicStyle)) != 0);
}
void unset()
{
m_bold = false;
m_italic = false;
m_fontsize = 0;
m_align = m_AlignLeft;
diff --git a/noncore/apps/opie-write/qrichtext.cpp b/noncore/apps/opie-write/qrichtext.cpp
index c27eb1e..f040f1e 100644
--- a/noncore/apps/opie-write/qrichtext.cpp
+++ b/noncore/apps/opie-write/qrichtext.cpp
@@ -6015,197 +6015,196 @@ QTextFormat QTextFormat::makeTextFormat( const QStyleSheetItem *style, const QMa
format.setPointSize( int( scaleFontsFactor * style.mid( 10, style.length() - 12 ).toInt() ) );
} if ( style.startsWith("font-style:" ) ) {
QString s = style.mid( 11 ).stripWhiteSpace();
if ( s == "normal" )
format.fn.setItalic( FALSE );
else if ( s == "italic" || s == "oblique" )
format.fn.setItalic( TRUE );
} else if ( style.startsWith("font-weight:" ) ) {
QString s = style.mid( 12 );
bool ok = TRUE;
int n = s.toInt( &ok );
if ( ok )
format.fn.setWeight( n/8 );
} else if ( style.startsWith("font-family:" ) ) {
format.fn.setFamily( QTextDocument::section(style.mid(12),",",0,0).stripWhiteSpace() );
} else if ( style.startsWith("text-decoration:" ) ) {
QString s = style.mid( 16 ).stripWhiteSpace();
format.fn.setUnderline( s == "underline" );
} else if ( style.startsWith("vertical-align:" ) ) {
QString s = style.mid( 15 ).stripWhiteSpace();
if ( s == "sub" )
format.setVAlign( QTextFormat::AlignSubScript );
else if ( s == "super" )
format.setVAlign( QTextFormat::AlignSuperScript );
else
format.setVAlign( QTextFormat::AlignNormal );
} else if ( style.startsWith("color:" ) ) {
format.col.setNamedColor( style.mid(6) );
format.linkColor = FALSE;
}
}
}
format.update();
return format;
}
struct QPixmapInt
{
QPixmapInt() : ref( 0 ) {}
QPixmap pm;
int ref;
};
static QMap<QString, QPixmapInt> *pixmap_map = 0;
QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context,
QMimeSourceFactory &factory )
- : QTextCustomItem( p )
+ : QTextCustomItem( p ), reg( 0 )
{
width = height = 0;
if ( attr.contains("width") )
width = attr["width"].toInt();
if ( attr.contains("height") )
height = attr["height"].toInt();
- reg = 0;
QString imageName = attr["src"];
if (!imageName)
imageName = attr["source"];
if ( !imageName.isEmpty() ) {
imgId = QString( "%1,%2,%3,%4" ).arg( imageName ).arg( width ).arg( height ).arg( (ulong)&factory );
if ( !pixmap_map )
pixmap_map = new QMap<QString, QPixmapInt>;
if ( pixmap_map->contains( imgId ) ) {
QPixmapInt& pmi = pixmap_map->operator[](imgId);
pm = pmi.pm;
pmi.ref++;
width = pm.width();
height = pm.height();
} else {
QImage img;
const QMimeSource* m =
factory.data( imageName, context );
if ( !m ) {
owarn << "QTextImage: no mimesource for " << imageName.latin1() << "" << oendl;
}
else {
if ( !QImageDrag::decode( m, img ) ) {
owarn << "QTextImage: cannot decode " << imageName.latin1() << "" << oendl;
}
}
if ( !img.isNull() ) {
if ( width == 0 ) {
width = img.width();
if ( height != 0 ) {
width = img.width() * height / img.height();
}
}
if ( height == 0 ) {
height = img.height();
if ( width != img.width() ) {
height = img.height() * width / img.width();
}
}
if ( img.width() != width || img.height() != height ){
#ifndef QT_NO_IMAGE_SMOOTHSCALE
img = img.smoothScale(width, height);
#endif
width = img.width();
height = img.height();
}
pm.convertFromImage( img );
}
if ( !pm.isNull() ) {
QPixmapInt& pmi = pixmap_map->operator[](imgId);
pmi.pm = pm;
pmi.ref++;
}
}
if ( pm.mask() ) {
QRegion mask( *pm.mask() );
QRegion all( 0, 0, pm.width(), pm.height() );
reg = new QRegion( all.subtract( mask ) );
}
}
if ( pm.isNull() && (width*height)==0 )
width = height = 50;
place = PlaceInline;
if ( attr["align"] == "left" )
place = PlaceLeft;
else if ( attr["align"] == "right" )
place = PlaceRight;
tmpwidth = width;
tmpheight = height;
attributes = attr;
}
QTextImage::~QTextImage()
{
+ delete reg;
if ( pixmap_map && pixmap_map->contains( imgId ) ) {
QPixmapInt& pmi = pixmap_map->operator[](imgId);
pmi.ref--;
if ( !pmi.ref ) {
pixmap_map->remove( imgId );
if ( pixmap_map->isEmpty() ) {
delete pixmap_map;
pixmap_map = 0;
}
}
}
- delete reg;
}
QString QTextImage::richText() const
{
QString s;
s += "<img ";
QMap<QString, QString>::ConstIterator it = attributes.begin();
for ( ; it != attributes.end(); ++it )
s += it.key() + "=" + *it + " ";
s += ">";
return s;
}
void QTextImage::adjustToPainter( QPainter* p )
{
width = scale( tmpwidth, p );
height = scale( tmpheight, p );
}
#if !defined(Q_WS_X11)
#include <qbitmap.h>
#include "qcleanuphandler.h"
static QPixmap *qrt_selection = 0;
static QSingleCleanupHandler<QPixmap> qrt_cleanup_pixmap;
static void qrt_createSelectionPixmap( const QColorGroup &cg )
{
qrt_selection = new QPixmap( 2, 2 );
qrt_cleanup_pixmap.set( &qrt_selection );
qrt_selection->fill( Qt::color0 );
QBitmap m( 2, 2 );
m.fill( Qt::color1 );
QPainter p( &m );
p.setPen( Qt::color0 );
for ( int j = 0; j < 2; ++j ) {
p.drawPoint( j % 2, j );
}
p.end();
qrt_selection->setMask( m );
qrt_selection->fill( cg.highlight() );
}
#endif
void QTextImage::draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected )
{
if ( placement() != PlaceInline ) {
x = xpos;
y = ypos;
}
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.cpp b/noncore/apps/tinykate/libkate/document/katehighlight.cpp
index 539d356..89024f7 100644
--- a/noncore/apps/tinykate/libkate/document/katehighlight.cpp
+++ b/noncore/apps/tinykate/libkate/document/katehighlight.cpp
@@ -344,103 +344,108 @@ const QChar *HlCHex::checkHgl(const QChar *str, int len, bool) {
#if 0
int i;
for (i=0;(*s)!='\0';s++,i++);
QString line(str,i);
QRegExp3 rx("0[xX][a-fA-F\\d]+[UuLl]?"); // this matches but is also matching parenthesis
int pos=rx.search(line,0);
if(pos > -1) return str+rx.matchedLength();
else
return 0L;
#else
if (str[0] == '0' && ((str[1]&0xdf) == 'X' )) {
str += 2;
s = str;
while (s->isDigit() || ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') /*|| (*s >= 'a' && *s <= 'f')*/) s++;
if (s > str) {
if ((*s&0xdf) == 'L' || (*s&0xdf) == 'U' ) s++;
return s;
}
}
return 0L;
#endif
}
HlCFloat::HlCFloat(int attribute, int context)
: HlFloat(attribute,context) {
}
const QChar *HlCFloat::checkHgl(const QChar *s, int len, bool lineStart) {
s = HlFloat::checkHgl(s, len, lineStart);
if (s && ((*s&0xdf) == 'F' )) s++;
return s;
}
HlAnyChar::HlAnyChar(int attribute, int context, const QChar* charList, uint len)
: HlItem(attribute, context) {
_charList=charList;
_charListLen=len;
}
const QChar *HlAnyChar::checkHgl(const QChar *s, int len, bool)
{
if (ustrchr(_charList, _charListLen, *s)) return s +1;
return 0L;
}
HlRegExpr::HlRegExpr(int attribute, int context,QString regexp)
- : HlItem(attribute, context) {
+ : HlItem(attribute, context), Expr(0) {
handlesLinestart=regexp.startsWith("^");
if(!handlesLinestart) regexp.prepend("^");
Expr=new QRegExp3(regexp);
}
+HlRegExpr::~HlRegExpr()
+{
+ delete Expr;
+}
+
const QChar *HlRegExpr::checkHgl(const QChar *s, int len, bool lineStart)
{
if ((!lineStart) && handlesLinestart) return 0;
QString line(s,len);
int pos = Expr->search( line, 0 );
if (pos==-1) return 0L;
else
return (s+Expr->matchedLength());
};
HlLineContinue::HlLineContinue(int attribute, int context)
: HlItem(attribute,context) {
}
const QChar *HlLineContinue::checkHgl(const QChar *s, int len, bool) {
if ((s[0].latin1() == '\\') && (len == 1))
{
return s + 1;
}
return 0L;
}
HlCStringChar::HlCStringChar(int attribute, int context)
: HlItem(attribute,context) {
}
//checks for hex and oct (for example \x1b or \033)
const QChar *checkCharHexOct(const QChar *str) {
const QChar *s;
s=str;
int n;
if (*s == 'x') {
n = 0;
do {
s++;
n *= 16;
if (s->isDigit()) n += *s - '0';
else if ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') n += (*s&0xdf) - 'A' + 10;
// else if (*s >= 'a' && *s <= 'f') n += *s - 'a' + 10;
else break;
if (n >= 256) return 0L;
} while (true);
if (s - str == 1) return 0L;
} else {
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.h b/noncore/apps/tinykate/libkate/document/katehighlight.h
index fddf585..f0be27b 100644
--- a/noncore/apps/tinykate/libkate/document/katehighlight.h
+++ b/noncore/apps/tinykate/libkate/document/katehighlight.h
@@ -139,97 +139,97 @@ class HlCInt : public HlInt {
class HlCOct : public HlItem {
public:
HlCOct(int attribute, int context);
virtual const QChar *checkHgl(const QChar *, int len, bool);
};
class HlCHex : public HlItem {
public:
HlCHex(int attribute, int context);
virtual const QChar *checkHgl(const QChar *, int len, bool);
};
class HlCFloat : public HlFloat {
public:
HlCFloat(int attribute, int context);
virtual const QChar *checkHgl(const QChar *, int len, bool);
};
class HlLineContinue : public HlItem {
public:
HlLineContinue(int attribute, int context);
virtual bool endEnable(QChar c) {return c == '\0';}
virtual const QChar *checkHgl(const QChar *, int len, bool);
};
class HlCStringChar : public HlItem {
public:
HlCStringChar(int attribute, int context);
virtual const QChar *checkHgl(const QChar *, int len, bool);
};
class HlCChar : public HlItem {
public:
HlCChar(int attribute, int context);
virtual const QChar *checkHgl(const QChar *, int len, bool);
};
class HlAnyChar : public HlItem {
public:
HlAnyChar(int attribute, int context, const QChar* charList, uint len);
virtual const QChar *checkHgl(const QChar *, int len, bool);
const QChar* _charList;
uint _charListLen;
};
class HlRegExpr : public HlItem {
public:
HlRegExpr(int attribute, int context,QString expr);
- ~HlRegExpr(){delete Expr;};
+ ~HlRegExpr();
virtual const QChar *checkHgl(const QChar *, int len, bool);
QRegExp3 *Expr;
bool handlesLinestart;
};
//--------
//Item Style: color, selected color, bold, italic
class ItemStyle {
public:
ItemStyle();
// ItemStyle(const ItemStyle &);
ItemStyle(const QColor &, const QColor &, bool bold, bool italic);
ItemStyle(ItemStyle *its){col=its->col;selCol=its->selCol; bold=its->bold; italic=its->italic;}
// void setData(const ItemStyle &);
QColor col;
QColor selCol;
int bold; //boolean value
int italic; //boolean value
};
typedef QList<ItemStyle> ItemStyleList;
//Item Properties: name, Item Style, Item Font
class ItemData : public ItemStyle {
public:
ItemData(const QString name, int defStyleNum);
ItemData(const QString name, int defStyleNum,
const QColor&, const QColor&, bool bold, bool italic);
ItemData(ItemData
*itd):ItemStyle((ItemStyle*)itd),name(itd->name),defStyleNum(itd->defStyleNum),defStyle(itd->defStyle){;}
const QString name;
int defStyleNum;
int defStyle; //boolean value
};
typedef QList<ItemData> ItemDataList;
class HlData {
public:
HlData(const QString &wildcards, const QString &mimetypes,const QString &identifier);
ItemDataList itemDataList;
QString wildcards;
QString mimetypes;
QString identifier;
};