Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <svtools/editbrowsebox.hxx>
30 : : #include <vcl/decoview.hxx>
31 : : #include <svtools/fmtfield.hxx>
32 : : #include <vcl/xtextedt.hxx>
33 : :
34 : : #include <algorithm>
35 : :
36 : : // .......................................................................
37 : : namespace svt
38 : : {
39 : : // .......................................................................
40 : :
41 [ # # ]: 0 : TYPEINIT0(CellController);
42 [ # # ][ # # ]: 0 : TYPEINIT1(EditCellController, CellController);
43 [ # # ][ # # ]: 0 : TYPEINIT1(SpinCellController, CellController);
44 [ # # ][ # # ]: 0 : TYPEINIT1(CheckBoxCellController, CellController);
45 [ # # ][ # # ]: 0 : TYPEINIT1(ComboBoxCellController, CellController);
46 [ # # ][ # # ]: 0 : TYPEINIT1(ListBoxCellController, CellController);
47 : :
48 [ # # ][ # # ]: 0 : TYPEINIT1( FormattedFieldCellController, EditCellController );
49 : :
50 : : //==================================================================
51 : : //= ComboBoxControl
52 : : //==================================================================
53 : 0 : ComboBoxControl::ComboBoxControl(Window* pParent, WinBits nWinStyle)
54 : 0 : :ComboBox(pParent, nWinStyle|WB_DROPDOWN|WB_NOBORDER)
55 : : {
56 [ # # ]: 0 : EnableAutoSize(sal_False);
57 [ # # ]: 0 : EnableAutocomplete(sal_True);
58 [ # # ]: 0 : SetDropDownLineCount(5);
59 : 0 : }
60 : :
61 : : //------------------------------------------------------------------
62 : 0 : long ComboBoxControl::PreNotify( NotifyEvent& rNEvt )
63 : : {
64 [ # # ]: 0 : switch (rNEvt.GetType())
65 : : {
66 : : case EVENT_KEYINPUT:
67 [ # # ]: 0 : if (!IsInDropDown())
68 : : {
69 [ # # ]: 0 : const KeyEvent *pEvt = rNEvt.GetKeyEvent();
70 : 0 : const KeyCode rKey = pEvt->GetKeyCode();
71 : :
72 [ # # # # : 0 : if ((rKey.GetCode() == KEY_UP || rKey.GetCode() == KEY_DOWN) &&
# # ][ # # ]
[ # # ]
73 : 0 : (!pEvt->GetKeyCode().IsShift() && pEvt->GetKeyCode().IsMod1()))
74 : : {
75 : : // select next resp. previous entry
76 [ # # ][ # # ]: 0 : int nPos = GetEntryPos(GetText());
[ # # ]
77 [ # # ]: 0 : nPos = nPos + (rKey.GetCode() == KEY_DOWN ? 1 : -1);
78 [ # # ]: 0 : if (nPos < 0)
79 : 0 : nPos = 0;
80 [ # # ][ # # ]: 0 : if (nPos >= GetEntryCount())
81 [ # # ]: 0 : nPos = GetEntryCount() - 1;
82 [ # # ][ # # ]: 0 : SetText(GetEntry(sal::static_int_cast< sal_uInt16 >(nPos)));
[ # # ]
83 : 0 : return 1;
84 : : }
85 : : }
86 : 0 : break;
87 : : }
88 : 0 : return ComboBox::PreNotify(rNEvt);
89 : : }
90 : :
91 : : //==================================================================
92 : : //= ComboBoxCellController
93 : : //==================================================================
94 : : //------------------------------------------------------------------
95 : 0 : ComboBoxCellController::ComboBoxCellController(ComboBoxControl* pWin)
96 : 0 : :CellController(pWin)
97 : : {
98 : 0 : }
99 : :
100 : : //------------------------------------------------------------------
101 : 0 : sal_Bool ComboBoxCellController::MoveAllowed(const KeyEvent& rEvt) const
102 : : {
103 : 0 : ComboBoxControl& rBox = GetComboBox();
104 [ # # # # : 0 : switch (rEvt.GetKeyCode().GetCode())
# ]
105 : : {
106 : : case KEY_END:
107 : : case KEY_RIGHT:
108 : : {
109 [ # # ]: 0 : Selection aSel = rBox.GetSelection();
110 [ # # ][ # # ]: 0 : return !aSel && aSel.Max() == rBox.GetText().Len();
[ # # ][ # # ]
[ # # ][ # # ]
111 : : }
112 : : case KEY_HOME:
113 : : case KEY_LEFT:
114 : : {
115 [ # # ]: 0 : Selection aSel = rBox.GetSelection();
116 [ # # ][ # # ]: 0 : return !aSel && aSel.Min() == 0;
117 : : }
118 : : case KEY_UP:
119 : : case KEY_DOWN:
120 [ # # ]: 0 : if (rBox.IsInDropDown())
121 : 0 : return sal_False;
122 [ # # # # ]: 0 : if (!rEvt.GetKeyCode().IsShift() &&
[ # # ]
123 : 0 : rEvt.GetKeyCode().IsMod1())
124 : 0 : return sal_False;
125 : : // drop down the list box
126 [ # # ][ # # ]: 0 : else if (rEvt.GetKeyCode().IsMod2() && rEvt.GetKeyCode().GetCode() == KEY_DOWN)
[ # # ]
127 : 0 : return sal_False;
128 : : case KEY_PAGEUP:
129 : : case KEY_PAGEDOWN:
130 : : case KEY_RETURN:
131 [ # # ]: 0 : if (rBox.IsInDropDown())
132 : 0 : return sal_False;
133 : : default:
134 : 0 : return sal_True;
135 : : }
136 : : }
137 : :
138 : : //------------------------------------------------------------------
139 : 0 : sal_Bool ComboBoxCellController::IsModified() const
140 : : {
141 [ # # ]: 0 : return GetComboBox().GetSavedValue() != GetComboBox().GetText();
142 : : }
143 : :
144 : : //------------------------------------------------------------------
145 : 0 : void ComboBoxCellController::ClearModified()
146 : : {
147 : 0 : GetComboBox().SaveValue();
148 : 0 : }
149 : :
150 : : //------------------------------------------------------------------
151 : 0 : void ComboBoxCellController::SetModifyHdl(const Link& rLink)
152 : : {
153 : 0 : GetComboBox().SetModifyHdl(rLink);
154 : 0 : }
155 : :
156 : : //==================================================================
157 : : //= ListBoxControl
158 : : //==================================================================
159 : : //------------------------------------------------------------------
160 : 0 : ListBoxControl::ListBoxControl(Window* pParent, WinBits nWinStyle)
161 : 0 : :ListBox(pParent, nWinStyle|WB_DROPDOWN|WB_NOBORDER)
162 : : {
163 [ # # ]: 0 : EnableAutoSize(sal_False);
164 [ # # ]: 0 : EnableMultiSelection(sal_False);
165 [ # # ]: 0 : SetDropDownLineCount(20);
166 : 0 : }
167 : :
168 : : //------------------------------------------------------------------
169 : 0 : long ListBoxControl::PreNotify( NotifyEvent& rNEvt )
170 : : {
171 [ # # ]: 0 : switch (rNEvt.GetType())
172 : : {
173 : : case EVENT_KEYINPUT:
174 [ # # ]: 0 : if (!IsInDropDown())
175 : : {
176 [ # # ]: 0 : const KeyEvent *pEvt = rNEvt.GetKeyEvent();
177 : 0 : const KeyCode rKey = pEvt->GetKeyCode();
178 : :
179 [ # # # # : 0 : if ((rKey.GetCode() == KEY_UP || rKey.GetCode() == KEY_DOWN) &&
# # ][ # # ]
[ # # ]
180 : 0 : (!pEvt->GetKeyCode().IsShift() && pEvt->GetKeyCode().IsMod1()))
181 : : {
182 : : // select next resp. previous entry
183 [ # # ]: 0 : int nPos = GetSelectEntryPos();
184 [ # # ]: 0 : nPos = nPos + (rKey.GetCode() == KEY_DOWN ? 1 : -1);
185 [ # # ]: 0 : if (nPos < 0)
186 : 0 : nPos = 0;
187 [ # # ][ # # ]: 0 : if (nPos >= GetEntryCount())
188 [ # # ]: 0 : nPos = GetEntryCount() - 1;
189 [ # # ]: 0 : SelectEntryPos(sal::static_int_cast< sal_uInt16 >(nPos));
190 [ # # ]: 0 : Select(); // for calling Modify
191 : 0 : return 1;
192 : : }
193 [ # # ][ # # ]: 0 : else if (GetParent()->PreNotify(rNEvt))
[ # # ]
194 : 0 : return 1;
195 : : }
196 : 0 : break;
197 : : }
198 : 0 : return ListBox::PreNotify(rNEvt);
199 : : }
200 : :
201 : : //==================================================================
202 : : //= ListBoxCellController
203 : : //==================================================================
204 : : //------------------------------------------------------------------
205 : 0 : ListBoxCellController::ListBoxCellController(ListBoxControl* pWin)
206 : 0 : :CellController(pWin)
207 : : {
208 : 0 : }
209 : :
210 : : //------------------------------------------------------------------
211 : 0 : sal_Bool ListBoxCellController::MoveAllowed(const KeyEvent& rEvt) const
212 : : {
213 : 0 : ListBoxControl& rBox = GetListBox();
214 [ # # # ]: 0 : switch (rEvt.GetKeyCode().GetCode())
215 : : {
216 : : case KEY_UP:
217 : : case KEY_DOWN:
218 [ # # # # ]: 0 : if (!rEvt.GetKeyCode().IsShift() &&
[ # # ]
219 : 0 : rEvt.GetKeyCode().IsMod1())
220 : 0 : return sal_False;
221 : : // drop down the list box
222 : : else
223 [ # # ][ # # ]: 0 : if (rEvt.GetKeyCode().IsMod2() && rEvt.GetKeyCode().GetCode() == KEY_DOWN)
[ # # ]
224 : 0 : return sal_False;
225 : : case KEY_PAGEUP:
226 : : case KEY_PAGEDOWN:
227 [ # # ]: 0 : if (rBox.IsTravelSelect())
228 : 0 : return sal_False;
229 : : default:
230 : 0 : return sal_True;
231 : : }
232 : : }
233 : :
234 : : //------------------------------------------------------------------
235 : 0 : sal_Bool ListBoxCellController::IsModified() const
236 : : {
237 : 0 : return GetListBox().GetSelectEntryPos() != GetListBox().GetSavedValue();
238 : : }
239 : :
240 : : //------------------------------------------------------------------
241 : 0 : void ListBoxCellController::ClearModified()
242 : : {
243 : 0 : GetListBox().SaveValue();
244 : 0 : }
245 : :
246 : : //------------------------------------------------------------------
247 : 0 : void ListBoxCellController::SetModifyHdl(const Link& rLink)
248 : : {
249 : 0 : GetListBox().SetSelectHdl(rLink);
250 : 0 : }
251 : :
252 : : //==================================================================
253 : : //= CheckBoxControl
254 : : //==================================================================
255 : : //------------------------------------------------------------------
256 : 40 : CheckBoxControl::CheckBoxControl(Window* pParent, WinBits nWinStyle)
257 [ + - ][ + - ]: 40 : :Control(pParent, nWinStyle)
[ + - ]
258 : : {
259 : 40 : const Wallpaper& rParentBackground = pParent->GetBackground();
260 [ - + ][ # # ]: 40 : if ( (pParent->GetStyle() & WB_CLIPCHILDREN) || rParentBackground.IsFixed() )
[ # # ][ + - ]
[ + - ]
261 [ + - ]: 40 : SetBackground( rParentBackground );
262 : : else
263 : : {
264 [ # # ]: 0 : SetPaintTransparent( sal_True );
265 [ # # ]: 0 : SetBackground();
266 : : }
267 : :
268 [ + - ]: 40 : EnableChildTransparentMode();
269 : :
270 [ + - ][ + - ]: 40 : pBox = new TriStateBox(this,WB_CENTER|WB_VCENTER);
271 : 40 : pBox->SetLegacyNoTextAlign( true );
272 [ + - ]: 40 : pBox->EnableChildTransparentMode();
273 [ + - ]: 40 : pBox->SetPaintTransparent( sal_True );
274 [ + - ]: 40 : pBox->SetClickHdl( LINK( this, CheckBoxControl, OnClick ) );
275 [ + - ]: 40 : pBox->Show();
276 : 40 : }
277 : :
278 : : //------------------------------------------------------------------
279 : 40 : CheckBoxControl::~CheckBoxControl()
280 : : {
281 [ + - ][ + - ]: 40 : delete pBox;
282 [ - + ]: 80 : }
283 : :
284 : : //------------------------------------------------------------------
285 : 0 : IMPL_LINK_NOARG(CheckBoxControl, OnClick)
286 : : {
287 : 0 : m_aClickLink.Call(pBox);
288 : 0 : return m_aModifyLink.Call(pBox);
289 : : }
290 : :
291 : : //------------------------------------------------------------------
292 : 0 : void CheckBoxControl::Resize()
293 : : {
294 : 0 : Control::Resize();
295 [ # # ]: 0 : pBox->SetPosSizePixel(Point(0,0),GetSizePixel());
296 : 0 : }
297 : :
298 : : //------------------------------------------------------------------------------
299 : 64 : void CheckBoxControl::DataChanged( const DataChangedEvent& _rEvent )
300 : : {
301 [ + - ]: 64 : if ( _rEvent.GetType() == DATACHANGED_SETTINGS )
302 : 64 : pBox->SetSettings( GetSettings() );
303 : 64 : }
304 : :
305 : : //------------------------------------------------------------------------------
306 : 34 : void CheckBoxControl::StateChanged( StateChangedType nStateChange )
307 : : {
308 : 34 : Control::StateChanged(nStateChange);
309 [ - + ]: 34 : if ( nStateChange == STATE_CHANGE_ZOOM )
310 : 0 : pBox->SetZoom(GetZoom());
311 : 34 : }
312 : :
313 : : //------------------------------------------------------------------
314 : 0 : void CheckBoxControl::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags )
315 : : {
316 : 0 : pBox->Draw(pDev,rPos,rSize,nFlags);
317 : 0 : }
318 : :
319 : : //------------------------------------------------------------------
320 : 0 : void CheckBoxControl::GetFocus()
321 : : {
322 : 0 : pBox->GrabFocus();
323 : 0 : }
324 : :
325 : : //------------------------------------------------------------------
326 : 0 : void CheckBoxControl::Paint(const Rectangle& rClientRect)
327 : : {
328 : 0 : Control::Paint(rClientRect);
329 [ # # ]: 0 : if (HasFocus())
330 : 0 : ShowFocus(aFocusRect);
331 : 0 : }
332 : :
333 : : //------------------------------------------------------------------
334 : 0 : long CheckBoxControl::PreNotify(NotifyEvent& rEvt)
335 : : {
336 [ # # # ]: 0 : switch (rEvt.GetType())
337 : : {
338 : : case EVENT_GETFOCUS:
339 : 0 : ShowFocus(aFocusRect);
340 : 0 : break;
341 : : case EVENT_LOSEFOCUS:
342 : 0 : HideFocus();
343 : : }
344 : 0 : return Control::PreNotify(rEvt);
345 : : }
346 : :
347 : : //==================================================================
348 : : //= CheckBoxCellController
349 : : //==================================================================
350 : : //------------------------------------------------------------------
351 : 0 : sal_Bool CheckBoxCellController::WantMouseEvent() const
352 : : {
353 : 0 : return sal_True;
354 : : }
355 : :
356 : : //------------------------------------------------------------------
357 : 0 : CheckBox& CheckBoxCellController::GetCheckBox() const
358 : : {
359 : 0 : return ((CheckBoxControl &)GetWindow()).GetBox();
360 : : }
361 : :
362 : : //------------------------------------------------------------------
363 : 0 : sal_Bool CheckBoxCellController::IsModified() const
364 : : {
365 : 0 : return GetCheckBox().GetSavedValue() != GetCheckBox().GetState();
366 : : }
367 : :
368 : : //------------------------------------------------------------------
369 : 0 : void CheckBoxCellController::ClearModified()
370 : : {
371 : 0 : GetCheckBox().SaveValue();
372 : 0 : }
373 : :
374 : : //------------------------------------------------------------------
375 : 0 : void CheckBoxCellController::SetModifyHdl(const Link& rLink)
376 : : {
377 : 0 : ((CheckBoxControl &)GetWindow()).SetModifyHdl(rLink);
378 : 0 : }
379 : :
380 : : //==================================================================
381 : : //= MultiLineEditImplementation
382 : : //==================================================================
383 : : //------------------------------------------------------------------
384 : 0 : String MultiLineEditImplementation::GetText( LineEnd aSeparator ) const
385 : : {
386 : 0 : return const_cast< MultiLineEditImplementation* >( this )->GetEditWindow().GetText( aSeparator );
387 : : }
388 : :
389 : : //------------------------------------------------------------------
390 : 0 : String MultiLineEditImplementation::GetSelected( LineEnd aSeparator ) const
391 : : {
392 : 0 : return const_cast< MultiLineEditImplementation* >( this )->GetEditWindow().GetSelected( aSeparator );
393 : : }
394 : :
395 : : //==================================================================
396 : : //= EditCellController
397 : : //==================================================================
398 : : //------------------------------------------------------------------
399 : 28 : EditCellController::EditCellController( Edit* _pEdit )
400 : : :CellController( _pEdit )
401 [ + - ]: 28 : ,m_pEditImplementation( new EditImplementation( *_pEdit ) )
402 [ + - ]: 28 : ,m_bOwnImplementation( sal_True )
403 : : {
404 : 28 : }
405 : :
406 : : //------------------------------------------------------------------
407 : 34 : EditCellController::EditCellController( IEditImplementation* _pImplementation )
408 : 34 : :CellController( &_pImplementation->GetControl() )
409 : : ,m_pEditImplementation( _pImplementation )
410 : 34 : ,m_bOwnImplementation( sal_False )
411 : : {
412 : 34 : }
413 : :
414 : : //-----------------------------------------------------------------------------
415 : 62 : EditCellController::~EditCellController( )
416 : : {
417 [ + + ]: 62 : if ( m_bOwnImplementation )
418 [ + - ][ + - ]: 28 : DELETEZ( m_pEditImplementation );
419 [ - + ]: 96 : }
420 : :
421 : : //-----------------------------------------------------------------------------
422 : 0 : void EditCellController::SetModified()
423 : : {
424 : 0 : m_pEditImplementation->SetModified();
425 : 0 : }
426 : :
427 : : //-----------------------------------------------------------------------------
428 : 0 : void EditCellController::ClearModified()
429 : : {
430 : 0 : m_pEditImplementation->ClearModified();
431 : 0 : }
432 : :
433 : : //------------------------------------------------------------------
434 : 0 : sal_Bool EditCellController::MoveAllowed(const KeyEvent& rEvt) const
435 : : {
436 : : sal_Bool bResult;
437 [ # # # ]: 0 : switch (rEvt.GetKeyCode().GetCode())
438 : : {
439 : : case KEY_END:
440 : : case KEY_RIGHT:
441 : : {
442 [ # # ]: 0 : Selection aSel = m_pEditImplementation->GetSelection();
443 [ # # ][ # # ]: 0 : bResult = !aSel && aSel.Max() == m_pEditImplementation->GetText( LINEEND_LF ).Len();
[ # # ][ # # ]
[ # # ][ # # ]
444 : 0 : } break;
445 : : case KEY_HOME:
446 : : case KEY_LEFT:
447 : : {
448 [ # # ]: 0 : Selection aSel = m_pEditImplementation->GetSelection();
449 [ # # ][ # # ]: 0 : bResult = !aSel && aSel.Min() == 0;
450 : 0 : } break;
451 : : default:
452 : 0 : bResult = sal_True;
453 : : }
454 : 0 : return bResult;
455 : : }
456 : :
457 : : //------------------------------------------------------------------
458 : 0 : sal_Bool EditCellController::IsModified() const
459 : : {
460 : 0 : return m_pEditImplementation->IsModified();
461 : : }
462 : :
463 : : //------------------------------------------------------------------
464 : 0 : void EditCellController::SetModifyHdl(const Link& rLink)
465 : : {
466 : 0 : m_pEditImplementation->SetModifyHdl(rLink);
467 : 0 : }
468 : :
469 : : //==================================================================
470 : : //= SpinCellController
471 : : //==================================================================
472 : : //------------------------------------------------------------------
473 : 0 : SpinCellController::SpinCellController(SpinField* pWin)
474 : 0 : :CellController(pWin)
475 : : {
476 : 0 : }
477 : :
478 : : //-----------------------------------------------------------------------------
479 : 0 : void SpinCellController::SetModified()
480 : : {
481 : 0 : GetSpinWindow().SetModifyFlag();
482 : 0 : }
483 : :
484 : : //-----------------------------------------------------------------------------
485 : 0 : void SpinCellController::ClearModified()
486 : : {
487 : 0 : GetSpinWindow().ClearModifyFlag();
488 : 0 : }
489 : :
490 : : //------------------------------------------------------------------
491 : 0 : sal_Bool SpinCellController::MoveAllowed(const KeyEvent& rEvt) const
492 : : {
493 : : sal_Bool bResult;
494 [ # # # ]: 0 : switch (rEvt.GetKeyCode().GetCode())
495 : : {
496 : : case KEY_END:
497 : : case KEY_RIGHT:
498 : : {
499 [ # # ]: 0 : Selection aSel = GetSpinWindow().GetSelection();
500 [ # # ][ # # ]: 0 : bResult = !aSel && aSel.Max() == GetSpinWindow().GetText().Len();
[ # # ][ # # ]
[ # # ][ # # ]
501 : 0 : } break;
502 : : case KEY_HOME:
503 : : case KEY_LEFT:
504 : : {
505 [ # # ]: 0 : Selection aSel = GetSpinWindow().GetSelection();
506 [ # # ][ # # ]: 0 : bResult = !aSel && aSel.Min() == 0;
507 : 0 : } break;
508 : : default:
509 : 0 : bResult = sal_True;
510 : : }
511 : 0 : return bResult;
512 : : }
513 : :
514 : : //------------------------------------------------------------------
515 : 0 : sal_Bool SpinCellController::IsModified() const
516 : : {
517 : 0 : return GetSpinWindow().IsModified();
518 : : }
519 : :
520 : : //------------------------------------------------------------------
521 : 0 : void SpinCellController::SetModifyHdl(const Link& rLink)
522 : : {
523 : 0 : GetSpinWindow().SetModifyHdl(rLink);
524 : 0 : }
525 : :
526 : : //==================================================================
527 : : //= FormattedFieldCellController
528 : : //==================================================================
529 : : //------------------------------------------------------------------
530 : 28 : FormattedFieldCellController::FormattedFieldCellController( FormattedField* _pFormatted )
531 : 28 : :EditCellController( _pFormatted )
532 : : {
533 : 28 : }
534 : :
535 : : //------------------------------------------------------------------
536 : 0 : void FormattedFieldCellController::CommitModifications()
537 : : {
538 : 0 : static_cast< FormattedField& >( GetWindow() ).Commit();
539 : 0 : }
540 : :
541 : : //==================================================================
542 : : //= MultiLineTextCell
543 : : //==================================================================
544 : : //------------------------------------------------------------------
545 : 0 : void MultiLineTextCell::Modify()
546 : : {
547 : 0 : GetTextEngine()->SetModified( sal_True );
548 : 0 : MultiLineEdit::Modify();
549 : 0 : }
550 : :
551 : : //------------------------------------------------------------------
552 : 0 : sal_Bool MultiLineTextCell::dispatchKeyEvent( const KeyEvent& _rEvent )
553 : : {
554 [ # # ]: 0 : Selection aOldSelection( GetSelection() );
555 : :
556 [ # # ]: 0 : sal_Bool bWasModified = IsModified();
557 [ # # ]: 0 : ClearModifyFlag( );
558 : :
559 [ # # ][ # # ]: 0 : sal_Bool bHandled = GetTextView()->KeyInput( _rEvent );
560 : :
561 [ # # ]: 0 : sal_Bool bIsModified = IsModified();
562 [ # # ][ # # ]: 0 : if ( bWasModified && !bIsModified )
563 : : // not sure whether this can really happen
564 [ # # ]: 0 : SetModifyFlag();
565 : :
566 [ # # ]: 0 : if ( bHandled ) // the view claimed it handled the key input
567 : : {
568 : : // unfortunately, KeyInput also returns <TRUE/> (means "I handled this key input")
569 : : // when nothing really changed. Let's care for this.
570 [ # # ]: 0 : Selection aNewSelection( GetSelection() );
571 [ # # ][ # # ]: 0 : if ( aNewSelection != aOldSelection // selection changed
[ # # ]
572 : : || bIsModified // or some other modification
573 : : )
574 : 0 : return sal_True;
575 : : }
576 : 0 : return sal_False;
577 : : }
578 : :
579 : : //------------------------------------------------------------------
580 : 0 : long MultiLineTextCell::PreNotify( NotifyEvent& rNEvt )
581 : : {
582 [ # # ]: 0 : if ( rNEvt.GetType() == EVENT_KEYINPUT )
583 : : {
584 [ # # ]: 0 : if ( IsWindowOrChild( rNEvt.GetWindow() ) )
585 : : {
586 : : // give the text view a chance to handle the keys
587 : : // this is necessary since a lot of keys which are normally handled
588 : : // by this view (in KeyInput) are intercepted by the EditBrowseBox,
589 : : // which uses them for other reasons. An example is the KeyUp key,
590 : : // which is used by both the text view and the edit browse box
591 : :
592 : 0 : const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
593 : 0 : const KeyCode& rKeyCode = pKeyEvent->GetKeyCode();
594 : 0 : sal_uInt16 nCode = rKeyCode.GetCode();
595 : :
596 [ # # ][ # # ]: 0 : if ( ( nCode == KEY_RETURN ) && ( rKeyCode.GetModifier() == KEY_MOD1 ) )
[ # # ]
597 : : {
598 : 0 : KeyEvent aEvent( pKeyEvent->GetCharCode(),
599 : : KeyCode( KEY_RETURN ),
600 : 0 : pKeyEvent->GetRepeat()
601 [ # # ]: 0 : );
602 [ # # ][ # # ]: 0 : if ( dispatchKeyEvent( aEvent ) )
603 : 0 : return 1;
604 : : }
605 : :
606 [ # # ][ # # ]: 0 : if ( ( nCode != KEY_TAB ) && ( nCode != KEY_RETURN ) ) // everything but tab and enter
607 : : {
608 [ # # ]: 0 : if ( dispatchKeyEvent( *pKeyEvent ) )
609 : 0 : return 1;
610 : : }
611 : : }
612 : : }
613 : 0 : return MultiLineEdit::PreNotify( rNEvt );
614 : : }
615 : :
616 : : // .......................................................................
617 : : } // namespace svt
618 : : // .......................................................................
619 : :
620 : :
621 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|