2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2005-02-02 15:47:06 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 11:30:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2005-02-02 15:47:06 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2005-02-02 15:47:06 +00:00
|
|
|
*
|
2008-04-11 11:30:00 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2005-02-02 15:47:06 +00:00
|
|
|
*
|
2008-04-11 11:30:00 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2005-02-02 15:47:06 +00:00
|
|
|
*
|
2008-04-11 11:30:00 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2005-02-02 15:47:06 +00:00
|
|
|
*
|
2008-04-11 11:30:00 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2005-02-02 15:47:06 +00:00
|
|
|
*
|
2008-04-11 11:30:00 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2005-02-02 15:47:06 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 15:30:32 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sfx2.hxx"
|
|
|
|
|
2005-02-02 15:47:06 +00:00
|
|
|
#include "alienwarn.hxx"
|
|
|
|
#include "sfxresid.hxx"
|
2007-06-27 22:09:13 +00:00
|
|
|
#include <sfx2/sfxuno.hxx>
|
2005-02-02 15:47:06 +00:00
|
|
|
|
|
|
|
#include "alienwarn.hrc"
|
|
|
|
#include "dialog.hrc"
|
|
|
|
#include <vcl/msgbox.hxx>
|
2009-10-06 07:38:24 +02:00
|
|
|
#include <unotools/saveopt.hxx>
|
2005-02-02 15:47:06 +00:00
|
|
|
|
|
|
|
// class SfxAlienWarningDialog -------------------------------------------
|
|
|
|
|
|
|
|
SfxAlienWarningDialog::SfxAlienWarningDialog( Window* pParent, const String& _rFormatName ) :
|
|
|
|
|
|
|
|
SfxModalDialog( pParent, SfxResId( RID_DLG_ALIEN_WARNING ) ),
|
|
|
|
|
2008-03-12 10:33:58 +00:00
|
|
|
m_aKeepCurrentBtn ( this, SfxResId( PB_NO ) ),
|
|
|
|
m_aSaveODFBtn ( this, SfxResId( PB_YES ) ),
|
|
|
|
m_aMoreInfoBtn ( this, SfxResId( PB_MOREINFO ) ),
|
|
|
|
m_aOptionLine ( this, SfxResId( FL_OPTION ) ),
|
2008-07-22 06:44:16 +00:00
|
|
|
m_aWarningOnBox ( this, SfxResId( CB_WARNING_OFF ) ),
|
|
|
|
m_aQueryImage ( this, SfxResId( FI_QUERY ) ),
|
|
|
|
m_aInfoText ( this, SfxResId( FT_INFOTEXT ) )
|
2005-02-02 15:47:06 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
FreeResource();
|
|
|
|
|
|
|
|
// set questionmark image
|
|
|
|
m_aQueryImage.SetImage( QueryBox::GetStandardImage() );
|
|
|
|
|
|
|
|
// replace formatname
|
|
|
|
String sInfoText = m_aInfoText.GetText();
|
2005-04-04 14:30:41 +00:00
|
|
|
sInfoText.SearchAndReplaceAll( DEFINE_CONST_UNICODE("%FORMATNAME"), _rFormatName );
|
2005-02-02 15:47:06 +00:00
|
|
|
m_aInfoText.SetText( sInfoText );
|
|
|
|
|
2008-03-12 10:33:58 +00:00
|
|
|
// load value of "warning on" checkbox from save options
|
|
|
|
m_aWarningOnBox.Check( SvtSaveOptions().IsWarnAlienFormat() == sal_True );
|
2005-07-12 13:26:29 +00:00
|
|
|
|
2008-03-12 10:33:58 +00:00
|
|
|
// set focus to "Keep Current Format" button
|
|
|
|
m_aKeepCurrentBtn.GrabFocus();
|
2005-07-12 13:26:29 +00:00
|
|
|
|
|
|
|
// pb: #i43989# we have no online help for this dialog at the moment
|
|
|
|
// -> hide the "more info" button
|
2008-03-12 10:33:58 +00:00
|
|
|
//m_aMoreInfoBtn.Hide();
|
2005-07-12 13:26:29 +00:00
|
|
|
|
|
|
|
// calculate and set the size of the dialog and its controls
|
|
|
|
InitSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
SfxAlienWarningDialog::~SfxAlienWarningDialog()
|
|
|
|
{
|
|
|
|
// save value of "warning off" checkbox, if necessary
|
|
|
|
SvtSaveOptions aSaveOpt;
|
2008-03-12 10:33:58 +00:00
|
|
|
sal_Bool bChecked = m_aWarningOnBox.IsChecked();
|
2005-07-12 13:26:29 +00:00
|
|
|
if ( aSaveOpt.IsWarnAlienFormat() != bChecked )
|
|
|
|
aSaveOpt.SetWarnAlienFormat( bChecked );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SfxAlienWarningDialog::InitSize()
|
|
|
|
{
|
2005-02-02 15:47:06 +00:00
|
|
|
// if the button text is too wide, then broaden the button
|
2008-03-12 10:33:58 +00:00
|
|
|
long nTxtW = m_aMoreInfoBtn.GetCtrlTextWidth( m_aMoreInfoBtn.GetText() );
|
2005-02-02 15:47:06 +00:00
|
|
|
long nCtrlW = m_aMoreInfoBtn.GetSizePixel().Width();
|
|
|
|
if ( nTxtW >= nCtrlW )
|
|
|
|
{
|
|
|
|
long nDelta = nTxtW - nCtrlW;
|
2008-03-12 10:33:58 +00:00
|
|
|
nDelta += IMPL_EXTRA_BUTTON_WIDTH;
|
|
|
|
Point aNextPoint = m_aKeepCurrentBtn.GetPosPixel();
|
|
|
|
aNextPoint.X() += m_aKeepCurrentBtn.GetSizePixel().Width();
|
2005-02-02 15:47:06 +00:00
|
|
|
Point aNewPoint = m_aMoreInfoBtn.GetPosPixel();
|
|
|
|
aNewPoint.X() -= nDelta;
|
|
|
|
if ( aNextPoint.X() >= aNewPoint.X() )
|
|
|
|
{
|
|
|
|
long nSpace = aNextPoint.X() - aNewPoint.X();
|
|
|
|
nSpace += 2;
|
|
|
|
nDelta -= nSpace;
|
|
|
|
aNewPoint.X() += nSpace;
|
|
|
|
}
|
|
|
|
Size aNewSize = m_aMoreInfoBtn.GetSizePixel();
|
|
|
|
aNewSize.Width() += nDelta;
|
|
|
|
m_aMoreInfoBtn.SetPosSizePixel( aNewPoint, aNewSize );
|
|
|
|
}
|
|
|
|
|
|
|
|
// text of checkbox to wide -> add new line
|
2008-03-12 10:33:58 +00:00
|
|
|
nTxtW = m_aWarningOnBox.GetCtrlTextWidth( m_aWarningOnBox.GetText() ) + IMPL_EXTRA_BUTTON_WIDTH;
|
|
|
|
nCtrlW = m_aWarningOnBox.GetSizePixel().Width();
|
2005-02-02 15:47:06 +00:00
|
|
|
if ( nTxtW >= nCtrlW )
|
|
|
|
{
|
2008-03-12 10:33:58 +00:00
|
|
|
long nTextHeight = m_aWarningOnBox.GetTextHeight();
|
|
|
|
Size aNewSize = m_aWarningOnBox.GetSizePixel();
|
2005-02-02 15:47:06 +00:00
|
|
|
aNewSize.Height() += nTextHeight;
|
2008-03-12 10:33:58 +00:00
|
|
|
m_aWarningOnBox.SetSizePixel( aNewSize );
|
2005-02-02 15:47:06 +00:00
|
|
|
aNewSize = GetSizePixel();
|
|
|
|
aNewSize.Height() += nTextHeight;
|
|
|
|
SetSizePixel( aNewSize );
|
|
|
|
}
|
|
|
|
|
2005-07-12 13:26:29 +00:00
|
|
|
// align the size of the information text control (FixedText) to its content
|
|
|
|
Size aMinSize = m_aInfoText.CalcMinimumSize( m_aInfoText.GetSizePixel().Width() );
|
|
|
|
long nTxtH = aMinSize.Height();
|
|
|
|
long nCtrlH = m_aInfoText.GetSizePixel().Height();
|
|
|
|
long nDelta = ( nCtrlH - nTxtH );
|
|
|
|
Size aNewSize = m_aInfoText.GetSizePixel();
|
|
|
|
aNewSize.Height() -= nDelta;
|
|
|
|
m_aInfoText.SetSizePixel( aNewSize );
|
|
|
|
|
|
|
|
// new position for the succeeding windows
|
|
|
|
Window* pWins[] =
|
|
|
|
{
|
2008-03-12 10:33:58 +00:00
|
|
|
&m_aSaveODFBtn, &m_aKeepCurrentBtn, &m_aMoreInfoBtn, &m_aOptionLine, &m_aWarningOnBox
|
2005-07-12 13:26:29 +00:00
|
|
|
};
|
|
|
|
Window** pCurrent = pWins;
|
2010-10-14 21:14:52 +01:00
|
|
|
for ( sal_uInt32 i = 0; i < SAL_N_ELEMENTS( pWins ); ++i, ++pCurrent )
|
2005-07-12 13:26:29 +00:00
|
|
|
{
|
|
|
|
Point aNewPos = (*pCurrent)->GetPosPixel();
|
|
|
|
aNewPos.Y() -= nDelta;
|
|
|
|
(*pCurrent)->SetPosPixel( aNewPos );
|
|
|
|
}
|
2005-02-02 15:47:06 +00:00
|
|
|
|
2005-07-12 13:26:29 +00:00
|
|
|
// new size of the dialog
|
|
|
|
aNewSize = GetSizePixel();
|
|
|
|
aNewSize.Height() -= nDelta;
|
|
|
|
SetSizePixel( aNewSize );
|
2008-03-12 10:33:58 +00:00
|
|
|
|
|
|
|
// recalculate the size and position of the buttons
|
|
|
|
m_aMoreInfoBtn.Hide();
|
|
|
|
nTxtW = m_aKeepCurrentBtn.GetCtrlTextWidth( m_aKeepCurrentBtn.GetText() );
|
|
|
|
long nTemp = m_aSaveODFBtn.GetCtrlTextWidth( m_aSaveODFBtn.GetText() );
|
|
|
|
if ( nTemp > nTxtW )
|
|
|
|
nTxtW = nTemp;
|
|
|
|
nTxtW += IMPL_EXTRA_BUTTON_WIDTH;
|
|
|
|
Size a3Size = LogicToPixel( Size( 3, 3 ), MAP_APPFONT );
|
|
|
|
Point aPos = m_aKeepCurrentBtn.GetPosPixel();
|
|
|
|
aPos.X() = ( aNewSize.Width() - (2*nTxtW) - a3Size.Width() ) / 2;
|
|
|
|
long nDefX = m_aWarningOnBox.GetPosPixel().X();
|
|
|
|
if ( nDefX < aPos.X() )
|
|
|
|
aPos.X() = nDefX;
|
|
|
|
aNewSize = m_aKeepCurrentBtn.GetSizePixel();
|
|
|
|
aNewSize.Width() = nTxtW;
|
|
|
|
m_aKeepCurrentBtn.SetPosSizePixel( aPos, aNewSize );
|
|
|
|
aPos.X() += nTxtW + a3Size.Width();
|
|
|
|
m_aSaveODFBtn.SetPosSizePixel( aPos, aNewSize );
|
2005-02-02 15:47:06 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|