1*1d2dbeb0SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*1d2dbeb0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*1d2dbeb0SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*1d2dbeb0SAndrew Rist * distributed with this work for additional information 6*1d2dbeb0SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*1d2dbeb0SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*1d2dbeb0SAndrew Rist * "License"); you may not use this file except in compliance 9*1d2dbeb0SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*1d2dbeb0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*1d2dbeb0SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*1d2dbeb0SAndrew Rist * software distributed under the License is distributed on an 15*1d2dbeb0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*1d2dbeb0SAndrew Rist * KIND, either express or implied. See the License for the 17*1d2dbeb0SAndrew Rist * specific language governing permissions and limitations 18*1d2dbeb0SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*1d2dbeb0SAndrew Rist *************************************************************/ 21*1d2dbeb0SAndrew Rist 22*1d2dbeb0SAndrew 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. 86cdf0e10cSrcweir 87cdf0e10cSrcweir sal_Bool bOrtho; //Nur wenn dieses Flag gesetzt ist wird beim setzen 88cdf0e10cSrcweir //der GutterWidth eine 'optische Verteilung' 89cdf0e10cSrcweir //vorgenommen. 90cdf0e10cSrcweir //Es muss zurueckgesetzt werden wenn an den 91cdf0e10cSrcweir //Spaltenbreiten bzw. den Raendern gedreht wird. 92cdf0e10cSrcweir //Wenn es wieder gesetzt wird wird automatisch neu 93cdf0e10cSrcweir //gemischt (optisch verteilt). 94cdf0e10cSrcweir //Das Flag ist initial gesetzt. 95cdf0e10cSrcweir 96cdf0e10cSrcweir SW_DLLPRIVATE void Calc( sal_uInt16 nGutterWidth, sal_uInt16 nAct ); 97cdf0e10cSrcweir 98cdf0e10cSrcweir public: 99cdf0e10cSrcweir SwFmtCol(); 100cdf0e10cSrcweir SwFmtCol( const SwFmtCol& ); 101cdf0e10cSrcweir ~SwFmtCol(); 102cdf0e10cSrcweir 103cdf0e10cSrcweir SwFmtCol& operator=( const SwFmtCol& ); 104cdf0e10cSrcweir 105cdf0e10cSrcweir // "pure virtual Methoden" vom SfxPoolItem 106cdf0e10cSrcweir virtual int operator==( const SfxPoolItem& ) const; 107cdf0e10cSrcweir virtual SfxPoolItem* Clone( SfxItemPool* pPool = 0 ) const; 108cdf0e10cSrcweir virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres, 109cdf0e10cSrcweir SfxMapUnit eCoreMetric, 110cdf0e10cSrcweir SfxMapUnit ePresMetric, 111cdf0e10cSrcweir String &rText, 112cdf0e10cSrcweir const IntlWrapper* pIntl = 0 ) const; 113cdf0e10cSrcweir 114cdf0e10cSrcweir virtual sal_Bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const; 115cdf0e10cSrcweir virtual sal_Bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ); 116cdf0e10cSrcweir 117cdf0e10cSrcweir const SwColumns &GetColumns() const { return aColumns; } 118cdf0e10cSrcweir SwColumns &GetColumns() { return aColumns; } 119cdf0e10cSrcweir sal_uInt16 GetNumCols() const { return aColumns.Count(); } 120cdf0e10cSrcweir // const Pen& GetLinePen() const { return aPen; } 121cdf0e10cSrcweir sal_uLong GetLineWidth() const { return nLineWidth;} 122cdf0e10cSrcweir const Color& GetLineColor() const { return aLineColor;} 123cdf0e10cSrcweir 124cdf0e10cSrcweir 125cdf0e10cSrcweir SwColLineAdj GetLineAdj() const { return eAdj; } 126cdf0e10cSrcweir sal_Bool IsOrtho() const { return bOrtho; } 127cdf0e10cSrcweir sal_uInt16 GetWishWidth() const { return nWidth; } 128cdf0e10cSrcweir sal_uInt8 GetLineHeight()const { return nLineHeight; } 129cdf0e10cSrcweir 130cdf0e10cSrcweir //Return USHRT_MAX wenn uneindeutig. 131cdf0e10cSrcweir //Return die kleinste Breite wenn bMin True ist. 132cdf0e10cSrcweir sal_uInt16 GetGutterWidth( sal_Bool bMin = sal_False ) const; 133cdf0e10cSrcweir 134cdf0e10cSrcweir // void SetLinePen( const Pen& rNew ) { aPen = rNew; } 135cdf0e10cSrcweir void SetLineWidth(sal_uLong nLWidth) { nLineWidth = nLWidth;} 136cdf0e10cSrcweir void SetLineColor(const Color& rCol ) { aLineColor = rCol;} 137cdf0e10cSrcweir void SetLineHeight( sal_uInt8 nNew ) { nLineHeight = nNew; } 138cdf0e10cSrcweir void SetLineAdj( SwColLineAdj eNew ){ eAdj = eNew; } 139cdf0e10cSrcweir void SetWishWidth( sal_uInt16 nNew ) { nWidth = nNew; } 140cdf0e10cSrcweir 141cdf0e10cSrcweir //Mit dieser Funktion koennen die Spalten (immer wieder) initialisert 142cdf0e10cSrcweir //werden. Das Ortho Flag wird automatisch gesetzt. 143cdf0e10cSrcweir void Init( sal_uInt16 nNumCols, sal_uInt16 nGutterWidth, sal_uInt16 nAct ); 144cdf0e10cSrcweir 145cdf0e10cSrcweir //Stellt die Raender fuer die Spalten in aColumns ein. 146cdf0e10cSrcweir //Wenn das Flag bOrtho gesetzt ist, werden die Spalten neu optisch 147cdf0e10cSrcweir //verteilt. Ist das Flag nicht gesetzt werden die Spaltenbreiten nicht 148cdf0e10cSrcweir //veraendert und die Raender werden einfach eingestellt. 149cdf0e10cSrcweir void SetGutterWidth( sal_uInt16 nNew, sal_uInt16 nAct ); 150cdf0e10cSrcweir 151cdf0e10cSrcweir //Verteilt ebenfalls automatisch neu wenn das Flag gesetzt wird; 152cdf0e10cSrcweir //nur dann wird auch der zweite Param. benoetigt und beachtet. 153cdf0e10cSrcweir void SetOrtho( sal_Bool bNew, sal_uInt16 nGutterWidth, sal_uInt16 nAct ); 154cdf0e10cSrcweir 155cdf0e10cSrcweir //Fuer den Reader 156cdf0e10cSrcweir void _SetOrtho( sal_Bool bNew ) { bOrtho = bNew; } 157cdf0e10cSrcweir 158cdf0e10cSrcweir //Berechnet die aktuelle Breite der Spalte nCol. 159cdf0e10cSrcweir //Das Verhaeltniss von Wunschbreite der Spalte zum Returnwert ist 160cdf0e10cSrcweir //proportional zum Verhaeltniss des Gesamtwunschwertes zu nAct. 161cdf0e10cSrcweir sal_uInt16 CalcColWidth( sal_uInt16 nCol, sal_uInt16 nAct ) const; 162cdf0e10cSrcweir 163cdf0e10cSrcweir //Wie oben, aber es wir die Breite der PrtArea - also das was fuer 164cdf0e10cSrcweir //den Anwender die Spalte ist - geliefert. 165cdf0e10cSrcweir sal_uInt16 CalcPrtColWidth( sal_uInt16 nCol, sal_uInt16 nAct ) const; 166cdf0e10cSrcweir }; 167cdf0e10cSrcweir 168cdf0e10cSrcweir inline const SwFmtCol &SwAttrSet::GetCol(sal_Bool bInP) const 169cdf0e10cSrcweir { return (const SwFmtCol&)Get( RES_COL,bInP); } 170cdf0e10cSrcweir 171cdf0e10cSrcweir inline const SwFmtCol &SwFmt::GetCol(sal_Bool bInP) const 172cdf0e10cSrcweir { return aSet.GetCol(bInP); } 173cdf0e10cSrcweir 174cdf0e10cSrcweir #endif 175cdf0e10cSrcweir 176