Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _SVX_TSPTITEM_HXX
29 : : #define _SVX_TSPTITEM_HXX
30 : :
31 : : #include <svl/poolitem.hxx>
32 : : #include <editeng/svxenum.hxx>
33 : : #include <editeng/editengdllapi.h>
34 : : #include <o3tl/sorted_vector.hxx>
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)) // Get from IntlWrapper
42 : : #define cDfltFillChar (sal_Unicode(' '))
43 : :
44 : : class EDITENG_DLLPUBLIC SvxTabStop
45 : : {
46 : : private:
47 : : sal_Int32 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 : : SvxTabStop( const sal_Int32 nPos,
60 : : const SvxTabAdjust eAdjst = SVX_TAB_ADJUST_LEFT,
61 : : const sal_Unicode cDec = cDfltDecimalChar,
62 : : const sal_Unicode cFil = cDfltFillChar );
63 : :
64 : 312 : sal_Int32& GetTabPos() { return nTabPos; }
65 : 30316 : sal_Int32 GetTabPos() const { return nTabPos; }
66 : :
67 : 258 : SvxTabAdjust& GetAdjustment() { return eAdjustment; }
68 : 8775 : SvxTabAdjust GetAdjustment() const { return eAdjustment; }
69 : :
70 : 0 : sal_Unicode& GetDecimal() { fillDecimal(); return m_cDecimal; }
71 : 3455 : sal_Unicode GetDecimal() const { fillDecimal(); return m_cDecimal; }
72 : :
73 : 312 : sal_Unicode& GetFill() { return cFill; }
74 : 3526 : sal_Unicode GetFill() const { return cFill; }
75 : :
76 : : String GetValueString() const;
77 : :
78 : : // the "old" operator==()
79 : 8274 : sal_Bool IsEqual( const SvxTabStop& rTS ) const
80 : : {
81 : : return ( nTabPos == rTS.nTabPos &&
82 : : eAdjustment == rTS.eAdjustment &&
83 : : m_cDecimal == rTS.m_cDecimal &&
84 [ + + ][ + + ]: 8274 : cFill == rTS.cFill );
[ + + ][ + - ]
85 : : }
86 : :
87 : : // For the SortedArray:
88 : : sal_Bool operator==( const SvxTabStop& rTS ) const
89 : : { return nTabPos == rTS.nTabPos; }
90 : 19291 : sal_Bool operator <( const SvxTabStop& rTS ) const
91 : 19291 : { return nTabPos < rTS.nTabPos; }
92 : :
93 : 15 : SvxTabStop& operator=( const SvxTabStop& rTS )
94 : : {
95 : 15 : nTabPos = rTS.nTabPos;
96 : 15 : eAdjustment = rTS.eAdjustment;
97 : 15 : m_cDecimal = rTS.m_cDecimal;
98 : 15 : cFill = rTS.cFill;
99 : 15 : return *this;
100 : : }
101 : : };
102 : :
103 : : // class SvxTabStopItem --------------------------------------------------
104 : :
105 : : typedef o3tl::sorted_vector<SvxTabStop> SvxTabStopArr;
106 : :
107 : : /* [Description]
108 : :
109 : : This item describes a list of TabStops.
110 : : */
111 : :
112 [ - + ]: 220579 : class EDITENG_DLLPUBLIC SvxTabStopItem : public SfxPoolItem
113 : : {
114 : : SvxTabStopArr maTabStops;
115 : :
116 : : public:
117 : : TYPEINFO();
118 : :
119 : : SvxTabStopItem( sal_uInt16 nWhich );
120 : : SvxTabStopItem( const sal_uInt16 nTabs,
121 : : const sal_uInt16 nDist,
122 : : const SvxTabAdjust eAdjst /*= SVX_TAB_ADJUST_DEFAULT*/,
123 : : sal_uInt16 nWhich );
124 : : SvxTabStopItem( const SvxTabStopItem& rTSI );
125 : :
126 : : // Returns index of the tab or TAB_NOTFOUND
127 : : sal_uInt16 GetPos( const SvxTabStop& rTab ) const;
128 : :
129 : : // Returns index of the tab at nPos, or TAB_NOTFOUND
130 : : sal_uInt16 GetPos( const sal_Int32 nPos ) const;
131 : :
132 : : // unprivatized:
133 : 77688 : sal_uInt16 Count() const { return maTabStops.size(); }
134 : : bool Insert( const SvxTabStop& rTab );
135 : : void Insert( const SvxTabStopItem* pTabs, sal_uInt16 nStart = 0,
136 : : sal_uInt16 nEnd = USHRT_MAX );
137 : : void Remove( SvxTabStop& rTab )
138 : : { maTabStops.erase( rTab ); }
139 : 1230 : void Remove( const sal_uInt16 nPos, const sal_uInt16 nLen = 1 )
140 [ + - ][ + - ]: 1230 : { maTabStops.erase( maTabStops.begin() + nPos, maTabStops.begin() + nPos + nLen ); }
[ + - ][ + - ]
141 : :
142 : : // Assignment operator, equality operator (caution: expensive!)
143 : : SvxTabStopItem& operator=( const SvxTabStopItem& rTSI );
144 : :
145 : : // this is already included in SfxPoolItem declaration
146 : : //int operator!=( const SvxTabStopItem& rTSI ) const
147 : : // { return !( operator==( rTSI ) ); }
148 : :
149 : 46195 : const SvxTabStop& operator[]( const sal_uInt16 nPos ) const
150 : 46195 : { return maTabStops[nPos]; }
151 : :
152 : : // "pure virtual Methods" from SfxPoolItem
153 : : virtual int operator==( const SfxPoolItem& ) const;
154 : : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
155 : : virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
156 : :
157 : : virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
158 : : SfxMapUnit eCoreMetric,
159 : : SfxMapUnit ePresMetric,
160 : : String &rText, const IntlWrapper * = 0 ) const;
161 : :
162 : : virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
163 : : virtual SfxPoolItem* Create( SvStream&, sal_uInt16 ) const;
164 : : virtual SvStream& Store( SvStream& , sal_uInt16 nItemVersion ) const;
165 : :
166 : : };
167 : :
168 : : #endif
169 : :
170 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|