xref: /aoo41x/main/editeng/source/items/optitems.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_editeng.hxx"
30 #include <tools/shl.hxx>
31 #include <tools/resid.hxx>
32 #include <tools/stream.hxx>
33 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
34 
35 #include <editeng/optitems.hxx>
36 #include <editeng/eerdll.hxx>
37 #include <editeng/editrids.hrc>
38 #include <editeng/eerdll.hxx>
39 #include <editeng/editrids.hrc>
40 
41 using namespace ::com::sun::star::uno;
42 using namespace ::com::sun::star::linguistic2;
43 
44 // STATIC DATA -----------------------------------------------------------
45 
46 TYPEINIT1(SfxSpellCheckItem, SfxPoolItem);
47 TYPEINIT1(SfxHyphenRegionItem, SfxPoolItem);
48 
49 // class SfxSpellCheckItem -----------------------------------------------
50 
51 SfxSpellCheckItem::SfxSpellCheckItem
52 (
53 	Reference< XSpellChecker1 > &xChecker,
54 	sal_uInt16 _nWhich
55 ) :
56 
57 	SfxPoolItem( _nWhich )
58 {
59 	xSpellCheck = xChecker;
60 }
61 
62 // -----------------------------------------------------------------------
63 
64 SfxSpellCheckItem::SfxSpellCheckItem( const SfxSpellCheckItem& rItem ) :
65 
66 	SfxPoolItem( rItem ),
67 	xSpellCheck( rItem.GetXSpellChecker() )
68 {
69 }
70 
71 //------------------------------------------------------------------------
72 
73 SfxItemPresentation SfxSpellCheckItem::GetPresentation
74 (
75 	SfxItemPresentation	ePres,
76 	SfxMapUnit			,
77 	SfxMapUnit			,
78 	String&				rText,
79     const IntlWrapper*
80 )	const
81 {
82 	switch ( ePres )
83 	{
84 		case SFX_ITEM_PRESENTATION_NONE:
85 			rText.Erase();
86 			return SFX_ITEM_PRESENTATION_NONE;
87 
88 		case SFX_ITEM_PRESENTATION_NAMELESS:
89 		case SFX_ITEM_PRESENTATION_COMPLETE:
90 		{
91 			return ePres;
92 		}
93 		default:
94 			return SFX_ITEM_PRESENTATION_NONE;
95 	}
96 }
97 
98 // -----------------------------------------------------------------------
99 
100 SfxPoolItem* SfxSpellCheckItem::Clone( SfxItemPool* ) const
101 {
102 	return new SfxSpellCheckItem( *this );
103 }
104 
105 // -----------------------------------------------------------------------
106 
107 int SfxSpellCheckItem::operator==( const SfxPoolItem& rItem ) const
108 {
109 	DBG_ASSERT( SfxPoolItem::operator==(rItem), "unequal types" );
110 	return ( xSpellCheck == ( (const SfxSpellCheckItem& )rItem ).GetXSpellChecker() );
111 }
112 
113 // class SfxHyphenRegionItem -----------------------------------------------
114 
115 SfxHyphenRegionItem::SfxHyphenRegionItem( const sal_uInt16 nId ) :
116 
117 	SfxPoolItem( nId )
118 {
119 	nMinLead = nMinTrail = 0;
120 }
121 
122 // -----------------------------------------------------------------------
123 
124 SfxHyphenRegionItem::SfxHyphenRegionItem( const SfxHyphenRegionItem& rItem ) :
125 
126 	SfxPoolItem	( rItem ),
127 
128 	nMinLead	( rItem.GetMinLead() ),
129 	nMinTrail	( rItem.GetMinTrail() )
130 {
131 }
132 
133 // -----------------------------------------------------------------------
134 
135 int SfxHyphenRegionItem::operator==( const SfxPoolItem& rAttr ) const
136 {
137 	DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
138 
139 	return ( ( ( (SfxHyphenRegionItem&)rAttr ).nMinLead == nMinLead ) &&
140 			 ( ( (SfxHyphenRegionItem&)rAttr ).nMinTrail == nMinTrail ) );
141 }
142 
143 // -----------------------------------------------------------------------
144 
145 SfxPoolItem* SfxHyphenRegionItem::Clone( SfxItemPool* ) const
146 {
147 	return new SfxHyphenRegionItem( *this );
148 }
149 
150 //------------------------------------------------------------------------
151 
152 SfxItemPresentation SfxHyphenRegionItem::GetPresentation
153 (
154 	SfxItemPresentation ePres,
155 	SfxMapUnit			,
156 	SfxMapUnit			,
157 	String&				rText,
158     const IntlWrapper*
159 )	const
160 {
161 	switch ( ePres )
162 	{
163 		case SFX_ITEM_PRESENTATION_NONE:
164 			rText.Erase();
165 			return SFX_ITEM_PRESENTATION_NONE;
166 
167 		case SFX_ITEM_PRESENTATION_NAMELESS:
168 		case SFX_ITEM_PRESENTATION_COMPLETE:
169 		{
170 			rText += String::CreateFromInt32( nMinLead );
171 			rText += String( EditResId( RID_SVXITEMS_HYPHEN_MINLEAD ) );
172 			rText += ',';
173 			rText += String::CreateFromInt32( nMinTrail );
174 			rText += String( EditResId( RID_SVXITEMS_HYPHEN_MINTRAIL ) );
175 			return ePres;
176 		}
177 		default:
178 			return SFX_ITEM_PRESENTATION_NONE;
179 	}
180 }
181 
182 // -----------------------------------------------------------------------
183 
184 SfxPoolItem* SfxHyphenRegionItem::Create(SvStream& rStrm, sal_uInt16 ) const
185 {
186 	sal_uInt8 _nMinLead, _nMinTrail;
187 	rStrm >> _nMinLead >> _nMinTrail;
188 	SfxHyphenRegionItem* pAttr = new SfxHyphenRegionItem( Which() );
189 	pAttr->GetMinLead() = _nMinLead;
190 	pAttr->GetMinTrail() = _nMinTrail;
191 	return pAttr;
192 }
193 
194 // -----------------------------------------------------------------------
195 
196 SvStream& SfxHyphenRegionItem::Store( SvStream& rStrm, sal_uInt16 ) const
197 {
198 	rStrm << (sal_uInt8) GetMinLead()
199 		  << (sal_uInt8) GetMinTrail();
200 	return rStrm;
201 }
202 
203 
204