2011-04-04 18:02:18 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2011-01-12 11:56:09 +01:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
|
|
|
*
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
|
|
*
|
|
|
|
* This file is part of OpenOffice.org.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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).
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
// include ---------------------------------------------------------------
|
|
|
|
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#include <vcl/msgbox.hxx>
|
2011-04-04 18:02:18 +01:00
|
|
|
|
2011-01-12 11:56:09 +01:00
|
|
|
#include <tools/stream.hxx>
|
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
#include <rtl/bootstrap.hxx>
|
|
|
|
#include <unotools/configmgr.hxx>
|
|
|
|
#include <unotools/bootstrap.hxx>
|
|
|
|
#include <com/sun/star/uno/Any.h>
|
2011-04-04 18:02:18 +01:00
|
|
|
#include <unotools/configmgr.hxx>
|
|
|
|
#include <vcl/svapp.hxx>
|
2011-01-12 11:56:09 +01:00
|
|
|
#include <vcl/graph.hxx>
|
|
|
|
#include <svtools/filter.hxx>
|
2011-04-04 18:02:18 +01:00
|
|
|
|
|
|
|
#include "com/sun/star/system/SystemShellExecuteFlags.hpp"
|
|
|
|
#include "com/sun/star/system/XSystemShellExecute.hpp"
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#include "comphelper/anytostring.hxx"
|
|
|
|
#include "cppuhelper/exc_hlp.hxx"
|
|
|
|
#include "cppuhelper/bootstrap.hxx"
|
|
|
|
|
2011-01-12 11:56:09 +01:00
|
|
|
#include <sfx2/sfxuno.hxx>
|
2011-04-04 18:02:18 +01:00
|
|
|
#include <sfx2/sfxcommands.h>
|
2011-01-12 11:56:09 +01:00
|
|
|
#include "about.hxx"
|
2011-04-04 18:02:18 +01:00
|
|
|
#include "about.hrc"
|
2011-01-12 11:56:09 +01:00
|
|
|
#include <sfx2/sfxdefs.hxx>
|
|
|
|
#include <sfx2/app.hxx>
|
2011-04-04 18:02:18 +01:00
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
2011-01-12 11:56:09 +01:00
|
|
|
|
|
|
|
// defines ---------------------------------------------------------------
|
|
|
|
|
|
|
|
#define SCROLL_OFFSET 1
|
|
|
|
#define SPACE_OFFSET 5
|
|
|
|
#define SCROLL_TIMER 30
|
|
|
|
|
2011-04-04 18:02:18 +01:00
|
|
|
/** loads the application logo as used in the about dialog and impress slideshow pause screen */
|
|
|
|
Image SfxApplication::GetApplicationLogo()
|
2011-01-12 11:56:09 +01:00
|
|
|
{
|
2011-04-04 18:02:18 +01:00
|
|
|
BitmapEx aBitmap;
|
|
|
|
Application::LoadBrandBitmap ("about", aBitmap);
|
|
|
|
return Image( aBitmap );
|
2011-01-12 11:56:09 +01:00
|
|
|
}
|
|
|
|
|
2011-06-28 13:00:51 +01:00
|
|
|
/* get good version information */
|
2011-04-04 18:02:18 +01:00
|
|
|
static String
|
2011-04-04 18:06:02 +01:00
|
|
|
GetBuildId()
|
2011-01-12 11:56:09 +01:00
|
|
|
{
|
2011-04-04 18:06:02 +01:00
|
|
|
rtl::OUString sDefault;
|
2011-06-28 13:00:51 +01:00
|
|
|
rtl::OUString sBuildId( utl::Bootstrap::getBuildIdData( sDefault ) );
|
2011-06-30 08:52:39 +01:00
|
|
|
if (!sBuildId.isEmpty() && sBuildId.getLength() > 50)
|
2011-06-28 13:00:51 +01:00
|
|
|
{
|
|
|
|
rtl::OUStringBuffer aBuffer;
|
2011-06-30 08:52:39 +01:00
|
|
|
aBuffer.appendAscii(RTL_CONSTASCII_STRINGPARAM("\n\t"));
|
2011-06-28 13:00:51 +01:00
|
|
|
sal_Int32 nIndex = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
rtl::OUString aToken = sBuildId.getToken( 0, '-', nIndex );
|
|
|
|
if (!aToken.isEmpty())
|
|
|
|
{
|
|
|
|
aBuffer.append(aToken);
|
2011-06-28 13:26:48 +01:00
|
|
|
if (nIndex >= 0)
|
|
|
|
{
|
|
|
|
if (nIndex % 5)
|
|
|
|
aBuffer.append(static_cast<sal_Unicode>('-'));
|
|
|
|
else
|
2011-06-30 08:52:39 +01:00
|
|
|
aBuffer.appendAscii(RTL_CONSTASCII_STRINGPARAM("\n\t"));
|
2011-06-28 13:26:48 +01:00
|
|
|
}
|
2011-06-28 13:00:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
while ( nIndex >= 0 );
|
|
|
|
sBuildId = aBuffer.makeStringAndClear();
|
|
|
|
}
|
|
|
|
|
|
|
|
OSL_ENSURE( sBuildId.getLength() > 0, "No BUILDID in bootstrap file" );
|
2011-04-04 18:06:02 +01:00
|
|
|
return sBuildId;
|
2011-01-12 11:56:09 +01:00
|
|
|
}
|
|
|
|
|
2011-04-04 18:02:18 +01:00
|
|
|
AboutDialog::AboutDialog( Window* pParent, const ResId& rId) :
|
2011-01-12 11:56:09 +01:00
|
|
|
|
|
|
|
SfxModalDialog ( pParent, rId ),
|
|
|
|
|
|
|
|
aOKButton ( this, ResId( ABOUT_BTN_OK, *rId.GetResMgr() ) ),
|
|
|
|
aVersionText ( this, ResId( ABOUT_FTXT_VERSION, *rId.GetResMgr() ) ),
|
|
|
|
aCopyrightText ( this, ResId( ABOUT_FTXT_COPYRIGHT, *rId.GetResMgr() ) ),
|
2011-04-04 18:02:18 +01:00
|
|
|
aInfoLink ( this, ResId( ABOUT_FTXT_LINK, *rId.GetResMgr() ) ),
|
|
|
|
aVersionTextStr( ResId( ABOUT_STR_VERSION, *rId.GetResMgr() ) ),
|
|
|
|
aCopyrightTextStr( ResId( ABOUT_STR_COPYRIGHT, *rId.GetResMgr() ) ),
|
2011-06-28 13:00:24 +01:00
|
|
|
aLinkStr ( ResId( ABOUT_STR_LINK, *rId.GetResMgr() ) ),
|
|
|
|
m_sBuildStr(ResId(ABOUT_STR_BUILD, *rId.GetResMgr()))
|
2011-01-12 11:56:09 +01:00
|
|
|
{
|
|
|
|
rtl::OUString sProduct;
|
|
|
|
utl::ConfigManager::GetDirectConfigProperty(utl::ConfigManager::PRODUCTNAME) >>= sProduct;
|
|
|
|
|
|
|
|
// load image from module path
|
|
|
|
aAppLogo = SfxApplication::GetApplicationLogo();
|
|
|
|
|
2011-04-04 18:02:18 +01:00
|
|
|
// Transparent Font
|
2011-01-12 11:56:09 +01:00
|
|
|
Font aFont = GetFont();
|
2011-02-08 11:49:29 +01:00
|
|
|
aFont.SetTransparent( sal_True );
|
2011-01-12 11:56:09 +01:00
|
|
|
SetFont( aFont );
|
|
|
|
|
|
|
|
// if necessary more info
|
2011-04-04 18:02:18 +01:00
|
|
|
String sVersion = aVersionTextStr;
|
2011-01-12 11:56:09 +01:00
|
|
|
sVersion.SearchAndReplaceAscii( "$(VER)", Application::GetDisplayName() );
|
|
|
|
sVersion += '\n';
|
2011-06-28 13:00:24 +01:00
|
|
|
sVersion += m_sBuildStr;
|
|
|
|
sVersion += ' ';
|
2011-04-04 18:06:02 +01:00
|
|
|
sVersion += GetBuildId();
|
2011-04-04 18:02:18 +01:00
|
|
|
#ifdef BUILD_VER_STRING
|
|
|
|
String aBuildString( DEFINE_CONST_UNICODE( BUILD_VER_STRING ) );
|
|
|
|
sVersion += '\n';
|
|
|
|
sVersion += aBuildString;
|
|
|
|
#endif
|
2011-01-12 11:56:09 +01:00
|
|
|
aVersionText.SetText( sVersion );
|
|
|
|
|
|
|
|
// set for background and text the correct system color
|
|
|
|
const StyleSettings& rSettings = GetSettings().GetStyleSettings();
|
|
|
|
Color aWhiteCol( rSettings.GetWindowColor() );
|
|
|
|
Wallpaper aWall( aWhiteCol );
|
|
|
|
SetBackground( aWall );
|
|
|
|
Font aNewFont( aCopyrightText.GetFont() );
|
2011-02-08 11:49:29 +01:00
|
|
|
aNewFont.SetTransparent( sal_True );
|
2011-01-12 11:56:09 +01:00
|
|
|
|
|
|
|
aVersionText.SetFont( aNewFont );
|
|
|
|
aCopyrightText.SetFont( aNewFont );
|
|
|
|
|
|
|
|
aVersionText.SetBackground();
|
|
|
|
aCopyrightText.SetBackground();
|
2011-04-04 18:02:18 +01:00
|
|
|
aInfoLink.SetURL( aLinkStr );
|
|
|
|
aInfoLink.SetBackground();
|
|
|
|
aInfoLink.SetClickHdl( LINK( this, AboutDialog, HandleHyperlink ) );
|
2011-01-12 11:56:09 +01:00
|
|
|
|
|
|
|
Color aTextColor( rSettings.GetWindowTextColor() );
|
|
|
|
aVersionText.SetControlForeground( aTextColor );
|
|
|
|
aCopyrightText.SetControlForeground( aTextColor );
|
2011-04-04 18:02:18 +01:00
|
|
|
|
|
|
|
aCopyrightText.SetText( aCopyrightTextStr );
|
2011-01-12 11:56:09 +01:00
|
|
|
|
|
|
|
// determine size and position of the dialog & elements
|
|
|
|
Size aAppLogoSiz = aAppLogo.GetSizePixel();
|
2011-04-04 18:02:18 +01:00
|
|
|
|
|
|
|
// analyze size of the aVersionText widget
|
|
|
|
// character size
|
2011-01-12 11:56:09 +01:00
|
|
|
Size a6Size = aVersionText.LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
|
2011-04-04 18:02:18 +01:00
|
|
|
// preferred Version widget size
|
2011-01-12 11:56:09 +01:00
|
|
|
long nY = aAppLogoSiz.Height() + ( a6Size.Height() * 2 );
|
2011-06-30 08:52:39 +01:00
|
|
|
long nDlgMargin = a6Size.Width() * 2;
|
2011-06-28 11:57:55 +01:00
|
|
|
long nCtrlMargin = a6Size.Height() * 2;
|
2011-06-30 08:52:39 +01:00
|
|
|
|
|
|
|
aVersionText.SetSizePixel(Size(800,600));
|
|
|
|
Size aVersionTextSize = aVersionText.CalcMinimumSize();
|
|
|
|
aVersionTextSize.Width() += nDlgMargin;
|
|
|
|
|
|
|
|
Size aOutSiz = GetOutputSizePixel();
|
|
|
|
aOutSiz.Width() = aAppLogoSiz.Width();
|
|
|
|
|
|
|
|
if (aOutSiz.Width() < aVersionTextSize.Width())
|
|
|
|
aOutSiz.Width() = aVersionTextSize.Width();
|
|
|
|
|
|
|
|
if (aOutSiz.Width() < 300)
|
|
|
|
aOutSiz.Width() = 300;
|
|
|
|
|
2011-01-12 11:56:09 +01:00
|
|
|
long nTextWidth = aOutSiz.Width() - nDlgMargin;
|
|
|
|
|
2011-04-04 18:02:18 +01:00
|
|
|
// finally set the aVersionText widget position and size
|
2011-06-28 13:00:24 +01:00
|
|
|
Size aVTSize = aVersionText.GetSizePixel();
|
|
|
|
aVTSize.Width() = nTextWidth;
|
|
|
|
aVersionText.SetSizePixel(aVTSize);
|
|
|
|
aVTSize = aVersionText.CalcMinimumSize();
|
|
|
|
Point aVTPnt;
|
|
|
|
aVTPnt.X() = ( aOutSiz.Width() - aVTSize.Width() ) / 2;
|
|
|
|
aVTPnt.Y() = nY;
|
|
|
|
aVersionText.SetPosSizePixel( aVTPnt, aVTSize );
|
2011-01-12 11:56:09 +01:00
|
|
|
|
2011-06-28 13:00:24 +01:00
|
|
|
nY += aVTSize.Height() + nCtrlMargin;
|
2011-01-12 11:56:09 +01:00
|
|
|
|
|
|
|
// Multiline edit with Copyright-Text
|
2011-06-28 11:57:55 +01:00
|
|
|
// preferred Version widget size
|
2011-06-30 11:30:44 +01:00
|
|
|
aCopyrightText.SetSizePixel(Size(nTextWidth,600));
|
|
|
|
Size aCTSize = aCopyrightText.CalcMinimumSize();
|
|
|
|
aCTSize.Width()= nTextWidth;
|
2011-06-28 13:00:24 +01:00
|
|
|
Point aCTPnt;
|
|
|
|
aCTPnt.X() = ( aOutSiz.Width() - aCTSize.Width() ) / 2;
|
|
|
|
aCTPnt.Y() = nY;
|
|
|
|
aCopyrightText.SetPosSizePixel( aCTPnt, aCTSize );
|
2011-01-12 11:56:09 +01:00
|
|
|
|
2011-06-28 13:00:24 +01:00
|
|
|
nY += aCTSize.Height() + nCtrlMargin;
|
2011-04-04 18:02:18 +01:00
|
|
|
|
2011-06-28 11:57:55 +01:00
|
|
|
// FixedHyperlink with more info link
|
2011-06-28 13:00:24 +01:00
|
|
|
Size aLTSize = aInfoLink.CalcMinimumSize();
|
|
|
|
Point aLTPnt;
|
|
|
|
aLTPnt.X() = ( aOutSiz.Width() - aLTSize.Width() ) / 2;
|
|
|
|
aLTPnt.Y() = nY;
|
|
|
|
aInfoLink.SetPosSizePixel( aLTPnt, aLTSize );
|
2011-04-04 18:02:18 +01:00
|
|
|
|
2011-06-28 13:00:24 +01:00
|
|
|
nY += aLTSize.Height() + nCtrlMargin;
|
2011-04-04 18:02:18 +01:00
|
|
|
|
2011-06-28 11:57:55 +01:00
|
|
|
// OK-Button-Position (at the bottom and centered)
|
|
|
|
Size aOKSiz = aOKButton.GetSizePixel();
|
|
|
|
Point aOKPnt;
|
2011-01-12 11:56:09 +01:00
|
|
|
aOKPnt.X() = ( aOutSiz.Width() - aOKSiz.Width() ) / 2;
|
|
|
|
aOKPnt.Y() = nY;
|
|
|
|
aOKButton.SetPosPixel( aOKPnt );
|
|
|
|
|
2011-06-28 11:57:55 +01:00
|
|
|
nY += aOKSiz.Height() + nCtrlMargin;
|
|
|
|
|
|
|
|
aOutSiz.Height() = nY;
|
|
|
|
|
|
|
|
// Change the size of the dialog
|
2011-01-12 11:56:09 +01:00
|
|
|
SetOutputSizePixel( aOutSiz );
|
|
|
|
|
|
|
|
FreeResource();
|
|
|
|
|
2011-04-04 18:02:18 +01:00
|
|
|
// explicit Help-Id
|
2011-01-12 11:56:09 +01:00
|
|
|
SetHelpId( CMD_SID_ABOUT );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2011-04-04 18:02:18 +01:00
|
|
|
IMPL_LINK( AboutDialog, HandleHyperlink, svt::FixedHyperlink*, pHyperlink )
|
2011-01-12 11:56:09 +01:00
|
|
|
{
|
2011-04-04 18:02:18 +01:00
|
|
|
rtl::OUString sURL=pHyperlink->GetURL();
|
|
|
|
rtl::OUString sTitle=GetText();
|
2011-01-12 11:56:09 +01:00
|
|
|
|
2011-04-04 18:02:18 +01:00
|
|
|
if ( ! sURL.getLength() ) // Nothing to do, when the URL is empty
|
|
|
|
return 1;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference< com::sun::star::system::XSystemShellExecute > xSystemShellExecute(
|
|
|
|
::comphelper::getProcessServiceFactory()->createInstance(
|
|
|
|
DEFINE_CONST_UNICODE("com.sun.star.system.SystemShellExecute") ), uno::UNO_QUERY_THROW );
|
|
|
|
xSystemShellExecute->execute( sURL, rtl::OUString(), com::sun::star::system::SystemShellExecuteFlags::DEFAULTS );
|
|
|
|
}
|
|
|
|
catch ( uno::Exception& )
|
|
|
|
{
|
|
|
|
uno::Any exc( ::cppu::getCaughtException() );
|
|
|
|
rtl::OUString msg( ::comphelper::anyToString( exc ) );
|
|
|
|
const SolarMutexGuard guard;
|
|
|
|
ErrorBox aErrorBox( NULL, WB_OK, msg );
|
|
|
|
aErrorBox.SetText( sTitle );
|
|
|
|
aErrorBox.Execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2011-01-12 11:56:09 +01:00
|
|
|
|
|
|
|
void AboutDialog::Paint( const Rectangle& rRect )
|
|
|
|
{
|
|
|
|
SetClipRegion( rRect );
|
2011-06-28 11:57:55 +01:00
|
|
|
Point aPos( 0, 0 );
|
2011-04-04 18:02:18 +01:00
|
|
|
DrawImage( aPos, aAppLogo );
|
|
|
|
}
|
2011-01-12 11:56:09 +01:00
|
|
|
|
2011-04-04 18:02:18 +01:00
|
|
|
sal_Bool AboutDialog::Close()
|
|
|
|
{
|
|
|
|
EndDialog( RET_OK );
|
|
|
|
return sal_False;
|
2011-01-12 11:56:09 +01:00
|
|
|
}
|
2011-04-04 18:02:18 +01:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|