merge the formfield patch from ooo-build
[ooovba.git] / svtools / source / items1 / cstitem.cxx
blob97d4492fbfb213a095b1b49fa3c67f2093b32bd0
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: cstitem.cxx,v $
10 * $Revision: 1.9 $
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>
37 #include <tools/stream.hxx>
38 #include <tools/debug.hxx>
39 #include <tools/datetime.hxx>
41 #include <svtools/svtdata.hxx>
42 #include <svtools/cstitem.hxx>
44 #include <svtools/svtools.hrc>
45 #include <com/sun/star/lang/Locale.hpp>
47 DBG_NAME( SfxCrawlStatusItem )
48 TYPEINIT1( SfxCrawlStatusItem, SfxPoolItem );
50 // -----------------------------------------------------------------------
52 SfxCrawlStatusItem::SfxCrawlStatusItem( USHORT which ) :
53 SfxPoolItem( which )
55 DBG_CTOR( SfxCrawlStatusItem, 0 );
58 // -----------------------------------------------------------------------
60 SfxCrawlStatusItem::SfxCrawlStatusItem( USHORT which, CrawlStatus eStat ) :
61 SfxPoolItem( which ),
62 eStatus( eStat )
64 DBG_CTOR( SfxCrawlStatusItem, 0 );
67 // -----------------------------------------------------------------------
69 SfxCrawlStatusItem::SfxCrawlStatusItem( const SfxCrawlStatusItem& rItem ) :
70 SfxPoolItem( rItem ),
71 eStatus( rItem.eStatus )
73 DBG_CTOR( SfxCrawlStatusItem, 0 );
76 // -----------------------------------------------------------------------
78 int SfxCrawlStatusItem::operator==( const SfxPoolItem& rItem ) const
80 DBG_CHKTHIS( SfxCrawlStatusItem, 0 );
81 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
83 return ((SfxCrawlStatusItem&)rItem).eStatus == eStatus;
86 // -----------------------------------------------------------------------
88 int SfxCrawlStatusItem::Compare( const SfxPoolItem& rItem ) const
90 DBG_CHKTHIS( SfxCrawlStatusItem, 0 );
91 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
93 if( ((const SfxCrawlStatusItem&)rItem).eStatus < eStatus )
94 return -1;
95 else if( ((const SfxCrawlStatusItem&)rItem).eStatus == eStatus )
96 return 0;
97 else
98 return 1;
101 // -----------------------------------------------------------------------
103 SfxPoolItem* SfxCrawlStatusItem::Create( SvStream& rStream, USHORT ) const
105 DBG_CHKTHIS(SfxCrawlStatusItem, 0);
107 USHORT _eStatus;
108 rStream >> _eStatus;
110 return new SfxCrawlStatusItem( Which(), (CrawlStatus)_eStatus );
113 // -----------------------------------------------------------------------
115 SvStream& SfxCrawlStatusItem::Store( SvStream& rStream, USHORT ) const
117 DBG_CHKTHIS( SfxCrawlStatusItem, 0 );
119 USHORT nStatus = (USHORT)eStatus;
120 rStream << (USHORT) nStatus;
122 return rStream;
125 // -----------------------------------------------------------------------
127 SfxPoolItem* SfxCrawlStatusItem::Clone( SfxItemPool* ) const
129 DBG_CHKTHIS( SfxCrawlStatusItem, 0 );
130 return new SfxCrawlStatusItem( *this );
132 // -----------------------------------------------------------------------
134 SfxItemPresentation SfxCrawlStatusItem::GetPresentation
136 SfxItemPresentation /*ePresentation*/,
137 SfxMapUnit /*eCoreMetric*/,
138 SfxMapUnit /*ePresentationMetric*/,
139 XubString& rText,
140 const IntlWrapper * pIntlWrapper
141 ) const
143 DBG_CHKTHIS(SfxCrawlStatusItem, 0);
144 DBG_ASSERT(pIntlWrapper,
145 "SfxCrawlStatusItem::GetPresentation():"
146 " Using default IntlWrapper");
148 ::com::sun::star::lang::Locale aLocale;
150 switch (eStatus)
152 case CSTAT_NEVER_UPD:
153 rText = String(SvtResId(STR_CSTAT_NEVER_UPD,
154 pIntlWrapper ?
155 pIntlWrapper->getLocale() :
156 aLocale));
157 break;
159 case CSTAT_IN_UPD:
160 rText = String(SvtResId(STR_CSTAT_IN_UPD,
161 pIntlWrapper ?
162 pIntlWrapper->getLocale() :
163 aLocale));
164 break;
166 case CSTAT_UPD_NEWER:
167 rText = String(SvtResId(STR_CSTAT_UPD_NEWER,
168 pIntlWrapper ?
169 pIntlWrapper->getLocale() :
170 aLocale));
171 break;
173 case CSTAT_UPD_NOT_NEWER:
174 rText = String(SvtResId(STR_CSTAT_UPD_NOT_NEWER,
175 pIntlWrapper ?
176 pIntlWrapper->getLocale() :
177 aLocale));
178 break;
180 case CSTAT_UPD_CANCEL:
181 rText = String(SvtResId(STR_CSTAT_UPD_CANCEL,
182 pIntlWrapper ?
183 pIntlWrapper->getLocale() :
184 aLocale));
185 break;
187 case CSTAT_ERR_GENERAL:
188 rText = String(SvtResId(STR_CSTAT_ERR_GENERAL,
189 pIntlWrapper ?
190 pIntlWrapper->getLocale() :
191 aLocale));
192 break;
194 case CSTAT_ERR_NOTEXISTS:
195 rText = String(SvtResId(STR_CSTAT_ERR_NOTEXISTS,
196 pIntlWrapper ?
197 pIntlWrapper->getLocale() :
198 aLocale));
199 break;
201 case CSTAT_ERR_NOTREACHED:
202 rText = String(SvtResId(STR_CSTAT_ERR_NOTREACHED,
203 pIntlWrapper ?
204 pIntlWrapper->getLocale() :
205 aLocale));
206 break;
208 case CSTAT_UPD_IMMEDIATELY:
209 rText = String(SvtResId(STR_CSTAT_UPD_IMMEDIATELY,
210 pIntlWrapper ?
211 pIntlWrapper->getLocale() :
212 aLocale));
213 break;
215 case CSTAT_ERR_OFFLINE:
216 rText = String(SvtResId(STR_CSTAT_ERR_OFFLINE,
217 pIntlWrapper ?
218 pIntlWrapper->getLocale() :
219 aLocale));
220 break;
222 default:
223 rText.Erase();
224 break;
226 return SFX_ITEM_PRESENTATION_NAMELESS;
229 //----------------------------------------------------------------------------
230 // virtual
231 BOOL SfxCrawlStatusItem::PutValue( const com::sun::star::uno::Any& rVal,BYTE )
233 sal_Int16 aValue = sal_Int16();
234 if ( rVal >>= aValue )
236 SetStatus( static_cast< CrawlStatus >( aValue ) );
237 return TRUE;
240 DBG_ERROR( "SfxCrawlStatusItem::PutValue - Wrong type!" );
241 return FALSE;
244 //----------------------------------------------------------------------------
245 // virtual
246 BOOL SfxCrawlStatusItem::QueryValue( com::sun::star::uno::Any& rVal,BYTE ) const
248 sal_Int16 aValue = sal::static_int_cast< sal_Int16 >(GetStatus());
249 rVal <<= aValue;
250 return TRUE;