Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "initui.hxx"
31 : : #include "view.hxx"
32 : : #include "edtwin.hxx"
33 : : #include "wrtsh.hxx"
34 : : #include "globals.hrc"
35 : : #include <vcl/msgbox.hxx>
36 : : #include <vcl/wrkwin.hxx>
37 : : #include <linguistic/lngprops.hxx>
38 : : #include <com/sun/star/beans/XPropertySet.hpp>
39 : : #include <swwait.hxx>
40 : :
41 : : #include "hyp.hxx"
42 : : #include "mdiexp.hxx"
43 : : #include "olmenu.hrc"
44 : :
45 : : #include <unomid.h>
46 : :
47 : : #define PSH (&pView->GetWrtShell())
48 : :
49 : : using namespace ::com::sun::star;
50 : : using ::rtl::OUString;
51 : :
52 : : /*--------------------------------------------------------------------
53 : : Description: interactive separation
54 : : --------------------------------------------------------------------*/
55 : :
56 : 0 : SwHyphWrapper::SwHyphWrapper( SwView* pVw,
57 : : uno::Reference< linguistic2::XHyphenator > &rxHyph,
58 : : sal_Bool bStart, sal_Bool bOther, sal_Bool bSelect ) :
59 : 0 : SvxSpellWrapper( &pVw->GetEditWin(), rxHyph, bStart, bOther ),
60 : : pView( pVw ),
61 : : xHyph( rxHyph ),
62 : : nLangError( 0 ),
63 : : nPageCount( 0 ),
64 : : nPageStart( 0 ),
65 : : bInSelection( bSelect ),
66 : : bShowError( sal_False ),
67 [ # # ]: 0 : bInfoBox( sal_False )
68 : : {
69 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xProp( GetLinguPropertySet() );
70 : 0 : bAutomatic = xProp.is() ?
71 [ # # ][ # # ]: 0 : *(sal_Bool*)xProp->getPropertyValue( C2U(UPN_IS_HYPH_AUTO) ).getValue() : sal_False;
[ # # ][ # # ]
[ # # ]
[ # # # # ]
[ # # ]
72 : 0 : SetHyphen();
73 : 0 : }
74 : :
75 : : // -----------------------------------------------------------------------
76 : 0 : void SwHyphWrapper::SpellStart( SvxSpellArea eSpell )
77 : : {
78 [ # # ][ # # ]: 0 : if( SVX_SPELL_OTHER == eSpell && nPageCount )
79 : : {
80 : 0 : ::EndProgress( pView->GetDocShell() );
81 : 0 : nPageCount = 0;
82 : 0 : nPageStart = 0;
83 : : }
84 : 0 : pView->HyphStart( eSpell );
85 : 0 : }
86 : :
87 : : // -----------------------------------------------------------------------
88 : :
89 : 0 : sal_Bool SwHyphWrapper::SpellContinue()
90 : : {
91 : : // for automatic separation, make actions visible only at the end
92 : 0 : SwWait *pWait = 0;
93 [ # # ]: 0 : if( bAutomatic )
94 : : {
95 [ # # ]: 0 : PSH->StartAllAction();
96 [ # # ][ # # ]: 0 : pWait = new SwWait( *pView->GetDocShell(), sal_True );
[ # # ]
97 : : }
98 : :
99 : : uno::Reference< uno::XInterface > xHyphWord = bInSelection ?
100 : 0 : PSH->HyphContinue( NULL, NULL ) :
101 [ # # # # ]: 0 : PSH->HyphContinue( &nPageCount, &nPageStart );
[ # # ]
102 [ # # ]: 0 : SetLast( xHyphWord );
103 : :
104 : : // for automatic separation, make actions visible only at the end
105 [ # # ]: 0 : if( bAutomatic )
106 : : {
107 [ # # ]: 0 : PSH->EndAllAction();
108 [ # # ][ # # ]: 0 : delete pWait;
109 : : }
110 : :
111 [ # # ]: 0 : if( bShowError )
112 : : {
113 : 0 : bShowError = sal_False;
114 [ # # ]: 0 : PSH->Push();
115 [ # # ]: 0 : PSH->ClearMark();
116 [ # # ]: 0 : pView->SpellError( nLangError );
117 [ # # ]: 0 : PSH->Combine();
118 : : }
119 [ # # ]: 0 : return GetLast().is();
120 : : }
121 : :
122 : : // -----------------------------------------------------------------------
123 : 0 : void SwHyphWrapper::SpellEnd()
124 : : {
125 : 0 : PSH->HyphEnd();
126 : 0 : SvxSpellWrapper::SpellEnd();
127 : 0 : }
128 : :
129 : : // -----------------------------------------------------------------------
130 : 0 : sal_Bool SwHyphWrapper::SpellMore()
131 : : {
132 : 0 : PSH->Push();
133 : 0 : bInfoBox = sal_True;
134 : 0 : PSH->Combine();
135 : 0 : return sal_False;
136 : : }
137 : :
138 : : // -----------------------------------------------------------------------
139 : :
140 : 0 : void SwHyphWrapper::InsertHyphen( const sal_uInt16 nPos )
141 : : {
142 [ # # ]: 0 : if( nPos)
143 : 0 : PSH->InsertSoftHyph( nPos + 1); // does nPos == 1 really mean
144 : : // insert hyphen after first char?
145 : : // (instead of nPos == 0)
146 : : else
147 : 0 : PSH->HyphIgnore();
148 : 0 : }
149 : :
150 : : // -----------------------------------------------------------------------
151 : 0 : SwHyphWrapper::~SwHyphWrapper()
152 : : {
153 [ # # ]: 0 : if( nPageCount )
154 [ # # ][ # # ]: 0 : ::EndProgress( pView->GetDocShell() );
155 [ # # ]: 0 : if( bInfoBox )
156 [ # # ][ # # ]: 0 : InfoBox( &pView->GetEditWin(), SW_RESSTR(STR_HYP_OK) ).Execute();
[ # # ][ # # ]
[ # # ][ # # ]
157 [ # # ]: 0 : }
158 : :
159 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|