1*40df464eSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*40df464eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*40df464eSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*40df464eSAndrew Rist * distributed with this work for additional information
6*40df464eSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*40df464eSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*40df464eSAndrew Rist * "License"); you may not use this file except in compliance
9*40df464eSAndrew Rist * with the License. You may obtain a copy of the License at
10*40df464eSAndrew Rist *
11*40df464eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*40df464eSAndrew Rist *
13*40df464eSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*40df464eSAndrew Rist * software distributed under the License is distributed on an
15*40df464eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*40df464eSAndrew Rist * KIND, either express or implied. See the License for the
17*40df464eSAndrew Rist * specific language governing permissions and limitations
18*40df464eSAndrew Rist * under the License.
19*40df464eSAndrew Rist *
20*40df464eSAndrew Rist *************************************************************/
21*40df464eSAndrew Rist
22*40df464eSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <svl/intitem.hxx>
28cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
29cdf0e10cSrcweir #include <tools/bigint.hxx>
30cdf0e10cSrcweir #include <tools/stream.hxx>
31cdf0e10cSrcweir #include <svl/metitem.hxx>
32cdf0e10cSrcweir
33cdf0e10cSrcweir //============================================================================
34cdf0e10cSrcweir //
35cdf0e10cSrcweir // class SfxByteItem
36cdf0e10cSrcweir //
37cdf0e10cSrcweir //============================================================================
38cdf0e10cSrcweir
39cdf0e10cSrcweir TYPEINIT1_AUTOFACTORY(SfxByteItem, CntByteItem);
40cdf0e10cSrcweir
41cdf0e10cSrcweir //============================================================================
42cdf0e10cSrcweir // virtual
Create(SvStream & rStream,sal_uInt16) const43cdf0e10cSrcweir SfxPoolItem * SfxByteItem::Create(SvStream & rStream, sal_uInt16) const
44cdf0e10cSrcweir {
45cdf0e10cSrcweir short nValue = 0;
46cdf0e10cSrcweir rStream >> nValue;
47cdf0e10cSrcweir return new SfxByteItem(Which(), sal_uInt8(nValue));
48cdf0e10cSrcweir }
49cdf0e10cSrcweir
50cdf0e10cSrcweir //============================================================================
51cdf0e10cSrcweir //
52cdf0e10cSrcweir // class SfxInt16Item
53cdf0e10cSrcweir //
54cdf0e10cSrcweir //============================================================================
55cdf0e10cSrcweir
56cdf0e10cSrcweir DBG_NAME(SfxInt16Item);
57cdf0e10cSrcweir
58cdf0e10cSrcweir //============================================================================
59cdf0e10cSrcweir TYPEINIT1_AUTOFACTORY(SfxInt16Item, SfxPoolItem);
60cdf0e10cSrcweir
61cdf0e10cSrcweir //============================================================================
SfxInt16Item(sal_uInt16 which,SvStream & rStream)62cdf0e10cSrcweir SfxInt16Item::SfxInt16Item(sal_uInt16 which, SvStream & rStream):
63cdf0e10cSrcweir SfxPoolItem(which)
64cdf0e10cSrcweir {
65cdf0e10cSrcweir DBG_CTOR(SfxInt16Item, 0);
66cdf0e10cSrcweir short nTheValue = 0;
67cdf0e10cSrcweir rStream >> nTheValue;
68cdf0e10cSrcweir m_nValue = nTheValue;
69cdf0e10cSrcweir }
70cdf0e10cSrcweir
71cdf0e10cSrcweir //============================================================================
72cdf0e10cSrcweir // virtual
operator ==(const SfxPoolItem & rItem) const73cdf0e10cSrcweir int SfxInt16Item::operator ==(const SfxPoolItem & rItem) const
74cdf0e10cSrcweir {
75cdf0e10cSrcweir DBG_CHKTHIS(SfxInt16Item, 0);
76cdf0e10cSrcweir DBG_ASSERT(SfxPoolItem::operator ==(rItem), "unequal type");
77cdf0e10cSrcweir return m_nValue == SAL_STATIC_CAST(const SfxInt16Item *, &rItem)->
78cdf0e10cSrcweir m_nValue;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir
81cdf0e10cSrcweir //============================================================================
82cdf0e10cSrcweir // virtual
Compare(const SfxPoolItem & rWith) const83cdf0e10cSrcweir int SfxInt16Item::Compare(const SfxPoolItem & rWith) const
84cdf0e10cSrcweir {
85cdf0e10cSrcweir DBG_CHKTHIS(SfxInt16Item, 0);
86cdf0e10cSrcweir DBG_ASSERT(SfxPoolItem::operator ==(rWith), "unequal type");
87cdf0e10cSrcweir return SAL_STATIC_CAST(const SfxInt16Item *, &rWith)->m_nValue
88cdf0e10cSrcweir < m_nValue ?
89cdf0e10cSrcweir -1 :
90cdf0e10cSrcweir SAL_STATIC_CAST(const SfxInt16Item *, &rWith)->m_nValue
91cdf0e10cSrcweir == m_nValue ?
92cdf0e10cSrcweir 0 : 1;
93cdf0e10cSrcweir }
94cdf0e10cSrcweir
95cdf0e10cSrcweir //============================================================================
96cdf0e10cSrcweir // virtual
GetPresentation(SfxItemPresentation,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const97cdf0e10cSrcweir SfxItemPresentation SfxInt16Item::GetPresentation(SfxItemPresentation,
98cdf0e10cSrcweir SfxMapUnit, SfxMapUnit,
99cdf0e10cSrcweir XubString & rText,
100cdf0e10cSrcweir const IntlWrapper *) const
101cdf0e10cSrcweir {
102cdf0e10cSrcweir DBG_CHKTHIS(SfxInt16Item, 0);
103cdf0e10cSrcweir rText = UniString::CreateFromInt32(m_nValue);
104cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NAMELESS;
105cdf0e10cSrcweir }
106cdf0e10cSrcweir
107cdf0e10cSrcweir
108cdf0e10cSrcweir //============================================================================
109cdf0e10cSrcweir // virtual
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8) const110cdf0e10cSrcweir sal_Bool SfxInt16Item::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8) const
111cdf0e10cSrcweir {
112cdf0e10cSrcweir sal_Int16 nValue = m_nValue;
113cdf0e10cSrcweir rVal <<= nValue;
114cdf0e10cSrcweir return sal_True;
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
117cdf0e10cSrcweir //============================================================================
118cdf0e10cSrcweir // virtual
PutValue(const com::sun::star::uno::Any & rVal,sal_uInt8)119cdf0e10cSrcweir sal_Bool SfxInt16Item::PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8 )
120cdf0e10cSrcweir {
121cdf0e10cSrcweir sal_Int16 nValue = sal_Int16();
122cdf0e10cSrcweir if (rVal >>= nValue)
123cdf0e10cSrcweir {
124cdf0e10cSrcweir m_nValue = nValue;
125cdf0e10cSrcweir return sal_True;
126cdf0e10cSrcweir }
127cdf0e10cSrcweir
128cdf0e10cSrcweir DBG_ERROR( "SfxInt16Item::PutValue - Wrong type!" );
129cdf0e10cSrcweir return sal_False;
130cdf0e10cSrcweir }
131cdf0e10cSrcweir
132cdf0e10cSrcweir //============================================================================
133cdf0e10cSrcweir // virtual
Create(SvStream & rStream,sal_uInt16) const134cdf0e10cSrcweir SfxPoolItem * SfxInt16Item::Create(SvStream & rStream, sal_uInt16) const
135cdf0e10cSrcweir {
136cdf0e10cSrcweir DBG_CHKTHIS(SfxInt16Item, 0);
137cdf0e10cSrcweir return new SfxInt16Item(Which(), rStream);
138cdf0e10cSrcweir }
139cdf0e10cSrcweir
140cdf0e10cSrcweir //============================================================================
141cdf0e10cSrcweir // virtual
Store(SvStream & rStream,sal_uInt16) const142cdf0e10cSrcweir SvStream & SfxInt16Item::Store(SvStream & rStream, sal_uInt16) const
143cdf0e10cSrcweir {
144cdf0e10cSrcweir DBG_CHKTHIS(SfxInt16Item, 0);
145cdf0e10cSrcweir rStream << short(m_nValue);
146cdf0e10cSrcweir return rStream;
147cdf0e10cSrcweir }
148cdf0e10cSrcweir
149cdf0e10cSrcweir //============================================================================
Clone(SfxItemPool *) const150cdf0e10cSrcweir SfxPoolItem * SfxInt16Item::Clone(SfxItemPool *) const
151cdf0e10cSrcweir {
152cdf0e10cSrcweir DBG_CHKTHIS(SfxInt16Item, 0);
153cdf0e10cSrcweir return new SfxInt16Item(*this);
154cdf0e10cSrcweir }
155cdf0e10cSrcweir
156cdf0e10cSrcweir //============================================================================
GetMin() const157cdf0e10cSrcweir sal_Int16 SfxInt16Item::GetMin() const
158cdf0e10cSrcweir {
159cdf0e10cSrcweir DBG_CHKTHIS(SfxInt16Item, 0);
160cdf0e10cSrcweir return -32768;
161cdf0e10cSrcweir }
162cdf0e10cSrcweir
163cdf0e10cSrcweir //============================================================================
GetMax() const164cdf0e10cSrcweir sal_Int16 SfxInt16Item::GetMax() const
165cdf0e10cSrcweir {
166cdf0e10cSrcweir DBG_CHKTHIS(SfxInt16Item, 0);
167cdf0e10cSrcweir return 32767;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir
170cdf0e10cSrcweir //============================================================================
GetUnit() const171cdf0e10cSrcweir SfxFieldUnit SfxInt16Item::GetUnit() const
172cdf0e10cSrcweir {
173cdf0e10cSrcweir DBG_CHKTHIS(SfxInt16Item, 0);
174cdf0e10cSrcweir return SFX_FUNIT_NONE;
175cdf0e10cSrcweir }
176cdf0e10cSrcweir
177cdf0e10cSrcweir //============================================================================
178cdf0e10cSrcweir //
179cdf0e10cSrcweir // class SfxUInt16Item
180cdf0e10cSrcweir //
181cdf0e10cSrcweir //============================================================================
182cdf0e10cSrcweir
183cdf0e10cSrcweir TYPEINIT1_AUTOFACTORY(SfxUInt16Item, CntUInt16Item);
184cdf0e10cSrcweir
185cdf0e10cSrcweir
186cdf0e10cSrcweir //============================================================================
187cdf0e10cSrcweir //
188cdf0e10cSrcweir // class SfxInt32Item
189cdf0e10cSrcweir //
190cdf0e10cSrcweir //============================================================================
191cdf0e10cSrcweir
192cdf0e10cSrcweir TYPEINIT1_AUTOFACTORY(SfxInt32Item, CntInt32Item);
193cdf0e10cSrcweir
194cdf0e10cSrcweir
195cdf0e10cSrcweir //============================================================================
196cdf0e10cSrcweir //
197cdf0e10cSrcweir // class SfxUInt32Item
198cdf0e10cSrcweir //
199cdf0e10cSrcweir //============================================================================
200cdf0e10cSrcweir
201cdf0e10cSrcweir TYPEINIT1_AUTOFACTORY(SfxUInt32Item, CntUInt32Item);
202cdf0e10cSrcweir
203cdf0e10cSrcweir
204cdf0e10cSrcweir //============================================================================
205cdf0e10cSrcweir //
206cdf0e10cSrcweir // class SfxMetricItem
207cdf0e10cSrcweir //
208cdf0e10cSrcweir //============================================================================
209cdf0e10cSrcweir
210cdf0e10cSrcweir DBG_NAME(SfxMetricItem);
211cdf0e10cSrcweir
212cdf0e10cSrcweir //============================================================================
213cdf0e10cSrcweir TYPEINIT1_AUTOFACTORY(SfxMetricItem, SfxInt32Item);
214cdf0e10cSrcweir
215cdf0e10cSrcweir //============================================================================
SfxMetricItem(sal_uInt16 which,sal_uInt32 nValue)216cdf0e10cSrcweir SfxMetricItem::SfxMetricItem(sal_uInt16 which, sal_uInt32 nValue):
217cdf0e10cSrcweir SfxInt32Item(which, nValue)
218cdf0e10cSrcweir {
219cdf0e10cSrcweir DBG_CTOR(SfxMetricItem, 0);
220cdf0e10cSrcweir }
221cdf0e10cSrcweir
222cdf0e10cSrcweir //============================================================================
SfxMetricItem(sal_uInt16 which,SvStream & rStream)223cdf0e10cSrcweir SfxMetricItem::SfxMetricItem(sal_uInt16 which, SvStream & rStream):
224cdf0e10cSrcweir SfxInt32Item(which, rStream)
225cdf0e10cSrcweir {
226cdf0e10cSrcweir DBG_CTOR(SfxMetricItem, 0);
227cdf0e10cSrcweir }
228cdf0e10cSrcweir
229cdf0e10cSrcweir //============================================================================
SfxMetricItem(const SfxMetricItem & rItem)230cdf0e10cSrcweir SfxMetricItem::SfxMetricItem(const SfxMetricItem & rItem):
231cdf0e10cSrcweir SfxInt32Item(rItem)
232cdf0e10cSrcweir {
233cdf0e10cSrcweir DBG_CTOR(SfxMetricItem, 0);
234cdf0e10cSrcweir }
235cdf0e10cSrcweir
236cdf0e10cSrcweir //============================================================================
237cdf0e10cSrcweir // virtual
ScaleMetrics(long nMult,long nDiv)238cdf0e10cSrcweir int SfxMetricItem::ScaleMetrics(long nMult, long nDiv)
239cdf0e10cSrcweir {
240cdf0e10cSrcweir BigInt aTheValue(GetValue());
241cdf0e10cSrcweir aTheValue *= nMult;
242cdf0e10cSrcweir aTheValue += nDiv / 2;
243cdf0e10cSrcweir aTheValue /= nDiv;
244cdf0e10cSrcweir SetValue(aTheValue);
245cdf0e10cSrcweir return 1;
246cdf0e10cSrcweir }
247cdf0e10cSrcweir
248cdf0e10cSrcweir //============================================================================
249cdf0e10cSrcweir // virtual
HasMetrics() const250cdf0e10cSrcweir int SfxMetricItem::HasMetrics() const
251cdf0e10cSrcweir {
252cdf0e10cSrcweir return 1;
253cdf0e10cSrcweir }
254cdf0e10cSrcweir
255