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

Generated by: LCOV version 1.10