/src/libreoffice/sw/source/uibase/lingu/hyp.cxx
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 | | |
20 | | #include <view.hxx> |
21 | | #include <edtwin.hxx> |
22 | | #include <wrtsh.hxx> |
23 | | #include <vcl/svapp.hxx> |
24 | | #include <vcl/weld/MessageDialog.hxx> |
25 | | #include <com/sun/star/linguistic2/XLinguProperties.hpp> |
26 | | #include <swwait.hxx> |
27 | | |
28 | | #include <hyp.hxx> |
29 | | #include <mdiexp.hxx> |
30 | | #include <strings.hrc> |
31 | | |
32 | | #include <memory> |
33 | | |
34 | | using namespace ::com::sun::star; |
35 | | |
36 | | // interactive separation |
37 | | SwHyphWrapper::SwHyphWrapper( SwView& rView, |
38 | | uno::Reference< linguistic2::XHyphenator > const &rxHyph, |
39 | | bool bStart, bool bOther, bool bSelect ) : |
40 | 0 | SvxSpellWrapper( rView.GetEditWin().GetFrameWeld(), rxHyph, bStart, bOther ), |
41 | 0 | m_rView( rView ), |
42 | 0 | m_nPageCount( 0 ), |
43 | 0 | m_nPageStart( 0 ), |
44 | 0 | m_bInSelection( bSelect ), |
45 | 0 | m_bInfoBox( false ) |
46 | 0 | { |
47 | 0 | uno::Reference< linguistic2::XLinguProperties > xProp( GetLinguPropertySet() ); |
48 | 0 | m_bAutomatic = xProp.is() && xProp->getIsHyphAuto(); |
49 | 0 | } |
50 | | |
51 | | void SwHyphWrapper::SpellStart( SvxSpellArea eSpell ) |
52 | 0 | { |
53 | 0 | if( SvxSpellArea::Other == eSpell && m_nPageCount ) |
54 | 0 | { |
55 | 0 | ::EndProgress( m_rView.GetDocShell() ); |
56 | 0 | m_nPageCount = 0; |
57 | 0 | m_nPageStart = 0; |
58 | 0 | } |
59 | 0 | m_rView.HyphStart( eSpell ); |
60 | 0 | } |
61 | | |
62 | | void SwHyphWrapper::SpellContinue() |
63 | 0 | { |
64 | | // for automatic separation, make actions visible only at the end |
65 | 0 | std::optional<SwWait> oWait; |
66 | 0 | SwWrtShell &rSh = m_rView.GetWrtShell(); |
67 | 0 | if( m_bAutomatic ) |
68 | 0 | { |
69 | 0 | rSh.StartAllAction(); |
70 | 0 | oWait.emplace( *m_rView.GetDocShell(), true ); |
71 | 0 | } |
72 | |
|
73 | 0 | uno::Reference< uno::XInterface > xHyphWord = m_bInSelection ? |
74 | 0 | rSh.HyphContinue( nullptr, nullptr ) : |
75 | 0 | rSh.HyphContinue( &m_nPageCount, &m_nPageStart ); |
76 | 0 | SetLast( xHyphWord ); |
77 | | |
78 | | // for automatic separation, make actions visible only at the end |
79 | 0 | if( m_bAutomatic ) |
80 | 0 | { |
81 | 0 | rSh.EndAllAction(); |
82 | 0 | oWait.reset(); |
83 | 0 | } |
84 | 0 | } |
85 | | |
86 | | void SwHyphWrapper::SpellEnd() |
87 | 0 | { |
88 | 0 | m_rView.GetWrtShell().HyphEnd(); |
89 | 0 | SvxSpellWrapper::SpellEnd(); |
90 | 0 | } |
91 | | |
92 | | bool SwHyphWrapper::SpellMore() |
93 | 0 | { |
94 | 0 | SwWrtShell &rSh = m_rView.GetWrtShell(); |
95 | 0 | rSh.Push(); |
96 | 0 | m_bInfoBox = true; |
97 | 0 | rSh.Combine(); |
98 | 0 | return false; |
99 | 0 | } |
100 | | |
101 | | void SwHyphWrapper::InsertHyphen( const sal_Int32 nPos ) |
102 | 0 | { |
103 | 0 | if( nPos) |
104 | 0 | SwEditShell::InsertSoftHyph(nPos + 1); // does nPos == 1 really mean |
105 | | // insert hyphen after first char? |
106 | | // (instead of nPos == 0) |
107 | 0 | else |
108 | 0 | m_rView.GetWrtShell().HyphIgnore(); |
109 | 0 | } |
110 | | |
111 | | SwHyphWrapper::~SwHyphWrapper() |
112 | 0 | { |
113 | 0 | if( m_nPageCount ) |
114 | 0 | ::EndProgress( m_rView.GetDocShell() ); |
115 | 0 | if( m_bInfoBox && !Application::IsHeadlessModeEnabled() ) |
116 | 0 | { |
117 | 0 | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_rView.GetEditWin().GetFrameWeld(), |
118 | 0 | VclMessageType::Info, VclButtonsType::Ok, |
119 | 0 | SwResId(STR_HYP_OK))); |
120 | 0 | xInfoBox->run(); |
121 | 0 | } |
122 | 0 | } |
123 | | |
124 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |