Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / inc / splargs.hxx
bloba46c78d924fda9f000d18771bbdb080579c27288
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/gen.hxx>
25 #include <com/sun/star/linguistic2/XSpellAlternatives.hpp>
26 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
28 #include <functional>
29 #include <utility>
31 struct SwPosition;
32 class SwTextFrame;
33 class SwTextNode;
34 class SwContentIndex;
35 namespace vcl { class Font; }
36 namespace com::sun::star::linguistic2 { class XHyphenatedWord; }
38 struct SwArgsBase // used for text conversion (Hangul/Hanja, ...)
40 SwPosition *pStartPos; // these both point to SwTextNode
41 SwPosition *pEndPos;
43 SwArgsBase(SwPosition& rStart, SwPosition& rEnd )
44 : pStartPos( &rStart ), pEndPos( &rEnd )
47 void SetStart(SwPosition& rStart )
49 pStartPos = &rStart;
52 void SetEnd( SwPosition& rEnd )
54 pEndPos = &rEnd ;
58 // used for text conversion (Hangul/Hanja, Simplified/Traditional Chinese, ...)
59 struct SwConversionArgs : SwArgsBase
61 OUString aConvText; // convertible text found
62 LanguageType nConvSrcLang; // (source) language to look for
63 LanguageType nConvTextLang; // language of aConvText (if the latter one was found)
65 // used for chinese translation
66 LanguageType nConvTargetLang; // target language of text to be changed
67 const vcl::Font *pTargetFont; // target font of text to be changed
68 // explicitly enables or disables application of the above two
69 bool bAllowImplicitChangesForNotConvertibleText;
71 SwConversionArgs( LanguageType nLang,
72 SwPosition& rStart,
73 SwPosition& rEnd )
74 : SwArgsBase( rStart, rEnd ),
75 nConvSrcLang( nLang ),
76 nConvTextLang( LANGUAGE_NONE ),
77 nConvTargetLang( LANGUAGE_NONE ),
78 pTargetFont( nullptr ),
79 bAllowImplicitChangesForNotConvertibleText( false )
83 struct SwSpellArgs : SwArgsBase
85 css::uno::Reference< css::linguistic2::XSpellChecker1 > xSpeller;
87 css::uno::Reference< css::linguistic2::XSpellAlternatives > xSpellAlt;
89 bool bIsGrammarCheck;
91 SwSpellArgs(css::uno::Reference< css::linguistic2::XSpellChecker1 > xSplChk,
92 SwPosition& rStart,
93 SwPosition& rEnd,
94 bool bGrammar )
95 : SwArgsBase( rStart, rEnd ),
96 xSpeller(std::move( xSplChk )),
97 bIsGrammarCheck( bGrammar )
101 // Parameter-class for Hyphenate.
102 // docedt.cxx: SwDoc::Hyphenate()
103 // txtedt.cxx: SwTextNode::Hyphenate()
104 // txthyph.cxx: SwTextFrame::Hyphenate()
106 class SwInterHyphInfo
108 /// output: hyphenated word
109 css::uno::Reference<css::linguistic2::XHyphenatedWord> m_xHyphWord;
110 /// input: cursor point to locate the frame
111 const Point m_aCursorPos;
112 public:
113 /// input: requested range to hyphenate
114 sal_Int32 m_nStart;
115 sal_Int32 m_nEnd;
116 /// output: found word
117 sal_Int32 m_nWordStart;
118 sal_Int32 m_nWordLen;
120 SwInterHyphInfo( const Point &rCursorPos )
121 : m_aCursorPos(rCursorPos)
122 , m_nStart(0)
123 , m_nEnd(SAL_MAX_INT32)
124 , m_nWordStart(0), m_nWordLen(0)
127 const Point *GetCursorPos() const
129 return m_aCursorPos.X() || m_aCursorPos.Y() ? &m_aCursorPos : nullptr;
131 void SetHyphWord(const css::uno::Reference< css::linguistic2::XHyphenatedWord > &rxHW)
133 m_xHyphWord = rxHW;
135 const css::uno::Reference< css::linguistic2::XHyphenatedWord >& GetHyphWord() const
137 return m_xHyphWord;
142 namespace sw {
144 typedef std::function<SwTextFrame*()> Creator;
146 SwTextFrame *
147 SwHyphIterCacheLastTextFrame(SwTextNode const *, const Creator& rCreator);
151 #endif
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */