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