1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
23 #include <vcl/svapp.hxx>
24 #include <vcl/weld.hxx>
25 #include <com/sun/star/linguistic2/XLinguProperties.hpp>
30 #include <strings.hrc>
34 #define PSH (&m_pView->GetWrtShell())
36 using namespace ::com::sun::star
;
38 // interactive separation
39 SwHyphWrapper::SwHyphWrapper( SwView
* pVw
,
40 uno::Reference
< linguistic2::XHyphenator
> const &rxHyph
,
41 bool bStart
, bool bOther
, bool bSelect
) :
42 SvxSpellWrapper( pVw
->GetEditWin().GetFrameWeld(), rxHyph
, bStart
, bOther
),
46 m_bInSelection( bSelect
),
49 uno::Reference
< linguistic2::XLinguProperties
> xProp( GetLinguPropertySet() );
50 m_bAutomatic
= xProp
.is() && xProp
->getIsHyphAuto();
53 void SwHyphWrapper::SpellStart( SvxSpellArea eSpell
)
55 if( SvxSpellArea::Other
== eSpell
&& m_nPageCount
)
57 ::EndProgress( m_pView
->GetDocShell() );
61 m_pView
->HyphStart( eSpell
);
64 void SwHyphWrapper::SpellContinue()
66 // for automatic separation, make actions visible only at the end
67 std::optional
<SwWait
> oWait
;
70 PSH
->StartAllAction();
71 oWait
.emplace( *m_pView
->GetDocShell(), true );
74 uno::Reference
< uno::XInterface
> xHyphWord
= m_bInSelection
?
75 PSH
->HyphContinue( nullptr, nullptr ) :
76 PSH
->HyphContinue( &m_nPageCount
, &m_nPageStart
);
79 // for automatic separation, make actions visible only at the end
87 void SwHyphWrapper::SpellEnd()
90 SvxSpellWrapper::SpellEnd();
93 bool SwHyphWrapper::SpellMore()
101 void SwHyphWrapper::InsertHyphen( const sal_Int32 nPos
)
104 SwEditShell::InsertSoftHyph(nPos
+ 1); // does nPos == 1 really mean
105 // insert hyphen after first char?
106 // (instead of nPos == 0)
111 SwHyphWrapper::~SwHyphWrapper()
114 ::EndProgress( m_pView
->GetDocShell() );
115 if( m_bInfoBox
&& !Application::IsHeadlessModeEnabled() )
117 std::unique_ptr
<weld::MessageDialog
> xInfoBox(Application::CreateMessageDialog(m_pView
->GetEditWin().GetFrameWeld(),
118 VclMessageType::Info
, VclButtonsType::Ok
,
119 SwResId(STR_HYP_OK
)));
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */