merge the formfield patch from ooo-build
[ooovba.git] / svtools / source / items1 / custritm.cxx
blobfd889b15aa95a43539af75cca6a228260c8f1c1b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: custritm.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
33 #include <com/sun/star/uno/Any.hxx>
35 #include <unotools/intlwrapper.hxx>
36 #include <tools/stream.hxx>
37 #include <svtools/custritm.hxx>
39 //============================================================================
41 // class CntUnencodedStringItem
43 //============================================================================
45 DBG_NAME(CntUnencodedStringItem)
47 //============================================================================
48 TYPEINIT1_AUTOFACTORY(CntUnencodedStringItem, SfxPoolItem)
50 //============================================================================
51 // virtual
52 int CntUnencodedStringItem::operator ==(const SfxPoolItem & rItem) const
54 DBG_CHKTHIS(CntUnencodedStringItem, 0);
55 DBG_ASSERT(rItem.ISA(CntUnencodedStringItem),
56 "CntUnencodedStringItem::operator ==(): Bad type");
57 return m_aValue
58 == SAL_STATIC_CAST(const CntUnencodedStringItem *, &rItem)->
59 m_aValue;
62 //============================================================================
63 // virtual
64 int CntUnencodedStringItem::Compare(SfxPoolItem const & rWith) const
66 DBG_ERROR("CntUnencodedStringItem::Compare(): No international");
67 DBG_CHKTHIS(CntUnencodedStringItem, 0);
68 DBG_ASSERT(rWith.ISA(CntUnencodedStringItem),
69 "CntUnencodedStringItem::Compare(): Bad type");
70 switch (m_aValue.CompareTo(static_cast< CntUnencodedStringItem const * >(
71 &rWith)->
72 m_aValue))
74 case COMPARE_LESS:
75 return -1;
77 case COMPARE_EQUAL:
78 return 0;
80 default: // COMPARE_GREATER
81 return 1;
85 //============================================================================
86 // virtual
87 int CntUnencodedStringItem::Compare(SfxPoolItem const & rWith,
88 IntlWrapper const & rIntlWrapper)
89 const
91 DBG_CHKTHIS(CntUnencodedStringItem, 0);
92 DBG_ASSERT(rWith.ISA(CntUnencodedStringItem),
93 "CntUnencodedStringItem::Compare(): Bad type");
94 return rIntlWrapper.getCollator()->compareString( m_aValue,
95 static_cast< CntUnencodedStringItem const * >(&rWith)->m_aValue );
98 //============================================================================
99 // virtual
100 SfxItemPresentation
101 CntUnencodedStringItem::GetPresentation(SfxItemPresentation, SfxMapUnit,
102 SfxMapUnit, XubString & rText,
103 const IntlWrapper *) const
105 DBG_CHKTHIS(CntUnencodedStringItem, 0);
106 rText = m_aValue;
107 return SFX_ITEM_PRESENTATION_NAMELESS;
110 //============================================================================
111 // virtual
112 BOOL CntUnencodedStringItem::QueryValue(com::sun::star::uno::Any& rVal, BYTE)
113 const
115 rVal <<= rtl::OUString(m_aValue);
116 return true;
119 //============================================================================
120 // virtual
121 BOOL CntUnencodedStringItem::PutValue(const com::sun::star::uno::Any& rVal,
122 BYTE)
124 rtl::OUString aTheValue;
125 if (rVal >>= aTheValue)
127 m_aValue = UniString(aTheValue);
128 return true;
130 DBG_ERROR("CntUnencodedStringItem::PutValue(): Wrong type");
131 return false;
134 //============================================================================
135 // virtual
136 SfxPoolItem * CntUnencodedStringItem::Clone(SfxItemPool *) const
138 DBG_CHKTHIS(CntUnencodedStringItem, 0);
139 return new CntUnencodedStringItem(*this);