xref: /AOO41X/main/sw/inc/fmtclds.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _FMTCLDS_HXX
28 #define _FMTCLDS_HXX
29 
30 #include <tools/color.hxx>
31 #include <svl/poolitem.hxx>
32 #include "swdllapi.h"
33 #include <hintids.hxx>
34 #include <format.hxx>
35 
36 //Der ColumnDescriptor --------------------------
37 
38 class SwColumn
39 {
40 	sal_uInt16 nWish;	//Wunschbreite incl. Raender.
41 					//Verhaelt sich proportional zum Verhaeltniss:
42 					//Wunschbreite der Umgebung / aktuelle Breite der Spalte
43 	sal_uInt16 nUpper;	//Oberer Rand
44 	sal_uInt16 nLower;	//Unterer Rand
45 	sal_uInt16 nLeft;	//Linker Rand
46 	sal_uInt16 nRight;	//Rechter Rand
47 
48 public:
49 	SwColumn();
50 
51 	sal_Bool operator==( const SwColumn & );
52 
53 
54 	void SetWishWidth( sal_uInt16 nNew ) { nWish  = nNew; }
55 	void SetUpper( sal_uInt16  nNew ) { nUpper = nNew; }
56 	void SetLower( sal_uInt16  nNew ) { nLower = nNew; }
57 	void SetLeft ( sal_uInt16  nNew ) { nLeft  = nNew; }
58 	void SetRight( sal_uInt16  nNew ) { nRight = nNew; }
59 
60 	sal_uInt16 GetWishWidth() const { return nWish;  }
61 	sal_uInt16 GetUpper() const { return nUpper; }
62 	sal_uInt16 GetLower() const { return nLower; }
63 	sal_uInt16 GetLeft () const { return nLeft; }
64 	sal_uInt16 GetRight() const { return nRight; }
65 };
66 
67 typedef SwColumn* SwColumnPtr;
68 SV_DECL_PTRARR_DEL( SwColumns, SwColumnPtr, 0, 2 )
69 
70 enum SwColLineAdj
71 {
72 	COLADJ_NONE,
73 	COLADJ_TOP,
74 	COLADJ_CENTER,
75 	COLADJ_BOTTOM
76 };
77 
78 class SW_DLLPUBLIC SwFmtCol : public SfxPoolItem
79 {
80 //	Pen		 aPen;			//Pen fuer die Linine zwischen den Spalten
81 	sal_uLong	nLineWidth;		//width of the separator line
82 	Color	aLineColor;		//color of the separator line
83 
84 	sal_uInt8 	 nLineHeight;	//Prozentuale Hoehe der Linien
85 							//(Relativ zu der Hoehe der Spalten incl. UL).
86 	SwColLineAdj eAdj;		//Linie wird oben, mittig oder unten ausgerichtet.
87 
88 	SwColumns	aColumns;	//Informationen fuer die einzelnen Spalten.
89 	sal_uInt16		nWidth;		//Gesamtwunschbreite aller Spalten.
90 
91 	sal_Bool bOrtho;			//Nur wenn dieses Flag gesetzt ist wird beim setzen
92 							//der GutterWidth eine 'optische Verteilung'
93 							//vorgenommen.
94 							//Es muss zurueckgesetzt werden wenn an den
95 							//Spaltenbreiten bzw. den Raendern gedreht wird.
96 							//Wenn es wieder gesetzt wird wird automatisch neu
97 							//gemischt (optisch verteilt).
98 							//Das Flag ist initial gesetzt.
99 
100 	SW_DLLPRIVATE void Calc( sal_uInt16 nGutterWidth, sal_uInt16 nAct );
101 
102 public:
103 	SwFmtCol();
104 	SwFmtCol( const SwFmtCol& );
105 	~SwFmtCol();
106 
107 	SwFmtCol& operator=( const SwFmtCol& );
108 
109 	// "pure virtual Methoden" vom SfxPoolItem
110 	virtual int             operator==( const SfxPoolItem& ) const;
111 	virtual SfxPoolItem*	Clone( SfxItemPool* pPool = 0 ) const;
112 	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
113 									SfxMapUnit eCoreMetric,
114 									SfxMapUnit ePresMetric,
115 									String &rText,
116                                     const IntlWrapper* pIntl = 0 ) const;
117 
118 	virtual	sal_Bool        	 QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
119 	virtual	sal_Bool			 PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
120 
121 	const SwColumns &GetColumns() const { return aColumns; }
122 		  SwColumns &GetColumns()		{ return aColumns; }
123 	sal_uInt16			 GetNumCols() const { return aColumns.Count(); }
124 //	const Pen&       GetLinePen() const { return aPen; }
125 	sal_uLong			GetLineWidth() const  { return nLineWidth;}
126 	const Color&	GetLineColor() const { return aLineColor;}
127 
128 
129 	SwColLineAdj	 GetLineAdj() const { return eAdj; }
130 	sal_Bool			 IsOrtho()	  const { return bOrtho; }
131 	sal_uInt16			 GetWishWidth() const { return nWidth; }
132 	sal_uInt8			 GetLineHeight()const { return nLineHeight; }
133 
134 	//Return USHRT_MAX wenn uneindeutig.
135 	//Return die kleinste Breite wenn bMin True ist.
136 	sal_uInt16 GetGutterWidth( sal_Bool bMin = sal_False ) const;
137 
138 //	void SetLinePen( const Pen& rNew )  { aPen = rNew; }
139     void SetLineWidth(sal_uLong nLWidth)        { nLineWidth = nLWidth;}
140 	void SetLineColor(const Color& rCol )  	{ aLineColor = rCol;}
141 	void SetLineHeight( sal_uInt8 nNew )     { nLineHeight = nNew; }
142 	void SetLineAdj( SwColLineAdj eNew ){ eAdj = eNew; }
143 	void SetWishWidth( sal_uInt16 nNew )	{ nWidth = nNew; }
144 
145 	//Mit dieser Funktion koennen die Spalten (immer wieder) initialisert
146 	//werden. Das Ortho Flag wird automatisch gesetzt.
147 	void Init( sal_uInt16 nNumCols, sal_uInt16 nGutterWidth, sal_uInt16 nAct );
148 
149 	//Stellt die Raender fuer die Spalten in aColumns ein.
150 	//Wenn das Flag bOrtho gesetzt ist, werden die Spalten neu optisch
151 	//verteilt. Ist das Flag nicht gesetzt werden die Spaltenbreiten nicht
152 	//veraendert und die Raender werden einfach eingestellt.
153 	void SetGutterWidth( sal_uInt16 nNew, sal_uInt16 nAct );
154 
155 	//Verteilt ebenfalls automatisch neu wenn das Flag gesetzt wird;
156 	//nur dann wird auch der zweite Param. benoetigt und beachtet.
157 	void SetOrtho( sal_Bool bNew, sal_uInt16 nGutterWidth, sal_uInt16 nAct );
158 
159 	//Fuer den Reader
160 	void _SetOrtho( sal_Bool bNew ) { bOrtho = bNew; }
161 
162 	//Berechnet die aktuelle Breite der Spalte nCol.
163 	//Das Verhaeltniss von Wunschbreite der Spalte zum Returnwert ist
164 	//proportional zum Verhaeltniss des Gesamtwunschwertes zu nAct.
165 	sal_uInt16 CalcColWidth( sal_uInt16 nCol, sal_uInt16 nAct ) const;
166 
167 	//Wie oben, aber es wir die Breite der PrtArea - also das was fuer
168 	//den Anwender die Spalte ist - geliefert.
169 	sal_uInt16 CalcPrtColWidth( sal_uInt16 nCol, sal_uInt16 nAct ) const;
170 };
171 
172 inline const SwFmtCol &SwAttrSet::GetCol(sal_Bool bInP) const
173 	{ return (const SwFmtCol&)Get( RES_COL,bInP); }
174 
175 inline const SwFmtCol &SwFmt::GetCol(sal_Bool bInP) const
176 	{ return aSet.GetCol(bInP); }
177 
178 #endif
179 
180