LibreOffice Module svl (master) 1
intitem.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
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 <svl/metitem.hxx>
26#include <libxml/xmlwriter.h>
27#include <boost/property_tree/ptree.hpp>
28
29
30
31
33{
34 return new SfxByteItem();
35};
36
38{
39 return new SfxInt16Item();
40};
41
42// virtual
43bool SfxInt16Item::operator ==(const SfxPoolItem & rItem) const
44{
45 assert(SfxPoolItem::operator==(rItem));
46 return m_nValue == static_cast< const SfxInt16Item * >(&rItem)->
48}
49
50// virtual
53 OUString & rText,
54 const IntlWrapper&) const
55{
56 rText = OUString::number(m_nValue);
57 return true;
58}
59
60
61boost::property_tree::ptree SfxInt16Item::dumpAsJSON() const
62{
63 boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON();
64 aTree.put("state", GetValue());
65 return aTree;
66}
67
68
69// virtual
70bool SfxInt16Item::QueryValue(css::uno::Any& rVal, sal_uInt8) const
71{
72 sal_Int16 nValue = m_nValue;
73 rVal <<= nValue;
74 return true;
75}
76
77// virtual
78bool SfxInt16Item::PutValue(const css::uno::Any& rVal, sal_uInt8 )
79{
80 sal_Int16 nValue = sal_Int16();
81 if (rVal >>= nValue)
82 {
84 return true;
85 }
86
87 OSL_FAIL( "SfxInt16Item::PutValue - Wrong type!" );
88 return false;
89}
90
92{
93 return new SfxInt16Item(*this);
94}
95
97{
98 return new SfxUInt16Item();
99};
100
102{
103 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SfxUInt16Item"));
104 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
105 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::number(GetValue()).getStr()));
106 (void)xmlTextWriterEndElement(pWriter);
107}
108
109boost::property_tree::ptree SfxUInt16Item::dumpAsJSON() const
110{
111 boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON();
112 aTree.put("state", GetValue());
113 return aTree;
114}
115
116
117
118
120{
121 return new SfxInt32Item();
122};
123
125{
126 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SfxInt32Item"));
127 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
128 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::number(GetValue()).getStr()));
129 (void)xmlTextWriterEndElement(pWriter);
130}
131
132boost::property_tree::ptree SfxInt32Item::dumpAsJSON() const
133{
134 boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON();
135 aTree.put("state", GetValue());
136 return aTree;
137}
138
139
140
141
143{
144 return new SfxUInt32Item();
145};
146
148{
149 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SfxUInt32Item"));
150 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
151 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::number(GetValue()).getStr()));
152 (void)xmlTextWriterEndElement(pWriter);
153}
154
155boost::property_tree::ptree SfxUInt32Item::dumpAsJSON() const
156{
157 boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON();
158 aTree.put("state", GetValue());
159 return aTree;
160}
161
162SfxMetricItem::SfxMetricItem(sal_uInt16 which, sal_Int32 nValue):
163 SfxInt32Item(which, nValue)
164{
165}
166
167// virtual
169{
170 BigInt aTheValue(GetValue());
171 aTheValue *= nMult;
172 aTheValue += nDiv / 2;
173 aTheValue /= nDiv;
174 SetValue(aTheValue);
175}
176
177// virtual
179{
180 return true;
181}
182
183/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 GetValue() const
Definition: cintitem.hxx:126
void SetValue(sal_Int32 nTheValue)
Definition: cintitem.hxx:131
sal_uInt16 GetValue() const
Definition: cintitem.hxx:89
sal_uInt32 GetValue() const
Definition: cintitem.hxx:163
static SfxPoolItem * CreateDefault()
Definition: intitem.cxx:32
SfxByteItem(sal_uInt16 which=0, sal_uInt8 nValue=0)
Definition: intitem.hxx:33
static SfxPoolItem * CreateDefault()
Definition: intitem.cxx:37
virtual bool GetPresentation(SfxItemPresentation, MapUnit, MapUnit, OUString &rText, const IntlWrapper &) const override
This virtual method allows to get a textual representation of the value for the SfxPoolItem subclasse...
Definition: intitem.cxx:51
virtual boost::property_tree::ptree dumpAsJSON() const override
Definition: intitem.cxx:61
virtual SfxInt16Item * Clone(SfxItemPool *=nullptr) const override
Definition: intitem.cxx:91
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
Definition: intitem.cxx:78
sal_Int16 GetValue() const
Definition: intitem.hxx:69
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
Definition: intitem.cxx:70
SfxInt16Item(sal_uInt16 which=0, sal_Int16 nTheValue=0)
Definition: intitem.hxx:47
virtual bool operator==(const SfxPoolItem &rItem) const override
Definition: intitem.cxx:43
sal_Int16 m_nValue
Definition: intitem.hxx:42
static SfxPoolItem * CreateDefault()
Definition: intitem.cxx:119
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: intitem.cxx:124
SfxInt32Item(sal_uInt16 which=0, sal_Int32 nValue=0)
Definition: intitem.hxx:102
virtual boost::property_tree::ptree dumpAsJSON() const override
Definition: intitem.cxx:132
Base class for providers of defaults of SfxPoolItems.
Definition: itempool.hxx:51
virtual void ScaleMetrics(tools::Long lMult, tools::Long lDiv) override
Definition: intitem.cxx:168
virtual bool HasMetrics() const override
Definition: intitem.cxx:178
SfxMetricItem(sal_uInt16 nWhich, sal_Int32 nValue)
Definition: intitem.cxx:162
sal_uInt16 Which() const
Definition: poolitem.hxx:149
virtual boost::property_tree::ptree dumpAsJSON() const
Definition: poolitem.cxx:551
static SfxPoolItem * CreateDefault()
Definition: intitem.cxx:96
SfxUInt16Item(sal_uInt16 which=0, sal_uInt16 nValue=0)
Definition: intitem.hxx:86
virtual boost::property_tree::ptree dumpAsJSON() const override
Definition: intitem.cxx:109
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: intitem.cxx:101
virtual boost::property_tree::ptree dumpAsJSON() const override
Definition: intitem.cxx:155
static SfxPoolItem * CreateDefault()
Definition: intitem.cxx:142
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: intitem.cxx:147
SfxUInt32Item(sal_uInt16 which=0, sal_uInt32 nValue=0)
Definition: intitem.hxx:118
struct _xmlTextWriter * xmlTextWriterPtr
sal_Int16 nValue
MapUnit
long Long
SfxItemPresentation
Definition: poolitem.hxx:72
unsigned char sal_uInt8