xref: /aoo4110/main/svl/source/items/custritm.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svl.hxx"
26 #include <com/sun/star/uno/Any.hxx>
27 
28 #include <unotools/intlwrapper.hxx>
29 #include <tools/stream.hxx>
30 #include <svl/custritm.hxx>
31 
32 //============================================================================
33 //
34 //  class CntUnencodedStringItem
35 //
36 //============================================================================
37 
38 DBG_NAME(CntUnencodedStringItem)
39 
40 //============================================================================
41 TYPEINIT1_AUTOFACTORY(CntUnencodedStringItem, SfxPoolItem)
42 
43 //============================================================================
44 // virtual
45 int CntUnencodedStringItem::operator ==(const SfxPoolItem & rItem) const
46 {
47 	DBG_CHKTHIS(CntUnencodedStringItem, 0);
48 	DBG_ASSERT(rItem.ISA(CntUnencodedStringItem),
49 			   "CntUnencodedStringItem::operator ==(): Bad type");
50 	return m_aValue
51 	        == SAL_STATIC_CAST(const CntUnencodedStringItem *, &rItem)->
52 	            m_aValue;
53 }
54 
55 //============================================================================
56 // virtual
Compare(SfxPoolItem const & rWith) const57 int CntUnencodedStringItem::Compare(SfxPoolItem const & rWith) const
58 {
59 	DBG_ERROR("CntUnencodedStringItem::Compare(): No international");
60 	DBG_CHKTHIS(CntUnencodedStringItem, 0);
61 	DBG_ASSERT(rWith.ISA(CntUnencodedStringItem),
62 				"CntUnencodedStringItem::Compare(): Bad type");
63 	switch (m_aValue.CompareTo(static_cast< CntUnencodedStringItem const * >(
64 		                               &rWith)->
65 							       m_aValue))
66 	{
67 		case COMPARE_LESS:
68 			return -1;
69 
70 		case COMPARE_EQUAL:
71 			return 0;
72 
73 		default: // COMPARE_GREATER
74 			return 1;
75 	}
76 }
77 
78 //============================================================================
79 // virtual
Compare(SfxPoolItem const & rWith,IntlWrapper const & rIntlWrapper) const80 int CntUnencodedStringItem::Compare(SfxPoolItem const & rWith,
81                                     IntlWrapper const & rIntlWrapper)
82 	const
83 {
84 	DBG_CHKTHIS(CntUnencodedStringItem, 0);
85 	DBG_ASSERT(rWith.ISA(CntUnencodedStringItem),
86 			   "CntUnencodedStringItem::Compare(): Bad type");
87     return rIntlWrapper.getCollator()->compareString( m_aValue,
88         static_cast< CntUnencodedStringItem const * >(&rWith)->m_aValue );
89 }
90 
91 //============================================================================
92 // virtual
93 SfxItemPresentation
GetPresentation(SfxItemPresentation,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const94 CntUnencodedStringItem::GetPresentation(SfxItemPresentation, SfxMapUnit,
95 										SfxMapUnit, XubString & rText,
96                                         const IntlWrapper *) const
97 {
98 	DBG_CHKTHIS(CntUnencodedStringItem, 0);
99 	rText = m_aValue;
100 	return SFX_ITEM_PRESENTATION_NAMELESS;
101 }
102 
103 //============================================================================
104 // virtual
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8) const105 sal_Bool CntUnencodedStringItem::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8)
106 	const
107 {
108 	rVal <<= rtl::OUString(m_aValue);
109 	return true;
110 }
111 
112 //============================================================================
113 // virtual
PutValue(const com::sun::star::uno::Any & rVal,sal_uInt8)114 sal_Bool CntUnencodedStringItem::PutValue(const com::sun::star::uno::Any& rVal,
115 						   			  sal_uInt8)
116 {
117 	rtl::OUString aTheValue;
118 	if (rVal >>= aTheValue)
119 	{
120 		m_aValue = UniString(aTheValue);
121 		return true;
122 	}
123 	DBG_ERROR("CntUnencodedStringItem::PutValue(): Wrong type");
124 	return false;
125 }
126 
127 //============================================================================
128 // virtual
Clone(SfxItemPool *) const129 SfxPoolItem * CntUnencodedStringItem::Clone(SfxItemPool *) const
130 {
131 	DBG_CHKTHIS(CntUnencodedStringItem, 0);
132 	return new CntUnencodedStringItem(*this);
133 }
134 
135