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