update dev300-m57
[ooovba.git] / sw / inc / splargs.hxx
bloba91a3686bc1413bb65d47b1d2ce22e0a2c45d4c3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: splargs.hxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SPLARGS_HXX
31 #define _SPLARGS_HXX
33 #include <i18npool/lang.h>
34 #include <tools/solar.h>
35 #include <tools/gen.hxx>
36 #include <limits.h> // USHRT_MAX
37 #include <tools/string.hxx>
39 class SwTxtNode;
40 class SwIndex;
41 class SpellCheck;
42 class Font;
43 #include <com/sun/star/linguistic2/XSpellAlternatives.hpp>
44 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
45 #include <com/sun/star/linguistic2/XHyphenatedWord.hpp>
47 /*************************************************************************
48 * struct SwArgsBase
49 *************************************************************************/
52 struct SwArgsBase // used for text conversion (Hangul/Hanja, ...)
54 SwTxtNode *pStartNode;
55 SwIndex *pStartIdx;
56 SwTxtNode *pEndNode;
57 SwIndex *pEndIdx;
59 SwArgsBase(
60 SwTxtNode* pStart, SwIndex& rStart,
61 SwTxtNode* pEnd, SwIndex& rEnd )
62 : pStartNode( pStart ), pStartIdx( &rStart ),
63 pEndNode( pEnd ), pEndIdx( &rEnd )
66 void SetStart(SwTxtNode* pStart, SwIndex& rStart )
68 pStartNode = pStart; pStartIdx = &rStart ;
71 void SetEnd( SwTxtNode* pEnd, SwIndex& rEnd )
73 pEndNode = pEnd; pEndIdx = &rEnd ;
77 /*************************************************************************
78 * struct SwConversionArgs
79 * used for text conversion (Hangul/Hanja, Simplified/Traditional Chinese, ...)
80 *************************************************************************/
82 struct SwConversionArgs : SwArgsBase
84 rtl::OUString aConvText; // convertible text found
85 LanguageType nConvSrcLang; // (source) language to look for
86 LanguageType nConvTextLang; // language of aConvText (if the latter one was found)
88 // used for chinese translation
89 LanguageType nConvTargetLang; // target language of text to be changed
90 const Font *pTargetFont; // target font of text to be changed
91 // explicitly enables or disables application of the above two
92 sal_Bool bAllowImplicitChangesForNotConvertibleText;
94 SwConversionArgs( LanguageType nLang,
95 SwTxtNode* pStart, SwIndex& rStart,
96 SwTxtNode* pEnd, SwIndex& rEnd )
97 : SwArgsBase( pStart, rStart, pEnd, rEnd ),
98 nConvSrcLang( nLang ),
99 nConvTextLang( LANGUAGE_NONE ),
100 nConvTargetLang( LANGUAGE_NONE ),
101 pTargetFont( NULL ),
102 bAllowImplicitChangesForNotConvertibleText( sal_False )
106 /*************************************************************************
107 * struct SwSpellArgs
108 *************************************************************************/
110 struct SwSpellArgs : SwArgsBase
112 ::com::sun::star::uno::Reference<
113 ::com::sun::star::linguistic2::XSpellChecker1 > xSpeller;
115 ::com::sun::star::uno::Reference<
116 ::com::sun::star::linguistic2::XSpellAlternatives > xSpellAlt;
118 bool bIsGrammarCheck;
120 SwSpellArgs(::com::sun::star::uno::Reference<
121 ::com::sun::star::linguistic2::XSpellChecker1 > &rxSplChk,
122 SwTxtNode* pStart, SwIndex& rStart,
123 SwTxtNode* pEnd, SwIndex& rEnd,
124 bool bGrammar )
125 : SwArgsBase( pStart, rStart, pEnd, rEnd ),
126 xSpeller( rxSplChk ),
127 bIsGrammarCheck( bGrammar )
131 /*************************************************************************
132 * class SwInterHyphInfo
133 *************************************************************************/
135 // Parameter-Klasse fuer Hyphenate
136 // docedt.cxx: SwDoc::Hyphenate()
137 // txtedt.cxx: SwTxtNode::Hyphenate()
138 // txthyph.cxx: SwTxtFrm::Hyphenate()
140 class SwInterHyphInfo
142 ::com::sun::star::uno::Reference<
143 ::com::sun::star::linguistic2::XHyphenatedWord > xHyphWord;
144 const Point aCrsrPos;
145 sal_Bool bAuto : 1;
146 sal_Bool bNoLang : 1;
147 sal_Bool bCheck : 1;
148 public:
149 xub_StrLen nStart;
150 xub_StrLen nLen;
151 xub_StrLen nWordStart;
152 xub_StrLen nWordLen;
153 xub_StrLen nHyphPos;
154 sal_uInt16 nMinTrail;
156 inline SwInterHyphInfo( const Point &rCrsrPos,
157 const sal_uInt16 nStartPos = 0,
158 const sal_uInt16 nLength = USHRT_MAX )
159 : aCrsrPos( rCrsrPos ),
160 bAuto(sal_False), bNoLang(sal_False), bCheck(sal_False),
161 nStart(nStartPos), nLen(nLength),
162 nWordStart(0), nWordLen(0),
163 nHyphPos(0), nMinTrail(0)
165 inline xub_StrLen GetEnd() const
166 { return STRING_LEN == nLen ? nLen : nStart + nLen; }
167 inline const Point *GetCrsrPos() const
168 { return aCrsrPos.X() || aCrsrPos.Y() ? &aCrsrPos : 0; }
169 inline sal_Bool IsCheck() const { return bCheck; }
170 inline void SetCheck( const sal_Bool bNew ) { bCheck = bNew; }
171 inline void SetNoLang( const sal_Bool bNew ) { bNoLang = bNew; }
173 inline void
174 SetHyphWord(const ::com::sun::star::uno::Reference<
175 ::com::sun::star::linguistic2::XHyphenatedWord > &rxHW)
176 { xHyphWord = rxHW; }
177 inline ::com::sun::star::uno::Reference<
178 ::com::sun::star::linguistic2::XHyphenatedWord >
179 GetHyphWord() { return xHyphWord; }
183 #endif