bump product version to 6.3.0.0.beta1
[LibreOffice.git] / svl / source / items / intitem.cxx
blob70be1383349e3a6cf63d837735efa941187c2aba
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
30 // class SfxByteItem
33 SfxPoolItem* SfxByteItem::CreateDefault()
35 return new SfxByteItem();
38 SfxPoolItem* SfxInt16Item::CreateDefault()
40 return new SfxInt16Item();
43 // virtual
44 bool SfxInt16Item::operator ==(const SfxPoolItem & rItem) const
46 assert(SfxPoolItem::operator==(rItem));
47 return m_nValue == static_cast< const SfxInt16Item * >(&rItem)->
48 m_nValue;
51 // virtual
52 bool SfxInt16Item::GetPresentation(SfxItemPresentation,
53 MapUnit, MapUnit,
54 OUString & rText,
55 const IntlWrapper&) const
57 rText = OUString::number(m_nValue);
58 return true;
62 // virtual
63 bool SfxInt16Item::QueryValue(css::uno::Any& rVal, sal_uInt8) const
65 sal_Int16 nValue = m_nValue;
66 rVal <<= nValue;
67 return true;
70 // virtual
71 bool SfxInt16Item::PutValue(const css::uno::Any& rVal, sal_uInt8 )
73 sal_Int16 nValue = sal_Int16();
74 if (rVal >>= nValue)
76 m_nValue = nValue;
77 return true;
80 OSL_FAIL( "SfxInt16Item::PutValue - Wrong type!" );
81 return false;
84 SfxPoolItem * SfxInt16Item::Clone(SfxItemPool *) const
86 return new SfxInt16Item(*this);
89 // class SfxUInt16Item
90 SfxPoolItem* SfxUInt16Item::CreateDefault()
92 return new SfxUInt16Item();
95 void SfxUInt16Item::dumpAsXml(xmlTextWriterPtr pWriter) const
97 xmlTextWriterStartElement(pWriter, BAD_CAST("SfxUInt16Item"));
98 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
99 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::number(GetValue()).getStr()));
100 xmlTextWriterEndElement(pWriter);
104 // class SfxInt32Item
107 SfxPoolItem* SfxInt32Item::CreateDefault()
109 return new SfxInt32Item();
112 void SfxInt32Item::dumpAsXml(xmlTextWriterPtr pWriter) const
114 xmlTextWriterStartElement(pWriter, BAD_CAST("SfxInt32Item"));
115 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
116 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::number(GetValue()).getStr()));
117 xmlTextWriterEndElement(pWriter);
121 // class SfxUInt32Item
124 SfxPoolItem* SfxUInt32Item::CreateDefault()
126 return new SfxUInt32Item();
129 void SfxUInt32Item::dumpAsXml(xmlTextWriterPtr pWriter) const
131 xmlTextWriterStartElement(pWriter, BAD_CAST("SfxUInt32Item"));
132 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
133 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::number(GetValue()).getStr()));
134 xmlTextWriterEndElement(pWriter);
138 SfxMetricItem::SfxMetricItem(sal_uInt16 which, sal_uInt32 nValue):
139 SfxInt32Item(which, nValue)
143 // virtual
144 void SfxMetricItem::ScaleMetrics(long nMult, long nDiv)
146 BigInt aTheValue(GetValue());
147 aTheValue *= nMult;
148 aTheValue += nDiv / 2;
149 aTheValue /= nDiv;
150 SetValue(aTheValue);
153 // virtual
154 bool SfxMetricItem::HasMetrics() const
156 return true;
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */