Line data Source code
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 : #include <com/sun/star/uno/Any.hxx>
21 : #include <tools/stream.hxx>
22 : #include <svl/cintitem.hxx>
23 :
24 : //============================================================================
25 : //
26 : // class CntByteItem
27 : //
28 : //============================================================================
29 :
30 : DBG_NAME(CntByteItem)
31 :
32 : //============================================================================
33 1114 : TYPEINIT1_AUTOFACTORY(CntByteItem, SfxPoolItem);
34 :
35 : //============================================================================
36 : // virtual
37 564 : int CntByteItem::operator ==(const SfxPoolItem & rItem) const
38 : {
39 : DBG_CHKTHIS(CntByteItem, 0);
40 : DBG_ASSERT(rItem.ISA(CntByteItem),
41 : "CntByteItem::operator ==(): Bad type");
42 564 : return m_nValue == (static_cast< const CntByteItem * >(&rItem))->m_nValue;
43 : }
44 :
45 : //============================================================================
46 : // virtual
47 0 : int CntByteItem::Compare(const SfxPoolItem & rWith) const
48 : {
49 : DBG_CHKTHIS(CntByteItem, 0);
50 : DBG_ASSERT(rWith.ISA(CntByteItem), "CntByteItem::Compare(): Bad type");
51 : return (static_cast< const CntByteItem * >(&rWith))->m_nValue < m_nValue ?
52 : -1 :
53 : (static_cast< const CntByteItem * >(&rWith))->m_nValue
54 : == m_nValue ?
55 0 : 0 : 1;
56 : }
57 :
58 : //============================================================================
59 : // virtual
60 0 : SfxItemPresentation CntByteItem::GetPresentation(SfxItemPresentation,
61 : SfxMapUnit, SfxMapUnit,
62 : XubString & rText,
63 : const IntlWrapper *) const
64 : {
65 : DBG_CHKTHIS(CntByteItem, 0);
66 0 : rText = XubString::CreateFromInt32(m_nValue);
67 0 : return SFX_ITEM_PRESENTATION_NAMELESS;
68 : }
69 :
70 : //============================================================================
71 : // virtual
72 2 : bool CntByteItem::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8) const
73 : {
74 2 : sal_Int8 nValue = m_nValue;
75 2 : rVal <<= nValue;
76 2 : return true;
77 : }
78 :
79 : //============================================================================
80 : // virtual
81 448 : bool CntByteItem::PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8)
82 : {
83 448 : sal_Int8 nValue = sal_Int8();
84 448 : if (rVal >>= nValue)
85 : {
86 448 : m_nValue = nValue;
87 448 : return true;
88 : }
89 :
90 : OSL_FAIL( "CntByteItem::PutValue - Wrong type!" );
91 0 : return false;
92 : }
93 :
94 : //============================================================================
95 : // virtual
96 0 : SfxPoolItem * CntByteItem::Create(SvStream & rStream, sal_uInt16) const
97 : {
98 : DBG_CHKTHIS(CntByteItem, 0);
99 0 : short nTheValue = 0;
100 0 : rStream >> nTheValue;
101 0 : return new CntByteItem(Which(), sal_uInt8(nTheValue));
102 : }
103 :
104 : //============================================================================
105 : // virtual
106 0 : SvStream & CntByteItem::Store(SvStream & rStream, sal_uInt16) const
107 : {
108 : DBG_CHKTHIS(CntByteItem, 0);
109 0 : rStream << short(m_nValue);
110 0 : return rStream;
111 : }
112 :
113 : //============================================================================
114 : // virtual
115 0 : SfxPoolItem * CntByteItem::Clone(SfxItemPool *) const
116 : {
117 : DBG_CHKTHIS(CntByteItem, 0);
118 0 : return new CntByteItem(*this);
119 : }
120 :
121 : //============================================================================
122 : // virtual
123 0 : sal_uInt8 CntByteItem::GetMin() const
124 : {
125 : DBG_CHKTHIS(CntByteItem, 0);
126 0 : return 0;
127 : }
128 :
129 : //============================================================================
130 : // virtual
131 0 : sal_uInt8 CntByteItem::GetMax() const
132 : {
133 : DBG_CHKTHIS(CntByteItem, 0);
134 0 : return 255;
135 : }
136 :
137 : //============================================================================
138 : // virtual
139 0 : SfxFieldUnit CntByteItem::GetUnit() const
140 : {
141 : DBG_CHKTHIS(CntByteItem, 0);
142 0 : return SFX_FUNIT_NONE;
143 : }
144 :
145 : //============================================================================
146 : //
147 : // class CntUInt16Item
148 : //
149 : //============================================================================
150 :
151 : DBG_NAME(CntUInt16Item);
152 :
153 : //============================================================================
154 46366 : TYPEINIT1_AUTOFACTORY(CntUInt16Item, SfxPoolItem);
155 :
156 : //============================================================================
157 0 : CntUInt16Item::CntUInt16Item(sal_uInt16 which, SvStream & rStream) :
158 0 : SfxPoolItem(which)
159 : {
160 : DBG_CTOR(CntUInt16Item, 0);
161 0 : sal_uInt16 nTheValue = 0;
162 0 : rStream >> nTheValue;
163 0 : m_nValue = nTheValue;
164 0 : }
165 :
166 : //============================================================================
167 : // virtual
168 14616 : int CntUInt16Item::operator ==(const SfxPoolItem & rItem) const
169 : {
170 : DBG_CHKTHIS(CntUInt16Item, 0);
171 : DBG_ASSERT(rItem.ISA(CntUInt16Item),
172 : "CntUInt16Item::operator ==(): Bad type");
173 : return m_nValue == (static_cast< const CntUInt16Item * >(&rItem))->
174 14616 : m_nValue;
175 : }
176 :
177 : //============================================================================
178 : // virtual
179 0 : int CntUInt16Item::Compare(const SfxPoolItem & rWith) const
180 : {
181 : DBG_CHKTHIS(CntUInt16Item, 0);
182 : DBG_ASSERT(rWith.ISA(CntUInt16Item),
183 : "CntUInt16Item::Compare(): Bad type");
184 : return (static_cast< const CntUInt16Item * >(&rWith))->m_nValue
185 : < m_nValue ?
186 : -1 :
187 : (static_cast< const CntUInt16Item * >(&rWith))->m_nValue
188 : == m_nValue ?
189 0 : 0 : 1;
190 : }
191 :
192 : //============================================================================
193 : // virtual
194 0 : SfxItemPresentation CntUInt16Item::GetPresentation(SfxItemPresentation,
195 : SfxMapUnit, SfxMapUnit,
196 : XubString & rText,
197 : const IntlWrapper *)
198 : const
199 : {
200 : DBG_CHKTHIS(CntUInt16Item, 0);
201 0 : rText = XubString::CreateFromInt32(m_nValue);
202 0 : return SFX_ITEM_PRESENTATION_NAMELESS;
203 : }
204 :
205 : //============================================================================
206 : // virtual
207 609 : bool CntUInt16Item::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8) const
208 : {
209 609 : sal_Int32 nValue = m_nValue;
210 609 : rVal <<= nValue;
211 609 : return true;
212 : }
213 :
214 : //============================================================================
215 : // virtual
216 4824 : bool CntUInt16Item::PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8)
217 : {
218 4824 : sal_Int32 nValue = 0;
219 4824 : if (rVal >>= nValue)
220 : {
221 : DBG_ASSERT( nValue <= USHRT_MAX, "Overflow in UInt16 value!");
222 4824 : m_nValue = (sal_uInt16)nValue;
223 4824 : return true;
224 : }
225 :
226 : OSL_FAIL( "CntUInt16Item::PutValue - Wrong type!" );
227 0 : return false;
228 : }
229 :
230 : //============================================================================
231 : // virtual
232 0 : SfxPoolItem * CntUInt16Item::Create(SvStream & rStream, sal_uInt16) const
233 : {
234 : DBG_CHKTHIS(CntUInt16Item, 0);
235 0 : return new CntUInt16Item(Which(), rStream);
236 : }
237 :
238 : //============================================================================
239 : // virtual
240 0 : SvStream & CntUInt16Item::Store(SvStream &rStream, sal_uInt16) const
241 : {
242 : DBG_CHKTHIS(CntUInt16Item, 0);
243 0 : rStream << sal_uInt16(m_nValue);
244 0 : return rStream;
245 : }
246 :
247 : //============================================================================
248 : // virtual
249 0 : SfxPoolItem * CntUInt16Item::Clone(SfxItemPool *) const
250 : {
251 : DBG_CHKTHIS(CntUInt16Item, 0);
252 0 : return new CntUInt16Item(*this);
253 : }
254 :
255 : //============================================================================
256 : // virtual
257 0 : sal_uInt16 CntUInt16Item::GetMin() const
258 : {
259 : DBG_CHKTHIS(CntUInt16Item, 0);
260 0 : return 0;
261 : }
262 :
263 : //============================================================================
264 : // virtual
265 0 : sal_uInt16 CntUInt16Item::GetMax() const
266 : {
267 : DBG_CHKTHIS(CntUInt16Item, 0);
268 0 : return 65535;
269 : }
270 :
271 : //============================================================================
272 : // virtual
273 0 : SfxFieldUnit CntUInt16Item::GetUnit() const
274 : {
275 : DBG_CHKTHIS(CntUInt16Item, 0);
276 0 : return SFX_FUNIT_NONE;
277 : }
278 :
279 : //============================================================================
280 : //
281 : // class CntInt32Item
282 : //
283 : //============================================================================
284 :
285 : DBG_NAME(CntInt32Item);
286 :
287 : //============================================================================
288 29042 : TYPEINIT1_AUTOFACTORY(CntInt32Item, SfxPoolItem);
289 :
290 : //============================================================================
291 0 : CntInt32Item::CntInt32Item(sal_uInt16 which, SvStream & rStream) :
292 0 : SfxPoolItem(which)
293 : {
294 : DBG_CTOR(CntInt32Item, 0);
295 : //fdo#39428 SvStream no longer supports operator>>(long&)
296 0 : rStream >> m_nValue;
297 0 : }
298 :
299 : //============================================================================
300 : // virtual
301 69005 : int CntInt32Item::operator ==(const SfxPoolItem & rItem) const
302 : {
303 : DBG_CHKTHIS(CntInt32Item, 0);
304 : DBG_ASSERT(rItem.ISA(CntInt32Item),
305 : "CntInt32Item::operator ==(): Bad type");
306 : return m_nValue == (static_cast< const CntInt32Item * >(&rItem))->
307 69005 : m_nValue;
308 : }
309 :
310 : //============================================================================
311 : // virtual
312 0 : int CntInt32Item::Compare(const SfxPoolItem & rWith) const
313 : {
314 : DBG_CHKTHIS(CntInt32Item, 0);
315 : DBG_ASSERT(rWith.ISA(CntInt32Item), "CntInt32Item::Compare(): Bad type");
316 : return (static_cast< const CntInt32Item * >(&rWith))->m_nValue
317 : < m_nValue ?
318 : -1 :
319 : (static_cast< const CntInt32Item * >(&rWith))->m_nValue
320 : == m_nValue ?
321 0 : 0 : 1;
322 : }
323 :
324 : //============================================================================
325 : // virtual
326 0 : SfxItemPresentation CntInt32Item::GetPresentation(SfxItemPresentation,
327 : SfxMapUnit, SfxMapUnit,
328 : XubString & rText,
329 : const IntlWrapper *) const
330 : {
331 : DBG_CHKTHIS(CntInt32Item, 0);
332 0 : rText = XubString::CreateFromInt32(m_nValue);
333 0 : return SFX_ITEM_PRESENTATION_NAMELESS;
334 : }
335 :
336 : //============================================================================
337 : // virtual
338 810 : bool CntInt32Item::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8) const
339 : {
340 810 : sal_Int32 nValue = m_nValue;
341 810 : rVal <<= nValue;
342 810 : return true;
343 : }
344 :
345 : //============================================================================
346 : // virtual
347 4475 : bool CntInt32Item::PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8)
348 : {
349 4475 : sal_Int32 nValue = 0;
350 4475 : if (rVal >>= nValue)
351 : {
352 4475 : m_nValue = nValue;
353 4475 : return true;
354 : }
355 :
356 : OSL_FAIL( "CntInt32Item::PutValue - Wrong type!" );
357 0 : return false;
358 : }
359 :
360 : //============================================================================
361 : // virtual
362 0 : SfxPoolItem * CntInt32Item::Create(SvStream & rStream, sal_uInt16) const
363 : {
364 : DBG_CHKTHIS(CntInt32Item, 0);
365 0 : return new CntInt32Item(Which(), rStream);
366 : }
367 :
368 : //============================================================================
369 : // virtual
370 0 : SvStream & CntInt32Item::Store(SvStream &rStream, sal_uInt16) const
371 : {
372 : DBG_CHKTHIS(CntInt32Item, 0);
373 : //fdo#39428 SvStream no longer supports operator<<(long)
374 0 : rStream << m_nValue;
375 0 : return rStream;
376 : }
377 :
378 : //============================================================================
379 : // virtual
380 0 : SfxPoolItem * CntInt32Item::Clone(SfxItemPool *) const
381 : {
382 : DBG_CHKTHIS(CntInt32Item, 0);
383 0 : return new CntInt32Item(*this);
384 : }
385 :
386 : //============================================================================
387 : // virtual
388 0 : sal_Int32 CntInt32Item::GetMin() const
389 : {
390 : DBG_CHKTHIS(CntInt32Item, 0);
391 0 : return sal_Int32(0x80000000);
392 : }
393 :
394 : //============================================================================
395 : // virtual
396 0 : sal_Int32 CntInt32Item::GetMax() const
397 : {
398 : DBG_CHKTHIS(CntInt32Item, 0);
399 0 : return 0x7FFFFFFF;
400 : }
401 :
402 : //============================================================================
403 : // virtual
404 0 : SfxFieldUnit CntInt32Item::GetUnit() const
405 : {
406 : DBG_CHKTHIS(CntInt32Item, 0);
407 0 : return SFX_FUNIT_NONE;
408 : }
409 :
410 : //============================================================================
411 : //
412 : // class CntUInt32Item
413 : //
414 : //============================================================================
415 :
416 : DBG_NAME(CntUInt32Item);
417 :
418 : //============================================================================
419 4016 : TYPEINIT1_AUTOFACTORY(CntUInt32Item, SfxPoolItem);
420 :
421 : //============================================================================
422 0 : CntUInt32Item::CntUInt32Item(sal_uInt16 which, SvStream & rStream) :
423 0 : SfxPoolItem(which)
424 : {
425 : DBG_CTOR(CntUInt32Item, 0);
426 0 : sal_uInt32 nTheValue = 0;
427 0 : rStream >> nTheValue;
428 0 : m_nValue = nTheValue;
429 0 : }
430 :
431 : //============================================================================
432 : // virtual
433 6244 : int CntUInt32Item::operator ==(const SfxPoolItem & rItem) const
434 : {
435 : DBG_CHKTHIS(CntUInt32Item, 0);
436 : DBG_ASSERT(rItem.ISA(CntUInt32Item),
437 : "CntUInt32Item::operator ==(): Bad type");
438 : return m_nValue == (static_cast< const CntUInt32Item * >(&rItem))->
439 6244 : m_nValue;
440 : }
441 :
442 : //============================================================================
443 : // virtual
444 0 : int CntUInt32Item::Compare(const SfxPoolItem & rWith) const
445 : {
446 : DBG_CHKTHIS(CntUInt32Item, 0);
447 : DBG_ASSERT(rWith.ISA(CntUInt32Item),
448 : "CntUInt32Item::operator ==(): Bad type");
449 : return (static_cast< const CntUInt32Item * >(&rWith))->m_nValue
450 : < m_nValue ?
451 : -1 :
452 : (static_cast< const CntUInt32Item * >(&rWith))->m_nValue
453 : == m_nValue ?
454 0 : 0 : 1;
455 : }
456 :
457 : //============================================================================
458 : // virtual
459 0 : SfxItemPresentation CntUInt32Item::GetPresentation(SfxItemPresentation,
460 : SfxMapUnit, SfxMapUnit,
461 : XubString & rText,
462 : const IntlWrapper *)
463 : const
464 : {
465 : DBG_CHKTHIS(CntUInt32Item, 0);
466 0 : rText = rtl::OUString::valueOf(static_cast<sal_Int64>(m_nValue));
467 0 : return SFX_ITEM_PRESENTATION_NAMELESS;
468 : }
469 :
470 : //============================================================================
471 : // virtual
472 0 : bool CntUInt32Item::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8) const
473 : {
474 0 : sal_Int32 nValue = m_nValue;
475 : DBG_ASSERT( nValue>=0, "Overflow in UInt32 value!");
476 0 : rVal <<= nValue;
477 0 : return true;
478 : }
479 :
480 : //============================================================================
481 : // virtual
482 0 : bool CntUInt32Item::PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8)
483 : {
484 0 : sal_Int32 nValue = 0;
485 0 : if (rVal >>= nValue)
486 : {
487 : DBG_ASSERT( nValue>=0, "Overflow in UInt32 value!");
488 0 : m_nValue = nValue;
489 0 : return true;
490 : }
491 :
492 : OSL_FAIL( "CntUInt32Item::PutValue - Wrong type!" );
493 0 : return false;
494 : }
495 :
496 : //============================================================================
497 : // virtual
498 0 : SfxPoolItem * CntUInt32Item::Create(SvStream & rStream, sal_uInt16) const
499 : {
500 : DBG_CHKTHIS(CntUInt32Item, 0);
501 0 : return new CntUInt32Item(Which(), rStream);
502 : }
503 :
504 : //============================================================================
505 : // virtual
506 0 : SvStream & CntUInt32Item::Store(SvStream &rStream, sal_uInt16) const
507 : {
508 : DBG_CHKTHIS(CntUInt32Item, 0);
509 0 : rStream << static_cast<sal_uInt32>(m_nValue);
510 0 : return rStream;
511 : }
512 :
513 : //============================================================================
514 : // virtual
515 0 : SfxPoolItem * CntUInt32Item::Clone(SfxItemPool *) const
516 : {
517 : DBG_CHKTHIS(CntUInt32Item, 0);
518 0 : return new CntUInt32Item(*this);
519 : }
520 :
521 : //============================================================================
522 : // virtual
523 0 : sal_uInt32 CntUInt32Item::GetMin() const
524 : {
525 : DBG_CHKTHIS(CntUInt32Item, 0);
526 0 : return 0;
527 : }
528 :
529 : //============================================================================
530 : // virtual
531 0 : sal_uInt32 CntUInt32Item::GetMax() const
532 : {
533 : DBG_CHKTHIS(CntUInt32Item, 0);
534 0 : return 0xFFFFFFFF;
535 : }
536 :
537 : //============================================================================
538 : // virtual
539 0 : SfxFieldUnit CntUInt32Item::GetUnit() const
540 : {
541 : DBG_CHKTHIS(CntUInt32Item, 0);
542 0 : return SFX_FUNIT_NONE;
543 : }
544 :
545 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|