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