1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
,
45 SfxPoolItem( _nWhich
)
47 xSpellCheck
= xChecker
;
50 // -----------------------------------------------------------------------
52 SfxSpellCheckItem::SfxSpellCheckItem( const SfxSpellCheckItem
& rItem
) :
55 xSpellCheck( rItem
.GetXSpellChecker() )
59 //------------------------------------------------------------------------
61 SfxItemPresentation
SfxSpellCheckItem::GetPresentation
63 SfxItemPresentation ePres
,
72 case SFX_ITEM_PRESENTATION_NONE
:
74 return SFX_ITEM_PRESENTATION_NONE
;
76 case SFX_ITEM_PRESENTATION_NAMELESS
:
77 case SFX_ITEM_PRESENTATION_COMPLETE
:
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
) :
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
,
151 case SFX_ITEM_PRESENTATION_NONE
:
153 return SFX_ITEM_PRESENTATION_NONE
;
155 case SFX_ITEM_PRESENTATION_NAMELESS
:
156 case SFX_ITEM_PRESENTATION_COMPLETE
:
159 EE_RESSTR(RID_SVXITEMS_HYPHEN_MINLEAD
).replaceAll("%1", OUString::number(nMinLead
)) +
161 EE_RESSTR(RID_SVXITEMS_HYPHEN_MINTRAIL
).replaceAll("%1", OUString::number(nMinTrail
));
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
;
181 // -----------------------------------------------------------------------
183 SvStream
& SfxHyphenRegionItem::Store( SvStream
& rStrm
, sal_uInt16
) const
185 rStrm
<< (sal_uInt8
) GetMinLead()
186 << (sal_uInt8
) GetMinTrail();
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */