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 <tools/shl.hxx>
30 : : #include <sfx2/dispatch.hxx>
31 : : #include <sfx2/objsh.hxx>
32 : : #include <sfx2/viewsh.hxx>
33 : : #include <sfx2/module.hxx>
34 : : #include <tools/urlobj.hxx>
35 : :
36 : : #define _SVX_ITEMWIN_CXX
37 : :
38 : : #include <vcl/svapp.hxx>
39 : :
40 : : #include <svx/dialogs.hrc>
41 : :
42 : : #define DELAY_TIMEOUT 100
43 : :
44 : : #include <svx/xlnclit.hxx>
45 : : #include <svx/xlnwtit.hxx>
46 : : #include <svx/xlineit0.hxx>
47 : : #include <svx/xlndsit.hxx>
48 : : #include <svx/xtable.hxx>
49 : : #include "svx/drawitem.hxx"
50 : : #include <svx/dialmgr.hxx>
51 : : #include "svx/dlgutil.hxx"
52 : : #include <svx/itemwin.hxx>
53 : : #include "svx/linectrl.hxx"
54 : : #include <svtools/colorcfg.hxx>
55 : :
56 : : #include "linectrl.hrc"
57 : :
58 : : using namespace ::com::sun::star::uno;
59 : : using namespace ::com::sun::star::frame;
60 : : using namespace ::com::sun::star::util;
61 : : using namespace ::com::sun::star::lang;
62 : : using namespace ::com::sun::star::beans;
63 : :
64 : : #define LOGICAL_EDIT_HEIGHT 12
65 : : //========================================================================
66 : : // SvxLineBox
67 : : //========================================================================
68 : :
69 : 129 : SvxLineBox::SvxLineBox( Window* pParent, const Reference< XFrame >& rFrame, WinBits nBits ) :
70 : : LineLB( pParent, nBits ),
71 : : nCurPos ( 0 ),
72 : : aLogicalSize(40,140),
73 : : bRelease ( sal_True ),
74 : : mpSh ( NULL ),
75 [ + - ]: 129 : mxFrame ( rFrame )
76 : : {
77 [ + - ][ + - ]: 129 : SetSizePixel( LogicToPixel( aLogicalSize, MAP_APPFONT ));
[ + - ][ + - ]
78 [ + - ]: 129 : Show();
79 : :
80 [ + - ]: 129 : aDelayTimer.SetTimeout( DELAY_TIMEOUT );
81 [ + - ]: 129 : aDelayTimer.SetTimeoutHdl( LINK( this, SvxLineBox, DelayHdl_Impl ) );
82 [ + - ]: 129 : aDelayTimer.Start();
83 : 129 : }
84 : :
85 : : // -----------------------------------------------------------------------
86 : :
87 [ + - ]: 129 : SvxLineBox::~SvxLineBox()
88 : : {
89 [ - + ]: 258 : }
90 : :
91 : : // -----------------------------------------------------------------------
92 : :
93 : 126 : IMPL_LINK_NOARG(SvxLineBox, DelayHdl_Impl)
94 : : {
95 [ + - ]: 126 : if ( GetEntryCount() == 0 )
96 : : {
97 : 126 : mpSh = SfxObjectShell::Current();
98 : 126 : FillControl();
99 : : }
100 : 126 : return 0;
101 : : }
102 : :
103 : : // -----------------------------------------------------------------------
104 : :
105 : 0 : void SvxLineBox::Select()
106 : : {
107 : : // Call the parent's Select() member to trigger accessibility events.
108 : 0 : LineLB::Select();
109 : :
110 [ # # ]: 0 : if ( !IsTravelSelect() )
111 : : {
112 : : XLineStyle eXLS;
113 [ # # ]: 0 : sal_uInt16 nPos = GetSelectEntryPos();
114 : :
115 [ # # # ]: 0 : switch ( nPos )
116 : : {
117 : : case 0:
118 : 0 : eXLS = XLINE_NONE;
119 : 0 : break;
120 : :
121 : : case 1:
122 : 0 : eXLS = XLINE_SOLID;
123 : 0 : break;
124 : :
125 : : default:
126 : : {
127 : 0 : eXLS = XLINE_DASH;
128 : :
129 [ # # ][ # # ]: 0 : if ( nPos != LISTBOX_ENTRY_NOTFOUND &&
[ # # ][ # # ]
130 [ # # ]: 0 : SfxObjectShell::Current() &&
131 [ # # ][ # # ]: 0 : SfxObjectShell::Current()->GetItem( SID_DASH_LIST ) )
132 : : {
133 : : // LineDashItem wird nur geschickt, wenn es auch einen Dash besitzt.
134 : : // Notify k"ummert sich darum!
135 : : SvxDashListItem aItem( *(const SvxDashListItem*)(
136 [ # # ][ # # ]: 0 : SfxObjectShell::Current()->GetItem( SID_DASH_LIST ) ) );
[ # # ]
137 : 0 : XLineDashItem aLineDashItem( GetSelectEntry(),
138 [ # # ][ # # ]: 0 : aItem.GetDashList()->GetDash( nPos - 2 )->GetDash() );
[ # # ][ # # ]
[ # # ]
139 : :
140 : 0 : Any a;
141 [ # # ]: 0 : Sequence< PropertyValue > aArgs( 1 );
142 [ # # ][ # # ]: 0 : aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineDash" ));
143 [ # # ]: 0 : aLineDashItem.QueryValue ( a );
144 [ # # ]: 0 : aArgs[0].Value = a;
145 [ # # ]: 0 : SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
146 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineDash" )),
147 [ # # ][ # # ]: 0 : aArgs );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
148 : : }
149 : : }
150 : 0 : break;
151 : : }
152 : :
153 [ # # ]: 0 : XLineStyleItem aLineStyleItem( eXLS );
154 : 0 : Any a;
155 [ # # ]: 0 : Sequence< PropertyValue > aArgs( 1 );
156 [ # # ][ # # ]: 0 : aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XLineStyle" ));
157 [ # # ]: 0 : aLineStyleItem.QueryValue ( a );
158 [ # # ]: 0 : aArgs[0].Value = a;
159 [ # # ]: 0 : SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
160 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:XLineStyle" )),
161 [ # # ][ # # ]: 0 : aArgs );
[ # # ][ # # ]
162 : :
163 [ # # ]: 0 : nCurPos = GetSelectEntryPos();
164 [ # # ][ # # ]: 0 : ReleaseFocus_Impl();
[ # # ]
165 : : }
166 : 0 : }
167 : :
168 : : // -----------------------------------------------------------------------
169 : :
170 : 0 : long SvxLineBox::PreNotify( NotifyEvent& rNEvt )
171 : : {
172 : 0 : sal_uInt16 nType = rNEvt.GetType();
173 : :
174 [ # # # # ]: 0 : switch(nType)
175 : : {
176 : : case EVENT_MOUSEBUTTONDOWN:
177 : : case EVENT_GETFOCUS:
178 : 0 : nCurPos = GetSelectEntryPos();
179 : 0 : break;
180 : : case EVENT_LOSEFOCUS:
181 : 0 : SelectEntryPos(nCurPos);
182 : 0 : break;
183 : : case EVENT_KEYINPUT:
184 : : {
185 : 0 : const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
186 [ # # ]: 0 : if( pKEvt->GetKeyCode().GetCode() == KEY_TAB)
187 : : {
188 : 0 : bRelease = sal_False;
189 : 0 : Select();
190 : : }
191 : : }
192 : 0 : break;
193 : : }
194 : 0 : return LineLB::PreNotify( rNEvt );
195 : : }
196 : :
197 : : // -----------------------------------------------------------------------
198 : :
199 : 0 : long SvxLineBox::Notify( NotifyEvent& rNEvt )
200 : : {
201 : 0 : long nHandled = LineLB::Notify( rNEvt );
202 : :
203 [ # # ]: 0 : if ( rNEvt.GetType() == EVENT_KEYINPUT )
204 : : {
205 : 0 : const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
206 : :
207 [ # # # ]: 0 : switch ( pKEvt->GetKeyCode().GetCode() )
208 : : {
209 : : case KEY_RETURN:
210 : 0 : Select();
211 : 0 : nHandled = 1;
212 : 0 : break;
213 : :
214 : : case KEY_ESCAPE:
215 : 0 : SelectEntryPos( nCurPos );
216 : 0 : ReleaseFocus_Impl();
217 : 0 : nHandled = 1;
218 : 0 : break;
219 : : }
220 : : }
221 : 0 : return nHandled;
222 : : }
223 : :
224 : : // -----------------------------------------------------------------------
225 : :
226 : 0 : void SvxLineBox::ReleaseFocus_Impl()
227 : : {
228 [ # # ]: 0 : if(!bRelease)
229 : : {
230 : 0 : bRelease = sal_True;
231 : 0 : return;
232 : : }
233 : :
234 [ # # ]: 0 : if( SfxViewShell::Current() )
235 : : {
236 : 0 : Window* pShellWnd = SfxViewShell::Current()->GetWindow();
237 : :
238 [ # # ]: 0 : if ( pShellWnd )
239 : 0 : pShellWnd->GrabFocus();
240 : : }
241 : : }
242 : :
243 : 0 : void SvxLineBox::DataChanged( const DataChangedEvent& rDCEvt )
244 : : {
245 [ # # # # ]: 0 : if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
[ # # ]
246 : 0 : (rDCEvt.GetFlags() & SETTINGS_STYLE) )
247 : : {
248 [ # # ][ # # ]: 0 : SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT));
[ # # ][ # # ]
249 : 0 : Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT);
250 [ # # ][ # # ]: 0 : SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT));
[ # # ][ # # ]
251 : : }
252 : :
253 : 0 : LineLB::DataChanged( rDCEvt );
254 : 0 : }
255 : :
256 : 126 : void SvxLineBox::FillControl()
257 : : {
258 : 126 : FillStyles();
259 [ - + ]: 126 : if ( !mpSh )
260 : 0 : mpSh = SfxObjectShell::Current();
261 : :
262 [ + - ]: 126 : if( mpSh )
263 : : {
264 : 126 : const SvxDashListItem* pItem = (const SvxDashListItem*)( mpSh->GetItem( SID_DASH_LIST ) );
265 [ + - ]: 126 : if ( pItem )
266 [ + - ]: 126 : Fill( pItem->GetDashList() );
267 : : }
268 : 126 : }
269 : :
270 : : //========================================================================
271 : : // SvxColorBox
272 : : //========================================================================
273 : :
274 : 129 : SvxColorBox::SvxColorBox(
275 : : Window* pParent,
276 : : const ::rtl::OUString& rCommand,
277 : : const Reference< XFrame >& rFrame,
278 : : WinBits nBits ) :
279 : : ColorLB( pParent, nBits ),
280 : : nCurPos ( 0 ),
281 : : aLogicalSize(45,80),
282 : : bRelease ( sal_True ),
283 : : maCommand ( rCommand ),
284 [ + - ]: 129 : mxFrame ( rFrame )
285 : : {
286 [ + - ][ + - ]: 129 : SetSizePixel( LogicToPixel( aLogicalSize , MAP_APPFONT));
[ + - ][ + - ]
287 [ + - ]: 129 : Show();
288 : :
289 [ + - ]: 129 : SfxObjectShell* pSh = SfxObjectShell::Current();
290 : :
291 [ + - ]: 129 : if ( pSh )
292 : : {
293 : : const SvxColorListItem* pItem =
294 [ + - ]: 129 : (const SvxColorListItem*)( pSh->GetItem( SID_COLOR_TABLE ) );
295 [ + - ]: 129 : if(pItem)
296 [ + - ][ + - ]: 129 : Fill( pItem->GetColorList() );
297 : : }
298 : 129 : }
299 : :
300 : : // -----------------------------------------------------------------------
301 : :
302 [ + - ]: 129 : SvxColorBox::~SvxColorBox()
303 : : {
304 [ - + ]: 258 : }
305 : :
306 : : // -----------------------------------------------------------------------
307 : :
308 : 150 : void SvxColorBox::Update( const XLineColorItem* pItem )
309 : : {
310 [ + - ]: 150 : if ( pItem )
311 : 150 : SelectEntry( pItem->GetColorValue() );
312 : : else
313 : 0 : SetNoSelection();
314 : 150 : }
315 : :
316 : : // -----------------------------------------------------------------------
317 : :
318 : 0 : void SvxColorBox::Select()
319 : : {
320 : : // OJ: base class call needed here because otherwise no event is send for accessibility
321 : 0 : ColorLB::Select();
322 [ # # ]: 0 : if ( !IsTravelSelect() )
323 : : {
324 [ # # ][ # # ]: 0 : XLineColorItem aLineColorItem( GetSelectEntry(), GetSelectEntryColor() );
[ # # ][ # # ]
325 : :
326 [ # # ]: 0 : INetURLObject aObj( maCommand );
327 : :
328 : 0 : Any a;
329 [ # # ]: 0 : Sequence< PropertyValue > aArgs( 1 );
330 [ # # ][ # # ]: 0 : aArgs[0].Name = aObj.GetURLPath();
331 [ # # ]: 0 : aLineColorItem.QueryValue( a );
332 [ # # ]: 0 : aArgs[0].Value = a;
333 [ # # ]: 0 : SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
334 : : maCommand,
335 [ # # ][ # # ]: 0 : aArgs );
[ # # ]
336 : :
337 [ # # ]: 0 : nCurPos = GetSelectEntryPos();
338 [ # # ][ # # ]: 0 : ReleaseFocus_Impl();
[ # # ][ # # ]
339 : : }
340 : 0 : }
341 : :
342 : : // -----------------------------------------------------------------------
343 : :
344 : 0 : long SvxColorBox::PreNotify( NotifyEvent& rNEvt )
345 : : {
346 : 0 : sal_uInt16 nType = rNEvt.GetType();
347 : :
348 [ # # # # ]: 0 : switch(nType)
349 : : {
350 : : case EVENT_MOUSEBUTTONDOWN:
351 : : case EVENT_GETFOCUS:
352 : 0 : nCurPos = GetSelectEntryPos();
353 : 0 : break;
354 : : case EVENT_LOSEFOCUS:
355 : 0 : SelectEntryPos(nCurPos);
356 : 0 : break;
357 : : case EVENT_KEYINPUT:
358 : : {
359 : 0 : const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
360 : :
361 [ # # ]: 0 : if( pKEvt->GetKeyCode().GetCode() == KEY_TAB)
362 : : {
363 : 0 : bRelease = sal_False;
364 : 0 : Select();
365 : : }
366 : : }
367 : : }
368 : :
369 : 0 : return ColorLB::PreNotify( rNEvt );
370 : : }
371 : :
372 : : // -----------------------------------------------------------------------
373 : :
374 : 0 : long SvxColorBox::Notify( NotifyEvent& rNEvt )
375 : : {
376 : 0 : long nHandled = ColorLB::Notify( rNEvt );
377 : :
378 [ # # ]: 0 : if ( rNEvt.GetType() == EVENT_KEYINPUT )
379 : : {
380 : 0 : const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
381 : :
382 [ # # # ]: 0 : switch ( pKEvt->GetKeyCode().GetCode() )
383 : : {
384 : : case KEY_RETURN:
385 : 0 : Select();
386 : 0 : nHandled = 1;
387 : 0 : break;
388 : :
389 : : case KEY_ESCAPE:
390 : 0 : SelectEntryPos( nCurPos );
391 : 0 : ReleaseFocus_Impl();
392 : 0 : nHandled = 1;
393 : 0 : break;
394 : : }
395 : : }
396 : 0 : return nHandled;
397 : : }
398 : :
399 : 0 : void SvxColorBox::DataChanged( const DataChangedEvent& rDCEvt )
400 : : {
401 [ # # # # ]: 0 : if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
[ # # ]
402 : 0 : (rDCEvt.GetFlags() & SETTINGS_STYLE) )
403 : : {
404 [ # # ][ # # ]: 0 : SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT));
[ # # ][ # # ]
405 : 0 : Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT);
406 [ # # ][ # # ]: 0 : SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT));
[ # # ][ # # ]
407 : : }
408 : :
409 : 0 : ColorLB::DataChanged( rDCEvt );
410 : 0 : }
411 : : // -----------------------------------------------------------------------
412 : :
413 : 0 : void SvxColorBox::ReleaseFocus_Impl()
414 : : {
415 [ # # ]: 0 : if(!bRelease)
416 : : {
417 : 0 : bRelease = sal_True;
418 : 0 : return;
419 : : }
420 : :
421 [ # # ]: 0 : if( SfxViewShell::Current() )
422 : : {
423 : 0 : Window* pShellWnd = SfxViewShell::Current()->GetWindow();
424 : :
425 [ # # ]: 0 : if ( pShellWnd )
426 : 0 : pShellWnd->GrabFocus();
427 : : }
428 : : }
429 : :
430 : : //========================================================================
431 : : // SvxMetricField
432 : : //========================================================================
433 : :
434 : 129 : SvxMetricField::SvxMetricField(
435 : : Window* pParent, const Reference< XFrame >& rFrame, WinBits nBits ) :
436 : : MetricField( pParent, nBits ),
437 : : aCurTxt( String() ),
438 [ + - ]: 129 : mxFrame( rFrame )
439 : : {
440 [ + - ][ + - ]: 129 : Size aSize = Size(GetTextWidth( rtl::OUString("99,99mm") ),GetTextHeight());
[ + - ][ + - ]
441 : 129 : aSize.Width() += 20;
442 : 129 : aSize.Height() += 6;
443 [ + - ]: 129 : SetSizePixel( aSize );
444 [ + - ][ + - ]: 129 : aLogicalSize = PixelToLogic(aSize, MAP_APPFONT);
[ + - ]
445 [ + - ]: 129 : SetUnit( FUNIT_MM );
446 [ + - ]: 129 : SetDecimalDigits( 2 );
447 [ + - ]: 129 : SetMax( 5000 );
448 [ + - ]: 129 : SetMin( 0 );
449 [ + - ]: 129 : SetLast( 5000 );
450 [ + - ]: 129 : SetFirst( 0 );
451 : :
452 [ + - ]: 129 : eDlgUnit = SfxModule::GetModuleFieldUnit( mxFrame );
453 [ + - ]: 129 : SetFieldUnit( *this, eDlgUnit, sal_False );
454 [ + - ]: 129 : Show();
455 : 129 : }
456 : :
457 : : // -----------------------------------------------------------------------
458 : :
459 [ + - ]: 129 : SvxMetricField::~SvxMetricField()
460 : : {
461 [ - + ]: 258 : }
462 : :
463 : : // -----------------------------------------------------------------------
464 : :
465 : 150 : void SvxMetricField::Update( const XLineWidthItem* pItem )
466 : : {
467 [ + - ]: 150 : if ( pItem )
468 : : {
469 [ - + ]: 150 : if ( pItem->GetValue() != GetCoreValue( *this, ePoolUnit ) )
470 : 0 : SetMetricValue( *this, pItem->GetValue(), ePoolUnit );
471 : : }
472 : : else
473 [ # # ]: 0 : SetText( String() );
474 : 150 : }
475 : :
476 : : // -----------------------------------------------------------------------
477 : :
478 : 0 : void SvxMetricField::Modify()
479 : : {
480 [ # # ]: 0 : MetricField::Modify();
481 [ # # ]: 0 : long nTmp = GetCoreValue( *this, ePoolUnit );
482 [ # # ]: 0 : XLineWidthItem aLineWidthItem( nTmp );
483 : :
484 : 0 : Any a;
485 [ # # ]: 0 : Sequence< PropertyValue > aArgs( 1 );
486 [ # # ][ # # ]: 0 : aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineWidth" ));
487 [ # # ]: 0 : aLineWidthItem.QueryValue( a );
488 [ # # ]: 0 : aArgs[0].Value = a;
489 [ # # ]: 0 : SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
490 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineWidth" )),
491 [ # # ][ # # ]: 0 : aArgs );
[ # # ][ # # ]
[ # # ][ # # ]
492 : 0 : }
493 : :
494 : : // -----------------------------------------------------------------------
495 : :
496 : 0 : void SvxMetricField::ReleaseFocus_Impl()
497 : : {
498 [ # # ]: 0 : if( SfxViewShell::Current() )
499 : : {
500 : 0 : Window* pShellWnd = SfxViewShell::Current()->GetWindow();
501 [ # # ]: 0 : if ( pShellWnd )
502 : 0 : pShellWnd->GrabFocus();
503 : : }
504 : 0 : }
505 : :
506 : : // -----------------------------------------------------------------------
507 : :
508 : 0 : void SvxMetricField::Down()
509 : : {
510 : 0 : sal_Int64 nValue = GetValue();
511 : 0 : nValue -= GetSpinSize();
512 : :
513 : : // Um unter OS/2 einen Sprung auf Max zu verhindern
514 [ # # ]: 0 : if ( nValue >= GetMin() )
515 : 0 : MetricField::Down();
516 : 0 : }
517 : :
518 : : // -----------------------------------------------------------------------
519 : :
520 : 0 : void SvxMetricField::Up()
521 : : {
522 : 0 : MetricField::Up();
523 : 0 : }
524 : :
525 : : // -----------------------------------------------------------------------
526 : :
527 : 150 : void SvxMetricField::SetCoreUnit( SfxMapUnit eUnit )
528 : : {
529 : 150 : ePoolUnit = eUnit;
530 : 150 : }
531 : :
532 : : // -----------------------------------------------------------------------
533 : :
534 : 206 : void SvxMetricField::RefreshDlgUnit()
535 : : {
536 : 206 : FieldUnit eTmpUnit = SfxModule::GetModuleFieldUnit( mxFrame );
537 [ - + ]: 206 : if ( eDlgUnit != eTmpUnit )
538 : : {
539 : 0 : eDlgUnit = eTmpUnit;
540 : 0 : SetFieldUnit( *this, eDlgUnit, sal_False );
541 : : }
542 : 206 : }
543 : :
544 : : // -----------------------------------------------------------------------
545 : :
546 : 0 : long SvxMetricField::PreNotify( NotifyEvent& rNEvt )
547 : : {
548 : 0 : sal_uInt16 nType = rNEvt.GetType();
549 : :
550 [ # # ][ # # ]: 0 : if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
551 [ # # ]: 0 : aCurTxt = GetText();
552 : :
553 : 0 : return MetricField::PreNotify( rNEvt );
554 : : }
555 : :
556 : : // -----------------------------------------------------------------------
557 : :
558 : 0 : long SvxMetricField::Notify( NotifyEvent& rNEvt )
559 : : {
560 : 0 : long nHandled = MetricField::Notify( rNEvt );
561 : :
562 [ # # ]: 0 : if ( rNEvt.GetType() == EVENT_KEYINPUT )
563 : : {
564 : 0 : const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
565 : 0 : const KeyCode& rKey = pKEvt->GetKeyCode();
566 : 0 : SfxViewShell* pSh = SfxViewShell::Current();
567 : :
568 [ # # ][ # # ]: 0 : if ( rKey.GetModifier() && rKey.GetGroup() != KEYGROUP_CURSOR && pSh )
[ # # ][ # # ]
569 : 0 : pSh->KeyInput( *pKEvt );
570 : : else
571 : : {
572 : 0 : bool bHandled = false;
573 : :
574 [ # # # ]: 0 : switch ( rKey.GetCode() )
575 : : {
576 : : case KEY_RETURN:
577 : 0 : Reformat();
578 : 0 : bHandled = true;
579 : 0 : break;
580 : :
581 : : case KEY_ESCAPE:
582 : 0 : SetText( aCurTxt );
583 : 0 : bHandled = true;
584 : 0 : break;
585 : : }
586 : :
587 [ # # ]: 0 : if ( bHandled )
588 : : {
589 : 0 : nHandled = 1;
590 : 0 : Modify();
591 : 0 : ReleaseFocus_Impl();
592 : : }
593 : : }
594 : : }
595 : 0 : return nHandled;
596 : : }
597 : :
598 : 0 : void SvxMetricField::DataChanged( const DataChangedEvent& rDCEvt )
599 : : {
600 [ # # # # ]: 0 : if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
[ # # ]
601 : 0 : (rDCEvt.GetFlags() & SETTINGS_STYLE) )
602 : : {
603 [ # # ][ # # ]: 0 : SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT));
604 : : }
605 : :
606 : 0 : MetricField::DataChanged( rDCEvt );
607 : 0 : }
608 : :
609 : : //========================================================================
610 : : // SvxFillTypeBox
611 : : //========================================================================
612 : :
613 : 129 : SvxFillTypeBox::SvxFillTypeBox( Window* pParent, WinBits nBits ) :
614 : : FillTypeLB( pParent, nBits | WB_TABSTOP ),
615 : : nCurPos ( 0 ),
616 : : bSelect ( sal_False ),
617 : 129 : bRelease(sal_True)
618 : : {
619 [ + - ][ + - ]: 129 : SetSizePixel( LogicToPixel( Size(40, 40 ),MAP_APPFONT ));
[ + - ][ + - ]
620 [ + - ]: 129 : Fill();
621 [ + - ]: 129 : SelectEntryPos( XFILL_SOLID );
622 [ + - ]: 129 : Show();
623 : 129 : }
624 : :
625 : : // -----------------------------------------------------------------------
626 : :
627 : 129 : SvxFillTypeBox::~SvxFillTypeBox()
628 : : {
629 [ - + ]: 258 : }
630 : :
631 : : // -----------------------------------------------------------------------
632 : :
633 : 0 : long SvxFillTypeBox::PreNotify( NotifyEvent& rNEvt )
634 : : {
635 : 0 : sal_uInt16 nType = rNEvt.GetType();
636 : :
637 [ # # ][ # # ]: 0 : if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
638 : 0 : nCurPos = GetSelectEntryPos();
639 [ # # # # : 0 : else if ( EVENT_LOSEFOCUS == nType
# # ][ # # ]
640 : 0 : && Application::GetFocusWindow()
641 : 0 : && !IsWindowOrChild( Application::GetFocusWindow(), sal_True ) )
642 : : {
643 [ # # ]: 0 : if ( !bSelect )
644 : 0 : SelectEntryPos( nCurPos );
645 : : else
646 : 0 : bSelect = sal_False;
647 : : }
648 : :
649 : 0 : return FillTypeLB::PreNotify( rNEvt );
650 : : }
651 : :
652 : : // -----------------------------------------------------------------------
653 : :
654 : 0 : long SvxFillTypeBox::Notify( NotifyEvent& rNEvt )
655 : : {
656 : 0 : long nHandled = FillTypeLB::Notify( rNEvt );
657 : :
658 [ # # ]: 0 : if ( rNEvt.GetType() == EVENT_KEYINPUT )
659 : : {
660 : 0 : const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
661 [ # # # # ]: 0 : switch ( pKEvt->GetKeyCode().GetCode() )
662 : : {
663 : : case KEY_RETURN:
664 : 0 : nHandled = 1;
665 : 0 : ( (Link&)GetSelectHdl() ).Call( this );
666 : 0 : break;
667 : : case KEY_TAB:
668 : 0 : bRelease = sal_False;
669 : 0 : ( (Link&)GetSelectHdl() ).Call( this );
670 : 0 : bRelease = sal_True;
671 : 0 : break;
672 : :
673 : : case KEY_ESCAPE:
674 : 0 : SelectEntryPos( nCurPos );
675 : 0 : ReleaseFocus_Impl();
676 : 0 : nHandled = 1;
677 : 0 : break;
678 : : }
679 : : }
680 : 0 : return nHandled;
681 : : }
682 : :
683 : : // -----------------------------------------------------------------------
684 : :
685 : 0 : void SvxFillTypeBox::ReleaseFocus_Impl()
686 : : {
687 [ # # ]: 0 : if( SfxViewShell::Current() )
688 : : {
689 : 0 : Window* pShellWnd = SfxViewShell::Current()->GetWindow();
690 : :
691 [ # # ]: 0 : if ( pShellWnd )
692 : 0 : pShellWnd->GrabFocus();
693 : : }
694 : 0 : }
695 : :
696 : : //========================================================================
697 : : // SvxFillAttrBox
698 : : //========================================================================
699 : :
700 : 129 : SvxFillAttrBox::SvxFillAttrBox( Window* pParent, WinBits nBits ) :
701 : :
702 : : FillAttrLB( pParent, nBits | WB_TABSTOP ),
703 : :
704 : : nCurPos( 0 ),
705 : 129 : bRelease( sal_True )
706 : :
707 : : {
708 [ + - ]: 129 : SetPosPixel( Point( 90, 0 ) );
709 [ + - ][ + - ]: 129 : SetSizePixel( LogicToPixel( Size(50, 80 ), MAP_APPFONT ));
[ + - ][ + - ]
710 [ + - ]: 129 : Show();
711 : 129 : }
712 : :
713 : : // -----------------------------------------------------------------------
714 : :
715 : 129 : SvxFillAttrBox::~SvxFillAttrBox()
716 : : {
717 [ - + ]: 258 : }
718 : :
719 : : // -----------------------------------------------------------------------
720 : :
721 : 0 : long SvxFillAttrBox::PreNotify( NotifyEvent& rNEvt )
722 : : {
723 : 0 : sal_uInt16 nType = rNEvt.GetType();
724 : :
725 [ # # ][ # # ]: 0 : if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
726 : 0 : nCurPos = GetSelectEntryPos();
727 : :
728 : 0 : return FillAttrLB::PreNotify( rNEvt );
729 : : }
730 : :
731 : : // -----------------------------------------------------------------------
732 : :
733 : 0 : long SvxFillAttrBox::Notify( NotifyEvent& rNEvt )
734 : : {
735 : 0 : long nHandled = FillAttrLB::Notify( rNEvt );
736 : :
737 [ # # ]: 0 : if ( rNEvt.GetType() == EVENT_KEYINPUT )
738 : : {
739 : 0 : const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
740 : :
741 [ # # # # ]: 0 : switch ( pKEvt->GetKeyCode().GetCode() )
742 : : {
743 : : case KEY_RETURN:
744 : 0 : ( (Link&)GetSelectHdl() ).Call( this );
745 : 0 : nHandled = 1;
746 : 0 : break;
747 : : case KEY_TAB:
748 : 0 : bRelease = sal_False;
749 : 0 : GetSelectHdl().Call( this );
750 : 0 : bRelease = sal_True;
751 : 0 : break;
752 : : case KEY_ESCAPE:
753 : 0 : SelectEntryPos( nCurPos );
754 : 0 : ReleaseFocus_Impl();
755 : 0 : nHandled = 1;
756 : 0 : break;
757 : : }
758 : : }
759 : 0 : return nHandled;
760 : : }
761 : :
762 : : // -----------------------------------------------------------------------
763 : :
764 : 0 : void SvxFillAttrBox::Select()
765 : : {
766 : 0 : FillAttrLB::Select();
767 : 0 : }
768 : :
769 : : // -----------------------------------------------------------------------
770 : :
771 : 0 : void SvxFillAttrBox::ReleaseFocus_Impl()
772 : : {
773 [ # # ]: 0 : if( SfxViewShell::Current() )
774 : : {
775 : 0 : Window* pShellWnd = SfxViewShell::Current()->GetWindow();
776 : :
777 [ # # ]: 0 : if ( pShellWnd )
778 : 0 : pShellWnd->GrabFocus();
779 : : }
780 : 0 : }
781 : :
782 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|