1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sc.hxx" 30*cdf0e10cSrcweir #include "spelleng.hxx" 31*cdf0e10cSrcweir #include <com/sun/star/i18n/TextConversionOption.hpp> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <memory> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include "scitems.hxx" 36*cdf0e10cSrcweir #include <editeng/eeitem.hxx> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include <editeng/langitem.hxx> 40*cdf0e10cSrcweir #include <editeng/editobj.hxx> 41*cdf0e10cSrcweir #include <editeng/editview.hxx> 42*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 43*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 44*cdf0e10cSrcweir #include <vcl/svapp.hxx> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir #include "spelldialog.hxx" 47*cdf0e10cSrcweir #include "tabvwsh.hxx" 48*cdf0e10cSrcweir #include "docsh.hxx" 49*cdf0e10cSrcweir #include "cell.hxx" 50*cdf0e10cSrcweir #include "patattr.hxx" 51*cdf0e10cSrcweir #include "waitoff.hxx" 52*cdf0e10cSrcweir #include "globstr.hrc" 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir using namespace ::com::sun::star; 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir // ============================================================================ 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir namespace { 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir bool lclHasString( ScDocument& rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString ) 62*cdf0e10cSrcweir { 63*cdf0e10cSrcweir String aCompStr; 64*cdf0e10cSrcweir rDoc.GetString( nCol, nRow, nTab, aCompStr ); 65*cdf0e10cSrcweir return aCompStr == rString; //! case-insensitive? 66*cdf0e10cSrcweir } 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir } // namespace 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir // ---------------------------------------------------------------------------- 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir ScConversionEngineBase::ScConversionEngineBase( 73*cdf0e10cSrcweir SfxItemPool* pEnginePoolP, ScViewData& rViewData, 74*cdf0e10cSrcweir ScDocument* pUndoDoc, ScDocument* pRedoDoc ) : 75*cdf0e10cSrcweir ScEditEngineDefaulter( pEnginePoolP ), 76*cdf0e10cSrcweir mrViewData( rViewData ), 77*cdf0e10cSrcweir mrDocShell( *rViewData.GetDocShell() ), 78*cdf0e10cSrcweir mrDoc( *rViewData.GetDocShell()->GetDocument() ), 79*cdf0e10cSrcweir maSelState( rViewData ), 80*cdf0e10cSrcweir mpUndoDoc( pUndoDoc ), 81*cdf0e10cSrcweir mpRedoDoc( pRedoDoc ), 82*cdf0e10cSrcweir meCurrLang( LANGUAGE_ENGLISH_US ), 83*cdf0e10cSrcweir mbIsAnyModified( false ), 84*cdf0e10cSrcweir mbInitialState( true ), 85*cdf0e10cSrcweir mbWrappedInTable( false ), 86*cdf0e10cSrcweir mbFinished( false ) 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir maSelState.GetCellCursor().GetVars( mnStartCol, mnStartRow, mnStartTab ); 89*cdf0e10cSrcweir // start with cell A1 in cell/range/multi-selection, will seek to first selected 90*cdf0e10cSrcweir if( maSelState.GetSelectionType() == SC_SELECTTYPE_SHEET ) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir mnStartCol = 0; 93*cdf0e10cSrcweir mnStartRow = 0; 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir mnCurrCol = mnStartCol; 96*cdf0e10cSrcweir mnCurrRow = mnStartRow; 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir ScConversionEngineBase::~ScConversionEngineBase() 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir bool ScConversionEngineBase::FindNextConversionCell() 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir ScMarkData& rMark = mrViewData.GetMarkData(); 106*cdf0e10cSrcweir ScTabViewShell* pViewShell = mrViewData.GetViewShell(); 107*cdf0e10cSrcweir ScBaseCell* pCell = NULL; 108*cdf0e10cSrcweir const ScPatternAttr* pPattern = NULL; 109*cdf0e10cSrcweir const ScPatternAttr* pLastPattern = NULL; 110*cdf0e10cSrcweir ::std::auto_ptr< SfxItemSet > pEditDefaults( new SfxItemSet( GetEmptyItemSet() ) ); 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir if( IsModified() ) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir mbIsAnyModified = true; 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir String aNewStr = GetText(); 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir sal_Bool bMultiTab = (rMark.GetSelectCount() > 1); 119*cdf0e10cSrcweir String aVisibleStr; 120*cdf0e10cSrcweir if( bMultiTab ) 121*cdf0e10cSrcweir mrDoc.GetString( mnCurrCol, mnCurrRow, mnStartTab, aVisibleStr ); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir for( SCTAB nTab = 0, nTabCount = mrDoc.GetTableCount(); nTab < nTabCount; ++nTab ) 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir // #69965# always change the cell on the visible tab, 126*cdf0e10cSrcweir // on the other selected tabs only if they contain the same text 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir if( (nTab == mnStartTab) || 129*cdf0e10cSrcweir (bMultiTab && rMark.GetTableSelect( nTab ) && 130*cdf0e10cSrcweir lclHasString( mrDoc, mnCurrCol, mnCurrRow, nTab, aVisibleStr )) ) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir ScAddress aPos( mnCurrCol, mnCurrRow, nTab ); 133*cdf0e10cSrcweir CellType eCellType = mrDoc.GetCellType( aPos ); 134*cdf0e10cSrcweir pCell = mrDoc.GetCell( aPos ); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir if( mpUndoDoc && pCell ) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir ScBaseCell* pUndoCell = pCell->CloneWithoutNote( *mpUndoDoc ); 139*cdf0e10cSrcweir mpUndoDoc->PutCell( aPos, pUndoCell ); 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir if( eCellType == CELLTYPE_EDIT ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir if( pCell ) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir ScEditCell* pEditCell = static_cast< ScEditCell* >( pCell ); 147*cdf0e10cSrcweir ::std::auto_ptr< EditTextObject > pEditObj( CreateTextObject() ); 148*cdf0e10cSrcweir pEditCell->SetData( pEditObj.get(), GetEditTextObjectPool() ); 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir else 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir mrDoc.SetString( mnCurrCol, mnCurrRow, nTab, aNewStr ); 154*cdf0e10cSrcweir pCell = mrDoc.GetCell( aPos ); 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir if( mpRedoDoc && pCell ) 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir ScBaseCell* pRedoCell = pCell->CloneWithoutNote( *mpRedoDoc ); 160*cdf0e10cSrcweir mpRedoDoc->PutCell( aPos, pRedoCell ); 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir mrDocShell.PostPaintCell( mnCurrCol, mnCurrRow, nTab ); 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir pCell = NULL; 168*cdf0e10cSrcweir SCCOL nNewCol = mnCurrCol; 169*cdf0e10cSrcweir SCROW nNewRow = mnCurrRow; 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir if( mbInitialState ) 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir /* On very first call, decrement row to let GetNextSpellingCell() find 174*cdf0e10cSrcweir the first cell of current range. */ 175*cdf0e10cSrcweir mbInitialState = false; 176*cdf0e10cSrcweir --nNewRow; 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir bool bSheetSel = maSelState.GetSelectionType() == SC_SELECTTYPE_SHEET; 180*cdf0e10cSrcweir bool bLoop = true; 181*cdf0e10cSrcweir bool bFound = false; 182*cdf0e10cSrcweir while( bLoop && !bFound ) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir bLoop = mrDoc.GetNextSpellingCell( nNewCol, nNewRow, mnStartTab, bSheetSel, rMark ); 185*cdf0e10cSrcweir if( bLoop ) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir FillFromCell( mnCurrCol, mnCurrRow, mnStartTab ); 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir if( mbWrappedInTable && ((nNewCol > mnStartCol) || ((nNewCol == mnStartCol) && (nNewRow >= mnStartRow))) ) 190*cdf0e10cSrcweir { 191*cdf0e10cSrcweir ShowFinishDialog(); 192*cdf0e10cSrcweir bLoop = false; 193*cdf0e10cSrcweir mbFinished = true; 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir else if( nNewCol > MAXCOL ) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir // no more cells in the sheet - try to restart at top of sheet 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir if( bSheetSel || ((mnStartCol == 0) && (mnStartRow == 0)) ) 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir // conversion started at cell A1 or in selection, do not query to restart at top 202*cdf0e10cSrcweir ShowFinishDialog(); 203*cdf0e10cSrcweir bLoop = false; 204*cdf0e10cSrcweir mbFinished = true; 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir else if( ShowTableWrapDialog() ) 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir // conversion started anywhere but in cell A1, user wants to restart 209*cdf0e10cSrcweir nNewRow = MAXROW + 2; 210*cdf0e10cSrcweir mbWrappedInTable = true; 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir else 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir bLoop = false; 215*cdf0e10cSrcweir mbFinished = true; 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir else 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir pPattern = mrDoc.GetPattern( nNewCol, nNewRow, mnStartTab ); 221*cdf0e10cSrcweir if( pPattern && (pPattern != pLastPattern) ) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir pPattern->FillEditItemSet( pEditDefaults.get() ); 224*cdf0e10cSrcweir SetDefaults( *pEditDefaults ); 225*cdf0e10cSrcweir pLastPattern = pPattern; 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir // language changed? 229*cdf0e10cSrcweir const SfxPoolItem* pItem = mrDoc.GetAttr( nNewCol, nNewRow, mnStartTab, ATTR_FONT_LANGUAGE ); 230*cdf0e10cSrcweir if( const SvxLanguageItem* pLangItem = PTR_CAST( SvxLanguageItem, pItem ) ) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir LanguageType eLang = static_cast< LanguageType >( pLangItem->GetValue() ); 233*cdf0e10cSrcweir if( eLang == LANGUAGE_SYSTEM ) 234*cdf0e10cSrcweir eLang = Application::GetSettings().GetLanguage(); // never use SYSTEM for spelling 235*cdf0e10cSrcweir if( eLang != meCurrLang ) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir meCurrLang = eLang; 238*cdf0e10cSrcweir SetDefaultLanguage( eLang ); 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir FillFromCell( nNewCol, nNewRow, mnStartTab ); 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir bFound = bLoop && NeedsConversion(); 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir if( bFound ) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir pViewShell->AlignToCursor( nNewCol, nNewRow, SC_FOLLOW_JUMP ); 252*cdf0e10cSrcweir pViewShell->SetCursor( nNewCol, nNewRow, sal_True ); 253*cdf0e10cSrcweir mrViewData.GetView()->MakeEditView( this, nNewCol, nNewRow ); 254*cdf0e10cSrcweir EditView* pEditView = mrViewData.GetSpellingView(); 255*cdf0e10cSrcweir // maSelState.GetEditSelection() returns (0,0) if not in edit mode -> ok 256*cdf0e10cSrcweir pEditView->SetSelection( maSelState.GetEditSelection() ); 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir ClearModifyFlag(); 259*cdf0e10cSrcweir mnCurrCol = nNewCol; 260*cdf0e10cSrcweir mnCurrRow = nNewRow; 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir return bFound; 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir void ScConversionEngineBase::RestoreCursorPos() 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir const ScAddress& rPos = maSelState.GetCellCursor(); 269*cdf0e10cSrcweir mrViewData.GetViewShell()->SetCursor( rPos.Col(), rPos.Row() ); 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir bool ScConversionEngineBase::ShowTableWrapDialog() 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir // default: no dialog, always restart at top 275*cdf0e10cSrcweir return true; 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir void ScConversionEngineBase::ShowFinishDialog() 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir // default: no dialog 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir // private -------------------------------------------------------------------- 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir void ScConversionEngineBase::FillFromCell( SCCOL nCol, SCROW nRow, SCTAB nTab ) 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir CellType eCellType; 288*cdf0e10cSrcweir mrDoc.GetCellType( nCol, nRow, nTab, eCellType ); 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir switch( eCellType ) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir case CELLTYPE_STRING: 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir String aText; 295*cdf0e10cSrcweir mrDoc.GetString( nCol, nRow, nTab, aText ); 296*cdf0e10cSrcweir SetText( aText ); 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir break; 299*cdf0e10cSrcweir case CELLTYPE_EDIT: 300*cdf0e10cSrcweir { 301*cdf0e10cSrcweir ScBaseCell* pCell = NULL; 302*cdf0e10cSrcweir mrDoc.GetCell( nCol, nRow, nTab, pCell ); 303*cdf0e10cSrcweir if( pCell ) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir const EditTextObject* pNewEditObj = NULL; 306*cdf0e10cSrcweir static_cast< ScEditCell* >( pCell )->GetData( pNewEditObj ); 307*cdf0e10cSrcweir if( pNewEditObj ) 308*cdf0e10cSrcweir SetText( *pNewEditObj ); 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir break; 312*cdf0e10cSrcweir default: 313*cdf0e10cSrcweir SetText( EMPTY_STRING ); 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir // ============================================================================ 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir ScSpellingEngine::ScSpellingEngine( 320*cdf0e10cSrcweir SfxItemPool* pEnginePoolP, ScViewData& rViewData, 321*cdf0e10cSrcweir ScDocument* pUndoDoc, ScDocument* pRedoDoc, 322*cdf0e10cSrcweir XSpellCheckerRef xSpeller ) : 323*cdf0e10cSrcweir ScConversionEngineBase( pEnginePoolP, rViewData, pUndoDoc, pRedoDoc ) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir SetSpeller( xSpeller ); 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir void ScSpellingEngine::ConvertAll( EditView& rEditView ) 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir EESpellState eState = EE_SPELL_OK; 331*cdf0e10cSrcweir if( FindNextConversionCell() ) 332*cdf0e10cSrcweir eState = rEditView.StartSpeller( static_cast< sal_Bool >( sal_True ) ); 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir DBG_ASSERT( eState != EE_SPELL_NOSPELLER, "ScSpellingEngine::Convert - no spell checker" ); 335*cdf0e10cSrcweir if( eState == EE_SPELL_NOLANGUAGE ) 336*cdf0e10cSrcweir { 337*cdf0e10cSrcweir Window* pParent = GetDialogParent(); 338*cdf0e10cSrcweir ScWaitCursorOff aWaitOff( pParent ); 339*cdf0e10cSrcweir InfoBox( pParent, ScGlobal::GetRscString( STR_NOLANGERR ) ).Execute(); 340*cdf0e10cSrcweir } 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir sal_Bool ScSpellingEngine::SpellNextDocument() 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir return FindNextConversionCell(); 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir bool ScSpellingEngine::NeedsConversion() 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir return HasSpellErrors() != EE_SPELL_OK; 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir bool ScSpellingEngine::ShowTableWrapDialog() 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir Window* pParent = GetDialogParent(); 356*cdf0e10cSrcweir ScWaitCursorOff aWaitOff( pParent ); 357*cdf0e10cSrcweir MessBox aMsgBox( pParent, WinBits( WB_YES_NO | WB_DEF_YES ), 358*cdf0e10cSrcweir ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), 359*cdf0e10cSrcweir ScGlobal::GetRscString( STR_SPELLING_BEGIN_TAB) ); 360*cdf0e10cSrcweir return aMsgBox.Execute() == RET_YES; 361*cdf0e10cSrcweir } 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir void ScSpellingEngine::ShowFinishDialog() 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir Window* pParent = GetDialogParent(); 366*cdf0e10cSrcweir ScWaitCursorOff aWaitOff( pParent ); 367*cdf0e10cSrcweir InfoBox( pParent, ScGlobal::GetRscString( STR_SPELLING_STOP_OK ) ).Execute(); 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir Window* ScSpellingEngine::GetDialogParent() 371*cdf0e10cSrcweir { 372*cdf0e10cSrcweir sal_uInt16 nWinId = ScSpellDialogChildWindow::GetChildWindowId(); 373*cdf0e10cSrcweir SfxViewFrame* pViewFrm = mrViewData.GetViewShell()->GetViewFrame(); 374*cdf0e10cSrcweir if( pViewFrm->HasChildWindow( nWinId ) ) 375*cdf0e10cSrcweir if( SfxChildWindow* pChild = pViewFrm->GetChildWindow( nWinId ) ) 376*cdf0e10cSrcweir if( Window* pWin = pChild->GetWindow() ) 377*cdf0e10cSrcweir if( pWin->IsVisible() ) 378*cdf0e10cSrcweir return pWin; 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir // fall back to standard dialog parent 381*cdf0e10cSrcweir return mrDocShell.GetActiveDialogParent(); 382*cdf0e10cSrcweir } 383*cdf0e10cSrcweir 384*cdf0e10cSrcweir // ============================================================================ 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir ScConversionParam::ScConversionParam( ScConversionType eConvType ) : 387*cdf0e10cSrcweir meConvType( eConvType ), 388*cdf0e10cSrcweir meSourceLang( LANGUAGE_NONE ), 389*cdf0e10cSrcweir meTargetLang( LANGUAGE_NONE ), 390*cdf0e10cSrcweir mnOptions( 0 ), 391*cdf0e10cSrcweir mbUseTargetFont( false ), 392*cdf0e10cSrcweir mbIsInteractive( false ) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir ScConversionParam::ScConversionParam( ScConversionType eConvType, 397*cdf0e10cSrcweir LanguageType eLang, sal_Int32 nOptions, bool bIsInteractive ) : 398*cdf0e10cSrcweir meConvType( eConvType ), 399*cdf0e10cSrcweir meSourceLang( eLang ), 400*cdf0e10cSrcweir meTargetLang( eLang ), 401*cdf0e10cSrcweir mnOptions( nOptions ), 402*cdf0e10cSrcweir mbUseTargetFont( false ), 403*cdf0e10cSrcweir mbIsInteractive( bIsInteractive ) 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir if (LANGUAGE_KOREAN == eLang) 406*cdf0e10cSrcweir mnOptions = i18n::TextConversionOption::CHARACTER_BY_CHARACTER; 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir ScConversionParam::ScConversionParam( ScConversionType eConvType, 410*cdf0e10cSrcweir LanguageType eSourceLang, LanguageType eTargetLang, const Font& rTargetFont, 411*cdf0e10cSrcweir sal_Int32 nOptions, bool bIsInteractive ) : 412*cdf0e10cSrcweir meConvType( eConvType ), 413*cdf0e10cSrcweir meSourceLang( eSourceLang ), 414*cdf0e10cSrcweir meTargetLang( eTargetLang ), 415*cdf0e10cSrcweir maTargetFont( rTargetFont ), 416*cdf0e10cSrcweir mnOptions( nOptions ), 417*cdf0e10cSrcweir mbUseTargetFont( true ), 418*cdf0e10cSrcweir mbIsInteractive( bIsInteractive ) 419*cdf0e10cSrcweir { 420*cdf0e10cSrcweir if (LANGUAGE_KOREAN == meSourceLang && LANGUAGE_KOREAN == meTargetLang) 421*cdf0e10cSrcweir mnOptions = i18n::TextConversionOption::CHARACTER_BY_CHARACTER; 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir // ---------------------------------------------------------------------------- 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir ScTextConversionEngine::ScTextConversionEngine( 427*cdf0e10cSrcweir SfxItemPool* pEnginePoolP, ScViewData& rViewData, 428*cdf0e10cSrcweir const ScConversionParam& rConvParam, 429*cdf0e10cSrcweir ScDocument* pUndoDoc, ScDocument* pRedoDoc ) : 430*cdf0e10cSrcweir ScConversionEngineBase( pEnginePoolP, rViewData, pUndoDoc, pRedoDoc ), 431*cdf0e10cSrcweir maConvParam( rConvParam ) 432*cdf0e10cSrcweir { 433*cdf0e10cSrcweir } 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir void ScTextConversionEngine::ConvertAll( EditView& rEditView ) 436*cdf0e10cSrcweir { 437*cdf0e10cSrcweir if( FindNextConversionCell() ) 438*cdf0e10cSrcweir { 439*cdf0e10cSrcweir rEditView.StartTextConversion( 440*cdf0e10cSrcweir maConvParam.GetSourceLang(), maConvParam.GetTargetLang(), maConvParam.GetTargetFont(), 441*cdf0e10cSrcweir maConvParam.GetOptions(), maConvParam.IsInteractive(), sal_True ); 442*cdf0e10cSrcweir // #i34769# restore initial cursor position 443*cdf0e10cSrcweir RestoreCursorPos(); 444*cdf0e10cSrcweir } 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir sal_Bool ScTextConversionEngine::ConvertNextDocument() 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir return FindNextConversionCell(); 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir bool ScTextConversionEngine::NeedsConversion() 453*cdf0e10cSrcweir { 454*cdf0e10cSrcweir return HasConvertibleTextPortion( maConvParam.GetSourceLang() ); 455*cdf0e10cSrcweir } 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir // ============================================================================ 458*cdf0e10cSrcweir 459