bump product version to 4.1.6.2
[LibreOffice.git] / svx / source / items / numinf.cxx
blob34ab3ea9b249c260a8ed6f842d28f73381b1df2f
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>
22 // -----------------------------------------------------------------------
24 TYPEINIT1(SvxNumberInfoItem, SfxPoolItem);
26 // class SvxNumberInfoItem -----------------------------------------------
28 #define INIT(pNum,eVal,nDouble,rStr) \
29 SfxPoolItem ( nId ), \
31 pFormatter ( pNum ), \
32 eValueType ( eVal ), \
33 aStringVal ( rStr ), \
34 nDoubleVal ( nDouble ), \
35 pDelFormatArr ( NULL ), \
36 nDelCount ( 0 )
38 SvxNumberInfoItem::SvxNumberInfoItem( const sal_uInt16 nId ) :
40 INIT( NULL, SVX_VALUE_TYPE_UNDEFINED, 0, String() )
45 // -----------------------------------------------------------------------
47 SvxNumberInfoItem::SvxNumberInfoItem( SvNumberFormatter* pNumFormatter,
48 const sal_uInt16 nId ) :
50 INIT( pNumFormatter, SVX_VALUE_TYPE_UNDEFINED, 0, String() )
55 // -----------------------------------------------------------------------
57 SvxNumberInfoItem::SvxNumberInfoItem( SvNumberFormatter* pNumFormatter,
58 const String& rVal, const sal_uInt16 nId ) :
60 INIT( pNumFormatter, SVX_VALUE_TYPE_STRING, 0, rVal )
65 // -----------------------------------------------------------------------
67 SvxNumberInfoItem::SvxNumberInfoItem( SvNumberFormatter* pNumFormatter,
68 const double& rVal, const sal_uInt16 nId ) :
70 INIT( pNumFormatter, SVX_VALUE_TYPE_NUMBER, rVal, String() )
75 // -----------------------------------------------------------------------
77 SvxNumberInfoItem::SvxNumberInfoItem( SvNumberFormatter* pNumFormatter,
78 const double& rVal, const String& rValueStr,
79 const sal_uInt16 nId ) :
81 INIT( pNumFormatter, SVX_VALUE_TYPE_NUMBER, rVal, rValueStr )
86 #undef INIT
88 // -----------------------------------------------------------------------
90 SvxNumberInfoItem::SvxNumberInfoItem( const SvxNumberInfoItem& rItem ) :
92 SfxPoolItem( rItem.Which() ),
94 pFormatter ( rItem.pFormatter ),
95 eValueType ( rItem.eValueType ),
96 aStringVal ( rItem.aStringVal ),
97 nDoubleVal ( rItem.nDoubleVal ),
98 pDelFormatArr( NULL ),
99 nDelCount ( rItem.nDelCount )
102 if ( rItem.nDelCount > 0 )
104 pDelFormatArr = new sal_uInt32[ rItem.nDelCount ];
106 for ( sal_uInt16 i = 0; i < rItem.nDelCount; ++i )
107 pDelFormatArr[i] = rItem.pDelFormatArr[i];
111 // -----------------------------------------------------------------------
113 SvxNumberInfoItem::~SvxNumberInfoItem()
115 delete [] pDelFormatArr;
118 //------------------------------------------------------------------------
120 SfxItemPresentation SvxNumberInfoItem::GetPresentation
122 SfxItemPresentation /*ePres*/,
123 SfxMapUnit /*eCoreUnit*/,
124 SfxMapUnit /*ePresUnit*/,
125 OUString& rText, const IntlWrapper *
126 ) const
128 rText = OUString();
129 return SFX_ITEM_PRESENTATION_NONE;
132 // -----------------------------------------------------------------------
134 int SvxNumberInfoItem::operator==( const SfxPoolItem& rItem ) const
136 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal which or type" );
138 SvxNumberInfoItem& rOther = (SvxNumberInfoItem&)rItem;
140 sal_Bool bEqual = sal_False;
142 if ( nDelCount == rOther.nDelCount )
144 if ( nDelCount > 0 )
146 if ( pDelFormatArr != NULL && rOther.pDelFormatArr != NULL )
148 bEqual = sal_True;
150 for ( sal_uInt16 i = 0; i < nDelCount && bEqual; ++i )
151 bEqual = ( pDelFormatArr[i] == rOther.pDelFormatArr[i] );
154 else if ( nDelCount == 0 )
155 bEqual = ( pDelFormatArr == NULL && rOther.pDelFormatArr == NULL );
157 bEqual = bEqual &&
158 pFormatter == rOther.pFormatter &&
159 eValueType == rOther.eValueType &&
160 nDoubleVal == rOther.nDoubleVal &&
161 aStringVal == rOther.aStringVal;
163 return bEqual;
166 // -----------------------------------------------------------------------
168 SfxPoolItem* SvxNumberInfoItem::Clone( SfxItemPool * ) const
170 return new SvxNumberInfoItem( *this );
173 // Laden/Speichern wird nicht gebraucht!
174 // -----------------------------------------------------------------------
176 SfxPoolItem* SvxNumberInfoItem::Create( SvStream& /*rStream*/, sal_uInt16 ) const
178 return new SvxNumberInfoItem( *this );
181 // -----------------------------------------------------------------------
183 SvStream& SvxNumberInfoItem::Store( SvStream &rStream, sal_uInt16 /*nItemVersion*/ ) const
185 return rStream;
188 // -----------------------------------------------------------------------
190 void SvxNumberInfoItem::SetDelFormatArray( const sal_uInt32* pData,
191 const sal_uInt32 nCount )
193 if ( pDelFormatArr )
195 delete []pDelFormatArr;
196 pDelFormatArr = NULL;
199 nDelCount = nCount;
201 if ( nCount > 0 )
203 pDelFormatArr = new sal_uInt32[ nCount ];
205 if ( pData != NULL )
207 for ( sal_uInt16 i = 0; i < nCount; ++i )
208 pDelFormatArr[i] = pData[i];
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */