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
00027
00028
00029
00030
00031 #ifndef __VSDXSTYLES_H__
00032 #define __VSDXSTYLES_H__
00033
00034 #include <map>
00035 #include <vector>
00036 #include <libwpg/libwpg.h>
00037 #include "VSDXTypes.h"
00038
00039 namespace libvisio
00040 {
00041
00042 struct VSDXLineStyle
00043 {
00044 VSDXLineStyle()
00045 : width(0.01), colour(), pattern(0), startMarker(0), endMarker(0), cap(0) {}
00046 VSDXLineStyle(double w, Colour col, unsigned char p, unsigned char sm,
00047 unsigned char em, unsigned char c)
00048 : width(w), colour(col), pattern(p), startMarker(sm), endMarker(em), cap(c) {}
00049 VSDXLineStyle(const VSDXLineStyle &lineStyle)
00050 : width(lineStyle.width), colour(lineStyle.colour), pattern(lineStyle.pattern), startMarker(lineStyle.startMarker), endMarker(lineStyle.endMarker), cap(lineStyle.cap) {}
00051 ~VSDXLineStyle() {}
00052 double width;
00053 Colour colour;
00054 unsigned char pattern;
00055 unsigned char startMarker;
00056 unsigned char endMarker;
00057 unsigned char cap;
00058 };
00059
00060 struct VSDXFillStyle
00061 {
00062 VSDXFillStyle()
00063 : fgColourId(1), bgColourId(0), pattern(0), fgTransparency(0), bgTransparency(0), shadowFgColour(), shadowPattern(0), shadowOffsetX(0), shadowOffsetY(0) {}
00064 VSDXFillStyle(unsigned char fgcId, unsigned char bgcId, unsigned char p, unsigned char fga, unsigned char bga, Colour sfgc, unsigned char shp, double shX, double shY)
00065 : fgColourId(fgcId), bgColourId(bgcId), pattern(p), fgTransparency(fga), bgTransparency(bga), shadowFgColour(sfgc), shadowPattern(shp), shadowOffsetX(shX), shadowOffsetY(shY) {}
00066 VSDXFillStyle(const VSDXFillStyle &fillStyle)
00067 : fgColourId(fillStyle.fgColourId), bgColourId(fillStyle.bgColourId), pattern(fillStyle.pattern),
00068 fgTransparency(fillStyle.fgTransparency), bgTransparency(fillStyle.bgTransparency), shadowFgColour(fillStyle.shadowFgColour),
00069 shadowPattern(fillStyle.shadowPattern), shadowOffsetX(fillStyle.shadowOffsetX), shadowOffsetY(fillStyle.shadowOffsetY) {}
00070 ~VSDXFillStyle() {}
00071 unsigned char fgColourId;
00072
00073 unsigned char bgColourId;
00074
00075 unsigned char pattern;
00076
00077 unsigned char fgTransparency;
00078 unsigned char bgTransparency;
00079
00080 Colour shadowFgColour;
00081 unsigned char shadowPattern;
00082 double shadowOffsetX;
00083 double shadowOffsetY;
00084 };
00085
00086 struct VSDXCharStyle
00087 {
00088 VSDXCharStyle() :
00089 charCount(0),
00090 faceID(0),
00091 colour(),
00092 langID(0),
00093 size(12.0/72.0),
00094 bold(false),
00095 italic(false),
00096 underline(false),
00097 doubleunderline(false),
00098 strikeout(false),
00099 doublestrikeout(false),
00100 allcaps(false),
00101 initcaps(false),
00102 smallcaps(false),
00103 superscript(false),
00104 subscript(false),
00105 face("Arial") {}
00106 VSDXCharStyle(unsigned cc, unsigned short id, Colour c, unsigned lang, double s, bool b, bool i, bool u, bool du, bool so, bool dso, bool ac, bool ic, bool sc, bool super, bool sub, WPXString f) :
00107 charCount(cc),
00108 faceID(id),
00109 colour(c),
00110 langID(lang),
00111 size(s),
00112 bold(b),
00113 italic(i),
00114 underline(u),
00115 doubleunderline(du),
00116 strikeout(so),
00117 doublestrikeout(dso),
00118 allcaps(ac),
00119 initcaps(ic),
00120 smallcaps(sc),
00121 superscript(super),
00122 subscript(sub),
00123 face(f) {}
00124 ~VSDXCharStyle() {}
00125 unsigned charCount;
00126 unsigned short faceID;
00127 Colour colour;
00128 unsigned langID;
00129 double size;
00130 bool bold;
00131 bool italic;
00132 bool underline;
00133 bool doubleunderline;
00134 bool strikeout;
00135 bool doublestrikeout;
00136 bool allcaps;
00137 bool initcaps;
00138 bool smallcaps;
00139 bool superscript;
00140 bool subscript;
00141 WPXString face;
00142 };
00143
00144 struct VSDXParaStyle
00145 {
00146 VSDXParaStyle() :
00147 charCount(0),
00148 indFirst(0.0),
00149 indLeft(0.0),
00150 indRight(0.0),
00151 spLine(-1.2),
00152 spBefore(0.0),
00153 spAfter(0.0),
00154 align(1),
00155 flags(0) {}
00156 VSDXParaStyle(unsigned cc, double ifst, double il, double ir, double sl, double sb, double sa, unsigned char a, unsigned f) :
00157 charCount(cc),
00158 indFirst(ifst),
00159 indLeft(il),
00160 indRight(ir),
00161 spLine(sl),
00162 spBefore(sb),
00163 spAfter(sa),
00164 align(a),
00165 flags(f) {}
00166 ~VSDXParaStyle() {}
00167 unsigned charCount;
00168 double indFirst;
00169 double indLeft;
00170 double indRight;
00171 double spLine;
00172 double spBefore;
00173 double spAfter;
00174 unsigned char align;
00175 unsigned flags;
00176 };
00177
00178 struct VSDXTextBlockStyle
00179 {
00180 VSDXTextBlockStyle() :
00181 leftMargin(0.0),
00182 rightMargin(0.0),
00183 topMargin(0.0),
00184 bottomMargin(0.0),
00185 verticalAlign(0),
00186 textBkgndColourId(0),
00187 textBkgndColour(0xff,0xff,0xff,0),
00188 defaultTabStop(0.5),
00189 textDirection(0) {}
00190 VSDXTextBlockStyle(double lm, double rm, double tm, double bm, unsigned char va, unsigned char bgClrId, Colour bgClr, double defTab, unsigned char td) :
00191 leftMargin(lm),
00192 rightMargin(rm),
00193 topMargin(tm),
00194 bottomMargin(bm),
00195 verticalAlign(va),
00196 textBkgndColourId(bgClrId),
00197 textBkgndColour(bgClr),
00198 defaultTabStop(defTab),
00199 textDirection(td) {}
00200 ~VSDXTextBlockStyle() {}
00201 double leftMargin;
00202 double rightMargin;
00203 double topMargin;
00204 double bottomMargin;
00205 unsigned char verticalAlign;
00206 unsigned char textBkgndColourId;
00207 Colour textBkgndColour;
00208 double defaultTabStop;
00209 unsigned char textDirection;
00210 };
00211
00212 class VSDXStyles
00213 {
00214 public:
00215 VSDXStyles();
00216 VSDXStyles(const VSDXStyles &styles);
00217 ~VSDXStyles();
00218 VSDXStyles &operator=(const VSDXStyles &styles);
00219 void addLineStyle(unsigned lineStyleIndex, VSDXLineStyle *lineStyle);
00220 void addFillStyle(unsigned fillStyleIndex, VSDXFillStyle *fillStyle);
00221 void addTextBlockStyle(unsigned textStyleIndex, VSDXTextBlockStyle *textBlockStyle);
00222 void addCharStyle(unsigned textStyleIndex, VSDXCharStyle *charStyle);
00223 void addParaStyle(unsigned textStyleIndex, VSDXParaStyle *paraStyle);
00224
00225 void addLineStyleMaster(unsigned lineStyleIndex, unsigned lineStyleMaster);
00226 void addFillStyleMaster(unsigned fillStyleIndex, unsigned fillStyleMaster);
00227 void addTextStyleMaster(unsigned textStyleIndex, unsigned textStyleMaster);
00228
00229 const VSDXLineStyle *getLineStyle(unsigned lineStyleIndex) const;
00230 const VSDXFillStyle *getFillStyle(unsigned fillStyleIndex) const;
00231 const VSDXTextBlockStyle *getTextBlockStyle(unsigned textStyleIndex) const;
00232 const VSDXCharStyle *getCharStyle(unsigned textStyleIndex) const;
00233 const VSDXParaStyle *getParaStyle(unsigned textStyleIndex) const;
00234
00235 private:
00236 std::map<unsigned, VSDXLineStyle *> m_lineStyles;
00237 std::map<unsigned, VSDXFillStyle *> m_fillStyles;
00238 std::map<unsigned, VSDXTextBlockStyle *> m_textBlockStyles;
00239 std::map<unsigned, VSDXCharStyle *> m_charStyles;
00240 std::map<unsigned, VSDXParaStyle *> m_paraStyles;
00241 std::map<unsigned, unsigned> m_lineStyleMasters;
00242 std::map<unsigned, unsigned> m_fillStyleMasters;
00243 std::map<unsigned, unsigned> m_textStyleMasters;
00244 };
00245
00246
00247 }
00248
00249 #endif // __VSDXSTYLES_H__
00250