1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _FMTCLDS_HXX 24 #define _FMTCLDS_HXX 25 26 #include <tools/color.hxx> 27 #include <svl/poolitem.hxx> 28 #include "swdllapi.h" 29 #include <hintids.hxx> 30 #include <format.hxx> 31 32 //Der ColumnDescriptor -------------------------- 33 34 class SwColumn 35 { 36 sal_uInt16 nWish; //Wunschbreite incl. Raender. 37 //Verhaelt sich proportional zum Verhaeltniss: 38 //Wunschbreite der Umgebung / aktuelle Breite der Spalte 39 sal_uInt16 nUpper; //Oberer Rand 40 sal_uInt16 nLower; //Unterer Rand 41 sal_uInt16 nLeft; //Linker Rand 42 sal_uInt16 nRight; //Rechter Rand 43 44 public: 45 SwColumn(); 46 47 sal_Bool operator==( const SwColumn & ); 48 49 50 void SetWishWidth( sal_uInt16 nNew ) { nWish = nNew; } 51 void SetUpper( sal_uInt16 nNew ) { nUpper = nNew; } 52 void SetLower( sal_uInt16 nNew ) { nLower = nNew; } 53 void SetLeft ( sal_uInt16 nNew ) { nLeft = nNew; } 54 void SetRight( sal_uInt16 nNew ) { nRight = nNew; } 55 56 sal_uInt16 GetWishWidth() const { return nWish; } 57 sal_uInt16 GetUpper() const { return nUpper; } 58 sal_uInt16 GetLower() const { return nLower; } 59 sal_uInt16 GetLeft () const { return nLeft; } 60 sal_uInt16 GetRight() const { return nRight; } 61 }; 62 63 typedef SwColumn* SwColumnPtr; 64 SV_DECL_PTRARR_DEL( SwColumns, SwColumnPtr, 0, 2 ) 65 66 enum SwColLineAdj 67 { 68 COLADJ_NONE, 69 COLADJ_TOP, 70 COLADJ_CENTER, 71 COLADJ_BOTTOM 72 }; 73 74 class SW_DLLPUBLIC SwFmtCol : public SfxPoolItem 75 { 76 // Pen aPen; //Pen fuer die Linine zwischen den Spalten 77 sal_uLong nLineWidth; //width of the separator line 78 Color aLineColor; //color of the separator line 79 80 sal_uInt8 nLineHeight; //Prozentuale Hoehe der Linien 81 //(Relativ zu der Hoehe der Spalten incl. UL). 82 SwColLineAdj eAdj; //Linie wird oben, mittig oder unten ausgerichtet. 83 84 SwColumns aColumns; //Informationen fuer die einzelnen Spalten. 85 sal_uInt16 nWidth; //Gesamtwunschbreite aller Spalten. 86 87 sal_Bool bOrtho; //Nur wenn dieses Flag gesetzt ist wird beim setzen 88 //der GutterWidth eine 'optische Verteilung' 89 //vorgenommen. 90 //Es muss zurueckgesetzt werden wenn an den 91 //Spaltenbreiten bzw. den Raendern gedreht wird. 92 //Wenn es wieder gesetzt wird wird automatisch neu 93 //gemischt (optisch verteilt). 94 //Das Flag ist initial gesetzt. 95 96 SW_DLLPRIVATE void Calc( sal_uInt16 nGutterWidth, sal_uInt16 nAct ); 97 98 public: 99 SwFmtCol(); 100 SwFmtCol( const SwFmtCol& ); 101 ~SwFmtCol(); 102 103 SwFmtCol& operator=( const SwFmtCol& ); 104 105 // "pure virtual Methoden" vom SfxPoolItem 106 virtual int operator==( const SfxPoolItem& ) const; 107 virtual SfxPoolItem* Clone( SfxItemPool* pPool = 0 ) const; 108 virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres, 109 SfxMapUnit eCoreMetric, 110 SfxMapUnit ePresMetric, 111 String &rText, 112 const IntlWrapper* pIntl = 0 ) const; 113 114 virtual sal_Bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const; 115 virtual sal_Bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ); 116 117 const SwColumns &GetColumns() const { return aColumns; } 118 SwColumns &GetColumns() { return aColumns; } 119 sal_uInt16 GetNumCols() const { return aColumns.Count(); } 120 // const Pen& GetLinePen() const { return aPen; } 121 sal_uLong GetLineWidth() const { return nLineWidth;} 122 const Color& GetLineColor() const { return aLineColor;} 123 124 125 SwColLineAdj GetLineAdj() const { return eAdj; } 126 sal_Bool IsOrtho() const { return bOrtho; } 127 sal_uInt16 GetWishWidth() const { return nWidth; } 128 sal_uInt8 GetLineHeight()const { return nLineHeight; } 129 130 //Return USHRT_MAX wenn uneindeutig. 131 //Return die kleinste Breite wenn bMin True ist. 132 sal_uInt16 GetGutterWidth( sal_Bool bMin = sal_False ) const; 133 134 // void SetLinePen( const Pen& rNew ) { aPen = rNew; } 135 void SetLineWidth(sal_uLong nLWidth) { nLineWidth = nLWidth;} 136 void SetLineColor(const Color& rCol ) { aLineColor = rCol;} 137 void SetLineHeight( sal_uInt8 nNew ) { nLineHeight = nNew; } 138 void SetLineAdj( SwColLineAdj eNew ){ eAdj = eNew; } 139 void SetWishWidth( sal_uInt16 nNew ) { nWidth = nNew; } 140 141 //Mit dieser Funktion koennen die Spalten (immer wieder) initialisert 142 //werden. Das Ortho Flag wird automatisch gesetzt. 143 void Init( sal_uInt16 nNumCols, sal_uInt16 nGutterWidth, sal_uInt16 nAct ); 144 145 //Stellt die Raender fuer die Spalten in aColumns ein. 146 //Wenn das Flag bOrtho gesetzt ist, werden die Spalten neu optisch 147 //verteilt. Ist das Flag nicht gesetzt werden die Spaltenbreiten nicht 148 //veraendert und die Raender werden einfach eingestellt. 149 void SetGutterWidth( sal_uInt16 nNew, sal_uInt16 nAct ); 150 151 //Verteilt ebenfalls automatisch neu wenn das Flag gesetzt wird; 152 //nur dann wird auch der zweite Param. benoetigt und beachtet. 153 void SetOrtho( sal_Bool bNew, sal_uInt16 nGutterWidth, sal_uInt16 nAct ); 154 155 //Fuer den Reader 156 void _SetOrtho( sal_Bool bNew ) { bOrtho = bNew; } 157 158 //Berechnet die aktuelle Breite der Spalte nCol. 159 //Das Verhaeltniss von Wunschbreite der Spalte zum Returnwert ist 160 //proportional zum Verhaeltniss des Gesamtwunschwertes zu nAct. 161 sal_uInt16 CalcColWidth( sal_uInt16 nCol, sal_uInt16 nAct ) const; 162 163 //Wie oben, aber es wir die Breite der PrtArea - also das was fuer 164 //den Anwender die Spalte ist - geliefert. 165 sal_uInt16 CalcPrtColWidth( sal_uInt16 nCol, sal_uInt16 nAct ) const; 166 }; 167 168 inline const SwFmtCol &SwAttrSet::GetCol(sal_Bool bInP) const 169 { return (const SwFmtCol&)Get( RES_COL,bInP); } 170 171 inline const SwFmtCol &SwFmt::GetCol(sal_Bool bInP) const 172 { return aSet.GetCol(bInP); } 173 174 #endif 175 176