PageRenderTime 43ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/abiword-2.8.6/plugins/opendocument/exp/xp/ODe_Style_Style.h

#
C Header | 349 lines | 216 code | 70 blank | 63 comment | 1 complexity | 80cd260db5963590c8952e6eb30ac43e MD5 | raw file
Possible License(s): GPL-2.0
  1. /* AbiSource
  2. *
  3. * Copyright (C) 2005 INdT
  4. * Author: Daniel d'Andrada T. de Carvalho <daniel.carvalho@indt.org.br>
  5. * Copyright 2009 AbiSource Corporation B.V.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  20. * 02111-1307, USA.
  21. */
  22. #ifndef _ODE_STYLE_STYLE_H_
  23. #define _ODE_STYLE_STYLE_H_
  24. #include <vector>
  25. // AbiWord includes
  26. #include <ut_string_class.h>
  27. // External includes
  28. #include <gsf/gsf.h>
  29. // AbiWord classes
  30. class PP_AttrProp;
  31. class ODe_Style_List;
  32. /**
  33. * Class representing an OpenDocument <style:style> element.
  34. */
  35. class ODe_Style_Style {
  36. public:
  37. ODe_Style_Style();
  38. virtual ~ODe_Style_Style();
  39. // Write the <style:style> element.
  40. bool write(GsfOutput* pODT, const UT_UTF8String& rSpacesOffset) const;
  41. static bool hasTextStyleProps(const PP_AttrProp* pAP);
  42. static bool hasParagraphStyleProps(const PP_AttrProp* pAP);
  43. static bool hasSectionInfo(const PP_AttrProp* pAP);
  44. static bool hasTableStyleProps(const PP_AttrProp* pAP);
  45. // It does not take style names into consideration.
  46. // Read it like: "is style "T1" equivalent to style "T2"
  47. // It is *NOT* like: "is style A equal to style B"
  48. bool isEquivalentTo(const ODe_Style_Style& rStyle);
  49. bool isEmpty() const;
  50. ODe_Style_Style& operator=(const ODe_Style_Style& rStyle);
  51. // Defines the style from attributes and properties of an AbiWord <s>.
  52. bool fetchAttributesFromAbiStyle(const PP_AttrProp* pAP);
  53. // Defines the style from attributes and properties of an AbiWord <span>.
  54. void fetchAttributesFromAbiSpan(const PP_AttrProp* pAP);
  55. // Defines the style from attributes and properties of an AbiWord <p>.
  56. void fetchAttributesFromAbiBlock(const PP_AttrProp* pAP, const ODe_Style_List* pCurrentListStyle);
  57. // Defines the style from attributes and properties of an AbiWord <section>.
  58. void fetchAttributesFromAbiSection(const PP_AttrProp* pAP);
  59. // Defines the style from attributes and properties of an AbiWord <table>.
  60. void fetchAttributesFromAbiTable(const PP_AttrProp* pAP);
  61. // Defines the style from attributes and properties of an AbiWord <cell>.
  62. void fetchAttributesFromAbiCell(const PP_AttrProp* pAP);
  63. // Defines the style from attributes and properties of an AbiWord <frame>.
  64. void fetchAttributesFromAbiFrame(const PP_AttrProp& rAP);
  65. void makeDefaultStyle() {
  66. m_defaultStyle = true;
  67. if (m_pParagraphProps)
  68. m_pParagraphProps->m_defaultStyle = m_defaultStyle;
  69. }
  70. void setStyleName(const UT_UTF8String& rStyleName) {
  71. m_name = rStyleName;
  72. }
  73. const UT_UTF8String& getName() const {
  74. return m_name;
  75. }
  76. void setFamily(const gchar* pFamily) {
  77. m_family = pFamily;
  78. }
  79. void setParentStyleName(const gchar* pParentStyleName) {
  80. m_parentStyleName = pParentStyleName;
  81. }
  82. void setMasterPageName(const UT_UTF8String& rMasterPageName) {
  83. m_masterPageName = rMasterPageName;
  84. }
  85. void setListStyleName(const UT_UTF8String& rListStyleName) {
  86. m_listStyleName = rListStyleName;
  87. }
  88. const UT_UTF8String& getFontName();
  89. void setBreakBefore(const gchar* pBreakBefore);
  90. void setColumnWidth(const gchar* pColumnWidth);
  91. void setRelColumnWidth(const gchar* pRelColumnWidth);
  92. void setRelTableWidth(const gchar* pRelTableWidth);
  93. void setTableWidth(const gchar* pTableWidth);
  94. void setRowHeight(const gchar* pRowHeight);
  95. void setMinRowHeight(const gchar* pMinRowHeight);
  96. void inheritTableCellProperties(const ODe_Style_Style& tableStyle);
  97. void setWrap(const UT_UTF8String& rWrap);
  98. void setRunThrough(const UT_UTF8String& rRunThrough);
  99. void setPadding(const UT_UTF8String& rPadding);
  100. void setHorizontalPos(const UT_UTF8String& rHorizontalPos);
  101. void setVerticalPos(const UT_UTF8String& rVerticalPos);
  102. void setVerticalRel(const UT_UTF8String& rVerticalRel);
  103. const UT_UTF8String& getDefaultTabInterval();
  104. void setDefaultTabInterval(const UT_UTF8String& rDefaultTabInterval);
  105. private:
  106. ////
  107. // <style:style> attributes
  108. bool m_defaultStyle; // if we are a <style:style>, or a <style:default-style>
  109. UT_UTF8String m_name; // text:style-name
  110. UT_UTF8String m_family; // style:family
  111. UT_UTF8String m_parentStyleName; // style:parent-style-name
  112. UT_UTF8String m_nextStyleName; // style:next-style-name
  113. UT_UTF8String m_masterPageName; // style:master-page-name
  114. UT_UTF8String m_listStyleName; // style:list-style-name
  115. ////
  116. // <style:section-properties> attributes
  117. class SectionProps {
  118. public:
  119. bool isEmpty() const;
  120. void fetchAttributesFromAbiProps(const PP_AttrProp& rAP);
  121. void write(UT_UTF8String& rOutput, const UT_UTF8String& rSpacesOffset) const ;
  122. SectionProps& operator=(const SectionProps& rSectionProps);
  123. bool operator==(const SectionProps& rSectionProps) const;
  124. ////
  125. // <style:columns> attributes
  126. UT_UTF8String m_columnCount; // fo:column-count
  127. UT_UTF8String m_columnGap; // fo:column-gap
  128. } *m_pSectionProps;
  129. ////
  130. // <style:tab-stops> members
  131. class TabStop {
  132. public:
  133. bool operator==(const TabStop& rTabStop) const;
  134. UT_UTF8String m_type; // style:type
  135. UT_UTF8String m_char; // style:char
  136. UT_UTF8String m_position; // style:position
  137. UT_UTF8String m_leaderStyle; // style:leader-style
  138. UT_UTF8String m_leaderText; // style:leader-text
  139. };
  140. ////
  141. // <style:paragraph-properties> attributes
  142. class ParagraphProps {
  143. public:
  144. ParagraphProps() {
  145. // Rule of thumb: never use this constructor, it only exists for
  146. // ODe_Style_Style::operator=(const ODe_Style_Style& rStyle)
  147. }
  148. ParagraphProps(bool defaultStyle)
  149. : m_defaultStyle(defaultStyle)
  150. { }
  151. bool isEmpty() const;
  152. void fetchAttributesFromAbiProps(const PP_AttrProp& rAP);
  153. void write(UT_UTF8String& rOutput, const UT_UTF8String& rSpacesOffset) const ;
  154. ParagraphProps& operator=(const ParagraphProps& rParagraphProps);
  155. bool operator==(const ParagraphProps& rParagraphProps) const;
  156. bool m_defaultStyle; // if we are a <style:style>, or a <style:default-style>
  157. UT_UTF8String m_textAlign; // fo:text-align
  158. UT_UTF8String m_textIndent; // fo:text-indent
  159. UT_UTF8String m_lineHeight; // fo:line-height
  160. UT_UTF8String m_lineHeightAtLeast; // style:line-height-at-least
  161. UT_UTF8String m_backgroundColor; // fo:background-color
  162. UT_UTF8String m_widows; // fo:widows
  163. UT_UTF8String m_orphans; // fo:orphans
  164. UT_UTF8String m_marginLeft; // fo:margin-left
  165. UT_UTF8String m_marginRight; // fo:margin-right
  166. UT_UTF8String m_marginTop; // fo:margin-top
  167. UT_UTF8String m_marginBottom; // fo:margin-bottom
  168. UT_UTF8String m_keepWithNext; // fo:keep-with-next
  169. UT_UTF8String m_breakBefore; // fo:break-before
  170. UT_UTF8String m_writingMode; // style:writing-mode
  171. UT_UTF8String m_defaultTabInterval; // style:tab-stop-distance
  172. std::vector<TabStop> m_tabStops; // style:tab-stops
  173. } *m_pParagraphProps;
  174. ////
  175. // <style:text-properties> attributes
  176. class TextProps {
  177. public:
  178. bool isEmpty() const;
  179. void fetchAttributesFromAbiProps(const PP_AttrProp& rAP);
  180. void write(UT_UTF8String& rOutput, const UT_UTF8String& rSpacesOffset) const ;
  181. TextProps& operator=(const TextProps& rTextProps);
  182. bool operator==(const TextProps& rTextProps) const;
  183. UT_UTF8String m_color; // fo:color
  184. UT_UTF8String m_underlineType; // style:text-underline-type
  185. UT_UTF8String m_lineThroughType; // style:text-line-through-type
  186. UT_UTF8String m_textPosition; // style:text-position
  187. UT_UTF8String m_fontName; // style:font-name
  188. UT_UTF8String m_fontSize; // fo:font-size
  189. UT_UTF8String m_language; // fo:language
  190. UT_UTF8String m_country; // fo:country
  191. UT_UTF8String m_fontStyle; // fo:font-style
  192. UT_UTF8String m_fontWeight; // fo:font-weight
  193. UT_UTF8String m_backgroundColor; // fo:background-color
  194. UT_UTF8String m_display; // text:display
  195. std::string m_transform; // fo:text-transform
  196. } *m_pTextProps;
  197. ////
  198. // <style:table-properties> attributes:
  199. class TableProps {
  200. public:
  201. bool isEmpty() const;
  202. void fetchAttributesFromAbiProps(const PP_AttrProp& rAP);
  203. void write(UT_UTF8String& rOutput, const UT_UTF8String& rSpacesOffset) const ;
  204. TableProps& operator=(const TableProps& rTableProps);
  205. bool operator==(const TableProps& rTableProps) const;
  206. UT_UTF8String m_width; // style:width
  207. UT_UTF8String m_RelTableWidth; // style:rel-width
  208. UT_UTF8String m_backgroundColor; // fo:background-color
  209. UT_UTF8String m_align; // table:align
  210. UT_UTF8String m_marginLeft; // fo:margin-left
  211. UT_UTF8String m_marginRight; // fo:margin-right
  212. } *m_pTableProps;
  213. ////
  214. // <style:table-column-properties> attributes:
  215. class ColumnProps {
  216. public:
  217. bool isEmpty() const;
  218. void write(UT_UTF8String& rOutput, const UT_UTF8String& rSpacesOffset) const ;
  219. ColumnProps& operator=(const ColumnProps& rColumnProps);
  220. bool operator==(const ColumnProps& rColumnProps) const;
  221. UT_UTF8String m_columnWidth; // style:column-width
  222. UT_UTF8String m_RelColumnWidth; // style:rel-column-width
  223. } *m_pColumnProps;
  224. ////
  225. // <style:table-row-properties> attributes:
  226. class RowProps {
  227. public:
  228. bool isEmpty() const;
  229. void write(UT_UTF8String& rOutput, const UT_UTF8String& rSpacesOffset) const ;
  230. RowProps& operator=(const RowProps& rRowProps);
  231. bool operator==(const RowProps& rRowProps) const;
  232. UT_UTF8String m_rowHeight; // style:row-height
  233. UT_UTF8String m_minRowHeight; // style:min-row-height
  234. } *m_pRowProps;
  235. ////
  236. // <style:table-cell-properties> attributes:
  237. class CellProps {
  238. public:
  239. bool isEmpty() const;
  240. void fetchAttributesFromAbiProps(const PP_AttrProp& rAP);
  241. void write(UT_UTF8String& rOutput, const UT_UTF8String& rSpacesOffset) const ;
  242. CellProps& operator=(const CellProps& rCellProps);
  243. bool operator==(const CellProps& rCellProps) const;
  244. UT_UTF8String m_leftThickness; // part of fo:border-left
  245. UT_UTF8String m_leftColor; // part of fo:border-left
  246. UT_UTF8String m_rightThickness; // part of fo:border-right
  247. UT_UTF8String m_rightColor; // part of fo:border-right
  248. UT_UTF8String m_topThickness; // part of fo:border-top
  249. UT_UTF8String m_topColor; // part of fo:border-top
  250. UT_UTF8String m_bottomThickness; // part of fo:border-bottom
  251. UT_UTF8String m_bottomColor; // part of fo:border-bottom
  252. UT_UTF8String m_backgroundColor; // fo:background-color
  253. UT_UTF8String m_backgroundImage; // style:background-image
  254. // TODO: support line styles
  255. } *m_pCellProps;
  256. ////
  257. // <style:graphic-properties> attributes:
  258. class GraphicProps {
  259. public:
  260. bool isEmpty() const;
  261. void fetchAttributesFromAbiProps(const PP_AttrProp& rAP);
  262. void write(UT_UTF8String& rOutput, const UT_UTF8String& rSpacesOffset) const ;
  263. GraphicProps& operator=(const GraphicProps& rGraphicProps);
  264. bool operator==(const GraphicProps& rGraphicProps) const;
  265. UT_UTF8String m_backgroundColor; // fo:background-color
  266. UT_UTF8String m_borderLeft; // fo:border-left
  267. UT_UTF8String m_borderRight; // fo:border-right
  268. UT_UTF8String m_borderTop; // fo:border-top
  269. UT_UTF8String m_borderBottom; // fo:border-bottom
  270. UT_UTF8String m_wrap; // style:wrap
  271. UT_UTF8String m_runThrough; // style:run-through
  272. UT_UTF8String m_verticalPos; // style:vertical-pos
  273. UT_UTF8String m_verticalRel; // style:vertical-rel
  274. UT_UTF8String m_horizontalPos; // style:horizontal-pos
  275. UT_UTF8String m_horizontalRel; // style:horizontal-rel
  276. UT_UTF8String m_padding; // fo:padding
  277. } *m_pGraphicProps;
  278. };
  279. #endif //_ODE_STYLE_STYLE_H_