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/poolitem.hxx>
22 #include <tools/stream.hxx>
23 #include <osl/diagnose.h>
24 #include <libxml/xmlwriter.h>
26 TYPEINIT0(SfxPoolItem
);
27 TYPEINIT1(SfxVoidItem
, SfxPoolItem
);
28 // @@@ TYPEINIT1(SfxInvalidItem, SfxPoolItem);
29 TYPEINIT1(SfxSetItem
, SfxPoolItem
);
30 // @@@ TYPEINIT1(SfxItemChangedHint, SfxHint);
33 #if OSL_DEBUG_LEVEL > 1
34 static sal_uLong nItemCount
= 0;
36 const char* pw1
= "Wow! 10.000 items!";
37 const char* pw2
= "Wow! 100.000 items!";
38 const char* pw3
= "Wow! 1.000.000 items!";
39 const char* pw4
= "Wow! 50.000.000 items!";
40 const char* pw5
= "Wow! 10.000.000 items!";
43 SfxPoolItem::SfxPoolItem(sal_uInt16
const nWhich
)
46 , m_nKind(SFX_ITEMS_NONE
)
48 DBG_ASSERT(nWhich
<= SHRT_MAX
, "invalid WhichId");
49 #if OSL_DEBUG_LEVEL > 1
51 if ( pw1
&& nItemCount
>=10000 )
56 if ( pw2
&& nItemCount
>=100000 )
61 if ( pw3
&& nItemCount
>=1000000 )
66 if ( pw4
&& nItemCount
>=5000000 )
71 if ( pw5
&& nItemCount
>=10000000 )
80 SfxPoolItem::SfxPoolItem( const SfxPoolItem
& rCpy
)
81 : m_nRefCount(0) // don't copy that
82 , m_nWhich(rCpy
.Which()) // call function because of ChkThis() (WTF does that mean?)
83 , m_nKind( SFX_ITEMS_NONE
)
85 #if OSL_DEBUG_LEVEL > 1
87 if ( pw1
&& nItemCount
>=10000 )
92 if ( pw2
&& nItemCount
>=100000 )
97 if ( pw3
&& nItemCount
>=1000000 )
102 if ( pw4
&& nItemCount
>=5000000 )
107 if ( pw5
&& nItemCount
>=10000000 )
116 SfxPoolItem::~SfxPoolItem()
118 DBG_ASSERT(m_nRefCount
== 0 || m_nRefCount
> SFX_ITEMS_MAXREF
,
119 "destroying item in use");
120 #if OSL_DEBUG_LEVEL > 1
126 int SfxPoolItem::Compare( const SfxPoolItem
& ) const
132 int SfxPoolItem::Compare( const SfxPoolItem
& rWith
, const IntlWrapper
& ) const
134 return Compare( rWith
);
138 bool SfxPoolItem::operator==( const SfxPoolItem
& rCmp
) const
140 return rCmp
.Type() == Type();
144 SfxPoolItem
* SfxPoolItem::Create(SvStream
&, sal_uInt16
) const
150 sal_uInt16
SfxPoolItem::GetVersion( sal_uInt16
) const
156 SvStream
& SfxPoolItem::Store(SvStream
&rStream
, sal_uInt16
) const
162 * This virtual method allows to get a textual representation of the value
163 * for the SfxPoolItem subclasses. It should be overridden by all UI-relevant
164 * SfxPoolItem subclasses.
166 * Because the unit of measure of the value in the SfxItemPool is only
167 * queryable via @see SfxItemPool::GetMetric(sal_uInt16) const (and not
168 * via the SfxPoolItem instance or subclass, the own unit of measure is
169 * passed to 'eCoreMetric'.
171 * The corresponding unit of measure is passed as 'ePresentationMetric'.
174 * @return SfxItemPresentation SFX_ITEM_PRESENTATION_NAMELESS
175 * A textual representation (if applicable
176 * with a unit of measure) could be created,
177 * but it doesn't contain any semantic meaning
179 * SFX_ITEM_PRESENTATION_COMPLETE
180 * A complete textual representation could be
181 * created with semantic meaning (if applicable
182 * with unit of measure)
186 * pSvxFontItem->GetPresentation( SFX_PRESENTATION_NAMELESS, ... )
187 * "12pt" with return SFX_ITEM_PRESENTATION_NAMELESS
189 * pSvxColorItem->GetPresentation( SFX_PRESENTATION_COMPLETE, ... )
190 * "red" with return SFX_ITEM_PRESENTATION_NAMELESS
191 * Because the SvxColorItem does not know which color it represents
192 * it cannot provide a name, which is communicated by the return value
194 * pSvxBorderItem->GetPresentation( SFX_PRESENTATION_COMPLETE, ... )
195 * "1cm top border, 2cm left border, 0.2cm bottom border, ..."
197 bool SfxPoolItem::GetPresentation
199 SfxItemPresentation
/*ePresentation*/, // IN: how we should format
200 SfxMapUnit
/*eCoreMetric*/, // IN: current metric of the SfxPoolItems
201 SfxMapUnit
/*ePresentationMetric*/, // IN: target metric of the presentation
202 OUString
& /*rText*/, // OUT: textual representation
209 void SfxPoolItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
211 xmlTextWriterStartElement(pWriter
, BAD_CAST("sfxPoolItem"));
212 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
213 xmlTextWriterEndElement(pWriter
);
216 SfxVoidItem::SfxVoidItem( sal_uInt16 which
):
221 SfxVoidItem::SfxVoidItem( const SfxVoidItem
& rCopy
):
227 bool SfxVoidItem::operator==( const SfxPoolItem
&
233 DBG_ASSERT( SfxPoolItem::operator==( rCmp
), "unequal type" );
238 bool SfxVoidItem::GetPresentation
240 SfxItemPresentation
/*ePresentation*/,
241 SfxMapUnit
/*eCoreMetric*/,
242 SfxMapUnit
/*ePresentationMetric*/,
252 SfxPoolItem
* SfxVoidItem::Clone(SfxItemPool
*) const
254 return new SfxVoidItem(*this);
257 bool SfxPoolItem::ScaleMetrics( long /*lMult*/, long /*lDiv*/ )
263 bool SfxPoolItem::HasMetrics() const
270 bool SfxPoolItem::QueryValue( com::sun::star::uno::Any
&, sal_uInt8
) const
272 OSL_FAIL("There is no implementation for QueryValue for this item!");
278 bool SfxPoolItem::PutValue( const com::sun::star::uno::Any
&, sal_uInt8
)
280 OSL_FAIL("There is no implementation for PutValue for this item!");
284 SfxVoidItem::~SfxVoidItem()
288 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */