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

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1