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