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 <osl/diagnose.h>
24 #include <tools/bigint.hxx>
25 #include <tools/stream.hxx>
26 #include <svl/metitem.hxx>
27 #include <libxml/xmlwriter.h>
33 TYPEINIT1_AUTOFACTORY(SfxByteItem
, CntByteItem
);
36 SfxPoolItem
* SfxByteItem::Create(SvStream
& rStream
, sal_uInt16
) const
39 rStream
.ReadInt16( nValue
);
40 return new SfxByteItem(Which(), sal_uInt8(nValue
));
43 TYPEINIT1_AUTOFACTORY(SfxInt16Item
, SfxPoolItem
);
45 SfxInt16Item::SfxInt16Item(sal_uInt16 which
, SvStream
& rStream
):
49 rStream
.ReadInt16( nTheValue
);
54 bool SfxInt16Item::operator ==(const SfxPoolItem
& rItem
) const
56 DBG_ASSERT(SfxPoolItem::operator ==(rItem
), "unequal type");
57 return m_nValue
== (static_cast< const SfxInt16Item
* >(&rItem
))->
62 int SfxInt16Item::Compare(const SfxPoolItem
& rWith
) const
64 DBG_ASSERT(SfxPoolItem::operator ==(rWith
), "unequal type");
65 return (static_cast< const SfxInt16Item
* >(&rWith
))->m_nValue
68 (static_cast< const SfxInt16Item
* >(&rWith
))->m_nValue
74 bool SfxInt16Item::GetPresentation(SfxItemPresentation
,
75 SfxMapUnit
, SfxMapUnit
,
77 const IntlWrapper
*) const
79 rText
= OUString::number(m_nValue
);
85 bool SfxInt16Item::QueryValue(com::sun::star::uno::Any
& rVal
, sal_uInt8
) const
87 sal_Int16 nValue
= m_nValue
;
93 bool SfxInt16Item::PutValue(const com::sun::star::uno::Any
& rVal
, sal_uInt8
)
95 sal_Int16 nValue
= sal_Int16();
102 OSL_FAIL( "SfxInt16Item::PutValue - Wrong type!" );
107 SfxPoolItem
* SfxInt16Item::Create(SvStream
& rStream
, sal_uInt16
) const
109 return new SfxInt16Item(Which(), rStream
);
113 SvStream
& SfxInt16Item::Store(SvStream
& rStream
, sal_uInt16
) const
115 rStream
.WriteInt16( short(m_nValue
) );
119 SfxPoolItem
* SfxInt16Item::Clone(SfxItemPool
*) const
121 return new SfxInt16Item(*this);
124 // class SfxUInt16Item
125 TYPEINIT1_AUTOFACTORY(SfxUInt16Item
, CntUInt16Item
);
127 void SfxUInt16Item::dumpAsXml(xmlTextWriterPtr pWriter
) const
129 xmlTextWriterStartElement(pWriter
, BAD_CAST("sfxUInt16Item"));
130 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
131 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OString::number(GetValue()).getStr()));
132 xmlTextWriterEndElement(pWriter
);
136 // class SfxInt32Item
139 TYPEINIT1_AUTOFACTORY(SfxInt32Item
, CntInt32Item
);
143 // class SfxUInt32Item
146 TYPEINIT1_AUTOFACTORY(SfxUInt32Item
, CntUInt32Item
);
148 TYPEINIT1_AUTOFACTORY(SfxMetricItem
, SfxInt32Item
);
150 SfxMetricItem::SfxMetricItem(sal_uInt16 which
, sal_uInt32 nValue
):
151 SfxInt32Item(which
, nValue
)
155 SfxMetricItem::SfxMetricItem(sal_uInt16 which
, SvStream
& rStream
):
156 SfxInt32Item(which
, rStream
)
160 SfxMetricItem::SfxMetricItem(const SfxMetricItem
& rItem
):
166 bool SfxMetricItem::ScaleMetrics(long nMult
, long nDiv
)
168 BigInt
aTheValue(GetValue());
170 aTheValue
+= nDiv
/ 2;
177 bool SfxMetricItem::HasMetrics() const
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */