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 #ifndef _SPLARGS_HXX 28*cdf0e10cSrcweir #define _SPLARGS_HXX 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #include <i18npool/lang.h> 31*cdf0e10cSrcweir #include <tools/solar.h> 32*cdf0e10cSrcweir #include <tools/gen.hxx> 33*cdf0e10cSrcweir #include <limits.h> // USHRT_MAX 34*cdf0e10cSrcweir #include <tools/string.hxx> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir class SwTxtNode; 37*cdf0e10cSrcweir class SwIndex; 38*cdf0e10cSrcweir class SpellCheck; 39*cdf0e10cSrcweir class Font; 40*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XSpellAlternatives.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XSpellChecker1.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XHyphenatedWord.hpp> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir /************************************************************************* 45*cdf0e10cSrcweir * struct SwArgsBase 46*cdf0e10cSrcweir *************************************************************************/ 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir struct SwArgsBase // used for text conversion (Hangul/Hanja, ...) 50*cdf0e10cSrcweir { 51*cdf0e10cSrcweir SwTxtNode *pStartNode; 52*cdf0e10cSrcweir SwIndex *pStartIdx; 53*cdf0e10cSrcweir SwTxtNode *pEndNode; 54*cdf0e10cSrcweir SwIndex *pEndIdx; 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir SwArgsBase( 57*cdf0e10cSrcweir SwTxtNode* pStart, SwIndex& rStart, 58*cdf0e10cSrcweir SwTxtNode* pEnd, SwIndex& rEnd ) 59*cdf0e10cSrcweir : pStartNode( pStart ), pStartIdx( &rStart ), 60*cdf0e10cSrcweir pEndNode( pEnd ), pEndIdx( &rEnd ) 61*cdf0e10cSrcweir {} 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir void SetStart(SwTxtNode* pStart, SwIndex& rStart ) 64*cdf0e10cSrcweir { 65*cdf0e10cSrcweir pStartNode = pStart; pStartIdx = &rStart ; 66*cdf0e10cSrcweir } 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir void SetEnd( SwTxtNode* pEnd, SwIndex& rEnd ) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir pEndNode = pEnd; pEndIdx = &rEnd ; 71*cdf0e10cSrcweir } 72*cdf0e10cSrcweir }; 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir /************************************************************************* 75*cdf0e10cSrcweir * struct SwConversionArgs 76*cdf0e10cSrcweir * used for text conversion (Hangul/Hanja, Simplified/Traditional Chinese, ...) 77*cdf0e10cSrcweir *************************************************************************/ 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir struct SwConversionArgs : SwArgsBase 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir rtl::OUString aConvText; // convertible text found 82*cdf0e10cSrcweir LanguageType nConvSrcLang; // (source) language to look for 83*cdf0e10cSrcweir LanguageType nConvTextLang; // language of aConvText (if the latter one was found) 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir // used for chinese translation 86*cdf0e10cSrcweir LanguageType nConvTargetLang; // target language of text to be changed 87*cdf0e10cSrcweir const Font *pTargetFont; // target font of text to be changed 88*cdf0e10cSrcweir // explicitly enables or disables application of the above two 89*cdf0e10cSrcweir sal_Bool bAllowImplicitChangesForNotConvertibleText; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir SwConversionArgs( LanguageType nLang, 92*cdf0e10cSrcweir SwTxtNode* pStart, SwIndex& rStart, 93*cdf0e10cSrcweir SwTxtNode* pEnd, SwIndex& rEnd ) 94*cdf0e10cSrcweir : SwArgsBase( pStart, rStart, pEnd, rEnd ), 95*cdf0e10cSrcweir nConvSrcLang( nLang ), 96*cdf0e10cSrcweir nConvTextLang( LANGUAGE_NONE ), 97*cdf0e10cSrcweir nConvTargetLang( LANGUAGE_NONE ), 98*cdf0e10cSrcweir pTargetFont( NULL ), 99*cdf0e10cSrcweir bAllowImplicitChangesForNotConvertibleText( sal_False ) 100*cdf0e10cSrcweir {} 101*cdf0e10cSrcweir }; 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir /************************************************************************* 104*cdf0e10cSrcweir * struct SwSpellArgs 105*cdf0e10cSrcweir *************************************************************************/ 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir struct SwSpellArgs : SwArgsBase 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 110*cdf0e10cSrcweir ::com::sun::star::linguistic2::XSpellChecker1 > xSpeller; 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 113*cdf0e10cSrcweir ::com::sun::star::linguistic2::XSpellAlternatives > xSpellAlt; 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir bool bIsGrammarCheck; 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir SwSpellArgs(::com::sun::star::uno::Reference< 118*cdf0e10cSrcweir ::com::sun::star::linguistic2::XSpellChecker1 > &rxSplChk, 119*cdf0e10cSrcweir SwTxtNode* pStart, SwIndex& rStart, 120*cdf0e10cSrcweir SwTxtNode* pEnd, SwIndex& rEnd, 121*cdf0e10cSrcweir bool bGrammar ) 122*cdf0e10cSrcweir : SwArgsBase( pStart, rStart, pEnd, rEnd ), 123*cdf0e10cSrcweir xSpeller( rxSplChk ), 124*cdf0e10cSrcweir bIsGrammarCheck( bGrammar ) 125*cdf0e10cSrcweir {} 126*cdf0e10cSrcweir }; 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir /************************************************************************* 129*cdf0e10cSrcweir * class SwInterHyphInfo 130*cdf0e10cSrcweir *************************************************************************/ 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir // Parameter-Klasse fuer Hyphenate 133*cdf0e10cSrcweir // docedt.cxx: SwDoc::Hyphenate() 134*cdf0e10cSrcweir // txtedt.cxx: SwTxtNode::Hyphenate() 135*cdf0e10cSrcweir // txthyph.cxx: SwTxtFrm::Hyphenate() 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir class SwInterHyphInfo 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 140*cdf0e10cSrcweir ::com::sun::star::linguistic2::XHyphenatedWord > xHyphWord; 141*cdf0e10cSrcweir const Point aCrsrPos; 142*cdf0e10cSrcweir sal_Bool bAuto : 1; 143*cdf0e10cSrcweir sal_Bool bNoLang : 1; 144*cdf0e10cSrcweir sal_Bool bCheck : 1; 145*cdf0e10cSrcweir public: 146*cdf0e10cSrcweir xub_StrLen nStart; 147*cdf0e10cSrcweir xub_StrLen nLen; 148*cdf0e10cSrcweir xub_StrLen nWordStart; 149*cdf0e10cSrcweir xub_StrLen nWordLen; 150*cdf0e10cSrcweir xub_StrLen nHyphPos; 151*cdf0e10cSrcweir sal_uInt16 nMinTrail; 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir inline SwInterHyphInfo( const Point &rCrsrPos, 154*cdf0e10cSrcweir const sal_uInt16 nStartPos = 0, 155*cdf0e10cSrcweir const sal_uInt16 nLength = USHRT_MAX ) 156*cdf0e10cSrcweir : aCrsrPos( rCrsrPos ), 157*cdf0e10cSrcweir bAuto(sal_False), bNoLang(sal_False), bCheck(sal_False), 158*cdf0e10cSrcweir nStart(nStartPos), nLen(nLength), 159*cdf0e10cSrcweir nWordStart(0), nWordLen(0), 160*cdf0e10cSrcweir nHyphPos(0), nMinTrail(0) 161*cdf0e10cSrcweir { } 162*cdf0e10cSrcweir inline xub_StrLen GetEnd() const 163*cdf0e10cSrcweir { return STRING_LEN == nLen ? nLen : nStart + nLen; } 164*cdf0e10cSrcweir inline const Point *GetCrsrPos() const 165*cdf0e10cSrcweir { return aCrsrPos.X() || aCrsrPos.Y() ? &aCrsrPos : 0; } 166*cdf0e10cSrcweir inline sal_Bool IsCheck() const { return bCheck; } 167*cdf0e10cSrcweir inline void SetCheck( const sal_Bool bNew ) { bCheck = bNew; } 168*cdf0e10cSrcweir inline void SetNoLang( const sal_Bool bNew ) { bNoLang = bNew; } 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir inline void 171*cdf0e10cSrcweir SetHyphWord(const ::com::sun::star::uno::Reference< 172*cdf0e10cSrcweir ::com::sun::star::linguistic2::XHyphenatedWord > &rxHW) 173*cdf0e10cSrcweir { xHyphWord = rxHW; } 174*cdf0e10cSrcweir inline ::com::sun::star::uno::Reference< 175*cdf0e10cSrcweir ::com::sun::star::linguistic2::XHyphenatedWord > 176*cdf0e10cSrcweir GetHyphWord() { return xHyphWord; } 177*cdf0e10cSrcweir }; 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir #endif 181