bump product version to 4.1.6.2
[LibreOffice.git] / sw / inc / splargs.hxx
blob2c7d6af110b01f6996afb095fce59c980d5cd8d8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _SPLARGS_HXX
20 #define _SPLARGS_HXX
22 #include <i18nlangtag/lang.h>
23 #include <tools/solar.h>
24 #include <tools/gen.hxx>
25 #include <limits.h> // USHRT_MAX
27 class SwTxtNode;
28 class SwIndex;
29 class Font;
30 #include <com/sun/star/linguistic2/XSpellAlternatives.hpp>
31 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
32 #include <com/sun/star/linguistic2/XHyphenatedWord.hpp>
34 /*************************************************************************
35 * struct SwArgsBase
36 *************************************************************************/
39 struct SwArgsBase // used for text conversion (Hangul/Hanja, ...)
41 SwTxtNode *pStartNode;
42 SwIndex *pStartIdx;
43 SwTxtNode *pEndNode;
44 SwIndex *pEndIdx;
46 SwArgsBase(
47 SwTxtNode* pStart, SwIndex& rStart,
48 SwTxtNode* pEnd, SwIndex& rEnd )
49 : pStartNode( pStart ), pStartIdx( &rStart ),
50 pEndNode( pEnd ), pEndIdx( &rEnd )
53 void SetStart(SwTxtNode* pStart, SwIndex& rStart )
55 pStartNode = pStart; pStartIdx = &rStart ;
58 void SetEnd( SwTxtNode* pEnd, SwIndex& rEnd )
60 pEndNode = pEnd; pEndIdx = &rEnd ;
64 /*************************************************************************
65 * struct SwConversionArgs
66 * used for text conversion (Hangul/Hanja, Simplified/Traditional Chinese, ...)
67 *************************************************************************/
69 struct SwConversionArgs : SwArgsBase
71 OUString aConvText; // convertible text found
72 LanguageType nConvSrcLang; // (source) language to look for
73 LanguageType nConvTextLang; // language of aConvText (if the latter one was found)
75 // used for chinese translation
76 LanguageType nConvTargetLang; // target language of text to be changed
77 const Font *pTargetFont; // target font of text to be changed
78 // explicitly enables or disables application of the above two
79 bool bAllowImplicitChangesForNotConvertibleText;
81 SwConversionArgs( LanguageType nLang,
82 SwTxtNode* pStart, SwIndex& rStart,
83 SwTxtNode* pEnd, SwIndex& rEnd )
84 : SwArgsBase( pStart, rStart, pEnd, rEnd ),
85 nConvSrcLang( nLang ),
86 nConvTextLang( LANGUAGE_NONE ),
87 nConvTargetLang( LANGUAGE_NONE ),
88 pTargetFont( NULL ),
89 bAllowImplicitChangesForNotConvertibleText( false )
93 /*************************************************************************
94 * struct SwSpellArgs
95 *************************************************************************/
97 struct SwSpellArgs : SwArgsBase
99 ::com::sun::star::uno::Reference<
100 ::com::sun::star::linguistic2::XSpellChecker1 > xSpeller;
102 ::com::sun::star::uno::Reference<
103 ::com::sun::star::linguistic2::XSpellAlternatives > xSpellAlt;
105 bool bIsGrammarCheck;
107 SwSpellArgs(::com::sun::star::uno::Reference<
108 ::com::sun::star::linguistic2::XSpellChecker1 > &rxSplChk,
109 SwTxtNode* pStart, SwIndex& rStart,
110 SwTxtNode* pEnd, SwIndex& rEnd,
111 bool bGrammar )
112 : SwArgsBase( pStart, rStart, pEnd, rEnd ),
113 xSpeller( rxSplChk ),
114 bIsGrammarCheck( bGrammar )
118 /*************************************************************************
119 * class SwInterHyphInfo
120 *************************************************************************/
122 // Parameter-class for Hyphenate.
123 // docedt.cxx: SwDoc::Hyphenate()
124 // txtedt.cxx: SwTxtNode::Hyphenate()
125 // txthyph.cxx: SwTxtFrm::Hyphenate()
127 class SwInterHyphInfo
129 ::com::sun::star::uno::Reference<
130 ::com::sun::star::linguistic2::XHyphenatedWord > xHyphWord;
131 const Point aCrsrPos;
132 sal_Bool bNoLang : 1;
133 sal_Bool bCheck : 1;
134 public:
135 xub_StrLen nStart;
136 xub_StrLen nLen;
137 xub_StrLen nWordStart;
138 xub_StrLen nWordLen;
139 xub_StrLen nHyphPos;
140 sal_uInt16 nMinTrail;
142 inline SwInterHyphInfo( const Point &rCrsrPos,
143 const sal_uInt16 nStartPos = 0,
144 const sal_uInt16 nLength = USHRT_MAX )
145 : aCrsrPos( rCrsrPos ),
146 bNoLang(sal_False), bCheck(sal_False),
147 nStart(nStartPos), nLen(nLength),
148 nWordStart(0), nWordLen(0),
149 nHyphPos(0), nMinTrail(0)
151 inline xub_StrLen GetEnd() const
152 { return STRING_LEN == nLen ? nLen : nStart + nLen; }
153 inline const Point *GetCrsrPos() const
154 { return aCrsrPos.X() || aCrsrPos.Y() ? &aCrsrPos : 0; }
155 inline sal_Bool IsCheck() const { return bCheck; }
156 inline void SetCheck( const sal_Bool bNew ) { bCheck = bNew; }
157 inline void SetNoLang( const sal_Bool bNew ) { bNoLang = bNew; }
159 inline void
160 SetHyphWord(const ::com::sun::star::uno::Reference<
161 ::com::sun::star::linguistic2::XHyphenatedWord > &rxHW)
162 { xHyphWord = rxHW; }
163 inline ::com::sun::star::uno::Reference<
164 ::com::sun::star::linguistic2::XHyphenatedWord >
165 GetHyphWord() { return xHyphWord; }
169 #endif
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */