Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _ODI_STYLE_STYLE_H_
00024 #define _ODI_STYLE_STYLE_H_
00025
00026
00027 #include "ODi_ListenerState.h"
00028
00029
00030 class ODi_FontFaceDecls;
00031 class ODi_Abi_Data;
00032
00033
00034 class PD_Document;
00035
00036
00040 class ODi_Style_Style : public ODi_ListenerState {
00041
00042 public:
00043
00044
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* , int ) {}
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
00249 void _parse_style_style(const gchar** ppAtts);
00250
00251
00252 void _parse_style_paragraphProperties(const gchar** ppProps);
00253
00254
00255 void _parse_style_tabStopProperties(const gchar** ppProps);
00256
00257
00258 void _parse_style_textProperties(const gchar** ppProps);
00259
00260
00261 void _parse_style_sectionProperties(const gchar** ppProps);
00262
00263
00264 void _parse_style_graphicProperties(const gchar** ppProps);
00265
00266
00267 void _parse_style_tableProperties(const gchar** ppProps);
00268
00269
00270 void _parse_style_tableColumnProperties(const gchar** ppProps);
00271
00272
00273 void _parse_style_tableRowProperties(const gchar** ppProps);
00274
00275
00276 void _parse_style_tableCellProperties(const gchar** ppProps);
00277
00278
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
00303
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
00313 std::string m_name;
00314
00315
00316
00317
00318 std::string m_displayName;
00319
00320
00321
00322
00323
00324
00325
00326
00327 std::string m_family;
00328
00329
00330
00331
00332
00333
00334 std::string m_parentStyleName;
00335
00336
00337
00338
00339 std::string m_nextStyleName;
00340
00341
00342
00343
00344
00345
00346
00347
00348 std::string m_listStyleName;
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359 std::string m_masterPageName;
00360
00361
00363
00364
00365 std::string m_lineHeight;
00366 std::string m_align;
00367 std::string m_breakBefore;
00368 std::string m_breakAfter;
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;
00378 std::string m_direction;
00379 std::string m_defaultTabInterval;
00380 std::string m_tabStops;
00381
00383
00384
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;
00394 std::string m_transform;
00395
00396
00397
00398
00399 std::string m_backgroundColor;
00400
00401
00402 std::string m_backgroundImageID;
00403
00404
00405
00406
00407
00408
00409
00410 std::string m_TableMarginLeft;
00411 std::string m_TableMarginRight;
00412 std::string m_TableWidth;
00413 std::string m_TableRelWidth;
00414
00415
00417
00418
00419 std::string m_columns;
00420 std::string m_columnGap;
00421
00423
00424 std::string m_wrap;
00425 std::string m_HorizRel;
00426 std::string m_HorizPos;
00427 std::string m_VerticalPos;
00428 std::string m_VerticalRel;
00429
00431
00432
00433
00434 std::string m_columnWidth;
00435 std::string m_columnRelWidth;
00436
00438
00439 std::string m_minRowHeight;
00440 std::string m_rowHeight;
00441
00442
00444
00445
00446
00447 std::string m_VerticalAlign;
00448
00449
00450 std::string m_borderTop_thickness;
00451 std::string m_borderTop_color;
00452 HAVE_BORDER m_haveTopBorder;
00453
00454
00455 std::string m_borderBottom_thickness;
00456 std::string m_borderBottom_color;
00457 HAVE_BORDER m_haveBottomBorder;
00458
00459
00460 std::string m_borderLeft_thickness;
00461 std::string m_borderLeft_color;
00462 HAVE_BORDER m_haveLeftBorder;
00463
00464
00465 std::string m_borderRight_thickness;
00466 std::string m_borderRight_color;
00467 HAVE_BORDER m_haveRightBorder;
00468
00469
00470 std::string m_paddingLeft;
00471 std::string m_paddingRight;
00472 std::string m_paddingTop;
00473 std::string m_paddingBot;
00474
00475
00476 std::string m_mergeBorders;
00477
00478 ODi_Abi_Data& m_rAbiData;
00479
00480
00481 };
00482
00483 #endif //_ODI_STYLE_STYLE_H_