1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_desktop.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "pages.hxx" 32*cdf0e10cSrcweir #include "wizard.hrc" 33*cdf0e10cSrcweir #include "wizard.hxx" 34*cdf0e10cSrcweir #include "migration.hxx" 35*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 36*cdf0e10cSrcweir #include <vcl/mnemonic.hxx> 37*cdf0e10cSrcweir #include <vos/security.hxx> 38*cdf0e10cSrcweir #include <app.hxx> 39*cdf0e10cSrcweir #include <rtl/ustring.hxx> 40*cdf0e10cSrcweir #include <osl/file.hxx> 41*cdf0e10cSrcweir #include <unotools/bootstrap.hxx> 42*cdf0e10cSrcweir #include <unotools/configmgr.hxx> 43*cdf0e10cSrcweir #include <unotools/regoptions.hxx> 44*cdf0e10cSrcweir #include <unotools/useroptions.hxx> 45*cdf0e10cSrcweir #include <sfx2/basedlgs.hxx> 46*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 47*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp> 50*cdf0e10cSrcweir #include <com/sun/star/beans/XMaterialHolder.hpp> 51*cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp> 52*cdf0e10cSrcweir #include <com/sun/star/container/XNameReplace.hpp> 53*cdf0e10cSrcweir #include <com/sun/star/task/XJobExecutor.hpp> 54*cdf0e10cSrcweir #include <comphelper/configurationhelper.hxx> 55*cdf0e10cSrcweir #include <rtl/bootstrap.hxx> 56*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 57*cdf0e10cSrcweir #include <osl/file.hxx> 58*cdf0e10cSrcweir #include <osl/thread.hxx> 59*cdf0e10cSrcweir #include <unotools/bootstrap.hxx> 60*cdf0e10cSrcweir #include <tools/config.hxx> 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir using namespace rtl; 63*cdf0e10cSrcweir using namespace osl; 64*cdf0e10cSrcweir using namespace utl; 65*cdf0e10cSrcweir using namespace svt; 66*cdf0e10cSrcweir using namespace com::sun::star; 67*cdf0e10cSrcweir using namespace com::sun::star::frame; 68*cdf0e10cSrcweir using namespace com::sun::star::lang; 69*cdf0e10cSrcweir using namespace com::sun::star::util; 70*cdf0e10cSrcweir using namespace com::sun::star::beans; 71*cdf0e10cSrcweir using namespace com::sun::star::uno; 72*cdf0e10cSrcweir using namespace com::sun::star::container; 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir #define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir namespace desktop { 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir static void _setBold(FixedText& ft) 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir Font f = ft.GetControlFont(); 81*cdf0e10cSrcweir f.SetWeight(WEIGHT_BOLD); 82*cdf0e10cSrcweir ft.SetControlFont(f); 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir WelcomePage::WelcomePage( svt::OWizardMachine* parent, const ResId& resid, sal_Bool bLicenseNeedsAcceptance ) 86*cdf0e10cSrcweir : OWizardPage(parent, resid) 87*cdf0e10cSrcweir , m_ftHead(this, WizardResId(FT_WELCOME_HEADER)) 88*cdf0e10cSrcweir , m_ftBody(this, WizardResId(FT_WELCOME_BODY)) 89*cdf0e10cSrcweir , m_pParent(parent) 90*cdf0e10cSrcweir , m_bLicenseNeedsAcceptance( bLicenseNeedsAcceptance ) 91*cdf0e10cSrcweir , bIsEvalVersion(false) 92*cdf0e10cSrcweir , bNoEvalText(false) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir FreeResource(); 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir _setBold(m_ftHead); 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir checkEval(); 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir // check for migration 101*cdf0e10cSrcweir if (Migration::checkMigration()) 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir String aText(WizardResId(STR_WELCOME_MIGRATION)); 104*cdf0e10cSrcweir // replace %OLDPRODUCT with found version name 105*cdf0e10cSrcweir aText.SearchAndReplaceAll( UniString::CreateFromAscii("%OLD_VERSION"), Migration::getOldVersionName()); 106*cdf0e10cSrcweir m_ftBody.SetText( aText ); 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir else if ( ! m_bLicenseNeedsAcceptance ) 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir String aText(WizardResId(STR_WELCOME_WITHOUT_LICENSE)); 111*cdf0e10cSrcweir m_ftBody.SetText( aText ); 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir void WelcomePage::checkEval() 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir Reference< XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); 119*cdf0e10cSrcweir Reference< XMaterialHolder > xHolder(xFactory->createInstance( 120*cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.tab.tabreg")), UNO_QUERY); 121*cdf0e10cSrcweir if (xHolder.is()) { 122*cdf0e10cSrcweir Any aData = xHolder->getMaterial(); 123*cdf0e10cSrcweir Sequence < NamedValue > aSeq; 124*cdf0e10cSrcweir if (aData >>= aSeq) { 125*cdf0e10cSrcweir bIsEvalVersion = true; 126*cdf0e10cSrcweir for (int i=0; i< aSeq.getLength(); i++) { 127*cdf0e10cSrcweir if (aSeq[i].Name.equalsAscii("NoEvalText")) { 128*cdf0e10cSrcweir aSeq[i].Value >>= bNoEvalText; 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir void WelcomePage::ActivatePage() 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir OWizardPage::ActivatePage(); 139*cdf0e10cSrcweir // this page has no controls, so forwarding to default 140*cdf0e10cSrcweir // button (next) won't work if we grap focus 141*cdf0e10cSrcweir // GrabFocus(); 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir LicensePage::LicensePage( svt::OWizardMachine* parent, const ResId& resid, const rtl::OUString &rLicensePath ) 145*cdf0e10cSrcweir : OWizardPage(parent, resid) 146*cdf0e10cSrcweir , m_pParent(parent) 147*cdf0e10cSrcweir , m_ftHead(this, WizardResId(FT_LICENSE_HEADER)) 148*cdf0e10cSrcweir , m_ftBody1(this, WizardResId(FT_LICENSE_BODY_1)) 149*cdf0e10cSrcweir , m_ftBody1Txt(this, WizardResId(FT_LICENSE_BODY_1_TXT)) 150*cdf0e10cSrcweir , m_ftBody2(this, WizardResId(FT_LICENSE_BODY_2)) 151*cdf0e10cSrcweir , m_ftBody2Txt(this, WizardResId(FT_LICENSE_BODY_2_TXT)) 152*cdf0e10cSrcweir , m_mlLicense(this, WizardResId(ML_LICENSE)) 153*cdf0e10cSrcweir , m_pbDown(this, WizardResId(PB_LICENSE_DOWN)) 154*cdf0e10cSrcweir , m_bLicenseRead(sal_False) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir FreeResource(); 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir _setBold(m_ftHead); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir m_mlLicense.SetEndReachedHdl( LINK(this, LicensePage, EndReachedHdl) ); 161*cdf0e10cSrcweir m_mlLicense.SetScrolledHdl( LINK(this, LicensePage, ScrolledHdl) ); 162*cdf0e10cSrcweir m_pbDown.SetClickHdl( LINK(this, LicensePage, PageDownHdl) ); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir // We want a automatic repeating page down button 165*cdf0e10cSrcweir WinBits aStyle = m_pbDown.GetStyle(); 166*cdf0e10cSrcweir aStyle |= WB_REPEAT; 167*cdf0e10cSrcweir m_pbDown.SetStyle( aStyle ); 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir // replace %PAGEDOWN in text2 with button text 170*cdf0e10cSrcweir String aText = m_ftBody1Txt.GetText(); 171*cdf0e10cSrcweir aText.SearchAndReplaceAll( UniString::CreateFromAscii("%PAGEDOWN"), 172*cdf0e10cSrcweir MnemonicGenerator::EraseAllMnemonicChars(m_pbDown.GetText())); 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir m_ftBody1Txt.SetText( aText ); 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir // load license text 177*cdf0e10cSrcweir File aLicenseFile(rLicensePath); 178*cdf0e10cSrcweir if ( aLicenseFile.open(OpenFlag_Read) == FileBase::E_None) 179*cdf0e10cSrcweir { 180*cdf0e10cSrcweir DirectoryItem d; 181*cdf0e10cSrcweir DirectoryItem::get(rLicensePath, d); 182*cdf0e10cSrcweir FileStatus fs(FileStatusMask_FileSize); 183*cdf0e10cSrcweir d.getFileStatus(fs); 184*cdf0e10cSrcweir sal_uInt64 nBytesRead = 0; 185*cdf0e10cSrcweir sal_uInt64 nPosition = 0; 186*cdf0e10cSrcweir sal_uInt32 nBytes = (sal_uInt32)fs.getFileSize(); 187*cdf0e10cSrcweir sal_Char *pBuffer = new sal_Char[nBytes]; 188*cdf0e10cSrcweir // FileBase RC r = FileBase::E_None; 189*cdf0e10cSrcweir while (aLicenseFile.read(pBuffer+nPosition, nBytes-nPosition, nBytesRead) == FileBase::E_None 190*cdf0e10cSrcweir && nPosition + nBytesRead < nBytes) 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir nPosition += nBytesRead; 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir OUString aLicenseString(pBuffer, nBytes, RTL_TEXTENCODING_UTF8, 195*cdf0e10cSrcweir OSTRING_TO_OUSTRING_CVTFLAGS | RTL_TEXTTOUNICODE_FLAGS_GLOBAL_SIGNATURE); 196*cdf0e10cSrcweir delete[] pBuffer; 197*cdf0e10cSrcweir m_mlLicense.SetText(aLicenseString); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir void LicensePage::ActivatePage() 203*cdf0e10cSrcweir { 204*cdf0e10cSrcweir OWizardPage::ActivatePage(); 205*cdf0e10cSrcweir m_bLicenseRead = m_mlLicense.IsEndReached(); 206*cdf0e10cSrcweir m_pbDown.GrabFocus(); 207*cdf0e10cSrcweir updateDialogTravelUI(); 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir bool LicensePage::canAdvance() const 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir if (m_mlLicense.IsEndReached()) 213*cdf0e10cSrcweir const_cast< LicensePage* >( this )->m_pbDown.Disable(); 214*cdf0e10cSrcweir else 215*cdf0e10cSrcweir const_cast< LicensePage* >( this )->m_pbDown.Enable(); 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir return m_bLicenseRead; 218*cdf0e10cSrcweir } 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir IMPL_LINK( LicensePage, PageDownHdl, PushButton *, EMPTYARG ) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir m_mlLicense.ScrollDown( SCROLL_PAGEDOWN ); 223*cdf0e10cSrcweir return 0; 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir IMPL_LINK( LicensePage, EndReachedHdl, LicenseView *, EMPTYARG ) 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir m_bLicenseRead = sal_True; 229*cdf0e10cSrcweir updateDialogTravelUI(); 230*cdf0e10cSrcweir return 0; 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir IMPL_LINK( LicensePage, ScrolledHdl, LicenseView *, EMPTYARG ) 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir updateDialogTravelUI(); 236*cdf0e10cSrcweir return 0; 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir LicenseView::LicenseView( Window* pParent, const ResId& rResId ) 241*cdf0e10cSrcweir : MultiLineEdit( pParent, rResId ) 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir SetLeftMargin( 5 ); 244*cdf0e10cSrcweir mbEndReached = IsEndReached(); 245*cdf0e10cSrcweir StartListening( *GetTextEngine() ); 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir LicenseView::~LicenseView() 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir maEndReachedHdl = Link(); 251*cdf0e10cSrcweir maScrolledHdl = Link(); 252*cdf0e10cSrcweir EndListeningAll(); 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir void LicenseView::ScrollDown( ScrollType eScroll ) 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir ScrollBar* pScroll = GetVScrollBar(); 258*cdf0e10cSrcweir if ( pScroll ) 259*cdf0e10cSrcweir pScroll->DoScrollAction( eScroll ); 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir sal_Bool LicenseView::IsEndReached() const 263*cdf0e10cSrcweir { 264*cdf0e10cSrcweir sal_Bool bEndReached; 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir ExtTextView* pView = GetTextView(); 267*cdf0e10cSrcweir ExtTextEngine* pEdit = GetTextEngine(); 268*cdf0e10cSrcweir sal_uLong nHeight = pEdit->GetTextHeight(); 269*cdf0e10cSrcweir Size aOutSize = pView->GetWindow()->GetOutputSizePixel(); 270*cdf0e10cSrcweir Point aBottom( 0, aOutSize.Height() ); 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir if ( (sal_uLong) pView->GetDocPos( aBottom ).Y() >= nHeight - 1 ) 273*cdf0e10cSrcweir bEndReached = sal_True; 274*cdf0e10cSrcweir else 275*cdf0e10cSrcweir bEndReached = sal_False; 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir return bEndReached; 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir void LicenseView::Notify( SfxBroadcaster&, const SfxHint& rHint ) 281*cdf0e10cSrcweir { 282*cdf0e10cSrcweir if ( rHint.IsA( TYPE(TextHint) ) ) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir sal_Bool bLastVal = EndReached(); 285*cdf0e10cSrcweir sal_uLong nId = ((const TextHint&)rHint).GetId(); 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir if ( nId == TEXT_HINT_PARAINSERTED ) 288*cdf0e10cSrcweir { 289*cdf0e10cSrcweir if ( bLastVal ) 290*cdf0e10cSrcweir mbEndReached = IsEndReached(); 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir else if ( nId == TEXT_HINT_VIEWSCROLLED ) 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir if ( ! mbEndReached ) 295*cdf0e10cSrcweir mbEndReached = IsEndReached(); 296*cdf0e10cSrcweir maScrolledHdl.Call( this ); 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir if ( EndReached() && !bLastVal ) 300*cdf0e10cSrcweir { 301*cdf0e10cSrcweir maEndReachedHdl.Call( this ); 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir } 304*cdf0e10cSrcweir } 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir // ------------------------------------------------------------------- 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir class MigrationThread : public ::osl::Thread 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir public: 313*cdf0e10cSrcweir MigrationThread(); 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir virtual void SAL_CALL run(); 316*cdf0e10cSrcweir virtual void SAL_CALL onTerminated(); 317*cdf0e10cSrcweir }; 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir MigrationThread::MigrationThread() 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir void MigrationThread::run() 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir try 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir Migration::doMigration(); 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir catch ( uno::Exception& ) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir void MigrationThread::onTerminated() 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir // ------------------------------------------------------------------- 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir MigrationPage::MigrationPage( 341*cdf0e10cSrcweir svt::OWizardMachine* parent, 342*cdf0e10cSrcweir const ResId& resid, Throbber& i_throbber ) 343*cdf0e10cSrcweir : OWizardPage(parent, resid) 344*cdf0e10cSrcweir , m_ftHead(this, WizardResId(FT_MIGRATION_HEADER)) 345*cdf0e10cSrcweir , m_ftBody(this, WizardResId(FT_MIGRATION_BODY)) 346*cdf0e10cSrcweir , m_cbMigration(this, WizardResId(CB_MIGRATION)) 347*cdf0e10cSrcweir , m_rThrobber(i_throbber) 348*cdf0e10cSrcweir , m_bMigrationDone(sal_False) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir FreeResource(); 351*cdf0e10cSrcweir _setBold(m_ftHead); 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir // replace %OLDPRODUCT with found version name 354*cdf0e10cSrcweir String aText = m_ftBody.GetText(); 355*cdf0e10cSrcweir aText.SearchAndReplaceAll( UniString::CreateFromAscii("%OLDPRODUCT"), Migration::getOldVersionName()); 356*cdf0e10cSrcweir m_ftBody.SetText( aText ); 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir sal_Bool MigrationPage::commitPage( svt::WizardTypes::CommitPageReason _eReason ) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir if (_eReason == svt::WizardTypes::eTravelForward && m_cbMigration.IsChecked() && !m_bMigrationDone) 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir GetParent()->EnterWait(); 364*cdf0e10cSrcweir FirstStartWizard* pWizard = dynamic_cast< FirstStartWizard* >( GetParent() ); 365*cdf0e10cSrcweir if ( pWizard ) 366*cdf0e10cSrcweir pWizard->DisableButtonsWhileMigration(); 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir m_rThrobber.Show(); 369*cdf0e10cSrcweir m_rThrobber.start(); 370*cdf0e10cSrcweir MigrationThread* pMigThread = new MigrationThread(); 371*cdf0e10cSrcweir pMigThread->create(); 372*cdf0e10cSrcweir 373*cdf0e10cSrcweir while ( pMigThread->isRunning() ) 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir Application::Reschedule(); 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir m_rThrobber.stop(); 379*cdf0e10cSrcweir GetParent()->LeaveWait(); 380*cdf0e10cSrcweir // Next state will enable buttons - so no EnableButtons necessary! 381*cdf0e10cSrcweir m_rThrobber.Hide(); 382*cdf0e10cSrcweir pMigThread->join(); 383*cdf0e10cSrcweir delete pMigThread; 384*cdf0e10cSrcweir m_bMigrationDone = sal_True; 385*cdf0e10cSrcweir } 386*cdf0e10cSrcweir else 387*cdf0e10cSrcweir Migration::cancelMigration(); 388*cdf0e10cSrcweir return sal_True; 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir void MigrationPage::ActivatePage() 392*cdf0e10cSrcweir { 393*cdf0e10cSrcweir OWizardPage::ActivatePage(); 394*cdf0e10cSrcweir GrabFocus(); 395*cdf0e10cSrcweir } 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir UserPage::UserPage( svt::OWizardMachine* parent, const ResId& resid) 398*cdf0e10cSrcweir : OWizardPage(parent, resid) 399*cdf0e10cSrcweir , m_ftHead(this, WizardResId(FT_USER_HEADER)) 400*cdf0e10cSrcweir , m_ftBody(this, WizardResId(FT_USER_BODY)) 401*cdf0e10cSrcweir , m_ftFirst(this, WizardResId(FT_USER_FIRST)) 402*cdf0e10cSrcweir , m_edFirst(this, WizardResId(ED_USER_FIRST)) 403*cdf0e10cSrcweir , m_ftLast(this, WizardResId(FT_USER_LAST)) 404*cdf0e10cSrcweir , m_edLast(this, WizardResId(ED_USER_LAST)) 405*cdf0e10cSrcweir , m_ftInitials(this, WizardResId(FT_USER_INITIALS)) 406*cdf0e10cSrcweir , m_edInitials(this, WizardResId(ED_USER_INITIALS)) 407*cdf0e10cSrcweir , m_ftFather(this, WizardResId(FT_USER_FATHER)) 408*cdf0e10cSrcweir , m_edFather(this, WizardResId(ED_USER_FATHER)) 409*cdf0e10cSrcweir , m_lang(Application::GetSettings().GetUILanguage()) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir FreeResource(); 412*cdf0e10cSrcweir _setBold(m_ftHead); 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir // check whether this is a russian version. otherwise 415*cdf0e10cSrcweir // we'll hide the 'Fathers name' field 416*cdf0e10cSrcweir SvtUserOptions aUserOpt; 417*cdf0e10cSrcweir m_edFirst.SetText(aUserOpt.GetFirstName()); 418*cdf0e10cSrcweir m_edLast.SetText(aUserOpt.GetLastName()); 419*cdf0e10cSrcweir #if 0 420*cdf0e10cSrcweir rtl::OUString aUserName; 421*cdf0e10cSrcweir vos::OSecurity().getUserName( aUserName ); 422*cdf0e10cSrcweir aUserOpt.SetID( aUserName ); 423*cdf0e10cSrcweir #endif 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir m_edInitials.SetText(aUserOpt.GetID()); 426*cdf0e10cSrcweir if (m_lang == LANGUAGE_RUSSIAN) 427*cdf0e10cSrcweir { 428*cdf0e10cSrcweir m_ftFather.Show(); 429*cdf0e10cSrcweir m_edFather.Show(); 430*cdf0e10cSrcweir m_edFather.SetText(aUserOpt.GetFathersName()); 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir } 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir sal_Bool UserPage::commitPage( svt::WizardTypes::CommitPageReason ) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir SvtUserOptions aUserOpt; 437*cdf0e10cSrcweir aUserOpt.SetFirstName(m_edFirst.GetText()); 438*cdf0e10cSrcweir aUserOpt.SetLastName(m_edLast.GetText()); 439*cdf0e10cSrcweir aUserOpt.SetID( m_edInitials.GetText()); 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir if (m_lang == LANGUAGE_RUSSIAN) 442*cdf0e10cSrcweir aUserOpt.SetFathersName(m_edFather.GetText()); 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir return sal_True; 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir void UserPage::ActivatePage() 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir OWizardPage::ActivatePage(); 450*cdf0e10cSrcweir GrabFocus(); 451*cdf0e10cSrcweir } 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir // ------------------------------------------------------------------- 454*cdf0e10cSrcweir UpdateCheckPage::UpdateCheckPage( svt::OWizardMachine* parent, const ResId& resid) 455*cdf0e10cSrcweir : OWizardPage(parent, resid) 456*cdf0e10cSrcweir , m_ftHead(this, WizardResId(FT_UPDATE_CHECK_HEADER)) 457*cdf0e10cSrcweir , m_ftBody(this, WizardResId(FT_UPDATE_CHECK_BODY)) 458*cdf0e10cSrcweir , m_cbUpdateCheck(this, WizardResId(CB_UPDATE_CHECK)) 459*cdf0e10cSrcweir { 460*cdf0e10cSrcweir FreeResource(); 461*cdf0e10cSrcweir _setBold(m_ftHead); 462*cdf0e10cSrcweir } 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir sal_Bool UpdateCheckPage::commitPage( svt::WizardTypes::CommitPageReason _eReason ) 465*cdf0e10cSrcweir { 466*cdf0e10cSrcweir if ( _eReason == svt::WizardTypes::eTravelForward ) 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir try { 469*cdf0e10cSrcweir Reference < XNameReplace > xUpdateAccess; 470*cdf0e10cSrcweir Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir xUpdateAccess = Reference < XNameReplace >( 473*cdf0e10cSrcweir xFactory->createInstance( UNISTRING( "com.sun.star.setup.UpdateCheckConfig" ) ), UNO_QUERY_THROW ); 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir if ( !xUpdateAccess.is() ) 476*cdf0e10cSrcweir return sal_False; 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir sal_Bool bAutoUpdChk = m_cbUpdateCheck.IsChecked(); 479*cdf0e10cSrcweir xUpdateAccess->replaceByName( UNISTRING("AutoCheckEnabled"), makeAny( bAutoUpdChk ) ); 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir Reference< XChangesBatch > xChangesBatch( xUpdateAccess, UNO_QUERY); 482*cdf0e10cSrcweir if( xChangesBatch.is() && xChangesBatch->hasPendingChanges() ) 483*cdf0e10cSrcweir xChangesBatch->commitChanges(); 484*cdf0e10cSrcweir } catch (RuntimeException) 485*cdf0e10cSrcweir { 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir } 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir return sal_True; 490*cdf0e10cSrcweir } 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir void UpdateCheckPage::ActivatePage() 493*cdf0e10cSrcweir { 494*cdf0e10cSrcweir OWizardPage::ActivatePage(); 495*cdf0e10cSrcweir GrabFocus(); 496*cdf0e10cSrcweir } 497*cdf0e10cSrcweir 498*cdf0e10cSrcweir // ------------------------------------------------------------------- 499*cdf0e10cSrcweir RegistrationPage::RegistrationPage( Window* pParent, const ResId& rResid ) 500*cdf0e10cSrcweir : OWizardPage( pParent, rResid ) 501*cdf0e10cSrcweir , m_ftHeader(this, WizardResId(FT_REGISTRATION_HEADER)) 502*cdf0e10cSrcweir , m_ftBody(this, WizardResId(FT_REGISTRATION_BODY)) 503*cdf0e10cSrcweir , m_rbNow(this, WizardResId(RB_REGISTRATION_NOW)) 504*cdf0e10cSrcweir , m_rbLater(this, WizardResId(RB_REGISTRATION_LATER)) 505*cdf0e10cSrcweir , m_rbNever(this, WizardResId(RB_REGISTRATION_NEVER)) 506*cdf0e10cSrcweir , m_flSeparator(this, WizardResId(FL_REGISTRATION)) 507*cdf0e10cSrcweir , m_ftEnd(this, WizardResId(FT_REGISTRATION_END)) 508*cdf0e10cSrcweir , m_bNeverVisible( sal_True ) 509*cdf0e10cSrcweir { 510*cdf0e10cSrcweir FreeResource(); 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir // another text for OOo 513*cdf0e10cSrcweir sal_Int32 nOpenSourceContext = 0; 514*cdf0e10cSrcweir try 515*cdf0e10cSrcweir { 516*cdf0e10cSrcweir ::utl::ConfigManager::GetDirectConfigProperty( 517*cdf0e10cSrcweir ::utl::ConfigManager::OPENSOURCECONTEXT ) >>= nOpenSourceContext; 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir catch( Exception& ) 520*cdf0e10cSrcweir { 521*cdf0e10cSrcweir DBG_ERRORFILE( "RegistrationPage::RegistrationPage(): error while getting open source context" ); 522*cdf0e10cSrcweir } 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir if ( nOpenSourceContext > 0 ) 525*cdf0e10cSrcweir { 526*cdf0e10cSrcweir String sBodyText( WizardResId( STR_REGISTRATION_OOO ) ); 527*cdf0e10cSrcweir m_ftBody.SetText( sBodyText ); 528*cdf0e10cSrcweir } 529*cdf0e10cSrcweir 530*cdf0e10cSrcweir // calculate height of body text and rearrange the buttons 531*cdf0e10cSrcweir Size aSize = m_ftBody.GetSizePixel(); 532*cdf0e10cSrcweir Size aMinSize = m_ftBody.CalcMinimumSize( aSize.Width() ); 533*cdf0e10cSrcweir long nTxtH = aMinSize.Height(); 534*cdf0e10cSrcweir long nCtrlH = aSize.Height(); 535*cdf0e10cSrcweir long nDelta = ( nCtrlH - nTxtH ); 536*cdf0e10cSrcweir aSize.Height() -= nDelta; 537*cdf0e10cSrcweir m_ftBody.SetSizePixel( aSize ); 538*cdf0e10cSrcweir Window* pWins[] = { &m_rbNow, &m_rbLater, &m_rbNever }; 539*cdf0e10cSrcweir Window** pCurrent = pWins; 540*cdf0e10cSrcweir for ( sal_uInt32 i = 0; i < sizeof( pWins ) / sizeof( pWins[ 0 ] ); ++i, ++pCurrent ) 541*cdf0e10cSrcweir { 542*cdf0e10cSrcweir Point aNewPos = (*pCurrent)->GetPosPixel(); 543*cdf0e10cSrcweir aNewPos.Y() -= nDelta; 544*cdf0e10cSrcweir (*pCurrent)->SetPosPixel( aNewPos ); 545*cdf0e10cSrcweir } 546*cdf0e10cSrcweir 547*cdf0e10cSrcweir _setBold(m_ftHeader); 548*cdf0e10cSrcweir impl_retrieveConfigurationData(); 549*cdf0e10cSrcweir updateButtonStates(); 550*cdf0e10cSrcweir } 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir bool RegistrationPage::canAdvance() const 553*cdf0e10cSrcweir { 554*cdf0e10cSrcweir return false; 555*cdf0e10cSrcweir } 556*cdf0e10cSrcweir 557*cdf0e10cSrcweir void RegistrationPage::ActivatePage() 558*cdf0e10cSrcweir { 559*cdf0e10cSrcweir OWizardPage::ActivatePage(); 560*cdf0e10cSrcweir GrabFocus(); 561*cdf0e10cSrcweir } 562*cdf0e10cSrcweir 563*cdf0e10cSrcweir void RegistrationPage::impl_retrieveConfigurationData() 564*cdf0e10cSrcweir { 565*cdf0e10cSrcweir static ::rtl::OUString PACKAGE = ::rtl::OUString::createFromAscii("org.openoffice.FirstStartWizard"); 566*cdf0e10cSrcweir static ::rtl::OUString PATH = ::rtl::OUString::createFromAscii("TabPages/Registration/RegistrationOptions/NeverButton"); 567*cdf0e10cSrcweir static ::rtl::OUString KEY = ::rtl::OUString::createFromAscii("Visible"); 568*cdf0e10cSrcweir 569*cdf0e10cSrcweir ::com::sun::star::uno::Any aValue; 570*cdf0e10cSrcweir try 571*cdf0e10cSrcweir { 572*cdf0e10cSrcweir aValue = ::comphelper::ConfigurationHelper::readDirectKey( 573*cdf0e10cSrcweir ::comphelper::getProcessServiceFactory(), 574*cdf0e10cSrcweir PACKAGE, 575*cdf0e10cSrcweir PATH, 576*cdf0e10cSrcweir KEY, 577*cdf0e10cSrcweir ::comphelper::ConfigurationHelper::E_READONLY); 578*cdf0e10cSrcweir } 579*cdf0e10cSrcweir catch(const ::com::sun::star::uno::Exception&) 580*cdf0e10cSrcweir { aValue.clear(); } 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir aValue >>= m_bNeverVisible; 583*cdf0e10cSrcweir } 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir void RegistrationPage::updateButtonStates() 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir m_rbNever.Show( m_bNeverVisible ); 588*cdf0e10cSrcweir } 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir sal_Bool RegistrationPage::commitPage( svt::WizardTypes::CommitPageReason _eReason ) 591*cdf0e10cSrcweir { 592*cdf0e10cSrcweir if ( _eReason == svt::WizardTypes::eFinish ) 593*cdf0e10cSrcweir { 594*cdf0e10cSrcweir ::utl::RegOptions aOptions; 595*cdf0e10cSrcweir rtl::OUString aEvent; 596*cdf0e10cSrcweir 597*cdf0e10cSrcweir if ( m_rbNow.IsChecked()) 598*cdf0e10cSrcweir { 599*cdf0e10cSrcweir aEvent = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RegistrationRequired" ) ); 600*cdf0e10cSrcweir } 601*cdf0e10cSrcweir else if (m_rbLater.IsChecked()) 602*cdf0e10cSrcweir { 603*cdf0e10cSrcweir aOptions.activateReminder(7); 604*cdf0e10cSrcweir // avtivate a reminder job... 605*cdf0e10cSrcweir } 606*cdf0e10cSrcweir // aOptions.markSessionDone(); 607*cdf0e10cSrcweir 608*cdf0e10cSrcweir try 609*cdf0e10cSrcweir { 610*cdf0e10cSrcweir // create the Desktop component which can load components 611*cdf0e10cSrcweir Reference < XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); 612*cdf0e10cSrcweir if( xFactory.is() ) 613*cdf0e10cSrcweir { 614*cdf0e10cSrcweir Reference< com::sun::star::task::XJobExecutor > xProductRegistration( 615*cdf0e10cSrcweir xFactory->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.setup.ProductRegistration" ) ) ), 616*cdf0e10cSrcweir UNO_QUERY_THROW ); 617*cdf0e10cSrcweir 618*cdf0e10cSrcweir // tell it that the user wants to register 619*cdf0e10cSrcweir xProductRegistration->trigger( aEvent ); 620*cdf0e10cSrcweir } 621*cdf0e10cSrcweir } 622*cdf0e10cSrcweir catch( const Exception& ) 623*cdf0e10cSrcweir { 624*cdf0e10cSrcweir } 625*cdf0e10cSrcweir } 626*cdf0e10cSrcweir return sal_True; 627*cdf0e10cSrcweir } 628*cdf0e10cSrcweir 629*cdf0e10cSrcweir RegistrationPage::RegistrationMode RegistrationPage::getRegistrationMode() const 630*cdf0e10cSrcweir { 631*cdf0e10cSrcweir RegistrationPage::RegistrationMode eMode = rmNow; 632*cdf0e10cSrcweir if ( m_rbLater.IsChecked() ) 633*cdf0e10cSrcweir eMode = rmLater; 634*cdf0e10cSrcweir else if ( m_rbNever.IsChecked() ) 635*cdf0e10cSrcweir eMode = rmNever; 636*cdf0e10cSrcweir return eMode; 637*cdf0e10cSrcweir } 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir void RegistrationPage::prepareSingleMode() 640*cdf0e10cSrcweir { 641*cdf0e10cSrcweir // remove wizard text (hide and cut) 642*cdf0e10cSrcweir m_flSeparator.Hide(); 643*cdf0e10cSrcweir m_ftEnd.Hide(); 644*cdf0e10cSrcweir Size aNewSize = GetSizePixel(); 645*cdf0e10cSrcweir aNewSize.Height() -= ( aNewSize.Height() - m_flSeparator.GetPosPixel().Y() ); 646*cdf0e10cSrcweir SetSizePixel( aNewSize ); 647*cdf0e10cSrcweir } 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir bool RegistrationPage::hasReminderDateCome() 650*cdf0e10cSrcweir { 651*cdf0e10cSrcweir return ::utl::RegOptions().hasReminderDateCome(); 652*cdf0e10cSrcweir } 653*cdf0e10cSrcweir 654*cdf0e10cSrcweir void RegistrationPage::executeSingleMode() 655*cdf0e10cSrcweir { 656*cdf0e10cSrcweir // opens the page in a single tabdialog 657*cdf0e10cSrcweir SfxSingleTabDialog aSingleDlg( NULL, TP_REGISTRATION ); 658*cdf0e10cSrcweir RegistrationPage* pPage = new RegistrationPage( &aSingleDlg, WizardResId( TP_REGISTRATION ) ); 659*cdf0e10cSrcweir pPage->prepareSingleMode(); 660*cdf0e10cSrcweir aSingleDlg.SetPage( pPage ); 661*cdf0e10cSrcweir aSingleDlg.SetText( pPage->getSingleModeTitle() ); 662*cdf0e10cSrcweir aSingleDlg.Execute(); 663*cdf0e10cSrcweir // the registration modes "Now" and "Later" are handled by the page 664*cdf0e10cSrcweir RegistrationPage::RegistrationMode eMode = pPage->getRegistrationMode(); 665*cdf0e10cSrcweir if ( eMode == RegistrationPage::rmNow || eMode == RegistrationPage::rmLater ) 666*cdf0e10cSrcweir pPage->commitPage( WizardTypes::eFinish ); 667*cdf0e10cSrcweir if ( eMode != RegistrationPage::rmLater ) 668*cdf0e10cSrcweir ::utl::RegOptions().removeReminder(); 669*cdf0e10cSrcweir } 670*cdf0e10cSrcweir 671*cdf0e10cSrcweir } // namespace desktop 672