bump product version to 5.0.4.1
[LibreOffice.git] / svx / source / items / numinf.cxx
blob5a855d5a7e4aa78f52be47bb8f3ed2a5d24413ab
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 .
20 #include <svx/numinf.hxx>
24 TYPEINIT1(SvxNumberInfoItem, SfxPoolItem);
26 #define INIT(pNum,eVal,nDouble,rStr) \
27 SfxPoolItem ( nId ), \
29 pFormatter ( pNum ), \
30 eValueType ( eVal ), \
31 aStringVal ( rStr ), \
32 nDoubleVal ( nDouble ), \
33 pDelFormatArr ( NULL ), \
34 nDelCount ( 0 )
36 SvxNumberInfoItem::SvxNumberInfoItem( const sal_uInt16 nId ) :
38 INIT( NULL, SVX_VALUE_TYPE_UNDEFINED, 0, "" )
45 SvxNumberInfoItem::SvxNumberInfoItem( SvNumberFormatter* pNumFormatter,
46 const sal_uInt16 nId ) :
48 INIT( pNumFormatter, SVX_VALUE_TYPE_UNDEFINED, 0, "" )
55 SvxNumberInfoItem::SvxNumberInfoItem( SvNumberFormatter* pNumFormatter,
56 const OUString& rVal, const sal_uInt16 nId ) :
58 INIT( pNumFormatter, SVX_VALUE_TYPE_STRING, 0, rVal )
65 SvxNumberInfoItem::SvxNumberInfoItem( SvNumberFormatter* pNumFormatter,
66 const double& rVal, const sal_uInt16 nId ) :
68 INIT( pNumFormatter, SVX_VALUE_TYPE_NUMBER, rVal, "" )
75 SvxNumberInfoItem::SvxNumberInfoItem( SvNumberFormatter* pNumFormatter,
76 const double& rVal, const OUString& rValueStr,
77 const sal_uInt16 nId ) :
79 INIT( pNumFormatter, SVX_VALUE_TYPE_NUMBER, rVal, rValueStr )
84 #undef INIT
88 SvxNumberInfoItem::SvxNumberInfoItem( const SvxNumberInfoItem& rItem ) :
90 SfxPoolItem( rItem.Which() ),
92 pFormatter ( rItem.pFormatter ),
93 eValueType ( rItem.eValueType ),
94 aStringVal ( rItem.aStringVal ),
95 nDoubleVal ( rItem.nDoubleVal ),
96 pDelFormatArr( NULL ),
97 nDelCount ( rItem.nDelCount )
100 if ( rItem.nDelCount > 0 )
102 pDelFormatArr = new sal_uInt32[ rItem.nDelCount ];
104 for ( sal_uInt16 i = 0; i < rItem.nDelCount; ++i )
105 pDelFormatArr[i] = rItem.pDelFormatArr[i];
111 SvxNumberInfoItem::~SvxNumberInfoItem()
113 delete [] pDelFormatArr;
118 bool SvxNumberInfoItem::GetPresentation
120 SfxItemPresentation /*ePres*/,
121 SfxMapUnit /*eCoreUnit*/,
122 SfxMapUnit /*ePresUnit*/,
123 OUString& rText, const IntlWrapper *
124 ) const
126 rText.clear();
127 return false;
132 bool SvxNumberInfoItem::operator==( const SfxPoolItem& rItem ) const
134 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal which or type" );
136 const SvxNumberInfoItem& rOther = static_cast<const SvxNumberInfoItem&>(rItem);
138 bool bEqual = false;
140 if ( nDelCount == rOther.nDelCount )
142 if ( nDelCount > 0 )
144 if ( pDelFormatArr != NULL && rOther.pDelFormatArr != NULL )
146 bEqual = true;
148 for ( sal_uInt16 i = 0; i < nDelCount && bEqual; ++i )
149 bEqual = ( pDelFormatArr[i] == rOther.pDelFormatArr[i] );
152 else if ( nDelCount == 0 )
153 bEqual = ( pDelFormatArr == NULL && rOther.pDelFormatArr == NULL );
155 bEqual = bEqual &&
156 pFormatter == rOther.pFormatter &&
157 eValueType == rOther.eValueType &&
158 nDoubleVal == rOther.nDoubleVal &&
159 aStringVal == rOther.aStringVal;
161 return bEqual;
166 SfxPoolItem* SvxNumberInfoItem::Clone( SfxItemPool * ) const
168 return new SvxNumberInfoItem( *this );
171 // Load/Save is unused!
174 SfxPoolItem* SvxNumberInfoItem::Create( SvStream& /*rStream*/, sal_uInt16 ) const
176 return new SvxNumberInfoItem( *this );
181 SvStream& SvxNumberInfoItem::Store( SvStream &rStream, sal_uInt16 /*nItemVersion*/ ) const
183 return rStream;
188 void SvxNumberInfoItem::SetDelFormatArray( const sal_uInt32* pData,
189 const sal_uInt32 nCount )
191 if ( pDelFormatArr )
193 delete []pDelFormatArr;
194 pDelFormatArr = NULL;
197 nDelCount = nCount;
199 if ( nCount > 0 )
201 pDelFormatArr = new sal_uInt32[ nCount ];
203 if ( pData != NULL )
205 for ( sal_uInt16 i = 0; i < nCount; ++i )
206 pDelFormatArr[i] = pData[i];
212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */