xref: /trunk/main/svl/source/items/custritm.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svl.hxx"
30 #include <com/sun/star/uno/Any.hxx>
31 
32 #include <unotools/intlwrapper.hxx>
33 #include <tools/stream.hxx>
34 #include <svl/custritm.hxx>
35 
36 //============================================================================
37 //
38 //  class CntUnencodedStringItem
39 //
40 //============================================================================
41 
42 DBG_NAME(CntUnencodedStringItem)
43 
44 //============================================================================
45 TYPEINIT1_AUTOFACTORY(CntUnencodedStringItem, SfxPoolItem)
46 
47 //============================================================================
48 // virtual
49 int CntUnencodedStringItem::operator ==(const SfxPoolItem & rItem) const
50 {
51     DBG_CHKTHIS(CntUnencodedStringItem, 0);
52     DBG_ASSERT(rItem.ISA(CntUnencodedStringItem),
53                "CntUnencodedStringItem::operator ==(): Bad type");
54     return m_aValue
55             == SAL_STATIC_CAST(const CntUnencodedStringItem *, &rItem)->
56                 m_aValue;
57 }
58 
59 //============================================================================
60 // virtual
61 int CntUnencodedStringItem::Compare(SfxPoolItem const & rWith) const
62 {
63     DBG_ERROR("CntUnencodedStringItem::Compare(): No international");
64     DBG_CHKTHIS(CntUnencodedStringItem, 0);
65     DBG_ASSERT(rWith.ISA(CntUnencodedStringItem),
66                 "CntUnencodedStringItem::Compare(): Bad type");
67     switch (m_aValue.CompareTo(static_cast< CntUnencodedStringItem const * >(
68                                        &rWith)->
69                                    m_aValue))
70     {
71         case COMPARE_LESS:
72             return -1;
73 
74         case COMPARE_EQUAL:
75             return 0;
76 
77         default: // COMPARE_GREATER
78             return 1;
79     }
80 }
81 
82 //============================================================================
83 // virtual
84 int CntUnencodedStringItem::Compare(SfxPoolItem const & rWith,
85                                     IntlWrapper const & rIntlWrapper)
86     const
87 {
88     DBG_CHKTHIS(CntUnencodedStringItem, 0);
89     DBG_ASSERT(rWith.ISA(CntUnencodedStringItem),
90                "CntUnencodedStringItem::Compare(): Bad type");
91     return rIntlWrapper.getCollator()->compareString( m_aValue,
92         static_cast< CntUnencodedStringItem const * >(&rWith)->m_aValue );
93 }
94 
95 //============================================================================
96 // virtual
97 SfxItemPresentation
98 CntUnencodedStringItem::GetPresentation(SfxItemPresentation, SfxMapUnit,
99                                         SfxMapUnit, XubString & rText,
100                                         const IntlWrapper *) const
101 {
102     DBG_CHKTHIS(CntUnencodedStringItem, 0);
103     rText = m_aValue;
104     return SFX_ITEM_PRESENTATION_NAMELESS;
105 }
106 
107 //============================================================================
108 // virtual
109 sal_Bool CntUnencodedStringItem::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8)
110     const
111 {
112     rVal <<= rtl::OUString(m_aValue);
113     return true;
114 }
115 
116 //============================================================================
117 // virtual
118 sal_Bool CntUnencodedStringItem::PutValue(const com::sun::star::uno::Any& rVal,
119                                       sal_uInt8)
120 {
121     rtl::OUString aTheValue;
122     if (rVal >>= aTheValue)
123     {
124         m_aValue = UniString(aTheValue);
125         return true;
126     }
127     DBG_ERROR("CntUnencodedStringItem::PutValue(): Wrong type");
128     return false;
129 }
130 
131 //============================================================================
132 // virtual
133 SfxPoolItem * CntUnencodedStringItem::Clone(SfxItemPool *) const
134 {
135     DBG_CHKTHIS(CntUnencodedStringItem, 0);
136     return new CntUnencodedStringItem(*this);
137 }
138 
139