xlsxformat.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. /****************************************************************************
  2. ** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
  3. ** All right reserved.
  4. **
  5. ** Permission is hereby granted, free of charge, to any person obtaining
  6. ** a copy of this software and associated documentation files (the
  7. ** "Software"), to deal in the Software without restriction, including
  8. ** without limitation the rights to use, copy, modify, merge, publish,
  9. ** distribute, sublicense, and/or sell copies of the Software, and to
  10. ** permit persons to whom the Software is furnished to do so, subject to
  11. ** the following conditions:
  12. **
  13. ** The above copyright notice and this permission notice shall be
  14. ** included in all copies or substantial portions of the Software.
  15. **
  16. ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  17. ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18. ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  19. ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  20. ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  21. ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  22. ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. **
  24. ****************************************************************************/
  25. #ifndef QXLSX_FORMAT_H
  26. #define QXLSX_FORMAT_H
  27. #include "xlsxglobal.h"
  28. #include <QFont>
  29. #include <QColor>
  30. #include <QByteArray>
  31. #include <QList>
  32. #include <QExplicitlySharedDataPointer>
  33. #include <QVariant>
  34. class FormatTest;
  35. QT_BEGIN_NAMESPACE_XLSX
  36. class Styles;
  37. class Worksheet;
  38. class WorksheetPrivate;
  39. class RichStringPrivate;
  40. class SharedStrings;
  41. class FormatPrivate;
  42. class Q_XLSX_EXPORT Format
  43. {
  44. public:
  45. enum FontScript
  46. {
  47. FontScriptNormal,
  48. FontScriptSuper,
  49. FontScriptSub
  50. };
  51. enum FontUnderline
  52. {
  53. FontUnderlineNone,
  54. FontUnderlineSingle,
  55. FontUnderlineDouble,
  56. FontUnderlineSingleAccounting,
  57. FontUnderlineDoubleAccounting
  58. };
  59. enum HorizontalAlignment
  60. {
  61. AlignHGeneral,
  62. AlignLeft,
  63. AlignHCenter,
  64. AlignRight,
  65. AlignHFill,
  66. AlignHJustify,
  67. AlignHMerge,
  68. AlignHDistributed
  69. };
  70. enum VerticalAlignment
  71. {
  72. AlignTop,
  73. AlignVCenter,
  74. AlignBottom,
  75. AlignVJustify,
  76. AlignVDistributed
  77. };
  78. enum BorderStyle
  79. {
  80. BorderNone,
  81. BorderThin,
  82. BorderMedium,
  83. BorderDashed,
  84. BorderDotted,
  85. BorderThick,
  86. BorderDouble,
  87. BorderHair,
  88. BorderMediumDashed,
  89. BorderDashDot,
  90. BorderMediumDashDot,
  91. BorderDashDotDot,
  92. BorderMediumDashDotDot,
  93. BorderSlantDashDot
  94. };
  95. enum DiagonalBorderType
  96. {
  97. DiagonalBorderNone,
  98. DiagonalBorderDown,
  99. DiagonalBorderUp,
  100. DiagnoalBorderBoth
  101. };
  102. enum FillPattern
  103. {
  104. PatternNone,
  105. PatternSolid,
  106. PatternMediumGray,
  107. PatternDarkGray,
  108. PatternLightGray,
  109. PatternDarkHorizontal,
  110. PatternDarkVertical,
  111. PatternDarkDown,
  112. PatternDarkUp,
  113. PatternDarkGrid,
  114. PatternDarkTrellis,
  115. PatternLightHorizontal,
  116. PatternLightVertical,
  117. PatternLightDown,
  118. PatternLightUp,
  119. PatternLightTrellis,
  120. PatternGray125,
  121. PatternGray0625,
  122. PatternLightGrid
  123. };
  124. Format();
  125. Format(const Format &other);
  126. Format &operator=(const Format &rhs);
  127. ~Format();
  128. int numberFormatIndex() const;
  129. void setNumberFormatIndex(int format);
  130. QString numberFormat() const;
  131. void setNumberFormat(const QString &format);
  132. void setNumberFormat(int id, const QString &format);
  133. bool isDateTimeFormat() const;
  134. int fontSize() const;
  135. void setFontSize(int size);
  136. bool fontItalic() const;
  137. void setFontItalic(bool italic);
  138. bool fontStrikeOut() const;
  139. void setFontStrikeOut(bool);
  140. QColor fontColor() const;
  141. void setFontColor(const QColor &);
  142. bool fontBold() const;
  143. void setFontBold(bool bold);
  144. FontScript fontScript() const;
  145. void setFontScript(FontScript);
  146. FontUnderline fontUnderline() const;
  147. void setFontUnderline(FontUnderline);
  148. bool fontOutline() const;
  149. void setFontOutline(bool outline);
  150. QString fontName() const;
  151. void setFontName(const QString &);
  152. QFont font() const;
  153. void setFont(const QFont &font);
  154. HorizontalAlignment horizontalAlignment() const;
  155. void setHorizontalAlignment(HorizontalAlignment align);
  156. VerticalAlignment verticalAlignment() const;
  157. void setVerticalAlignment(VerticalAlignment align);
  158. bool textWrap() const;
  159. void setTextWarp(bool textWrap);
  160. int rotation() const;
  161. void setRotation(int rotation);
  162. int indent() const;
  163. void setIndent(int indent);
  164. bool shrinkToFit() const;
  165. void setShrinkToFit(bool shink);
  166. void setBorderStyle(BorderStyle style);
  167. void setBorderColor(const QColor &color);
  168. BorderStyle leftBorderStyle() const;
  169. void setLeftBorderStyle(BorderStyle style);
  170. QColor leftBorderColor() const;
  171. void setLeftBorderColor(const QColor &color);
  172. BorderStyle rightBorderStyle() const;
  173. void setRightBorderStyle(BorderStyle style);
  174. QColor rightBorderColor() const;
  175. void setRightBorderColor(const QColor &color);
  176. BorderStyle topBorderStyle() const;
  177. void setTopBorderStyle(BorderStyle style);
  178. QColor topBorderColor() const;
  179. void setTopBorderColor(const QColor &color);
  180. BorderStyle bottomBorderStyle() const;
  181. void setBottomBorderStyle(BorderStyle style);
  182. QColor bottomBorderColor() const;
  183. void setBottomBorderColor(const QColor &color);
  184. BorderStyle diagonalBorderStyle() const;
  185. void setDiagonalBorderStyle(BorderStyle style);
  186. DiagonalBorderType diagonalBorderType() const;
  187. void setDiagonalBorderType(DiagonalBorderType style);
  188. QColor diagonalBorderColor() const;
  189. void setDiagonalBorderColor(const QColor &color);
  190. FillPattern fillPattern() const;
  191. void setFillPattern(FillPattern pattern);
  192. QColor patternForegroundColor() const;
  193. void setPatternForegroundColor(const QColor &color);
  194. QColor patternBackgroundColor() const;
  195. void setPatternBackgroundColor(const QColor &color);
  196. bool locked() const;
  197. void setLocked(bool locked);
  198. bool hidden() const;
  199. void setHidden(bool hidden);
  200. void mergeFormat(const Format &modifier);
  201. bool isValid() const;
  202. bool isEmpty() const;
  203. bool operator == (const Format &format) const;
  204. bool operator != (const Format &format) const;
  205. QVariant property(int propertyId, const QVariant &defaultValue=QVariant()) const;
  206. void setProperty(int propertyId, const QVariant &value, const QVariant &clearValue=QVariant(), bool detach=true);
  207. void clearProperty(int propertyId);
  208. bool hasProperty(int propertyId) const;
  209. bool boolProperty(int propertyId, bool defaultValue=false) const;
  210. int intProperty(int propertyId, int defaultValue=0) const;
  211. double doubleProperty(int propertyId, double defaultValue = 0.0) const;
  212. QString stringProperty(int propertyId, const QString &defaultValue = QString()) const;
  213. QColor colorProperty(int propertyId, const QColor &defaultValue = QColor()) const;
  214. bool hasNumFmtData() const;
  215. bool hasFontData() const;
  216. bool hasFillData() const;
  217. bool hasBorderData() const;
  218. bool hasAlignmentData() const;
  219. bool hasProtectionData() const;
  220. bool fontIndexValid() const;
  221. int fontIndex() const;
  222. QByteArray fontKey() const;
  223. bool borderIndexValid() const;
  224. QByteArray borderKey() const;
  225. int borderIndex() const;
  226. bool fillIndexValid() const;
  227. QByteArray fillKey() const;
  228. int fillIndex() const;
  229. QByteArray formatKey() const;
  230. bool xfIndexValid() const;
  231. int xfIndex() const;
  232. bool dxfIndexValid() const;
  233. int dxfIndex() const;
  234. void fixNumberFormat(int id, const QString &format);
  235. void setFontIndex(int index);
  236. void setBorderIndex(int index);
  237. void setFillIndex(int index);
  238. void setXfIndex(int index);
  239. void setDxfIndex(int index);
  240. private:
  241. friend class Styles;
  242. friend class ::FormatTest;
  243. friend Q_XLSX_EXPORT QDebug operator<<(QDebug, const Format &f);
  244. int theme() const;
  245. QExplicitlySharedDataPointer<FormatPrivate> d;
  246. };
  247. #ifndef QT_NO_DEBUG_STREAM
  248. Q_XLSX_EXPORT QDebug operator<<(QDebug dbg, const Format &f);
  249. #endif
  250. QT_END_NAMESPACE_XLSX
  251. #endif // QXLSX_FORMAT_H