/src/libreoffice/sw/inc/splargs.hxx
Line | Count | Source |
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/gen.hxx> |
24 | | |
25 | | #include <com/sun/star/linguistic2/XSpellAlternatives.hpp> |
26 | | #include <com/sun/star/linguistic2/XSpellChecker1.hpp> |
27 | | |
28 | | #include <functional> |
29 | | #include <utility> |
30 | | |
31 | | struct SwPosition; |
32 | | class SwTextFrame; |
33 | | class SwTextNode; |
34 | | namespace vcl { class Font; } |
35 | | namespace com::sun::star::linguistic2 { class XHyphenatedWord; } |
36 | | |
37 | | struct SwArgsBase // used for text conversion (Hangul/Hanja, ...) |
38 | | { |
39 | | SwPosition *pStartPos; // these both point to SwTextNode |
40 | | SwPosition *pEndPos; |
41 | | |
42 | | SwArgsBase(SwPosition& rStart, SwPosition& rEnd ) |
43 | 0 | : pStartPos( &rStart ), pEndPos( &rEnd ) |
44 | 0 | {} |
45 | | |
46 | | void SetStart(SwPosition& rStart ) |
47 | 0 | { |
48 | 0 | pStartPos = &rStart; |
49 | 0 | } |
50 | | |
51 | | void SetEnd( SwPosition& rEnd ) |
52 | 0 | { |
53 | 0 | pEndPos = &rEnd ; |
54 | 0 | } |
55 | | }; |
56 | | |
57 | | // used for text conversion (Hangul/Hanja, Simplified/Traditional Chinese, ...) |
58 | | struct SwConversionArgs : SwArgsBase |
59 | | { |
60 | | OUString aConvText; // convertible text found |
61 | | LanguageType nConvSrcLang; // (source) language to look for |
62 | | LanguageType nConvTextLang; // language of aConvText (if the latter one was found) |
63 | | |
64 | | // used for chinese translation |
65 | | LanguageType nConvTargetLang; // target language of text to be changed |
66 | | const vcl::Font *pTargetFont; // target font of text to be changed |
67 | | // explicitly enables or disables application of the above two |
68 | | bool bAllowImplicitChangesForNotConvertibleText; |
69 | | |
70 | | SwConversionArgs( LanguageType nLang, |
71 | | SwPosition& rStart, |
72 | | SwPosition& rEnd ) |
73 | 0 | : SwArgsBase( rStart, rEnd ), |
74 | 0 | nConvSrcLang( nLang ), |
75 | 0 | nConvTextLang( LANGUAGE_NONE ), |
76 | 0 | nConvTargetLang( LANGUAGE_NONE ), |
77 | 0 | pTargetFont( nullptr ), |
78 | 0 | bAllowImplicitChangesForNotConvertibleText( false ) |
79 | 0 | {} |
80 | | }; |
81 | | |
82 | | struct SwSpellArgs : SwArgsBase |
83 | | { |
84 | | css::uno::Reference< css::linguistic2::XSpellChecker1 > xSpeller; |
85 | | |
86 | | css::uno::Reference< css::linguistic2::XSpellAlternatives > xSpellAlt; |
87 | | |
88 | | bool bIsGrammarCheck; |
89 | | |
90 | | SwSpellArgs(css::uno::Reference< css::linguistic2::XSpellChecker1 > xSplChk, |
91 | | SwPosition& rStart, |
92 | | SwPosition& rEnd, |
93 | | bool bGrammar ) |
94 | 0 | : SwArgsBase( rStart, rEnd ), |
95 | 0 | xSpeller(std::move( xSplChk )), |
96 | 0 | bIsGrammarCheck( bGrammar ) |
97 | 0 | {} |
98 | | }; |
99 | | |
100 | | // Parameter-class for Hyphenate. |
101 | | // docedt.cxx: SwDoc::Hyphenate() |
102 | | // txtedt.cxx: SwTextNode::Hyphenate() |
103 | | // txthyph.cxx: SwTextFrame::Hyphenate() |
104 | | |
105 | | class SwInterHyphInfo |
106 | | { |
107 | | /// output: hyphenated word |
108 | | css::uno::Reference<css::linguistic2::XHyphenatedWord> m_xHyphWord; |
109 | | /// input: cursor point to locate the frame |
110 | | const Point m_aCursorPos; |
111 | | public: |
112 | | /// input: requested range to hyphenate |
113 | | sal_Int32 m_nStart; |
114 | | sal_Int32 m_nEnd; |
115 | | /// output: found word |
116 | | sal_Int32 m_nWordStart; |
117 | | sal_Int32 m_nWordLen; |
118 | | |
119 | | SwInterHyphInfo( const Point &rCursorPos ) |
120 | 0 | : m_aCursorPos(rCursorPos) |
121 | 0 | , m_nStart(0) |
122 | 0 | , m_nEnd(SAL_MAX_INT32) |
123 | 0 | , m_nWordStart(0), m_nWordLen(0) |
124 | 0 | { |
125 | 0 | } |
126 | | const Point *GetCursorPos() const |
127 | 0 | { |
128 | 0 | return m_aCursorPos.X() || m_aCursorPos.Y() ? &m_aCursorPos : nullptr; |
129 | 0 | } |
130 | | void SetHyphWord(const css::uno::Reference< css::linguistic2::XHyphenatedWord > &rxHW) |
131 | 0 | { |
132 | 0 | m_xHyphWord = rxHW; |
133 | 0 | } |
134 | | const css::uno::Reference< css::linguistic2::XHyphenatedWord >& GetHyphWord() const |
135 | 0 | { |
136 | 0 | return m_xHyphWord; |
137 | 0 | } |
138 | | }; |
139 | | |
140 | | |
141 | | namespace sw { |
142 | | |
143 | | typedef std::function<SwTextFrame*()> Creator; |
144 | | |
145 | | SwTextFrame * |
146 | | SwHyphIterCacheLastTextFrame(SwTextNode const *, const Creator& rCreator); |
147 | | |
148 | | } |
149 | | |
150 | | #endif |
151 | | |
152 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |