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

Generated by: LCOV version 1.10