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