xref: /aoo42x/main/sw/source/ui/ribbar/inputwin.cxx (revision cdf0e10c)
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 #include <tools/gen.hxx>
33 #include <sfx2/imgmgr.hxx>
34 #include <sfx2/viewfrm.hxx>
35 #include <sfx2/dispatch.hxx>
36 #include <svx/ruler.hxx>
37 #include <svl/zforlist.hxx>
38 #include <svl/stritem.hxx>
39 #include <unotools/undoopt.hxx>
40 
41 #include "swtypes.hxx"
42 #include "cmdid.h"
43 #include "swmodule.hxx"
44 #include "wrtsh.hxx"
45 #include "view.hxx"
46 #include "calc.hxx"
47 #include "inputwin.hxx"
48 #include "fldbas.hxx"
49 #include "fldmgr.hxx"
50 #include "frmfmt.hxx"
51 #include "cellatr.hxx"
52 #include "edtwin.hxx"
53 #include "helpid.h"
54 
55 // nur fuers UpdateRange - Box in dem der gestackte Cursor sthet loeschen
56 #include "pam.hxx"
57 
58 #include "swundo.hxx"
59 #include "ribbar.hrc"
60 #include "inputwin.hrc"
61 
62 #include <IDocumentContentOperations.hxx>
63 
64 SFX_IMPL_POS_CHILDWINDOW( SwInputChild, FN_EDIT_FORMULA, SFX_OBJECTBAR_OBJECT )
65 
66 //==================================================================
67 
68 SwInputWindow::SwInputWindow( Window* pParent, SfxBindings* pBind )
69 	: ToolBox( 	pParent ,	SW_RES( RID_TBX_FORMULA )),
70     aPos(       this,       SW_RES(ED_POS)),
71 	aEdit(      this, WB_3DLOOK|WB_TABSTOP|WB_BORDER|WB_NOHIDESELECTION),
72 	aPopMenu(	SW_RES(MN_CALC_POPUP)),
73 	pMgr(0),
74     pWrtShell(0),
75 	pView(0),
76     pBindings(pBind),
77 	aAktTableName(aEmptyStr)
78     , m_nActionCount(0)
79     , m_bDoesUndo(true)
80     , m_bResetUndo(false)
81     , m_bCallUndo(false)
82 {
83     bFirst = sal_True;
84     bActive = bIsTable = bDelSel = sal_False;
85 
86 	FreeResource();
87 
88 	aEdit.SetSizePixel( aEdit.CalcMinimumSize() );
89 
90     SfxImageManager* pManager = SfxImageManager::GetImageManager( SW_MOD() );
91     pManager->RegisterToolBox(this);
92 
93 	pView = ::GetActiveView();
94 	pWrtShell = pView ? pView->GetWrtShellPtr() : 0;
95 
96 	InsertWindow( ED_POS, &aPos, 0, 0);
97 	InsertSeparator ( 1 );
98 	InsertSeparator ();
99 	InsertWindow( ED_FORMULA, &aEdit);
100 	SetHelpId(ED_FORMULA, HID_EDIT_FORMULA);
101 
102     sal_Bool bHC = GetSettings().GetStyleSettings().GetHighContrastMode();
103     SetItemImage( FN_FORMULA_CALC, pManager->GetImage(FN_FORMULA_CALC, bHC ));
104 	SetItemImage( FN_FORMULA_CANCEL, pManager->GetImage(FN_FORMULA_CANCEL, bHC  ));
105 	SetItemImage( FN_FORMULA_APPLY, pManager->GetImage(FN_FORMULA_APPLY, bHC  ));
106 
107     SetItemBits( FN_FORMULA_CALC, GetItemBits( FN_FORMULA_CALC ) | TIB_DROPDOWNONLY );
108     SetDropdownClickHdl( LINK( this, SwInputWindow, DropdownClickHdl ));
109 
110 	Size	aSizeTbx = CalcWindowSizePixel();
111 	Size 	aEditSize = aEdit.GetSizePixel();
112 	Rectangle aItemRect( GetItemRect(FN_FORMULA_CALC) );
113 	long nMaxHeight = (aEditSize.Height() > aItemRect.GetHeight()) ? aEditSize.Height() : aItemRect.GetHeight();
114 	if( nMaxHeight+2 > aSizeTbx.Height() )
115 	    aSizeTbx.Height() = nMaxHeight+2;
116 	Size aSize = GetSizePixel();
117 	aSize.Height() = aSizeTbx.Height();
118 	SetSizePixel( aSize );
119 
120 	// align edit and item vcentered
121 	Size 	aPosSize = aPos.GetSizePixel();
122 	aPosSize.Height()  = nMaxHeight;
123 	aEditSize.Height() = nMaxHeight;
124 	Point aPosPos  = aPos.GetPosPixel();
125 	Point aEditPos = aEdit.GetPosPixel();
126 	aPosPos.Y()    = (aSize.Height() - nMaxHeight)/2 + 1;
127 	aEditPos.Y()   = (aSize.Height() - nMaxHeight)/2 + 1;
128 	aPos.SetPosSizePixel( aPosPos, aPosSize );
129 	aEdit.SetPosSizePixel( aEditPos, aEditSize );
130 
131 	aPopMenu.SetSelectHdl(LINK( this, SwInputWindow, MenuHdl ));
132 }
133 
134 //==================================================================
135 
136 __EXPORT SwInputWindow::~SwInputWindow()
137 {
138     SfxImageManager::GetImageManager( SW_MOD() )->ReleaseToolBox(this);
139 
140 	//Lineale aufwecken
141 	if(pView)
142 	{
143         pView->GetHLineal().SetActive( sal_True );
144         pView->GetVLineal().SetActive( sal_True );
145 	}
146 	if ( pMgr )
147 		delete pMgr;
148 	if(pWrtShell)
149 		pWrtShell->EndSelTblCells();
150 
151     CleanupUglyHackWithUndo();
152 }
153 
154 void SwInputWindow::CleanupUglyHackWithUndo()
155 {
156     if (m_bResetUndo)
157     {
158         DelBoxCntnt();
159         pWrtShell->DoUndo(m_bDoesUndo);
160         if (m_bCallUndo)
161         {
162             pWrtShell->Undo();
163         }
164         if (0 == m_nActionCount)
165         {
166             SW_MOD()->GetUndoOptions().SetUndoCount(0);
167         }
168         m_bResetUndo = false; // #i117122# once is enough :)
169     }
170 }
171 
172 
173 //==================================================================
174 
175 void SwInputWindow::DataChanged( const DataChangedEvent& rDCEvt )
176 {
177     if ( rDCEvt.GetType() == DATACHANGED_SETTINGS && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
178     {
179         //      update item images
180         SwModule *pMod  = SW_MOD();
181         SfxImageManager *pImgMgr = SfxImageManager::GetImageManager( pMod );
182         sal_Bool bHC = GetSettings().GetStyleSettings().GetHighContrastMode();
183         //
184         SetItemImage( FN_FORMULA_CALC,   pImgMgr->GetImage(FN_FORMULA_CALC,   bHC ));
185         SetItemImage( FN_FORMULA_CANCEL, pImgMgr->GetImage(FN_FORMULA_CANCEL, bHC ));
186         SetItemImage( FN_FORMULA_APPLY,  pImgMgr->GetImage(FN_FORMULA_APPLY,  bHC ));
187     }
188 
189     ToolBox::DataChanged( rDCEvt );
190 }
191 
192 //==================================================================
193 
194 void __EXPORT SwInputWindow::Resize()
195 {
196 	ToolBox::Resize();
197 
198 	long	nWidth		= GetSizePixel().Width();
199 	long	nLeft		= aEdit.GetPosPixel().X();
200 	Size	aEditSize	= aEdit.GetSizePixel();
201 
202 	aEditSize.Width() = Max( ((long)(nWidth - nLeft - 5)), (long)0 );
203 	aEdit.SetSizePixel( aEditSize );
204 	aEdit.Invalidate();
205 }
206 
207 //==================================================================
208 
209 void SwInputWindow::ShowWin()
210 {
211 	bIsTable = sal_False;
212 	//Lineale anhalten
213 	if(pView)
214 	{
215         pView->GetHLineal().SetActive( sal_False );
216         pView->GetVLineal().SetActive( sal_False );
217 
218 		DBG_ASSERT(pWrtShell, "Keine WrtShell!");
219 		// Cursor in Tabelle
220 		bIsTable = pWrtShell->IsCrsrInTbl() ? sal_True : sal_False;
221 
222 		if( bFirst )
223 			pWrtShell->SelTblCells( LINK( this, SwInputWindow,
224 												SelTblCellsNotify) );
225 		if( bIsTable )
226 		{
227 			const String& rPos = pWrtShell->GetBoxNms();
228 			sal_uInt16 nPos = 0;
229 			short nSrch = -1;
230 			while( (nPos = rPos.Search( ':',nPos + 1 ) ) != STRING_NOTFOUND )
231 				nSrch = (short) nPos;
232 			aPos.SetText( rPos.Copy( ++nSrch ) );
233 			aAktTableName = pWrtShell->GetTableFmt()->GetName();
234 		}
235 		else
236             aPos.SetText(SW_RESSTR(STR_TBL_FORMULA));
237 
238 		// Aktuelles Feld bearbeiten
239 		ASSERT(pMgr == 0, FieldManager nicht geloescht.);
240 		pMgr = new SwFldMgr;
241 
242 		// JP 13.01.97: Formel soll immer mit einem "=" beginnen, hier
243 		//				also setzen
244 		String sEdit( '=' );
245 		if( pMgr->GetCurFld() && TYP_FORMELFLD == pMgr->GetCurTypeId() )
246 		{
247 			sEdit += pMgr->GetCurFldPar2();
248 		}
249 		else if( bFirst )
250 		{
251 			if( bIsTable )
252             {
253                 m_bResetUndo = true;
254                 m_nActionCount = SW_MOD()->GetUndoOptions().GetUndoCount();
255                 if (0 == m_nActionCount) { // deactivated? turn it on...
256                     SW_MOD()->GetUndoOptions().SetUndoCount(1);
257                 }
258 
259                 m_bDoesUndo = pWrtShell->DoesUndo();
260                 if( !m_bDoesUndo )
261                 {
262                     pWrtShell->DoUndo( sal_True );
263                 }
264 
265 				if( !pWrtShell->SwCrsrShell::HasSelection() )
266 				{
267 					pWrtShell->MoveSection( fnSectionCurr, fnSectionStart );
268 					pWrtShell->SetMark();
269 					pWrtShell->MoveSection( fnSectionCurr, fnSectionEnd );
270 				}
271 				if( pWrtShell->SwCrsrShell::HasSelection() )
272 				{
273 					pWrtShell->StartUndo( UNDO_DELETE );
274 					pWrtShell->Delete();
275 					if( 0 != pWrtShell->EndUndo( UNDO_DELETE ))
276                     {
277                         m_bCallUndo = true;
278                     }
279                 }
280                 pWrtShell->DoUndo(false);
281 
282 				SfxItemSet aSet( pWrtShell->GetAttrPool(), RES_BOXATR_FORMULA, RES_BOXATR_FORMULA );
283 				if( pWrtShell->GetTblBoxFormulaAttrs( aSet ))
284 					sEdit += ((SwTblBoxFormula&)aSet.Get( RES_BOXATR_FORMULA )).GetFormula();
285 			}
286 		}
287 
288 		if( bFirst )
289 		{
290 			// WrtShell Flags richtig setzen
291 			pWrtShell->SttSelect();
292 			pWrtShell->EndSelect();
293 		}
294 
295 		bFirst = sal_False;
296 
297 		aEdit.SetModifyHdl( LINK( this, SwInputWindow, ModifyHdl ));
298 
299 		aEdit.SetText( sEdit );
300 		aEdit.SetSelection( Selection( sEdit.Len(), sEdit.Len() ) );
301 		sOldFml = sEdit;
302 
303 		aEdit.Invalidate();
304 		aEdit.Update();
305 		aEdit.GrabFocus();
306 		// UserInterface fuer die Eingabe abklemmen
307 
308 		pView->GetEditWin().LockKeyInput(sal_True);
309 		pView->GetViewFrame()->GetDispatcher()->Lock(sal_True);
310 		pWrtShell->Push();
311 	}
312 	ToolBox::Show();
313 }
314 //==================================================================
315 
316 IMPL_LINK( SwInputWindow, MenuHdl, Menu *, pMenu )
317 {
318 static const char * __READONLY_DATA aStrArr[] = {
319 	sCalc_Phd,
320 	sCalc_Sqrt,
321 	sCalc_Or,
322 	sCalc_Xor,
323 	sCalc_And,
324 	sCalc_Not,
325 	sCalc_Eq,
326 	sCalc_Neq,
327 	sCalc_Leq,
328 	sCalc_Geq,
329 	sCalc_L,
330 	sCalc_G,
331 	sCalc_Sum,
332 	sCalc_Mean,
333 	sCalc_Min,
334 	sCalc_Max,
335 	sCalc_Sin,
336 	sCalc_Cos,
337 	sCalc_Tan,
338 	sCalc_Asin,
339 	sCalc_Acos,
340 	sCalc_Atan,
341 	sCalc_Pow,
342 	"|",
343 	sCalc_Round
344 };
345 
346 	sal_uInt16 nId = pMenu->GetCurItemId();
347 	if ( nId <= MN_CALC_ROUND )
348 	{
349 		String aTmp( String::CreateFromAscii(aStrArr[nId - 1]) );
350 		aTmp += ' ';
351 		aEdit.ReplaceSelected( aTmp );
352 	}
353 	return 0;
354 }
355 
356 IMPL_LINK( SwInputWindow, DropdownClickHdl, ToolBox*, EMPTYARG )
357 {
358 	sal_uInt16 nCurID = GetCurItemId();
359 	EndSelection();	// setzt CurItemId zurueck !
360 	switch ( nCurID )
361 	{
362 		case FN_FORMULA_CALC :
363 		{
364             aPopMenu.Execute( this, GetItemRect( FN_FORMULA_CALC ), POPUPMENU_NOMOUSEUPCLOSE );
365             break;
366         default:
367             break;
368         }
369     }
370 
371     return sal_True;
372 }
373 
374 //==================================================================
375 
376 
377 void __EXPORT SwInputWindow::Click( )
378 {
379 	sal_uInt16 nCurID = GetCurItemId();
380 	EndSelection();	// setzt CurItemId zurueck !
381 	switch ( nCurID )
382 	{
383 		case FN_FORMULA_CANCEL:
384 		{
385 			CancelFormula();
386 		}
387 		break;
388 		case FN_FORMULA_APPLY:
389 		{
390 			ApplyFormula();
391 		}
392 		break;
393    }
394 }
395 
396 //==================================================================
397 
398 void  SwInputWindow::ApplyFormula()
399 {
400 	pView->GetViewFrame()->GetDispatcher()->Lock(sal_False);
401 	pView->GetEditWin().LockKeyInput(sal_False);
402     CleanupUglyHackWithUndo();
403 	pWrtShell->Pop( sal_False );
404 
405 	// JP 13.01.97: Formel soll immer mit einem "=" beginnen, hier
406 	//				also wieder entfernen
407 	String sEdit( aEdit.GetText() );
408 	sEdit.EraseLeadingChars().EraseTrailingChars();
409 	if( sEdit.Len() && '=' == sEdit.GetChar( 0 ) )
410 		sEdit.Erase( 0, 1 );
411     SfxStringItem aParam(FN_EDIT_FORMULA, sEdit);
412 
413 	pWrtShell->EndSelTblCells();
414 	pView->GetEditWin().GrabFocus();
415     const SfxPoolItem* aArgs[2];
416     aArgs[0] = &aParam;
417     aArgs[1] = 0;
418     pView->GetViewFrame()->GetBindings().Execute( FN_EDIT_FORMULA, aArgs, 0, SFX_CALLMODE_ASYNCHRON );
419 }
420 
421 //==================================================================
422 
423 void  SwInputWindow::CancelFormula()
424 {
425 	if(pView)
426 	{
427 		pView->GetViewFrame()->GetDispatcher()->Lock( sal_False );
428 		pView->GetEditWin().LockKeyInput(sal_False);
429         CleanupUglyHackWithUndo();
430 		pWrtShell->Pop( sal_False );
431 
432 		if( bDelSel )
433 			pWrtShell->EnterStdMode();
434 
435 		pWrtShell->EndSelTblCells();
436 
437 		pView->GetEditWin().GrabFocus();
438 	}
439 	pView->GetViewFrame()->GetDispatcher()->Execute( FN_EDIT_FORMULA, SFX_CALLMODE_ASYNCHRON);
440 }
441 //==================================================================
442 
443 const xub_Unicode CH_LRE = 0x202a;
444 const xub_Unicode CH_PDF = 0x202c;
445 
446 IMPL_LINK( SwInputWindow, SelTblCellsNotify, SwWrtShell *, pCaller )
447 {
448 	if(bIsTable)
449 	{
450 		SwFrmFmt* pTblFmt = pCaller->GetTableFmt();
451 		String sBoxNms( pCaller->GetBoxNms() );
452 		String sTblNm;
453 		if( pTblFmt && aAktTableName != pTblFmt->GetName() )
454 			sTblNm = pTblFmt->GetName();
455 
456 		aEdit.UpdateRange( sBoxNms, sTblNm );
457 
458 		String sNew;
459         sNew += CH_LRE;
460         sNew += aEdit.GetText();
461         sNew += CH_PDF;
462 
463         if( sNew != sOldFml )
464 		{
465 			// Die WrtShell ist in der Tabellen Selektion
466 			// dann die Tabellen Selektion wieder aufheben, sonst steht der
467 			// Cursor "im Wald" und das LiveUpdate funktioniert nicht!
468 			pWrtShell->StartAllAction();
469 
470 			SwPaM aPam( *pWrtShell->GetStkCrsr()->GetPoint() );
471 			aPam.Move( fnMoveBackward, fnGoSection );
472 			aPam.SetMark();
473 			aPam.Move( fnMoveForward, fnGoSection );
474 
475             IDocumentContentOperations* pIDCO = pWrtShell->getIDocumentContentOperations();
476             pIDCO->DeleteRange( aPam );
477             pIDCO->InsertString( aPam, sNew );
478 			pWrtShell->EndAllAction();
479 			sOldFml = sNew;
480 		}
481 	}
482 	else
483 		aEdit.GrabFocus();
484 	return 0;
485 }
486 
487 
488 void SwInputWindow::SetFormula( const String& rFormula, sal_Bool bDelFlag )
489 {
490 	String sEdit( '=' );
491 	if( rFormula.Len() )
492 	{
493 		if( '=' == rFormula.GetChar( 0 ) )
494 			sEdit = rFormula;
495 		else
496 			sEdit += rFormula;
497 	}
498 	aEdit.SetText( sEdit );
499 	aEdit.SetSelection( Selection( sEdit.Len(), sEdit.Len() ) );
500 	aEdit.Invalidate();
501 	bDelSel = bDelFlag;
502 }
503 
504 IMPL_LINK( SwInputWindow, ModifyHdl, InputEdit*, EMPTYARG )
505 {
506     if (bIsTable && m_bResetUndo)
507 	{
508 		pWrtShell->StartAllAction();
509 		DelBoxCntnt();
510 		String sNew;
511         sNew += CH_LRE;
512         sNew += aEdit.GetText();
513         sNew += CH_PDF;
514         pWrtShell->SwEditShell::Insert2( sNew );
515 		pWrtShell->EndAllAction();
516 		sOldFml = sNew;
517 	}
518 	return 0;
519 }
520 
521 
522 void SwInputWindow::DelBoxCntnt()
523 {
524 	if( bIsTable )
525 	{
526 		pWrtShell->StartAllAction();
527 		pWrtShell->ClearMark();
528 		pWrtShell->Pop( sal_False );
529 		pWrtShell->Push();
530 		pWrtShell->MoveSection( fnSectionCurr, fnSectionStart );
531 		pWrtShell->SetMark();
532 		pWrtShell->MoveSection( fnSectionCurr, fnSectionEnd );
533 		pWrtShell->SwEditShell::Delete();
534 		pWrtShell->EndAllAction();
535 	}
536 }
537 
538 //==================================================================
539 
540 void __EXPORT InputEdit::KeyInput(const KeyEvent& rEvent)
541 {
542 	const KeyCode aCode = rEvent.GetKeyCode();
543 	if(aCode == KEY_RETURN || aCode == KEY_F2 )
544 		((SwInputWindow*)GetParent())->ApplyFormula();
545 	else if(aCode == KEY_ESCAPE )
546 		((SwInputWindow*)GetParent())->CancelFormula();
547 	else
548 		Edit::KeyInput(rEvent);
549 }
550 
551 //==================================================================
552 
553 void __EXPORT InputEdit::UpdateRange(const String& rBoxes,
554 									const String& rName )
555 {
556 	if( !rBoxes.Len() )
557 	{
558 		GrabFocus();
559 		return;
560 	}
561 	const sal_Unicode	cOpen = '<', cClose = '>',
562                 cOpenBracket = '(';
563 	String aPrefix = rName;
564 	if(rName.Len())
565 		aPrefix += '.';
566 	String aBoxes = aPrefix;
567 	aBoxes += rBoxes;
568 	Selection aSelection(GetSelection());
569 	sal_uInt16 nSel = (sal_uInt16) aSelection.Len();
570 	//OS: mit dem folgenden Ausdruck wird sichergestellt, dass im overwrite-Modus
571 	//die selektierte schliessende Klammer nicht geloescht wird
572 	if( nSel && ( nSel > 1 ||
573 		GetText().GetChar( (sal_uInt16)aSelection.Min() ) != cClose ) )
574 		Cut();
575 	else
576 		aSelection.Max() = aSelection.Min();
577 	String aActText(GetText());
578 	const sal_uInt16 nLen = aActText.Len();
579 	if( !nLen )
580 	{
581 		String aStr(cOpen);
582 		aStr += aBoxes;
583 		aStr += cClose;
584 		SetText(aStr);
585 		sal_uInt16 nPos = aStr.Search( cClose );
586 		ASSERT(nPos < aStr.Len(), Delimiter nicht gefunden.);
587 		++nPos;
588 		SetSelection( Selection( nPos, nPos ));
589 	}
590 	else
591 	{
592 		sal_Bool bFound = sal_False;
593 		sal_Unicode cCh;
594         sal_uInt16 nPos, nEndPos = 0, nStartPos = (sal_uInt16) aSelection.Min();
595 		if( nStartPos-- )
596 		{
597 			do {
598 				if( cOpen  == (cCh = aActText.GetChar( nStartPos ) ) ||
599 					cOpenBracket == cCh )
600 				{
601 					bFound = cCh == cOpen;
602 					break;
603 				}
604 			} while( nStartPos-- > 0 );
605 		}
606 		if( bFound )
607 		{
608 			bFound = sal_False;
609 			nEndPos = nStartPos;
610 			while( nEndPos < nLen )
611 			{
612 				if( cClose == (cCh = aActText.GetChar( nEndPos )) /*||
613 					cCh == cCloseBracket*/ )
614 				{
615 					bFound = sal_True;
616 					break;
617 				}
618 				++nEndPos;
619 			}
620 			// nur wenn akt. Pos im Breich oder direkt dahinter liegt
621 			if( bFound && !( nStartPos < (sal_uInt16)aSelection.Max() &&
622 							 (sal_uInt16)aSelection.Max() <= nEndPos + 1 ))
623 				bFound = sal_False;
624 		}
625 		if( bFound )
626 		{
627 			nPos = ++nStartPos + 1; // wir wollen dahinter
628 			aActText.Erase( nStartPos, nEndPos - nStartPos );
629 			aActText.Insert( aBoxes, nStartPos );
630             nPos = nPos + aBoxes.Len();
631 		}
632 		else
633 		{
634 			String aTmp( (char)cOpen );
635 			aTmp += aBoxes;
636 			aTmp += (char)cClose;
637 			nPos = (sal_uInt16)aSelection.Min();
638 			aActText.Insert( aTmp, nPos );
639             nPos = nPos + aTmp.Len();
640 		}
641 		if( GetText() != aActText )
642 		{
643 			SetText( aActText );
644 			SetSelection( Selection( nPos, nPos ) );
645 //			GetModifyHdl().Call( this );
646 		}
647 	}
648 	GrabFocus();
649 
650 }
651 //==================================================================
652 
653 
654 SwInputChild::SwInputChild(Window* _pParent,
655 								sal_uInt16 nId,
656                                 SfxBindings* pBindings,
657 								SfxChildWinInfo* ) :
658                                 SfxChildWindow( _pParent, nId )
659 {
660     pDispatch = pBindings->GetDispatcher();
661     pWindow = new SwInputWindow( _pParent, pBindings );
662 	((SwInputWindow*)pWindow)->ShowWin();
663 	eChildAlignment = SFX_ALIGN_LOWESTTOP;
664 }
665 
666 
667 __EXPORT SwInputChild::~SwInputChild()
668 {
669 	if(pDispatch)
670 		pDispatch->Lock(sal_False);
671 }
672 
673 
674 SfxChildWinInfo __EXPORT SwInputChild::GetInfo() const
675 {
676 	SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();	   \
677 	return aInfo;
678 }
679 
680