Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : : #ifndef _SPLARGS_HXX
20 : : #define _SPLARGS_HXX
21 : :
22 : : #include <i18npool/lang.h>
23 : : #include <tools/solar.h>
24 : : #include <tools/gen.hxx>
25 : : #include <limits.h> // USHRT_MAX
26 : :
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>
33 : :
34 : : /*************************************************************************
35 : : * struct SwArgsBase
36 : : *************************************************************************/
37 : :
38 : :
39 : : struct SwArgsBase // used for text conversion (Hangul/Hanja, ...)
40 : : {
41 : : SwTxtNode *pStartNode;
42 : : SwIndex *pStartIdx;
43 : : SwTxtNode *pEndNode;
44 : : SwIndex *pEndIdx;
45 : :
46 : 0 : SwArgsBase(
47 : : SwTxtNode* pStart, SwIndex& rStart,
48 : : SwTxtNode* pEnd, SwIndex& rEnd )
49 : : : pStartNode( pStart ), pStartIdx( &rStart ),
50 : 0 : pEndNode( pEnd ), pEndIdx( &rEnd )
51 : 0 : {}
52 : :
53 : 0 : void SetStart(SwTxtNode* pStart, SwIndex& rStart )
54 : : {
55 : 0 : pStartNode = pStart; pStartIdx = &rStart ;
56 : 0 : }
57 : :
58 : 0 : void SetEnd( SwTxtNode* pEnd, SwIndex& rEnd )
59 : : {
60 : 0 : pEndNode = pEnd; pEndIdx = &rEnd ;
61 : 0 : }
62 : : };
63 : :
64 : : /*************************************************************************
65 : : * struct SwConversionArgs
66 : : * used for text conversion (Hangul/Hanja, Simplified/Traditional Chinese, ...)
67 : : *************************************************************************/
68 : :
69 : 0 : struct SwConversionArgs : SwArgsBase
70 : : {
71 : : rtl::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)
74 : :
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 : : sal_Bool bAllowImplicitChangesForNotConvertibleText;
80 : :
81 : 0 : 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 : 0 : bAllowImplicitChangesForNotConvertibleText( sal_False )
90 : 0 : {}
91 : : };
92 : :
93 : : /*************************************************************************
94 : : * struct SwSpellArgs
95 : : *************************************************************************/
96 : :
97 : 0 : struct SwSpellArgs : SwArgsBase
98 : : {
99 : : ::com::sun::star::uno::Reference<
100 : : ::com::sun::star::linguistic2::XSpellChecker1 > xSpeller;
101 : :
102 : : ::com::sun::star::uno::Reference<
103 : : ::com::sun::star::linguistic2::XSpellAlternatives > xSpellAlt;
104 : :
105 : : bool bIsGrammarCheck;
106 : :
107 : 0 : 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 : 0 : bIsGrammarCheck( bGrammar )
115 : 0 : {}
116 : : };
117 : :
118 : : /*************************************************************************
119 : : * class SwInterHyphInfo
120 : : *************************************************************************/
121 : :
122 : : // Parameter-class for Hyphenate.
123 : : // docedt.cxx: SwDoc::Hyphenate()
124 : : // txtedt.cxx: SwTxtNode::Hyphenate()
125 : : // txthyph.cxx: SwTxtFrm::Hyphenate()
126 : :
127 : 0 : class SwInterHyphInfo
128 : : {
129 : : ::com::sun::star::uno::Reference<
130 : : ::com::sun::star::linguistic2::XHyphenatedWord > xHyphWord;
131 : : const Point aCrsrPos;
132 : : sal_Bool bAuto : 1;
133 : : sal_Bool bNoLang : 1;
134 : : sal_Bool bCheck : 1;
135 : : public:
136 : : xub_StrLen nStart;
137 : : xub_StrLen nLen;
138 : : xub_StrLen nWordStart;
139 : : xub_StrLen nWordLen;
140 : : xub_StrLen nHyphPos;
141 : : sal_uInt16 nMinTrail;
142 : :
143 : 0 : inline SwInterHyphInfo( const Point &rCrsrPos,
144 : : const sal_uInt16 nStartPos = 0,
145 : : const sal_uInt16 nLength = USHRT_MAX )
146 : : : aCrsrPos( rCrsrPos ),
147 : : bAuto(sal_False), bNoLang(sal_False), bCheck(sal_False),
148 : : nStart(nStartPos), nLen(nLength),
149 : : nWordStart(0), nWordLen(0),
150 : 0 : nHyphPos(0), nMinTrail(0)
151 : 0 : { }
152 : 0 : inline xub_StrLen GetEnd() const
153 [ # # ]: 0 : { return STRING_LEN == nLen ? nLen : nStart + nLen; }
154 : 0 : inline const Point *GetCrsrPos() const
155 [ # # ][ # # ]: 0 : { return aCrsrPos.X() || aCrsrPos.Y() ? &aCrsrPos : 0; }
156 : 0 : inline sal_Bool IsCheck() const { return bCheck; }
157 : 0 : inline void SetCheck( const sal_Bool bNew ) { bCheck = bNew; }
158 : 0 : inline void SetNoLang( const sal_Bool bNew ) { bNoLang = bNew; }
159 : :
160 : : inline void
161 : 0 : SetHyphWord(const ::com::sun::star::uno::Reference<
162 : : ::com::sun::star::linguistic2::XHyphenatedWord > &rxHW)
163 : 0 : { xHyphWord = rxHW; }
164 : : inline ::com::sun::star::uno::Reference<
165 : : ::com::sun::star::linguistic2::XHyphenatedWord >
166 : 0 : GetHyphWord() { return xHyphWord; }
167 : : };
168 : :
169 : :
170 : : #endif
171 : :
172 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|