1*1d2dbeb0SAndrew Rist /************************************************************** 2*1d2dbeb0SAndrew Rist * 3*1d2dbeb0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*1d2dbeb0SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*1d2dbeb0SAndrew Rist * distributed with this work for additional information 6*1d2dbeb0SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*1d2dbeb0SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*1d2dbeb0SAndrew Rist * "License"); you may not use this file except in compliance 9*1d2dbeb0SAndrew Rist * with the License. You may obtain a copy of the License at 10*1d2dbeb0SAndrew Rist * 11*1d2dbeb0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*1d2dbeb0SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*1d2dbeb0SAndrew Rist * software distributed under the License is distributed on an 15*1d2dbeb0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*1d2dbeb0SAndrew Rist * KIND, either express or implied. See the License for the 17*1d2dbeb0SAndrew Rist * specific language governing permissions and limitations 18*1d2dbeb0SAndrew Rist * under the License. 19*1d2dbeb0SAndrew Rist * 20*1d2dbeb0SAndrew Rist *************************************************************/ 21*1d2dbeb0SAndrew Rist 22*1d2dbeb0SAndrew Rist 23cdf0e10cSrcweir #ifndef _SPLARGS_HXX 24cdf0e10cSrcweir #define _SPLARGS_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <i18npool/lang.h> 27cdf0e10cSrcweir #include <tools/solar.h> 28cdf0e10cSrcweir #include <tools/gen.hxx> 29cdf0e10cSrcweir #include <limits.h> // USHRT_MAX 30cdf0e10cSrcweir #include <tools/string.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir class SwTxtNode; 33cdf0e10cSrcweir class SwIndex; 34cdf0e10cSrcweir class SpellCheck; 35cdf0e10cSrcweir class Font; 36cdf0e10cSrcweir #include <com/sun/star/linguistic2/XSpellAlternatives.hpp> 37cdf0e10cSrcweir #include <com/sun/star/linguistic2/XSpellChecker1.hpp> 38cdf0e10cSrcweir #include <com/sun/star/linguistic2/XHyphenatedWord.hpp> 39cdf0e10cSrcweir 40cdf0e10cSrcweir /************************************************************************* 41cdf0e10cSrcweir * struct SwArgsBase 42cdf0e10cSrcweir *************************************************************************/ 43cdf0e10cSrcweir 44cdf0e10cSrcweir 45cdf0e10cSrcweir struct SwArgsBase // used for text conversion (Hangul/Hanja, ...) 46cdf0e10cSrcweir { 47cdf0e10cSrcweir SwTxtNode *pStartNode; 48cdf0e10cSrcweir SwIndex *pStartIdx; 49cdf0e10cSrcweir SwTxtNode *pEndNode; 50cdf0e10cSrcweir SwIndex *pEndIdx; 51cdf0e10cSrcweir SwArgsBaseSwArgsBase52cdf0e10cSrcweir SwArgsBase( 53cdf0e10cSrcweir SwTxtNode* pStart, SwIndex& rStart, 54cdf0e10cSrcweir SwTxtNode* pEnd, SwIndex& rEnd ) 55cdf0e10cSrcweir : pStartNode( pStart ), pStartIdx( &rStart ), 56cdf0e10cSrcweir pEndNode( pEnd ), pEndIdx( &rEnd ) 57cdf0e10cSrcweir {} 58cdf0e10cSrcweir SetStartSwArgsBase59cdf0e10cSrcweir void SetStart(SwTxtNode* pStart, SwIndex& rStart ) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir pStartNode = pStart; pStartIdx = &rStart ; 62cdf0e10cSrcweir } 63cdf0e10cSrcweir SetEndSwArgsBase64cdf0e10cSrcweir void SetEnd( SwTxtNode* pEnd, SwIndex& rEnd ) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir pEndNode = pEnd; pEndIdx = &rEnd ; 67cdf0e10cSrcweir } 68cdf0e10cSrcweir }; 69cdf0e10cSrcweir 70cdf0e10cSrcweir /************************************************************************* 71cdf0e10cSrcweir * struct SwConversionArgs 72cdf0e10cSrcweir * used for text conversion (Hangul/Hanja, Simplified/Traditional Chinese, ...) 73cdf0e10cSrcweir *************************************************************************/ 74cdf0e10cSrcweir 75cdf0e10cSrcweir struct SwConversionArgs : SwArgsBase 76cdf0e10cSrcweir { 77cdf0e10cSrcweir rtl::OUString aConvText; // convertible text found 78cdf0e10cSrcweir LanguageType nConvSrcLang; // (source) language to look for 79cdf0e10cSrcweir LanguageType nConvTextLang; // language of aConvText (if the latter one was found) 80cdf0e10cSrcweir 81cdf0e10cSrcweir // used for chinese translation 82cdf0e10cSrcweir LanguageType nConvTargetLang; // target language of text to be changed 83cdf0e10cSrcweir const Font *pTargetFont; // target font of text to be changed 84cdf0e10cSrcweir // explicitly enables or disables application of the above two 85cdf0e10cSrcweir sal_Bool bAllowImplicitChangesForNotConvertibleText; 86cdf0e10cSrcweir SwConversionArgsSwConversionArgs87cdf0e10cSrcweir SwConversionArgs( LanguageType nLang, 88cdf0e10cSrcweir SwTxtNode* pStart, SwIndex& rStart, 89cdf0e10cSrcweir SwTxtNode* pEnd, SwIndex& rEnd ) 90cdf0e10cSrcweir : SwArgsBase( pStart, rStart, pEnd, rEnd ), 91cdf0e10cSrcweir nConvSrcLang( nLang ), 92cdf0e10cSrcweir nConvTextLang( LANGUAGE_NONE ), 93cdf0e10cSrcweir nConvTargetLang( LANGUAGE_NONE ), 94cdf0e10cSrcweir pTargetFont( NULL ), 95cdf0e10cSrcweir bAllowImplicitChangesForNotConvertibleText( sal_False ) 96cdf0e10cSrcweir {} 97cdf0e10cSrcweir }; 98cdf0e10cSrcweir 99cdf0e10cSrcweir /************************************************************************* 100cdf0e10cSrcweir * struct SwSpellArgs 101cdf0e10cSrcweir *************************************************************************/ 102cdf0e10cSrcweir 103cdf0e10cSrcweir struct SwSpellArgs : SwArgsBase 104cdf0e10cSrcweir { 105cdf0e10cSrcweir ::com::sun::star::uno::Reference< 106cdf0e10cSrcweir ::com::sun::star::linguistic2::XSpellChecker1 > xSpeller; 107cdf0e10cSrcweir 108cdf0e10cSrcweir ::com::sun::star::uno::Reference< 109cdf0e10cSrcweir ::com::sun::star::linguistic2::XSpellAlternatives > xSpellAlt; 110cdf0e10cSrcweir 111cdf0e10cSrcweir bool bIsGrammarCheck; 112cdf0e10cSrcweir SwSpellArgsSwSpellArgs113cdf0e10cSrcweir SwSpellArgs(::com::sun::star::uno::Reference< 114cdf0e10cSrcweir ::com::sun::star::linguistic2::XSpellChecker1 > &rxSplChk, 115cdf0e10cSrcweir SwTxtNode* pStart, SwIndex& rStart, 116cdf0e10cSrcweir SwTxtNode* pEnd, SwIndex& rEnd, 117cdf0e10cSrcweir bool bGrammar ) 118cdf0e10cSrcweir : SwArgsBase( pStart, rStart, pEnd, rEnd ), 119cdf0e10cSrcweir xSpeller( rxSplChk ), 120cdf0e10cSrcweir bIsGrammarCheck( bGrammar ) 121cdf0e10cSrcweir {} 122cdf0e10cSrcweir }; 123cdf0e10cSrcweir 124cdf0e10cSrcweir /************************************************************************* 125cdf0e10cSrcweir * class SwInterHyphInfo 126cdf0e10cSrcweir *************************************************************************/ 127cdf0e10cSrcweir 128cdf0e10cSrcweir // Parameter-Klasse fuer Hyphenate 129cdf0e10cSrcweir // docedt.cxx: SwDoc::Hyphenate() 130cdf0e10cSrcweir // txtedt.cxx: SwTxtNode::Hyphenate() 131cdf0e10cSrcweir // txthyph.cxx: SwTxtFrm::Hyphenate() 132cdf0e10cSrcweir 133cdf0e10cSrcweir class SwInterHyphInfo 134cdf0e10cSrcweir { 135cdf0e10cSrcweir ::com::sun::star::uno::Reference< 136cdf0e10cSrcweir ::com::sun::star::linguistic2::XHyphenatedWord > xHyphWord; 137cdf0e10cSrcweir const Point aCrsrPos; 138cdf0e10cSrcweir sal_Bool bAuto : 1; 139cdf0e10cSrcweir sal_Bool bNoLang : 1; 140cdf0e10cSrcweir sal_Bool bCheck : 1; 141cdf0e10cSrcweir public: 142cdf0e10cSrcweir xub_StrLen nStart; 143cdf0e10cSrcweir xub_StrLen nLen; 144cdf0e10cSrcweir xub_StrLen nWordStart; 145cdf0e10cSrcweir xub_StrLen nWordLen; 146cdf0e10cSrcweir xub_StrLen nHyphPos; 147cdf0e10cSrcweir sal_uInt16 nMinTrail; 148cdf0e10cSrcweir SwInterHyphInfo(const Point & rCrsrPos,const sal_uInt16 nStartPos=0,const sal_uInt16 nLength=USHRT_MAX)149cdf0e10cSrcweir inline SwInterHyphInfo( const Point &rCrsrPos, 150cdf0e10cSrcweir const sal_uInt16 nStartPos = 0, 151cdf0e10cSrcweir const sal_uInt16 nLength = USHRT_MAX ) 152cdf0e10cSrcweir : aCrsrPos( rCrsrPos ), 153cdf0e10cSrcweir bAuto(sal_False), bNoLang(sal_False), bCheck(sal_False), 154cdf0e10cSrcweir nStart(nStartPos), nLen(nLength), 155cdf0e10cSrcweir nWordStart(0), nWordLen(0), 156cdf0e10cSrcweir nHyphPos(0), nMinTrail(0) 157cdf0e10cSrcweir { } GetEnd() const158cdf0e10cSrcweir inline xub_StrLen GetEnd() const 159cdf0e10cSrcweir { return STRING_LEN == nLen ? nLen : nStart + nLen; } GetCrsrPos() const160cdf0e10cSrcweir inline const Point *GetCrsrPos() const 161cdf0e10cSrcweir { return aCrsrPos.X() || aCrsrPos.Y() ? &aCrsrPos : 0; } IsCheck() const162cdf0e10cSrcweir inline sal_Bool IsCheck() const { return bCheck; } SetCheck(const sal_Bool bNew)163cdf0e10cSrcweir inline void SetCheck( const sal_Bool bNew ) { bCheck = bNew; } SetNoLang(const sal_Bool bNew)164cdf0e10cSrcweir inline void SetNoLang( const sal_Bool bNew ) { bNoLang = bNew; } 165cdf0e10cSrcweir 166cdf0e10cSrcweir inline void SetHyphWord(const::com::sun::star::uno::Reference<::com::sun::star::linguistic2::XHyphenatedWord> & rxHW)167cdf0e10cSrcweir SetHyphWord(const ::com::sun::star::uno::Reference< 168cdf0e10cSrcweir ::com::sun::star::linguistic2::XHyphenatedWord > &rxHW) 169cdf0e10cSrcweir { xHyphWord = rxHW; } 170cdf0e10cSrcweir inline ::com::sun::star::uno::Reference< 171cdf0e10cSrcweir ::com::sun::star::linguistic2::XHyphenatedWord > GetHyphWord()172cdf0e10cSrcweir GetHyphWord() { return xHyphWord; } 173cdf0e10cSrcweir }; 174cdf0e10cSrcweir 175cdf0e10cSrcweir 176cdf0e10cSrcweir #endif 177