1 /* AbiWord 2 * Copyright (C) 2000,2001 Mike Nordell, Dom Lachowicz, and others 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17 * 02110-1301 USA. 18 */ 19 20 #ifndef FP_PAGESIZE_H 21 #define FP_PAGESIZE_H 22 23 #include "ut_types.h" 24 #include "ut_units.h" 25 26 #if _MSC_VER 27 #pragma warning(disable: 4522) // multiple assignment operators specified 28 #endif 29 30 class UT_UTF8String; 31 32 class ABI_EXPORT fp_PageSize 33 { 34 public: 35 36 enum Predefined 37 { 38 _first_predefined_pagesize_ = 0, 39 40 // If you append a predefined pagesize here, don't forget 41 // to update the cpp accordingly. 42 43 psA0 = 0, psA1, psA2, psA3, psA4, psA5, psA6, psA7, psA8, psA9, psA10, 44 psB0, psB1, psB2, psB3, psB4, psB5, psB6, psB7, psB8, psB9, psB10, 45 psC0, psC1, psC2, psC3, psC4, psC5, psC6, psC7, psC8, psC9, psC10, 46 psLegal, psFolio, psLetter, 47 ps1_3A4, ps1_4A4, ps1_8A4, ps1_4A3, ps1_3A5, 48 psEnvelope_DL, psEnvelope_C6_C5, psEnvelope_no10, psEnvelope_6x9, 49 psCustom, 50 51 // append new pagesizes here 52 _last_predefined_pagesize_dont_use_ 53 }; 54 55 UT_UTF8String static getDefaultPageMargin(UT_Dimension dim); 56 57 fp_PageSize(Predefined preDef); 58 fp_PageSize(const char *name); 59 fp_PageSize(double w, double h, UT_Dimension u); 60 fp_PageSize& operator=(fp_PageSize& rhs); 61 fp_PageSize& operator=(const fp_PageSize& rhs); 62 63 bool match(double x, double y); 64 void Set(Predefined preDef, UT_Dimension u = DIM_none); 65 void Set(const char *name, UT_Dimension u = DIM_none); 66 void Set(double w, double h, UT_Dimension u = DIM_none); Set(UT_Dimension u)67 void Set(UT_Dimension u) { m_unit = u; } 68 bool Set(const gchar ** attributes); setScale(double scale)69 inline void setScale( double scale) { m_scale = scale; } 70 void setPortrait(void); 71 void setLandscape(void); isPortrait(void)72 bool isPortrait(void) const { return m_bisPortrait; } 73 double Width(UT_Dimension u) const; 74 double Height(UT_Dimension u) const; 75 getScale(void)76 double getScale(void) const { return m_scale; } getDims(void)77 UT_Dimension getDims(void) const { return m_unit; } getPredefinedName(void)78 inline char * getPredefinedName (void) const { return m_predefined; } 79 80 static bool IsPredefinedName(const char* szPageSizeName); 81 static Predefined NameToPredefined(const char *name); 82 static const char * PredefinedToName(Predefined preDef); 83 static int PredefinedToLocalName(Predefined preDef); 84 85 private: 86 char * m_predefined; 87 88 double m_iWidth; 89 double m_iHeight; 90 91 bool m_bisPortrait; 92 double m_scale; 93 UT_Dimension m_unit; 94 }; 95 96 #endif // FP_PAGESIZE_H 97