1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_SW_INC_SPLARGS_HXX
20 #define INCLUDED_SW_INC_SPLARGS_HXX
22 #include <i18nlangtag/lang.h>
23 #include <tools/solar.h>
24 #include <tools/gen.hxx>
27 #include <com/sun/star/linguistic2/XSpellAlternatives.hpp>
28 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
29 #include <com/sun/star/linguistic2/XHyphenatedWord.hpp>
33 namespace vcl
{ class Font
; }
35 struct SwArgsBase
// used for text conversion (Hangul/Hanja, ...)
37 SwTextNode
*pStartNode
;
43 SwTextNode
* pStart
, SwIndex
& rStart
,
44 SwTextNode
* pEnd
, SwIndex
& rEnd
)
45 : pStartNode( pStart
), pStartIdx( &rStart
),
46 pEndNode( pEnd
), pEndIdx( &rEnd
)
49 void SetStart(SwTextNode
* pStart
, SwIndex
& rStart
)
51 pStartNode
= pStart
; pStartIdx
= &rStart
;
54 void SetEnd( SwTextNode
* pEnd
, SwIndex
& rEnd
)
56 pEndNode
= pEnd
; pEndIdx
= &rEnd
;
60 // used for text conversion (Hangul/Hanja, Simplified/Traditional Chinese, ...)
61 struct SwConversionArgs
: SwArgsBase
63 OUString aConvText
; // convertible text found
64 LanguageType nConvSrcLang
; // (source) language to look for
65 LanguageType nConvTextLang
; // language of aConvText (if the latter one was found)
67 // used for chinese translation
68 LanguageType nConvTargetLang
; // target language of text to be changed
69 const vcl::Font
*pTargetFont
; // target font of text to be changed
70 // explicitly enables or disables application of the above two
71 bool bAllowImplicitChangesForNotConvertibleText
;
73 SwConversionArgs( LanguageType nLang
,
74 SwTextNode
* pStart
, SwIndex
& rStart
,
75 SwTextNode
* pEnd
, SwIndex
& rEnd
)
76 : SwArgsBase( pStart
, rStart
, pEnd
, rEnd
),
77 nConvSrcLang( nLang
),
78 nConvTextLang( LANGUAGE_NONE
),
79 nConvTargetLang( LANGUAGE_NONE
),
81 bAllowImplicitChangesForNotConvertibleText( false )
85 struct SwSpellArgs
: SwArgsBase
87 ::com::sun::star::uno::Reference
<
88 ::com::sun::star::linguistic2::XSpellChecker1
> xSpeller
;
90 ::com::sun::star::uno::Reference
<
91 ::com::sun::star::linguistic2::XSpellAlternatives
> xSpellAlt
;
95 SwSpellArgs(::com::sun::star::uno::Reference
<
96 ::com::sun::star::linguistic2::XSpellChecker1
> &rxSplChk
,
97 SwTextNode
* pStart
, SwIndex
& rStart
,
98 SwTextNode
* pEnd
, SwIndex
& rEnd
,
100 : SwArgsBase( pStart
, rStart
, pEnd
, rEnd
),
101 xSpeller( rxSplChk
),
102 bIsGrammarCheck( bGrammar
)
106 // Parameter-class for Hyphenate.
107 // docedt.cxx: SwDoc::Hyphenate()
108 // txtedt.cxx: SwTextNode::Hyphenate()
109 // txthyph.cxx: SwTextFrm::Hyphenate()
111 class SwInterHyphInfo
113 css::uno::Reference
< css::linguistic2::XHyphenatedWord
> xHyphWord
;
114 const Point aCrsrPos
;
120 sal_Int32 nWordStart
;
123 sal_uInt16 nMinTrail
;
125 SwInterHyphInfo( const Point
&rCrsrPos
, sal_Int32 nStartPos
= 0,
126 sal_Int32 nLength
= SAL_MAX_INT32
)
131 , nEnd(nLength
== SAL_MAX_INT32
? SAL_MAX_INT32
: nStartPos
+ nLength
)
132 , nWordStart(0), nWordLen(0)
133 , nHyphPos(0), nMinTrail(0)
136 sal_Int32
GetEnd() const
140 const Point
*GetCrsrPos() const
142 return aCrsrPos
.X() || aCrsrPos
.Y() ? &aCrsrPos
: 0;
144 bool IsCheck() const { return bCheck
; }
145 void SetCheck( const bool bNew
) { bCheck
= bNew
; }
146 void SetNoLang( const bool bNew
) { bNoLang
= bNew
; }
147 void SetHyphWord(const css::uno::Reference
< css::linguistic2::XHyphenatedWord
> &rxHW
)
151 css::uno::Reference
< css::linguistic2::XHyphenatedWord
> GetHyphWord()
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */