summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorVladimir Glazunov <vg@openoffice.org>2010-03-29 10:53:28 +0200
committerVladimir Glazunov <vg@openoffice.org>2010-03-29 10:53:28 +0200
commit5af27f49f23578df5da2a0b24c08014cdaf0b675 (patch)
treedacad63b117f65907b5cf0d764683cf8a9238668 /desktop
parent5a706905ff3eb0c1dd3256f7aa39c6a37572b3e5 (diff)
#161436# Added throbber for migration page. Disable buttons to prevent user to cancel the process - transplanted from 219801e88d38@native0
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/migration/migration.cxx1
-rw-r--r--desktop/source/migration/pages.cxx63
-rw-r--r--desktop/source/migration/pages.hxx5
-rw-r--r--desktop/source/migration/wizard.cxx75
-rw-r--r--desktop/source/migration/wizard.hrc1
-rw-r--r--desktop/source/migration/wizard.hxx5
6 files changed, 138 insertions, 12 deletions
diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx
index d7043a5b1600..4d2cebdb4387 100644
--- a/desktop/source/migration/migration.cxx
+++ b/desktop/source/migration/migration.cxx
@@ -92,7 +92,6 @@ static void releaseImpl()
}
}
-
// static main entry point for the migration process
void Migration::doMigration()
{
diff --git a/desktop/source/migration/pages.cxx b/desktop/source/migration/pages.cxx
index 0aadc92827bb..11cc61ed84ff 100644
--- a/desktop/source/migration/pages.cxx
+++ b/desktop/source/migration/pages.cxx
@@ -55,6 +55,7 @@
#include <rtl/bootstrap.hxx>
#include <rtl/ustrbuf.hxx>
#include <osl/file.hxx>
+#include <osl/thread.hxx>
#include <unotools/bootstrap.hxx>
#include <tools/config.hxx>
@@ -62,6 +63,7 @@ using namespace rtl;
using namespace osl;
using namespace utl;
using namespace svt;
+using namespace com::sun::star;
using namespace com::sun::star::frame;
using namespace com::sun::star::lang;
using namespace com::sun::star::util;
@@ -305,12 +307,46 @@ void LicenseView::Notify( SfxBroadcaster&, const SfxHint& rHint )
// -------------------------------------------------------------------
-MigrationPage::MigrationPage( svt::OWizardMachine* parent, const ResId& resid)
+class MigrationThread : public ::osl::Thread
+{
+ public:
+ MigrationThread();
+
+ virtual void SAL_CALL run();
+ virtual void SAL_CALL onTerminated();
+};
+
+MigrationThread::MigrationThread()
+{
+}
+
+void MigrationThread::run()
+{
+ try
+ {
+ Migration::doMigration();
+ }
+ catch ( uno::Exception& )
+ {
+ }
+}
+
+void MigrationThread::onTerminated()
+{
+}
+
+// -------------------------------------------------------------------
+
+MigrationPage::MigrationPage(
+ svt::OWizardMachine* parent,
+ const ResId& resid,
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XThrobber > xThrobber)
: OWizardPage(parent, resid)
, m_ftHead(this, WizardResId(FT_MIGRATION_HEADER))
, m_ftBody(this, WizardResId(FT_MIGRATION_BODY))
, m_cbMigration(this, WizardResId(CB_MIGRATION))
, m_bMigrationDone(sal_False)
+ , m_xThrobber(xThrobber)
{
FreeResource();
_setBold(m_ftHead);
@@ -325,9 +361,28 @@ sal_Bool MigrationPage::commitPage( CommitPageReason _eReason )
{
if (_eReason == eTravelForward && m_cbMigration.IsChecked() && !m_bMigrationDone)
{
- EnterWait();
- Migration::doMigration();
- LeaveWait();
+ GetParent()->EnterWait();
+ FirstStartWizard* pWizard = dynamic_cast< FirstStartWizard* >( GetParent() );
+ if ( pWizard )
+ pWizard->DisableButtonsWhileMigration();
+
+ uno::Reference< awt::XWindow > xWin( m_xThrobber, uno::UNO_QUERY );
+ xWin->setVisible( true );
+ m_xThrobber->start();
+ MigrationThread* pMigThread = new MigrationThread();
+ pMigThread->create();
+
+ while ( pMigThread->isRunning() )
+ {
+ Application::Reschedule();
+ }
+
+ m_xThrobber->stop();
+ GetParent()->LeaveWait();
+ // Next state will enable buttons - so no EnableButtons necessary!
+ xWin->setVisible( false );
+ pMigThread->join();
+ delete pMigThread;
m_bMigrationDone = sal_True;
}
else
diff --git a/desktop/source/migration/pages.hxx b/desktop/source/migration/pages.hxx
index c1e8b2c62e42..9740773fe602 100644
--- a/desktop/source/migration/pages.hxx
+++ b/desktop/source/migration/pages.hxx
@@ -38,6 +38,8 @@
#include <svl/lstner.hxx>
#include <svtools/xtextedt.hxx>
+#include <com/sun/star/awt/XThrobber.hpp>
+
namespace desktop
{
class WelcomePage : public svt::OWizardPage
@@ -120,8 +122,9 @@ private:
FixedText m_ftBody;
CheckBox m_cbMigration;
sal_Bool m_bMigrationDone;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XThrobber > m_xThrobber;
public:
- MigrationPage( svt::OWizardMachine* parent, const ResId& resid);
+ MigrationPage( svt::OWizardMachine* parent, const ResId& resid, ::com::sun::star::uno::Reference< ::com::sun::star::awt::XThrobber > xThrobber );
virtual sal_Bool commitPage( CommitPageReason _eReason );
protected:
diff --git a/desktop/source/migration/wizard.cxx b/desktop/source/migration/wizard.cxx
index eeea969c6175..ac9d4e84f012 100644
--- a/desktop/source/migration/wizard.cxx
+++ b/desktop/source/migration/wizard.cxx
@@ -61,11 +61,14 @@
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/util/XChangesBatch.hpp>
#include <com/sun/star/container/XNameReplace.hpp>
+#include <com/sun/star/awt/WindowDescriptor.hpp>
+#include <com/sun/star/awt/WindowAttribute.hpp>
using namespace svt;
using namespace rtl;
using namespace osl;
using namespace utl;
+using namespace com::sun::star;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::beans;
@@ -77,13 +80,23 @@ using namespace com::sun::star::container;
namespace desktop
{
-const FirstStartWizard::WizardState FirstStartWizard::STATE_WELCOME = 0;
-const FirstStartWizard::WizardState FirstStartWizard::STATE_LICENSE = 1;
-const FirstStartWizard::WizardState FirstStartWizard::STATE_MIGRATION = 2;
-const FirstStartWizard::WizardState FirstStartWizard::STATE_USER = 3;
+const FirstStartWizard::WizardState FirstStartWizard::STATE_WELCOME = 0;
+const FirstStartWizard::WizardState FirstStartWizard::STATE_LICENSE = 1;
+const FirstStartWizard::WizardState FirstStartWizard::STATE_MIGRATION = 2;
+const FirstStartWizard::WizardState FirstStartWizard::STATE_USER = 3;
const FirstStartWizard::WizardState FirstStartWizard::STATE_UPDATE_CHECK = 4;
const FirstStartWizard::WizardState FirstStartWizard::STATE_REGISTRATION = 5;
+static uno::Reference< uno::XComponentContext > getComponentContext( const uno::Reference< lang::XMultiServiceFactory >& rFactory )
+{
+ uno::Reference< uno::XComponentContext > rContext;
+ uno::Reference< beans::XPropertySet > rPropSet( rFactory, uno::UNO_QUERY );
+ uno::Any a = rPropSet->getPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) );
+ a >>= rContext;
+ return rContext;
+}
+
WizardResId::WizardResId( USHORT nId ) :
ResId( nId, *FirstStartWizard::GetResManager() )
{
@@ -118,7 +131,47 @@ FirstStartWizard::FirstStartWizard( Window* pParent, sal_Bool bLicenseNeedsAccep
// enableState(STATE_USER, sal_False);
// enableState(STATE_REGISTRATION, sal_False);
- ShowButtonFixedLine(sal_True);
+ try
+ {
+ Point pos(5, 210 );
+ Size size(11, 11 );
+
+ pos = LogicToPixel( pos, MAP_APPFONT );
+ size = LogicToPixel( size, MAP_APPFONT );
+
+ uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
+ uno::Reference< awt::XToolkit > xToolkit(
+ uno::Reference< lang::XMultiComponentFactory >(
+ xFactory, uno::UNO_QUERY_THROW)->
+ createInstanceWithContext(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.Toolkit")),
+ getComponentContext(xFactory)),
+ uno::UNO_QUERY_THROW);
+
+ m_xThrobber = uno::Reference< awt::XThrobber >(
+ xToolkit->createWindow(
+ awt::WindowDescriptor(
+ awt::WindowClass_SIMPLE,
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Throbber")),
+ GetComponentInterface(), 0,
+ awt::Rectangle(
+ pos.X(), pos.Y(), size.Width(), size.Height()),
+ awt::WindowAttribute::SHOW)),
+ uno::UNO_QUERY_THROW);
+ }
+ catch (uno::RuntimeException &)
+ {
+ throw;
+ }
+ catch (Exception& )
+ {
+ }
+
+ uno::Reference< awt::XWindow > xThrobberWin( m_xThrobber, uno::UNO_QUERY );
+ if ( xThrobberWin.is() )
+ xThrobberWin->setVisible( false );
+
Size aTPSize(TP_WIDTH, TP_HEIGHT);
SetPageSizePixel(LogicToPixel(aTPSize, MAP_APPFONT));
@@ -151,6 +204,16 @@ FirstStartWizard::FirstStartWizard( Window* pParent, sal_Bool bLicenseNeedsAccep
defaultButton(WZB_NEXT);
}
+void FirstStartWizard::EnableButtonsWhileMigration()
+{
+ enableButtons(0xff, sal_True);
+}
+
+void FirstStartWizard::DisableButtonsWhileMigration()
+{
+ enableButtons(0xff, sal_False);
+}
+
::svt::RoadmapWizardTypes::PathId FirstStartWizard::defineWizardPagesDependingFromContext()
{
::svt::RoadmapWizardTypes::PathId aDefaultPath = 0;
@@ -280,7 +343,7 @@ TabPage* FirstStartWizard::createPage(WizardState _nState)
pTabPage = new LicensePage(this, WizardResId(TP_LICENSE), m_aLicensePath);
break;
case STATE_MIGRATION:
- pTabPage = new MigrationPage(this, WizardResId(TP_MIGRATION));
+ pTabPage = new MigrationPage(this, WizardResId(TP_MIGRATION), m_xThrobber );
break;
case STATE_USER:
pTabPage = new UserPage(this, WizardResId(TP_USER));
diff --git a/desktop/source/migration/wizard.hrc b/desktop/source/migration/wizard.hrc
index 56bc61184fda..fdad97a8174b 100644
--- a/desktop/source/migration/wizard.hrc
+++ b/desktop/source/migration/wizard.hrc
@@ -78,6 +78,7 @@
#define ED_USER_LAST 17
#define ED_USER_FATHER 18
#define ED_USER_INITIALS 19
+#define TR_WAITING 20
// global strings
#define STR_STATE_WELCOME RID_FIRSTSTSTART_START+100
diff --git a/desktop/source/migration/wizard.hxx b/desktop/source/migration/wizard.hxx
index b84b461937e7..792ce5cea02b 100644
--- a/desktop/source/migration/wizard.hxx
+++ b/desktop/source/migration/wizard.hxx
@@ -32,6 +32,7 @@
#include <svtools/roadmapwizard.hxx>
#include <vcl/window.hxx>
#include <tools/resid.hxx>
+#include <com/sun/star/awt/XThrobber.hpp>
namespace desktop
{
@@ -61,6 +62,9 @@ public:
virtual short Execute();
virtual long PreNotify( NotifyEvent& rNEvt );
+ void EnableButtonsWhileMigration();
+ void DisableButtonsWhileMigration();
+
private:
sal_Bool m_bOverride;
WizardState _currentState;
@@ -73,6 +77,7 @@ private:
sal_Bool m_bLicenseWasAccepted;
sal_Bool m_bAutomaticUpdChk;
Link m_lnkCancel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XThrobber > m_xThrobber;
rtl::OUString m_aLicensePath;