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