1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <svl/intitem.hxx>
22 #include <com/sun/star/uno/Any.hxx>
23 #include <tools/bigint.hxx>
24 #include <tools/stream.hxx>
25 #include <svl/metitem.hxx>
27 //============================================================================
31 //============================================================================
33 TYPEINIT1_AUTOFACTORY(SfxByteItem
, CntByteItem
);
35 //============================================================================
37 SfxPoolItem
* SfxByteItem::Create(SvStream
& rStream
, sal_uInt16
) const
41 return new SfxByteItem(Which(), sal_uInt8(nValue
));
44 //============================================================================
48 //============================================================================
50 DBG_NAME(SfxInt16Item
);
52 //============================================================================
53 TYPEINIT1_AUTOFACTORY(SfxInt16Item
, SfxPoolItem
);
55 //============================================================================
56 SfxInt16Item::SfxInt16Item(sal_uInt16 which
, SvStream
& rStream
):
59 DBG_CTOR(SfxInt16Item
, 0);
65 //============================================================================
67 int SfxInt16Item::operator ==(const SfxPoolItem
& rItem
) const
69 DBG_CHKTHIS(SfxInt16Item
, 0);
70 DBG_ASSERT(SfxPoolItem::operator ==(rItem
), "unequal type");
71 return m_nValue
== (static_cast< const SfxInt16Item
* >(&rItem
))->
75 //============================================================================
77 int SfxInt16Item::Compare(const SfxPoolItem
& rWith
) const
79 DBG_CHKTHIS(SfxInt16Item
, 0);
80 DBG_ASSERT(SfxPoolItem::operator ==(rWith
), "unequal type");
81 return (static_cast< const SfxInt16Item
* >(&rWith
))->m_nValue
84 (static_cast< const SfxInt16Item
* >(&rWith
))->m_nValue
89 //============================================================================
91 SfxItemPresentation
SfxInt16Item::GetPresentation(SfxItemPresentation
,
92 SfxMapUnit
, SfxMapUnit
,
94 const IntlWrapper
*) const
96 DBG_CHKTHIS(SfxInt16Item
, 0);
97 rText
= OUString::number(m_nValue
);
98 return SFX_ITEM_PRESENTATION_NAMELESS
;
102 //============================================================================
104 bool SfxInt16Item::QueryValue(com::sun::star::uno::Any
& rVal
, sal_uInt8
) const
106 sal_Int16 nValue
= m_nValue
;
111 //============================================================================
113 bool SfxInt16Item::PutValue(const com::sun::star::uno::Any
& rVal
, sal_uInt8
)
115 sal_Int16 nValue
= sal_Int16();
122 OSL_FAIL( "SfxInt16Item::PutValue - Wrong type!" );
126 //============================================================================
128 SfxPoolItem
* SfxInt16Item::Create(SvStream
& rStream
, sal_uInt16
) const
130 DBG_CHKTHIS(SfxInt16Item
, 0);
131 return new SfxInt16Item(Which(), rStream
);
134 //============================================================================
136 SvStream
& SfxInt16Item::Store(SvStream
& rStream
, sal_uInt16
) const
138 DBG_CHKTHIS(SfxInt16Item
, 0);
139 rStream
<< short(m_nValue
);
143 //============================================================================
144 SfxPoolItem
* SfxInt16Item::Clone(SfxItemPool
*) const
146 DBG_CHKTHIS(SfxInt16Item
, 0);
147 return new SfxInt16Item(*this);
150 //============================================================================
151 sal_Int16
SfxInt16Item::GetMin() const
153 DBG_CHKTHIS(SfxInt16Item
, 0);
157 //============================================================================
158 sal_Int16
SfxInt16Item::GetMax() const
160 DBG_CHKTHIS(SfxInt16Item
, 0);
164 //============================================================================
165 SfxFieldUnit
SfxInt16Item::GetUnit() const
167 DBG_CHKTHIS(SfxInt16Item
, 0);
168 return SFX_FUNIT_NONE
;
171 //============================================================================
173 // class SfxUInt16Item
175 //============================================================================
177 TYPEINIT1_AUTOFACTORY(SfxUInt16Item
, CntUInt16Item
);
180 //============================================================================
182 // class SfxInt32Item
184 //============================================================================
186 TYPEINIT1_AUTOFACTORY(SfxInt32Item
, CntInt32Item
);
189 //============================================================================
191 // class SfxUInt32Item
193 //============================================================================
195 TYPEINIT1_AUTOFACTORY(SfxUInt32Item
, CntUInt32Item
);
198 //============================================================================
200 // class SfxMetricItem
202 //============================================================================
204 DBG_NAME(SfxMetricItem
);
206 //============================================================================
207 TYPEINIT1_AUTOFACTORY(SfxMetricItem
, SfxInt32Item
);
209 //============================================================================
210 SfxMetricItem::SfxMetricItem(sal_uInt16 which
, sal_uInt32 nValue
):
211 SfxInt32Item(which
, nValue
)
213 DBG_CTOR(SfxMetricItem
, 0);
216 //============================================================================
217 SfxMetricItem::SfxMetricItem(sal_uInt16 which
, SvStream
& rStream
):
218 SfxInt32Item(which
, rStream
)
220 DBG_CTOR(SfxMetricItem
, 0);
223 //============================================================================
224 SfxMetricItem::SfxMetricItem(const SfxMetricItem
& rItem
):
227 DBG_CTOR(SfxMetricItem
, 0);
230 //============================================================================
232 bool SfxMetricItem::ScaleMetrics(long nMult
, long nDiv
)
234 BigInt
aTheValue(GetValue());
236 aTheValue
+= nDiv
/ 2;
242 //============================================================================
244 bool SfxMetricItem::HasMetrics() const
249 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */