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

ODe_Style_Style.h

Go to the documentation of this file.
00001 /* AbiSource
00002  *
00003  * Copyright (C) 2005 INdT
00004  * Author: Daniel d'Andrada T. de Carvalho <daniel.carvalho@indt.org.br>
00005  * Copyright 2009-2010 AbiSource Corporation B.V.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00020  * 02111-1307, USA.
00021  */
00022 
00023 #ifndef _ODE_STYLE_STYLE_H_
00024 #define _ODE_STYLE_STYLE_H_
00025 
00026 #include <vector>
00027 #include <map>
00028 #include <string>
00029 
00030 // AbiWord includes
00031 #include <ut_string_class.h>
00032 
00033 // External includes
00034 #include <gsf/gsf.h>
00035 
00036 // AbiWord classes
00037 class PP_AttrProp;
00038 class ODe_Style_List;
00039 
00043 class ODe_Style_Style {
00044 public:
00045 
00046     ODe_Style_Style();
00047     virtual ~ODe_Style_Style();
00048 
00049     // Write the <style:style> element.
00050     bool write(GsfOutput* pODT, const UT_UTF8String& rSpacesOffset) const;
00051 
00052     static bool hasTextStyleProps(const PP_AttrProp* pAP);
00053     static bool hasParagraphStyleProps(const PP_AttrProp* pAP);
00054     static bool hasSectionInfo(const PP_AttrProp* pAP);
00055     static bool hasTableStyleProps(const PP_AttrProp* pAP);
00056 
00057     // It does not take style names into consideration.
00058     // Read it like: "is style "T1" equivalent to style "T2"
00059     // It is *NOT* like: "is style A equal to style B"
00060     bool isEquivalentTo(const ODe_Style_Style& rStyle);
00061 
00062     bool isEmpty() const;
00063 
00064     ODe_Style_Style& operator=(const ODe_Style_Style& rStyle);
00065 
00066     // Defines the style from attributes and properties of an AbiWord <s>.
00067     bool fetchAttributesFromAbiStyle(const PP_AttrProp* pAP);
00068 
00069     // Defines the style from attributes and properties of an AbiWord <span>.
00070     void fetchAttributesFromAbiSpan(const PP_AttrProp* pAP);
00071 
00072     // Defines the style from attributes and properties of an AbiWord <p>.
00073     void fetchAttributesFromAbiBlock(const PP_AttrProp* pAP, const ODe_Style_List* pCurrentListStyle);
00074 
00075     // Defines the style from attributes and properties of an AbiWord <section>.
00076     void fetchAttributesFromAbiSection(const PP_AttrProp* pAP);
00077 
00078     // Defines the style from attributes and properties of an AbiWord <table>.
00079     void fetchAttributesFromAbiTable(const PP_AttrProp* pAP);
00080 
00081     // Defines the style from attributes and properties of an AbiWord <cell>.
00082     void fetchAttributesFromAbiCell(const PP_AttrProp* pAP);
00083 
00084     // Defines the style from attributes and properties of an AbiWord <frame>.
00085     void fetchAttributesFromAbiFrame(const PP_AttrProp& rAP);
00086 
00087     void makeDefaultStyle() {
00088         m_defaultStyle = true;
00089         if (m_pParagraphProps)
00090             m_pParagraphProps->m_defaultStyle = m_defaultStyle;
00091     }
00092 
00093     void setStyleName(const UT_UTF8String& rStyleName) {
00094         m_name = rStyleName;
00095     }
00096 
00097     const UT_UTF8String& getName() const {
00098         return m_name;
00099     }
00100 
00101     void setFamily(const gchar* pFamily) {
00102         m_family = pFamily;
00103     }
00104 
00105     void setParentStyleName(const gchar* pParentStyleName) {
00106         m_parentStyleName = pParentStyleName;
00107     }
00108 
00109     void setMasterPageName(const UT_UTF8String& rMasterPageName) {
00110         m_masterPageName = rMasterPageName;
00111     }
00112 
00113      void setListStyleName(const UT_UTF8String& rListStyleName) {
00114         m_listStyleName = rListStyleName;
00115     }
00116 
00117     const UT_UTF8String& getFontName();
00118 
00119     void setBreakBefore(const gchar* pBreakBefore);
00120     void setColumnWidth(const gchar* pColumnWidth);
00121     void setRelColumnWidth(const gchar* pRelColumnWidth);
00122     void setRelTableWidth(const gchar* pRelTableWidth);
00123     void setTableWidth(const gchar* pTableWidth);
00124     void setRowHeight(const gchar* pRowHeight);
00125     void setMinRowHeight(const gchar* pMinRowHeight);
00126     void inheritTableCellProperties(const ODe_Style_Style& tableStyle);
00127     void setWrap(const UT_UTF8String& rWrap);
00128     void setRunThrough(const UT_UTF8String& rRunThrough);
00129     void setPadding(const UT_UTF8String& rPadding);
00130     void setHorizontalPos(const UT_UTF8String& rHorizontalPos);
00131     void setVerticalPos(const UT_UTF8String& rVerticalPos);
00132     void setVerticalRel(const UT_UTF8String& rVerticalRel);
00133 
00134     const UT_UTF8String& getDefaultTabInterval();
00135     void setDefaultTabInterval(const UT_UTF8String& rDefaultTabInterval);
00136 
00137     static UT_UTF8String convertStyleToNCName(const UT_UTF8String& name);
00138 
00139 private:
00140 
00141     // It's not really nice that this mapping is static, but otherwise we'd
00142     // for example have to pass an ODe_Styles object which holds the mapping to
00143     // the ODe_Style_Style constuctor. This would mean changing lots of code.
00144     // Having a static mapping can do no harm whatsoever, so let's just use
00145     // that -- MARCM
00146     static std::map<std::string, std::string> m_NCStyleMappings;
00147 
00148 
00150     // <style:style> attributes
00151     bool m_defaultStyle;             // if we are a <style:style>, or a <style:default-style>
00152     UT_UTF8String m_name;            // text:style-name
00153     UT_UTF8String m_family;          // style:family
00154     UT_UTF8String m_parentStyleName; // style:parent-style-name
00155     UT_UTF8String m_nextStyleName;   // style:next-style-name
00156     UT_UTF8String m_masterPageName;  // style:master-page-name
00157     UT_UTF8String m_listStyleName;   // style:list-style-name
00158 
00159 
00161     // <style:section-properties> attributes
00162     class SectionProps {
00163         public:
00164 
00165         bool isEmpty() const;
00166         void fetchAttributesFromAbiProps(const PP_AttrProp& rAP);
00167         void write(UT_UTF8String& rOutput, const UT_UTF8String& rSpacesOffset) const ;
00168         SectionProps& operator=(const SectionProps& rSectionProps);
00169         bool operator==(const SectionProps& rSectionProps) const;
00170 
00172         // <style:columns> attributes
00173         UT_UTF8String m_columnCount;     // fo:column-count
00174         UT_UTF8String m_columnGap;       // fo:column-gap
00175     } *m_pSectionProps;
00176 
00177 
00179     // <style:tab-stops> members
00180     class TabStop {
00181         public:
00182         bool operator==(const TabStop& rTabStop) const;
00183 
00184         UT_UTF8String m_type;            // style:type
00185         UT_UTF8String m_char;            // style:char
00186         UT_UTF8String m_position;        // style:position
00187         UT_UTF8String m_leaderStyle;     // style:leader-style
00188         UT_UTF8String m_leaderText;      // style:leader-text
00189     };
00190 
00192     // <style:paragraph-properties> attributes
00193     class ParagraphProps {
00194         public:
00195         ParagraphProps() {
00196             // Rule of thumb: never use this constructor, it only exists for
00197             // ODe_Style_Style::operator=(const ODe_Style_Style& rStyle)
00198         }
00199         ParagraphProps(bool defaultStyle)
00200             : m_defaultStyle(defaultStyle)
00201         { }
00202 
00203         bool isEmpty() const;
00204         void fetchAttributesFromAbiProps(const PP_AttrProp& rAP);
00205         void write(UT_UTF8String& rOutput, const UT_UTF8String& rSpacesOffset) const ;
00206         ParagraphProps& operator=(const ParagraphProps& rParagraphProps);
00207         bool operator==(const ParagraphProps& rParagraphProps) const;
00208 
00209         bool m_defaultStyle;             // if we are a <style:style>, or a <style:default-style>
00210 
00211         UT_UTF8String m_textAlign;       // fo:text-align
00212         UT_UTF8String m_textIndent;      // fo:text-indent
00213         UT_UTF8String m_lineHeight;      // fo:line-height
00214         UT_UTF8String m_lineHeightAtLeast; // style:line-height-at-least
00215         UT_UTF8String m_backgroundColor; // fo:background-color
00216         UT_UTF8String m_widows;          // fo:widows
00217         UT_UTF8String m_orphans;         // fo:orphans
00218         UT_UTF8String m_marginLeft;      // fo:margin-left
00219         UT_UTF8String m_marginRight;     // fo:margin-right
00220         UT_UTF8String m_marginTop;       // fo:margin-top
00221         UT_UTF8String m_marginBottom;    // fo:margin-bottom
00222         UT_UTF8String m_keepWithNext;    // fo:keep-with-next
00223         UT_UTF8String m_breakBefore;     // fo:break-before
00224         UT_UTF8String m_writingMode;     // style:writing-mode
00225         UT_UTF8String m_borderMerge;     // style:join-border
00226         UT_UTF8String m_borderLeft;      // fo:border-left
00227         UT_UTF8String m_borderRight;     // fo:border-right
00228         UT_UTF8String m_borderTop;       // fo:border-top
00229         UT_UTF8String m_borderBottom;    // fo:border-bottom
00230         UT_UTF8String m_botSpace;        // fo:padding-bottom
00231         UT_UTF8String m_leftSpace;       // fo:padding-left
00232         UT_UTF8String m_rightSpace;      // fo:padding-right
00233         UT_UTF8String m_topSpace;        // fo:padding-top
00234 
00235         UT_UTF8String m_defaultTabInterval; // style:tab-stop-distance
00236         std::vector<TabStop> m_tabStops; // style:tab-stops
00237     } *m_pParagraphProps;
00238 
00239 
00241     // <style:text-properties> attributes
00242     class TextProps {
00243         public:
00244 
00245         bool isEmpty() const;
00246         void fetchAttributesFromAbiProps(const PP_AttrProp& rAP);
00247         void write(UT_UTF8String& rOutput, const UT_UTF8String& rSpacesOffset) const ;
00248         TextProps& operator=(const TextProps& rTextProps);
00249         bool operator==(const TextProps& rTextProps) const;
00250 
00251         UT_UTF8String m_color;           // fo:color
00252         UT_UTF8String m_underlineType;   // style:text-underline-type
00253         UT_UTF8String m_lineThroughType; // style:text-line-through-type
00254         UT_UTF8String m_textPosition;    // style:text-position
00255         UT_UTF8String m_fontName;        // style:font-name
00256         UT_UTF8String m_fontSize;        // fo:font-size
00257         UT_UTF8String m_language;        // fo:language
00258         UT_UTF8String m_country;         // fo:country
00259         UT_UTF8String m_fontStyle;       // fo:font-style
00260         UT_UTF8String m_fontWeight;      // fo:font-weight
00261         UT_UTF8String m_backgroundColor; // fo:background-color
00262         UT_UTF8String m_display;         // text:display
00263         std::string m_transform;         // fo:text-transform
00264     } *m_pTextProps;
00265 
00266 
00268     // <style:table-properties> attributes:
00269     class TableProps {
00270         public:
00271 
00272         bool isEmpty() const;
00273         void fetchAttributesFromAbiProps(const PP_AttrProp& rAP);
00274         void write(UT_UTF8String& rOutput, const UT_UTF8String& rSpacesOffset) const ;
00275         TableProps& operator=(const TableProps& rTableProps);
00276         bool operator==(const TableProps& rTableProps) const;
00277 
00278         UT_UTF8String m_width;           // style:width
00279         UT_UTF8String m_RelTableWidth;     // style:rel-width
00280         UT_UTF8String m_backgroundColor; // fo:background-color
00281         UT_UTF8String m_align;           // table:align
00282         UT_UTF8String m_marginLeft;      // fo:margin-left
00283         UT_UTF8String m_marginRight;     // fo:margin-right
00284     } *m_pTableProps;
00285 
00286 
00288     // <style:table-column-properties> attributes:
00289     class ColumnProps {
00290         public:
00291 
00292         bool isEmpty() const;
00293         void write(UT_UTF8String& rOutput, const UT_UTF8String& rSpacesOffset) const ;
00294         ColumnProps& operator=(const ColumnProps& rColumnProps);
00295         bool operator==(const ColumnProps& rColumnProps) const;
00296 
00297         UT_UTF8String m_columnWidth;     // style:column-width
00298         UT_UTF8String m_RelColumnWidth;     // style:rel-column-width
00299     } *m_pColumnProps;
00300 
00301 
00303     // <style:table-row-properties> attributes:
00304     class RowProps {
00305         public:
00306 
00307         bool isEmpty() const;
00308         void write(UT_UTF8String& rOutput, const UT_UTF8String& rSpacesOffset) const ;
00309         RowProps& operator=(const RowProps& rRowProps);
00310         bool operator==(const RowProps& rRowProps) const;
00311 
00312         UT_UTF8String m_rowHeight;       // style:row-height
00313         UT_UTF8String m_minRowHeight;    // style:min-row-height
00314     } *m_pRowProps;
00315 
00316 
00318     // <style:table-cell-properties> attributes:
00319     class CellProps {
00320         public:
00321 
00322         bool isEmpty() const;
00323         void fetchAttributesFromAbiProps(const PP_AttrProp& rAP);
00324         void write(UT_UTF8String& rOutput, const UT_UTF8String& rSpacesOffset) const ;
00325         CellProps& operator=(const CellProps& rCellProps);
00326         bool operator==(const CellProps& rCellProps) const;
00327 
00328         UT_UTF8String m_leftThickness;   // part of fo:border-left
00329         UT_UTF8String m_leftColor;       // part of fo:border-left
00330         UT_UTF8String m_rightThickness;  // part of fo:border-right
00331         UT_UTF8String m_rightColor;      // part of fo:border-right
00332         UT_UTF8String m_topThickness;    // part of fo:border-top
00333         UT_UTF8String m_topColor;        // part of fo:border-top
00334         UT_UTF8String m_bottomThickness; // part of fo:border-bottom
00335         UT_UTF8String m_bottomColor;     // part of fo:border-bottom
00336         UT_UTF8String m_backgroundColor; // fo:background-color
00337     UT_UTF8String m_backgroundImage; // style:background-image
00338     UT_UTF8String m_verticalAlign;   // style:vertical-align
00339 
00340         // TODO: support line styles
00341     } *m_pCellProps;
00342 
00343 
00345     // <style:graphic-properties> attributes:
00346     class GraphicProps {
00347         public:
00348 
00349         bool isEmpty() const;
00350         void fetchAttributesFromAbiProps(const PP_AttrProp& rAP);
00351         void write(UT_UTF8String& rOutput, const UT_UTF8String& rSpacesOffset) const ;
00352         GraphicProps& operator=(const GraphicProps& rGraphicProps);
00353         bool operator==(const GraphicProps& rGraphicProps) const;
00354 
00355         UT_UTF8String m_backgroundColor; // fo:background-color
00356         UT_UTF8String m_borderLeft;      // fo:border-left
00357         UT_UTF8String m_borderRight;     // fo:border-right
00358         UT_UTF8String m_borderTop;       // fo:border-top
00359         UT_UTF8String m_borderBottom;    // fo:border-bottom
00360         UT_UTF8String m_wrap;            // style:wrap
00361         UT_UTF8String m_runThrough;      // style:run-through
00362         UT_UTF8String m_verticalPos;     // style:vertical-pos
00363         UT_UTF8String m_verticalRel;     // style:vertical-rel
00364         UT_UTF8String m_horizontalPos;   // style:horizontal-pos
00365         UT_UTF8String m_horizontalRel;   // style:horizontal-rel
00366         UT_UTF8String m_padding;         // fo:padding
00367     } *m_pGraphicProps;
00368 };
00369 
00370 
00371 #endif //_ODE_STYLE_STYLE_H_

Generated on Sat May 26 2012 for AbiWord by  doxygen 1.7.1