Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "sal/config.h"
21 :
22 : #include <comphelper/string.hxx>
23 : #include <officecfg/Office/Common.hxx>
24 : #include <tools/gen.hxx>
25 : #include <sfx2/imgmgr.hxx>
26 : #include <sfx2/viewfrm.hxx>
27 : #include <sfx2/dispatch.hxx>
28 : #include <svx/ruler.hxx>
29 : #include <svl/zforlist.hxx>
30 : #include <svl/stritem.hxx>
31 :
32 : #include "swtypes.hxx"
33 : #include "cmdid.h"
34 : #include "swmodule.hxx"
35 : #include "wrtsh.hxx"
36 : #include "view.hxx"
37 : #include "calc.hxx"
38 : #include "inputwin.hxx"
39 : #include "fldbas.hxx"
40 : #include "fldmgr.hxx"
41 : #include "frmfmt.hxx"
42 : #include "cellatr.hxx"
43 : #include "edtwin.hxx"
44 : #include "helpid.h"
45 :
46 : // Only for the UpdateRange: Delete the box in which the stacked cursor is positioned.
47 : #include "pam.hxx"
48 :
49 : #include "swundo.hxx"
50 : #include "ribbar.hrc"
51 : #include "inputwin.hrc"
52 :
53 : #include <IDocumentContentOperations.hxx>
54 :
55 1617 : SFX_IMPL_POS_CHILDWINDOW_WITHID( SwInputChild, FN_EDIT_FORMULA, SFX_OBJECTBAR_OBJECT )
56 :
57 0 : SwInputWindow::SwInputWindow( Window* pParent, SfxBindings* pBind )
58 : : ToolBox( pParent , SW_RES( RID_TBX_FORMULA )),
59 : aPos( this, SW_RES(ED_POS)),
60 : aEdit( this, WB_3DLOOK|WB_TABSTOP|WB_BORDER|WB_NOHIDESELECTION),
61 : aPopMenu( SW_RES(MN_CALC_POPUP)),
62 : pMgr(0),
63 : pWrtShell(0),
64 : pView(0),
65 : pBindings(pBind),
66 : aAktTableName(aEmptyStr)
67 : , m_bDoesUndo(true)
68 : , m_bResetUndo(false)
69 0 : , m_bCallUndo(false)
70 : {
71 0 : bFirst = sal_True;
72 0 : bActive = bIsTable = bDelSel = sal_False;
73 :
74 0 : FreeResource();
75 :
76 0 : aEdit.SetSizePixel( aEdit.CalcMinimumSize() );
77 :
78 0 : SfxImageManager* pManager = SfxImageManager::GetImageManager( SW_MOD() );
79 0 : pManager->RegisterToolBox(this);
80 :
81 0 : pView = ::GetActiveView();
82 0 : pWrtShell = pView ? pView->GetWrtShellPtr() : 0;
83 :
84 0 : InsertWindow( ED_POS, &aPos, 0, 0);
85 0 : InsertSeparator ( 1 );
86 0 : InsertSeparator ();
87 0 : InsertWindow( ED_FORMULA, &aEdit);
88 0 : SetHelpId(ED_FORMULA, HID_EDIT_FORMULA);
89 :
90 0 : SetItemImage( FN_FORMULA_CALC, pManager->GetImage(FN_FORMULA_CALC ));
91 0 : SetItemImage( FN_FORMULA_CANCEL, pManager->GetImage(FN_FORMULA_CANCEL ));
92 0 : SetItemImage( FN_FORMULA_APPLY, pManager->GetImage(FN_FORMULA_APPLY ));
93 :
94 0 : SetItemBits( FN_FORMULA_CALC, GetItemBits( FN_FORMULA_CALC ) | TIB_DROPDOWNONLY );
95 0 : SetDropdownClickHdl( LINK( this, SwInputWindow, DropdownClickHdl ));
96 :
97 0 : Size aSizeTbx = CalcWindowSizePixel();
98 0 : Size aEditSize = aEdit.GetSizePixel();
99 0 : Rectangle aItemRect( GetItemRect(FN_FORMULA_CALC) );
100 0 : long nMaxHeight = (aEditSize.Height() > aItemRect.GetHeight()) ? aEditSize.Height() : aItemRect.GetHeight();
101 0 : if( nMaxHeight+2 > aSizeTbx.Height() )
102 0 : aSizeTbx.Height() = nMaxHeight+2;
103 0 : Size aSize = GetSizePixel();
104 0 : aSize.Height() = aSizeTbx.Height();
105 0 : SetSizePixel( aSize );
106 :
107 : // align edit and item vcentered
108 0 : Size aPosSize = aPos.GetSizePixel();
109 0 : aPosSize.Height() = nMaxHeight;
110 0 : aEditSize.Height() = nMaxHeight;
111 0 : Point aPosPos = aPos.GetPosPixel();
112 0 : Point aEditPos = aEdit.GetPosPixel();
113 0 : aPosPos.Y() = (aSize.Height() - nMaxHeight)/2 + 1;
114 0 : aEditPos.Y() = (aSize.Height() - nMaxHeight)/2 + 1;
115 0 : aPos.SetPosSizePixel( aPosPos, aPosSize );
116 0 : aEdit.SetPosSizePixel( aEditPos, aEditSize );
117 :
118 0 : aPopMenu.SetSelectHdl(LINK( this, SwInputWindow, MenuHdl ));
119 0 : }
120 :
121 0 : SwInputWindow::~SwInputWindow()
122 : {
123 0 : SfxImageManager::GetImageManager( SW_MOD() )->ReleaseToolBox(this);
124 :
125 : // wake rulers
126 0 : if(pView)
127 : {
128 0 : pView->GetHRuler().SetActive( sal_True );
129 0 : pView->GetVRuler().SetActive( sal_True );
130 : }
131 0 : delete pMgr;
132 0 : if(pWrtShell)
133 0 : pWrtShell->EndSelTblCells();
134 :
135 0 : CleanupUglyHackWithUndo();
136 0 : }
137 :
138 0 : void SwInputWindow::CleanupUglyHackWithUndo()
139 : {
140 0 : if (m_bResetUndo)
141 : {
142 0 : DelBoxCntnt();
143 0 : pWrtShell->DoUndo(m_bDoesUndo);
144 0 : if (m_bCallUndo)
145 : {
146 0 : pWrtShell->Undo();
147 : }
148 0 : m_bResetUndo = false; // #i117122# once is enough :)
149 : }
150 0 : }
151 :
152 0 : void SwInputWindow::DataChanged( const DataChangedEvent& rDCEvt )
153 : {
154 0 : if ( rDCEvt.GetType() == DATACHANGED_SETTINGS && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
155 : {
156 : // update item images
157 0 : SwModule *pMod = SW_MOD();
158 0 : SfxImageManager *pImgMgr = SfxImageManager::GetImageManager( pMod );
159 0 : SetItemImage( FN_FORMULA_CALC, pImgMgr->GetImage(FN_FORMULA_CALC ));
160 0 : SetItemImage( FN_FORMULA_CANCEL, pImgMgr->GetImage(FN_FORMULA_CANCEL ));
161 0 : SetItemImage( FN_FORMULA_APPLY, pImgMgr->GetImage(FN_FORMULA_APPLY ));
162 : }
163 :
164 0 : ToolBox::DataChanged( rDCEvt );
165 0 : }
166 :
167 0 : void SwInputWindow::Resize()
168 : {
169 0 : ToolBox::Resize();
170 :
171 0 : long nWidth = GetSizePixel().Width();
172 0 : long nLeft = aEdit.GetPosPixel().X();
173 0 : Size aEditSize = aEdit.GetSizePixel();
174 :
175 0 : aEditSize.Width() = std::max( ((long)(nWidth - nLeft - 5)), (long)0 );
176 0 : aEdit.SetSizePixel( aEditSize );
177 0 : aEdit.Invalidate();
178 0 : }
179 :
180 0 : void SwInputWindow::ShowWin()
181 : {
182 0 : bIsTable = sal_False;
183 : // stop rulers
184 0 : if(pView)
185 : {
186 0 : pView->GetHRuler().SetActive( sal_False );
187 0 : pView->GetVRuler().SetActive( sal_False );
188 :
189 : OSL_ENSURE(pWrtShell, "no WrtShell!");
190 : // Cursor in table
191 0 : bIsTable = pWrtShell->IsCrsrInTbl() ? sal_True : sal_False;
192 :
193 0 : if( bFirst )
194 : pWrtShell->SelTblCells( LINK( this, SwInputWindow,
195 0 : SelTblCellsNotify) );
196 0 : if( bIsTable )
197 : {
198 0 : const String& rPos = pWrtShell->GetBoxNms();
199 0 : sal_uInt16 nPos = 0;
200 0 : short nSrch = -1;
201 0 : while( (nPos = rPos.Search( ':',nPos + 1 ) ) != STRING_NOTFOUND )
202 0 : nSrch = (short) nPos;
203 0 : aPos.SetText( rPos.Copy( ++nSrch ) );
204 0 : aAktTableName = pWrtShell->GetTableFmt()->GetName();
205 : }
206 : else
207 0 : aPos.SetText(SW_RESSTR(STR_TBL_FORMULA));
208 :
209 : // Edit current field
210 : OSL_ENSURE(pMgr == 0, "FieldManager not deleted");
211 0 : pMgr = new SwFldMgr;
212 :
213 : // Formular should always begin with "=" , so set here
214 0 : String sEdit = OUString('=');
215 0 : if( pMgr->GetCurFld() && TYP_FORMELFLD == pMgr->GetCurTypeId() )
216 : {
217 0 : sEdit += pMgr->GetCurFldPar2();
218 : }
219 0 : else if( bFirst )
220 : {
221 0 : if( bIsTable )
222 : {
223 0 : m_bResetUndo = true;
224 : SAL_WARN_IF(
225 : officecfg::Office::Common::Undo::Steps::get() <= 0,
226 : "sw", "/org.openoffice.Office.Common/Undo/Steps <= 0");
227 :
228 0 : m_bDoesUndo = pWrtShell->DoesUndo();
229 0 : if( !m_bDoesUndo )
230 : {
231 0 : pWrtShell->DoUndo( sal_True );
232 : }
233 :
234 0 : if( !pWrtShell->SwCrsrShell::HasSelection() )
235 : {
236 0 : pWrtShell->MoveSection( fnSectionCurr, fnSectionStart );
237 0 : pWrtShell->SetMark();
238 0 : pWrtShell->MoveSection( fnSectionCurr, fnSectionEnd );
239 : }
240 0 : if( pWrtShell->SwCrsrShell::HasSelection() )
241 : {
242 0 : pWrtShell->StartUndo( UNDO_DELETE );
243 0 : pWrtShell->Delete();
244 0 : if( 0 != pWrtShell->EndUndo( UNDO_DELETE ))
245 : {
246 0 : m_bCallUndo = true;
247 : }
248 : }
249 0 : pWrtShell->DoUndo(false);
250 :
251 0 : SfxItemSet aSet( pWrtShell->GetAttrPool(), RES_BOXATR_FORMULA, RES_BOXATR_FORMULA );
252 0 : if( pWrtShell->GetTblBoxFormulaAttrs( aSet ))
253 0 : sEdit += ((SwTblBoxFormula&)aSet.Get( RES_BOXATR_FORMULA )).GetFormula();
254 : }
255 : }
256 :
257 0 : if( bFirst )
258 : {
259 : // Set WrtShell flags correctly
260 0 : pWrtShell->SttSelect();
261 0 : pWrtShell->EndSelect();
262 : }
263 :
264 0 : bFirst = sal_False;
265 :
266 0 : aEdit.SetModifyHdl( LINK( this, SwInputWindow, ModifyHdl ));
267 :
268 0 : aEdit.SetText( sEdit );
269 0 : aEdit.SetSelection( Selection( sEdit.Len(), sEdit.Len() ) );
270 0 : sOldFml = sEdit;
271 :
272 0 : aEdit.Invalidate();
273 0 : aEdit.Update();
274 0 : aEdit.GrabFocus();
275 : // For input cut the UserInterface
276 :
277 0 : pView->GetEditWin().LockKeyInput(sal_True);
278 0 : pView->GetViewFrame()->GetDispatcher()->Lock(sal_True);
279 0 : pWrtShell->Push();
280 : }
281 0 : ToolBox::Show();
282 0 : }
283 :
284 0 : IMPL_LINK( SwInputWindow, MenuHdl, Menu *, pMenu )
285 : {
286 : static const char * const aStrArr[] = {
287 : sCalc_Phd,
288 : sCalc_Sqrt,
289 : sCalc_Or,
290 : sCalc_Xor,
291 : sCalc_And,
292 : sCalc_Not,
293 : sCalc_Eq,
294 : sCalc_Neq,
295 : sCalc_Leq,
296 : sCalc_Geq,
297 : sCalc_L,
298 : sCalc_G,
299 : sCalc_Sum,
300 : sCalc_Mean,
301 : sCalc_Min,
302 : sCalc_Max,
303 : sCalc_Sin,
304 : sCalc_Cos,
305 : sCalc_Tan,
306 : sCalc_Asin,
307 : sCalc_Acos,
308 : sCalc_Atan,
309 : sCalc_Pow,
310 : "|",
311 : sCalc_Round
312 : };
313 :
314 0 : sal_uInt16 nId = pMenu->GetCurItemId();
315 0 : if ( nId <= MN_CALC_ROUND )
316 : {
317 0 : String aTmp( OUString::createFromAscii(aStrArr[nId - 1]) );
318 0 : aTmp += ' ';
319 0 : aEdit.ReplaceSelected( aTmp );
320 : }
321 0 : return 0;
322 : }
323 :
324 0 : IMPL_LINK_NOARG(SwInputWindow, DropdownClickHdl)
325 : {
326 0 : sal_uInt16 nCurID = GetCurItemId();
327 0 : EndSelection(); // reset back CurItemId !
328 0 : switch ( nCurID )
329 : {
330 : case FN_FORMULA_CALC :
331 : {
332 0 : aPopMenu.Execute( this, GetItemRect( FN_FORMULA_CALC ), POPUPMENU_NOMOUSEUPCLOSE );
333 0 : break;
334 : default:
335 0 : break;
336 : }
337 : }
338 :
339 0 : return sal_True;
340 : }
341 :
342 0 : void SwInputWindow::Click( )
343 : {
344 0 : sal_uInt16 nCurID = GetCurItemId();
345 0 : EndSelection(); // reset back CurItemId !
346 0 : switch ( nCurID )
347 : {
348 : case FN_FORMULA_CANCEL:
349 : {
350 0 : CancelFormula();
351 : }
352 0 : break;
353 : case FN_FORMULA_APPLY:
354 : {
355 0 : ApplyFormula();
356 : }
357 0 : break;
358 : }
359 0 : }
360 :
361 0 : void SwInputWindow::ApplyFormula()
362 : {
363 0 : pView->GetViewFrame()->GetDispatcher()->Lock(sal_False);
364 0 : pView->GetEditWin().LockKeyInput(sal_False);
365 0 : CleanupUglyHackWithUndo();
366 0 : pWrtShell->Pop( sal_False );
367 :
368 : // Formular should always begin with "=", so remove it here again
369 0 : String sEdit(comphelper::string::strip(aEdit.GetText(), ' '));
370 0 : if( sEdit.Len() && '=' == sEdit.GetChar( 0 ) )
371 0 : sEdit.Erase( 0, 1 );
372 0 : SfxStringItem aParam(FN_EDIT_FORMULA, sEdit);
373 :
374 0 : pWrtShell->EndSelTblCells();
375 0 : pView->GetEditWin().GrabFocus();
376 : const SfxPoolItem* aArgs[2];
377 0 : aArgs[0] = &aParam;
378 0 : aArgs[1] = 0;
379 0 : pView->GetViewFrame()->GetBindings().Execute( FN_EDIT_FORMULA, aArgs, 0, SFX_CALLMODE_ASYNCHRON );
380 0 : }
381 :
382 0 : void SwInputWindow::CancelFormula()
383 : {
384 0 : if(pView)
385 : {
386 0 : pView->GetViewFrame()->GetDispatcher()->Lock( sal_False );
387 0 : pView->GetEditWin().LockKeyInput(sal_False);
388 0 : CleanupUglyHackWithUndo();
389 0 : pWrtShell->Pop( sal_False );
390 :
391 0 : if( bDelSel )
392 0 : pWrtShell->EnterStdMode();
393 :
394 0 : pWrtShell->EndSelTblCells();
395 :
396 0 : pView->GetEditWin().GrabFocus();
397 : }
398 0 : pView->GetViewFrame()->GetDispatcher()->Execute( FN_EDIT_FORMULA, SFX_CALLMODE_ASYNCHRON);
399 0 : }
400 :
401 : const sal_Unicode CH_LRE = 0x202a;
402 : const sal_Unicode CH_PDF = 0x202c;
403 :
404 0 : IMPL_LINK( SwInputWindow, SelTblCellsNotify, SwWrtShell *, pCaller )
405 : {
406 0 : if(bIsTable)
407 : {
408 0 : SwFrmFmt* pTblFmt = pCaller->GetTableFmt();
409 0 : String sBoxNms( pCaller->GetBoxNms() );
410 0 : String sTblNm;
411 0 : if( pTblFmt && aAktTableName != pTblFmt->GetName() )
412 0 : sTblNm = pTblFmt->GetName();
413 :
414 0 : aEdit.UpdateRange( sBoxNms, sTblNm );
415 :
416 0 : String sNew;
417 0 : sNew += CH_LRE;
418 0 : sNew += aEdit.GetText();
419 0 : sNew += CH_PDF;
420 :
421 0 : if( sNew != sOldFml )
422 : {
423 : // The WrtShell is in the table selection,
424 : // then cancel the table selection otherwise, the cursor is
425 : // positioned "in the forest" and the live update does not work!
426 0 : pWrtShell->StartAllAction();
427 :
428 0 : SwPaM aPam( *pWrtShell->GetStkCrsr()->GetPoint() );
429 0 : aPam.Move( fnMoveBackward, fnGoSection );
430 0 : aPam.SetMark();
431 0 : aPam.Move( fnMoveForward, fnGoSection );
432 :
433 0 : IDocumentContentOperations* pIDCO = pWrtShell->getIDocumentContentOperations();
434 0 : pIDCO->DeleteRange( aPam );
435 0 : pIDCO->InsertString( aPam, sNew );
436 0 : pWrtShell->EndAllAction();
437 0 : sOldFml = sNew;
438 0 : }
439 : }
440 : else
441 0 : aEdit.GrabFocus();
442 0 : return 0;
443 : }
444 :
445 :
446 0 : void SwInputWindow::SetFormula( const String& rFormula, sal_Bool bDelFlag )
447 : {
448 0 : String sEdit = OUString('=');
449 0 : if( rFormula.Len() )
450 : {
451 0 : if( '=' == rFormula.GetChar( 0 ) )
452 0 : sEdit = rFormula;
453 : else
454 0 : sEdit += rFormula;
455 : }
456 0 : aEdit.SetText( sEdit );
457 0 : aEdit.SetSelection( Selection( sEdit.Len(), sEdit.Len() ) );
458 0 : aEdit.Invalidate();
459 0 : bDelSel = bDelFlag;
460 0 : }
461 :
462 0 : IMPL_LINK_NOARG(SwInputWindow, ModifyHdl)
463 : {
464 0 : if (bIsTable && m_bResetUndo)
465 : {
466 0 : pWrtShell->StartAllAction();
467 0 : DelBoxCntnt();
468 0 : String sNew;
469 0 : sNew += CH_LRE;
470 0 : sNew += aEdit.GetText();
471 0 : sNew += CH_PDF;
472 0 : pWrtShell->SwEditShell::Insert2( sNew );
473 0 : pWrtShell->EndAllAction();
474 0 : sOldFml = sNew;
475 : }
476 0 : return 0;
477 : }
478 :
479 :
480 0 : void SwInputWindow::DelBoxCntnt()
481 : {
482 0 : if( bIsTable )
483 : {
484 0 : pWrtShell->StartAllAction();
485 0 : pWrtShell->ClearMark();
486 0 : pWrtShell->Pop( sal_False );
487 0 : pWrtShell->Push();
488 0 : pWrtShell->MoveSection( fnSectionCurr, fnSectionStart );
489 0 : pWrtShell->SetMark();
490 0 : pWrtShell->MoveSection( fnSectionCurr, fnSectionEnd );
491 0 : pWrtShell->SwEditShell::Delete();
492 0 : pWrtShell->EndAllAction();
493 : }
494 0 : }
495 :
496 0 : void InputEdit::KeyInput(const KeyEvent& rEvent)
497 : {
498 0 : const KeyCode aCode = rEvent.GetKeyCode();
499 0 : if(aCode == KEY_RETURN || aCode == KEY_F2 )
500 0 : ((SwInputWindow*)GetParent())->ApplyFormula();
501 0 : else if(aCode == KEY_ESCAPE )
502 0 : ((SwInputWindow*)GetParent())->CancelFormula();
503 : else
504 0 : Edit::KeyInput(rEvent);
505 0 : }
506 :
507 0 : void InputEdit::UpdateRange(const String& rBoxes,
508 : const String& rName )
509 : {
510 0 : if( !rBoxes.Len() )
511 : {
512 0 : GrabFocus();
513 0 : return;
514 : }
515 0 : const sal_Unicode cOpen = '<', cClose = '>',
516 0 : cOpenBracket = '(';
517 0 : String aPrefix = rName;
518 0 : if(rName.Len())
519 0 : aPrefix += '.';
520 0 : String aBoxes = aPrefix;
521 0 : aBoxes += rBoxes;
522 0 : Selection aSelection(GetSelection());
523 0 : sal_uInt16 nSel = (sal_uInt16) aSelection.Len();
524 : // OS: The following expression ensures that in the overwrite mode,
525 : // the selected closing parenthesis will be not deleted.
526 0 : if( nSel && ( nSel > 1 ||
527 0 : GetText()[ (sal_uInt16)aSelection.Min() ] != cClose ))
528 0 : Cut();
529 : else
530 0 : aSelection.Max() = aSelection.Min();
531 0 : String aActText(GetText());
532 0 : const sal_uInt16 nLen = aActText.Len();
533 0 : if( !nLen )
534 : {
535 : String aStr = OUStringBuffer().
536 0 : append(cOpen).append(aBoxes).append(cClose).
537 0 : makeStringAndClear();
538 0 : SetText(aStr);
539 0 : sal_uInt16 nPos = aStr.Search( cClose );
540 : OSL_ENSURE(nPos < aStr.Len(), "delimiter not found");
541 0 : ++nPos;
542 0 : SetSelection( Selection( nPos, nPos ));
543 : }
544 : else
545 : {
546 0 : bool bFound = false;
547 : sal_Unicode cCh;
548 0 : sal_uInt16 nPos, nEndPos = 0, nStartPos = (sal_uInt16) aSelection.Min();
549 0 : if( nStartPos-- )
550 : {
551 0 : do {
552 0 : if( cOpen == (cCh = aActText.GetChar( nStartPos ) ) ||
553 : cOpenBracket == cCh )
554 : {
555 0 : bFound = cCh == cOpen;
556 0 : break;
557 : }
558 0 : } while( nStartPos-- > 0 );
559 : }
560 0 : if( bFound )
561 : {
562 0 : bFound = false;
563 0 : nEndPos = nStartPos;
564 0 : while( nEndPos < nLen )
565 : {
566 0 : if( cClose == (cCh = aActText.GetChar( nEndPos )))
567 : {
568 0 : bFound = true;
569 0 : break;
570 : }
571 0 : ++nEndPos;
572 : }
573 : // Only if the current position lies in the range or right behind.
574 0 : if( bFound && !( nStartPos < (sal_uInt16)aSelection.Max() &&
575 0 : (sal_uInt16)aSelection.Max() <= nEndPos + 1 ))
576 0 : bFound = false;
577 : }
578 0 : if( bFound )
579 : {
580 0 : nPos = ++nStartPos + 1; // We want behind
581 0 : aActText.Erase( nStartPos, nEndPos - nStartPos );
582 0 : aActText.Insert( aBoxes, nStartPos );
583 0 : nPos = nPos + aBoxes.Len();
584 : }
585 : else
586 : {
587 : OUString aTmp = OUStringBuffer().
588 0 : append(cOpen).append(aBoxes).append(cClose).
589 0 : makeStringAndClear();
590 0 : nPos = (sal_uInt16)aSelection.Min();
591 0 : aActText.Insert( aTmp, nPos );
592 0 : nPos = nPos + aTmp.getLength();
593 : }
594 0 : if( GetText() != OUString(aActText) )
595 : {
596 0 : SetText( aActText );
597 0 : SetSelection( Selection( nPos, nPos ) );
598 : }
599 : }
600 0 : GrabFocus();
601 :
602 : }
603 :
604 0 : SwInputChild::SwInputChild(Window* _pParent,
605 : sal_uInt16 nId,
606 : SfxBindings* pBindings,
607 : SfxChildWinInfo* ) :
608 0 : SfxChildWindow( _pParent, nId )
609 : {
610 0 : pDispatch = pBindings->GetDispatcher();
611 0 : pWindow = new SwInputWindow( _pParent, pBindings );
612 0 : ((SwInputWindow*)pWindow)->ShowWin();
613 0 : eChildAlignment = SFX_ALIGN_LOWESTTOP;
614 0 : }
615 :
616 0 : SwInputChild::~SwInputChild()
617 : {
618 0 : if(pDispatch)
619 0 : pDispatch->Lock(sal_False);
620 0 : }
621 :
622 :
623 0 : SfxChildWinInfo SwInputChild::GetInfo() const
624 : {
625 0 : SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
626 0 : return aInfo;
627 99 : }
628 :
629 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|