xref: /aoo4110/main/editeng/inc/editeng/tstpitem.hxx (revision b1cdbd2c)
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 _SVX_TSPTITEM_HXX
24 #define _SVX_TSPTITEM_HXX
25 
26 // include ---------------------------------------------------------------
27 
28 #include <svl/poolitem.hxx>
29 #include <editeng/svxenum.hxx>
30 #include <editeng/editengdllapi.h>
31 
32 // class SvxTabStop ------------------------------------------------------
33 
34 #define SVX_TAB_DEFCOUNT    10
35 #define SVX_TAB_DEFDIST     1134            // 2cm in twips
36 #define SVX_TAB_NOTFOUND    USHRT_MAX
37 #define cDfltDecimalChar    (sal_Unicode(0x00)) // aus IntlWrapper besorgen
38 #define cDfltFillChar       (sal_Unicode(' '))
39 
40 class EDITENG_DLLPUBLIC SvxTabStop
41 {
42 private:
43 	long            nTabPos;
44 
45 	SvxTabAdjust    eAdjustment;
46 	mutable sal_Unicode		m_cDecimal;
47 	sal_Unicode		cFill;
48 
49 	EDITENG_DLLPRIVATE friend SvStream& operator<<( SvStream&, SvxTabStop& );
50 
51     void fillDecimal() const;
52 
53 public:
54 	SvxTabStop();
55 #if (_MSC_VER < 1300)
56 	SvxTabStop( const long nPos,
57 				const SvxTabAdjust eAdjst = SVX_TAB_ADJUST_LEFT,
58 				const sal_Unicode cDec = cDfltDecimalChar,
59 				const sal_Unicode cFil = cDfltFillChar );
60 #else
61 	SvxTabStop::SvxTabStop( const long nPos,
62 				const SvxTabAdjust eAdjst = SVX_TAB_ADJUST_LEFT,
63 				const sal_Unicode cDec = cDfltDecimalChar,
64 				const sal_Unicode cFil = cDfltFillChar );
65 #endif
66 
GetTabPos()67 	long&           GetTabPos() { return nTabPos; }
GetTabPos() const68 	long            GetTabPos() const { return nTabPos; }
69 
GetAdjustment()70 	SvxTabAdjust&   GetAdjustment() { return eAdjustment; }
GetAdjustment() const71 	SvxTabAdjust    GetAdjustment() const { return eAdjustment; }
72 
GetDecimal()73 	sal_Unicode&  GetDecimal() { fillDecimal(); return m_cDecimal; }
GetDecimal() const74 	sal_Unicode   GetDecimal() const { fillDecimal(); return m_cDecimal; }
75 
GetFill()76 	sal_Unicode&  GetFill() { return cFill; }
GetFill() const77 	sal_Unicode   GetFill() const { return cFill; }
78 
79 	String			GetValueString() const;
80 
81 	// das "alte" operator==()
IsEqual(const SvxTabStop & rTS) const82 	sal_Bool			IsEqual( const SvxTabStop& rTS ) const
83 						{
84 							return ( nTabPos     == rTS.nTabPos     &&
85 									 eAdjustment == rTS.eAdjustment &&
86 									 m_cDecimal    == rTS.m_cDecimal    &&
87 									 cFill       == rTS.cFill );
88 						}
89 
90 	// Fuer das SortedArray:
operator ==(const SvxTabStop & rTS) const91 	sal_Bool            operator==( const SvxTabStop& rTS ) const
92 						{ return nTabPos == rTS.nTabPos; }
operator <(const SvxTabStop & rTS) const93 	sal_Bool            operator <( const SvxTabStop& rTS ) const
94 						{ return nTabPos < rTS.nTabPos; }
95 
operator =(const SvxTabStop & rTS)96 	SvxTabStop&     operator=( const SvxTabStop& rTS )
97 						{
98 							nTabPos = rTS.nTabPos;
99 							eAdjustment = rTS.eAdjustment;
100 							m_cDecimal = rTS.m_cDecimal;
101 							cFill = rTS.cFill;
102 							return *this;
103 						}
104 };
105 
106 // class SvxTabStopItem --------------------------------------------------
107 
108 SV_DECL_VARARR_SORT_VISIBILITY( SvxTabStopArr, SvxTabStop, SVX_TAB_DEFCOUNT, 1, EDITENG_DLLPUBLIC )
109 
110 /*
111 [Beschreibung]
112 Dieses Item beschreibt eine Liste von TabStops.
113 */
114 
115 class EDITENG_DLLPUBLIC SvxTabStopItem : public SfxPoolItem, private SvxTabStopArr
116 {
117 //friend class SvxTabStopObject_Impl;
118 
119 public:
120 	TYPEINFO();
121 
122     SvxTabStopItem( sal_uInt16 nWhich  );
123 	SvxTabStopItem( const sal_uInt16 nTabs,
124 					const sal_uInt16 nDist,
125                     const SvxTabAdjust eAdjst /*= SVX_TAB_ADJUST_DEFAULT*/,
126                     sal_uInt16 nWhich  );
127 	SvxTabStopItem( const SvxTabStopItem& rTSI );
128 
129 	// Liefert Index-Position des Tabs zurueck oder TAB_NOTFOUND
130 	sal_uInt16          GetPos( const SvxTabStop& rTab ) const;
131 
132 	// Liefert Index-Position des Tabs an nPos zurueck oder TAB_NOTFOUND
133 	sal_uInt16          GetPos( const long nPos ) const;
134 
135 	// entprivatisiert:
Count() const136 	sal_uInt16          Count() const { return SvxTabStopArr::Count(); }
137 	sal_Bool            Insert( const SvxTabStop& rTab );
138 	void            Insert( const SvxTabStopItem* pTabs, sal_uInt16 nStart = 0,
139 							sal_uInt16 nEnd = USHRT_MAX );
Remove(SvxTabStop & rTab)140 	void            Remove( SvxTabStop& rTab )
141 						{ SvxTabStopArr::Remove( rTab ); }
Remove(const sal_uInt16 nPos,const sal_uInt16 nLen=1)142 	void            Remove( const sal_uInt16 nPos, const sal_uInt16 nLen = 1 )
143 						{ SvxTabStopArr::Remove( nPos, nLen ); }
144 
145 	// Zuweisungsoperator, Gleichheitsoperator (vorsicht: teuer!)
146 	SvxTabStopItem& operator=( const SvxTabStopItem& rTSI );
147 
148 	// this is already included in SfxPoolItem declaration
149 	//int             operator!=( const SvxTabStopItem& rTSI ) const
150 	//					{ return !( operator==( rTSI ) ); }
151 
152 	// SortedArrays liefern nur Stackobjekte zurueck!
operator [](const sal_uInt16 nPos) const153 	const SvxTabStop& operator[]( const sal_uInt16 nPos ) const
154 						{
155 							DBG_ASSERT( GetStart() &&
156 										nPos < Count(), "op[]" );
157 							return *( GetStart() + nPos );
158 						}
GetStart() const159 	const SvxTabStop*  GetStart() const
160 						{   return SvxTabStopArr::GetData(); }
161 
162 	// "pure virtual Methoden" vom SfxPoolItem
163 	virtual int 			 operator==( const SfxPoolItem& ) const;
164 	virtual	sal_Bool        	 QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
165 	virtual	sal_Bool			 PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
166 
167 	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
168 									SfxMapUnit eCoreMetric,
169 									SfxMapUnit ePresMetric,
170                                     String &rText, const IntlWrapper * = 0 ) const;
171 
172 	virtual SfxPoolItem*	 Clone( SfxItemPool *pPool = 0 ) const;
173 	virtual SfxPoolItem*	 Create( SvStream&, sal_uInt16 ) const;
174 	virtual SvStream&		 Store( SvStream& , sal_uInt16 nItemVersion ) const;
175 
176     using SvxTabStopArr::Insert;
177     using SvxTabStopArr::Remove;
178 };
179 
180 #endif
181 
182