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