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>
31 TYPEINIT1_AUTOFACTORY(SfxByteItem
, CntByteItem
);
34 SfxPoolItem
* SfxByteItem::Create(SvStream
& rStream
, sal_uInt16
) const
38 return new SfxByteItem(Which(), sal_uInt8(nValue
));
45 DBG_NAME(SfxInt16Item
);
47 TYPEINIT1_AUTOFACTORY(SfxInt16Item
, SfxPoolItem
);
49 SfxInt16Item::SfxInt16Item(sal_uInt16 which
, SvStream
& rStream
):
52 DBG_CTOR(SfxInt16Item
, 0);
59 int SfxInt16Item::operator ==(const SfxPoolItem
& rItem
) const
61 DBG_CHKTHIS(SfxInt16Item
, 0);
62 DBG_ASSERT(SfxPoolItem::operator ==(rItem
), "unequal type");
63 return m_nValue
== (static_cast< const SfxInt16Item
* >(&rItem
))->
68 int SfxInt16Item::Compare(const SfxPoolItem
& rWith
) const
70 DBG_CHKTHIS(SfxInt16Item
, 0);
71 DBG_ASSERT(SfxPoolItem::operator ==(rWith
), "unequal type");
72 return (static_cast< const SfxInt16Item
* >(&rWith
))->m_nValue
75 (static_cast< const SfxInt16Item
* >(&rWith
))->m_nValue
81 SfxItemPresentation
SfxInt16Item::GetPresentation(SfxItemPresentation
,
82 SfxMapUnit
, SfxMapUnit
,
84 const IntlWrapper
*) const
86 DBG_CHKTHIS(SfxInt16Item
, 0);
87 rText
= OUString::number(m_nValue
);
88 return SFX_ITEM_PRESENTATION_NAMELESS
;
93 bool SfxInt16Item::QueryValue(com::sun::star::uno::Any
& rVal
, sal_uInt8
) const
95 sal_Int16 nValue
= m_nValue
;
101 bool SfxInt16Item::PutValue(const com::sun::star::uno::Any
& rVal
, sal_uInt8
)
103 sal_Int16 nValue
= sal_Int16();
110 OSL_FAIL( "SfxInt16Item::PutValue - Wrong type!" );
115 SfxPoolItem
* SfxInt16Item::Create(SvStream
& rStream
, sal_uInt16
) const
117 DBG_CHKTHIS(SfxInt16Item
, 0);
118 return new SfxInt16Item(Which(), rStream
);
122 SvStream
& SfxInt16Item::Store(SvStream
& rStream
, sal_uInt16
) const
124 DBG_CHKTHIS(SfxInt16Item
, 0);
125 rStream
<< short(m_nValue
);
129 SfxPoolItem
* SfxInt16Item::Clone(SfxItemPool
*) const
131 DBG_CHKTHIS(SfxInt16Item
, 0);
132 return new SfxInt16Item(*this);
135 sal_Int16
SfxInt16Item::GetMin() const
137 DBG_CHKTHIS(SfxInt16Item
, 0);
141 sal_Int16
SfxInt16Item::GetMax() const
143 DBG_CHKTHIS(SfxInt16Item
, 0);
147 SfxFieldUnit
SfxInt16Item::GetUnit() const
149 DBG_CHKTHIS(SfxInt16Item
, 0);
150 return SFX_FUNIT_NONE
;
154 // class SfxUInt16Item
157 TYPEINIT1_AUTOFACTORY(SfxUInt16Item
, CntUInt16Item
);
161 // class SfxInt32Item
164 TYPEINIT1_AUTOFACTORY(SfxInt32Item
, CntInt32Item
);
168 // class SfxUInt32Item
171 TYPEINIT1_AUTOFACTORY(SfxUInt32Item
, CntUInt32Item
);
175 // class SfxMetricItem
178 DBG_NAME(SfxMetricItem
);
180 TYPEINIT1_AUTOFACTORY(SfxMetricItem
, SfxInt32Item
);
182 SfxMetricItem::SfxMetricItem(sal_uInt16 which
, sal_uInt32 nValue
):
183 SfxInt32Item(which
, nValue
)
185 DBG_CTOR(SfxMetricItem
, 0);
188 SfxMetricItem::SfxMetricItem(sal_uInt16 which
, SvStream
& rStream
):
189 SfxInt32Item(which
, rStream
)
191 DBG_CTOR(SfxMetricItem
, 0);
194 SfxMetricItem::SfxMetricItem(const SfxMetricItem
& rItem
):
197 DBG_CTOR(SfxMetricItem
, 0);
201 bool SfxMetricItem::ScaleMetrics(long nMult
, long nDiv
)
203 BigInt
aTheValue(GetValue());
205 aTheValue
+= nDiv
/ 2;
212 bool SfxMetricItem::HasMetrics() const
217 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */