-rw-r--r-- | noncore/apps/opie-reader/Bkmks.cpp | 18 | ||||
-rw-r--r-- | noncore/apps/opie-reader/Bkmks.h | 7 | ||||
-rw-r--r-- | noncore/apps/opie-reader/StyleConsts.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/opie-reader/StyleConsts.h | 8 |
4 files changed, 29 insertions, 11 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 @@ | |||
1 | #include <qmessagebox.h> | 1 | #include <qmessagebox.h> |
2 | 2 | ||
3 | #include "Bkmks.h" | 3 | #include "Bkmks.h" |
4 | 4 | ||
5 | #include "StyleConsts.h" | 5 | #include "StyleConsts.h" |
6 | #include "Markups.h" | 6 | #include "Markups.h" |
7 | #include "my_list.h" | 7 | #include "my_list.h" |
8 | #include "version.h" | 8 | #include "version.h" |
9 | #include "names.h" | 9 | #include "names.h" |
10 | 10 | ||
11 | const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE); | 11 | const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE); |
12 | 12 | ||
13 | Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p) | 13 | Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p) : |
14 | m_name(0), | ||
15 | m_namelen(0), | ||
16 | m_anno(0), | ||
17 | m_annolen(0), | ||
18 | m_position(0) | ||
14 | { | 19 | { |
15 | init(_nm, _nmlen, _anno, _annolen, _p); | 20 | init(_nm, _nmlen, _anno, _annolen, _p); |
16 | } | 21 | } |
17 | 22 | ||
18 | Bkmk::Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short annolen, unsigned int _p) : m_position(_p) | 23 | Bkmk::Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short annolen, unsigned int _p) : m_position(_p) |
19 | { | 24 | { |
20 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, annolen, _p); | 25 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, annolen, _p); |
21 | } | 26 | } |
22 | 27 | ||
28 | Bkmk::Bkmk(const Bkmk& rhs) : | ||
29 | m_name(0), | ||
30 | m_namelen(0), | ||
31 | m_anno(0), | ||
32 | m_annolen(0), | ||
33 | m_position(0) | ||
34 | { | ||
35 | init(rhs.name(), sizeof(tchar)*(ustrlen(rhs.name())+1), rhs.anno(), | ||
36 | sizeof(tchar)*(ustrlen(rhs.anno())+1), rhs.value()); | ||
37 | } | ||
38 | |||
23 | Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p) | 39 | Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p) |
24 | { | 40 | { |
25 | if (_anno == NULL) | 41 | if (_anno == NULL) |
26 | { | 42 | { |
27 | tchar t = 0; | 43 | tchar t = 0; |
28 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p); | 44 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p); |
29 | } | 45 | } |
30 | else | 46 | else |
31 | { | 47 | { |
32 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p); | 48 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p); |
33 | } | 49 | } |
34 | } | 50 | } |
35 | 51 | ||
36 | Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2) : m_position(_p) | 52 | Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2) : m_position(_p) |
37 | { | 53 | { |
38 | if (_anno == NULL) | 54 | if (_anno == NULL) |
39 | { | 55 | { |
40 | tchar t = 0; | 56 | tchar t = 0; |
41 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p); | 57 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p); |
42 | } | 58 | } |
43 | else | 59 | else |
44 | { | 60 | { |
45 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p); | 61 | init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _p); |
46 | } | 62 | } |
47 | m_position2 = _p2; | 63 | m_position2 = _p2; |
48 | m_red = m_green = m_blue = 127; | 64 | m_red = m_green = m_blue = 127; |
49 | } | 65 | } |
50 | 66 | ||
51 | void Bkmk::init(const void* _nm, unsigned short _nmlen, const void* _anno, unsigned short _annolen, unsigned int _p) | 67 | void Bkmk::init(const void* _nm, unsigned short _nmlen, const void* _anno, unsigned short _annolen, unsigned int _p) |
52 | { | 68 | { |
53 | m_namelen = _nmlen; | 69 | m_namelen = _nmlen; |
54 | if (m_namelen > 0) | 70 | if (m_namelen > 0) |
55 | { | 71 | { |
56 | m_name = new unsigned char[m_namelen]; | 72 | m_name = new unsigned char[m_namelen]; |
57 | memcpy(m_name, _nm, m_namelen); | 73 | memcpy(m_name, _nm, m_namelen); |
58 | } | 74 | } |
59 | else | 75 | else |
60 | { | 76 | { |
61 | m_name = NULL; | 77 | m_name = NULL; |
62 | } | 78 | } |
63 | 79 | ||
64 | m_annolen = _annolen; | 80 | m_annolen = _annolen; |
65 | if (m_annolen > 0) | 81 | if (m_annolen > 0) |
66 | { | 82 | { |
67 | m_anno = new unsigned char[m_annolen]; | 83 | m_anno = new unsigned char[m_annolen]; |
68 | memcpy(m_anno, _anno, m_annolen); | 84 | memcpy(m_anno, _anno, m_annolen); |
69 | } | 85 | } |
70 | else | 86 | 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 @@ | |||
1 | #ifndef __Bkmks_h | 1 | #ifndef __Bkmks_h |
2 | #define __Bkmks_h | 2 | #define __Bkmks_h |
3 | 3 | ||
4 | #include "config.h" | 4 | #include "config.h" |
5 | #include "Filedata.h" | 5 | #include "Filedata.h" |
6 | #include <stdio.h> | 6 | #include <stdio.h> |
7 | 7 | ||
8 | template<class T> | 8 | template<class T> |
9 | class CList; | 9 | class CList; |
10 | 10 | ||
11 | class Bkmk | 11 | class Bkmk |
12 | { | 12 | { |
13 | friend class BkmkFile; | 13 | friend class BkmkFile; |
14 | unsigned char* m_name; | 14 | unsigned char* m_name; |
15 | unsigned short m_namelen; | 15 | unsigned short m_namelen; |
16 | unsigned char* m_anno; | 16 | unsigned char* m_anno; |
17 | unsigned short m_annolen; | 17 | unsigned short m_annolen; |
18 | unsigned int m_position; | 18 | unsigned int m_position; |
19 | unsigned int m_position2; | 19 | unsigned int m_position2; |
20 | unsigned char m_red,m_green,m_blue, m_level; | 20 | unsigned char m_red,m_green,m_blue, m_level; |
21 | void init(const void*, unsigned short, const void*, unsigned short, unsigned int); | 21 | void init(const void*, unsigned short, const void*, unsigned short, unsigned int); |
22 | public: | 22 | public: |
23 | Bkmk() : m_name(NULL), m_namelen(0), m_anno(NULL), m_annolen(0), m_position(0) {}; | 23 | Bkmk() : m_name(0), m_namelen(0), m_anno(0), m_annolen(0), m_position(0) {}; |
24 | Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); | 24 | Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); |
25 | Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); | 25 | Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); |
26 | Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p); | 26 | Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p); |
27 | Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2); | 27 | Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2); |
28 | Bkmk(const Bkmk& rhs) : m_name(NULL), m_anno(NULL) | 28 | Bkmk(const Bkmk& rhs); |
29 | { | ||
30 | *this = rhs; | ||
31 | } | ||
32 | ~Bkmk(); | 29 | ~Bkmk(); |
33 | unsigned int value() const { return m_position; } | 30 | unsigned int value() const { return m_position; } |
34 | void value(unsigned int _v) { m_position = _v; } | 31 | void value(unsigned int _v) { m_position = _v; } |
35 | unsigned int value2() const { return m_position2; } | 32 | unsigned int value2() const { return m_position2; } |
36 | void value2(unsigned int _v) { m_position2 = _v; } | 33 | void value2(unsigned int _v) { m_position2 = _v; } |
37 | unsigned char red() { return m_red; } | 34 | unsigned char red() { return m_red; } |
38 | unsigned char green() { return m_green; } | 35 | unsigned char green() { return m_green; } |
39 | unsigned char blue() { return m_blue; } | 36 | unsigned char blue() { return m_blue; } |
40 | void red(unsigned char _v) { m_red = _v; } | 37 | void red(unsigned char _v) { m_red = _v; } |
41 | void green(unsigned char _v) { m_green = _v; } | 38 | void green(unsigned char _v) { m_green = _v; } |
42 | void blue(unsigned char _v) { m_blue = _v; } | 39 | void blue(unsigned char _v) { m_blue = _v; } |
43 | unsigned char level() { return m_level; } | 40 | unsigned char level() { return m_level; } |
44 | void level(unsigned char _v) { m_level = _v; } | 41 | void level(unsigned char _v) { m_level = _v; } |
45 | tchar *name() const { return (tchar*)m_name; } | 42 | tchar *name() const { return (tchar*)m_name; } |
46 | tchar *anno() const { return (tchar*)m_anno; } | 43 | tchar *anno() const { return (tchar*)m_anno; } |
47 | bool operator<(const Bkmk& rhs) { return (m_position < rhs.m_position); } | 44 | bool operator<(const Bkmk& rhs) { return (m_position < rhs.m_position); } |
48 | Bkmk& operator=(const Bkmk& rhs); | 45 | Bkmk& operator=(const Bkmk& rhs); |
49 | bool operator==(const Bkmk& rhs); | 46 | bool operator==(const Bkmk& rhs); |
50 | void setAnno(tchar* t); | 47 | void setAnno(tchar* t); |
51 | void setAnno(unsigned char* t, unsigned short len); | 48 | void setAnno(unsigned char* t, unsigned short len); |
52 | unsigned char* filedata() | 49 | unsigned char* filedata() |
53 | { | 50 | { |
54 | CFiledata fd(anno()); | 51 | CFiledata fd(anno()); |
55 | return m_anno+fd.length(); | 52 | return m_anno+fd.length(); |
56 | } | 53 | } |
57 | unsigned short filedatalen() | 54 | unsigned short filedatalen() |
58 | { | 55 | { |
59 | CFiledata fd(anno()); | 56 | CFiledata fd(anno()); |
60 | return m_annolen - fd.length(); | 57 | return m_annolen - fd.length(); |
61 | } | 58 | } |
62 | }; | 59 | }; |
63 | 60 | ||
64 | class BkmkFile | 61 | class BkmkFile |
65 | { | 62 | { |
66 | FILE* f; | 63 | FILE* f; |
67 | bool wt; | 64 | bool wt; |
68 | bool isUpgraded, m_extras; | 65 | bool isUpgraded, m_extras; |
69 | static const unsigned long magic; | 66 | static const unsigned long magic; |
70 | private: | 67 | private: |
71 | static Bkmk* read07(BkmkFile*, FILE*); | 68 | static Bkmk* read07(BkmkFile*, FILE*); |
72 | static Bkmk* read06(BkmkFile*, FILE*); | 69 | static Bkmk* read06(BkmkFile*, FILE*); |
73 | static Bkmk* read05(BkmkFile*, FILE*); | 70 | static Bkmk* read05(BkmkFile*, FILE*); |
74 | static Bkmk* read03(BkmkFile*, FILE*); | 71 | static Bkmk* read03(BkmkFile*, FILE*); |
75 | CList<Bkmk>* readall00(Bkmk*(*fn)(BkmkFile*, FILE*)); | 72 | CList<Bkmk>* readall00(Bkmk*(*fn)(BkmkFile*, FILE*)); |
76 | void write(const Bkmk& b); | 73 | void write(const Bkmk& b); |
77 | public: | 74 | public: |
78 | bool upgraded() { return isUpgraded; } | 75 | bool upgraded() { return isUpgraded; } |
79 | BkmkFile(const char *fnm, bool w, bool _x); | 76 | 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 @@ | |||
1 | 1 | ||
2 | #include <qimage.h> | 2 | #include <qimage.h> |
3 | #include "StyleConsts.h" | 3 | #include "StyleConsts.h" |
4 | 4 | ||
5 | GraphicLink::~GraphicLink() { delete graphic; } | 5 | GraphicLink::~GraphicLink() { delete graphic; } |
6 | 6 | ||
7 | pmstore::pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) : | ||
8 | count(1), | ||
9 | m_isScaleable(_canScale) | ||
10 | { | ||
11 | graphic = new GraphicLink(p, isLnk, tgt); | ||
12 | } | ||
13 | |||
7 | pmstore::~pmstore() | 14 | pmstore::~pmstore() |
8 | { | 15 | { |
9 | //// qDebug("Deleting image"); | 16 | //// qDebug("Deleting image"); |
10 | delete graphic; | 17 | delete graphic; |
11 | } | 18 | } |
12 | 19 | ||
13 | CStyle::~CStyle() | 20 | CStyle::~CStyle() |
14 | { | 21 | { |
15 | if (graphic != NULL) | 22 | if (graphic != NULL) |
16 | { | 23 | { |
17 | if (--(graphic->count) == 0) | 24 | if (--(graphic->count) == 0) |
18 | { | 25 | { |
19 | delete graphic; | 26 | delete graphic; |
20 | } | 27 | } |
21 | } | 28 | } |
22 | } | 29 | } |
23 | 30 | ||
24 | CStyle::CStyle(const CStyle& rhs) : graphic(NULL) | 31 | CStyle::CStyle(const CStyle& rhs) : graphic(NULL) |
25 | { | 32 | { |
26 | *this = rhs; | 33 | *this = rhs; |
27 | } | 34 | } |
28 | 35 | ||
29 | CStyle& CStyle::operator=(const CStyle& rhs) | 36 | CStyle& CStyle::operator=(const CStyle& rhs) |
30 | { | 37 | { |
31 | if (rhs.graphic != NULL) | 38 | if (rhs.graphic != NULL) |
32 | { | 39 | { |
33 | (rhs.graphic->count)++; | 40 | (rhs.graphic->count)++; |
34 | if (graphic != NULL) | 41 | if (graphic != NULL) |
35 | { | 42 | { |
36 | if (--(graphic->count) == 0) | 43 | if (--(graphic->count) == 0) |
37 | { | 44 | { |
38 | delete graphic; | 45 | delete graphic; |
39 | } | 46 | } |
40 | } | 47 | } |
41 | graphic = rhs.graphic; | 48 | graphic = rhs.graphic; |
42 | } | 49 | } |
43 | else | 50 | else |
44 | { | 51 | { |
45 | if (graphic != NULL) | 52 | if (graphic != NULL) |
46 | { | 53 | { |
47 | if (--(graphic->count) == 0) | 54 | if (--(graphic->count) == 0) |
48 | { | 55 | { |
49 | delete graphic; | 56 | delete graphic; |
50 | } | 57 | } |
51 | graphic = NULL; | 58 | graphic = NULL; |
52 | } | 59 | } |
53 | } | 60 | } |
54 | sty = rhs.sty; | 61 | 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 @@ | |||
1 | #ifndef __STYLECONSTS_H | 1 | #ifndef __STYLECONSTS_H |
2 | #define __STYLECONSTS_H | 2 | #define __STYLECONSTS_H |
3 | 3 | ||
4 | typedef unsigned short StyleType; | 4 | typedef unsigned short StyleType; |
5 | 5 | ||
6 | #ifdef _WINDOWS | 6 | #ifdef _WINDOWS |
7 | #include <string.h> | 7 | #include <string.h> |
8 | #endif | 8 | #endif |
9 | #include <string.h> | 9 | #include <string.h> |
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <qglobal.h> | 11 | #include <qglobal.h> |
12 | class QImage; | 12 | class QImage; |
13 | 13 | ||
14 | struct GraphicLink | 14 | struct GraphicLink |
15 | { | 15 | { |
16 | QImage* graphic; | 16 | QImage* graphic; |
17 | bool isLink; | 17 | bool isLink; |
18 | unsigned long link; | 18 | unsigned long link; |
19 | GraphicLink(QImage* p, bool isLnk, unsigned long tgt) : | 19 | GraphicLink(QImage* p, bool isLnk, unsigned long tgt) : |
20 | graphic(p), isLink(isLnk), link(tgt) {} | 20 | graphic(p), isLink(isLnk), link(tgt) {} |
21 | ~GraphicLink(); | 21 | ~GraphicLink(); |
22 | }; | 22 | }; |
23 | 23 | ||
24 | struct pmstore | 24 | class pmstore |
25 | { | 25 | { |
26 | public: | ||
26 | unsigned int count; | 27 | unsigned int count; |
27 | bool m_isScaleable; | 28 | bool m_isScaleable; |
28 | GraphicLink* graphic; | 29 | GraphicLink* graphic; |
29 | pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) : count(1), m_isScaleable(_canScale) | 30 | pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt); |
30 | { | ||
31 | graphic = new GraphicLink(p, isLnk, tgt); | ||
32 | } | ||
33 | ~pmstore(); | 31 | ~pmstore(); |
34 | }; | 32 | }; |
35 | 33 | ||
36 | enum EalignmentType | 34 | enum EalignmentType |
37 | { | 35 | { |
38 | m_AlignLeft, | 36 | m_AlignLeft, |
39 | m_AlignRight, | 37 | m_AlignRight, |
40 | m_AlignCentre, | 38 | m_AlignCentre, |
41 | m_AlignJustify, | 39 | m_AlignJustify, |
42 | m_AlignNone | 40 | m_AlignNone |
43 | }; | 41 | }; |
44 | 42 | ||
45 | class CBasicStyle | 43 | class CBasicStyle |
46 | { | 44 | { |
47 | friend class CStyle; | 45 | friend class CStyle; |
48 | bool m_bold, | 46 | bool m_bold, |
49 | m_italic; | 47 | m_italic; |
50 | unsigned long m_table; | 48 | unsigned long m_table; |
51 | int m_fontsize; | 49 | int m_fontsize; |
52 | EalignmentType m_align; | 50 | EalignmentType m_align; |
53 | unsigned char red, green, blue; | 51 | unsigned char red, green, blue; |
54 | unsigned char bred, bgreen, bblue; | 52 | unsigned char bred, bgreen, bblue; |
55 | unsigned char pred, pgreen, pblue; | 53 | unsigned char pred, pgreen, pblue; |
56 | unsigned long data; | 54 | unsigned long data; |
57 | unsigned long offset; | 55 | unsigned long offset; |
58 | bool isLink; | 56 | bool isLink; |
59 | // bool isVisited; | 57 | // bool isVisited; |
60 | bool m_underline; | 58 | bool m_underline; |
61 | bool m_strikethru; | 59 | bool m_strikethru; |
62 | bool m_monospaced; | 60 | bool m_monospaced; |
63 | unsigned char m_leftmargin, m_rightmargin; | 61 | unsigned char m_leftmargin, m_rightmargin; |
64 | signed char m_extraspace; | 62 | signed char m_extraspace; |
65 | signed char m_voffset; | 63 | signed char m_voffset; |
66 | CBasicStyle() | 64 | CBasicStyle() |
67 | { | 65 | { |
68 | unset(); | 66 | unset(); |
69 | m_table = 0xffffffff; | 67 | m_table = 0xffffffff; |
70 | } | 68 | } |
71 | bool operator!=(const CBasicStyle& rhs) | 69 | bool operator!=(const CBasicStyle& rhs) |
72 | { | 70 | { |
73 | return (memcmp(this, &rhs, sizeof(CBasicStyle)) != 0); | 71 | return (memcmp(this, &rhs, sizeof(CBasicStyle)) != 0); |
74 | } | 72 | } |
75 | void unset() | 73 | void unset() |
76 | { | 74 | { |
77 | m_bold = false; | 75 | m_bold = false; |
78 | m_italic = false; | 76 | m_italic = false; |
79 | m_fontsize = 0; | 77 | m_fontsize = 0; |
80 | m_align = m_AlignLeft; | 78 | m_align = m_AlignLeft; |