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