LCOV - code coverage report
Current view: top level - svx/source/dialog - linkwarn.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 70 0.0 %
Date: 2012-08-25 Functions: 0 4 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 162 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                 :            :  * Copyright 2010 Novell, Inc.
       8                 :            :  *
       9                 :            :  * OpenOffice.org - a multi-platform office productivity suite
      10                 :            :  *
      11                 :            :  * This file is part of OpenOffice.org.
      12                 :            :  *
      13                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      14                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      15                 :            :  * only, as published by the Free Software Foundation.
      16                 :            :  *
      17                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      18                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      19                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      20                 :            :  * GNU Lesser General Public License version 3 for more details
      21                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      22                 :            :  *
      23                 :            :  * You should have received a copy of the GNU Lesser General Public License
      24                 :            :  * version 3 along with OpenOffice.org.  If not, see
      25                 :            :  * <http://www.openoffice.org/license.html>
      26                 :            :  * for a copy of the LGPLv3 License.
      27                 :            :  *
      28                 :            :  ************************************************************************/
      29                 :            : 
      30                 :            : 
      31                 :            : #include "linkwarn.hrc"
      32                 :            : #include "svx/linkwarn.hxx"
      33                 :            : #include "svx/dialogs.hrc"
      34                 :            : #include "svx/dialmgr.hxx"
      35                 :            : #include <vcl/msgbox.hxx>
      36                 :            : #include <sfx2/basedlgs.hxx>
      37                 :            : #include <svtools/miscopt.hxx>
      38                 :            : 
      39                 :          0 : SvxLinkWarningDialog::SvxLinkWarningDialog( Window* pParent, const String& _rFileName ) :
      40                 :          0 :     SfxModalDialog( pParent, SVX_RES( RID_SVXDLG_LINK_WARNING ) ),
      41         [ #  # ]:          0 :     m_aQueryImage       ( this, SVX_RES( FI_QUERY ) ),
      42         [ #  # ]:          0 :     m_aInfoText         ( this, SVX_RES( FT_INFOTEXT ) ),
      43         [ #  # ]:          0 :     m_aLinkGraphicBtn   ( this, SVX_RES( PB_OK ) ),
      44         [ #  # ]:          0 :     m_aEmbedGraphicBtn  ( this, SVX_RES( PB_NO ) ),
      45         [ #  # ]:          0 :     m_aOptionLine       ( this, SVX_RES( FL_OPTION ) ),
      46 [ #  # ][ #  # ]:          0 :     m_aWarningOnBox     ( this, SVX_RES( CB_WARNING_OFF ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      47                 :            : {
      48         [ #  # ]:          0 :     FreeResource();
      49                 :            : 
      50                 :            :     // set questionmark image
      51 [ #  # ][ #  # ]:          0 :     m_aQueryImage.SetImage( QueryBox::GetStandardImage() );
                 [ #  # ]
      52                 :            : 
      53                 :            :     // replace filename
      54         [ #  # ]:          0 :     String sInfoText = m_aInfoText.GetText();
      55 [ #  # ][ #  # ]:          0 :     sInfoText.SearchAndReplaceAll(rtl::OUString("%FILENAME"), _rFileName);
                 [ #  # ]
      56         [ #  # ]:          0 :     m_aInfoText.SetText( sInfoText );
      57                 :            : 
      58                 :            :     // load state of "warning on" checkbox from misc options
      59         [ #  # ]:          0 :     SvtMiscOptions aMiscOpt;
      60 [ #  # ][ #  # ]:          0 :     m_aWarningOnBox.Check( aMiscOpt.ShowLinkWarningDialog() == sal_True );
      61 [ #  # ][ #  # ]:          0 :     if( aMiscOpt.IsShowLinkWarningDialogReadOnly() )
      62         [ #  # ]:          0 :         m_aWarningOnBox.Disable();
      63                 :            : 
      64                 :            :     // set focus to Cancel button
      65         [ #  # ]:          0 :     m_aEmbedGraphicBtn.GrabFocus();
      66                 :            : 
      67                 :            :     // calculate and set the size of the dialog and its controls
      68 [ #  # ][ #  # ]:          0 :     InitSize();
                 [ #  # ]
      69                 :          0 : }
      70                 :            : 
      71                 :            : // -----------------------------------------------------------------------
      72                 :            : 
      73 [ #  # ][ #  # ]:          0 : SvxLinkWarningDialog::~SvxLinkWarningDialog()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      74                 :            : {
      75                 :            :     // save value of "warning off" checkbox, if necessary
      76         [ #  # ]:          0 :     SvtMiscOptions aMiscOpt;
      77         [ #  # ]:          0 :     sal_Bool bChecked = m_aWarningOnBox.IsChecked();
      78 [ #  # ][ #  # ]:          0 :     if ( aMiscOpt.ShowLinkWarningDialog() != bChecked )
      79 [ #  # ][ #  # ]:          0 :         aMiscOpt.SetShowLinkWarningDialog( bChecked );
      80         [ #  # ]:          0 : }
      81                 :            : 
      82                 :            : // -----------------------------------------------------------------------
      83                 :            : 
      84                 :          0 : void SvxLinkWarningDialog::InitSize()
      85                 :            : {
      86                 :            :     // text of checkbox to wide -> add new line
      87 [ #  # ][ #  # ]:          0 :     long nTxtW = m_aWarningOnBox.GetCtrlTextWidth( m_aWarningOnBox.GetText() ) + IMPL_EXTRA_BUTTON_WIDTH;
                 [ #  # ]
      88         [ #  # ]:          0 :     long nCtrlW = m_aWarningOnBox.GetSizePixel().Width();
      89         [ #  # ]:          0 :     if ( nTxtW >= nCtrlW )
      90                 :            :     {
      91         [ #  # ]:          0 :         long nTextHeight = m_aWarningOnBox.GetTextHeight();
      92         [ #  # ]:          0 :         Size aNewSize = m_aWarningOnBox.GetSizePixel();
      93                 :          0 :         aNewSize.Height() += nTextHeight;
      94         [ #  # ]:          0 :         m_aWarningOnBox.SetSizePixel( aNewSize );
      95         [ #  # ]:          0 :         aNewSize = GetSizePixel();
      96                 :          0 :         aNewSize.Height() += nTextHeight;
      97         [ #  # ]:          0 :         SetSizePixel( aNewSize );
      98                 :            :     }
      99                 :            : 
     100                 :            :     // align the size of the information text control (FixedText) to its content
     101 [ #  # ][ #  # ]:          0 :     Size aMinSize = m_aInfoText.CalcMinimumSize( m_aInfoText.GetSizePixel().Width() );
     102                 :          0 :     long nTxtH = aMinSize.Height();
     103         [ #  # ]:          0 :     long nCtrlH = m_aInfoText.GetSizePixel().Height();
     104                 :          0 :     long nDelta = ( nCtrlH - nTxtH );
     105         [ #  # ]:          0 :     Size aNewSize = m_aInfoText.GetSizePixel();
     106                 :          0 :     aNewSize.Height() -= nDelta;
     107         [ #  # ]:          0 :     m_aInfoText.SetSizePixel( aNewSize );
     108                 :            : 
     109                 :            :     // new position for the succeeding windows
     110                 :            :     Window* pWins[] =
     111                 :            :     {
     112                 :            :         &m_aLinkGraphicBtn, &m_aEmbedGraphicBtn, &m_aOptionLine, &m_aWarningOnBox
     113                 :          0 :     };
     114                 :          0 :     Window** pCurrent = pWins;
     115         [ #  # ]:          0 :     for ( sal_uInt32 i = 0; i < SAL_N_ELEMENTS(pWins); ++i, ++pCurrent )
     116                 :            :     {
     117         [ #  # ]:          0 :         Point aNewPos = (*pCurrent)->GetPosPixel();
     118                 :          0 :         aNewPos.Y() -= nDelta;
     119         [ #  # ]:          0 :         (*pCurrent)->SetPosPixel( aNewPos );
     120                 :            :     }
     121                 :            : 
     122                 :            :     // new size of the dialog
     123         [ #  # ]:          0 :     aNewSize = GetSizePixel();
     124                 :          0 :     aNewSize.Height() -= nDelta;
     125         [ #  # ]:          0 :     SetSizePixel( aNewSize );
     126                 :            : 
     127                 :            :     // recalculate the size and position of the buttons
     128 [ #  # ][ #  # ]:          0 :     nTxtW = m_aLinkGraphicBtn.GetCtrlTextWidth( m_aLinkGraphicBtn.GetText() );
                 [ #  # ]
     129 [ #  # ][ #  # ]:          0 :     long nTemp = m_aEmbedGraphicBtn.GetCtrlTextWidth( m_aEmbedGraphicBtn.GetText() );
                 [ #  # ]
     130         [ #  # ]:          0 :     if ( nTemp > nTxtW )
     131                 :          0 :         nTxtW = nTemp;
     132                 :          0 :     nTxtW += IMPL_EXTRA_BUTTON_WIDTH;
     133 [ #  # ][ #  # ]:          0 :     Size a3Size = LogicToPixel( Size( 3, 3 ), MAP_APPFONT );
                 [ #  # ]
     134         [ #  # ]:          0 :     Point aPos = m_aLinkGraphicBtn.GetPosPixel();
     135                 :          0 :     aPos.X() = ( aNewSize.Width() - (2*nTxtW) - a3Size.Width() ) / 2;
     136         [ #  # ]:          0 :     long nDefX = m_aWarningOnBox.GetPosPixel().X();
     137         [ #  # ]:          0 :     if ( nDefX < aPos.X() )
     138                 :          0 :         aPos.X() = nDefX;
     139         [ #  # ]:          0 :     aNewSize = m_aLinkGraphicBtn.GetSizePixel();
     140                 :          0 :     aNewSize.Width() = nTxtW;
     141         [ #  # ]:          0 :     m_aLinkGraphicBtn.SetPosSizePixel( aPos, aNewSize );
     142                 :          0 :     aPos.X() += nTxtW + a3Size.Width();
     143         [ #  # ]:          0 :     m_aEmbedGraphicBtn.SetPosSizePixel( aPos, aNewSize );
     144                 :          0 : }
     145                 :            : 
     146                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10