LCOV - code coverage report
Current view: top level - libreoffice/svx/source/dialog - linkwarn.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 70 0.0 %
Date: 2012-12-27 Functions: 0 4 0.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 "linkwarn.hrc"
      21             : #include "svx/linkwarn.hxx"
      22             : #include "svx/dialogs.hrc"
      23             : #include "svx/dialmgr.hxx"
      24             : #include <vcl/msgbox.hxx>
      25             : #include <sfx2/basedlgs.hxx>
      26             : #include <svtools/miscopt.hxx>
      27             : 
      28           0 : SvxLinkWarningDialog::SvxLinkWarningDialog( Window* pParent, const String& _rFileName ) :
      29           0 :     SfxModalDialog( pParent, SVX_RES( RID_SVXDLG_LINK_WARNING ) ),
      30           0 :     m_aQueryImage       ( this, SVX_RES( FI_QUERY ) ),
      31           0 :     m_aInfoText         ( this, SVX_RES( FT_INFOTEXT ) ),
      32           0 :     m_aLinkGraphicBtn   ( this, SVX_RES( PB_OK ) ),
      33           0 :     m_aEmbedGraphicBtn  ( this, SVX_RES( PB_NO ) ),
      34           0 :     m_aOptionLine       ( this, SVX_RES( FL_OPTION ) ),
      35           0 :     m_aWarningOnBox     ( this, SVX_RES( CB_WARNING_OFF ) )
      36             : {
      37           0 :     FreeResource();
      38             : 
      39             :     // set questionmark image
      40           0 :     m_aQueryImage.SetImage( QueryBox::GetStandardImage() );
      41             : 
      42             :     // replace filename
      43           0 :     String sInfoText = m_aInfoText.GetText();
      44           0 :     sInfoText.SearchAndReplaceAll(rtl::OUString("%FILENAME"), _rFileName);
      45           0 :     m_aInfoText.SetText( sInfoText );
      46             : 
      47             :     // load state of "warning on" checkbox from misc options
      48           0 :     SvtMiscOptions aMiscOpt;
      49           0 :     m_aWarningOnBox.Check( aMiscOpt.ShowLinkWarningDialog() == sal_True );
      50           0 :     if( aMiscOpt.IsShowLinkWarningDialogReadOnly() )
      51           0 :         m_aWarningOnBox.Disable();
      52             : 
      53             :     // set focus to Cancel button
      54           0 :     m_aEmbedGraphicBtn.GrabFocus();
      55             : 
      56             :     // calculate and set the size of the dialog and its controls
      57           0 :     InitSize();
      58           0 : }
      59             : 
      60             : // -----------------------------------------------------------------------
      61             : 
      62           0 : SvxLinkWarningDialog::~SvxLinkWarningDialog()
      63             : {
      64             :     // save value of "warning off" checkbox, if necessary
      65           0 :     SvtMiscOptions aMiscOpt;
      66           0 :     sal_Bool bChecked = m_aWarningOnBox.IsChecked();
      67           0 :     if ( aMiscOpt.ShowLinkWarningDialog() != bChecked )
      68           0 :         aMiscOpt.SetShowLinkWarningDialog( bChecked );
      69           0 : }
      70             : 
      71             : // -----------------------------------------------------------------------
      72             : 
      73           0 : void SvxLinkWarningDialog::InitSize()
      74             : {
      75             :     // text of checkbox to wide -> add new line
      76           0 :     long nTxtW = m_aWarningOnBox.GetCtrlTextWidth( m_aWarningOnBox.GetText() ) + IMPL_EXTRA_BUTTON_WIDTH;
      77           0 :     long nCtrlW = m_aWarningOnBox.GetSizePixel().Width();
      78           0 :     if ( nTxtW >= nCtrlW )
      79             :     {
      80           0 :         long nTextHeight = m_aWarningOnBox.GetTextHeight();
      81           0 :         Size aNewSize = m_aWarningOnBox.GetSizePixel();
      82           0 :         aNewSize.Height() += nTextHeight;
      83           0 :         m_aWarningOnBox.SetSizePixel( aNewSize );
      84           0 :         aNewSize = GetSizePixel();
      85           0 :         aNewSize.Height() += nTextHeight;
      86           0 :         SetSizePixel( aNewSize );
      87             :     }
      88             : 
      89             :     // align the size of the information text control (FixedText) to its content
      90           0 :     Size aMinSize = m_aInfoText.CalcMinimumSize( m_aInfoText.GetSizePixel().Width() );
      91           0 :     long nTxtH = aMinSize.Height();
      92           0 :     long nCtrlH = m_aInfoText.GetSizePixel().Height();
      93           0 :     long nDelta = ( nCtrlH - nTxtH );
      94           0 :     Size aNewSize = m_aInfoText.GetSizePixel();
      95           0 :     aNewSize.Height() -= nDelta;
      96           0 :     m_aInfoText.SetSizePixel( aNewSize );
      97             : 
      98             :     // new position for the succeeding windows
      99             :     Window* pWins[] =
     100             :     {
     101             :         &m_aLinkGraphicBtn, &m_aEmbedGraphicBtn, &m_aOptionLine, &m_aWarningOnBox
     102           0 :     };
     103           0 :     Window** pCurrent = pWins;
     104           0 :     for ( sal_uInt32 i = 0; i < SAL_N_ELEMENTS(pWins); ++i, ++pCurrent )
     105             :     {
     106           0 :         Point aNewPos = (*pCurrent)->GetPosPixel();
     107           0 :         aNewPos.Y() -= nDelta;
     108           0 :         (*pCurrent)->SetPosPixel( aNewPos );
     109             :     }
     110             : 
     111             :     // new size of the dialog
     112           0 :     aNewSize = GetSizePixel();
     113           0 :     aNewSize.Height() -= nDelta;
     114           0 :     SetSizePixel( aNewSize );
     115             : 
     116             :     // recalculate the size and position of the buttons
     117           0 :     nTxtW = m_aLinkGraphicBtn.GetCtrlTextWidth( m_aLinkGraphicBtn.GetText() );
     118           0 :     long nTemp = m_aEmbedGraphicBtn.GetCtrlTextWidth( m_aEmbedGraphicBtn.GetText() );
     119           0 :     if ( nTemp > nTxtW )
     120           0 :         nTxtW = nTemp;
     121           0 :     nTxtW += IMPL_EXTRA_BUTTON_WIDTH;
     122           0 :     Size a3Size = LogicToPixel( Size( 3, 3 ), MAP_APPFONT );
     123           0 :     Point aPos = m_aLinkGraphicBtn.GetPosPixel();
     124           0 :     aPos.X() = ( aNewSize.Width() - (2*nTxtW) - a3Size.Width() ) / 2;
     125           0 :     long nDefX = m_aWarningOnBox.GetPosPixel().X();
     126           0 :     if ( nDefX < aPos.X() )
     127           0 :         aPos.X() = nDefX;
     128           0 :     aNewSize = m_aLinkGraphicBtn.GetSizePixel();
     129           0 :     aNewSize.Width() = nTxtW;
     130           0 :     m_aLinkGraphicBtn.SetPosSizePixel( aPos, aNewSize );
     131           0 :     aPos.X() += nTxtW + a3Size.Width();
     132           0 :     m_aEmbedGraphicBtn.SetPosSizePixel( aPos, aNewSize );
     133           0 : }
     134             : 
     135             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10