LibreOffice Module sw (master)  1
splargs.hxx
Go to the documentation of this file.
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 
30 class SwTextFrame;
31 class SwTextNode;
32 class SwIndex;
33 namespace vcl { class Font; }
34 namespace com { namespace sun { namespace star { namespace linguistic2 { class XHyphenatedWord; } } } }
35 
36 struct SwArgsBase // used for text conversion (Hangul/Hanja, ...)
37 {
42 
44  SwTextNode* pStart, SwIndex& rStart,
45  SwTextNode* pEnd, SwIndex& rEnd )
46  : pStartNode( pStart ), pStartIdx( &rStart ),
47  pEndNode( pEnd ), pEndIdx( &rEnd )
48  {}
49 
50  void SetStart(SwTextNode* pStart, SwIndex& rStart )
51  {
52  pStartNode = pStart; pStartIdx = &rStart ;
53  }
54 
55  void SetEnd( SwTextNode* pEnd, SwIndex& rEnd )
56  {
57  pEndNode = pEnd; pEndIdx = &rEnd ;
58  }
59 };
60 
61 // used for text conversion (Hangul/Hanja, Simplified/Traditional Chinese, ...)
63 {
64  OUString aConvText; // convertible text found
65  LanguageType const nConvSrcLang; // (source) language to look for
66  LanguageType nConvTextLang; // language of aConvText (if the latter one was found)
67 
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
73 
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 )
83  {}
84 };
85 
87 {
88  css::uno::Reference< css::linguistic2::XSpellChecker1 > xSpeller;
89 
90  css::uno::Reference< css::linguistic2::XSpellAlternatives > xSpellAlt;
91 
92  bool const bIsGrammarCheck;
93 
94  SwSpellArgs(css::uno::Reference<
95  css::linguistic2::XSpellChecker1 > const &rxSplChk,
96  SwTextNode* pStart, SwIndex& rStart,
97  SwTextNode* pEnd, SwIndex& rEnd,
98  bool bGrammar )
99  : SwArgsBase( pStart, rStart, pEnd, rEnd ),
100  xSpeller( rxSplChk ),
101  bIsGrammarCheck( bGrammar )
102  {}
103 };
104 
105 // Parameter-class for Hyphenate.
106 // docedt.cxx: SwDoc::Hyphenate()
107 // txtedt.cxx: SwTextNode::Hyphenate()
108 // txthyph.cxx: SwTextFrame::Hyphenate()
109 
111 {
113  css::uno::Reference<css::linguistic2::XHyphenatedWord> xHyphWord;
116 public:
118  sal_Int32 nStart;
119  sal_Int32 nEnd;
121  sal_Int32 nWordStart;
122  sal_Int32 nWordLen;
123 
124  SwInterHyphInfo( const Point &rCursorPos )
125  : aCursorPos(rCursorPos)
126  , nStart(0)
127  , nEnd(SAL_MAX_INT32)
128  , nWordStart(0), nWordLen(0)
129  {
130  }
131  const Point *GetCursorPos() const
132  {
133  return aCursorPos.X() || aCursorPos.Y() ? &aCursorPos : nullptr;
134  }
135  void SetHyphWord(const css::uno::Reference< css::linguistic2::XHyphenatedWord > &rxHW)
136  {
137  xHyphWord = rxHW;
138  }
139  const css::uno::Reference< css::linguistic2::XHyphenatedWord >& GetHyphWord() const
140  {
141  return xHyphWord;
142  }
143 };
144 
145 
146 namespace sw {
147 
148 typedef std::function<SwTextFrame*()> Creator;
149 
150 SwTextFrame *
151 SwHyphIterCacheLastTextFrame(SwTextNode const *, const Creator& rCreator);
152 
153 }
154 
155 #endif
156 
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
LanguageType const nConvSrcLang
Definition: splargs.hxx:65
SwConversionArgs(LanguageType nLang, SwTextNode *pStart, SwIndex &rStart, SwTextNode *pEnd, SwIndex &rEnd)
Definition: splargs.hxx:74
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
#define LANGUAGE_NONE
bool bAllowImplicitChangesForNotConvertibleText
Definition: splargs.hxx:72
std::function< SwTextFrame *()> Creator
Definition: splargs.hxx:148
css::uno::Reference< css::linguistic2::XSpellChecker1 > xSpeller
Definition: splargs.hxx:88
const Point aCursorPos
input: cursor point to locate the frame
Definition: splargs.hxx:115
Dialog to specify the properties of date form field.
const vcl::Font * pTargetFont
Definition: splargs.hxx:70
const Point * GetCursorPos() const
Definition: splargs.hxx:131
static LanguageType nLang
Definition: srtdlg.cxx:60
void SetEnd(SwTextNode *pEnd, SwIndex &rEnd)
Definition: splargs.hxx:55
const css::uno::Reference< css::linguistic2::XHyphenatedWord > & GetHyphWord() const
Definition: splargs.hxx:139
SwArgsBase(SwTextNode *pStart, SwIndex &rStart, SwTextNode *pEnd, SwIndex &rEnd)
Definition: splargs.hxx:43
SwSpellArgs(css::uno::Reference< css::linguistic2::XSpellChecker1 > const &rxSplChk, SwTextNode *pStart, SwIndex &rStart, SwTextNode *pEnd, SwIndex &rEnd, bool bGrammar)
Definition: splargs.hxx:94
css::uno::Reference< css::linguistic2::XHyphenatedWord > xHyphWord
output: hyphenated word
Definition: splargs.hxx:113
SwIndex * pStartIdx
Definition: splargs.hxx:39
LanguageType nConvTextLang
Definition: splargs.hxx:66
#define SAL_MAX_INT32
SwInterHyphInfo(const Point &rCursorPos)
Definition: splargs.hxx:124
sal_Int32 nStart
input: requested range to hyphenate
Definition: splargs.hxx:118
Marks a character position inside a document model node.
Definition: index.hxx:37
bool const bIsGrammarCheck
Definition: splargs.hxx:92
LanguageType nConvTargetLang
Definition: splargs.hxx:69
long X() const
sal_Int32 nEnd
Definition: splargs.hxx:119
OUString aConvText
Definition: splargs.hxx:64
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
css::uno::Reference< css::linguistic2::XSpellAlternatives > xSpellAlt
Definition: splargs.hxx:90
void SetHyphWord(const css::uno::Reference< css::linguistic2::XHyphenatedWord > &rxHW)
Definition: splargs.hxx:135
sal_Int32 nWordLen
Definition: splargs.hxx:122
SwTextNode * pStartNode
Definition: splargs.hxx:38
SwIndex * pEndIdx
Definition: splargs.hxx:41
SwTextFrame * SwHyphIterCacheLastTextFrame(SwTextNode const *pNode, const sw::Creator &create)
Definition: edlingu.cxx:564
sal_Int32 nWordStart
output: found word
Definition: splargs.hxx:121
void SetStart(SwTextNode *pStart, SwIndex &rStart)
Definition: splargs.hxx:50
SwTextNode * pEndNode
Definition: splargs.hxx:40
long Y() const