Line data Source code
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 :
21 : #include "initui.hxx"
22 : #include "view.hxx"
23 : #include "edtwin.hxx"
24 : #include "wrtsh.hxx"
25 : #include "globals.hrc"
26 : #include <vcl/msgbox.hxx>
27 : #include <vcl/wrkwin.hxx>
28 : #include <linguistic/lngprops.hxx>
29 : #include <com/sun/star/beans/XPropertySet.hpp>
30 : #include <com/sun/star/linguistic2/XLinguProperties.hpp>
31 : #include <swwait.hxx>
32 :
33 : #include "hyp.hxx"
34 : #include "mdiexp.hxx"
35 : #include "olmenu.hrc"
36 :
37 : #include <unomid.h>
38 :
39 : #define PSH (&pView->GetWrtShell())
40 :
41 : using namespace ::com::sun::star;
42 :
43 : /*--------------------------------------------------------------------
44 : Description: interactive separation
45 : --------------------------------------------------------------------*/
46 :
47 0 : SwHyphWrapper::SwHyphWrapper( SwView* pVw,
48 : uno::Reference< linguistic2::XHyphenator > &rxHyph,
49 : sal_Bool bStart, sal_Bool bOther, sal_Bool bSelect ) :
50 0 : SvxSpellWrapper( &pVw->GetEditWin(), rxHyph, bStart, bOther ),
51 : pView( pVw ),
52 : xHyph( rxHyph ),
53 : nPageCount( 0 ),
54 : nPageStart( 0 ),
55 : bInSelection( bSelect ),
56 0 : bInfoBox( sal_False )
57 : {
58 0 : uno::Reference< linguistic2::XLinguProperties > xProp( GetLinguPropertySet() );
59 0 : bAutomatic = xProp.is() ? xProp->getIsHyphAuto() : sal_False;
60 0 : SetHyphen();
61 0 : }
62 :
63 : // -----------------------------------------------------------------------
64 0 : void SwHyphWrapper::SpellStart( SvxSpellArea eSpell )
65 : {
66 0 : if( SVX_SPELL_OTHER == eSpell && nPageCount )
67 : {
68 0 : ::EndProgress( pView->GetDocShell() );
69 0 : nPageCount = 0;
70 0 : nPageStart = 0;
71 : }
72 0 : pView->HyphStart( eSpell );
73 0 : }
74 :
75 : // -----------------------------------------------------------------------
76 :
77 0 : sal_Bool SwHyphWrapper::SpellContinue()
78 : {
79 : // for automatic separation, make actions visible only at the end
80 0 : SwWait *pWait = 0;
81 0 : if( bAutomatic )
82 : {
83 0 : PSH->StartAllAction();
84 0 : pWait = new SwWait( *pView->GetDocShell(), sal_True );
85 : }
86 :
87 : uno::Reference< uno::XInterface > xHyphWord = bInSelection ?
88 0 : PSH->HyphContinue( NULL, NULL ) :
89 0 : PSH->HyphContinue( &nPageCount, &nPageStart );
90 0 : SetLast( xHyphWord );
91 :
92 : // for automatic separation, make actions visible only at the end
93 0 : if( bAutomatic )
94 : {
95 0 : PSH->EndAllAction();
96 0 : delete pWait;
97 : }
98 :
99 0 : return GetLast().is();
100 : }
101 :
102 : // -----------------------------------------------------------------------
103 0 : void SwHyphWrapper::SpellEnd()
104 : {
105 0 : PSH->HyphEnd();
106 0 : SvxSpellWrapper::SpellEnd();
107 0 : }
108 :
109 : // -----------------------------------------------------------------------
110 0 : sal_Bool SwHyphWrapper::SpellMore()
111 : {
112 0 : PSH->Push();
113 0 : bInfoBox = sal_True;
114 0 : PSH->Combine();
115 0 : return sal_False;
116 : }
117 :
118 : // -----------------------------------------------------------------------
119 :
120 0 : void SwHyphWrapper::InsertHyphen( const sal_uInt16 nPos )
121 : {
122 0 : if( nPos)
123 0 : PSH->InsertSoftHyph( nPos + 1); // does nPos == 1 really mean
124 : // insert hyphen after first char?
125 : // (instead of nPos == 0)
126 : else
127 0 : PSH->HyphIgnore();
128 0 : }
129 :
130 : // -----------------------------------------------------------------------
131 0 : SwHyphWrapper::~SwHyphWrapper()
132 : {
133 0 : if( nPageCount )
134 0 : ::EndProgress( pView->GetDocShell() );
135 0 : if( bInfoBox )
136 0 : InfoBox( &pView->GetEditWin(), SW_RESSTR(STR_HYP_OK) ).Execute();
137 99 : }
138 :
139 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|