LCOV - code coverage report
Current view: top level - dbaccess/source/ext/macromigration - macromigrationwizard.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 54 0.0 %
Date: 2014-04-14 Functions: 0 16 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 "dbmm_module.hxx"
      21             : #include "dbmm_global.hrc"
      22             : #include "macromigrationdialog.hxx"
      23             : 
      24             : #include <com/sun/star/ucb/AlreadyInitializedException.hpp>
      25             : #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
      26             : #include <com/sun/star/frame/XStorable.hpp>
      27             : 
      28             : #include <svtools/genericunodialog.hxx>
      29             : 
      30             : namespace dbmm
      31             : {
      32             : 
      33             :     using ::com::sun::star::uno::Reference;
      34             :     using ::com::sun::star::uno::XInterface;
      35             :     using ::com::sun::star::uno::UNO_QUERY;
      36             :     using ::com::sun::star::uno::UNO_QUERY_THROW;
      37             :     using ::com::sun::star::uno::UNO_SET_THROW;
      38             :     using ::com::sun::star::uno::Exception;
      39             :     using ::com::sun::star::uno::RuntimeException;
      40             :     using ::com::sun::star::uno::Any;
      41             :     using ::com::sun::star::uno::makeAny;
      42             :     using ::com::sun::star::uno::XComponentContext;
      43             :     using ::com::sun::star::uno::Sequence;
      44             :     using ::com::sun::star::beans::XPropertySetInfo;
      45             :     using ::com::sun::star::beans::Property;
      46             :     using ::com::sun::star::ucb::AlreadyInitializedException;
      47             :     using ::com::sun::star::sdb::XOfficeDatabaseDocument;
      48             :     using ::com::sun::star::lang::IllegalArgumentException;
      49             :     using ::com::sun::star::frame::XStorable;
      50             : 
      51             :     // MacroMigrationDialogService
      52             :     class MacroMigrationDialogService;
      53             :     typedef ::svt::OGenericUnoDialog                                                MacroMigrationDialogService_Base;
      54             :     typedef ::comphelper::OPropertyArrayUsageHelper< MacroMigrationDialogService >  MacroMigrationDialogService_PBase;
      55             : 
      56             :     class MacroMigrationDialogService
      57             :                 :public MacroMigrationDialogService_Base
      58             :                 ,public MacroMigrationDialogService_PBase
      59             :                 ,public MacroMigrationModuleClient
      60             :     {
      61             :     public:
      62             :         MacroMigrationDialogService( const Reference< XComponentContext >& _rxContext );
      63             : 
      64             :         // XTypeProvider
      65             :         virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(RuntimeException, std::exception) SAL_OVERRIDE;
      66             : 
      67             :         // XServiceInfo
      68             :         virtual OUString SAL_CALL getImplementationName() throw(RuntimeException, std::exception) SAL_OVERRIDE;
      69             :         virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException, std::exception) SAL_OVERRIDE;
      70             : 
      71             :         // XInitialization
      72             :         virtual void SAL_CALL initialize( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments ) throw(com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      73             : 
      74             :         // XPropertySet
      75             :         virtual Reference< XPropertySetInfo >  SAL_CALL getPropertySetInfo() throw(RuntimeException, std::exception) SAL_OVERRIDE;
      76             :         virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE;
      77             : 
      78             :         // OPropertyArrayUsageHelper
      79             :         virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE;
      80             : 
      81             :         // helper for factories
      82             :         static Reference< XInterface > SAL_CALL Create( const Reference< XComponentContext >& _rxContext );
      83             :         static OUString SAL_CALL getImplementationName_static() throw(RuntimeException);
      84             :         static Sequence< OUString > SAL_CALL getSupportedServiceNames_static() throw(RuntimeException);
      85             : 
      86             :     protected:
      87             :         virtual ~MacroMigrationDialogService();
      88             : 
      89             :     protected:
      90             :         virtual Dialog* createDialog( Window* _pParent ) SAL_OVERRIDE;
      91             :         virtual void destroyDialog() SAL_OVERRIDE;
      92             : 
      93             :     private:
      94             :         Reference<XComponentContext>          m_aContext;
      95             :         Reference< XOfficeDatabaseDocument >    m_xDocument;
      96             :     };
      97             : 
      98             :     // MacroMigrationDialogService
      99           0 :     MacroMigrationDialogService::MacroMigrationDialogService( const Reference< XComponentContext >& _rxContext )
     100             :         :MacroMigrationDialogService_Base( _rxContext )
     101           0 :         ,m_aContext( _rxContext )
     102             :     {
     103           0 :         m_bNeedInitialization = true;
     104           0 :     }
     105             : 
     106           0 :     MacroMigrationDialogService::~MacroMigrationDialogService()
     107             :     {
     108             :         // we do this here cause the base class' call to destroyDialog won't reach us anymore : we're within an dtor,
     109             :         // so this virtual-method-call the base class does does not work, we're already dead then ...
     110           0 :         if ( m_pDialog )
     111             :         {
     112           0 :             ::osl::MutexGuard aGuard( m_aMutex );
     113           0 :             if ( m_pDialog )
     114           0 :                 destroyDialog();
     115             :         }
     116           0 :     }
     117             : 
     118           0 :     Reference< XInterface > SAL_CALL MacroMigrationDialogService::Create( const Reference< XComponentContext >& _rxContext )
     119             :     {
     120           0 :         return *(new MacroMigrationDialogService( _rxContext ) );
     121             :     }
     122             : 
     123           0 :     Dialog* MacroMigrationDialogService::createDialog( Window* _pParent )
     124             :     {
     125           0 :         return new MacroMigrationDialog( _pParent, m_aContext, m_xDocument );
     126             :     }
     127             : 
     128           0 :     void MacroMigrationDialogService::destroyDialog()
     129             :     {
     130           0 :         MacroMigrationDialogService_Base::destroyDialog();
     131           0 :     }
     132             : 
     133           0 :     Sequence< sal_Int8 > SAL_CALL MacroMigrationDialogService::getImplementationId() throw(RuntimeException, std::exception)
     134             :     {
     135           0 :         return css::uno::Sequence<sal_Int8>();
     136             :     }
     137             : 
     138           0 :     OUString SAL_CALL MacroMigrationDialogService::getImplementationName_static() throw(RuntimeException)
     139             :     {
     140           0 :         return OUString( "com.sun.star.comp.dbaccess.macromigration.MacroMigrationDialogService" );
     141             :     }
     142             : 
     143           0 :     Sequence< OUString > SAL_CALL MacroMigrationDialogService::getSupportedServiceNames_static() throw(RuntimeException)
     144             :     {
     145           0 :         Sequence< OUString > aServices(1);
     146           0 :         aServices[0] = "com.sun.star.sdb.application.MacroMigrationWizard";
     147           0 :         return aServices;
     148             :     }
     149             : 
     150           0 :     OUString SAL_CALL MacroMigrationDialogService::getImplementationName() throw(RuntimeException, std::exception)
     151             :     {
     152           0 :         return getImplementationName_static();
     153             :     }
     154             : 
     155           0 :     Sequence< OUString > SAL_CALL MacroMigrationDialogService::getSupportedServiceNames() throw(RuntimeException, std::exception)
     156             :     {
     157           0 :         return getSupportedServiceNames_static();
     158             :     }
     159             : 
     160           0 :     void SAL_CALL MacroMigrationDialogService::initialize( const Sequence< Any >& _rArguments ) throw(Exception, RuntimeException, std::exception)
     161             :     {
     162           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     163           0 :         if ( m_bInitialized )
     164           0 :             throw AlreadyInitializedException( OUString(), *this );
     165             : 
     166           0 :         if ( _rArguments.getLength() != 1 )
     167             :             throw IllegalArgumentException(
     168             :                 OUString(MacroMigrationResId(STR_INVALID_NUMBER_ARGS)),
     169             :                 *this,
     170             :                 1
     171           0 :             );
     172             : 
     173           0 :         m_xDocument.set( _rArguments[0], UNO_QUERY );
     174           0 :         if ( !m_xDocument.is() )
     175             :             throw IllegalArgumentException(
     176             :                 OUString(MacroMigrationResId(STR_NO_DATABASE)),
     177             :                 *this,
     178             :                 1
     179           0 :             );
     180             : 
     181           0 :         Reference< XStorable > xDocStor( m_xDocument, UNO_QUERY_THROW );
     182           0 :         if ( xDocStor->isReadonly() )
     183             :             throw IllegalArgumentException(
     184             :                 OUString(MacroMigrationResId(STR_NOT_READONLY)),
     185             :                 *this,
     186             :                 1
     187           0 :             );
     188             : 
     189           0 :         m_bInitialized = true;
     190           0 :     }
     191             : 
     192           0 :     Reference< XPropertySetInfo > SAL_CALL MacroMigrationDialogService::getPropertySetInfo() throw(RuntimeException, std::exception)
     193             :     {
     194           0 :         return createPropertySetInfo( getInfoHelper() );
     195             :     }
     196             : 
     197           0 :     ::cppu::IPropertyArrayHelper& SAL_CALL MacroMigrationDialogService::getInfoHelper()
     198             :     {
     199           0 :         return *const_cast< MacroMigrationDialogService* >( this )->getArrayHelper();
     200             :     }
     201             : 
     202           0 :     ::cppu::IPropertyArrayHelper* MacroMigrationDialogService::createArrayHelper( ) const
     203             :     {
     204           0 :         Sequence< Property > aProps;
     205           0 :         describeProperties( aProps );
     206           0 :         return new ::cppu::OPropertyArrayHelper( aProps );
     207             :     }
     208             : 
     209           0 :     void createRegistryInfo_MacroMigrationDialogService()
     210             :     {
     211           0 :         static OAutoRegistration< MacroMigrationDialogService > aAutoRegistration;
     212           0 :     }
     213             : 
     214             : } // namespace dbmm
     215             : 
     216             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10