00001 /* AbiWord 00002 * Copyright (C) 1998,1999 AbiSource, Inc. 00003 * BIDI Copyright (c) 2001,2002 Tomas Frydrych 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00018 * 02110-1301 USA. 00019 */ 00020 00021 #ifndef FB_ALIGNMENT_H 00022 #define FB_ALIGNMENT_H 00023 00024 #include "ut_types.h" 00025 00026 class fp_Line; 00027 class fp_Run; 00028 00029 /* 00030 fb_Alignment is an abstract worker class that encapsulates the 00031 alignment policy in effect for the current fp_Line of an individual 00032 fl_Block during formatting. 00033 00034 Each policy is implemented in its own subclass: 00035 00036 fb_Alignment_left 00037 fb_Alignment_center 00038 fb_Alignment_right 00039 fb_Alignment_justify 00040 */ 00041 enum FB_AlignmentType { FB_ALIGNMENT_LEFT, 00042 FB_ALIGNMENT_RIGHT, 00043 FB_ALIGNMENT_CENTER, 00044 FB_ALIGNMENT_JUSTIFY 00045 }; 00046 00047 00048 class ABI_EXPORT fb_Alignment 00049 { 00050 00051 public: 00052 virtual ~fb_Alignment() {} 00053 00054 virtual void initialize(fp_Line *pLine) = 0; 00055 virtual UT_sint32 getStartPosition() = 0; 00056 virtual void eraseLineFromRun(fp_Line *pLine, UT_uint32 runIndex) = 0; 00057 virtual FB_AlignmentType getType() = 0; 00058 00059 }; 00060 00061 class ABI_EXPORT fb_Alignment_left : public fb_Alignment 00062 { 00063 public: 00064 00065 void initialize(fp_Line *pLine); 00066 UT_sint32 getStartPosition(); 00067 void eraseLineFromRun(fp_Line *pLine, UT_uint32 runIndex); 00068 FB_AlignmentType getType(){return FB_ALIGNMENT_LEFT;}; 00069 00070 private: 00071 00072 UT_sint32 m_iStartPosition; 00073 }; 00074 00075 class ABI_EXPORT fb_Alignment_center : public fb_Alignment 00076 { 00077 public: 00078 00079 void initialize(fp_Line *pLine); 00080 UT_sint32 getStartPosition(); 00081 void eraseLineFromRun(fp_Line *pLine, UT_uint32 runIndex); 00082 FB_AlignmentType getType(){return FB_ALIGNMENT_CENTER;}; 00083 00084 private: 00085 00086 UT_sint32 m_startPosition; 00087 }; 00088 00089 class ABI_EXPORT fb_Alignment_right : public fb_Alignment 00090 { 00091 public: 00092 00093 void initialize(fp_Line *pLine); 00094 UT_sint32 getStartPosition(); 00095 void eraseLineFromRun(fp_Line *pLine, UT_uint32 runIndex); 00096 FB_AlignmentType getType(){return FB_ALIGNMENT_RIGHT;}; 00097 00098 private: 00099 00100 UT_sint32 m_startPosition; 00101 }; 00102 00103 class ABI_EXPORT fb_Alignment_justify : public fb_Alignment 00104 { 00105 public: 00106 00107 void initialize(fp_Line *pLine); 00108 UT_sint32 getStartPosition(); 00109 void eraseLineFromRun(fp_Line *pLine, UT_uint32 runIndex); 00110 FB_AlignmentType getType(){return FB_ALIGNMENT_JUSTIFY;}; 00111 00112 private: 00113 00114 int m_iExtraWidth; 00115 UT_sint32 m_iStartPosition; 00116 00117 00118 }; 00119 00120 #endif /* FB_ALIGNMENT_H */