LCOV - code coverage report
Current view: top level - svtools/source/control - filectrl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 87 0.0 %
Date: 2012-08-25 Functions: 0 12 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 128 0.0 %

           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/svtresid.hxx>
      30                 :            : #include <svtools/filectrl.hxx>
      31                 :            : #include <filectrl.hrc>
      32                 :            : 
      33                 :            : // =======================================================================
      34                 :            : 
      35                 :          0 : FileControl::FileControl( Window* pParent, WinBits nStyle, FileControlMode nFlags ) :
      36                 :            :     Window( pParent, nStyle|WB_DIALOGCONTROL ),
      37                 :            :     maEdit( this, (nStyle&(~WB_BORDER))|WB_NOTABSTOP ),
      38                 :            :     maButton( this, (nStyle&(~WB_BORDER))|WB_NOLIGHTBORDER|WB_NOPOINTERFOCUS|WB_NOTABSTOP ),
      39                 :            :     maButtonText( SVT_RESSTR(STR_FILECTRL_BUTTONTEXT) ),
      40                 :            :     mnFlags( nFlags ),
      41 [ #  # ][ #  # ]:          0 :     mnInternalFlags( FILECTRL_ORIGINALBUTTONTEXT )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      42                 :            : {
      43         [ #  # ]:          0 :     maButton.SetClickHdl( LINK( this, FileControl, ButtonHdl ) );
      44                 :          0 :     mbOpenDlg = sal_True;
      45                 :            : 
      46         [ #  # ]:          0 :     maButton.Show();
      47         [ #  # ]:          0 :     maEdit.Show();
      48                 :            : 
      49         [ #  # ]:          0 :     SetCompoundControl( sal_True );
      50                 :            : 
      51 [ #  # ][ #  # ]:          0 :     SetStyle( ImplInitStyle( GetStyle() ) );
                 [ #  # ]
      52                 :          0 : }
      53                 :            : 
      54                 :            : // -----------------------------------------------------------------------
      55                 :            : 
      56                 :          0 : WinBits FileControl::ImplInitStyle( WinBits nStyle )
      57                 :            : {
      58         [ #  # ]:          0 :     if ( !( nStyle & WB_NOTABSTOP ) )
      59                 :            :     {
      60                 :          0 :         maEdit.SetStyle( (maEdit.GetStyle()|WB_TABSTOP)&(~WB_NOTABSTOP) );
      61                 :          0 :         maButton.SetStyle( (maButton.GetStyle()|WB_TABSTOP)&(~WB_NOTABSTOP) );
      62                 :            :     }
      63                 :            :     else
      64                 :            :     {
      65                 :          0 :         maEdit.SetStyle( (maEdit.GetStyle()|WB_NOTABSTOP)&(~WB_TABSTOP) );
      66                 :          0 :         maButton.SetStyle( (maButton.GetStyle()|WB_NOTABSTOP)&(~WB_TABSTOP) );
      67                 :            :     }
      68                 :            : 
      69                 :          0 :     const WinBits nAlignmentStyle = ( WB_TOP | WB_VCENTER | WB_BOTTOM );
      70                 :          0 :     maEdit.SetStyle( ( maEdit.GetStyle() & ~nAlignmentStyle ) | ( nStyle & nAlignmentStyle ) );
      71                 :            : 
      72         [ #  # ]:          0 :     if ( !(nStyle & WB_NOGROUP) )
      73                 :          0 :         nStyle |= WB_GROUP;
      74                 :            : 
      75         [ #  # ]:          0 :     if ( !(nStyle & WB_NOBORDER ) )
      76                 :          0 :         nStyle |= WB_BORDER;
      77                 :            : 
      78                 :          0 :     nStyle &= ~WB_TABSTOP;
      79                 :            : 
      80                 :          0 :     return nStyle;
      81                 :            : }
      82                 :            : 
      83                 :            : // -----------------------------------------------------------------------
      84                 :            : 
      85 [ #  # ][ #  # ]:          0 : FileControl::~FileControl()
                 [ #  # ]
      86                 :            : {
      87         [ #  # ]:          0 : }
      88                 :            : 
      89                 :            : // -----------------------------------------------------------------------
      90                 :            : 
      91                 :          0 : void FileControl::SetText( const XubString& rStr )
      92                 :            : {
      93                 :          0 :     maEdit.SetText( rStr );
      94         [ #  # ]:          0 :     if ( mnFlags & FILECTRL_RESIZEBUTTONBYPATHLEN )
      95                 :          0 :         Resize();
      96                 :          0 : }
      97                 :            : 
      98                 :            : // -----------------------------------------------------------------------
      99                 :            : 
     100                 :          0 : XubString FileControl::GetText() const
     101                 :            : {
     102                 :          0 :     return maEdit.GetText();
     103                 :            : }
     104                 :            : 
     105                 :            : // -----------------------------------------------------------------------
     106                 :            : 
     107                 :          0 : void FileControl::StateChanged( StateChangedType nType )
     108                 :            : {
     109         [ #  # ]:          0 :     if ( nType == STATE_CHANGE_ENABLE )
     110                 :            :     {
     111                 :          0 :         maEdit.Enable( IsEnabled() );
     112                 :          0 :         maButton.Enable( IsEnabled() );
     113                 :            :     }
     114         [ #  # ]:          0 :     else if ( nType == STATE_CHANGE_ZOOM )
     115                 :            :     {
     116                 :          0 :         GetEdit().SetZoom( GetZoom() );
     117                 :          0 :         GetButton().SetZoom( GetZoom() );
     118                 :            :     }
     119         [ #  # ]:          0 :     else if ( nType == STATE_CHANGE_STYLE )
     120                 :            :     {
     121                 :          0 :         SetStyle( ImplInitStyle( GetStyle() ) );
     122                 :            :     }
     123         [ #  # ]:          0 :     else if ( nType == STATE_CHANGE_CONTROLFONT )
     124                 :            :     {
     125 [ #  # ][ #  # ]:          0 :         GetEdit().SetControlFont( GetControlFont() );
                 [ #  # ]
     126                 :            :         // Fuer den Button nur die Hoehe uebernehmen, weil in
     127                 :            :         // HTML immer Courier eingestellt wird.
     128         [ #  # ]:          0 :         Font aFont = GetButton().GetControlFont();
     129 [ #  # ][ #  # ]:          0 :         aFont.SetSize( GetControlFont().GetSize() );
         [ #  # ][ #  # ]
     130 [ #  # ][ #  # ]:          0 :         GetButton().SetControlFont( aFont );
     131                 :            :     }
     132         [ #  # ]:          0 :     else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
     133                 :            :     {
     134         [ #  # ]:          0 :         GetEdit().SetControlForeground( GetControlForeground() );
     135         [ #  # ]:          0 :         GetButton().SetControlForeground( GetControlForeground() );
     136                 :            :     }
     137         [ #  # ]:          0 :     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
     138                 :            :     {
     139         [ #  # ]:          0 :         GetEdit().SetControlBackground( GetControlBackground() );
     140         [ #  # ]:          0 :         GetButton().SetControlBackground( GetControlBackground() );
     141                 :            :     }
     142                 :          0 :     Window::StateChanged( nType );
     143                 :          0 : }
     144                 :            : 
     145                 :            : // -----------------------------------------------------------------------
     146                 :            : 
     147                 :          0 : void FileControl::Resize()
     148                 :            : {
     149                 :            :     static long ButtonBorder = 10;
     150                 :            : 
     151         [ #  # ]:          0 :     if( mnInternalFlags & FILECTRL_INRESIZE )
     152                 :          0 :         return;
     153                 :          0 :     mnInternalFlags |= FILECTRL_INRESIZE;//InResize = sal_True
     154                 :            : 
     155                 :          0 :     Size aOutSz = GetOutputSizePixel();
     156         [ #  # ]:          0 :     long nButtonTextWidth = maButton.GetTextWidth( maButtonText );
     157   [ #  #  #  # ]:          0 :     if ( ((mnInternalFlags & FILECTRL_ORIGINALBUTTONTEXT) == 0) ||
         [ #  # ][ #  # ]
     158                 :          0 :         ( nButtonTextWidth < aOutSz.Width()/3 &&
     159                 :            :         ( mnFlags & FILECTRL_RESIZEBUTTONBYPATHLEN
     160 [ #  # ][ #  # ]:          0 :         ? ( maEdit.GetTextWidth( maEdit.GetText() )
         [ #  # ][ #  # ]
                 [ #  # ]
     161                 :          0 :             <= aOutSz.Width() - nButtonTextWidth - ButtonBorder )
     162         [ #  # ]:          0 :         : sal_True ) )
     163                 :            :        )
     164                 :            :     {
     165         [ #  # ]:          0 :         maButton.SetText( maButtonText );
     166                 :            :     }
     167                 :            :     else
     168                 :            :     {
     169                 :          0 :         rtl::OUString aSmallText( "..." );
     170 [ #  # ][ #  # ]:          0 :         maButton.SetText( aSmallText );
                 [ #  # ]
     171 [ #  # ][ #  # ]:          0 :         nButtonTextWidth = maButton.GetTextWidth( aSmallText );
                 [ #  # ]
     172                 :            :     }
     173                 :            : 
     174                 :          0 :     long nButtonWidth = nButtonTextWidth+ButtonBorder;
     175         [ #  # ]:          0 :     maEdit.SetPosSizePixel( 0, 0, aOutSz.Width()-nButtonWidth, aOutSz.Height() );
     176         [ #  # ]:          0 :     maButton.SetPosSizePixel( aOutSz.Width()-nButtonWidth, 0, nButtonWidth, aOutSz.Height() );
     177                 :            : 
     178                 :          0 :     mnInternalFlags &= ~FILECTRL_INRESIZE; //InResize = sal_False
     179                 :            : }
     180                 :            : 
     181                 :            : // -----------------------------------------------------------------------
     182                 :            : 
     183                 :          0 : IMPL_LINK_NOARG(FileControl, ButtonHdl)
     184                 :            : {
     185                 :          0 :     ImplBrowseFile( );
     186                 :            : 
     187                 :          0 :     return 0;
     188                 :            : }
     189                 :            : 
     190                 :            : // -----------------------------------------------------------------------
     191                 :            : 
     192                 :          0 : void FileControl::GetFocus()
     193                 :            : {
     194                 :          0 :     maEdit.GrabFocus();
     195                 :          0 : }
     196                 :            : 
     197                 :            : // -----------------------------------------------------------------------
     198                 :            : 
     199                 :          0 : void FileControl::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags )
     200                 :            : {
     201                 :          0 :     WinBits nOldEditStyle = GetEdit().GetStyle();
     202         [ #  # ]:          0 :     if ( GetStyle() & WB_BORDER )
     203                 :          0 :         GetEdit().SetStyle( nOldEditStyle|WB_BORDER );
     204                 :          0 :     GetEdit().Draw( pDev, rPos, rSize, nFlags );
     205         [ #  # ]:          0 :     if ( GetStyle() & WB_BORDER )
     206                 :          0 :         GetEdit().SetStyle( nOldEditStyle );
     207                 :          0 : }
     208                 :            : 
     209                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10