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/gen.hxx>
25 #include <com/sun/star/linguistic2/XSpellAlternatives.hpp>
26 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
33 namespace vcl
{ class Font
; }
34 namespace com::sun::star::linguistic2
{ class XHyphenatedWord
; }
36 struct SwArgsBase
// used for text conversion (Hangul/Hanja, ...)
38 SwTextNode
*pStartNode
;
44 SwTextNode
* pStart
, SwIndex
& rStart
,
45 SwTextNode
* pEnd
, SwIndex
& rEnd
)
46 : pStartNode( pStart
), pStartIdx( &rStart
),
47 pEndNode( pEnd
), pEndIdx( &rEnd
)
50 void SetStart(SwTextNode
* pStart
, SwIndex
& rStart
)
52 pStartNode
= pStart
; pStartIdx
= &rStart
;
55 void SetEnd( SwTextNode
* pEnd
, SwIndex
& rEnd
)
57 pEndNode
= pEnd
; pEndIdx
= &rEnd
;
61 // used for text conversion (Hangul/Hanja, Simplified/Traditional Chinese, ...)
62 struct SwConversionArgs
: SwArgsBase
64 OUString aConvText
; // convertible text found
65 LanguageType nConvSrcLang
; // (source) language to look for
66 LanguageType nConvTextLang
; // language of aConvText (if the latter one was found)
68 // used for chinese translation
69 LanguageType nConvTargetLang
; // target language of text to be changed
70 const vcl::Font
*pTargetFont
; // target font of text to be changed
71 // explicitly enables or disables application of the above two
72 bool bAllowImplicitChangesForNotConvertibleText
;
74 SwConversionArgs( LanguageType nLang
,
75 SwTextNode
* pStart
, SwIndex
& rStart
,
76 SwTextNode
* pEnd
, SwIndex
& rEnd
)
77 : SwArgsBase( pStart
, rStart
, pEnd
, rEnd
),
78 nConvSrcLang( nLang
),
79 nConvTextLang( LANGUAGE_NONE
),
80 nConvTargetLang( LANGUAGE_NONE
),
81 pTargetFont( nullptr ),
82 bAllowImplicitChangesForNotConvertibleText( false )
86 struct SwSpellArgs
: SwArgsBase
88 css::uno::Reference
< css::linguistic2::XSpellChecker1
> xSpeller
;
90 css::uno::Reference
< css::linguistic2::XSpellAlternatives
> xSpellAlt
;
94 SwSpellArgs(css::uno::Reference
<
95 css::linguistic2::XSpellChecker1
> const &rxSplChk
,
96 SwTextNode
* pStart
, SwIndex
& rStart
,
97 SwTextNode
* pEnd
, SwIndex
& rEnd
,
99 : SwArgsBase( pStart
, rStart
, pEnd
, rEnd
),
100 xSpeller( rxSplChk
),
101 bIsGrammarCheck( bGrammar
)
105 // Parameter-class for Hyphenate.
106 // docedt.cxx: SwDoc::Hyphenate()
107 // txtedt.cxx: SwTextNode::Hyphenate()
108 // txthyph.cxx: SwTextFrame::Hyphenate()
110 class SwInterHyphInfo
112 /// output: hyphenated word
113 css::uno::Reference
<css::linguistic2::XHyphenatedWord
> m_xHyphWord
;
114 /// input: cursor point to locate the frame
115 const Point m_aCursorPos
;
117 /// input: requested range to hyphenate
120 /// output: found word
121 sal_Int32 m_nWordStart
;
122 sal_Int32 m_nWordLen
;
124 SwInterHyphInfo( const Point
&rCursorPos
)
125 : m_aCursorPos(rCursorPos
)
127 , m_nEnd(SAL_MAX_INT32
)
128 , m_nWordStart(0), m_nWordLen(0)
131 const Point
*GetCursorPos() const
133 return m_aCursorPos
.X() || m_aCursorPos
.Y() ? &m_aCursorPos
: nullptr;
135 void SetHyphWord(const css::uno::Reference
< css::linguistic2::XHyphenatedWord
> &rxHW
)
139 const css::uno::Reference
< css::linguistic2::XHyphenatedWord
>& GetHyphWord() const
148 typedef std::function
<SwTextFrame
*()> Creator
;
151 SwHyphIterCacheLastTextFrame(SwTextNode
const *, const Creator
& rCreator
);
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */