xref: /AOO41X/main/sw/inc/fmtclds.hxx (revision 47148b3bc50811ceb41802e4cc50a5db21535900)
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 
SetWishWidth(sal_uInt16 nNew)50     void SetWishWidth( sal_uInt16 nNew ) { nWish  = nNew; }
SetUpper(sal_uInt16 nNew)51     void SetUpper( sal_uInt16  nNew ) { nUpper = nNew; }
SetLower(sal_uInt16 nNew)52     void SetLower( sal_uInt16  nNew ) { nLower = nNew; }
SetLeft(sal_uInt16 nNew)53     void SetLeft ( sal_uInt16  nNew ) { nLeft  = nNew; }
SetRight(sal_uInt16 nNew)54     void SetRight( sal_uInt16  nNew ) { nRight = nNew; }
55 
GetWishWidth() const56     sal_uInt16 GetWishWidth() const { return nWish;  }
GetUpper() const57     sal_uInt16 GetUpper() const { return nUpper; }
GetLower() const58     sal_uInt16 GetLower() const { return nLower; }
GetLeft() const59     sal_uInt16 GetLeft () const { return nLeft; }
GetRight() const60     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     sal_Int16   aWidthAdjustValue;
87 
88     sal_Bool bOrtho;            //Nur wenn dieses Flag gesetzt ist wird beim setzen
89                             //der GutterWidth eine 'optische Verteilung'
90                             //vorgenommen.
91                             //Es muss zurueckgesetzt werden wenn an den
92                             //Spaltenbreiten bzw. den Raendern gedreht wird.
93                             //Wenn es wieder gesetzt wird wird automatisch neu
94                             //gemischt (optisch verteilt).
95                             //Das Flag ist initial gesetzt.
96 
97     SW_DLLPRIVATE void Calc( sal_uInt16 nGutterWidth, sal_uInt16 nAct );
98 
99 public:
100     SwFmtCol();
101     SwFmtCol( const SwFmtCol& );
102     ~SwFmtCol();
103     //i120133
GetAdjustValue() const104     sal_Int16 GetAdjustValue() const { return aWidthAdjustValue; }
SetAdjustValue(const sal_Int16 & n)105     void    SetAdjustValue( const sal_Int16& n ) { aWidthAdjustValue = n; }
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 
GetColumns() const121     const SwColumns &GetColumns() const { return aColumns; }
GetColumns()122           SwColumns &GetColumns()       { return aColumns; }
GetNumCols() const123     sal_uInt16           GetNumCols() const { return aColumns.Count(); }
124 //  const Pen&       GetLinePen() const { return aPen; }
GetLineWidth() const125     sal_uLong           GetLineWidth() const  { return nLineWidth;}
GetLineColor() const126     const Color&    GetLineColor() const { return aLineColor;}
127 
128 
GetLineAdj() const129     SwColLineAdj     GetLineAdj() const { return eAdj; }
IsOrtho() const130     sal_Bool             IsOrtho()    const { return bOrtho; }
GetWishWidth() const131     sal_uInt16           GetWishWidth() const { return nWidth; }
GetLineHeight() const132     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; }
SetLineWidth(sal_uLong nLWidth)139     void SetLineWidth(sal_uLong nLWidth)        { nLineWidth = nLWidth;}
SetLineColor(const Color & rCol)140     void SetLineColor(const Color& rCol )   { aLineColor = rCol;}
SetLineHeight(sal_uInt8 nNew)141     void SetLineHeight( sal_uInt8 nNew )     { nLineHeight = nNew; }
SetLineAdj(SwColLineAdj eNew)142     void SetLineAdj( SwColLineAdj eNew ){ eAdj = eNew; }
SetWishWidth(sal_uInt16 nNew)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
_SetOrtho(sal_Bool bNew)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 
GetCol(sal_Bool bInP) const172 inline const SwFmtCol &SwAttrSet::GetCol(sal_Bool bInP) const
173     { return (const SwFmtCol&)Get( RES_COL,bInP); }
174 
GetCol(sal_Bool bInP) const175 inline const SwFmtCol &SwFmt::GetCol(sal_Bool bInP) const
176     { return aSet.GetCol(bInP); }
177 
178 #endif
179 
180