xref: /AOO41X/main/editeng/source/items/optitems.cxx (revision 190118d08a3be86671f4129b3e9a490e144719cd)
1*190118d0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*190118d0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*190118d0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*190118d0SAndrew Rist  * distributed with this work for additional information
6*190118d0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*190118d0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*190118d0SAndrew Rist  * "License"); you may not use this file except in compliance
9*190118d0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*190118d0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*190118d0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*190118d0SAndrew Rist  * software distributed under the License is distributed on an
15*190118d0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*190118d0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*190118d0SAndrew Rist  * specific language governing permissions and limitations
18*190118d0SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*190118d0SAndrew Rist  *************************************************************/
21*190118d0SAndrew Rist 
22*190118d0SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_editeng.hxx"
26cdf0e10cSrcweir #include <tools/shl.hxx>
27cdf0e10cSrcweir #include <tools/resid.hxx>
28cdf0e10cSrcweir #include <tools/stream.hxx>
29cdf0e10cSrcweir #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <editeng/optitems.hxx>
32cdf0e10cSrcweir #include <editeng/eerdll.hxx>
33cdf0e10cSrcweir #include <editeng/editrids.hrc>
34cdf0e10cSrcweir #include <editeng/eerdll.hxx>
35cdf0e10cSrcweir #include <editeng/editrids.hrc>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir using namespace ::com::sun::star::uno;
38cdf0e10cSrcweir using namespace ::com::sun::star::linguistic2;
39cdf0e10cSrcweir 
40cdf0e10cSrcweir // STATIC DATA -----------------------------------------------------------
41cdf0e10cSrcweir 
42cdf0e10cSrcweir TYPEINIT1(SfxSpellCheckItem, SfxPoolItem);
43cdf0e10cSrcweir TYPEINIT1(SfxHyphenRegionItem, SfxPoolItem);
44cdf0e10cSrcweir 
45cdf0e10cSrcweir // class SfxSpellCheckItem -----------------------------------------------
46cdf0e10cSrcweir 
SfxSpellCheckItem(Reference<XSpellChecker1> & xChecker,sal_uInt16 _nWhich)47cdf0e10cSrcweir SfxSpellCheckItem::SfxSpellCheckItem
48cdf0e10cSrcweir (
49cdf0e10cSrcweir 	Reference< XSpellChecker1 > &xChecker,
50cdf0e10cSrcweir 	sal_uInt16 _nWhich
51cdf0e10cSrcweir ) :
52cdf0e10cSrcweir 
53cdf0e10cSrcweir 	SfxPoolItem( _nWhich )
54cdf0e10cSrcweir {
55cdf0e10cSrcweir 	xSpellCheck = xChecker;
56cdf0e10cSrcweir }
57cdf0e10cSrcweir 
58cdf0e10cSrcweir // -----------------------------------------------------------------------
59cdf0e10cSrcweir 
SfxSpellCheckItem(const SfxSpellCheckItem & rItem)60cdf0e10cSrcweir SfxSpellCheckItem::SfxSpellCheckItem( const SfxSpellCheckItem& rItem ) :
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 	SfxPoolItem( rItem ),
63cdf0e10cSrcweir 	xSpellCheck( rItem.GetXSpellChecker() )
64cdf0e10cSrcweir {
65cdf0e10cSrcweir }
66cdf0e10cSrcweir 
67cdf0e10cSrcweir //------------------------------------------------------------------------
68cdf0e10cSrcweir 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,String & rText,const IntlWrapper *) const69cdf0e10cSrcweir SfxItemPresentation SfxSpellCheckItem::GetPresentation
70cdf0e10cSrcweir (
71cdf0e10cSrcweir 	SfxItemPresentation	ePres,
72cdf0e10cSrcweir 	SfxMapUnit			,
73cdf0e10cSrcweir 	SfxMapUnit			,
74cdf0e10cSrcweir 	String&				rText,
75cdf0e10cSrcweir     const IntlWrapper*
76cdf0e10cSrcweir )	const
77cdf0e10cSrcweir {
78cdf0e10cSrcweir 	switch ( ePres )
79cdf0e10cSrcweir 	{
80cdf0e10cSrcweir 		case SFX_ITEM_PRESENTATION_NONE:
81cdf0e10cSrcweir 			rText.Erase();
82cdf0e10cSrcweir 			return SFX_ITEM_PRESENTATION_NONE;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 		case SFX_ITEM_PRESENTATION_NAMELESS:
85cdf0e10cSrcweir 		case SFX_ITEM_PRESENTATION_COMPLETE:
86cdf0e10cSrcweir 		{
87cdf0e10cSrcweir 			return ePres;
88cdf0e10cSrcweir 		}
89cdf0e10cSrcweir 		default:
90cdf0e10cSrcweir 			return SFX_ITEM_PRESENTATION_NONE;
91cdf0e10cSrcweir 	}
92cdf0e10cSrcweir }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir // -----------------------------------------------------------------------
95cdf0e10cSrcweir 
Clone(SfxItemPool *) const96cdf0e10cSrcweir SfxPoolItem* SfxSpellCheckItem::Clone( SfxItemPool* ) const
97cdf0e10cSrcweir {
98cdf0e10cSrcweir 	return new SfxSpellCheckItem( *this );
99cdf0e10cSrcweir }
100cdf0e10cSrcweir 
101cdf0e10cSrcweir // -----------------------------------------------------------------------
102cdf0e10cSrcweir 
operator ==(const SfxPoolItem & rItem) const103cdf0e10cSrcweir int SfxSpellCheckItem::operator==( const SfxPoolItem& rItem ) const
104cdf0e10cSrcweir {
105cdf0e10cSrcweir 	DBG_ASSERT( SfxPoolItem::operator==(rItem), "unequal types" );
106cdf0e10cSrcweir 	return ( xSpellCheck == ( (const SfxSpellCheckItem& )rItem ).GetXSpellChecker() );
107cdf0e10cSrcweir }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir // class SfxHyphenRegionItem -----------------------------------------------
110cdf0e10cSrcweir 
SfxHyphenRegionItem(const sal_uInt16 nId)111cdf0e10cSrcweir SfxHyphenRegionItem::SfxHyphenRegionItem( const sal_uInt16 nId ) :
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	SfxPoolItem( nId )
114cdf0e10cSrcweir {
115cdf0e10cSrcweir 	nMinLead = nMinTrail = 0;
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
118cdf0e10cSrcweir // -----------------------------------------------------------------------
119cdf0e10cSrcweir 
SfxHyphenRegionItem(const SfxHyphenRegionItem & rItem)120cdf0e10cSrcweir SfxHyphenRegionItem::SfxHyphenRegionItem( const SfxHyphenRegionItem& rItem ) :
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	SfxPoolItem	( rItem ),
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 	nMinLead	( rItem.GetMinLead() ),
125cdf0e10cSrcweir 	nMinTrail	( rItem.GetMinTrail() )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir // -----------------------------------------------------------------------
130cdf0e10cSrcweir 
operator ==(const SfxPoolItem & rAttr) const131cdf0e10cSrcweir int SfxHyphenRegionItem::operator==( const SfxPoolItem& rAttr ) const
132cdf0e10cSrcweir {
133cdf0e10cSrcweir 	DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	return ( ( ( (SfxHyphenRegionItem&)rAttr ).nMinLead == nMinLead ) &&
136cdf0e10cSrcweir 			 ( ( (SfxHyphenRegionItem&)rAttr ).nMinTrail == nMinTrail ) );
137cdf0e10cSrcweir }
138cdf0e10cSrcweir 
139cdf0e10cSrcweir // -----------------------------------------------------------------------
140cdf0e10cSrcweir 
Clone(SfxItemPool *) const141cdf0e10cSrcweir SfxPoolItem* SfxHyphenRegionItem::Clone( SfxItemPool* ) const
142cdf0e10cSrcweir {
143cdf0e10cSrcweir 	return new SfxHyphenRegionItem( *this );
144cdf0e10cSrcweir }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir //------------------------------------------------------------------------
147cdf0e10cSrcweir 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,String & rText,const IntlWrapper *) const148cdf0e10cSrcweir SfxItemPresentation SfxHyphenRegionItem::GetPresentation
149cdf0e10cSrcweir (
150cdf0e10cSrcweir 	SfxItemPresentation ePres,
151cdf0e10cSrcweir 	SfxMapUnit			,
152cdf0e10cSrcweir 	SfxMapUnit			,
153cdf0e10cSrcweir 	String&				rText,
154cdf0e10cSrcweir     const IntlWrapper*
155cdf0e10cSrcweir )	const
156cdf0e10cSrcweir {
157cdf0e10cSrcweir 	switch ( ePres )
158cdf0e10cSrcweir 	{
159cdf0e10cSrcweir 		case SFX_ITEM_PRESENTATION_NONE:
160cdf0e10cSrcweir 			rText.Erase();
161cdf0e10cSrcweir 			return SFX_ITEM_PRESENTATION_NONE;
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 		case SFX_ITEM_PRESENTATION_NAMELESS:
164cdf0e10cSrcweir 		case SFX_ITEM_PRESENTATION_COMPLETE:
165cdf0e10cSrcweir 		{
166cdf0e10cSrcweir 			rText += String::CreateFromInt32( nMinLead );
167cdf0e10cSrcweir 			rText += String( EditResId( RID_SVXITEMS_HYPHEN_MINLEAD ) );
168cdf0e10cSrcweir 			rText += ',';
169cdf0e10cSrcweir 			rText += String::CreateFromInt32( nMinTrail );
170cdf0e10cSrcweir 			rText += String( EditResId( RID_SVXITEMS_HYPHEN_MINTRAIL ) );
171cdf0e10cSrcweir 			return ePres;
172cdf0e10cSrcweir 		}
173cdf0e10cSrcweir 		default:
174cdf0e10cSrcweir 			return SFX_ITEM_PRESENTATION_NONE;
175cdf0e10cSrcweir 	}
176cdf0e10cSrcweir }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir // -----------------------------------------------------------------------
179cdf0e10cSrcweir 
Create(SvStream & rStrm,sal_uInt16) const180cdf0e10cSrcweir SfxPoolItem* SfxHyphenRegionItem::Create(SvStream& rStrm, sal_uInt16 ) const
181cdf0e10cSrcweir {
182cdf0e10cSrcweir 	sal_uInt8 _nMinLead, _nMinTrail;
183cdf0e10cSrcweir 	rStrm >> _nMinLead >> _nMinTrail;
184cdf0e10cSrcweir 	SfxHyphenRegionItem* pAttr = new SfxHyphenRegionItem( Which() );
185cdf0e10cSrcweir 	pAttr->GetMinLead() = _nMinLead;
186cdf0e10cSrcweir 	pAttr->GetMinTrail() = _nMinTrail;
187cdf0e10cSrcweir 	return pAttr;
188cdf0e10cSrcweir }
189cdf0e10cSrcweir 
190cdf0e10cSrcweir // -----------------------------------------------------------------------
191cdf0e10cSrcweir 
Store(SvStream & rStrm,sal_uInt16) const192cdf0e10cSrcweir SvStream& SfxHyphenRegionItem::Store( SvStream& rStrm, sal_uInt16 ) const
193cdf0e10cSrcweir {
194cdf0e10cSrcweir 	rStrm << (sal_uInt8) GetMinLead()
195cdf0e10cSrcweir 		  << (sal_uInt8) GetMinTrail();
196cdf0e10cSrcweir 	return rStrm;
197cdf0e10cSrcweir }
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 
200