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