LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/source/tbxctrls - itemwin.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 86 348 24.7 %
Date: 2013-07-09 Functions: 24 48 50.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10