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