tdf#92527 construct default Segments sequence, when there is none
[LibreOffice.git] / sw / inc / splargs.hxx
blob33fe9424fed5cf6e3257b397ad38220dc4e407e8
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 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>
26 #include <com/sun/star/linguistic2/XSpellAlternatives.hpp>
27 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
28 #include <com/sun/star/linguistic2/XHyphenatedWord.hpp>
30 #include <functional>
31 #include <limits.h>
33 class SwTextFrm;
34 class SwTextNode;
35 class SwIndex;
36 namespace vcl { class Font; }
38 struct SwArgsBase // used for text conversion (Hangul/Hanja, ...)
40 SwTextNode *pStartNode;
41 SwIndex *pStartIdx;
42 SwTextNode *pEndNode;
43 SwIndex *pEndIdx;
45 SwArgsBase(
46 SwTextNode* pStart, SwIndex& rStart,
47 SwTextNode* pEnd, SwIndex& rEnd )
48 : pStartNode( pStart ), pStartIdx( &rStart ),
49 pEndNode( pEnd ), pEndIdx( &rEnd )
52 void SetStart(SwTextNode* pStart, SwIndex& rStart )
54 pStartNode = pStart; pStartIdx = &rStart ;
57 void SetEnd( SwTextNode* pEnd, SwIndex& rEnd )
59 pEndNode = pEnd; pEndIdx = &rEnd ;
63 // used for text conversion (Hangul/Hanja, Simplified/Traditional Chinese, ...)
64 struct SwConversionArgs : SwArgsBase
66 OUString aConvText; // convertible text found
67 LanguageType nConvSrcLang; // (source) language to look for
68 LanguageType nConvTextLang; // language of aConvText (if the latter one was found)
70 // used for chinese translation
71 LanguageType nConvTargetLang; // target language of text to be changed
72 const vcl::Font *pTargetFont; // target font of text to be changed
73 // explicitly enables or disables application of the above two
74 bool bAllowImplicitChangesForNotConvertibleText;
76 SwConversionArgs( LanguageType nLang,
77 SwTextNode* pStart, SwIndex& rStart,
78 SwTextNode* pEnd, SwIndex& rEnd )
79 : SwArgsBase( pStart, rStart, pEnd, rEnd ),
80 nConvSrcLang( nLang ),
81 nConvTextLang( LANGUAGE_NONE ),
82 nConvTargetLang( LANGUAGE_NONE ),
83 pTargetFont( nullptr ),
84 bAllowImplicitChangesForNotConvertibleText( false )
88 struct SwSpellArgs : SwArgsBase
90 css::uno::Reference< css::linguistic2::XSpellChecker1 > xSpeller;
92 css::uno::Reference< css::linguistic2::XSpellAlternatives > xSpellAlt;
94 bool bIsGrammarCheck;
96 SwSpellArgs(css::uno::Reference<
97 css::linguistic2::XSpellChecker1 > &rxSplChk,
98 SwTextNode* pStart, SwIndex& rStart,
99 SwTextNode* pEnd, SwIndex& rEnd,
100 bool bGrammar )
101 : SwArgsBase( pStart, rStart, pEnd, rEnd ),
102 xSpeller( rxSplChk ),
103 bIsGrammarCheck( bGrammar )
107 // Parameter-class for Hyphenate.
108 // docedt.cxx: SwDoc::Hyphenate()
109 // txtedt.cxx: SwTextNode::Hyphenate()
110 // txthyph.cxx: SwTextFrm::Hyphenate()
112 class SwInterHyphInfo
114 css::uno::Reference< css::linguistic2::XHyphenatedWord > xHyphWord;
115 const Point aCrsrPos;
116 bool bNoLang : 1;
117 bool bCheck : 1;
118 public:
119 sal_Int32 nStart;
120 sal_Int32 nEnd;
121 sal_Int32 nWordStart;
122 sal_Int32 nWordLen;
123 sal_Int32 nHyphPos;
124 sal_uInt16 nMinTrail;
126 SwInterHyphInfo( const Point &rCrsrPos, sal_Int32 nStartPos = 0,
127 sal_Int32 nLength = SAL_MAX_INT32 )
128 : aCrsrPos(rCrsrPos)
129 , bNoLang(false)
130 , bCheck(false)
131 , nStart(nStartPos)
132 , nEnd(nLength == SAL_MAX_INT32 ? SAL_MAX_INT32 : nStartPos + nLength)
133 , nWordStart(0), nWordLen(0)
134 , nHyphPos(0), nMinTrail(0)
137 sal_Int32 GetEnd() const
139 return nEnd;
141 const Point *GetCrsrPos() const
143 return aCrsrPos.X() || aCrsrPos.Y() ? &aCrsrPos : nullptr;
145 bool IsCheck() const { return bCheck; }
146 void SetCheck( const bool bNew ) { bCheck = bNew; }
147 void SetNoLang( const bool bNew ) { bNoLang = bNew; }
148 void SetHyphWord(const css::uno::Reference< css::linguistic2::XHyphenatedWord > &rxHW)
150 xHyphWord = rxHW;
152 css::uno::Reference< css::linguistic2::XHyphenatedWord > GetHyphWord()
154 return xHyphWord;
159 namespace sw {
161 SwTextFrm *
162 SwHyphIterCacheLastTxtFrm(SwTextNode *, std::function<SwTextFrm * ()>);
166 #endif
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */