LibreOffice Module sw (master)  1
hyp.cxx
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 
20 #include <view.hxx>
21 #include <edtwin.hxx>
22 #include <wrtsh.hxx>
23 #include <vcl/svapp.hxx>
24 #include <vcl/weld.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 #define PSH (&pView->GetWrtShell())
35 
36 using namespace ::com::sun::star;
37 
38 // interactive separation
40  uno::Reference< linguistic2::XHyphenator > const &rxHyph,
41  bool bStart, bool bOther, bool bSelect ) :
42  SvxSpellWrapper( pVw->GetEditWin().GetFrameWeld(), rxHyph, bStart, bOther ),
43  pView( pVw ),
44  nPageCount( 0 ),
45  nPageStart( 0 ),
46  bInSelection( bSelect ),
47  bInfoBox( false )
48 {
49  uno::Reference< linguistic2::XLinguProperties > xProp( GetLinguPropertySet() );
50  bAutomatic = xProp.is() && xProp->getIsHyphAuto();
51 }
52 
54 {
55  if( SvxSpellArea::Other == eSpell && nPageCount )
56  {
58  nPageCount = 0;
59  nPageStart = 0;
60  }
61  pView->HyphStart( eSpell );
62 }
63 
65 {
66  // for automatic separation, make actions visible only at the end
67  std::unique_ptr<SwWait> pWait;
68  if( bAutomatic )
69  {
70  PSH->StartAllAction();
71  pWait.reset(new SwWait( *pView->GetDocShell(), true ));
72  }
73 
74  uno::Reference< uno::XInterface > xHyphWord = bInSelection ?
75  PSH->HyphContinue( nullptr, nullptr ) :
76  PSH->HyphContinue( &nPageCount, &nPageStart );
77  SetLast( xHyphWord );
78 
79  // for automatic separation, make actions visible only at the end
80  if( bAutomatic )
81  {
82  PSH->EndAllAction();
83  pWait.reset();
84  }
85 }
86 
88 {
89  PSH->HyphEnd();
91 }
92 
94 {
95  PSH->Push();
96  bInfoBox = true;
97  PSH->Combine();
98  return false;
99 }
100 
101 void SwHyphWrapper::InsertHyphen( const sal_Int32 nPos )
102 {
103  if( nPos)
104  SwEditShell::InsertSoftHyph(nPos + 1); // does nPos == 1 really mean
105  // insert hyphen after first char?
106  // (instead of nPos == 0)
107  else
108  PSH->HyphIgnore();
109 }
110 
112 {
113  if( nPageCount )
116  {
117  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pView->GetEditWin().GetFrameWeld(),
118  VclMessageType::Info, VclButtonsType::Ok,
119  SwResId(STR_HYP_OK)));
120  xInfoBox->run();
121  }
122 }
123 
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwHyphWrapper(SwView *pVw, css::uno::Reference< css::linguistic2::XHyphenator > const &rxHyph, bool bStart, bool bOther, bool bSelect)
Definition: hyp.cxx:39
SwEditWin & GetEditWin()
Definition: view.hxx:403
void EndProgress(SwDocShell const *pDocShell)
Definition: mainwn.cxx:92
uno::Reference< linguistic2::XLinguProperties > GetLinguPropertySet()
Definition: swtypes.cxx:60
virtual void SpellContinue() override
Definition: hyp.cxx:64
weld::Window * GetFrameWeld() const
static void InsertSoftHyph(const sal_Int32 nHyphPos)
For Inserting SoftHyphen. Position is offset within the syllabificated word.
Definition: edlingu.cxx:805
#define PSH
Definition: hyp.cxx:34
virtual ~SwHyphWrapper() override
Definition: hyp.cxx:111
bool bInfoBox
Definition: hyp.hxx:36
virtual void SpellEnd()
virtual void SpellEnd() override
Definition: hyp.cxx:87
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:20
virtual bool SpellMore() override
Definition: hyp.cxx:93
SwView * pView
Definition: hyp.hxx:31
void SetLast(const css::uno::Reference< css::uno::XInterface > &xNewLast)
bool bAutomatic
Definition: hyp.hxx:35
OUString SwResId(const char *pId)
Definition: swmodule.cxx:178
SwDocShell * GetDocShell()
Definition: view.cxx:1128
bool const bInSelection
Definition: hyp.hxx:34
virtual void SpellStart(SvxSpellArea eSpell) override
Definition: hyp.cxx:53
SAL_DLLPRIVATE void HyphStart(SvxSpellArea eSpell)
Definition: viewling.cxx:389
static bool IsHeadlessModeEnabled()
SvxSpellArea
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage)
sal_uInt16 nPageCount
Definition: hyp.hxx:32
sal_uInt16 nPageStart
Definition: hyp.hxx:33
virtual void InsertHyphen(const sal_Int32 nPos) override
Definition: hyp.cxx:101
Definition: view.hxx:146