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