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 SfxPoolItem
* SfxByteItem::CreateDefault()
35 return new SfxByteItem();
39 SfxPoolItem
* SfxByteItem::Create(SvStream
& rStream
, sal_uInt16
) const
42 rStream
.ReadInt16( nValue
);
43 return new SfxByteItem(Which(), sal_uInt8(nValue
));
46 SfxPoolItem
* SfxInt16Item::CreateDefault()
48 return new SfxInt16Item();
51 SfxInt16Item::SfxInt16Item(sal_uInt16 which
, SvStream
& rStream
):
55 rStream
.ReadInt16( nTheValue
);
60 bool SfxInt16Item::operator ==(const SfxPoolItem
& rItem
) const
62 assert(SfxPoolItem::operator==(rItem
));
63 return m_nValue
== static_cast< const SfxInt16Item
* >(&rItem
)->
68 bool SfxInt16Item::GetPresentation(SfxItemPresentation
,
71 const IntlWrapper
&) const
73 rText
= OUString::number(m_nValue
);
78 boost::property_tree::ptree
SfxInt16Item::dumpAsJSON() const
80 boost::property_tree::ptree aTree
= SfxPoolItem::dumpAsJSON();
81 aTree
.put("state", GetValue());
87 bool SfxInt16Item::QueryValue(css::uno::Any
& rVal
, sal_uInt8
) const
89 sal_Int16 nValue
= m_nValue
;
95 bool SfxInt16Item::PutValue(const css::uno::Any
& rVal
, sal_uInt8
)
97 sal_Int16 nValue
= sal_Int16();
104 OSL_FAIL( "SfxInt16Item::PutValue - Wrong type!" );
109 SfxPoolItem
* SfxInt16Item::Create(SvStream
& rStream
, sal_uInt16
) const
111 return new SfxInt16Item(Which(), rStream
);
115 SvStream
& SfxInt16Item::Store(SvStream
& rStream
, sal_uInt16
) const
117 rStream
.WriteInt16( short(m_nValue
) );
121 SfxPoolItem
* SfxInt16Item::Clone(SfxItemPool
*) const
123 return new SfxInt16Item(*this);
126 // class SfxUInt16Item
127 SfxPoolItem
* SfxUInt16Item::CreateDefault()
129 return new SfxUInt16Item();
132 void SfxUInt16Item::dumpAsXml(xmlTextWriterPtr pWriter
) const
134 xmlTextWriterStartElement(pWriter
, BAD_CAST("SfxUInt16Item"));
135 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
136 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OString::number(GetValue()).getStr()));
137 xmlTextWriterEndElement(pWriter
);
140 boost::property_tree::ptree
SfxUInt16Item::dumpAsJSON() const
142 boost::property_tree::ptree aTree
= SfxPoolItem::dumpAsJSON();
143 aTree
.put("state", GetValue());
148 // class SfxInt32Item
151 SfxPoolItem
* SfxInt32Item::CreateDefault()
153 return new SfxInt32Item();
156 boost::property_tree::ptree
SfxInt32Item::dumpAsJSON() const
158 boost::property_tree::ptree aTree
= SfxPoolItem::dumpAsJSON();
159 aTree
.put("state", GetValue());
164 // class SfxUInt32Item
167 SfxPoolItem
* SfxUInt32Item::CreateDefault()
169 return new SfxUInt32Item();
172 boost::property_tree::ptree
SfxUInt32Item::dumpAsJSON() const
174 boost::property_tree::ptree aTree
= SfxPoolItem::dumpAsJSON();
175 aTree
.put("state", GetValue());
179 SfxMetricItem::SfxMetricItem(sal_uInt16 which
, sal_uInt32 nValue
):
180 SfxInt32Item(which
, nValue
)
185 void SfxMetricItem::ScaleMetrics(long nMult
, long nDiv
)
187 BigInt
aTheValue(GetValue());
189 aTheValue
+= nDiv
/ 2;
195 bool SfxMetricItem::HasMetrics() const
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */