1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cstitem.cxx,v $
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
) :
55 DBG_CTOR( SfxCrawlStatusItem
, 0 );
58 // -----------------------------------------------------------------------
60 SfxCrawlStatusItem::SfxCrawlStatusItem( USHORT which
, CrawlStatus eStat
) :
64 DBG_CTOR( SfxCrawlStatusItem
, 0 );
67 // -----------------------------------------------------------------------
69 SfxCrawlStatusItem::SfxCrawlStatusItem( const SfxCrawlStatusItem
& 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
)
95 else if( ((const SfxCrawlStatusItem
&)rItem
).eStatus
== eStatus
)
101 // -----------------------------------------------------------------------
103 SfxPoolItem
* SfxCrawlStatusItem::Create( SvStream
& rStream
, USHORT
) const
105 DBG_CHKTHIS(SfxCrawlStatusItem
, 0);
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
;
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*/,
140 const IntlWrapper
* pIntlWrapper
143 DBG_CHKTHIS(SfxCrawlStatusItem
, 0);
144 DBG_ASSERT(pIntlWrapper
,
145 "SfxCrawlStatusItem::GetPresentation():"
146 " Using default IntlWrapper");
148 ::com::sun::star::lang::Locale aLocale
;
152 case CSTAT_NEVER_UPD
:
153 rText
= String(SvtResId(STR_CSTAT_NEVER_UPD
,
155 pIntlWrapper
->getLocale() :
160 rText
= String(SvtResId(STR_CSTAT_IN_UPD
,
162 pIntlWrapper
->getLocale() :
166 case CSTAT_UPD_NEWER
:
167 rText
= String(SvtResId(STR_CSTAT_UPD_NEWER
,
169 pIntlWrapper
->getLocale() :
173 case CSTAT_UPD_NOT_NEWER
:
174 rText
= String(SvtResId(STR_CSTAT_UPD_NOT_NEWER
,
176 pIntlWrapper
->getLocale() :
180 case CSTAT_UPD_CANCEL
:
181 rText
= String(SvtResId(STR_CSTAT_UPD_CANCEL
,
183 pIntlWrapper
->getLocale() :
187 case CSTAT_ERR_GENERAL
:
188 rText
= String(SvtResId(STR_CSTAT_ERR_GENERAL
,
190 pIntlWrapper
->getLocale() :
194 case CSTAT_ERR_NOTEXISTS
:
195 rText
= String(SvtResId(STR_CSTAT_ERR_NOTEXISTS
,
197 pIntlWrapper
->getLocale() :
201 case CSTAT_ERR_NOTREACHED
:
202 rText
= String(SvtResId(STR_CSTAT_ERR_NOTREACHED
,
204 pIntlWrapper
->getLocale() :
208 case CSTAT_UPD_IMMEDIATELY
:
209 rText
= String(SvtResId(STR_CSTAT_UPD_IMMEDIATELY
,
211 pIntlWrapper
->getLocale() :
215 case CSTAT_ERR_OFFLINE
:
216 rText
= String(SvtResId(STR_CSTAT_ERR_OFFLINE
,
218 pIntlWrapper
->getLocale() :
226 return SFX_ITEM_PRESENTATION_NAMELESS
;
229 //----------------------------------------------------------------------------
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
) );
240 DBG_ERROR( "SfxCrawlStatusItem::PutValue - Wrong type!" );
244 //----------------------------------------------------------------------------
246 BOOL
SfxCrawlStatusItem::QueryValue( com::sun::star::uno::Any
& rVal
,BYTE
) const
248 sal_Int16 aValue
= sal::static_int_cast
< sal_Int16
>(GetStatus());