• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ODi_Style_Style.h

Go to the documentation of this file.
00001 /* AbiSource
00002  *
00003  * Copyright (C) 2005 Daniel d'Andrada T. de Carvalho
00004  * <daniel.carvalho@indt.org.br>
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00019  * 02110-1301 USA.
00020  */
00021 
00022 
00023 #ifndef _ODI_STYLE_STYLE_H_
00024 #define _ODI_STYLE_STYLE_H_
00025 
00026 // Internal includes
00027 #include "ODi_ListenerState.h"
00028 
00029 // Internal classes
00030 class ODi_FontFaceDecls;
00031 class ODi_Abi_Data;
00032 
00033 // AbiWord classes
00034 class PD_Document;
00035 
00036 
00040 class ODi_Style_Style : public ODi_ListenerState {
00041 
00042 public:
00043 
00044     // Used to specify whether a given cell has a border (top, left, etc).
00045     enum HAVE_BORDER {
00046         HAVE_BORDER_YES,
00047         HAVE_BORDER_NO,
00048         HAVE_BORDER_UNSPECIFIED
00049     };
00050 
00051 
00052     ODi_Style_Style(ODi_ElementStack& rElementStack,
00053             ODi_Abi_Data & rAbiData);
00054 
00055     virtual ~ODi_Style_Style() {}
00056 
00057     void startElement(const gchar* pName, const gchar** ppAtts,
00058                       ODi_ListenerStateAction& rAction);
00059 
00060     void endElement(const gchar* pName, ODi_ListenerStateAction& rAction);
00061 
00062     void charData (const gchar* /*pBuffer*/, int /*length*/) {}
00063 
00064 
00065     const std::string& getDisplayName() const {return m_displayName;}
00066     void setDisplayName(std::string& rDisplayName) {
00067         m_displayName = rDisplayName;
00068     }
00069 
00078     void defineAbiStyle(PD_Document* pDocument);
00079     ODi_Abi_Data & getAbiData(void)
00080       { return m_rAbiData;}
00081 
00086     void buildAbiPropsAttrString(ODi_FontFaceDecls& rFontFaceDecls);
00087 
00094     void getAbiPropsAttrString(std::string& rProps, bool appendParentProps=TRUE) const;
00095 
00096     void setParentStyleName(const gchar* pParentStyleName) {
00097         m_parentStyleName = pParentStyleName ? pParentStyleName : "";
00098     }
00099 
00100     const ODi_Style_Style* getParent() const {
00101         return m_pParentStyle;
00102     }
00103 
00104     void setParentStylePointer(const ODi_Style_Style* pParentStyle) {
00105         m_pParentStyle = pParentStyle;
00106     }
00107 
00108     void setNextStylePointer(const ODi_Style_Style* pNextStyle) {
00109         m_pNextStyle = pNextStyle;
00110     }
00111 
00112 
00113     const std::string& getBreakBefore() const {return m_breakBefore;}
00114     const std::string& getBreakAfter() const {return m_breakAfter;}
00115 
00116     const std::string& getName() const {return m_name;}
00117     void setName(std::string& rName) {
00118         m_name = rName;
00119     }
00120 
00121     const std::string& getParentName() const {return m_parentStyleName;}
00122     void setParentName(const char* pName) {if (pName) m_parentStyleName.assign(pName);}
00123     void setParentName(const std::string& rName) {m_parentStyleName = rName;}
00124 
00125     inline const std::string& getNextStyleName() const {return m_nextStyleName;}
00126     inline void setNextStyleName(const char* pName) {if (pName) m_nextStyleName.assign(pName);}
00127     void setNextStyleName(const std::string& rName) {m_nextStyleName = rName;}
00128 
00129     const std::string& getListStyleName() const {return m_listStyleName;}
00130 
00131     bool hasProperties() const {
00132         return !m_listStyleName.empty() ||
00133                !m_masterPageName.empty() ||
00134 
00135                !m_lineHeight.empty() ||
00136                !m_align.empty() ||
00137                !m_breakBefore.empty() ||
00138                !m_breakAfter.empty() ||
00139                !m_widows.empty() ||
00140                !m_orphans.empty() ||
00141                !m_marginLeft.empty() ||
00142                !m_marginRight.empty() ||
00143                !m_marginTop.empty() ||
00144                !m_marginBottom.empty() ||
00145                !m_bgcolor.empty() ||
00146                !m_keepWithNext.empty() ||
00147                !m_textIndent.empty() ||
00148                !m_direction.empty() ||
00149 
00150                !m_color.empty() ||
00151                !m_textDecoration.empty() ||
00152                !m_textPos.empty() ||
00153                !m_fontName.empty() ||
00154                !m_fontSize.empty() ||
00155                !m_lang.empty() ||
00156                !m_fontStyle.empty() ||
00157                !m_fontWeight.empty() ||
00158                !m_display.empty() ||
00159                !m_transform.empty() ||
00160 
00161                !m_columns.empty() ||
00162                !m_columnGap.empty() ||
00163 
00164                !m_wrap.empty() ||
00165            !m_HorizRel.empty() ||
00166            !m_HorizPos.empty() ||
00167            !m_VerticalPos.empty() ||
00168            !m_VerticalRel.empty() ||
00169 
00170                !m_backgroundColor.empty() ||
00171                !m_backgroundImageID.empty() ||
00172 
00173                !m_columnWidth.empty() ||
00174                !m_columnRelWidth.empty() ||
00175 
00176                !m_minRowHeight.empty() ||
00177                !m_TableMarginLeft.empty() ||
00178                !m_TableMarginRight.empty() ||
00179                !m_TableWidth.empty() ||
00180                !m_TableRelWidth.empty() ||
00181                !m_rowHeight.empty() ||
00182 
00183            !m_paddingLeft.empty() ||
00184            !m_paddingRight.empty() ||
00185            !m_paddingTop.empty()||
00186            !m_paddingBot.empty()||
00187            !m_mergeBorders.empty()||
00188 
00189       (m_haveTopBorder == HAVE_BORDER_YES) ||
00190       (m_haveBottomBorder == HAVE_BORDER_YES) ||
00191       (m_haveLeftBorder == HAVE_BORDER_YES) ||
00192       (m_haveRightBorder == HAVE_BORDER_YES) ||
00193 
00194                !m_tabStops.empty();
00195     }
00196 
00197     bool isAutomatic() const {return m_bAutomatic;}
00198     const std::string* getMarginLeft() const {return &m_marginLeft;}
00199     const std::string* getTextIndent() const {return &m_textIndent;}
00200     const std::string* getFamily() const {return &m_family;}
00201     const std::string* getFontName() const {return &m_fontName;}
00202 
00208     const std::string* getWrap(bool local) const;
00209     const std::string* getHorizPos(bool local) const;
00210     const std::string* getVerticalPos(bool local) const;
00211 
00212     const std::string* getBackgroundColor() const;
00213     const std::string* getBackgroundImageID() const;
00214 
00215     const std::string* getColumnWidth() const {return &m_columnWidth;}
00216     const std::string* getColumnRelWidth() const {return &m_columnRelWidth;}
00217 
00218     const std::string* getMinRowHeight() const {return &m_minRowHeight;}
00219     const std::string* getRowHeight() const {return &m_rowHeight;}
00220 
00221 
00222     const std::string* getBorderTop_thickness() const {return &m_borderTop_thickness;}
00223     const std::string* getBorderTop_color() const {return &m_borderTop_color;}
00224     HAVE_BORDER hasTopBorder() const {return m_haveTopBorder;}
00225 
00226     const std::string* getBorderBottom_thickness() const {return &m_borderBottom_thickness;}
00227     const std::string* getBorderBottom_color() const {return &m_borderBottom_color;}
00228     HAVE_BORDER hasBottomBorder() const {return m_haveBottomBorder;}
00229 
00230     const std::string* getBorderLeft_thickness() const {return &m_borderLeft_thickness;}
00231     const std::string* getBorderLeft_color() const {return &m_borderLeft_color;}
00232     HAVE_BORDER hasLeftBorder() const {return m_haveLeftBorder;}
00233 
00234     const std::string* getBorderRight_thickness() const {return &m_borderRight_thickness;}
00235     const std::string* getBorderRight_color() const {return &m_borderRight_color;}
00236     HAVE_BORDER hasRightBorder() const {return m_haveRightBorder;}
00237 
00238     const std::string* getMasterPageName() const {return &m_masterPageName;}
00239 
00240     const std::string* getTableMarginLeft() const {return &m_TableMarginLeft;}
00241     const std::string* getTableMarginRight() const {return &m_TableMarginRight;}
00242     const std::string* getTableWidth() const {return &m_TableWidth;}
00243     const std::string* getTableRelWidth() const {return &m_TableRelWidth;}
00244 
00245     const std::string* getVerticalAlign() const {return &m_VerticalAlign;}
00246 private:
00247 
00248     // <style:style />
00249     void _parse_style_style(const gchar** ppAtts);
00250 
00251     // <style:paragraph-properties />
00252     void _parse_style_paragraphProperties(const gchar** ppProps);
00253 
00254     // <style:tab-stop />
00255     void _parse_style_tabStopProperties(const gchar** ppProps);
00256 
00257     // <style:text-properties />
00258     void _parse_style_textProperties(const gchar** ppProps);
00259 
00260     // <style:section-properties />
00261     void _parse_style_sectionProperties(const gchar** ppProps);
00262 
00263     // <style:graphic-properties />
00264     void _parse_style_graphicProperties(const gchar** ppProps);
00265 
00266     // <style:table-properties />
00267     void _parse_style_tableProperties(const gchar** ppProps);
00268 
00269     // <style:table-column-properties />
00270     void _parse_style_tableColumnProperties(const gchar** ppProps);
00271 
00272     // <style:table-row-properties />
00273     void _parse_style_tableRowProperties(const gchar** ppProps);
00274 
00275     // <style:table-cell-properties />
00276     void _parse_style_tableCellProperties(const gchar** ppProps);
00277 
00278     // <style:background-image />
00279     void _parse_style_background_image(const gchar** ppProps);
00280 
00288     void _stripColorLength(std::string& rColor, std::string& rLength,
00289                            HAVE_BORDER& rHaveBorder,
00290                            const gchar* pString) const;
00291 
00300     bool _isValidDimensionString(const gchar* pString, UT_uint32 length=0) const;
00301 
00302     // true if it is an OpenDocument automatic style.
00303     // ie., it's defined inside a <office:automatic-styles> element.
00304     bool m_bAutomatic;
00305 
00306     const ODi_Style_Style* m_pParentStyle;
00307     const ODi_Style_Style* m_pNextStyle;
00308 
00309     std::string m_abiPropsAttr;
00310 
00311 
00312     // <attribute name="style:name">
00313     std::string m_name;
00314 
00315     // <attribute name="style:display-name"> (optional)
00316     // If this attribute is not present, the display name equals the style name.
00317     // In AbiWord, maps to the "name" attribute.
00318     std::string m_displayName;
00319 
00320     // Maps to the "type" attribute.
00321     // OpenDocument | AbiWord
00322     // "character"  - "C"
00323     // "paragraph"  - "P"
00324     // "section"    - none (AbiWord don't have section styles)
00325     //
00326     // An exception is "graphic" styles. AbiWord don't have then.
00327     std::string m_family;
00328 
00329     // <attribute name="style:parent-style-name"> (optional)
00330     // If a parent style is not specified, a default parent style defined by
00331     // the application is used.
00332     //
00333     // In AbiWord, maps to the "basedon" attribute.
00334     std::string m_parentStyleName;
00335 
00336     // <attribute name="style:next-style-name">
00337     // By default, the current style is used as the next style.
00338     // In AbiWord, maps to the "followedby" attribute.
00339     std::string m_nextStyleName;
00340 
00341     // <attribute name="style:list-style-name"> (optional)
00342     //
00343     // Is only applied to headings and to paragraphs that are contained in a
00344     // list, where the list does not specify a list style itself, and the list
00345     // has no list style specification for any of its parents.
00346     //
00347     // Maps to AbiWord, but not directly.
00348     std::string m_listStyleName;
00349 
00350     // <attribute name="style:master-page-name"> (optional)
00351     //
00352     // If this attribute is associated with a style, a page break is inserted
00353     // when the style is applied and the specified master page is applied to the
00354     // preceding page.
00355     // This attribute is ignored if it is associated with a paragraph style that
00356     // is applied to a paragraph within a table.
00357     //
00358     // Maps to AbiWord, but not directly.
00359     std::string m_masterPageName;
00360 
00361 
00363     // <style:paragraph-properties> attributes
00364     // These goes inside the Abi "props" attribute
00365     std::string m_lineHeight;
00366     std::string m_align;
00367     std::string m_breakBefore; // fo:break-before
00368     std::string m_breakAfter; // fo:break-after
00369     std::string m_widows;
00370     std::string m_orphans;
00371     std::string m_marginLeft;
00372     std::string m_marginRight;
00373     std::string m_marginTop;
00374     std::string m_marginBottom;
00375     std::string m_bgcolor;
00376     std::string m_keepWithNext;
00377     std::string m_textIndent; // fo:text-indent
00378     std::string m_direction; // style:writing-mode
00379     std::string m_defaultTabInterval; // style:tab-stop-distance
00380     std::string m_tabStops; // style:tab-stops
00381 
00383     // <style:text-properties />
00384     // These goes inside the Abi "props" attribute
00385     std::string m_color;
00386     std::string m_textDecoration;
00387     std::string m_textPos;
00388     std::string m_fontName;
00389     std::string m_fontSize;
00390     std::string m_lang;
00391     std::string m_fontStyle;
00392     std::string m_fontWeight;
00393     std::string m_display; //text:display
00394     std::string m_transform; //fo:text-transform
00395 
00396 
00397     // fo:background-color
00398     // For <style:table-properties> and <style:table-cell-properties>
00399     std::string m_backgroundColor;
00400 
00401     // <style:bakground-image>
00402     std::string m_backgroundImageID; // xlink:href
00403 
00404     // For <style:table-properties
00405     // fo:margin-left
00406     // fo:margin-right
00407     // style:width
00408     // style:rel-width
00409 
00410     std::string   m_TableMarginLeft;
00411     std::string   m_TableMarginRight;
00412     std::string   m_TableWidth;
00413     std::string   m_TableRelWidth;
00414 
00415 
00417     // <style:section-properties>
00418     // These goes inside the Abi "props" attribute
00419     std::string m_columns;
00420     std::string m_columnGap;
00421 
00423     // <style:graphic-properties>
00424     std::string m_wrap; // style:wrap
00425     std::string m_HorizRel; // style:horizontal-rel
00426     std::string m_HorizPos; // style:horizontal-pos
00427     std::string m_VerticalPos; // style:vertical-pos
00428     std::string m_VerticalRel; //  style:vertical-rel
00429 
00431     // <style:table-column-properties>
00432     // style:column-width
00433     // rel-column-width
00434     std::string m_columnWidth; // style:column-width
00435     std::string m_columnRelWidth; // style:rel-column-width
00436 
00438     // <style:table-row-properties>
00439     std::string m_minRowHeight; // style:min-row-height
00440     std::string m_rowHeight; // style:row-height
00441 
00442 
00444     // <style:table-cell-properties>
00445 
00446     // style:vertical-align
00447     std::string m_VerticalAlign;
00448 
00449     // fo:border-top
00450     std::string m_borderTop_thickness;
00451     std::string m_borderTop_color;
00452     HAVE_BORDER m_haveTopBorder;
00453 
00454     // fo:border-bottom
00455     std::string m_borderBottom_thickness;
00456     std::string m_borderBottom_color;
00457     HAVE_BORDER m_haveBottomBorder;
00458 
00459     // fo:border-left
00460     std::string m_borderLeft_thickness;
00461     std::string m_borderLeft_color;
00462     HAVE_BORDER m_haveLeftBorder;
00463 
00464     // fo:border-right
00465     std::string m_borderRight_thickness;
00466     std::string m_borderRight_color;
00467     HAVE_BORDER m_haveRightBorder;
00468 
00469     // fo:padding
00470     std::string m_paddingLeft;
00471     std::string m_paddingRight;
00472     std::string m_paddingTop;
00473     std::string m_paddingBot;
00474 
00475     // style:merge-borders
00476     std::string m_mergeBorders;
00477 
00478     ODi_Abi_Data& m_rAbiData;
00479 
00480     // OBS: If "fo:border" is defined, its value will fill all "fo:border-*"
00481 };
00482 
00483 #endif //_ODI_STYLE_STYLE_H_

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1