1*efeef26fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*efeef26fSAndrew Rist * distributed with this work for additional information 6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*efeef26fSAndrew Rist * software distributed under the License is distributed on an 15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17*efeef26fSAndrew Rist * specific language governing permissions and limitations 18*efeef26fSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*efeef26fSAndrew Rist *************************************************************/ 21*efeef26fSAndrew Rist 22*efeef26fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sw.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "initui.hxx" 30cdf0e10cSrcweir #include "view.hxx" 31cdf0e10cSrcweir #include "edtwin.hxx" 32cdf0e10cSrcweir #include "wrtsh.hxx" 33cdf0e10cSrcweir #include "globals.hrc" 34cdf0e10cSrcweir #include <vcl/msgbox.hxx> 35cdf0e10cSrcweir #ifndef _WRKWIN_HXX //autogen 36cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 37cdf0e10cSrcweir #endif 38cdf0e10cSrcweir #include <linguistic/lngprops.hxx> 39cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 40cdf0e10cSrcweir #include <swwait.hxx> 41cdf0e10cSrcweir 42cdf0e10cSrcweir 43cdf0e10cSrcweir #include "hyp.hxx" 44cdf0e10cSrcweir #include "mdiexp.hxx" 45cdf0e10cSrcweir #include "olmenu.hrc" 46cdf0e10cSrcweir 47cdf0e10cSrcweir #include <unomid.h> 48cdf0e10cSrcweir 49cdf0e10cSrcweir #define HYPHHERE '-' 50cdf0e10cSrcweir #define PSH (&pView->GetWrtShell()) 51cdf0e10cSrcweir 52cdf0e10cSrcweir using namespace ::com::sun::star; 53cdf0e10cSrcweir using ::rtl::OUString; 54cdf0e10cSrcweir 55cdf0e10cSrcweir /*-------------------------------------------------------------------- 56cdf0e10cSrcweir Beschreibung: Interaktive Trennung 57cdf0e10cSrcweir --------------------------------------------------------------------*/ 58cdf0e10cSrcweir 59cdf0e10cSrcweir SwHyphWrapper::SwHyphWrapper( SwView* pVw, 60cdf0e10cSrcweir uno::Reference< linguistic2::XHyphenator > &rxHyph, 61cdf0e10cSrcweir sal_Bool bStart, sal_Bool bOther, sal_Bool bSelect ) : 62cdf0e10cSrcweir SvxSpellWrapper( &pVw->GetEditWin(), rxHyph, bStart, bOther ), 63cdf0e10cSrcweir pView( pVw ), 64cdf0e10cSrcweir xHyph( rxHyph ), 65cdf0e10cSrcweir nLangError( 0 ), 66cdf0e10cSrcweir nPageCount( 0 ), 67cdf0e10cSrcweir nPageStart( 0 ), 68cdf0e10cSrcweir bInSelection( bSelect ), 69cdf0e10cSrcweir bShowError( sal_False ), 70cdf0e10cSrcweir bInfoBox( sal_False ) 71cdf0e10cSrcweir { 72cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProp( GetLinguPropertySet() ); 73cdf0e10cSrcweir bAutomatic = xProp.is() ? 74cdf0e10cSrcweir *(sal_Bool*)xProp->getPropertyValue( C2U(UPN_IS_HYPH_AUTO) ).getValue() : sal_False; 75cdf0e10cSrcweir SetHyphen(); 76cdf0e10cSrcweir } 77cdf0e10cSrcweir 78cdf0e10cSrcweir // ----------------------------------------------------------------------- 79cdf0e10cSrcweir void SwHyphWrapper::SpellStart( SvxSpellArea eSpell ) 80cdf0e10cSrcweir { 81cdf0e10cSrcweir if( SVX_SPELL_OTHER == eSpell && nPageCount ) 82cdf0e10cSrcweir { 83cdf0e10cSrcweir ::EndProgress( pView->GetDocShell() ); 84cdf0e10cSrcweir nPageCount = 0; 85cdf0e10cSrcweir nPageStart = 0; 86cdf0e10cSrcweir } 87cdf0e10cSrcweir pView->HyphStart( eSpell ); 88cdf0e10cSrcweir } 89cdf0e10cSrcweir 90cdf0e10cSrcweir // ----------------------------------------------------------------------- 91cdf0e10cSrcweir 92cdf0e10cSrcweir sal_Bool SwHyphWrapper::SpellContinue() 93cdf0e10cSrcweir { 94cdf0e10cSrcweir // Fuer autom. Trennung Aktionen erst am Ende sichtbar machen 95cdf0e10cSrcweir SwWait *pWait = 0; 96cdf0e10cSrcweir if( bAutomatic ) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir PSH->StartAllAction(); 99cdf0e10cSrcweir pWait = new SwWait( *pView->GetDocShell(), sal_True ); 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir uno::Reference< uno::XInterface > xHyphWord = bInSelection ? 103cdf0e10cSrcweir PSH->HyphContinue( NULL, NULL ) : 104cdf0e10cSrcweir PSH->HyphContinue( &nPageCount, &nPageStart ); 105cdf0e10cSrcweir SetLast( xHyphWord ); 106cdf0e10cSrcweir 107cdf0e10cSrcweir // Fuer autom. Trennung Aktionen erst am Ende sichtbar machen 108cdf0e10cSrcweir if( bAutomatic ) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir PSH->EndAllAction(); 111cdf0e10cSrcweir delete pWait; 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir if( bShowError ) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir bShowError = sal_False; 117cdf0e10cSrcweir PSH->Push(); 118cdf0e10cSrcweir PSH->ClearMark(); 119cdf0e10cSrcweir pView->SpellError( &nLangError ); 120cdf0e10cSrcweir PSH->Combine(); 121cdf0e10cSrcweir } 122cdf0e10cSrcweir return GetLast().is(); 123cdf0e10cSrcweir } 124cdf0e10cSrcweir 125cdf0e10cSrcweir // ----------------------------------------------------------------------- 126cdf0e10cSrcweir void SwHyphWrapper::SpellEnd() 127cdf0e10cSrcweir { 128cdf0e10cSrcweir PSH->HyphEnd(); 129cdf0e10cSrcweir SvxSpellWrapper::SpellEnd(); 130cdf0e10cSrcweir } 131cdf0e10cSrcweir 132cdf0e10cSrcweir IMPL_LINK( SwHyphWrapper, SpellError, LanguageType *, pLang ) 133cdf0e10cSrcweir { 134cdf0e10cSrcweir if (pLang && *pLang != nLangError ) 135cdf0e10cSrcweir { 136cdf0e10cSrcweir nLangError = *pLang; 137cdf0e10cSrcweir bShowError = sal_True; 138cdf0e10cSrcweir } 139cdf0e10cSrcweir return 0; 140cdf0e10cSrcweir } 141cdf0e10cSrcweir 142cdf0e10cSrcweir 143cdf0e10cSrcweir // ----------------------------------------------------------------------- 144cdf0e10cSrcweir sal_Bool SwHyphWrapper::SpellMore() 145cdf0e10cSrcweir { 146cdf0e10cSrcweir PSH->Push(); 147cdf0e10cSrcweir bInfoBox = sal_True; 148cdf0e10cSrcweir PSH->Combine(); 149cdf0e10cSrcweir return sal_False; 150cdf0e10cSrcweir } 151cdf0e10cSrcweir 152cdf0e10cSrcweir // ----------------------------------------------------------------------- 153cdf0e10cSrcweir 154cdf0e10cSrcweir void SwHyphWrapper::InsertHyphen( const sal_uInt16 nPos ) 155cdf0e10cSrcweir { 156cdf0e10cSrcweir if( nPos) 157cdf0e10cSrcweir PSH->InsertSoftHyph( nPos + 1); // does nPos == 1 really mean 158cdf0e10cSrcweir // insert hyphen after first char? 159cdf0e10cSrcweir // (instead of nPos == 0) 160cdf0e10cSrcweir else 161cdf0e10cSrcweir PSH->HyphIgnore(); 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir // ----------------------------------------------------------------------- 165cdf0e10cSrcweir SwHyphWrapper::~SwHyphWrapper() 166cdf0e10cSrcweir { 167cdf0e10cSrcweir if( nPageCount ) 168cdf0e10cSrcweir ::EndProgress( pView->GetDocShell() ); 169cdf0e10cSrcweir if( bInfoBox ) 170cdf0e10cSrcweir InfoBox( &pView->GetEditWin(), SW_RESSTR(STR_HYP_OK) ).Execute(); 171cdf0e10cSrcweir } 172cdf0e10cSrcweir 173