bump product version to 4.1.6.2
[LibreOffice.git] / editeng / source / items / optitems.cxx
blobc3f315ed27912ea08e431685d089f92c55bcec22
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <tools/shl.hxx>
21 #include <tools/resid.hxx>
22 #include <tools/stream.hxx>
23 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
25 #include <editeng/optitems.hxx>
26 #include <editeng/eerdll.hxx>
27 #include <editeng/editrids.hrc>
29 using namespace ::com::sun::star::uno;
30 using namespace ::com::sun::star::linguistic2;
32 // STATIC DATA -----------------------------------------------------------
34 TYPEINIT1(SfxSpellCheckItem, SfxPoolItem);
35 TYPEINIT1(SfxHyphenRegionItem, SfxPoolItem);
37 // class SfxSpellCheckItem -----------------------------------------------
39 SfxSpellCheckItem::SfxSpellCheckItem
41 Reference< XSpellChecker1 > &xChecker,
42 sal_uInt16 _nWhich
43 ) :
45 SfxPoolItem( _nWhich )
47 xSpellCheck = xChecker;
50 // -----------------------------------------------------------------------
52 SfxSpellCheckItem::SfxSpellCheckItem( const SfxSpellCheckItem& rItem ) :
54 SfxPoolItem( rItem ),
55 xSpellCheck( rItem.GetXSpellChecker() )
59 //------------------------------------------------------------------------
61 SfxItemPresentation SfxSpellCheckItem::GetPresentation
63 SfxItemPresentation ePres,
64 SfxMapUnit ,
65 SfxMapUnit ,
66 OUString& rText,
67 const IntlWrapper*
68 ) const
70 switch ( ePres )
72 case SFX_ITEM_PRESENTATION_NONE:
73 rText = OUString();
74 return SFX_ITEM_PRESENTATION_NONE;
76 case SFX_ITEM_PRESENTATION_NAMELESS:
77 case SFX_ITEM_PRESENTATION_COMPLETE:
79 return ePres;
81 default:
82 return SFX_ITEM_PRESENTATION_NONE;
86 // -----------------------------------------------------------------------
88 SfxPoolItem* SfxSpellCheckItem::Clone( SfxItemPool* ) const
90 return new SfxSpellCheckItem( *this );
93 // -----------------------------------------------------------------------
95 int SfxSpellCheckItem::operator==( const SfxPoolItem& rItem ) const
97 DBG_ASSERT( SfxPoolItem::operator==(rItem), "unequal types" );
98 return ( xSpellCheck == ( (const SfxSpellCheckItem& )rItem ).GetXSpellChecker() );
101 // class SfxHyphenRegionItem -----------------------------------------------
103 SfxHyphenRegionItem::SfxHyphenRegionItem( const sal_uInt16 nId ) :
105 SfxPoolItem( nId )
107 nMinLead = nMinTrail = 0;
110 // -----------------------------------------------------------------------
112 SfxHyphenRegionItem::SfxHyphenRegionItem( const SfxHyphenRegionItem& rItem ) :
114 SfxPoolItem ( rItem ),
116 nMinLead ( rItem.GetMinLead() ),
117 nMinTrail ( rItem.GetMinTrail() )
121 // -----------------------------------------------------------------------
123 int SfxHyphenRegionItem::operator==( const SfxPoolItem& rAttr ) const
125 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
127 return ( ( ( (SfxHyphenRegionItem&)rAttr ).nMinLead == nMinLead ) &&
128 ( ( (SfxHyphenRegionItem&)rAttr ).nMinTrail == nMinTrail ) );
131 // -----------------------------------------------------------------------
133 SfxPoolItem* SfxHyphenRegionItem::Clone( SfxItemPool* ) const
135 return new SfxHyphenRegionItem( *this );
138 //------------------------------------------------------------------------
140 SfxItemPresentation SfxHyphenRegionItem::GetPresentation
142 SfxItemPresentation ePres,
143 SfxMapUnit ,
144 SfxMapUnit ,
145 OUString& rText,
146 const IntlWrapper*
147 ) const
149 switch ( ePres )
151 case SFX_ITEM_PRESENTATION_NONE:
152 rText = OUString();
153 return SFX_ITEM_PRESENTATION_NONE;
155 case SFX_ITEM_PRESENTATION_NAMELESS:
156 case SFX_ITEM_PRESENTATION_COMPLETE:
158 rText = rText +
159 EE_RESSTR(RID_SVXITEMS_HYPHEN_MINLEAD).replaceAll("%1", OUString::number(nMinLead)) +
160 "," +
161 EE_RESSTR(RID_SVXITEMS_HYPHEN_MINTRAIL).replaceAll("%1", OUString::number(nMinTrail));
162 return ePres;
164 default:
165 return SFX_ITEM_PRESENTATION_NONE;
169 // -----------------------------------------------------------------------
171 SfxPoolItem* SfxHyphenRegionItem::Create(SvStream& rStrm, sal_uInt16 ) const
173 sal_uInt8 _nMinLead, _nMinTrail;
174 rStrm >> _nMinLead >> _nMinTrail;
175 SfxHyphenRegionItem* pAttr = new SfxHyphenRegionItem( Which() );
176 pAttr->GetMinLead() = _nMinLead;
177 pAttr->GetMinTrail() = _nMinTrail;
178 return pAttr;
181 // -----------------------------------------------------------------------
183 SvStream& SfxHyphenRegionItem::Store( SvStream& rStrm, sal_uInt16 ) const
185 rStrm << (sal_uInt8) GetMinLead()
186 << (sal_uInt8) GetMinTrail();
187 return rStrm;
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */