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