Update ooo320-m1
[ooovba.git] / svx / source / options / optitems.cxx
blobf37e9ecc987b4a4b71cd1e6d91e8221954b61333
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: optitems.cxx,v $
10 * $Revision: 1.10 $
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_svx.hxx"
33 #include <tools/shl.hxx>
34 #include <tools/resid.hxx>
35 #include <tools/stream.hxx>
36 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
38 #include "optitems.hxx"
39 #include <svx/dialmgr.hxx>
40 #include <svx/svxitems.hrc>
42 using namespace ::com::sun::star::uno;
43 using namespace ::com::sun::star::linguistic2;
45 // STATIC DATA -----------------------------------------------------------
47 TYPEINIT1(SfxSpellCheckItem, SfxPoolItem);
48 TYPEINIT1(SfxHyphenRegionItem, SfxPoolItem);
50 // class SfxSpellCheckItem -----------------------------------------------
52 SfxSpellCheckItem::SfxSpellCheckItem
54 Reference< XSpellChecker1 > &xChecker,
55 sal_uInt16 _nWhich
56 ) :
58 SfxPoolItem( _nWhich )
60 xSpellCheck = xChecker;
63 // -----------------------------------------------------------------------
65 SfxSpellCheckItem::SfxSpellCheckItem( const SfxSpellCheckItem& rItem ) :
67 SfxPoolItem( rItem ),
68 xSpellCheck( rItem.GetXSpellChecker() )
72 //------------------------------------------------------------------------
74 SfxItemPresentation SfxSpellCheckItem::GetPresentation
76 SfxItemPresentation ePres,
77 SfxMapUnit ,
78 SfxMapUnit ,
79 String& rText,
80 const IntlWrapper*
81 ) const
83 switch ( ePres )
85 case SFX_ITEM_PRESENTATION_NONE:
86 rText.Erase();
87 return SFX_ITEM_PRESENTATION_NONE;
89 case SFX_ITEM_PRESENTATION_NAMELESS:
90 case SFX_ITEM_PRESENTATION_COMPLETE:
92 return ePres;
94 default:
95 return SFX_ITEM_PRESENTATION_NONE;
99 // -----------------------------------------------------------------------
101 SfxPoolItem* SfxSpellCheckItem::Clone( SfxItemPool* ) const
103 return new SfxSpellCheckItem( *this );
106 // -----------------------------------------------------------------------
108 int SfxSpellCheckItem::operator==( const SfxPoolItem& rItem ) const
110 DBG_ASSERT( SfxPoolItem::operator==(rItem), "unequal types" );
111 return ( xSpellCheck == ( (const SfxSpellCheckItem& )rItem ).GetXSpellChecker() );
114 // class SfxHyphenRegionItem -----------------------------------------------
116 SfxHyphenRegionItem::SfxHyphenRegionItem( const sal_uInt16 nId ) :
118 SfxPoolItem( nId )
120 nMinLead = nMinTrail = 0;
123 // -----------------------------------------------------------------------
125 SfxHyphenRegionItem::SfxHyphenRegionItem( const SfxHyphenRegionItem& rItem ) :
127 SfxPoolItem ( rItem ),
129 nMinLead ( rItem.GetMinLead() ),
130 nMinTrail ( rItem.GetMinTrail() )
134 // -----------------------------------------------------------------------
136 int SfxHyphenRegionItem::operator==( const SfxPoolItem& rAttr ) const
138 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
140 return ( ( ( (SfxHyphenRegionItem&)rAttr ).nMinLead == nMinLead ) &&
141 ( ( (SfxHyphenRegionItem&)rAttr ).nMinTrail == nMinTrail ) );
144 // -----------------------------------------------------------------------
146 SfxPoolItem* SfxHyphenRegionItem::Clone( SfxItemPool* ) const
148 return new SfxHyphenRegionItem( *this );
151 //------------------------------------------------------------------------
153 SfxItemPresentation SfxHyphenRegionItem::GetPresentation
155 SfxItemPresentation ePres,
156 SfxMapUnit ,
157 SfxMapUnit ,
158 String& rText,
159 const IntlWrapper*
160 ) const
162 switch ( ePres )
164 case SFX_ITEM_PRESENTATION_NONE:
165 rText.Erase();
166 return SFX_ITEM_PRESENTATION_NONE;
168 case SFX_ITEM_PRESENTATION_NAMELESS:
169 case SFX_ITEM_PRESENTATION_COMPLETE:
171 rText += String::CreateFromInt32( nMinLead );
172 rText += String( ResId( RID_SVXITEMS_HYPHEN_MINLEAD, DIALOG_MGR() ) );
173 rText += ',';
174 rText += String::CreateFromInt32( nMinTrail );
175 rText += String( ResId( RID_SVXITEMS_HYPHEN_MINTRAIL, DIALOG_MGR() ) );
176 return ePres;
178 default:
179 return SFX_ITEM_PRESENTATION_NONE;
183 // -----------------------------------------------------------------------
185 SfxPoolItem* SfxHyphenRegionItem::Create(SvStream& rStrm, sal_uInt16 ) const
187 sal_uInt8 _nMinLead, _nMinTrail;
188 rStrm >> _nMinLead >> _nMinTrail;
189 SfxHyphenRegionItem* pAttr = new SfxHyphenRegionItem( Which() );
190 pAttr->GetMinLead() = _nMinLead;
191 pAttr->GetMinTrail() = _nMinTrail;
192 return pAttr;
195 // -----------------------------------------------------------------------
197 SvStream& SfxHyphenRegionItem::Store( SvStream& rStrm, sal_uInt16 ) const
199 rStrm << (sal_uInt8) GetMinLead()
200 << (sal_uInt8) GetMinTrail();
201 return rStrm;