LCOV - code coverage report
Current view: top level - dbaccess/source/ext/macromigration - macromigrationpages.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 136 0.0 %
Date: 2014-04-14 Functions: 0 30 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             :     // MacroMigrationPage
      49           0 :     MacroMigrationPage::MacroMigrationPage( MacroMigrationDialog& _rParentDialog, const ResId& _rRes )
      50             :         :MacroMigrationPage_Base( &_rParentDialog, _rRes )
      51           0 :         ,m_aHeader( this, MacroMigrationResId( FT_HEADER ) )
      52             :     {
      53           0 :         Font aFont( m_aHeader.GetFont() );
      54           0 :         aFont.SetWeight( WEIGHT_BOLD );
      55           0 :         m_aHeader.SetFont( aFont );
      56           0 :     }
      57             : 
      58           0 :     MacroMigrationPage::~MacroMigrationPage()
      59             :     {
      60           0 :     }
      61             : 
      62           0 :     const MacroMigrationDialog& MacroMigrationPage::getDialog() const
      63             :     {
      64           0 :         return *dynamic_cast< const MacroMigrationDialog* >( GetParentDialog() );
      65             :     }
      66             : 
      67           0 :     MacroMigrationDialog& MacroMigrationPage::getDialog()
      68             :     {
      69           0 :         return *dynamic_cast< MacroMigrationDialog* >( GetParentDialog() );
      70             :     }
      71             : 
      72             :     // PreparationPage
      73           0 :     PreparationPage::PreparationPage( MacroMigrationDialog& _rParentDialog )
      74             :         :MacroMigrationPage( _rParentDialog, MacroMigrationResId( TP_PREPARE ) )
      75             :         ,m_aIntroduction ( this, MacroMigrationResId( FT_INTRODUCTION    ) )
      76           0 :         ,m_aCloseDocError( this, MacroMigrationResId( FT_CLOSE_DOC_ERROR ) )
      77             :     {
      78           0 :         FreeResource();
      79           0 :     }
      80             : 
      81           0 :     void PreparationPage::showCloseDocsError( bool _bShow )
      82             :     {
      83           0 :         m_aCloseDocError.Show( _bShow );
      84           0 :     }
      85             : 
      86           0 :     TabPage* PreparationPage::Create( ::svt::RoadmapWizard& _rParentDialog )
      87             :     {
      88           0 :         return new PreparationPage( dynamic_cast< MacroMigrationDialog& >( _rParentDialog ) );
      89             :     }
      90             : 
      91             :     // SaveDBDocPage
      92           0 :     SaveDBDocPage::SaveDBDocPage( MacroMigrationDialog& _rParentDialog )
      93             :         :MacroMigrationPage( _rParentDialog, MacroMigrationResId( TP_SAVE_DBDOC_AS ) )
      94             :         ,m_aExplanation         ( this, MacroMigrationResId( FT_EXPLANATION             ) )
      95             :         ,m_aSaveAsLabel         ( this, MacroMigrationResId( FT_SAVE_AS_LABEL           ) )
      96             :         ,m_aSaveAsLocation      ( this, MacroMigrationResId( ED_SAVE_AS_LOCATION        ) )
      97             :         ,m_aBrowseSaveAsLocation( this, MacroMigrationResId( PB_BROWSE_SAVE_AS_LOCATION ) )
      98             :         ,m_aStartMigration      ( this, MacroMigrationResId( FT_START_MIGRATION         ) )
      99           0 :         ,m_aLocationController( _rParentDialog.getComponentContext(), m_aSaveAsLocation, m_aBrowseSaveAsLocation )
     100             :     {
     101           0 :         FreeResource();
     102             : 
     103           0 :         m_aSaveAsLocation.SetModifyHdl( LINK( this, SaveDBDocPage, OnLocationModified ) );
     104           0 :         m_aSaveAsLocation.SetDropDownLineCount( 20 );
     105             : 
     106           0 :         m_aSaveAsLocation.SetHelpId( HID_MACRO_MIGRATION_BACKUP_LOCATION );
     107             : 
     108           0 :         impl_updateLocationDependentItems();
     109           0 :     }
     110             : 
     111           0 :     void SaveDBDocPage::impl_updateLocationDependentItems()
     112             :     {
     113           0 :         updateDialogTravelUI();
     114           0 :         m_aStartMigration.Show( !m_aSaveAsLocation.GetText().isEmpty() );
     115           0 :     }
     116             : 
     117           0 :     IMPL_LINK( SaveDBDocPage, OnLocationModified, Edit*, /**/ )
     118             :     {
     119           0 :         impl_updateLocationDependentItems();
     120           0 :         return 0L;
     121             :     }
     122             : 
     123           0 :     void SaveDBDocPage::initializePage()
     124             :     {
     125           0 :         OWizardPage::initializePage();
     126             : 
     127             :         try
     128             :         {
     129             :             // get the document's current URL
     130           0 :             Reference< XModel > xDocument( getDialog().getDocument(), UNO_QUERY_THROW );
     131           0 :             INetURLObject aURLParser( xDocument->getURL() );
     132             :             OSL_ENSURE( aURLParser.GetProtocol() != INET_PROT_NOT_VALID, "SaveDBDocPage::initializePage: illegal document URL!" );
     133             : 
     134           0 :             OUStringBuffer aBaseName( aURLParser.getBase() );
     135           0 :             aBaseName.appendAscii( ".backup" );
     136           0 :             aURLParser.setBase( aBaseName.makeStringAndClear() );
     137             : 
     138           0 :             m_aLocationController.setURL( aURLParser.GetMainURL( INetURLObject::NO_DECODE ) );
     139           0 :             impl_updateLocationDependentItems();
     140             :         }
     141           0 :         catch( const Exception& )
     142             :         {
     143             :             DBG_UNHANDLED_EXCEPTION();
     144             :         }
     145           0 :     }
     146             : 
     147           0 :     bool SaveDBDocPage::canAdvance() const
     148             :     {
     149           0 :         if ( !MacroMigrationPage::canAdvance() )
     150           0 :             return false;
     151             : 
     152           0 :         return !m_aSaveAsLocation.GetText().isEmpty();
     153             :     }
     154             : 
     155           0 :     bool SaveDBDocPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
     156             :     {
     157           0 :         if ( !MacroMigrationPage::commitPage( _eReason ) )
     158           0 :             return false;
     159             : 
     160           0 :         if ( ::svt::WizardTypes::eTravelBackward == _eReason )
     161           0 :             return true;
     162             : 
     163           0 :         if ( !m_aLocationController.prepareCommit() )
     164           0 :             return false;
     165             : 
     166           0 :         return true;
     167             :     }
     168             : 
     169           0 :     TabPage* SaveDBDocPage::Create( ::svt::RoadmapWizard& _rParentDialog )
     170             :     {
     171           0 :         return new SaveDBDocPage( dynamic_cast< MacroMigrationDialog& >( _rParentDialog ) );
     172             :     }
     173             : 
     174             :     // ProgressPage
     175           0 :     ProgressPage::ProgressPage( MacroMigrationDialog& _rParentDialog )
     176             :         :MacroMigrationPage( _rParentDialog, MacroMigrationResId( TP_MIGRATE ) )
     177             :         ,m_aObjectCount             ( this, MacroMigrationResId( FT_OBJECT_COUNT            ) )
     178             :         ,m_aCurrentObjectLabel      ( this, MacroMigrationResId( FT_CURRENT_OBJECT_LABEL    ) )
     179             :         ,m_aCurrentObject           ( this, MacroMigrationResId( FT_CURRENT_OBJECT          ) )
     180             :         ,m_aCurrentActionLabel      ( this, MacroMigrationResId( FT_CURRENT_PROGRESS_LABEL  ) )
     181             :         ,m_aCurrentAction           ( this, MacroMigrationResId( FT_CURRENT_PROGRESS        ) )
     182             :         ,m_aCurrentProgress         ( this, MacroMigrationResId( WND_CURRENT_PROGRESS       ) )
     183             :         ,m_aAllProgressLabel        ( this, MacroMigrationResId( FT_ALL_PROGRESS_LABEL      ) )
     184             :         ,m_aAllProgressText         ( this, MacroMigrationResId( FT_OBJECT_COUNT_PROGRESS   ) )
     185             :         ,m_aAllProgress             ( this, MacroMigrationResId( WND_ALL_PROGRESS           ) )
     186           0 :         ,m_aMigrationDone           ( this, MacroMigrationResId( FT_MIGRATION_DONE          ) )
     187             :     {
     188           0 :         FreeResource();
     189           0 :     }
     190             : 
     191           0 :     TabPage* ProgressPage::Create( ::svt::RoadmapWizard& _rParentDialog )
     192             :     {
     193           0 :         return new ProgressPage( dynamic_cast< MacroMigrationDialog& >( _rParentDialog ) );
     194             :     }
     195             : 
     196           0 :     void ProgressPage::setDocumentCounts( const sal_Int32 _nForms, const sal_Int32 _nReports )
     197             :     {
     198           0 :         OUString sText( m_aObjectCount.GetText() );
     199           0 :         sText = sText.replaceFirst( "$forms$", OUString::number( _nForms ) );
     200           0 :         sText = sText.replaceFirst( "$reports$", OUString::number( _nReports ) );
     201           0 :         m_aObjectCount.SetText( sText );
     202           0 :     }
     203             : 
     204           0 :     void ProgressPage::onFinishedSuccessfully()
     205             :     {
     206           0 :         m_aMigrationDone.Show();
     207           0 :     }
     208             : 
     209           0 :     void ProgressPage::startObject( const OUString& _rObjectName, const OUString& _rCurrentAction, const sal_uInt32 _nRange )
     210             :     {
     211           0 :         m_aCurrentObject.SetText( _rObjectName );
     212           0 :         m_aCurrentAction.SetText( _rCurrentAction );
     213           0 :         m_aCurrentProgress.SetRange( _nRange );
     214           0 :         m_aCurrentProgress.SetValue( (sal_uInt32)0 );
     215             : 
     216             :         // since this is currently called from the main thread, which does not have the chance
     217             :         // to re-schedule, we need to explicitly update the display
     218           0 :         m_aCurrentObject.Update();
     219           0 :         m_aCurrentAction.Update();
     220           0 :         Update();
     221           0 :     }
     222             : 
     223           0 :     void ProgressPage::setObjectProgressText( const OUString& _rText )
     224             :     {
     225           0 :         m_aCurrentAction.SetText( _rText );
     226           0 :         m_aCurrentAction.Update();
     227           0 :         Update();
     228           0 :     }
     229             : 
     230           0 :     void ProgressPage::setObjectProgressValue( const sal_uInt32 _nValue )
     231             :     {
     232           0 :         m_aCurrentProgress.SetValue( _nValue );
     233           0 :         Update();
     234           0 :     }
     235             : 
     236           0 :     void ProgressPage::endObject()
     237             :     {
     238           0 :         m_aCurrentAction.SetText( OUString() );
     239           0 :         m_aCurrentProgress.SetValue( m_aCurrentProgress.GetRange() );
     240           0 :         m_aCurrentAction.Update();
     241           0 :         Update();
     242           0 :     }
     243             : 
     244           0 :     void ProgressPage::start( const sal_uInt32 _nOverallRange )
     245             :     {
     246           0 :         m_aAllProgress.SetRange( _nOverallRange );
     247           0 :         Update();
     248           0 :     }
     249             : 
     250           0 :     void ProgressPage::setOverallProgressText( const OUString& _rText )
     251             :     {
     252           0 :         m_aAllProgressText.SetText( _rText );
     253           0 :         Update();
     254           0 :     }
     255             : 
     256           0 :     void ProgressPage::setOverallProgressValue( const sal_uInt32 _nValue )
     257             :     {
     258           0 :         m_aAllProgress.SetValue( _nValue );
     259           0 :         Update();
     260           0 :     }
     261             : 
     262             :     // ResultPage
     263           0 :     ResultPage::ResultPage( MacroMigrationDialog& _rParentDialog )
     264             :         :MacroMigrationPage( _rParentDialog, MacroMigrationResId( TP_SUMMARY ) )
     265             :         ,m_aChangesLabel( this, MacroMigrationResId( FT_CHANGES_LABEL ) )
     266             :         ,m_aChanges     ( this, MacroMigrationResId( ED_CHANGES       ) )
     267             :         ,m_aSuccessful  (       MacroMigrationResId( STR_SUCCESSFUL   ) )
     268           0 :         ,m_aUnsuccessful(       MacroMigrationResId( STR_UNSUCCESSFUL ) )
     269             :     {
     270           0 :         FreeResource();
     271           0 :     }
     272             : 
     273           0 :     TabPage* ResultPage::Create( ::svt::RoadmapWizard& _rParentDialog )
     274             :     {
     275           0 :         return new ResultPage( dynamic_cast< MacroMigrationDialog& >( _rParentDialog ) );
     276             :     }
     277             : 
     278           0 :     void ResultPage::displayMigrationLog( const bool _bSuccessful, const OUString& _rSummary )
     279             :     {
     280           0 :         m_aChangesLabel.SetText( _bSuccessful ? m_aSuccessful : m_aUnsuccessful );
     281           0 :         m_aChanges.SetText( _rSummary );
     282             : 
     283             :         // resize m_aChangesLabel and m_aChances as needed for the label text to fit
     284           0 :         Rectangle aOriginalLabelSize( m_aChangesLabel.GetPosPixel(), m_aChangesLabel.GetSizePixel() );
     285             :         // assume 3 lines, at most
     286           0 :         Rectangle aNewLabelSize( aOriginalLabelSize );
     287           0 :         aNewLabelSize.Bottom() = aNewLabelSize.Top() + m_aChangesLabel.LogicToPixel( Size( 0, 3*8 ), MAP_APPFONT ).Height();
     288           0 :         TextRectInfo aInfo;
     289           0 :         aNewLabelSize = m_aChangesLabel.GetTextRect( aNewLabelSize, m_aChangesLabel.GetText(), TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK, &aInfo );
     290           0 :         aNewLabelSize.Bottom() = aNewLabelSize.Top() + m_aChangesLabel.LogicToPixel( Size( 0, aInfo.GetLineCount() * 8 ), MAP_APPFONT ).Height();
     291             : 
     292           0 :         m_aChangesLabel.SetSizePixel( aNewLabelSize.GetSize() );
     293             : 
     294           0 :         long nChangesDiff = aNewLabelSize.GetHeight() - aOriginalLabelSize.GetHeight();
     295           0 :         Size aChangesSize( m_aChanges.GetSizePixel() );
     296           0 :         aChangesSize.Height() -= nChangesDiff;
     297           0 :         m_aChanges.SetSizePixel( aChangesSize );
     298             : 
     299           0 :         Point aChangesPos( m_aChanges.GetPosPixel() );
     300           0 :         aChangesPos.Y() += nChangesDiff;
     301           0 :         m_aChanges.SetPosPixel( aChangesPos );
     302           0 :     }
     303             : 
     304             : } // namespace dbmm
     305             : 
     306             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10