LCOV - code coverage report
Current view: top level - dbaccess/source/ext/macromigration - macromigrationpages.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 169 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 42 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 "dbaccess_helpid.hrc"
      21             : #include "dbmm_module.hxx"
      22             : #include "dbmm_global.hrc"
      23             : #include "macromigration.hrc"
      24             : #include "macromigrationpages.hxx"
      25             : #include "macromigrationdialog.hxx"
      26             : 
      27             : #include <com/sun/star/frame/XModel.hpp>
      28             : 
      29             : #include <tools/urlobj.hxx>
      30             : #include <tools/diagnose_ex.h>
      31             : #include <vcl/metric.hxx>
      32             : 
      33             : namespace dbmm
      34             : {
      35             : 
      36             :     using ::com::sun::star::uno::Reference;
      37             :     using ::com::sun::star::uno::XInterface;
      38             :     using ::com::sun::star::uno::UNO_QUERY;
      39             :     using ::com::sun::star::uno::UNO_QUERY_THROW;
      40             :     using ::com::sun::star::uno::UNO_SET_THROW;
      41             :     using ::com::sun::star::uno::Exception;
      42             :     using ::com::sun::star::uno::RuntimeException;
      43             :     using ::com::sun::star::uno::Any;
      44             :     using ::com::sun::star::uno::makeAny;
      45             :     using ::com::sun::star::uno::Sequence;
      46             :     using ::com::sun::star::frame::XModel;
      47             : 
      48           0 :     MacroMigrationPage::MacroMigrationPage(vcl::Window *pParent, const OString& rID, const OUString& rUIXMLDescription)
      49           0 :         : MacroMigrationPage_Base(pParent, rID, rUIXMLDescription)
      50             :     {
      51           0 :     }
      52             : 
      53           0 :     const MacroMigrationDialog& MacroMigrationPage::getDialog() const
      54             :     {
      55           0 :         return *dynamic_cast< const MacroMigrationDialog* >( GetParentDialog() );
      56             :     }
      57             : 
      58           0 :     MacroMigrationDialog& MacroMigrationPage::getDialog()
      59             :     {
      60           0 :         return *dynamic_cast< MacroMigrationDialog* >( GetParentDialog() );
      61             :     }
      62             : 
      63             :     // PreparationPage
      64           0 :     PreparationPage::PreparationPage(vcl::Window *pParent)
      65           0 :         : MacroMigrationPage(pParent, "PreparePage" ,"dbaccess/ui/preparepage.ui")
      66             :     {
      67           0 :         get(m_pCloseDocError, "closedocerror");
      68           0 :     }
      69             : 
      70           0 :     PreparationPage::~PreparationPage()
      71             :     {
      72           0 :         disposeOnce();
      73           0 :     }
      74             : 
      75           0 :     void PreparationPage::dispose()
      76             :     {
      77           0 :         m_pCloseDocError.clear();
      78           0 :         MacroMigrationPage::dispose();
      79           0 :     }
      80             : 
      81           0 :     void PreparationPage::showCloseDocsError( bool _bShow )
      82             :     {
      83           0 :         m_pCloseDocError->Show( _bShow );
      84           0 :     }
      85             : 
      86           0 :     VclPtr<TabPage> PreparationPage::Create( ::svt::RoadmapWizard& _rParentDialog )
      87             :     {
      88           0 :         return VclPtr<PreparationPage>::Create(&_rParentDialog);
      89             :     }
      90             : 
      91             :     // SaveDBDocPage
      92           0 :     SaveDBDocPage::SaveDBDocPage(MacroMigrationDialog& _rParentDialog)
      93           0 :         : MacroMigrationPage(&_rParentDialog, "BackupPage" ,"dbaccess/ui/backuppage.ui")
      94             :     {
      95           0 :         get(m_pStartMigration, "startmigrate");
      96           0 :         get(m_pBrowseSaveAsLocation, "browse");
      97           0 :         get(m_pSaveAsLocation, "location");
      98             :         m_pLocationController = new svx::DatabaseLocationInputController(
      99           0 :             _rParentDialog.getComponentContext(), *m_pSaveAsLocation, *m_pBrowseSaveAsLocation);
     100             : 
     101           0 :         m_pSaveAsLocation->SetModifyHdl( LINK( this, SaveDBDocPage, OnLocationModified ) );
     102           0 :         m_pSaveAsLocation->SetDropDownLineCount( 20 );
     103             : 
     104           0 :         impl_updateLocationDependentItems();
     105           0 :     }
     106             : 
     107           0 :     SaveDBDocPage::~SaveDBDocPage()
     108             :     {
     109           0 :         disposeOnce();
     110           0 :     }
     111             : 
     112           0 :     void SaveDBDocPage::dispose()
     113             :     {
     114           0 :         delete m_pLocationController;
     115           0 :         m_pSaveAsLocation.clear();
     116           0 :         m_pBrowseSaveAsLocation.clear();
     117           0 :         m_pStartMigration.clear();
     118           0 :         MacroMigrationPage::dispose();
     119           0 :     }
     120             : 
     121           0 :     void SaveDBDocPage::impl_updateLocationDependentItems()
     122             :     {
     123           0 :         updateDialogTravelUI();
     124           0 :         m_pStartMigration->Show(!m_pSaveAsLocation->GetText().isEmpty());
     125           0 :     }
     126             : 
     127           0 :     IMPL_LINK( SaveDBDocPage, OnLocationModified, Edit*, /**/ )
     128             :     {
     129           0 :         impl_updateLocationDependentItems();
     130           0 :         return 0L;
     131             :     }
     132             : 
     133           0 :     void SaveDBDocPage::initializePage()
     134             :     {
     135           0 :         OWizardPage::initializePage();
     136             : 
     137             :         try
     138             :         {
     139             :             // get the document's current URL
     140           0 :             Reference< XModel > xDocument( getDialog().getDocument(), UNO_QUERY_THROW );
     141           0 :             INetURLObject aURLParser( xDocument->getURL() );
     142             :             OSL_ENSURE( aURLParser.GetProtocol() != INetProtocol::NotValid, "SaveDBDocPage::initializePage: illegal document URL!" );
     143             : 
     144           0 :             OUStringBuffer aBaseName( aURLParser.getBase() );
     145           0 :             aBaseName.appendAscii( ".backup" );
     146           0 :             aURLParser.setBase( aBaseName.makeStringAndClear() );
     147             : 
     148           0 :             m_pLocationController->setURL( aURLParser.GetMainURL( INetURLObject::NO_DECODE ) );
     149           0 :             impl_updateLocationDependentItems();
     150             :         }
     151           0 :         catch( const Exception& )
     152             :         {
     153             :             DBG_UNHANDLED_EXCEPTION();
     154             :         }
     155           0 :     }
     156             : 
     157           0 :     bool SaveDBDocPage::canAdvance() const
     158             :     {
     159           0 :         if ( !MacroMigrationPage::canAdvance() )
     160           0 :             return false;
     161             : 
     162           0 :         return !m_pSaveAsLocation->GetText().isEmpty();
     163             :     }
     164             : 
     165           0 :     bool SaveDBDocPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
     166             :     {
     167           0 :         if ( !MacroMigrationPage::commitPage( _eReason ) )
     168           0 :             return false;
     169             : 
     170           0 :         if ( ::svt::WizardTypes::eTravelBackward == _eReason )
     171           0 :             return true;
     172             : 
     173           0 :         if ( !m_pLocationController->prepareCommit() )
     174           0 :             return false;
     175             : 
     176           0 :         return true;
     177             :     }
     178             : 
     179           0 :     VclPtr<TabPage> SaveDBDocPage::Create( ::svt::RoadmapWizard& _rParentDialog )
     180             :     {
     181           0 :         return VclPtr<SaveDBDocPage>::Create( dynamic_cast< MacroMigrationDialog& >( _rParentDialog ) );
     182             :     }
     183             : 
     184             :     // ProgressPage
     185           0 :     ProgressPage::ProgressPage(vcl::Window* pParent)
     186           0 :         : MacroMigrationPage(pParent, "MigratePage" ,"dbaccess/ui/migratepage.ui")
     187             :     {
     188           0 :         get(m_pObjectCount, "count");
     189           0 :         get(m_pCurrentObject, "object");
     190           0 :         get(m_pCurrentAction, "current");
     191           0 :         m_aCurrentProgress.Set(get<ProgressBar>("currentprogress"));
     192           0 :         get(m_pAllProgressText, "overall");
     193           0 :         m_aAllProgress.Set(get<ProgressBar>("allprogress"));
     194           0 :         get(m_pMigrationDone, "done");
     195           0 :     }
     196             : 
     197           0 :     ProgressPage::~ProgressPage()
     198             :     {
     199           0 :         disposeOnce();
     200           0 :     }
     201             : 
     202           0 :     void ProgressPage::dispose()
     203             :     {
     204           0 :         m_pObjectCount.clear();
     205           0 :         m_pCurrentObject.clear();
     206           0 :         m_pCurrentAction.clear();
     207           0 :         m_pAllProgressText.clear();
     208           0 :         m_pMigrationDone.clear();
     209           0 :         MacroMigrationPage::dispose();
     210           0 :     }
     211             : 
     212           0 :     VclPtr<TabPage> ProgressPage::Create(::svt::RoadmapWizard& _rParentDialog)
     213             :     {
     214           0 :         return VclPtr<ProgressPage>::Create(&_rParentDialog);
     215             :     }
     216             : 
     217           0 :     void ProgressPage::setDocumentCounts( const sal_Int32 _nForms, const sal_Int32 _nReports )
     218             :     {
     219           0 :         OUString sText( m_pObjectCount->GetText() );
     220           0 :         sText = sText.replaceFirst( "$forms$", OUString::number( _nForms ) );
     221           0 :         sText = sText.replaceFirst( "$reports$", OUString::number( _nReports ) );
     222           0 :         m_pObjectCount->SetText( sText );
     223           0 :     }
     224             : 
     225           0 :     void ProgressPage::onFinishedSuccessfully()
     226             :     {
     227           0 :         m_pMigrationDone->Show();
     228           0 :     }
     229             : 
     230           0 :     void ProgressPage::startObject( const OUString& _rObjectName, const OUString& _rCurrentAction, const sal_uInt32 _nRange )
     231             :     {
     232           0 :         m_pCurrentObject->SetText( _rObjectName );
     233           0 :         m_pCurrentAction->SetText( _rCurrentAction );
     234           0 :         m_aCurrentProgress.SetRange( _nRange );
     235           0 :         m_aCurrentProgress.SetValue( (sal_uInt32)0 );
     236             : 
     237             :         // since this is currently called from the main thread, which does not have the chance
     238             :         // to re-schedule, we need to explicitly update the display
     239           0 :         m_pCurrentObject->Update();
     240           0 :         m_pCurrentAction->Update();
     241           0 :         Update();
     242           0 :     }
     243             : 
     244           0 :     void ProgressPage::setObjectProgressText( const OUString& _rText )
     245             :     {
     246           0 :         m_pCurrentAction->SetText( _rText );
     247           0 :         m_pCurrentAction->Update();
     248           0 :         Update();
     249           0 :     }
     250             : 
     251           0 :     void ProgressPage::setObjectProgressValue( const sal_uInt32 _nValue )
     252             :     {
     253           0 :         m_aCurrentProgress.SetValue( _nValue );
     254           0 :         Update();
     255           0 :     }
     256             : 
     257           0 :     void ProgressPage::endObject()
     258             :     {
     259           0 :         m_pCurrentAction->SetText( OUString() );
     260           0 :         m_aCurrentProgress.SetValue( m_aCurrentProgress.GetRange() );
     261           0 :         m_pCurrentAction->Update();
     262           0 :         Update();
     263           0 :     }
     264             : 
     265           0 :     void ProgressPage::start( const sal_uInt32 _nOverallRange )
     266             :     {
     267           0 :         m_aAllProgress.SetRange( _nOverallRange );
     268           0 :         Update();
     269           0 :     }
     270             : 
     271           0 :     void ProgressPage::setOverallProgressText( const OUString& _rText )
     272             :     {
     273           0 :         m_pAllProgressText->SetText( _rText );
     274           0 :         Update();
     275           0 :     }
     276             : 
     277           0 :     void ProgressPage::setOverallProgressValue( const sal_uInt32 _nValue )
     278             :     {
     279           0 :         m_aAllProgress.SetValue( _nValue );
     280           0 :         Update();
     281           0 :     }
     282             : 
     283             :     // ResultPage
     284           0 :     ResultPage::ResultPage(vcl::Window* pParent)
     285           0 :         : MacroMigrationPage(pParent, "SummaryPage" ,"dbaccess/ui/summarypage.ui")
     286             :     {
     287           0 :         get(m_pChanges, "textview");
     288           0 :         m_pChanges->set_height_request(GetTextHeight() * 10);
     289           0 :         m_pChanges->set_width_request(approximate_char_width() * 40);
     290           0 :         get(m_pSuccessLabel, "success");
     291           0 :         get(m_pFailureLabel, "failure");
     292           0 :     }
     293             : 
     294           0 :     ResultPage::~ResultPage()
     295             :     {
     296           0 :         disposeOnce();
     297           0 :     }
     298             : 
     299           0 :     void ResultPage::dispose()
     300             :     {
     301           0 :         m_pSuccessLabel.clear();
     302           0 :         m_pFailureLabel.clear();
     303           0 :         m_pChanges.clear();
     304           0 :         MacroMigrationPage::dispose();
     305           0 :     }
     306             : 
     307           0 :     VclPtr<TabPage> ResultPage::Create(::svt::RoadmapWizard& _rParentDialog)
     308             :     {
     309           0 :         return VclPtr<ResultPage>::Create(&_rParentDialog);
     310             :     }
     311             : 
     312           0 :     void ResultPage::displayMigrationLog(const bool _bSuccessful, const OUString& _rSummary)
     313             :     {
     314           0 :         if (_bSuccessful)
     315           0 :             m_pFailureLabel->Hide();
     316             :         else
     317           0 :             m_pSuccessLabel->Hide();
     318           0 :         m_pChanges->SetText(_rSummary);
     319           0 :     }
     320             : 
     321           0 : } // namespace dbmm
     322             : 
     323             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11