Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef WPS8_STRUCT_H
00027 #define WPS8_STRUCT_H
00028
00029 #include <string>
00030 #include <vector>
00031
00032 #include "libwps_internal.h"
00033
00035
00037
00039 namespace WPS8Struct
00040 {
00041 struct FileData;
00043 bool readData(RVNGInputStreamPtr input, long endPos, FileData &dt, std::string &error);
00045 bool readBlockData(RVNGInputStreamPtr input, long endPos, FileData &dt, std::string &error);
00047 std::ostream &operator<< (std::ostream &o, FileData const &dt);
00048
00063 struct FileData
00064 {
00066 FileData() : m_value(0), m_text(""), m_recursData(), m_type(-1), m_id(-1), m_beginOffset(-1), m_endOffset(-1), m_input() {}
00068 bool isBad() const
00069 {
00070 return m_type==-1;
00071 }
00073 bool hasStr() const
00074 {
00075 return m_text.size() != 0;
00076 }
00078 bool isNumber() const
00079 {
00080 return !hasStr() && (m_type & 0x30) != 0;
00081 }
00083 uint32_t getRGBColor() const
00084 {
00085 uint32_t col = (uint32_t)(m_value&0xFFFFFF);
00086 return (((col>>16)&0xFF) |(col&0xFF00)|((col&0xFF)<<16));
00087 }
00089 WPSBorder::Style getBorderStyle(std::string &mess) const;
00090
00092 bool isBool() const
00093 {
00094 return !hasStr() && (m_type & 0xb0)==0;
00095 }
00097 bool isTrue() const
00098 {
00099 return m_type == 0xa;
00100 }
00102 bool isFalse() const
00103 {
00104 return m_type == 0x2;
00105 }
00107 bool isArray() const
00108 {
00109 return !hasStr() && (m_type & 0x80)==0x80;
00110 }
00112 bool isRead() const
00113 {
00114 return (m_type & 0x80) !=0x80 || !(m_input.get() && m_beginOffset > 0 && m_endOffset >= m_beginOffset+2);
00115 }
00116
00118 int type() const
00119 {
00120 if (m_type == 0xa) return 2;
00121 return m_type;
00122 }
00124 int id() const
00125 {
00126 return m_id;
00127 }
00128
00130 bool readArrayBlock() const;
00131
00133 long m_value;
00135 std::string m_text;
00137 std::vector<FileData> m_recursData;
00138
00140 long begin() const
00141 {
00142 return m_beginOffset;
00143 }
00145 long end() const
00146 {
00147 return m_endOffset;
00148 }
00149 protected:
00151 static std::string createErrorString(RVNGInputStreamPtr input, long endPos);
00152
00154 int m_type;
00156 int m_id;
00157
00158 long m_beginOffset , m_endOffset ;
00160 RVNGInputStreamPtr m_input;
00161
00163 friend std::ostream &operator<< (std::ostream &o, FileData const &dt);
00165 friend bool readData(RVNGInputStreamPtr input, long endPos, FileData &dt, std::string &error);
00167 friend bool readBlockData(RVNGInputStreamPtr input, long endPos, FileData &dt, std::string &error);
00168 };
00169 }
00170
00171 #endif
00172