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

Generated on Sun May 27 2012 for AbiWord by  doxygen 1.7.1