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